|
48 | 48 | #
|
49 | 49 | # ----------------------------------------------------------------------------------------------------------------------
|
50 | 50 | ENV_PYPY_HOME = "PYPY_HOME"
|
| 51 | +ENV_JYTHON_JAR = "JYTHON_JAR" |
51 | 52 | VM_NAME_GRAALPYTHON = "graalpython"
|
52 | 53 | VM_NAME_CPYTHON = "cpython"
|
53 | 54 | VM_NAME_PYPY = "pypy"
|
@@ -248,22 +249,55 @@ def name(self):
|
248 | 249 | return VM_NAME_PYPY
|
249 | 250 |
|
250 | 251 |
|
251 |
| -class JythonVm(AbstractPythonIterationsControlVm): |
| 252 | +class JythonVm(AbstractPythonIterationsControlVm, GuestVm): |
252 | 253 | JYTHON_INTERPRETER = "jython"
|
253 | 254 |
|
254 |
| - def __init__(self, config_name, options=None, env=None, iterations=None): |
255 |
| - super(JythonVm, self).__init__(config_name, options=options, env=env, iterations=iterations) |
| 255 | + def __init__(self, config_name, options=None, env=None, iterations=None, host_vm=None): |
| 256 | + AbstractPythonIterationsControlVm.__init__(self, config_name, options=options, env=env, iterations=iterations) |
| 257 | + GuestVm.__init__(self, host_vm=host_vm) |
256 | 258 |
|
257 | 259 | def override_iterations(self, requested_iterations):
|
258 |
| - return 2 |
| 260 | + return 3 |
| 261 | + |
| 262 | + def hosting_registry(self): |
| 263 | + return java_vm_registry |
259 | 264 |
|
260 | 265 | @property
|
261 | 266 | def interpreter(self):
|
262 | 267 | try:
|
263 | 268 | return subprocess.check_output("which %s" % JythonVm.JYTHON_INTERPRETER, shell=True).decode().strip()
|
264 |
| - except OSError as e: |
| 269 | + except Exception as e: |
265 | 270 | mx.log_error(e)
|
266 |
| - mx.abort("Error when executing `which jython`!\n") |
| 271 | + mx.abort("`jython` is neither on the path, nor is {} set!\n".format(ENV_JYTHON_JAR)) |
| 272 | + |
| 273 | + def run(self, cwd, args): |
| 274 | + jar = mx.get_env(ENV_JYTHON_JAR) |
| 275 | + if jar: |
| 276 | + _check_vm_args(self.name(), args) |
| 277 | + host_vm = self.host_vm() |
| 278 | + |
| 279 | + vm_args = mx.get_runtime_jvm_args([]) |
| 280 | + vm_args += ["-jar", jar] |
| 281 | + for a in args[:]: |
| 282 | + if a.startswith("-D") or a.startswith("-XX"): |
| 283 | + vm_args.insert(0, a) |
| 284 | + args.remove(a) |
| 285 | + args = self._override_iterations_args(args) |
| 286 | + cmd = vm_args + args |
| 287 | + |
| 288 | + if not self._env: |
| 289 | + self._env = dict() |
| 290 | + with environ(self._env): |
| 291 | + return host_vm.run(cwd, cmd) |
| 292 | + else: |
| 293 | + return AbstractPythonIterationsControlVm.run(self, cwd, args) |
| 294 | + |
| 295 | + def config_name(self): |
| 296 | + return self._config_name |
| 297 | + |
| 298 | + def with_host_vm(self, host_vm): |
| 299 | + return self.__class__(config_name=self._config_name, options=self._options, env=self._env, |
| 300 | + iterations=self._iterations, host_vm=host_vm) |
267 | 301 |
|
268 | 302 | def name(self):
|
269 | 303 | return VM_NAME_JYTHON
|
@@ -657,4 +691,3 @@ def rules(self, output, benchmarks, bm_suite_args):
|
657 | 691 | }
|
658 | 692 | ),
|
659 | 693 | ]
|
660 |
| - |
|
0 commit comments