On Windows - GraalVM JavaScript offers preliminary support for Windows: set GRAALVM=c:\path\to\graalvm On MacOS - identical to the Linux command except for the path to GraalVM you need to add Contents/Home: GRAALVM=/path/to/graalvm/Contents/Home $JDK8/bin/java -cp $GRAALVM/jre/lib/graalvm/launcher-common.jar:$GRAALVM/jre/lib/graalvm/graaljs-launcher.jar:$GRAALVM/jre/languages/js/graaljs.jar:$GRAALVM/jre/lib/truffle/truffle-api.jar:$GRAALVM/jre/lib/boot/graal-sdk.jar:$GRAALVM/jre/lib/boot/graaljs-scriptengine.jar:$GRAALVM/jre/languages/regex/tregex.jar:$GRAALVM/jre/languages/js/icu4j.jar .shell.JSLauncher
See the JDK 11 example below for how to improve on this. Note that this variant does not include the GraalVM compiler as the optimizing compiler, so the performance of GraalVM JavaScript will be suboptimal. The following command line executes GraalVM JavaScript on a JDK 8, starting a JavaScript console. In a JDK11+ build, the *.jar files are located in different directories. The files are displayed here are for a JDK8 build.
In essence, the example POM file activates JVMCI to install additional JIT compilers, and configures the JIT compiler to be the GraalVM compiler by providing it on -module-path and -upgrade-module-path. Running with the GraalVM compiler will siginificantly improve the execution performance of any relatively large JavaScript codebase. It allows a user to compare the performance of GraalVM JavaScript running with or without the GraalVM compiler as the optimizing compiler. The example contains a Maven project for a JavaScript benchmark (a prime number generator). There is an example Maven project for GraalVM JavaScript on JDK11 (or later) using the GraalVM compiler at graal-js-jdk11-maven-demo. GraalVM JavaScript is open source and regularly pushed to Maven Central Repository by the community. This document describes how to run GraalVM JavaScript on stock Java VMs, and shows how you can use the GraalVM compiler as a JIT compiler to guarantee the best possible performance.
While the JIT compilers available on stock JVMs can execute and JIT-compile the GraalVM JavaScript codebase, they cannot optimize it to its full performance potential. When executed without the GraalVM compiler, JavaScript performance will be significantly worse. This guarantees best possible performance by using the GraalVM compiler as the optimizing compiler, and potentially Native Image to ahead-of-time compile the engine into a native binary.Īs GraalVM JavaScript is a Java application, it is possible to execute it on a stock Java VM like OpenJDK. GraalVM JavaScript is optimized for execution as part of GraalVM, or in an embedding scenario built on GraalVM.