Skip to content

Commit 69f244d

Browse files
committed
Fixed mx wasm and TruffleUnitTestConfig.
1 parent ea5ee28 commit 69f244d

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

truffle/mx.truffle/mx_truffle.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,17 @@ def enable_truffle_native_access(vmArgs):
215215
vmArgs.extend([f'--enable-native-access={native_access_target_module}'])
216216
return vmArgs
217217

218+
def enable_sun_misc_unsafe(vmArgs):
219+
"""
220+
Enables `sun.misc.Unsafe` access.
221+
This function appends the `--sun-misc-unsafe-memory-access=allow` option to the
222+
list of JVM arguments if the JDK version is 23 or higher. It then returns the
223+
updated list of arguments.
224+
"""
225+
if mx.VersionSpec("23.0.0") <= mx.get_jdk(tag="graalvm").version:
226+
vmArgs.extend(['--sun-misc-unsafe-memory-access=allow'])
227+
return vmArgs
228+
218229
class TruffleUnittestConfig(mx_unittest.MxUnittestConfig):
219230

220231
_use_enterprise_polyglot = True
@@ -247,6 +258,7 @@ def apply(self, config):
247258
# Disable VirtualThread warning
248259
vmArgs = vmArgs + ['-Dpolyglot.engine.WarnVirtualThreadSupport=false']
249260
enable_truffle_native_access(vmArgs)
261+
enable_sun_misc_unsafe(vmArgs)
250262
return (vmArgs, mainClass, mainClassArgs)
251263

252264

wasm/mx.wasm/mx_wasm.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import mx
4949
import mx_benchmark
5050
import mx_sdk_vm
51+
import mx_truffle
5152
import mx_unittest
5253
import mx_util
5354
# noinspection PyUnresolvedReferences
@@ -152,6 +153,10 @@ def apply(self, config):
152153
# Disable DefaultRuntime warning
153154
vmArgs += ['-Dpolyglot.engine.WarnInterpreterOnly=false']
154155
vmArgs += ['-Dpolyglot.engine.AllowExperimentalOptions=true']
156+
# This is needed for Truffle since JEP 472: Prepare to Restrict the Use of JNI
157+
mx_truffle.enable_truffle_native_access(vmArgs)
158+
# GR-59703: This is needed for Truffle since JEP 498: Warn upon Use of Memory-Access Methods in sun.misc.Unsafe
159+
mx_truffle.enable_sun_misc_unsafe(vmArgs)
155160
# Assert for enter/return parity of ProbeNode (if assertions are enabled only)
156161
if next((arg.startswith('-e') for arg in reversed(vmArgs) if arg in ['-ea', '-da', '-enableassertions', '-disableassertions']), False):
157162
vmArgs += ['-Dpolyglot.engine.AssertProbes=true']
@@ -634,6 +639,8 @@ def wasm(args, **kwargs):
634639
vmArgs, wasmArgs = mx.extract_VM_args(args, useDoubleDash=True, defaultAllVMArgs=False)
635640
# This is needed for Truffle since JEP 472: Prepare to Restrict the Use of JNI
636641
vmArgs += ['--enable-native-access=org.graalvm.truffle']
642+
# GR-59703: This is needed for Truffle since JEP 498: Warn upon Use of Memory-Access Methods in sun.misc.Unsafe
643+
mx_truffle.enable_sun_misc_unsafe(vmArgs)
637644

638645
path_args = mx.get_runtime_jvm_args([
639646
"TRUFFLE_API",

0 commit comments

Comments
 (0)