Added support for -XX:HeapGrowthLimit switch

Runtime can now take in a growth limit for the heap, which can be
smaller than the maximum size of the heap, and will prevent the heap
from growing beyond that size. The growth limit can also be cleared to
increase the size of the heap to the specified maximum size. This gives
apps some control of the size of the heap, but should be removed when we
have better ways to resize the heap.

Change-Id: I338655bccd20bfd32e2318365f0f3283dbaaab1e
diff --git a/src/heap.h b/src/heap.h
index 2e80571..5b71d18 100644
--- a/src/heap.h
+++ b/src/heap.h
@@ -46,7 +46,7 @@
   // image_file_names names specify Spaces to load based on
   // ImageWriter output.
   static void Init(bool is_verbose_heap, bool is_verbose_gc,
-                   size_t starting_size, size_t maximum_size,
+                   size_t starting_size, size_t maximum_size, size_t growth_size,
                    const std::vector<std::string>& image_file_names);
 
   static void Destroy();
@@ -91,9 +91,8 @@
   static int64_t CountInstances(Class* c, bool count_assignable);
 
   // Implements dalvik.system.VMRuntime.clearGrowthLimit.
-  static void ClearGrowthLimit() {
-    UNIMPLEMENTED(WARNING);
-  }
+  static void ClearGrowthLimit();
+
   // Implements dalvik.system.VMRuntime.getTargetHeapUtilization.
   static float GetTargetHeapUtilization() {
     return target_utilization_;
@@ -215,6 +214,13 @@
   // The maximum size of the heap in bytes.
   static size_t maximum_size_;
 
+  // The largest size the heap may grow. This value allows the app to limit the
+  // growth below the maximum size. This is a work around until we can
+  // dynamically set the maximum size. This value can range between the starting
+  // size and the maximum size but should never be set below the current
+  // footprint of the heap.
+  static size_t growth_size_;
+
   // True while the garbage collector is running.
   static bool is_gc_running_;