Merge "Fix the logic of parsing profilebootclasspath flags."

This commit is contained in:
Treehugger Robot
2022-11-10 19:17:24 +00:00
committed by Gerrit Code Review

View File

@@ -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");