diff options
-rw-r--r-- | runtime/native/dalvik_system_ZygoteHooks.cc | 11 | ||||
-rw-r--r-- | runtime/runtime.cc | 17 |
2 files changed, 16 insertions, 12 deletions
diff --git a/runtime/native/dalvik_system_ZygoteHooks.cc b/runtime/native/dalvik_system_ZygoteHooks.cc index ce942c846d..8e832b837f 100644 --- a/runtime/native/dalvik_system_ZygoteHooks.cc +++ b/runtime/native/dalvik_system_ZygoteHooks.cc @@ -264,7 +264,8 @@ static void ZygoteHooks_nativePostZygoteFork(JNIEnv*, jclass) { } static void ZygoteHooks_nativePostForkSystemServer(JNIEnv* env ATTRIBUTE_UNUSED, - jclass klass ATTRIBUTE_UNUSED) { + jclass klass ATTRIBUTE_UNUSED, + jint runtime_flags) { // Set the runtime state as the first thing, in case JIT and other services // start querying it. Runtime::Current()->SetAsSystemServer(); @@ -281,6 +282,12 @@ static void ZygoteHooks_nativePostForkSystemServer(JNIEnv* env ATTRIBUTE_UNUSED, // be closed in the common nativePostForkChild below. Runtime::Current()->GetOatFileManager().SetOnlyUseSystemOatFiles( /*enforce=*/false, /*assert_no_files_loaded=*/false); + + // Enable profiling if required based on the flags. This is done here instead of in + // nativePostForkChild since nativePostForkChild is called after loading the system server oat + // files. + bool profile_system_server = (runtime_flags & PROFILE_SYSTEM_SERVER) == PROFILE_SYSTEM_SERVER; + Runtime::Current()->GetJITOptions()->SetSaveProfilingInfo(profile_system_server); } static void ZygoteHooks_nativePostForkChild(JNIEnv* env, @@ -444,7 +451,7 @@ static void ZygoteHooks_stopZygoteNoThreadCreation(JNIEnv* env ATTRIBUTE_UNUSED, static JNINativeMethod gMethods[] = { NATIVE_METHOD(ZygoteHooks, nativePreFork, "()J"), NATIVE_METHOD(ZygoteHooks, nativePostZygoteFork, "()V"), - NATIVE_METHOD(ZygoteHooks, nativePostForkSystemServer, "()V"), + NATIVE_METHOD(ZygoteHooks, nativePostForkSystemServer, "(I)V"), NATIVE_METHOD(ZygoteHooks, nativePostForkChild, "(JIZZLjava/lang/String;)V"), NATIVE_METHOD(ZygoteHooks, startZygoteNoThreadCreation, "()V"), NATIVE_METHOD(ZygoteHooks, stopZygoteNoThreadCreation, "()V"), diff --git a/runtime/runtime.cc b/runtime/runtime.cc index 3d4116ba06..135ee63c1f 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -994,16 +994,13 @@ void Runtime::InitNonZygoteOrPostFork( } } - if (is_system_server) { - jit_options_->SetSaveProfilingInfo(profile_system_server); - if (profile_system_server) { - // Set the system server package name to "android". - // This is used to tell the difference between samples provided by system server - // and samples generated by other apps when processing boot image profiles. - SetProcessPackageName("android"); - jit_options_->SetWaitForJitNotificationsToSaveProfile(false); - VLOG(profiler) << "Enabling system server profiles"; - } + if (is_system_server && profile_system_server) { + // Set the system server package name to "android". + // This is used to tell the difference between samples provided by system server + // and samples generated by other apps when processing boot image profiles. + SetProcessPackageName("android"); + jit_options_->SetWaitForJitNotificationsToSaveProfile(false); + VLOG(profiler) << "Enabling system server profiles"; } // Create the thread pools. |