diff options
| -rw-r--r-- | test/638-checker-inline-cache-intrinsic/src/Main.java | 4 | ||||
| -rw-r--r-- | test/common/runtime_state.cc | 35 |
2 files changed, 32 insertions, 7 deletions
diff --git a/test/638-checker-inline-cache-intrinsic/src/Main.java b/test/638-checker-inline-cache-intrinsic/src/Main.java index 5334487dfa..738e13cf8d 100644 --- a/test/638-checker-inline-cache-intrinsic/src/Main.java +++ b/test/638-checker-inline-cache-intrinsic/src/Main.java @@ -63,6 +63,9 @@ public class Main { } public static void test() { + ensureJitBaselineCompiled(Main.class, "$noinline$stringEquals"); + ensureJitBaselineCompiled(Main.class, "$noinline$inlineMonomorphic"); + ensureJitBaselineCompiled(Main.class, "$noinline$knownReceiverType"); // Warm up inline cache. for (int i = 0; i < 600000; i++) { $noinline$inlineMonomorphic(str); @@ -91,5 +94,6 @@ public class Main { static String str = "xyz"; + private static native void ensureJitBaselineCompiled(Class<?> itf, String method_name); private static native void ensureJitCompiled(Class<?> itf, String method_name); } diff --git a/test/common/runtime_state.cc b/test/common/runtime_state.cc index c4edf19bd2..ac3cbdd0f8 100644 --- a/test/common/runtime_state.cc +++ b/test/common/runtime_state.cc @@ -229,7 +229,9 @@ extern "C" JNIEXPORT jboolean JNICALL Java_Main_hasJitCompiledCode(JNIEnv* env, return jit->GetCodeCache()->ContainsMethod(method); } -static void ForceJitCompiled(Thread* self, ArtMethod* method) REQUIRES(!Locks::mutator_lock_) { +static void ForceJitCompiled(Thread* self, + ArtMethod* method, + CompilationKind kind) REQUIRES(!Locks::mutator_lock_) { { ScopedObjectAccess soa(self); if (!Runtime::Current()->GetRuntimeCallbacks()->IsMethodSafeToJit(method)) { @@ -271,10 +273,9 @@ static void ForceJitCompiled(Thread* self, ArtMethod* method) REQUIRES(!Locks::m usleep(1000); ScopedObjectAccess soa(self); // Will either ensure it's compiled or do the compilation itself. We do - // this before checking if we will execute JIT code to make sure the - // method is compiled 'optimized' and not baseline (tests expect optimized - // compilation). - jit->CompileMethod(method, self, CompilationKind::kOptimized, /*prejit=*/ false); + // this before checking if we will execute JIT code in case the request + // is for an 'optimized' compilation. + jit->CompileMethod(method, self, kind, /*prejit=*/ false); } while (!code_cache->ContainsPc(method->GetEntryPointFromQuickCompiledCode())); } @@ -290,7 +291,7 @@ extern "C" JNIEXPORT void JNICALL Java_Main_ensureMethodJitCompiled(JNIEnv*, jcl ScopedObjectAccess soa(self); method = ArtMethod::FromReflectedMethod(soa, meth); } - ForceJitCompiled(self, method); + ForceJitCompiled(self, method, CompilationKind::kOptimized); } extern "C" JNIEXPORT void JNICALL Java_Main_ensureJitCompiled(JNIEnv* env, @@ -310,7 +311,27 @@ extern "C" JNIEXPORT void JNICALL Java_Main_ensureJitCompiled(JNIEnv* env, ScopedUtfChars chars(env, method_name); method = GetMethod(soa, cls, chars); } - ForceJitCompiled(self, method); + ForceJitCompiled(self, method, CompilationKind::kOptimized); +} + +extern "C" JNIEXPORT void JNICALL Java_Main_ensureJitBaselineCompiled(JNIEnv* env, + jclass, + jclass cls, + jstring method_name) { + jit::Jit* jit = GetJitIfEnabled(); + if (jit == nullptr) { + return; + } + + Thread* self = Thread::Current(); + ArtMethod* method = nullptr; + { + ScopedObjectAccess soa(self); + + ScopedUtfChars chars(env, method_name); + method = GetMethod(soa, cls, chars); + } + ForceJitCompiled(self, method, CompilationKind::kBaseline); } extern "C" JNIEXPORT jboolean JNICALL Java_Main_hasSingleImplementation(JNIEnv* env, |