File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed
espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/substitutions/jvmci Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -70,13 +70,16 @@ private Target_com_oracle_truffle_espresso_jvmci_EspressoJVMCIRuntime() {
7070 if (meta .jvmci .DummyEspressoGraalJVMCICompiler == null ) {
7171 throw meta .throwNoClassDefFoundErrorBoundary ("com.oracle.truffle.espresso.graal.DummyEspressoGraalJVMCICompiler is missing" );
7272 }
73- openJVMCITo (meta .jvmci .GraalJVMCICompiler .module (), meta );
73+ /*
74+ * JVMCI.initializeRuntime has already opened JVMCI to jdk.graal.compiler. Let's further
75+ * open it to jdk.graal.compiler.espresso.
76+ */
7477 openJVMCITo (meta .jvmci .DummyEspressoGraalJVMCICompiler .module (), meta );
7578 LOGGER .fine ("Creating DummyEspressoGraalJVMCICompiler" );
7679 return (StaticObject ) meta .jvmci .DummyEspressoGraalJVMCICompiler_create .invokeDirectStatic (self );
7780 }
7881
79- private static void openJVMCITo (ModuleTable .ModuleEntry compilerModuleEntry , Meta meta ) {
82+ static void openJVMCITo (ModuleTable .ModuleEntry compilerModuleEntry , Meta meta ) {
8083 LOGGER .finer (() -> "Opening JVMCI to " + compilerModuleEntry .getNameAsString ());
8184 StaticObject compilerModule = compilerModuleEntry .module ();
8285 meta .jvmci .Services_openJVMCITo .invokeDirectStatic (compilerModule );
Original file line number Diff line number Diff line change 2222 */
2323package com .oracle .truffle .espresso .substitutions .jvmci ;
2424
25+ import static com .oracle .truffle .espresso .substitutions .jvmci .Target_com_oracle_truffle_espresso_jvmci_EspressoJVMCIRuntime .openJVMCITo ;
26+
2527import com .oracle .truffle .api .CompilerDirectives .TruffleBoundary ;
2628import com .oracle .truffle .espresso .EspressoLanguage ;
2729import com .oracle .truffle .espresso .meta .Meta ;
@@ -42,6 +44,23 @@ private Target_jdk_vm_ci_runtime_JVMCI() {
4244 @ Substitution
4345 public static @ JavaType (internalName = "Ljdk/vm/ci/runtime/JVMCIRuntime;" ) StaticObject initializeRuntime (@ Inject EspressoContext context ) {
4446 checkJVMCIAvailable (context .getLanguage ());
47+ Meta meta = context .getMeta ();
48+ if (meta .jvmci .GraalJVMCICompiler != null ) {
49+ /*
50+ * On HotSpot, HotSpotJVMCIRuntime.runtime uses JVMCIServiceLocator.getProviders which
51+ * triggers Services.openJVMCITo for the module of HotSpotGraalJVMCIServiceLocator
52+ * (jdk.graal.compiler). Achieve the same here by directly calling Services.openJVMCITo
53+ * for the module of GraalJVMCICompiler (jdk.graal.compiler).
54+ *
55+ * Note that it is not enough to do this in
56+ * EspressoJVMCIRuntime.createEspressoGraalJVMCICompiler since GraalServices could be
57+ * used before the compiler is initialized.
58+ *
59+ * This is done only if GraalJVMCICompiler exists (i.e., jdk.graal.compiler is not an
60+ * empty module).
61+ */
62+ openJVMCITo (meta .jvmci .GraalJVMCICompiler .module (), meta );
63+ }
4564 return (StaticObject ) context .getMeta ().jvmci .EspressoJVMCIRuntime_runtime .invokeDirectStatic ();
4665 }
4766
You can’t perform that action at this time.
0 commit comments