Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/hotspot/share/jvmci/jvmciCompilerToVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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() {
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/jvmci/jvmci_globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion src/hotspot/share/jvmci/jvmci_globals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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") \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1528,4 +1528,9 @@ void getOopMapAt(HotSpotResolvedJavaMethodImpl method, int bci, long[] oopMap) {
* {@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();
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,27 @@ private static class DummyCompilerFactory implements JVMCICompilerFactory, JVMCI
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ static void test(String enableFlag) throws Exception {
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
Expand Down