oracle / graal

GraalVM compiles Java applications into native executables that start instantly, scale fast, and use fewer compute resources 🚀
https://www.graalvm.org
Other
20.16k stars 1.61k forks source link

GraalJS in OpenJDK using Karaf throws "Unknown JVM_CONSTANT tag 17" #6630

Open kaja-mohideen opened 1 year ago

kaja-mohideen commented 1 year ago

Describe the issue Trying to use the Graal JS (23.3.2) with latest stock OpenJDK with Apache Karaf throws "jdk.vm.ci.common.JVMCIError: Unknown JVM_CONSTANT tag 17"

Steps to reproduce the issue

  1. Use latest OpenJDK (output of java -version) openjdk version "11.0.20-beta" 2023-07-18 OpenJDK Runtime Environment Temurin-11.0.20+2-202305161807 (build 11.0.20-beta+2-202305161807) OpenJDK 64-Bit Server VM Temurin-11.0.20+2-202305161807 (build 11.0.20-beta+2-202305161807, mixed mode)
  2. Install Apache Karaf 4.3.6 (from karaf.apache.org)
  3. Place the following Graal JS related JARs under KARAF_HOME/lib/graal chromeinspector-22.3.2.jar compiler-22.3.2.jar compiler-management-22.3.2.jar graal-sdk-22.3.2.jar icu4j-73.1.jar js-22.3.2.jar js-scriptengine-22.3.2.jar profiler-22.3.2.jar regex-22.3.2.jar truffle-api-22.3.2.jar
  4. Update the JAVA_OPTS env variable as follows before starting karaf compilerJarName="compiler-22.3.2.jar" compilerMgmtJarName="compiler-management-22.3.2.jar" export JAVA_OPTS="-XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:+UseJVMCICompiler --module-path=${KARAF_HOME}/lib/graal --upgrade-module-path=${KARAF_HOME}/lib/graal/${compilerJarName}:${KARAF_HOME}/lib/graal/${compilerMgmtJarName}"
  5. Start Karaf ${KARAF_HOME}/bin/karaf
  6. Have a simple OSGi App that tries to create Graal JS Context and execute JavaScript code.

Describe GraalVM and your environment:

More details Add any other information about the problem here. Especially important are stack traces or log output. Feel free to link to gists or to screenshots if necessary.

org.graalvm.polyglot.PolyglotException: java.lang.AssertionError: Compiler initialization failed cannot continue.
    at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.hotspot.AbstractHotSpotTruffleRuntime.bypassedReservedOop(AbstractHotSpotTruffleRuntime.java:498)
    at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.hotspot.HotSpotFastThreadLocal.getJVMCIReservedReference(HotSpotFastThreadLocal.java:86)
    at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.hotspot.HotSpotFastThreadLocal.get(HotSpotFastThreadLocal.java:71)
    at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.hotspot.HotSpotFastThreadLocal.getJVMCIReservedReferenceNoFallback(HotSpotFastThreadLocal.java:122)
    at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.hotspot.HotSpotFastThreadLocal.getJVMCIReservedReference(HotSpotFastThreadLocal.java:92)
    at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.hotspot.HotSpotFastThreadLocal.get(HotSpotFastThreadLocal.java:71)
    at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.GraalFastThreadLocal.fastGet(GraalFastThreadLocal.java:64)
    at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotFastThreadLocals.needsEnter(PolyglotFastThreadLocals.java:129)
    at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotEngineImpl.needsEnter(PolyglotEngineImpl.java:1969)
    at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotEngineImpl.enterIfNeeded(PolyglotEngineImpl.java:1974)
    at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotValueDispatch.hostEnter(PolyglotValueDispatch.java:1228)
    at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotContextImpl.getBindings(PolyglotContextImpl.java:1203)
    at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotContextDispatch.getBindings(PolyglotContextDispatch.java:98)
    at org.graalvm.sdk/org.graalvm.polyglot.Context.getBindings(Context.java:560)
<< My App Call Stack >>
    at java.base/java.lang.Thread.run(Unknown Source)
Caused by: org.graalvm.compiler.java.BytecodeParser$BytecodeParserError: jdk.vm.ci.common.JVMCIError: Unknown JVM_CONSTANT tag 17
    at parsing platform/jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callBoundary(OptimizedCallTarget.java)
    at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.throwParserError(BytecodeParser.java:2518)
    at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3393)
    at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.handleBytecodeBlock(BytecodeParser.java:3345)
    at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.processBlock(BytecodeParser.java:3190)
    at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.build(BytecodeParser.java:1138)
    at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.buildRootMethod(BytecodeParser.java:1030)
    at jdk.internal.vm.compiler/org.graalvm.compiler.java.GraphBuilderPhase$Instance.run(GraphBuilderPhase.java:97)
    at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.run(Phase.java:49)
    at jdk.internal.vm.compiler/org.graalvm.compiler.phases.BasePhase.apply(BasePhase.java:446)
    at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.apply(Phase.java:42)
    at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.apply(Phase.java:38)
    at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.compiler.hotspot.HotSpotTruffleCompilerImpl.compileTruffleStub(HotSpotTruffleCompilerImpl.java:299)
    at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.compiler.hotspot.HotSpotTruffleCompilerImpl.lambda$installTruffleCallBoundaryMethod$0(HotSpotTruffleCompilerImpl.java:213)
    at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.compiler.hotspot.HotSpotTruffleCompilerImpl.compileAndInstallStub(HotSpotTruffleCompilerImpl.java:259)
    at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.compiler.hotspot.HotSpotTruffleCompilerImpl.installTruffleCallBoundaryMethod(HotSpotTruffleCompilerImpl.java:211)
    at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.hotspot.AbstractHotSpotTruffleRuntime.installCallBoundaryMethods(AbstractHotSpotTruffleRuntime.java:529)
    at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.hotspot.AbstractHotSpotTruffleRuntime.initializeTruffleCompiler(AbstractHotSpotTruffleRuntime.java:301)
    at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.hotspot.AbstractHotSpotTruffleRuntime$1.accept(AbstractHotSpotTruffleRuntime.java:253)
    at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.hotspot.AbstractHotSpotTruffleRuntime$1.accept(AbstractHotSpotTruffleRuntime.java:249)
    at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.CompilationTask.call(CompilationTask.java:225)
    at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.CompilationTask.call(CompilationTask.java:42)
    at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.base/java.lang.Thread.run(Unknown Source)
    at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.BackgroundCompileQueue$TruffleCompilerThreadFactory$1.run(BackgroundCompileQueue.java:289)
Caused by: jdk.vm.ci.common.JVMCIError: Unknown JVM_CONSTANT tag 17
    at jdk.internal.vm.ci/jdk.vm.ci.hotspot.HotSpotConstantPool$JVM_CONSTANT$TagValueMap.get(Unknown Source)
    at jdk.internal.vm.ci/jdk.vm.ci.hotspot.HotSpotConstantPool$JVM_CONSTANT.getEnum(Unknown Source)
    at jdk.internal.vm.ci/jdk.vm.ci.hotspot.HotSpotConstantPool.getTagAt(Unknown Source)
    at jdk.internal.vm.ci/jdk.vm.ci.hotspot.HotSpotConstantPool.loadReferencedType(Unknown Source)
    at jdk.internal.vm.ci/jdk.vm.ci.hotspot.HotSpotConstantPool.loadReferencedType(Unknown Source)
    at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.loadReferenceType(BytecodeParser.java:4292)
    at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.maybeEagerlyResolve(BytecodeParser.java:4269)
    at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.lookupConstant(BytecodeParser.java:4256)
    at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.genLoadConstant(BytecodeParser.java:3937)
    at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.processBytecode(BytecodeParser.java:5124)
    at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3385)
    ... 24 more
Caused by: Attached Guest Language Frames (0)
Internal GraalVM error, please report at https://github.com/oracle/graal/issues/.
dougxc commented 1 year ago

Looks like an incompatible JVMCI implementation being mixed with Graal. Please try using a labsjdk binary instead.

kaja-mohideen commented 1 year ago

Thanks @dougxc for your suggestion. I have tried using a nightly build of Java taken from the page here --> https://adoptium.net/temurin/nightly/?version=11 and it's visible in the java -version output as well.

Do you mean something different when you say "labsjdk"? If so, kindly help by providing link from where I can obtain the binary.

Thanks again.

kaja-mohideen commented 1 year ago

Slack thread link --> https://graalvm.slack.com/archives/CNBFR78F9/p1684137184970519 - There, I got input from @chumer about trying it on latest java.

dougxc commented 1 year ago

If I understand GraalJS versioning properly, then GraalJS 22.3.2 should be compatible with https://github.com/graalvm/labs-openjdk-11/releases/tag/jvmci-22.3-b04. @chumer @woess can you pease confirm that.

chumer commented 1 year ago

Sounds right to me.