diff options
| author | 2022-09-05 15:17:22 +0000 | |
|---|---|---|
| committer | 2022-09-15 13:47:45 +0000 | |
| commit | 93455a0a43f16bc7f7ece7ba196c411f01c28b2f (patch) | |
| tree | 5476c4a4015382a171e6326b4a766d1e865ca178 | |
| parent | 5aeed7f22b072c42079668af31a08df4ecb94a57 (diff) | |
Reland "Add isInitializing check in nterp header."
This reverts commit 2432d6bb2f7e105ba80f0b95f726621944cb1bc0.
Bug: 162110941
Reason for revert: Add a IsInitialized check to avoid busy looping
between the interpreter and the resolution trampoline.
Change-Id: I4d61bd10f73e1e9ee1ff7215872485915bf0874f
| -rw-r--r-- | runtime/instrumentation.cc | 8 | ||||
| -rw-r--r-- | runtime/interpreter/mterp/arm64ng/main.S | 23 | ||||
| -rw-r--r-- | runtime/interpreter/mterp/armng/main.S | 18 | ||||
| -rw-r--r-- | runtime/interpreter/mterp/x86_64ng/main.S | 8 | ||||
| -rw-r--r-- | runtime/interpreter/mterp/x86ng/main.S | 14 | ||||
| -rw-r--r-- | tools/cpp-define-generator/mirror_class.def | 3 |
6 files changed, 61 insertions, 13 deletions
diff --git a/runtime/instrumentation.cc b/runtime/instrumentation.cc index 8735dcfc81..f4584adb7c 100644 --- a/runtime/instrumentation.cc +++ b/runtime/instrumentation.cc @@ -1308,14 +1308,10 @@ const void* Instrumentation::GetCodeForInvoke(ArtMethod* method) { DCHECK(!method->IsProxyMethod()) << method->PrettyMethod(); ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); const void* code = method->GetEntryPointFromQuickCompiledCodePtrSize(kRuntimePointerSize); - // If we don't have the instrumentation, the resolution stub, the - // interpreter, or the nterp with clinit as entrypoint, just return the current entrypoint, + // If we don't have the instrumentation, the resolution stub, or the + // interpreter, just return the current entrypoint, // assuming it's the most optimized. - // We don't want to return the nterp with clinit entrypoint as it calls the - // resolution stub, and the resolution stub will call `GetCodeForInvoke` to know the actual - // code to invoke. if (code != GetQuickInstrumentationEntryPoint() && - code != interpreter::GetNterpWithClinitEntryPoint() && !class_linker->IsQuickResolutionStub(code) && !class_linker->IsQuickToInterpreterBridge(code)) { return code; diff --git a/runtime/interpreter/mterp/arm64ng/main.S b/runtime/interpreter/mterp/arm64ng/main.S index 81d6b7bd77..0ee04354c4 100644 --- a/runtime/interpreter/mterp/arm64ng/main.S +++ b/runtime/interpreter/mterp/arm64ng/main.S @@ -1591,10 +1591,25 @@ END \name */ OAT_ENTRY ExecuteNterpWithClinitImpl, EndExecuteNterpWithClinitImpl - ldr wip, [x0, ART_METHOD_DECLARING_CLASS_OFFSET] - ldrb wip, [ip, MIRROR_CLASS_IS_VISIBLY_INITIALIZED_OFFSET] - cmp ip, #MIRROR_CLASS_IS_VISIBLY_INITIALIZED_VALUE - bcs ExecuteNterpImpl + // For simplicity, we don't do a read barrier here, but instead rely + // on art_quick_resolution_trampoline to always have a suspend point before + // calling back here. + ldr wip, [x0, #ART_METHOD_DECLARING_CLASS_OFFSET] + ldrb wip2, [ip, #MIRROR_CLASS_IS_VISIBLY_INITIALIZED_OFFSET] + cmp ip2, #MIRROR_CLASS_IS_VISIBLY_INITIALIZED_VALUE + b.hs ExecuteNterpImpl + cmp ip2, #MIRROR_CLASS_IS_INITIALIZED_VALUE + b.lo .Linitializing_check + dmb ish + b ExecuteNterpImpl +.Linitializing_check: + cmp ip2, #MIRROR_CLASS_IS_INITIALIZING_VALUE + b.lo .Lresolution_trampoline + ldr wip2, [ip, #MIRROR_CLASS_CLINIT_THREAD_ID_OFFSET] + ldr wip, [xSELF, #THREAD_TID_OFFSET] + cmp wip, wip2 + b.eq ExecuteNterpImpl +.Lresolution_trampoline: b art_quick_resolution_trampoline EndExecuteNterpWithClinitImpl: diff --git a/runtime/interpreter/mterp/armng/main.S b/runtime/interpreter/mterp/armng/main.S index f89db40637..39cf537e42 100644 --- a/runtime/interpreter/mterp/armng/main.S +++ b/runtime/interpreter/mterp/armng/main.S @@ -1609,10 +1609,24 @@ END \name */ OAT_ENTRY ExecuteNterpWithClinitImpl, EndExecuteNterpWithClinitImpl - ldr ip, [r0, ART_METHOD_DECLARING_CLASS_OFFSET] - ldrb ip, [ip, MIRROR_CLASS_IS_VISIBLY_INITIALIZED_OFFSET] + // For simplicity, we don't do a read barrier here, but instead rely + // on art_quick_resolution_trampoline to always have a suspend point before + // calling back here. + ldr r4, [r0, ART_METHOD_DECLARING_CLASS_OFFSET] + ldrb ip, [r4, MIRROR_CLASS_IS_VISIBLY_INITIALIZED_OFFSET] cmp ip, #MIRROR_CLASS_IS_VISIBLY_INITIALIZED_VALUE bcs ExecuteNterpImpl + cmp ip, #MIRROR_CLASS_IS_INITIALIZED_VALUE + blo .Linitializing_check + dmb ish + b ExecuteNterpImpl +.Linitializing_check: + cmp ip, #MIRROR_CLASS_IS_INITIALIZING_VALUE + blo art_quick_resolution_trampoline + ldr r4, [r4, #MIRROR_CLASS_CLINIT_THREAD_ID_OFFSET] + ldr ip, [rSELF, #THREAD_TID_OFFSET] + cmp r4, ip + beq ExecuteNterpImpl b art_quick_resolution_trampoline EndExecuteNterpWithClinitImpl: diff --git a/runtime/interpreter/mterp/x86_64ng/main.S b/runtime/interpreter/mterp/x86_64ng/main.S index 3e476db953..6fc1777245 100644 --- a/runtime/interpreter/mterp/x86_64ng/main.S +++ b/runtime/interpreter/mterp/x86_64ng/main.S @@ -1695,9 +1695,17 @@ END_FUNCTION \name */ OAT_ENTRY ExecuteNterpWithClinitImpl, EndExecuteNterpWithClinitImpl + // For simplicity, we don't do a read barrier here, but instead rely + // on art_quick_resolution_trampoline to always have a suspend point before + // calling back here. movl ART_METHOD_DECLARING_CLASS_OFFSET(%rdi), %r10d cmpb $$(MIRROR_CLASS_IS_VISIBLY_INITIALIZED_VALUE), MIRROR_CLASS_IS_VISIBLY_INITIALIZED_OFFSET(%r10d) jae ExecuteNterpImpl + cmpb $$(MIRROR_CLASS_IS_INITIALIZING_VALUE), MIRROR_CLASS_IS_VISIBLY_INITIALIZED_OFFSET(%r10d) + jb art_quick_resolution_trampoline + movl MIRROR_CLASS_CLINIT_THREAD_ID_OFFSET(%r10d), %r10d + cmpl %r10d, rSELF:THREAD_TID_OFFSET + je ExecuteNterpImpl jmp art_quick_resolution_trampoline EndExecuteNterpWithClinitImpl: diff --git a/runtime/interpreter/mterp/x86ng/main.S b/runtime/interpreter/mterp/x86ng/main.S index 7872520384..42e2d182c5 100644 --- a/runtime/interpreter/mterp/x86ng/main.S +++ b/runtime/interpreter/mterp/x86ng/main.S @@ -1759,11 +1759,23 @@ END_FUNCTION \name OAT_ENTRY ExecuteNterpWithClinitImpl, EndExecuteNterpWithClinitImpl push %esi + // For simplicity, we don't do a read barrier here, but instead rely + // on art_quick_resolution_trampoline to always have a suspend point before + // calling back here. movl ART_METHOD_DECLARING_CLASS_OFFSET(%eax), %esi cmpb $$(MIRROR_CLASS_IS_VISIBLY_INITIALIZED_VALUE), MIRROR_CLASS_IS_VISIBLY_INITIALIZED_OFFSET(%esi) + jae .Lcontinue_execute_nterp + cmpb $$(MIRROR_CLASS_IS_INITIALIZING_VALUE), MIRROR_CLASS_IS_VISIBLY_INITIALIZED_OFFSET(%esi) + jb .Linvoke_trampoline + movl MIRROR_CLASS_CLINIT_THREAD_ID_OFFSET(%esi), %esi + cmpl %esi, rSELF:THREAD_TID_OFFSET + je .Lcontinue_execute_nterp +.Linvoke_trampoline: pop %esi - jae ExecuteNterpImpl jmp art_quick_resolution_trampoline +.Lcontinue_execute_nterp: + pop %esi + jmp ExecuteNterpImpl EndExecuteNterpWithClinitImpl: OAT_ENTRY ExecuteNterpImpl, EndExecuteNterpImpl diff --git a/tools/cpp-define-generator/mirror_class.def b/tools/cpp-define-generator/mirror_class.def index af396bfe10..062a7aa4b7 100644 --- a/tools/cpp-define-generator/mirror_class.def +++ b/tools/cpp-define-generator/mirror_class.def @@ -59,5 +59,8 @@ ASM_DEFINE(MIRROR_CLASS_IS_VISIBLY_INITIALIZED_VALUE, ASM_DEFINE(MIRROR_CLASS_IS_INITIALIZING_VALUE, art::enum_cast<uint32_t>(art::ClassStatus::kInitializing) << (art::SubtypeCheckBits::BitStructSizeOf() % art::kBitsPerByte)) +ASM_DEFINE(MIRROR_CLASS_IS_INITIALIZED_VALUE, + art::enum_cast<uint32_t>(art::ClassStatus::kInitialized) << + (art::SubtypeCheckBits::BitStructSizeOf() % art::kBitsPerByte)) ASM_DEFINE(MIRROR_CLASS_CLINIT_THREAD_ID_OFFSET, art::mirror::Class::ClinitThreadIdOffset().Int32Value()) |