Revert "Revert "Try really hard for JIT in test 916""
We were looping forever waiting for the entrypoint to be switched
despite the JIT being disabled by the tracing instrumentation.
This reverts commit ca4feac9484464a858990ca588398fceead55354.
Reason for revert: Problem with ensureJitCompiled fixed
Test: ART_TEST_TRACE=true \
ART_TEST_OPTIMIZING=false \
ART_TEST_INTERPRETER=true \
ART_USE_READ_BARRIER=false \
mma -j40 test-art-host-run-test-916-obsolete-jit
Change-Id: I11f1e3f6cf65f90509a1ba66625a7988f3d94af6
diff --git a/test/common/runtime_state.cc b/test/common/runtime_state.cc
index 1b6fc70..a841f9e 100644
--- a/test/common/runtime_state.cc
+++ b/test/common/runtime_state.cc
@@ -33,12 +33,18 @@
// public static native boolean hasJit();
-extern "C" JNIEXPORT jboolean JNICALL Java_Main_hasJit(JNIEnv*, jclass) {
+static jit::Jit* GetJitIfEnabled() {
Runtime* runtime = Runtime::Current();
- return runtime != nullptr
+ bool can_jit =
+ runtime != nullptr
&& runtime->GetJit() != nullptr
&& runtime->GetInstrumentation()->GetCurrentInstrumentationLevel() !=
instrumentation::Instrumentation::InstrumentationLevel::kInstrumentWithInterpreter;
+ return can_jit ? runtime->GetJit() : nullptr;
+}
+
+extern "C" JNIEXPORT jboolean JNICALL Java_Main_hasJit(JNIEnv*, jclass) {
+ return GetJitIfEnabled() != nullptr;
}
// public static native boolean hasOatFile();
@@ -152,7 +158,7 @@
jclass,
jclass cls,
jstring method_name) {
- jit::Jit* jit = Runtime::Current()->GetJit();
+ jit::Jit* jit = GetJitIfEnabled();
if (jit == nullptr) {
return;
}
@@ -166,6 +172,11 @@
CHECK(chars.c_str() != nullptr);
method = soa.Decode<mirror::Class>(cls)->FindDeclaredDirectMethodByName(
chars.c_str(), kRuntimePointerSize);
+ if (method == nullptr) {
+ method = soa.Decode<mirror::Class>(cls)->FindDeclaredVirtualMethodByName(
+ chars.c_str(), kRuntimePointerSize);
+ }
+ DCHECK(method != nullptr) << "Unable to find method called " << chars.c_str();
}
jit::JitCodeCache* code_cache = jit->GetCodeCache();