diff options
author | 2022-11-10 19:17:24 +0000 | |
---|---|---|
committer | 2022-11-10 19:17:24 +0000 | |
commit | f84d9caba4fd292848f2e0c96923ee6ecbb09bdc (patch) | |
tree | 06e480d2aa131695fab7ba07764a101353f5ea2c | |
parent | 66e5f1dac2d296902b48bc0eef27a9efa949306c (diff) | |
parent | b3c55fcf55732d5f911adb3f5208bcf1796769c5 (diff) |
Merge "Fix the logic of parsing profilebootclasspath flags."
-rw-r--r-- | core/jni/AndroidRuntime.cpp | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp index 6b736488fe8b..949f363a58f0 100644 --- a/core/jni/AndroidRuntime.cpp +++ b/core/jni/AndroidRuntime.cpp @@ -19,6 +19,7 @@ #define LOG_NDEBUG 1 #include <android-base/macros.h> +#include <android-base/parsebool.h> #include <android-base/properties.h> #include <android/graphics/jni_runtime.h> #include <android_runtime/AndroidRuntime.h> @@ -52,6 +53,8 @@ using namespace android; using android::base::GetBoolProperty; using android::base::GetProperty; +using android::base::ParseBool; +using android::base::ParseBoolResult; extern int register_android_os_Binder(JNIEnv* env); extern int register_android_os_Process(JNIEnv* env); @@ -701,17 +704,24 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv, bool zygote, bool p // Read if we are using the profile configuration, do this at the start since the last ART args // take precedence. - property_get("dalvik.vm.profilebootclasspath", propBuf, ""); - std::string profile_boot_class_path_flag = propBuf; - // Empty means the property is unset and we should default to the phenotype property. - // The possible values are {"true", "false", ""} - if (profile_boot_class_path_flag.empty()) { - profile_boot_class_path_flag = server_configurable_flags::GetServerConfigurableFlag( - RUNTIME_NATIVE_BOOT_NAMESPACE, - PROFILE_BOOT_CLASS_PATH, - /*default_value=*/ ""); + std::string profile_boot_class_path_flag = + server_configurable_flags::GetServerConfigurableFlag(RUNTIME_NATIVE_BOOT_NAMESPACE, + PROFILE_BOOT_CLASS_PATH, + /*default_value=*/""); + bool profile_boot_class_path; + switch (ParseBool(profile_boot_class_path_flag)) { + case ParseBoolResult::kError: + // Default to the system property. + profile_boot_class_path = + GetBoolProperty("dalvik.vm.profilebootclasspath", /*default_value=*/false); + break; + case ParseBoolResult::kTrue: + profile_boot_class_path = true; + break; + case ParseBoolResult::kFalse: + profile_boot_class_path = false; + break; } - const bool profile_boot_class_path = (profile_boot_class_path_flag == "true"); if (profile_boot_class_path) { addOption("-Xcompiler-option"); addOption("--count-hotness-in-compiled-code"); |