Loading core/jni/AndroidRuntime.cpp +24 −13 Original line number Diff line number Diff line Loading @@ -222,8 +222,15 @@ extern int register_com_android_internal_util_VirtualRefBasePtr(JNIEnv *env); // Namespace for Android Runtime flags applied during boot time. static const char* RUNTIME_NATIVE_BOOT_NAMESPACE = "runtime_native_boot"; // Feature flag name for Garbage Collector type. static const char* GCTYPE = "gctype"; // Feature flag name to enable/disable generational garbage collection in ART's // Concurrent Copying (CC) garbage collector. static const char* ENABLE_GENERATIONAL_CC = "enable_generational_cc"; // Runtime option enabling generational garbage collection in ART's Concurrent // Copying (CC) garbage collector. static const char* kGenerationalCCRuntimeOption = "-Xgc:generational_cc"; // Runtime option disabling generational garbage collection in ART's Concurrent // Copying (CC) garbage collector. static const char* kNoGenerationalCCRuntimeOption = "-Xgc:nogenerational_cc"; static AndroidRuntime* gCurRuntime = NULL; Loading Loading @@ -775,17 +782,21 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv, bool zygote) addOption("-XX:LowMemoryMode"); } std::string gc_type_override = /* * Garbage-collection related options. */ parseRuntimeOption("dalvik.vm.gctype", gctypeOptsBuf, "-Xgc:"); // If it set, honor the "enable_generational_cc" device configuration; // otherwise, let the runtime use its default behavior. std::string enable_generational_cc = server_configurable_flags::GetServerConfigurableFlag(RUNTIME_NATIVE_BOOT_NAMESPACE, GCTYPE, ENABLE_GENERATIONAL_CC, /*default_value=*/ ""); 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()); if (enable_generational_cc == "true") { addOption(kGenerationalCCRuntimeOption); } else if (enable_generational_cc == "false") { addOption(kNoGenerationalCCRuntimeOption); } parseRuntimeOption("dalvik.vm.backgroundgctype", backgroundgcOptsBuf, "-XX:BackgroundGC="); Loading core/jni/runtime_native_boot-flags-test.sh +12 −10 Original line number Diff line number Diff line Loading @@ -172,12 +172,14 @@ function check_no_zygote_gc_runtime_option { done } # test_android_runtime_flag FLAG VALUE # ------------------------------------ # Test device configuration FLAG with VALUE. # test_android_runtime_flag FLAG VALUE GC_RUNTIME_OPTION # ------------------------------------------------------ # Test device configuration FLAG with VALUE. Check that GC_RUNTIME_OPTION is # passed as GC Runtime option by the zygote. function test_android_runtime_flag { local flag=$1 local value=$2 local gc_runtime_option=$3 # Persistent system property (set after a reboot) associated with the device # configuration flag. Loading @@ -196,21 +198,21 @@ function test_android_runtime_flag { local context="Flag set, before reboot" check_device_config_flag "$context" "$flag" "$value" check_system_property "$context" "$prop" "$value" check_no_zygote_gc_runtime_option "$context" "$value" check_no_zygote_gc_runtime_option "$context" "$gc_runtime_option" # Reboot device for the flag value to take effect. reboot_and_wait_for_device context="Flag set, after 1st reboot" check_device_config_flag "$context" "$flag" "$value" check_system_property "$context" "$prop" "$value" check_zygote_gc_runtime_option "$context" "$value" check_zygote_gc_runtime_option "$context" "$gc_runtime_option" # Reboot device a second time and check that the state has persisted. reboot_and_wait_for_device context="Flag set, after 2nd reboot" check_device_config_flag "$context" "$flag" "$value" check_system_property "$context" "$prop" "$value" check_zygote_gc_runtime_option "$context" "$value" check_zygote_gc_runtime_option "$context" "$gc_runtime_option" say "Unsetting device configuration flag..." adb shell device_config delete "$namespace" "$flag" >/dev/null Loading @@ -222,7 +224,7 @@ function test_android_runtime_flag { context="Flag unset, after 3rd reboot" check_no_device_config_flag "$context" "$flag" check_no_system_property "$context" "$prop" check_no_zygote_gc_runtime_option "$context" "$value" check_no_zygote_gc_runtime_option "$context" "$gc_runtime_option" } # Enumerate Zygote processes. Loading @@ -232,9 +234,9 @@ case $(adb shell getprop ro.zygote) in (zygote32_64|zygote64_32) zygotes="zygote zygote64";; esac # Test "gctype" flag values. test_android_runtime_flag gctype nogenerational_cc test_android_runtime_flag gctype generational_cc # Test "enable_generational_cc" flag values. test_android_runtime_flag enable_generational_cc false nogenerational_cc test_android_runtime_flag enable_generational_cc true generational_cc if [[ "$exit_status" -eq 0 ]]; then banner "All tests passed." Loading Loading
core/jni/AndroidRuntime.cpp +24 −13 Original line number Diff line number Diff line Loading @@ -222,8 +222,15 @@ extern int register_com_android_internal_util_VirtualRefBasePtr(JNIEnv *env); // Namespace for Android Runtime flags applied during boot time. static const char* RUNTIME_NATIVE_BOOT_NAMESPACE = "runtime_native_boot"; // Feature flag name for Garbage Collector type. static const char* GCTYPE = "gctype"; // Feature flag name to enable/disable generational garbage collection in ART's // Concurrent Copying (CC) garbage collector. static const char* ENABLE_GENERATIONAL_CC = "enable_generational_cc"; // Runtime option enabling generational garbage collection in ART's Concurrent // Copying (CC) garbage collector. static const char* kGenerationalCCRuntimeOption = "-Xgc:generational_cc"; // Runtime option disabling generational garbage collection in ART's Concurrent // Copying (CC) garbage collector. static const char* kNoGenerationalCCRuntimeOption = "-Xgc:nogenerational_cc"; static AndroidRuntime* gCurRuntime = NULL; Loading Loading @@ -775,17 +782,21 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv, bool zygote) addOption("-XX:LowMemoryMode"); } std::string gc_type_override = /* * Garbage-collection related options. */ parseRuntimeOption("dalvik.vm.gctype", gctypeOptsBuf, "-Xgc:"); // If it set, honor the "enable_generational_cc" device configuration; // otherwise, let the runtime use its default behavior. std::string enable_generational_cc = server_configurable_flags::GetServerConfigurableFlag(RUNTIME_NATIVE_BOOT_NAMESPACE, GCTYPE, ENABLE_GENERATIONAL_CC, /*default_value=*/ ""); 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()); if (enable_generational_cc == "true") { addOption(kGenerationalCCRuntimeOption); } else if (enable_generational_cc == "false") { addOption(kNoGenerationalCCRuntimeOption); } parseRuntimeOption("dalvik.vm.backgroundgctype", backgroundgcOptsBuf, "-XX:BackgroundGC="); Loading
core/jni/runtime_native_boot-flags-test.sh +12 −10 Original line number Diff line number Diff line Loading @@ -172,12 +172,14 @@ function check_no_zygote_gc_runtime_option { done } # test_android_runtime_flag FLAG VALUE # ------------------------------------ # Test device configuration FLAG with VALUE. # test_android_runtime_flag FLAG VALUE GC_RUNTIME_OPTION # ------------------------------------------------------ # Test device configuration FLAG with VALUE. Check that GC_RUNTIME_OPTION is # passed as GC Runtime option by the zygote. function test_android_runtime_flag { local flag=$1 local value=$2 local gc_runtime_option=$3 # Persistent system property (set after a reboot) associated with the device # configuration flag. Loading @@ -196,21 +198,21 @@ function test_android_runtime_flag { local context="Flag set, before reboot" check_device_config_flag "$context" "$flag" "$value" check_system_property "$context" "$prop" "$value" check_no_zygote_gc_runtime_option "$context" "$value" check_no_zygote_gc_runtime_option "$context" "$gc_runtime_option" # Reboot device for the flag value to take effect. reboot_and_wait_for_device context="Flag set, after 1st reboot" check_device_config_flag "$context" "$flag" "$value" check_system_property "$context" "$prop" "$value" check_zygote_gc_runtime_option "$context" "$value" check_zygote_gc_runtime_option "$context" "$gc_runtime_option" # Reboot device a second time and check that the state has persisted. reboot_and_wait_for_device context="Flag set, after 2nd reboot" check_device_config_flag "$context" "$flag" "$value" check_system_property "$context" "$prop" "$value" check_zygote_gc_runtime_option "$context" "$value" check_zygote_gc_runtime_option "$context" "$gc_runtime_option" say "Unsetting device configuration flag..." adb shell device_config delete "$namespace" "$flag" >/dev/null Loading @@ -222,7 +224,7 @@ function test_android_runtime_flag { context="Flag unset, after 3rd reboot" check_no_device_config_flag "$context" "$flag" check_no_system_property "$context" "$prop" check_no_zygote_gc_runtime_option "$context" "$value" check_no_zygote_gc_runtime_option "$context" "$gc_runtime_option" } # Enumerate Zygote processes. Loading @@ -232,9 +234,9 @@ case $(adb shell getprop ro.zygote) in (zygote32_64|zygote64_32) zygotes="zygote zygote64";; esac # Test "gctype" flag values. test_android_runtime_flag gctype nogenerational_cc test_android_runtime_flag gctype generational_cc # Test "enable_generational_cc" flag values. test_android_runtime_flag enable_generational_cc false nogenerational_cc test_android_runtime_flag enable_generational_cc true generational_cc if [[ "$exit_status" -eq 0 ]]; then banner "All tests passed." Loading