Skip to content

Commit 5ce7a2f

Browse files
committed
add explicit use of -XX:+EnableJVMCI on command line or in jimage vm options
1 parent f231e31 commit 5ce7a2f

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

docs/reference-manual/embedding/embed-languages.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,15 +415,17 @@ This table shows the level of optimizations the Java runtimes currently provide:
415415
|-----------------------------------------------|---------------------------------------------------|
416416
| Oracle GraalVM | Optimized with additional compiler passes |
417417
| GraalVM Community Edition | Optimized |
418-
| Oracle JDK | Optimized if enabled via experimental VM option |
419-
| OpenJDK | Optimized if enabled via experimental VM option |
418+
| Oracle JDK | Optimized via VM option |
419+
| OpenJDK | Optimized via VM option and upgrade-module-path |
420420
| JDK without JVMCI capability | No runtime optimizations (interpreter-only) |
421421
422422
### Explanations
423423
424424
* **Optimized:** Executed guest application code can be compiled and executed as highly efficient machine code at run time.
425425
* **Optimized with additional compiler passes:** Oracle GraalVM implements additional optimizations performed during runtime compilation. For example, it uses a more advanced inlining heuristic. This typically leads to better runtime performance and memory consumption.
426-
* **Optimized if enabled via experimental VM option:** Optimization is not enabled by default and must be enabled using `-XX:+EnableJVMCI` virtual machine option. In addition, to support compilation, the Graal compiler must be downloaded as a JAR file and put on the `--upgrade-module-path`. In this mode, the compiler runs as a Java application and may negatively affect the execution performance of the host application.
426+
* **Optimized via VM option:** Optimization is enabled by specifying `-XX:+EnableJVMCI` to the `java` launcher.
427+
* **Optimized via VM option and upgrade-module-path:** Optimization is enabled by specifying `-XX:+EnableJVMCI` to the `java` launcher.
428+
In addition, the Graal compiler must be downloaded as a JAR file and put on the `--upgrade-module-path`. In this mode, the compiler runs as a Java application and may negatively affect the execution performance of the host application.
427429
* **No runtime optimizations:** With no runtime optimizations or if JVMCI is not enabled, the guest application code is executed in interpreter-only mode.
428430
* **JVMCI:** Refers to the [Java-Level JVM Compiler Interface](https://openjdk.org/jeps/243) supported by most Java runtimes.
429431

sdk/mx.sdk/mx_sdk.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,7 @@ def __init__(self):
273273
# Oracle JDK includes the libjvmci compiler, allowing it to function as GraalVM.
274274
# However, the Graal compiler is disabled by default and must be explicitly enabled using the -XX:+UseJVMCICompiler option.
275275
graalvm_home = default_jdk.home
276-
# GR-58388: Switch '-XX:+UseJVMCINativeLibrary' to '-XX:+UseGraalJIT'
277-
additional_vm_args = ['-XX:+UnlockExperimentalVMOptions', '-XX:+EnableJVMCI', '-XX:+UseJVMCINativeLibrary', '-XX:-UnlockExperimentalVMOptions']
276+
additional_vm_args = ['-XX:+UnlockExperimentalVMOptions', '-XX:+EnableJVMCI', '-XX:+UseGraalJIT', '-XX:-UnlockExperimentalVMOptions']
278277
else:
279278
graalvm_home = mx_sdk_vm.graalvm_home(fatalIfMissing=True)
280279
additional_vm_args = []

sdk/mx.sdk/mx_sdk_vm.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,8 @@ def _get_image_vm_options(jdk, use_upgrade_module_path, modules, synthetic_modul
776776
if default_to_jvmci or 'jdk.graal.compiler' in non_synthetic_modules:
777777
threads = get_JVMCIThreadsPerNativeLibraryRuntime(jdk)
778778
vm_options.extend(['-XX:+UnlockExperimentalVMOptions', '-XX:+EnableJVMCIProduct'])
779+
# As of JDK-8345826, the JVMCI module must be explicitly added to the root set
780+
vm_options.append('-XX:+EnableJVMCI')
779781
if threads is not None and threads != 1:
780782
vm_options.append('-XX:JVMCIThreadsPerNativeLibraryRuntime=1')
781783
if default_to_jvmci == 'lib':
@@ -978,7 +980,7 @@ def jlink_new_jdk(jdk, dst_jdk_dir, module_dists, ignore_dists,
978980
jlink_persist = []
979981

980982
if jdk_enables_jvmci_by_default(jdk):
981-
# On JDK 9+, +EnableJVMCI forces jdk.internal.vm.ci to be in the root set
983+
# +EnableJVMCI forces jdk.internal.vm.ci to be in the root set
982984
jlink += ['-J-XX:-EnableJVMCI', '-J-XX:-UseJVMCICompiler']
983985

984986
jlink.append('--add-modules=' + ','.join(_get_image_root_modules(root_module_names, module_names, jdk_modules.keys(), use_upgrade_module_path)))

truffle/mx.truffle/mx_truffle.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,8 +494,13 @@ def _truffle_gate_runner(args, tasks):
494494

495495

496496
def gate_truffle_jvm(tasks):
497-
if mx_sdk.GraalVMJDKConfig.is_libgraal_jdk(mx.get_jdk(tag='default').home):
497+
default_jdk = mx.get_jdk(tag='default')
498+
if mx_sdk.GraalVMJDKConfig.is_libgraal_jdk(default_jdk.home):
498499
additional_jvm_args = ['-XX:+UnlockExperimentalVMOptions', '-XX:+EnableJVMCI', '-XX:+UseJVMCINativeLibrary', '-XX:-UnlockExperimentalVMOptions']
500+
elif default_jdk.javaCompliance >= '25':
501+
# As of JDK-8345826, -XX:+EnableJVMCI must be on the command line
502+
# to load the JVMCI module if libgraal is in use
503+
additional_jvm_args = ['-XX:+EnableJVMCI']
499504
else:
500505
additional_jvm_args = []
501506
# GR-62632: Debug VM exception translation failure

0 commit comments

Comments
 (0)