diff options
author | 2022-05-05 13:49:05 +0000 | |
---|---|---|
committer | 2022-05-12 10:47:05 +0000 | |
commit | 5da52cd20ea0d24b038ae20c6c96aa22ac3a24a0 (patch) | |
tree | 9d250cd4be4ae21ebedf9a2256f2bcec0cd27dc1 /runtime/stack.cc | |
parent | 9f466bd54aa6a6c0f12b2a6ccf4d19bc987bcf04 (diff) |
Reland^2 "Don't use AOT code for native methods for java debuggable runtime"
This reverts commit 570ade8a6600d368a9e24b64cfa0a1907929166a.
Reason for revert: Relanding after a fix for failures. The original cl breaks the invariant that we would always use AOT code for native methods if there is AOT code. This invariant is necessary to get the header when walking the stack. This CL fixes it by not relying on the invariant but instead tagging the sp to differentiate between JIT and AOT code in debuggable runtimes. Non-debuggable runtimes still have the invariant.
Change-Id: I5141281f04202d41988021d53bfe30a48bc4db9c
Diffstat (limited to 'runtime/stack.cc')
-rw-r--r-- | runtime/stack.cc | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/runtime/stack.cc b/runtime/stack.cc index 50a96d0ddf..33d3668eb0 100644 --- a/runtime/stack.cc +++ b/runtime/stack.cc @@ -800,10 +800,20 @@ void StackVisitor::WalkStack(bool include_transitions) { // between GenericJNI frame and JIT-compiled JNI stub; the entrypoint may have // changed since the frame was entered. The top quick frame tag indicates // GenericJNI here, otherwise it's either AOT-compiled or JNI-compiled JNI stub. - if (UNLIKELY(current_fragment->GetTopQuickFrameTag())) { + if (UNLIKELY(current_fragment->GetTopQuickFrameGenericJniTag())) { // The generic JNI does not have any method header. cur_oat_quick_method_header_ = nullptr; + } else if (UNLIKELY(current_fragment->GetTopQuickFrameJitJniTag())) { + // Should be JITed code. + Runtime* runtime = Runtime::Current(); + const void* code = runtime->GetJit()->GetCodeCache()->GetJniStubCode(method); + CHECK(code != nullptr) << method->PrettyMethod(); + cur_oat_quick_method_header_ = OatQuickMethodHeader::FromCodePointer(code); } else { + // We are sure we are not running GenericJni here. Though the entry point could still be + // GenericJnistub. The entry point is usually JITed, AOT or instrumentation stub when + // instrumentation is enabled. It could be lso a resolution stub if the class isn't + // visibly initialized yet. const void* existing_entry_point = method->GetEntryPointFromQuickCompiledCode(); CHECK(existing_entry_point != nullptr); Runtime* runtime = Runtime::Current(); @@ -819,7 +829,11 @@ void StackVisitor::WalkStack(bool include_transitions) { if (code != nullptr) { cur_oat_quick_method_header_ = OatQuickMethodHeader::FromEntryPoint(code); } else { - // This must be a JITted JNI stub frame. + // This must be a JITted JNI stub frame. For non-debuggable runtimes we only generate + // JIT stubs if there are no AOT stubs for native methods. Since we checked for AOT + // code earlier, we must be running JITed code. For debuggable runtimes we might have + // JIT code even when AOT code is present but we tag SP in JITed JNI stubs + // in debuggable runtimes. This case is handled earlier. CHECK(runtime->GetJit() != nullptr); code = runtime->GetJit()->GetCodeCache()->GetJniStubCode(method); CHECK(code != nullptr) << method->PrettyMethod(); |