From c8a694ddbcda17fc90121d7e7985d90d3860a60c Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Mon, 17 Jan 2022 17:12:38 +0000 Subject: Reland "Use InitializeMethodsCode when we need to reinitialize a method entrypoint." This reverts commit b0f63c93e44bf53a34dda90c74b8725a932922da. Reason for revert: Fix For proxy init. Test: test.py Change-Id: I6b4796115d73a093f86309cec1f03cafd981c2e9 --- runtime/class_linker.cc | 35 +++++++---------------------------- 1 file changed, 7 insertions(+), 28 deletions(-) (limited to 'runtime/class_linker.cc') diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index 5ae65139af..5eab75dfb0 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -201,22 +201,6 @@ static void HandleEarlierErroneousStateError(Thread* self, self->AssertPendingException(); } -static void ChangeInterpreterBridgeToNterp(ArtMethod* method, ClassLinker* class_linker) - REQUIRES_SHARED(Locks::mutator_lock_) { - Runtime* runtime = Runtime::Current(); - if (class_linker->IsQuickToInterpreterBridge(method->GetEntryPointFromQuickCompiledCode()) && - CanMethodUseNterp(method)) { - if (method->GetDeclaringClass()->IsVisiblyInitialized() || - !NeedsClinitCheckBeforeCall(method)) { - runtime->GetInstrumentation()->UpdateMethodsCode(method, interpreter::GetNterpEntryPoint()); - } else { - // Put the resolution stub, which will initialize the class and then - // call the method with nterp. - runtime->GetInstrumentation()->UpdateMethodsCode(method, GetQuickResolutionStub()); - } - } -} - static void UpdateClassAfterVerification(Handle klass, PointerSize pointer_size, verifier::FailureKind failure_kind) @@ -231,7 +215,9 @@ static void UpdateClassAfterVerification(Handle klass, // to methods that currently use the switch interpreter. if (interpreter::CanRuntimeUseNterp()) { for (ArtMethod& m : klass->GetMethods(pointer_size)) { - ChangeInterpreterBridgeToNterp(&m, class_linker); + if (class_linker->IsQuickToInterpreterBridge(m.GetEntryPointFromQuickCompiledCode())) { + runtime->GetInstrumentation()->InitializeMethodsCode(&m, /*aot_code=*/nullptr); + } } } } @@ -2008,10 +1994,11 @@ bool ClassLinker::AddImageSpace( // reset it with the runtime value. method.ResetCounter(hotness_threshold); } - // Set image methods' entry point that point to the interpreter bridge to the - // nterp entry point. if (method.GetEntryPointFromQuickCompiledCode() == nterp_trampoline_) { if (can_use_nterp) { + // Set image methods' entry point that point to the nterp trampoline to the + // nterp entry point. This allows taking the fast path when doing a + // nterp->nterp call. DCHECK(!NeedsClinitCheckBeforeCall(&method) || method.GetDeclaringClass()->IsVisiblyInitialized()); method.SetEntryPointFromQuickCompiledCode(interpreter::GetNterpEntryPoint()); @@ -3388,6 +3375,7 @@ void ClassLinker::FixupStaticTrampolines(Thread* self, ObjPtr kla return; } + instrumentation::Instrumentation* instrumentation = runtime->GetInstrumentation(); // Link the code of methods skipped by LinkCode. for (size_t method_index = 0; method_index < num_direct_methods; ++method_index) { ArtMethod* method = klass->GetDirectMethod(method_index, pointer_size); @@ -3395,7 +3383,6 @@ void ClassLinker::FixupStaticTrampolines(Thread* self, ObjPtr kla // Only update static methods. continue; } - instrumentation::Instrumentation* instrumentation = runtime->GetInstrumentation(); instrumentation->UpdateMethodsCode(method, instrumentation->GetCodeForInvoke(method)); } // Ignore virtual methods on the iterator. @@ -9779,14 +9766,6 @@ const void* ClassLinker::GetRuntimeQuickGenericJniStub() const { return GetQuickGenericJniStub(); } -void ClassLinker::SetEntryPointsToInterpreter(ArtMethod* method) const { - if (!method->IsNative()) { - method->SetEntryPointFromQuickCompiledCode(GetQuickToInterpreterBridge()); - } else { - method->SetEntryPointFromQuickCompiledCode(GetQuickGenericJniStub()); - } -} - void ClassLinker::SetEntryPointsForObsoleteMethod(ArtMethod* method) const { DCHECK(method->IsObsolete()); // We cannot mess with the entrypoints of native methods because they are used to determine how -- cgit v1.2.3-59-g8ed1b