summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Boehm <hboehm@google.com>2021-02-12 20:17:20 -0800
committeralk3pInjection <webmaster@raspii.tech>2021-09-27 21:17:05 +0800
commit2b23a28109f57ec0cddbdc060cae3b446486a86e (patch)
tree4222a820309a9d54eb7188e10003284abc0b9945
parenta15fd2f72e84a84ceede994fcbbe0e55142acd91 (diff)
[master] Add nativeZygoteJitEnabled
... to allow the zygote to check whether it needs to keep the jit thread around. Bug: 159631815 Bug: 174211442 Test: Boot AOSP Change-Id: I4d32aee36993cf063d2464d839f2cabda1ee8ff5
-rw-r--r--runtime/jit/jit.cc7
-rw-r--r--runtime/jit/jit.h3
-rw-r--r--runtime/native/dalvik_system_ZygoteHooks.cc9
3 files changed, 18 insertions, 1 deletions
diff --git a/runtime/jit/jit.cc b/runtime/jit/jit.cc
index 8d434b8a0c..0610f6d073 100644
--- a/runtime/jit/jit.cc
+++ b/runtime/jit/jit.cc
@@ -1193,6 +1193,11 @@ static bool HasImageWithProfile() {
return false;
}
+bool Jit::InZygoteUsingJit() {
+ Runtime* runtime = Runtime::Current();
+ return runtime->IsZygote() && HasImageWithProfile() && runtime->UseJitCompilation();
+}
+
void Jit::CreateThreadPool() {
// There is a DCHECK in the 'AddSamples' method to ensure the tread pool
// is not null when we instrument.
@@ -1222,7 +1227,7 @@ void Jit::CreateThreadPool() {
thread_pool_->AddTask(Thread::Current(), new ZygoteVerificationTask());
}
- if (runtime->IsZygote() && HasImageWithProfile() && UseJitCompilation()) {
+ if (InZygoteUsingJit()) {
// If we have an image with a profile, request a JIT task to
// compile all methods in that profile.
thread_pool_->AddTask(Thread::Current(), new ZygoteTask());
diff --git a/runtime/jit/jit.h b/runtime/jit/jit.h
index e9fd915fc1..40a6eb7c74 100644
--- a/runtime/jit/jit.h
+++ b/runtime/jit/jit.h
@@ -393,6 +393,9 @@ class Jit {
// Called when system finishes booting.
void BootCompleted();
+ // Are we in a zygote using JIT compilation?
+ static bool InZygoteUsingJit();
+
// Compile methods from the given profile (.prof extension). If `add_to_queue`
// is true, methods in the profile are added to the JIT queue. Otherwise they are compiled
// directly.
diff --git a/runtime/native/dalvik_system_ZygoteHooks.cc b/runtime/native/dalvik_system_ZygoteHooks.cc
index c37b8bb51c..bc19503232 100644
--- a/runtime/native/dalvik_system_ZygoteHooks.cc
+++ b/runtime/native/dalvik_system_ZygoteHooks.cc
@@ -434,11 +434,20 @@ static void ZygoteHooks_stopZygoteNoThreadCreation(JNIEnv* env ATTRIBUTE_UNUSED,
Runtime::Current()->SetZygoteNoThreadSection(false);
}
+static jboolean ZygoteHooks_nativeZygoteJitEnabled(JNIEnv* env ATTRIBUTE_UNUSED,
+ jclass klass ATTRIBUTE_UNUSED) {
+ // Only called in zygote. Thus static is OK here.
+ static bool result = jit::Jit::InZygoteUsingJit();
+ return result ? JNI_TRUE : JNI_FALSE;
+}
+
+
static JNINativeMethod gMethods[] = {
NATIVE_METHOD(ZygoteHooks, nativePreFork, "()J"),
NATIVE_METHOD(ZygoteHooks, nativePostZygoteFork, "()V"),
NATIVE_METHOD(ZygoteHooks, nativePostForkSystemServer, "(I)V"),
NATIVE_METHOD(ZygoteHooks, nativePostForkChild, "(JIZZLjava/lang/String;)V"),
+ NATIVE_METHOD(ZygoteHooks, nativeZygoteJitEnabled, "()Z"),
NATIVE_METHOD(ZygoteHooks, startZygoteNoThreadCreation, "()V"),
NATIVE_METHOD(ZygoteHooks, stopZygoteNoThreadCreation, "()V"),
};