Skip to content

Commit fa58671

Browse files
author
Doug Simon
committed
8257020: [JVMCI] enable a JVMCICompiler to specify which GCs it supports
Reviewed-by: stefank, kvn
1 parent 129c377 commit fa58671

File tree

21 files changed

+197
-41
lines changed

21 files changed

+197
-41
lines changed

src/hotspot/share/compiler/compilerDefinitions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ void CompilerConfig::ergo_initialize() {
457457
#endif
458458

459459
#if INCLUDE_JVMCI
460-
// Check that JVMCI compiler supports selested GC.
460+
// Check that JVMCI supports selected GC.
461461
// Should be done after GCConfig::initialize() was called.
462462
JVMCIGlobals::check_jvmci_supported_gc();
463463

src/hotspot/share/jvmci/jvmciEnv.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,31 @@ void JVMCIEnv::fthrow_error(const char* file, int line, const char* format, ...)
635635
}
636636
}
637637

638+
jboolean JVMCIEnv::call_HotSpotJVMCIRuntime_isGCSupported (JVMCIObject runtime, jint gcIdentifier) {
639+
JavaThread* THREAD = JavaThread::current();
640+
if (is_hotspot()) {
641+
JavaCallArguments jargs;
642+
jargs.push_oop(Handle(THREAD, HotSpotJVMCI::resolve(runtime)));
643+
jargs.push_int(gcIdentifier);
644+
JavaValue result(T_BOOLEAN);
645+
JavaCalls::call_special(&result,
646+
HotSpotJVMCI::HotSpotJVMCIRuntime::klass(),
647+
vmSymbols::isGCSupported_name(),
648+
vmSymbols::int_bool_signature(), &jargs, CHECK_0);
649+
return result.get_jboolean();
650+
} else {
651+
JNIAccessMark jni(this, THREAD);
652+
jboolean result = jni()->CallNonvirtualBooleanMethod(runtime.as_jobject(),
653+
JNIJVMCI::HotSpotJVMCIRuntime::clazz(),
654+
JNIJVMCI::HotSpotJVMCIRuntime::isGCSupported_method(),
655+
gcIdentifier);
656+
if (jni()->ExceptionCheck()) {
657+
return false;
658+
}
659+
return result;
660+
}
661+
}
662+
638663
JVMCIObject JVMCIEnv::call_HotSpotJVMCIRuntime_compileMethod (JVMCIObject runtime, JVMCIObject method, int entry_bci,
639664
jlong compile_state, int id) {
640665
JavaThread* THREAD = JVMCI::compilation_tick(JavaThread::current());

src/hotspot/share/jvmci/jvmciEnv.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,8 @@ class JVMCIEnv : public ResourceObj {
310310
JVMCIObject call_JavaConstant_forFloat(float value, JVMCI_TRAPS);
311311
JVMCIObject call_JavaConstant_forDouble(double value, JVMCI_TRAPS);
312312

313+
jboolean call_HotSpotJVMCIRuntime_isGCSupported(JVMCIObject runtime, jint gcIdentifier);
314+
313315
BasicType kindToBasicType(JVMCIObject kind, JVMCI_TRAPS);
314316

315317
#define DO_THROW(name) \

src/hotspot/share/jvmci/jvmciJavaClasses.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@
348348
start_class(HotSpotJVMCIRuntime, jdk_vm_ci_hotspot_HotSpotJVMCIRuntime) \
349349
objectarray_field(HotSpotJVMCIRuntime, excludeFromJVMCICompilation, "[Ljava/lang/Module;") \
350350
jvmci_method(CallNonvirtualObjectMethod, GetMethodID, call_special, JVMCIObject, HotSpotJVMCIRuntime, compileMethod, compileMethod_signature, (JVMCIObject runtime, JVMCIObject method, int entry_bci, jlong env, int id)) \
351+
jvmci_method(CallNonvirtualObjectMethod, GetMethodID, call_special, JVMCIObject, HotSpotJVMCIRuntime, isGCSupported, int_bool_signature, (JVMCIObject runtime, int gcIdentifier)) \
351352
jvmci_method(CallStaticObjectMethod, GetStaticMethodID, call_static, JVMCIObject, HotSpotJVMCIRuntime, encodeThrowable, encodeThrowable_signature, (JVMCIObject throwable)) \
352353
jvmci_method(CallStaticObjectMethod, GetStaticMethodID, call_static, JVMCIObject, HotSpotJVMCIRuntime, decodeThrowable, decodeThrowable_signature, (JVMCIObject encodedThrowable)) \
353354
jvmci_method(CallNonvirtualVoidMethod, GetMethodID, call_special, void, HotSpotJVMCIRuntime, bootstrapFinished, void_method_signature, (JVMCIObject runtime, JVMCI_TRAPS)) \

src/hotspot/share/jvmci/jvmciRuntime.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,6 +1516,15 @@ void JVMCIRuntime::compile_method(JVMCIEnv* JVMCIENV, JVMCICompiler* compiler, c
15161516
}
15171517
}
15181518

1519+
bool JVMCIRuntime::is_gc_supported(JVMCIEnv* JVMCIENV, CollectedHeap::Name name) {
1520+
JVMCI_EXCEPTION_CONTEXT
1521+
1522+
JVMCIObject receiver = get_HotSpotJVMCIRuntime(JVMCIENV);
1523+
if (JVMCIENV->has_pending_exception()) {
1524+
fatal_exception(JVMCIENV, "Exception during HotSpotJVMCIRuntime initialization");
1525+
}
1526+
return JVMCIENV->call_HotSpotJVMCIRuntime_isGCSupported(receiver, (int) name);
1527+
}
15191528

15201529
// ------------------------------------------------------------------
15211530
JVMCI::CodeInstallResult JVMCIRuntime::register_method(JVMCIEnv* JVMCIENV,

src/hotspot/share/jvmci/jvmciRuntime.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#define SHARE_JVMCI_JVMCIRUNTIME_HPP
2626

2727
#include "code/nmethod.hpp"
28+
#include "gc/shared/collectedHeap.hpp"
2829
#include "jvmci/jvmci.hpp"
2930
#include "jvmci/jvmciExceptions.hpp"
3031
#include "jvmci/jvmciObject.hpp"
@@ -279,6 +280,9 @@ class JVMCIRuntime: public CHeapObj<mtJVMCI> {
279280
// Compiles `target` with the JVMCI compiler.
280281
void compile_method(JVMCIEnv* JVMCIENV, JVMCICompiler* compiler, const methodHandle& target, int entry_bci);
281282

283+
// Determines if the GC identified by `name` is supported by the JVMCI compiler.
284+
bool is_gc_supported(JVMCIEnv* JVMCIENV, CollectedHeap::Name name);
285+
282286
// Register the result of a compilation.
283287
JVMCI::CodeInstallResult register_method(JVMCIEnv* JVMCIENV,
284288
const methodHandle& target,

src/hotspot/share/jvmci/jvmci_globals.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,15 @@ bool JVMCIGlobals::enable_jvmci_product_mode(JVMFlagOrigin origin) {
200200
return true;
201201
}
202202

203+
bool JVMCIGlobals::gc_supports_jvmci() {
204+
return UseSerialGC || UseParallelGC || UseG1GC;
205+
}
206+
203207
void JVMCIGlobals::check_jvmci_supported_gc() {
204208
if (EnableJVMCI) {
205209
// Check if selected GC is supported by JVMCI and Java compiler
206-
if (!(UseSerialGC || UseParallelGC || UseG1GC)) {
207-
vm_exit_during_initialization("JVMCI Compiler does not support selected GC", GCConfig::hs_err_name());
210+
if (!gc_supports_jvmci()) {
211+
log_warning(gc, jvmci)("Setting EnableJVMCI to false as selected GC does not support JVMCI: %s", GCConfig::hs_err_name());
208212
FLAG_SET_DEFAULT(EnableJVMCI, false);
209213
FLAG_SET_DEFAULT(UseJVMCICompiler, false);
210214
}

src/hotspot/share/jvmci/jvmci_globals.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,10 @@ class JVMCIGlobals {
155155
// Convert JVMCI experimental flags to product
156156
static bool enable_jvmci_product_mode(JVMFlagOrigin);
157157

158-
// Check and exit VM with error if selected GC is not supported by JVMCI.
158+
// Returns true iff the GC fully supports JVMCI.
159+
static bool gc_supports_jvmci();
160+
161+
// Check and turn off EnableJVMCI if selected GC does not support JVMCI.
159162
static void check_jvmci_supported_gc();
160163

161164
static fileStream* get_jni_config_file() { return _jni_config_file; }

src/hotspot/share/jvmci/vmStructs_jvmci.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,14 @@
482482
declare_constant(CodeInstaller::VERIFY_OOP_MASK) \
483483
declare_constant(CodeInstaller::INVOKE_INVALID) \
484484
\
485+
declare_constant(CollectedHeap::None) \
486+
declare_constant(CollectedHeap::Serial) \
487+
declare_constant(CollectedHeap::Parallel) \
488+
declare_constant(CollectedHeap::G1) \
489+
declare_constant(CollectedHeap::Epsilon) \
490+
declare_constant(CollectedHeap::Z) \
491+
declare_constant(CollectedHeap::Shenandoah) \
492+
\
485493
declare_constant(vmIntrinsics::FIRST_MH_SIG_POLY) \
486494
declare_constant(vmIntrinsics::LAST_MH_SIG_POLY) \
487495
declare_constant(vmIntrinsics::_invokeGeneric) \

src/hotspot/share/jvmci/vmSymbols_jvmci.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
template(visitFrame_signature, "(Ljdk/vm/ci/code/stack/InspectedFrame;)Ljava/lang/Object;") \
104104
template(compileMethod_name, "compileMethod") \
105105
template(compileMethod_signature, "(Ljdk/vm/ci/hotspot/HotSpotResolvedJavaMethod;IJI)Ljdk/vm/ci/hotspot/HotSpotCompilationRequestResult;") \
106+
template(isGCSupported_name, "isGCSupported") \
106107
template(encodeThrowable_name, "encodeThrowable") \
107108
template(encodeThrowable_signature, "(Ljava/lang/Throwable;)Ljava/lang/String;") \
108109
template(decodeThrowable_name, "decodeThrowable") \

0 commit comments

Comments
 (0)