ADDITIONAL SYSTEM INFORMATION :
linux x86_64
A DESCRIPTION OF THE PROBLEM :
When running testcase compiler/codegen/aes/TestAESMain.java with option "-Xint", it will crash with "assert(comp != __null) failed: compiler not available" on a debug-level build or SIGSEGV on a release-level build.
The crash is caused by the absent of compiler when JVM is running in pure interpreter mode with option "-Xint". We can fix it by setting the highest compile level to be CompLevel_none if "-Xint" is enabled, and WB_IsIntrinsicAvailable will return with false directly rather than trying to get and use NULL compiler wrongly.
```
WB_ENTRY(jboolean, WB_IsIntrinsicAvailable(JNIEnv* env, jobject o, jobject method, jobject compilation_context, jint compLevel))
if (compLevel < CompLevel_none || compLevel > highestCompLevel()) {
return false; // Intrinsic is not available on a non-existent compilation level.
}
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 != NULL, "compiler not available");
// ...
}
```
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
jtreg -v:fail,error -nr -w tmp -Xint -jdk:path/to/jdk/build test/hotspot/jtreg/compiler/codegen/aes/TestAESMain.java
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The test case passes
ACTUAL -
Crash with SIGSEGV on release build and failed with "compiler not available" on debug build.
CUSTOMER SUBMITTED WORKAROUND :
```
diff --git a/src/hotspot/share/prims/whitebox.cpp b/src/hotspot/share/prims/whitebox.cpp
index 2dc6919574..e2f3003ad1 100644
--- a/src/hotspot/share/prims/whitebox.cpp
+++ b/src/hotspot/share/prims/whitebox.cpp
@@ -708,7 +708,15 @@ static jmethodID reflected_method_to_jmid(JavaThread* thread, JNIEnv* env, jobje
}
static CompLevel highestCompLevel() {
- return TieredCompilation ? MIN2((CompLevel) TieredStopAtLevel, CompLevel_highest_tier) : CompLevel_highest_tier;
+ CompLevel level = CompLevel_none;
+ if (!Arguments::is_interpreter_only()) {
+ if (TieredCompilation) {
+ level = MIN2((CompLevel) TieredStopAtLevel, CompLevel_highest_tier);
+ } else {
+ level = CompLevel_highest_tier;
+ }
+ }
+ return level;
}
```
FREQUENCY : always
linux x86_64
A DESCRIPTION OF THE PROBLEM :
When running testcase compiler/codegen/aes/TestAESMain.java with option "-Xint", it will crash with "assert(comp != __null) failed: compiler not available" on a debug-level build or SIGSEGV on a release-level build.
The crash is caused by the absent of compiler when JVM is running in pure interpreter mode with option "-Xint". We can fix it by setting the highest compile level to be CompLevel_none if "-Xint" is enabled, and WB_IsIntrinsicAvailable will return with false directly rather than trying to get and use NULL compiler wrongly.
```
WB_ENTRY(jboolean, WB_IsIntrinsicAvailable(JNIEnv* env, jobject o, jobject method, jobject compilation_context, jint compLevel))
if (compLevel < CompLevel_none || compLevel > highestCompLevel()) {
return false; // Intrinsic is not available on a non-existent compilation level.
}
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 != NULL, "compiler not available");
// ...
}
```
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
jtreg -v:fail,error -nr -w tmp -Xint -jdk:path/to/jdk/build test/hotspot/jtreg/compiler/codegen/aes/TestAESMain.java
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The test case passes
ACTUAL -
Crash with SIGSEGV on release build and failed with "compiler not available" on debug build.
CUSTOMER SUBMITTED WORKAROUND :
```
diff --git a/src/hotspot/share/prims/whitebox.cpp b/src/hotspot/share/prims/whitebox.cpp
index 2dc6919574..e2f3003ad1 100644
--- a/src/hotspot/share/prims/whitebox.cpp
+++ b/src/hotspot/share/prims/whitebox.cpp
@@ -708,7 +708,15 @@ static jmethodID reflected_method_to_jmid(JavaThread* thread, JNIEnv* env, jobje
}
static CompLevel highestCompLevel() {
- return TieredCompilation ? MIN2((CompLevel) TieredStopAtLevel, CompLevel_highest_tier) : CompLevel_highest_tier;
+ CompLevel level = CompLevel_none;
+ if (!Arguments::is_interpreter_only()) {
+ if (TieredCompilation) {
+ level = MIN2((CompLevel) TieredStopAtLevel, CompLevel_highest_tier);
+ } else {
+ level = CompLevel_highest_tier;
+ }
+ }
+ return level;
}
```
FREQUENCY : always
- duplicates
-
JDK-8324754 WB_IsIntrinsicAvailable failed with "compiler not available" with option -Xint
-
- Open
-