diff options
author | 2023-04-17 15:34:58 -0700 | |
---|---|---|
committer | 2023-04-25 16:20:39 -0700 | |
commit | c0e1321bbc8c809393936e1f5e948c1fd5f642f3 (patch) | |
tree | 29055ef80c4f49b99cd5c5407561973f5838a15e | |
parent | f2eef5f0e445f3dd439f91ee8db5fdfa2129b892 (diff) |
nterp: merge nterp_impl.cc back into nterp.cc
Test: it builds
lunch aosp_riscv64-userdebug
art/tools/buildbot-build.sh --target
Change-Id: I0be1224a9bfc30a26e1b18ef0d6915067b118e9f
-rw-r--r-- | runtime/Android.bp | 5 | ||||
-rw-r--r-- | runtime/interpreter/mterp/nterp.cc | 54 | ||||
-rw-r--r-- | runtime/interpreter/mterp/nterp_impl.cc | 84 |
3 files changed, 54 insertions, 89 deletions
diff --git a/runtime/Android.bp b/runtime/Android.bp index f02f530f75..1d42ccdd1e 100644 --- a/runtime/Android.bp +++ b/runtime/Android.bp @@ -344,7 +344,6 @@ cc_defaults { arm: { srcs: [ "interpreter/mterp/nterp.cc", - "interpreter/mterp/nterp_impl.cc", ":libart_mterp.armng", "arch/arm/context_arm.cc", "arch/arm/entrypoints_init_arm.cc", @@ -360,7 +359,6 @@ cc_defaults { arm64: { srcs: [ "interpreter/mterp/nterp.cc", - "interpreter/mterp/nterp_impl.cc", ":libart_mterp.arm64ng", "arch/arm64/context_arm64.cc", "arch/arm64/entrypoints_init_arm64.cc", @@ -382,14 +380,12 @@ cc_defaults { "arch/riscv64/quick_entrypoints_riscv64.S", "arch/riscv64/thread_riscv64.cc", "interpreter/mterp/nterp.cc", - "interpreter/mterp/nterp_impl.cc", "monitor_pool.cc", ], }, x86: { srcs: [ "interpreter/mterp/nterp.cc", - "interpreter/mterp/nterp_impl.cc", ":libart_mterp.x86ng", "arch/x86/context_x86.cc", "arch/x86/entrypoints_init_x86.cc", @@ -411,7 +407,6 @@ cc_defaults { // Note that the fault_handler_x86.cc is not a mistake. This file is // shared between the x86 and x86_64 architectures. "interpreter/mterp/nterp.cc", - "interpreter/mterp/nterp_impl.cc", ":libart_mterp.x86_64ng", "arch/x86_64/context_x86_64.cc", "arch/x86_64/entrypoints_init_x86_64.cc", diff --git a/runtime/interpreter/mterp/nterp.cc b/runtime/interpreter/mterp/nterp.cc index f46091b20f..054122848c 100644 --- a/runtime/interpreter/mterp/nterp.cc +++ b/runtime/interpreter/mterp/nterp.cc @@ -34,6 +34,60 @@ namespace art { namespace interpreter { +bool IsNterpSupported() { + return !kPoisonHeapReferences && kReserveMarkingRegister && + kRuntimeISA != InstructionSet::kRiscv64; +} + +bool CanRuntimeUseNterp() REQUIRES_SHARED(Locks::mutator_lock_) { + Runtime* runtime = Runtime::Current(); + instrumentation::Instrumentation* instr = runtime->GetInstrumentation(); + // If the runtime is interpreter only, we currently don't use nterp as some + // parts of the runtime (like instrumentation) make assumption on an + // interpreter-only runtime to always be in a switch-like interpreter. + return IsNterpSupported() && !runtime->IsJavaDebuggable() && !instr->EntryExitStubsInstalled() && + !instr->InterpretOnly() && !runtime->IsAotCompiler() && + !instr->NeedsSlowInterpreterForListeners() && + // An async exception has been thrown. We need to go to the switch interpreter. nterp + // doesn't know how to deal with these so we could end up never dealing with it if we are + // in an infinite loop. + !runtime->AreAsyncExceptionsThrown() && + (runtime->GetJit() == nullptr || !runtime->GetJit()->JitAtFirstUse()); +} + +// The entrypoint for nterp, which ArtMethods can directly point to. +extern "C" void ExecuteNterpImpl() REQUIRES_SHARED(Locks::mutator_lock_); + +const void* GetNterpEntryPoint() { + return reinterpret_cast<const void*>(interpreter::ExecuteNterpImpl); +} + +// Another entrypoint, which does a clinit check at entry. +extern "C" void ExecuteNterpWithClinitImpl() REQUIRES_SHARED(Locks::mutator_lock_); + +const void* GetNterpWithClinitEntryPoint() { + return reinterpret_cast<const void*>(interpreter::ExecuteNterpWithClinitImpl); +} + +/* + * Verify some constants used by the nterp interpreter. + */ +void CheckNterpAsmConstants() { + /* + * If we're using computed goto instruction transitions, make sure + * none of the handlers overflows the byte limit. This won't tell + * which one did, but if any one is too big the total size will + * overflow. + */ + const int width = kNterpHandlerSize; + ptrdiff_t interp_size = reinterpret_cast<uintptr_t>(artNterpAsmInstructionEnd) - + reinterpret_cast<uintptr_t>(artNterpAsmInstructionStart); + if ((interp_size == 0) || (interp_size != (art::kNumPackedOpcodes * width))) { + LOG(FATAL) << "ERROR: unexpected asm interp size " << interp_size + << "(did an instruction handler exceed " << width << " bytes?)"; + } +} + inline void UpdateHotness(ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_) { // The hotness we will add to a method when we perform a // field/method/class/string lookup. diff --git a/runtime/interpreter/mterp/nterp_impl.cc b/runtime/interpreter/mterp/nterp_impl.cc deleted file mode 100644 index f2a9855de1..0000000000 --- a/runtime/interpreter/mterp/nterp_impl.cc +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (C) 2023 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "arch/instruction_set.h" -#include "interpreter/interpreter_common.h" -#include "nterp.h" - -/* - * Definitions for targets that support nterp. - */ - -namespace art { - -namespace interpreter { - -bool IsNterpSupported() { - return !kPoisonHeapReferences && kReserveMarkingRegister && - kRuntimeISA != InstructionSet::kRiscv64; -} - -bool CanRuntimeUseNterp() REQUIRES_SHARED(Locks::mutator_lock_) { - Runtime* runtime = Runtime::Current(); - instrumentation::Instrumentation* instr = runtime->GetInstrumentation(); - // If the runtime is interpreter only, we currently don't use nterp as some - // parts of the runtime (like instrumentation) make assumption on an - // interpreter-only runtime to always be in a switch-like interpreter. - return IsNterpSupported() && !runtime->IsJavaDebuggable() && !instr->EntryExitStubsInstalled() && - !instr->InterpretOnly() && !runtime->IsAotCompiler() && - !instr->NeedsSlowInterpreterForListeners() && - // An async exception has been thrown. We need to go to the switch interpreter. nterp - // doesn't know how to deal with these so we could end up never dealing with it if we are - // in an infinite loop. - !runtime->AreAsyncExceptionsThrown() && - (runtime->GetJit() == nullptr || !runtime->GetJit()->JitAtFirstUse()); -} - -// The entrypoint for nterp, which ArtMethods can directly point to. -extern "C" void ExecuteNterpImpl() REQUIRES_SHARED(Locks::mutator_lock_); - -const void* GetNterpEntryPoint() { - return reinterpret_cast<const void*>(interpreter::ExecuteNterpImpl); -} - -// Another entrypoint, which does a clinit check at entry. -extern "C" void ExecuteNterpWithClinitImpl() REQUIRES_SHARED(Locks::mutator_lock_); - -const void* GetNterpWithClinitEntryPoint() { - return reinterpret_cast<const void*>(interpreter::ExecuteNterpWithClinitImpl); -} - -/* - * Verify some constants used by the nterp interpreter. - */ -void CheckNterpAsmConstants() { - /* - * If we're using computed goto instruction transitions, make sure - * none of the handlers overflows the byte limit. This won't tell - * which one did, but if any one is too big the total size will - * overflow. - */ - const int width = kNterpHandlerSize; - ptrdiff_t interp_size = reinterpret_cast<uintptr_t>(artNterpAsmInstructionEnd) - - reinterpret_cast<uintptr_t>(artNterpAsmInstructionStart); - if ((interp_size == 0) || (interp_size != (art::kNumPackedOpcodes * width))) { - LOG(FATAL) << "ERROR: unexpected asm interp size " << interp_size - << "(did an instruction handler exceed " << width << " bytes?)"; - } -} - -} // namespace interpreter -} // namespace art |