Skip to content

Commit 0efa9f6

Browse files
committed
add explicit use of -XX:+EnableJVMCI on command line or in jimage vm options
1 parent 72c8f61 commit 0efa9f6

File tree

7 files changed

+29
-17
lines changed

7 files changed

+29
-17
lines changed

ci/common.jsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ local common_json = import "../common.json";
5656
[name]: jdk_base + common_json.jdks[name] + { jdk_version:: 21 }
5757
for name in ["oraclejdk21"] + variants("labsjdk-ce-21") + variants("labsjdk-ee-21")
5858
} + {
59-
'oraclejdk23': jdk_base + common_json.jdks["oraclejdk23"] + { jdk_version:: 23 },
59+
'oraclejdk24': jdk_base + common_json.jdks["oraclejdk24"] + { jdk_version:: 24 },
6060
} + {
6161
[name]: jdk_base + common_json.jdks[name] + { jdk_version:: parse_labsjdk_version(self), jdk_name:: "jdk-latest"}
6262
for name in ["oraclejdk-latest"] + variants("labsjdk-ce-latest") + variants("labsjdk-ee-latest")

common.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"labsjdk-ee-21-llvm": {"name": "labsjdk", "version": "ee-21.0.2+13-jvmci-23.1-b33-sulong", "platformspecific": true },
4444
"graalvm-ee-21": {"name": "graalvm-java21", "version": "23.1.6", "platformspecific": true },
4545

46-
"oraclejdk23": {"name": "jpg-jdk", "version": "23", "build_id": "jdk-23+37", "platformspecific": true, "extrabundles": ["static-libs"]},
46+
"oraclejdk24": {"name": "jpg-jdk", "version": "24", "build_id": "jdk-24.0.1+9", "platformspecific": true, "extrabundles": ["static-libs"]},
4747

4848
"oraclejdk-latest": {"name": "jpg-jdk", "version": "25", "build_id": "jdk-25+22", "platformspecific": true, "extrabundles": ["static-libs"]},
4949
"labsjdk-ce-latest": {"name": "jpg-jdk", "version": "25", "build_id": "2025-05-17-2228274.doug.simon.open", "platformspecific": true, "extrabundles": ["static-libs"]},

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -411,19 +411,20 @@ Polyglot Truffle runtimes can be used on several host virtual machines with vary
411411
Runtime optimization of guest application code is crucial for the efficient execution of embedded guest applications.
412412
This table shows the level of optimizations the Java runtimes currently provide:
413413
414-
| Java Runtime | Runtime Optimization Level |
415-
|-----------------------------------------------|---------------------------------------------------|
416-
| Oracle GraalVM | Optimized with additional compiler passes |
417-
| GraalVM Community Edition | Optimized |
418-
| Oracle JDK | Optimized if enabled via experimental VM option |
419-
| OpenJDK | Optimized if enabled via experimental VM option |
420-
| JDK without JVMCI capability | No runtime optimizations (interpreter-only) |
414+
| Java Runtime | Runtime Optimization Level |
415+
|-----------------------------------------------|-----------------------------------------------------|
416+
| Oracle GraalVM | Best (includes additional compiler optimizations) |
417+
| GraalVM Community Edition | Optimized |
418+
| Oracle JDK | Optimized via VM option |
419+
| OpenJDK | Optimized via VM option and `--upgrade-module-path` |
420+
| 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. Additionally, the Graal compiler must be downloaded as a JAR file and specified to the `java` launcher with `--upgrade-module-path`. In this mode, the compiler runs as a Java application and may negatively affect the execution performance of the host application.
427428
* **No runtime optimizations:** With no runtime optimizations or if JVMCI is not enabled, the guest application code is executed in interpreter-only mode.
428429
* **JVMCI:** Refers to the [Java-Level JVM Compiler Interface](https://openjdk.org/jeps/243) supported by most Java runtimes.
429430

sdk/mx.sdk/mx_sdk.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,16 @@ def jlink_new_jdk(jdk, dst_jdk_dir, module_dists, ignore_dists,
261261
default_to_jvmci=default_to_jvmci)
262262

263263
class GraalVMJDKConfig(mx.JDKConfig):
264+
265+
# Oracle JDK includes the libjvmci compiler, allowing it to function as GraalVM.
266+
# However, the Graal compiler is disabled by default and must be explicitly
267+
# enabled using the -XX:+UseGraalJIT option.
268+
libgraal_additional_vm_args = [
269+
'-XX:+UnlockExperimentalVMOptions',
270+
'-XX:+EnableJVMCI',
271+
'-XX:+UseGraalJIT',
272+
'-XX:-UnlockExperimentalVMOptions'
273+
]
264274
"""
265275
A JDKConfig that configures the built GraalVM as a JDK config.
266276
"""
@@ -270,11 +280,8 @@ def __init__(self):
270280
graalvm_home = default_jdk.home
271281
additional_vm_args = []
272282
elif GraalVMJDKConfig.is_libgraal_jdk(default_jdk.home):
273-
# Oracle JDK includes the libjvmci compiler, allowing it to function as GraalVM.
274-
# However, the Graal compiler is disabled by default and must be explicitly enabled using the -XX:+UseJVMCICompiler option.
275283
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']
284+
additional_vm_args = GraalVMJDKConfig.libgraal_additional_vm_args
278285
else:
279286
graalvm_home = mx_sdk_vm.graalvm_home(fatalIfMissing=True)
280287
additional_vm_args = []

sdk/mx.sdk/mx_sdk_vm.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,9 @@ 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+
# -XX:+EnableJVMCI must be explicitly specified to the java launcher to add
780+
# jdk.internal.vm.ci to the root set (JDK-8345826)
781+
vm_options.append('-XX:+EnableJVMCI')
779782
if threads is not None and threads != 1:
780783
vm_options.append('-XX:JVMCIThreadsPerNativeLibraryRuntime=1')
781784
if default_to_jvmci == 'lib':
@@ -978,7 +981,7 @@ def jlink_new_jdk(jdk, dst_jdk_dir, module_dists, ignore_dists,
978981
jlink_persist = []
979982

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

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

truffle/ci/ci.jsonnet

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@
163163
linux_amd64 + graalVMCELatest + simple_tool_maven_project_gate,
164164
# Truffle JVM gate
165165
linux_amd64 + common.graalvmee21 + truffle_jvm_gate,
166-
linux_amd64 + common.oraclejdk23 + truffle_jvm_gate,
166+
# GR-XXXXX
167+
# linux_amd64 + common.oraclejdk24 + truffle_jvm_gate,
167168
linux_amd64 + graalVMCELatest + truffle_jvm_gate,
168169
# Truffle Native gate
169170
linux_amd64 + common.graalvmee21 + truffle_native_gate,

truffle/mx.truffle/mx_truffle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ def _truffle_gate_runner(args, tasks):
499499

500500
def gate_truffle_jvm(tasks):
501501
if mx_sdk.GraalVMJDKConfig.is_libgraal_jdk(mx.get_jdk(tag='default').home):
502-
additional_jvm_args = ['-XX:+UnlockExperimentalVMOptions', '-XX:+EnableJVMCI', '-XX:+UseJVMCINativeLibrary', '-XX:-UnlockExperimentalVMOptions']
502+
additional_jvm_args = mx_sdk.GraalVMJDKConfig.libgraal_additional_vm_args
503503
else:
504504
additional_jvm_args = []
505505
# GR-62632: Debug VM exception translation failure

0 commit comments

Comments
 (0)