From 58f4208dc161893569a43919780dae94cdf8d6d6 Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Mon, 19 Aug 2019 11:12:37 -0700 Subject: [PATCH] Add phenotype property for enabling profiling of boot class path If specified, does the same behavior as the dalvik.vm.profilebootimage property used to do. The new property is called profilebootclasspath and is in the runtime_native_boot namespace. Added logic to pass down Xjitsaveprofilinginfo if profilebootclasspath is specified. Bug: 139883463 Test: adb shell setprop dalvik.vm.profilebootclasspath true Test: look at logcat to verify the right options are passed down (cherry picked from commit 7253961bd00dc2408830701a7c88272c62ae433b) Merged-In: I3e2ec37931a6f9239c5d0fa9fcaea61637061ac1 Change-Id: Iab2118822e522f9f80016c2c6ad42af9cd7eba03 --- core/jni/AndroidRuntime.cpp | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp index 0da314ba43ca0..6c351fe23e600 100644 --- a/core/jni/AndroidRuntime.cpp +++ b/core/jni/AndroidRuntime.cpp @@ -232,6 +232,9 @@ static const char* kGenerationalCCRuntimeOption = "-Xgc:generational_cc"; // Copying (CC) garbage collector. static const char* kNoGenerationalCCRuntimeOption = "-Xgc:nogenerational_cc"; +// Phenotype property name for enabling profiling the boot class path. +static const char* PROFILE_BOOT_CLASS_PATH = "profilebootclasspath"; + // Feature flag name for running the JIT in Zygote experiment, b/119800099. static const char* ENABLE_APEX_IMAGE = "enable_apex_image"; // Flag to pass to the runtime when using the apex image. @@ -677,6 +680,24 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv, bool zygote, bool p char jdwpProviderBuf[sizeof("-XjdwpProvider:") - 1 + PROPERTY_VALUE_MAX]; char bootImageBuf[sizeof("-Ximage:") - 1 + PROPERTY_VALUE_MAX]; + // 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 = 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.empty()) { + profile_boot_class_path = server_configurable_flags::GetServerConfigurableFlag( + RUNTIME_NATIVE_BOOT_NAMESPACE, + PROFILE_BOOT_CLASS_PATH, + /*default_value=*/ ""); + } + if (profile_boot_class_path == "true") { + addOption("-Xps-profile-boot-class-path"); + addOption("-Xps-profile-aot-code"); + addOption("-Xjitsaveprofilinginfo"); + } + std::string use_apex_image = server_configurable_flags::GetServerConfigurableFlag(RUNTIME_NATIVE_BOOT_NAMESPACE, ENABLE_APEX_IMAGE, @@ -794,13 +815,6 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv, bool zygote, bool p parseRuntimeOption("dalvik.vm.jittransitionweight", jittransitionweightOptBuf, "-Xjittransitionweight:"); - - property_get("dalvik.vm.profilebootimage", propBuf, ""); - if (strcmp(propBuf, "true") == 0) { - addOption("-Xps-profile-boot-class-path"); - addOption("-Xps-profile-aot-code"); - } - /* * Madvise related options. */