Space trim and other unit tests. General space clean up.

The space unit tests now include checks on space invariants, in
particular relating to footprint and size.
Out-of-date comments have been removed.
This patch adds PrettySize and PrettyDuration methods to make these
strings more human readable.

Change-Id: I6bc05b2db0d0115b97d666b832fce57bcdd2e091
diff --git a/src/heap.h b/src/heap.h
index 678f876..ebb1c85 100644
--- a/src/heap.h
+++ b/src/heap.h
@@ -89,7 +89,8 @@
   // Implements VMDebug.countInstancesOfClass.
   static int64_t CountInstances(Class* c, bool count_assignable);
 
-  // Implements dalvik.system.VMRuntime.clearGrowthLimit.
+  // Removes the growth limit on the alloc space so it may grow to its maximum capacity. Used to
+  // implement dalvik.system.VMRuntime.clearGrowthLimit.
   static void ClearGrowthLimit();
 
   // Target ideal heap utilization ratio, implements
@@ -104,8 +105,9 @@
     DCHECK_LT(target, 1.0f);
     target_utilization_ = target;
   }
-  // Sets the maximum number of bytes that the heap is allowed to allocate
-  // from the system.  Clamps to the appropriate maximum value.
+
+  // For the alloc space, sets the maximum number of bytes that the heap is allowed to allocate
+  // from the system. Doesn't allow the space to exceed its growth limit.
   static void SetIdealFootprint(size_t max_allowed_footprint);
 
   // Blocks the caller until the garbage collector becomes idle.
@@ -221,6 +223,9 @@
 
   static void CollectGarbageInternal(bool clear_soft_references);
 
+  // Given the current contents of the alloc space, increase the allowed heap footprint to match
+  // the target utilization ratio.  This should only be called immediately after a full garbage
+  // collection.
   static void GrowForUtilization();
 
   static void AddSpace(Space* space) {
@@ -283,6 +288,8 @@
   static bool verify_objects_;
 
   FRIEND_TEST(SpaceTest, AllocAndFree);
+  FRIEND_TEST(SpaceTest, AllocAndFreeList);
+  friend class SpaceTest;
 
   DISALLOW_IMPLICIT_CONSTRUCTORS(Heap);
 };