diff options
| -rw-r--r-- | runtime/entrypoints/quick/quick_trampoline_entrypoints.cc | 10 | ||||
| -rw-r--r-- | runtime/jit/jit.cc | 7 | ||||
| -rw-r--r-- | test/1935-get-set-current-frame-jit/expected.txt | 4 | ||||
| -rw-r--r-- | test/1935-get-set-current-frame-jit/src/Main.java | 8 |
4 files changed, 17 insertions, 12 deletions
diff --git a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc index e9a0808843..c37e9eaa1b 100644 --- a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc @@ -2246,10 +2246,6 @@ extern "C" TwoWordReturn artQuickGenericJniTrampoline(Thread* self, ArtMethod** ArtMethod* called = *sp; DCHECK(called->IsNative()) << called->PrettyMethod(true); Runtime* runtime = Runtime::Current(); - jit::Jit* jit = runtime->GetJit(); - if (jit != nullptr) { - jit->AddSamples(self, called, 1u, /*with_backedges*/ false); - } uint32_t shorty_len = 0; const char* shorty = called->GetShorty(&shorty_len); bool critical_native = called->IsCriticalNative(); @@ -2275,6 +2271,12 @@ extern "C" TwoWordReturn artQuickGenericJniTrampoline(Thread* self, ArtMethod** self->VerifyStack(); + // We can now walk the stack if needed by JIT GC from MethodEntered() for JIT-on-first-use. + jit::Jit* jit = runtime->GetJit(); + if (jit != nullptr) { + jit->MethodEntered(self, called); + } + uint32_t cookie; uint32_t* sp32; // Skip calling JniMethodStart for @CriticalNative. diff --git a/runtime/jit/jit.cc b/runtime/jit/jit.cc index 23cf071d56..813430f0bb 100644 --- a/runtime/jit/jit.cc +++ b/runtime/jit/jit.cc @@ -718,10 +718,11 @@ void Jit::MethodEntered(Thread* thread, ArtMethod* method) { Runtime* runtime = Runtime::Current(); if (UNLIKELY(runtime->UseJitCompilation() && runtime->GetJit()->JitAtFirstUse())) { ArtMethod* np_method = method->GetInterfaceMethodIfProxy(kRuntimePointerSize); - DCHECK(!np_method->IsNative()); if (np_method->IsCompilable()) { - // The compiler requires a ProfilingInfo object. - ProfilingInfo::Create(thread, np_method, /* retry_allocation */ true); + if (!np_method->IsNative()) { + // The compiler requires a ProfilingInfo object for non-native methods. + ProfilingInfo::Create(thread, np_method, /* retry_allocation */ true); + } JitCompileTask compile_task(method, JitCompileTask::kCompile); compile_task.Run(thread); } diff --git a/test/1935-get-set-current-frame-jit/expected.txt b/test/1935-get-set-current-frame-jit/expected.txt index fed993cc1a..cdb8f6a825 100644 --- a/test/1935-get-set-current-frame-jit/expected.txt +++ b/test/1935-get-set-current-frame-jit/expected.txt @@ -1,7 +1,7 @@ JNI_OnLoad called From GetLocalInt(), value is 42 -isInterpreted? true +isInOsrCode? false Value is '42' Setting TARGET to 1337 -isInterpreted? true +isInOsrCode? false Value is '1337' diff --git a/test/1935-get-set-current-frame-jit/src/Main.java b/test/1935-get-set-current-frame-jit/src/Main.java index eb0a6374d2..714a98aaf3 100644 --- a/test/1935-get-set-current-frame-jit/src/Main.java +++ b/test/1935-get-set-current-frame-jit/src/Main.java @@ -64,9 +64,9 @@ public class Main { Main.ensureJitCompiled(IntRunner.class, "run"); i++; } - // We shouldn't be doing OSR since we are using JVMTI and the get/set local will push us to - // interpreter. - System.out.println("isInterpreted? " + Main.isInterpreted()); + // We shouldn't be doing OSR since we are using JVMTI and the get/set prevents OSR. + // Set local will also push us to interpreter but the get local may remain in compiled code. + System.out.println("isInOsrCode? " + (hasJit() && Main.isInOsrCode("run"))); reportValue(TARGET); } public void waitForBusyLoopStart() { while (!inBusyLoop) {} } @@ -159,4 +159,6 @@ public class Main { public static native void ensureJitCompiled(Class k, String f); public static native boolean isInterpreted(); + public static native boolean isInOsrCode(String methodName); + public static native boolean hasJit(); } |