Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,16 @@ private Target_com_oracle_truffle_espresso_jvmci_EspressoJVMCIRuntime() {
if (meta.jvmci.DummyEspressoGraalJVMCICompiler == null) {
throw meta.throwNoClassDefFoundErrorBoundary("com.oracle.truffle.espresso.graal.DummyEspressoGraalJVMCICompiler is missing");
}
openJVMCITo(meta.jvmci.GraalJVMCICompiler.module(), meta);
/*
* JVMCI.initializeRuntime has already opened JVMCI to jdk.graal.compiler. Let's further
* open it to jdk.graal.compiler.espresso.
*/
openJVMCITo(meta.jvmci.DummyEspressoGraalJVMCICompiler.module(), meta);
LOGGER.fine("Creating DummyEspressoGraalJVMCICompiler");
return (StaticObject) meta.jvmci.DummyEspressoGraalJVMCICompiler_create.invokeDirectStatic(self);
}

private static void openJVMCITo(ModuleTable.ModuleEntry compilerModuleEntry, Meta meta) {
static void openJVMCITo(ModuleTable.ModuleEntry compilerModuleEntry, Meta meta) {
LOGGER.finer(() -> "Opening JVMCI to " + compilerModuleEntry.getNameAsString());
StaticObject compilerModule = compilerModuleEntry.module();
meta.jvmci.Services_openJVMCITo.invokeDirectStatic(compilerModule);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
*/
package com.oracle.truffle.espresso.substitutions.jvmci;

import static com.oracle.truffle.espresso.substitutions.jvmci.Target_com_oracle_truffle_espresso_jvmci_EspressoJVMCIRuntime.openJVMCITo;

import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.espresso.EspressoLanguage;
import com.oracle.truffle.espresso.meta.Meta;
Expand All @@ -42,6 +44,23 @@ private Target_jdk_vm_ci_runtime_JVMCI() {
@Substitution
public static @JavaType(internalName = "Ljdk/vm/ci/runtime/JVMCIRuntime;") StaticObject initializeRuntime(@Inject EspressoContext context) {
checkJVMCIAvailable(context.getLanguage());
Meta meta = context.getMeta();
if (meta.jvmci.GraalJVMCICompiler != null) {
/*
* On HotSpot, HotSpotJVMCIRuntime.runtime uses JVMCIServiceLocator.getProviders which
* triggers Services.openJVMCITo for the module of HotSpotGraalJVMCIServiceLocator
* (jdk.graal.compiler). Achieve the same here by directly calling Services.openJVMCITo
* for the module of GraalJVMCICompiler (jdk.graal.compiler).
*
* Note that it is not enough to do this in
* EspressoJVMCIRuntime.createEspressoGraalJVMCICompiler since GraalServices could be
* used before the compiler is initialized.
*
* This is done only if GraalJVMCICompiler exists (i.e., jdk.graal.compiler is not an
* empty module).
*/
openJVMCITo(meta.jvmci.GraalJVMCICompiler.module(), meta);
}
return (StaticObject) context.getMeta().jvmci.EspressoJVMCIRuntime_runtime.invokeDirectStatic();
}

Expand Down