Skip to content

Commit 08b2df8

Browse files
author
Doug Simon
committed
8356447: Change default for EagerJVMCI to true
Reviewed-by: yzheng, kvn, never
1 parent 0318e49 commit 08b2df8

File tree

6 files changed

+32
-3
lines changed

6 files changed

+32
-3
lines changed

src/hotspot/share/jvmci/jvmciCompilerToVM.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3231,7 +3231,11 @@ C2V_END
32313231

32323232
C2V_VMENTRY_0(jint, getCompilationActivityMode, (JNIEnv* env, jobject))
32333233
return CompileBroker::get_compilation_activity_mode();
3234-
}
3234+
C2V_END
3235+
3236+
C2V_VMENTRY_0(jboolean, isCompilerThread, (JNIEnv* env, jobject))
3237+
return thread->is_Compiler_thread();
3238+
C2V_END
32353239

32363240
#define CC (char*) /*cast a literal from (const char*)*/
32373241
#define FN_PTR(f) CAST_FROM_FN_PTR(void*, &(c2v_ ## f))
@@ -3396,6 +3400,7 @@ JNINativeMethod CompilerToVM::methods[] = {
33963400
{CC "getOopMapAt", CC "(" HS_METHOD2 "I[J)V", FN_PTR(getOopMapAt)},
33973401
{CC "updateCompilerThreadCanCallJava", CC "(Z)Z", FN_PTR(updateCompilerThreadCanCallJava)},
33983402
{CC "getCompilationActivityMode", CC "()I", FN_PTR(getCompilationActivityMode)},
3403+
{CC "isCompilerThread", CC "()Z", FN_PTR(isCompilerThread)},
33993404
};
34003405

34013406
int CompilerToVM::methods_count() {

src/hotspot/share/jvmci/jvmci_globals.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ bool JVMCIGlobals::check_jvmci_flags_are_consistent() {
8686
return false;
8787
}
8888
FLAG_SET_DEFAULT(EnableJVMCI, true);
89+
FLAG_SET_ERGO_IF_DEFAULT(EagerJVMCI, true);
8990
}
9091

9192
if (EnableJVMCI) {

src/hotspot/share/jvmci/jvmci_globals.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ class fileStream;
8888
"-XX:-TieredCompilation makes JVMCI compile more of itself.") \
8989
\
9090
product(bool, EagerJVMCI, false, EXPERIMENTAL, \
91-
"Force eager JVMCI initialization") \
91+
"Force eager JVMCI initialization. Defaults to true if " \
92+
"UseJVMCICompiler is true.") \
9293
\
9394
product(bool, PrintBootstrap, true, EXPERIMENTAL, \
9495
"Print JVMCI bootstrap progress and summary") \

src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/CompilerToVM.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,4 +1528,9 @@ void getOopMapAt(HotSpotResolvedJavaMethodImpl method, int bci, long[] oopMap) {
15281528
* {@code stop_compilation = 0}, {@code run_compilation = 1} or {@code shutdown_compilation = 2}
15291529
*/
15301530
native int getCompilationActivityMode();
1531+
1532+
/**
1533+
* Returns whether the current thread is a CompilerThread.
1534+
*/
1535+
native boolean isCompilerThread();
15311536
}

src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,27 @@ private static class DummyCompilerFactory implements JVMCICompilerFactory, JVMCI
5151
DummyCompilerFactory(String reason, HotSpotJVMCIRuntime runtime) {
5252
this.reason = reason;
5353
this.runtime = runtime;
54+
if (runtime.getConfig().getFlag("EagerJVMCI", Boolean.class)) {
55+
if (runtime.getCompilerToVM().isCompilerThread()) {
56+
throw noCompilerError();
57+
} else {
58+
// This path will be taken when initializing JVMCI on a non-JIT thread.
59+
// Such a usage of JVMCI might never request a compilation so delay the
60+
// noCompilerError until such a request is made.
61+
}
62+
}
63+
}
64+
65+
/**
66+
* Exits the VM due to unavailability of a JVMCI compiler.
67+
*/
68+
Error noCompilerError() {
69+
throw runtime.exitHotSpotWithMessage(1, "Cannot use JVMCI compiler: %s%n", reason);
5470
}
5571

5672
@Override
5773
public HotSpotCompilationRequestResult compileMethod(CompilationRequest request) {
58-
throw runtime.exitHotSpotWithMessage(1, "Cannot use JVMCI compiler: %s%n", reason);
74+
throw noCompilerError();
5975
}
6076

6177
@Override

test/hotspot/jtreg/compiler/jvmci/TestJVMCIPrintProperties.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ static void test(String enableFlag) throws Exception {
4545
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
4646
"-XX:+UnlockExperimentalVMOptions",
4747
enableFlag, "-Djvmci.Compiler=null",
48+
"-XX:-EagerJVMCI",
4849
"-XX:+JVMCIPrintProperties");
4950
OutputAnalyzer output = new OutputAnalyzer(pb.start());
5051
output.shouldContain("[JVMCI properties]"); // expected message

0 commit comments

Comments
 (0)