OSDN Git Service

Add gctype device config property for GC experiments
authorMathieu Chartier <mathieuc@google.com>
Mon, 28 Jan 2019 19:11:25 +0000 (11:11 -0800)
committerNicolas Geoffray <ngeoffray@google.com>
Mon, 25 Feb 2019 14:17:57 +0000 (14:17 +0000)
Added to the runtime_native namespace.

The new property overrides dalvik.vm.gctype if it's set.

Bug: 120794191
Test: adb shell device_config put runtime_native gctype CC,preverify
Test: adb reboot

(cherry picked from commit d2a975adb5b97be5e8f86a603666a66bdc934fd6)

Change-Id: I9ca29e9a5a0c94234fb14a725334dae82171679b
Merged-In: I30a2a3bcfb83f502f168c0d8588d80982a5f7d76

core/jni/Android.bp
core/jni/AndroidRuntime.cpp

index c385ca1..f9813fd 100644 (file)
@@ -290,6 +290,7 @@ cc_library_shared {
         "libhwui",
         "libdl",
         "libstatslog",
+        "server_configurable_flags",
     ],
 
     generated_sources: ["android_util_StatsLog.cpp"],
index 565fa6f..55fb27e 100644 (file)
@@ -31,6 +31,7 @@
 #include <binder/Parcel.h>
 #include <utils/threads.h>
 #include <cutils/properties.h>
+#include <server_configurable_flags/get_flags.h>
 
 #include <SkGraphics.h>
 
@@ -769,7 +770,17 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv, bool zygote)
       addOption("-XX:LowMemoryMode");
     }
 
-    parseRuntimeOption("dalvik.vm.gctype", gctypeOptsBuf, "-Xgc:");
+    std::string gc_type_override =
+            server_configurable_flags::GetServerConfigurableFlag("runtime_native", "gctype", "");
+    std::string gc_type_override_temp;
+    if (gc_type_override.empty()) {
+        parseRuntimeOption("dalvik.vm.gctype", gctypeOptsBuf, "-Xgc:");
+    } else {
+        // Copy the string so it doesn't go out of scope since addOption does not make a copy.
+        gc_type_override_temp = "-Xgc:" + gc_type_override;
+        addOption(gc_type_override_temp.c_str());
+    }
+
     parseRuntimeOption("dalvik.vm.backgroundgctype", backgroundgcOptsBuf, "-XX:BackgroundGC=");
 
     /*