8356447: Change default for EagerJVMCI to true

Reviewed-by: yzheng, kvn, never
This commit is contained in:
Doug Simon 2025-05-13 15:58:59 +00:00
parent 0318e49500
commit 08b2df80c6
6 changed files with 32 additions and 3 deletions

View File

@ -3231,7 +3231,11 @@ C2V_END
C2V_VMENTRY_0(jint, getCompilationActivityMode, (JNIEnv* env, jobject))
return CompileBroker::get_compilation_activity_mode();
}
C2V_END
C2V_VMENTRY_0(jboolean, isCompilerThread, (JNIEnv* env, jobject))
return thread->is_Compiler_thread();
C2V_END
#define CC (char*) /*cast a literal from (const char*)*/
#define FN_PTR(f) CAST_FROM_FN_PTR(void*, &(c2v_ ## f))
@ -3396,6 +3400,7 @@ JNINativeMethod CompilerToVM::methods[] = {
{CC "getOopMapAt", CC "(" HS_METHOD2 "I[J)V", FN_PTR(getOopMapAt)},
{CC "updateCompilerThreadCanCallJava", CC "(Z)Z", FN_PTR(updateCompilerThreadCanCallJava)},
{CC "getCompilationActivityMode", CC "()I", FN_PTR(getCompilationActivityMode)},
{CC "isCompilerThread", CC "()Z", FN_PTR(isCompilerThread)},
};
int CompilerToVM::methods_count() {

View File

@ -86,6 +86,7 @@ bool JVMCIGlobals::check_jvmci_flags_are_consistent() {
return false;
}
FLAG_SET_DEFAULT(EnableJVMCI, true);
FLAG_SET_ERGO_IF_DEFAULT(EagerJVMCI, true);
}
if (EnableJVMCI) {

View File

@ -88,7 +88,8 @@ class fileStream;
"-XX:-TieredCompilation makes JVMCI compile more of itself.") \
\
product(bool, EagerJVMCI, false, EXPERIMENTAL, \
"Force eager JVMCI initialization") \
"Force eager JVMCI initialization. Defaults to true if " \
"UseJVMCICompiler is true.") \
\
product(bool, PrintBootstrap, true, EXPERIMENTAL, \
"Print JVMCI bootstrap progress and summary") \

View File

@ -1528,4 +1528,9 @@ final class CompilerToVM {
* {@code stop_compilation = 0}, {@code run_compilation = 1} or {@code shutdown_compilation = 2}
*/
native int getCompilationActivityMode();
/**
* Returns whether the current thread is a CompilerThread.
*/
native boolean isCompilerThread();
}

View File

@ -51,11 +51,27 @@ final class HotSpotJVMCICompilerConfig {
DummyCompilerFactory(String reason, HotSpotJVMCIRuntime runtime) {
this.reason = reason;
this.runtime = runtime;
if (runtime.getConfig().getFlag("EagerJVMCI", Boolean.class)) {
if (runtime.getCompilerToVM().isCompilerThread()) {
throw noCompilerError();
} else {
// This path will be taken when initializing JVMCI on a non-JIT thread.
// Such a usage of JVMCI might never request a compilation so delay the
// noCompilerError until such a request is made.
}
}
}
/**
* Exits the VM due to unavailability of a JVMCI compiler.
*/
Error noCompilerError() {
throw runtime.exitHotSpotWithMessage(1, "Cannot use JVMCI compiler: %s%n", reason);
}
@Override
public HotSpotCompilationRequestResult compileMethod(CompilationRequest request) {
throw runtime.exitHotSpotWithMessage(1, "Cannot use JVMCI compiler: %s%n", reason);
throw noCompilerError();
}
@Override

View File

@ -45,6 +45,7 @@ public class TestJVMCIPrintProperties {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
"-XX:+UnlockExperimentalVMOptions",
enableFlag, "-Djvmci.Compiler=null",
"-XX:-EagerJVMCI",
"-XX:+JVMCIPrintProperties");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldContain("[JVMCI properties]"); // expected message