Change native allocations to use growth limit.

Previously native allocation tracking used a GC footprint limit
which would cause GC in the allocating thread. This prevented
excessive growth of the heap but could cause jank due to GC in
the allocating thread. The new behavior is using the growth_limit
instead of the native footprint limit.

(cherry picked from commit d9819ecc0bc21a2bb356a4de9b013e36fe618627)

Change-Id: Ia40ed830e8c674cc49d4c0a6fd773d6cb8ff97fa
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index da08d36..d9d1e31 100644
--- a/runtime/gc/heap.cc
+++ b/runtime/gc/heap.cc
@@ -138,7 +138,6 @@
       growth_limit_(growth_limit),
       max_allowed_footprint_(initial_size),
       native_footprint_gc_watermark_(initial_size),
-      native_footprint_limit_(2 * initial_size),
       native_need_to_run_finalization_(false),
       // Initially assume we perceive jank in case the process state is never updated.
       process_state_(kProcessStateJankPerceptible),
@@ -2829,7 +2828,6 @@
     target_size = native_size + min_free_;
   }
   native_footprint_gc_watermark_ = target_size;
-  native_footprint_limit_ = 2 * target_size - native_size;
 }
 
 collector::GarbageCollector* Heap::FindCollectorByGcType(collector::GcType gc_type) {
@@ -3101,14 +3099,14 @@
 
     // The second watermark is higher than the gc watermark. If you hit this it means you are
     // allocating native objects faster than the GC can keep up with.
-    if (new_native_bytes_allocated > native_footprint_limit_) {
+    if (new_native_bytes_allocated > growth_limit_) {
       if (WaitForGcToComplete(kGcCauseForNativeAlloc, self) != collector::kGcTypeNone) {
         // Just finished a GC, attempt to run finalizers.
         RunFinalization(env);
         CHECK(!env->ExceptionCheck());
       }
       // If we still are over the watermark, attempt a GC for alloc and run finalizers.
-      if (new_native_bytes_allocated > native_footprint_limit_) {
+      if (new_native_bytes_allocated > growth_limit_) {
         CollectGarbageInternal(gc_type, kGcCauseForNativeAlloc, false);
         RunFinalization(env);
         native_need_to_run_finalization_ = false;
diff --git a/runtime/gc/heap.h b/runtime/gc/heap.h
index 8f55c46..a230f44 100644
--- a/runtime/gc/heap.h
+++ b/runtime/gc/heap.h
@@ -894,9 +894,6 @@
   // The watermark at which a concurrent GC is requested by registerNativeAllocation.
   size_t native_footprint_gc_watermark_;
 
-  // The watermark at which a GC is performed inside of registerNativeAllocation.
-  size_t native_footprint_limit_;
-
   // Whether or not we need to run finalizers in the next native allocation.
   bool native_need_to_run_finalization_;