From 7dc66b31c178d5851b954ee9bd677b70d752b820 Mon Sep 17 00:00:00 2001 From: Florian Mayer Date: Mon, 11 May 2020 16:23:21 +0000 Subject: [PATCH] Pass -XX:PerfettoHprof=true to ART. Bug: 147667830 Change-Id: Ibc26afc5e9e8744839dce7e863d0635788ad9507 --- core/jni/AndroidRuntime.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp index b30fed6743093..544340eaba899 100644 --- a/core/jni/AndroidRuntime.cpp +++ b/core/jni/AndroidRuntime.cpp @@ -693,6 +693,7 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv, bool zygote, bool p char dex2oatImageFlagsBuf[PROPERTY_VALUE_MAX]; char extraOptsBuf[PROPERTY_VALUE_MAX]; char voldDecryptBuf[PROPERTY_VALUE_MAX]; + char perfettoHprofOptBuf[sizeof("-XX:PerfettoHprof=") + PROPERTY_VALUE_MAX]; enum { kEMDefault, kEMIntPortable, @@ -807,6 +808,16 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv, bool zygote, bool p addOption("-verbose:gc"); //addOption("-verbose:class"); + // On Android, we always want to allow loading the PerfettoHprof plugin. + // Even with this option set, we will still only actually load the plugin + // if we are on a userdebug build or the app is debuggable or profileable. + // This is enforced in art/runtime/runtime.cc. + // + // We want to be able to disable this, because this does not work on host, + // and we do not want to enable it in tests. + parseRuntimeOption("dalvik.vm.perfetto_hprof", perfettoHprofOptBuf, "-XX:PerfettoHprof=", + "true"); + if (primary_zygote) { addOption("-Xprimaryzygote"); }