From 84e6432bb73e35b32f12cdc0e1a172b7c973e618 Mon Sep 17 00:00:00 2001 From: Daniel Skantz Date: Thu, 2 Jan 2025 22:13:14 +0000 Subject: [PATCH] 8346288: WB_IsIntrinsicAvailable fails if called with wrong compilation level Reviewed-by: kvn, rcastanedalo --- src/hotspot/share/prims/whitebox.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/prims/whitebox.cpp b/src/hotspot/share/prims/whitebox.cpp index a4b1d0ece6d..01038b879ab 100644 --- a/src/hotspot/share/prims/whitebox.cpp +++ b/src/hotspot/share/prims/whitebox.cpp @@ -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);