Remove low RAM special casing for heap growth multiplier

Moved to change the default value in runtime.cc. This enables
changing the value by passing in a
-XX:ForegroundHeapGrowthMultiplier value.

This enables devices to set the foreground heap growth multiplier
to non 1.0 values even when low_memory_mode is true. Doing this
reduces GC frequency and can help device performance.

Increased the limit to 5.0 since the old limit of 1.0 was bogus.

Bug: 67416130
Test: test-art-host
Test: make and flash

Change-Id: I86166830261c034255c23611cb8f4ebcf8c43b09
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index f1685b2..6129181 100644
--- a/runtime/gc/heap.cc
+++ b/runtime/gc/heap.cc
@@ -132,10 +132,6 @@
 // Dump the rosalloc stats on SIGQUIT.
 static constexpr bool kDumpRosAllocStatsOnSigQuit = false;
 
-// Extra added to the heap growth multiplier. Used to adjust the GC ergonomics for the read barrier
-// config.
-static constexpr double kExtraHeapGrowthMultiplier = kUseReadBarrier ? 1.0 : 0.0;
-
 static const char* kRegionSpaceName = "main space (region space)";
 
 // If true, we log all GCs in the both the foreground and background. Used for debugging.
@@ -255,8 +251,7 @@
       min_free_(min_free),
       max_free_(max_free),
       target_utilization_(target_utilization),
-      foreground_heap_growth_multiplier_(
-          foreground_heap_growth_multiplier + kExtraHeapGrowthMultiplier),
+      foreground_heap_growth_multiplier_(foreground_heap_growth_multiplier),
       total_wait_time_(0),
       verify_object_mode_(kVerifyObjectModeDisabled),
       disable_moving_gc_count_(0),
@@ -3428,7 +3423,7 @@
 
 double Heap::HeapGrowthMultiplier() const {
   // If we don't care about pause times we are background, so return 1.0.
-  if (!CareAboutPauseTimes() || IsLowMemoryMode()) {
+  if (!CareAboutPauseTimes()) {
     return 1.0;
   }
   return foreground_heap_growth_multiplier_;
diff --git a/runtime/parsed_options.cc b/runtime/parsed_options.cc
index 08768dd..5d2f3b2 100644
--- a/runtime/parsed_options.cc
+++ b/runtime/parsed_options.cc
@@ -121,7 +121,7 @@
           .WithType<double>().WithRange(0.1, 0.9)
           .IntoKey(M::HeapTargetUtilization)
       .Define("-XX:ForegroundHeapGrowthMultiplier=_")
-          .WithType<double>().WithRange(0.1, 1.0)
+          .WithType<double>().WithRange(0.1, 5.0)
           .IntoKey(M::ForegroundHeapGrowthMultiplier)
       .Define("-XX:ParallelGCThreads=_")
           .WithType<unsigned int>()
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 5c26392..c855906 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -171,6 +171,11 @@
 static constexpr double kLowMemoryMaxLoadFactor = 0.8;
 static constexpr double kNormalMinLoadFactor = 0.4;
 static constexpr double kNormalMaxLoadFactor = 0.7;
+
+// Extra added to the default heap growth multiplier. Used to adjust the GC ergonomics for the read
+// barrier config.
+static constexpr double kExtraDefaultHeapGrowthMultiplier = kUseReadBarrier ? 1.0 : 0.0;
+
 Runtime* Runtime::instance_ = nullptr;
 
 struct TraceConfig {
@@ -1144,13 +1149,22 @@
   //   agents_.push_back(lib);
   // }
 
+  float foreground_heap_growth_multiplier;
+  if (is_low_memory_mode_ && !runtime_options.Exists(Opt::ForegroundHeapGrowthMultiplier)) {
+    // If low memory mode, use 1.0 as the multiplier by default.
+    foreground_heap_growth_multiplier = 1.0f;
+  } else {
+    foreground_heap_growth_multiplier =
+        runtime_options.GetOrDefault(Opt::ForegroundHeapGrowthMultiplier) +
+            kExtraDefaultHeapGrowthMultiplier;
+  }
   XGcOption xgc_option = runtime_options.GetOrDefault(Opt::GcOption);
   heap_ = new gc::Heap(runtime_options.GetOrDefault(Opt::MemoryInitialSize),
                        runtime_options.GetOrDefault(Opt::HeapGrowthLimit),
                        runtime_options.GetOrDefault(Opt::HeapMinFree),
                        runtime_options.GetOrDefault(Opt::HeapMaxFree),
                        runtime_options.GetOrDefault(Opt::HeapTargetUtilization),
-                       runtime_options.GetOrDefault(Opt::ForegroundHeapGrowthMultiplier),
+                       foreground_heap_growth_multiplier,
                        runtime_options.GetOrDefault(Opt::MemoryMaximumSize),
                        runtime_options.GetOrDefault(Opt::NonMovingSpaceCapacity),
                        runtime_options.GetOrDefault(Opt::Image),