Skip to content

Commit 501e976

Browse files
committed
Add benchmark guest vm config 'sandboxed'.
1 parent 6d76962 commit 501e976

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

mx.graalpython/mx_graalpython.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
from mx_gate import Task
3939
from mx_graalpython_bench_param import PATH_MESO, BENCHMARKS
4040
from mx_graalpython_benchmark import PythonBenchmarkSuite, python_vm_registry, CPythonVm, PyPyVm, GraalPythonVm, \
41-
CONFIGURATION_DEFAULT, CONFIGURATION_EXPERIMENTAL_SPLITTING
41+
CONFIGURATION_DEFAULT, CONFIGURATION_EXPERIMENTAL_SPLITTING, CONFIGURATION_SANDBOXED
4242
from mx_unittest import unittest
4343

4444
SUITE = mx.suite('graalpython')
@@ -850,6 +850,9 @@ def _register_vms(namespace):
850850
'-Dgraal.TruffleExperimentalSplitting=true',
851851
'-Dgraal.TruffleExperimentalSplittingAllowForcedSplits=false'
852852
]), SUITE, 10)
853+
python_vm_registry.add_vm(GraalPythonVm(config_name=CONFIGURATION_SANDBOXED, extra_polyglot_args=[
854+
'--llvm.sandboxed',
855+
]), SUITE, 10)
853856

854857

855858
def _register_bench_suites(namespace):

mx.graalpython/mx_graalpython_benchmark.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2018, Oracle and/or its affiliates.
1+
# Copyright (c) 2018, 2019, Oracle and/or its affiliates.
22
# Copyright (c) 2013, Regents of the University of California
33
#
44
# All rights reserved.
@@ -30,6 +30,7 @@
3030
from os.path import join
3131

3232
import mx
33+
import mx_subst
3334
import mx_benchmark
3435
from mx_benchmark import StdOutRule, java_vm_registry, Vm, GuestVm, VmBenchmarkSuite, AveragingBenchmarkMixin
3536
from mx_graalpython_bench_param import HARNESS_PATH
@@ -55,6 +56,7 @@
5556
PYTHON_VM_REGISTRY_NAME = "Python"
5657
CONFIGURATION_DEFAULT = "default"
5758
CONFIGURATION_EXPERIMENTAL_SPLITTING = "experimental_splitting"
59+
CONFIGURATION_SANDBOXED = "sandboxed"
5860

5961
DEFAULT_ITERATIONS = 10
6062

@@ -187,13 +189,14 @@ def name(self):
187189

188190
class GraalPythonVm(GuestVm):
189191
def __init__(self, config_name=CONFIGURATION_DEFAULT, distributions=None, cp_suffix=None, cp_prefix=None,
190-
host_vm=None, extra_vm_args=None):
192+
host_vm=None, extra_vm_args=None, extra_polyglot_args=None):
191193
super(GraalPythonVm, self).__init__(host_vm=host_vm)
192194
self._config_name = config_name
193195
self._distributions = distributions
194196
self._cp_suffix = cp_suffix
195197
self._cp_prefix = cp_prefix
196198
self._extra_vm_args = extra_vm_args
199+
self._extra_polyglot_args = extra_polyglot_args
197200

198201
def hosting_registry(self):
199202
return java_vm_registry
@@ -211,10 +214,15 @@ def run(self, cwd, args):
211214
assert isinstance(self._distributions, list), "distributions must be either None or a list"
212215
dists += self._distributions
213216

217+
extra_polyglot_args = self._extra_polyglot_args if isinstance(self._extra_polyglot_args, list) else []
214218
if mx.suite("sulong", fatalIfMissing=False):
215219
dists.append('SULONG')
216220
if mx.suite("sulong-managed", fatalIfMissing=False):
217221
dists.append('SULONG_MANAGED')
222+
extra_polyglot_args += [mx_subst.path_substitutions.substitute('--llvm.libraryPath=<path:SULONG_MANAGED_LIBS>')]
223+
else:
224+
extra_polyglot_args += [mx_subst.path_substitutions.substitute('--llvm.libraryPath=<path:SULONG_LIBS>')]
225+
218226

219227
vm_args = mx.get_runtime_jvm_args(dists, cp_suffix=self._cp_suffix, cp_prefix=self._cp_prefix)
220228
if isinstance(self._extra_vm_args, list):
@@ -223,7 +231,7 @@ def run(self, cwd, args):
223231
"-Dpython.home=%s" % join(SUITE.dir, "graalpython"),
224232
"com.oracle.graal.python.shell.GraalPythonMain"
225233
]
226-
cmd = truffle_options + vm_args + args
234+
cmd = truffle_options + vm_args + extra_polyglot_args + args
227235
return self.host_vm().run(cwd, cmd)
228236

229237
def name(self):
@@ -234,7 +242,8 @@ def config_name(self):
234242

235243
def with_host_vm(self, host_vm):
236244
return self.__class__(config_name=self._config_name, distributions=self._distributions,
237-
cp_suffix=self._cp_suffix, cp_prefix=self._cp_prefix, host_vm=host_vm)
245+
cp_suffix=self._cp_suffix, cp_prefix=self._cp_prefix, host_vm=host_vm,
246+
extra_vm_args=self._extra_vm_args, extra_polyglot_args=self._extra_polyglot_args)
238247

239248

240249
# ----------------------------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)