Reland^2 "Cover more cases in nterp."
This reverts commit dd5db458831cf74ae5813d2278fbd599145c4522.
Bug: 112676029
Bug: 157658616
Bug: 160543640
Reason for revert: Fixed missed class initialization.
Test: wifi tests, run-tests
Change-Id: Ie0a8ae0e92587b5c86203228615534526df640fb
diff --git a/runtime/interpreter/mterp/nterp.cc b/runtime/interpreter/mterp/nterp.cc
index f1b6021..2ec142f 100644
--- a/runtime/interpreter/mterp/nterp.cc
+++ b/runtime/interpreter/mterp/nterp.cc
@@ -37,13 +37,20 @@
}
bool CanRuntimeUseNterp() REQUIRES_SHARED(Locks::mutator_lock_) {
- // Nterp has the same restrictions as Mterp.
- return IsNterpSupported() && CanUseMterp();
+ Runtime* runtime = Runtime::Current();
+ instrumentation::Instrumentation* instr = runtime->GetInstrumentation();
+ // Nterp shares the same restrictions as Mterp.
+ // 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() && CanUseMterp() && !instr->InterpretOnly();
}
bool CanMethodUseNterp(ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_) {
- return method->SkipAccessChecks() &&
- !method->IsNative() &&
+ return !method->IsNative() &&
+ method->SkipAccessChecks() &&
+ method->IsInvokable() &&
+ !method->MustCountLocks() &&
method->GetDexFile()->IsStandardDexFile() &&
// Proxy methods do not go through the JIT like other methods, so we don't
// run them with nterp.
@@ -526,11 +533,12 @@
DCHECK_LE(length, 5);
}
uint16_t type_idx = is_range ? inst->VRegB_3rc() : inst->VRegB_35c();
- ObjPtr<mirror::Class> array_class = ResolveVerifyAndClinit(dex::TypeIndex(type_idx),
- caller,
- self,
- /* can_run_clinit= */ true,
- /* verify_access= */ false);
+ ObjPtr<mirror::Class> array_class =
+ ResolveVerifyAndClinit(dex::TypeIndex(type_idx),
+ caller,
+ self,
+ /* can_run_clinit= */ true,
+ /* verify_access= */ !caller->SkipAccessChecks());
if (UNLIKELY(array_class == nullptr)) {
DCHECK(self->IsExceptionPending());
return nullptr;