8346288: WB_IsIntrinsicAvailable fails if called with wrong compilation level

Reviewed-by: kvn, rcastanedalo
This commit is contained in:
Daniel Skantz 2025-01-02 22:13:14 +00:00 committed by Vladimir Kozlov
parent a77ed30fcc
commit 84e6432bb7

View File

@ -920,14 +920,19 @@ WB_ENTRY(jboolean, WB_IsIntrinsicAvailable(JNIEnv* env, jobject o, jobject metho
if (compLevel < CompLevel_none || compLevel > CompilationPolicy::highest_compile_level()) {
return false; // Intrinsic is not available on a non-existent compilation level.
}
AbstractCompiler* comp = CompileBroker::compiler((int)compLevel);
if (comp == nullptr) {
// Could have compLevel == 0, or !TieredCompilation and incompatible values of TieredStopAtLevel and compLevel.
tty->print_cr("WB error: no compiler for requested compilation level %d", compLevel);
return false;
}
jmethodID method_id, compilation_context_id;
method_id = reflected_method_to_jmid(thread, env, method);
CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(method_id));
DirectiveSet* directive;
AbstractCompiler* comp = CompileBroker::compiler((int)compLevel);
assert(comp != nullptr, "compiler not available");
if (compilation_context != nullptr) {
compilation_context_id = reflected_method_to_jmid(thread, env, compilation_context);
CHECK_JNI_EXCEPTION_(env, JNI_FALSE);