comparison mx.graal/mx_graal_9.py @ 22882:9fed99d7f32d

made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
author Doug Simon <doug.simon@oracle.com>
date Sat, 24 Oct 2015 00:49:18 +0200
parents
children a9b332b34123
comparison
equal deleted inserted replaced
22881:c949fcd766c0 22882:9fed99d7f32d
1 #
2 # ----------------------------------------------------------------------------------------------------
3 #
4 # Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
5 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 #
7 # This code is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License version 2 only, as
9 # published by the Free Software Foundation.
10 #
11 # This code is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 # version 2 for more details (a copy is included in the LICENSE file that
15 # accompanied this code).
16 #
17 # You should have received a copy of the GNU General Public License version
18 # 2 along with this work; if not, write to the Free Software Foundation,
19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 #
21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 # or visit www.oracle.com if you need additional information or have any
23 # questions.
24 #
25 # ----------------------------------------------------------------------------------------------------
26
27 import os
28 from os.path import join
29 from argparse import ArgumentParser
30 import sanitycheck
31 import itertools
32 import json
33 import re
34
35 import mx
36 from mx_gate import Task
37 from sanitycheck import _noneAsEmptyList
38
39 from mx_unittest import unittest
40 import mx_gate
41 import mx_unittest
42
43 _suite = mx.suite('graal')
44
45 _jdk = mx.get_jdk()
46 assert _jdk.javaCompliance >= "1.9"
47
48 def isJVMCIEnabled(vm):
49 return True
50
51 _jvmciModes = {
52 'hosted' : ['-XX:+UnlockExperimentalVMOptions', '-XX:+EnableJVMCI'],
53 'jit' : ['-XX:+UnlockExperimentalVMOptions', '-XX:+EnableJVMCI', '-XX:+UseJVMCICompiler'],
54 'disabled' : []
55 }
56
57 def get_vm():
58 """
59 Gets the name of the currently selected JVM variant.
60 """
61 return 'server'
62
63 class JVMCIMode:
64 """
65 A context manager for setting the current JVMCI mode.
66 """
67 def __init__(self, jvmciMode=None):
68 self.update(jvmciMode)
69
70 def update(self, jvmciMode=None):
71 assert jvmciMode is None or jvmciMode in _jvmciModes, jvmciMode
72 self.jvmciMode = jvmciMode or _vm.jvmciMode
73
74 def __enter__(self):
75 global _vm
76 self.previousVm = _vm
77 _vm = self
78
79 def __exit__(self, exc_type, exc_value, traceback):
80 global _vm
81 _vm = self.previousVm
82
83 _vm = JVMCIMode(jvmciMode='hosted')
84
85 _compilers = ['graal-economy', 'graal']
86 _graalDists = [
87 'GRAAL_NODEINFO',
88 'GRAAL_API',
89 'GRAAL_COMPILER',
90 'GRAAL',
91 'GRAAL_HOTSPOT',
92 'GRAAL_TRUFFLE',
93 'GRAAL_TRUFFLE_HOTSPOT',
94 ]
95
96 def add_compiler(compilerName):
97 _compilers.append(compilerName)
98
99 def add_graal_dist(distName):
100 _graalDists.append(distName)
101
102 mx_gate.add_jacoco_includes(['com.oracle.graal.*'])
103 mx_gate.add_jacoco_excluded_annotations(['@Snippet', '@ClassSubstitution'])
104
105 def _run_benchmark(args, availableBenchmarks, runBenchmark):
106
107 vmOpts, benchmarksAndOptions = mx.extract_VM_args(args, useDoubleDash=availableBenchmarks is None)
108
109 if availableBenchmarks is None:
110 harnessArgs = benchmarksAndOptions
111 return runBenchmark(None, harnessArgs, vmOpts)
112
113 if len(benchmarksAndOptions) == 0:
114 mx.abort('at least one benchmark name or "all" must be specified')
115 benchmarks = list(itertools.takewhile(lambda x: not x.startswith('-'), benchmarksAndOptions))
116 harnessArgs = benchmarksAndOptions[len(benchmarks):]
117
118 if 'all' in benchmarks:
119 benchmarks = availableBenchmarks
120 else:
121 for bm in benchmarks:
122 if bm not in availableBenchmarks:
123 mx.abort('unknown benchmark: ' + bm + '\nselect one of: ' + str(availableBenchmarks))
124
125 failed = []
126 for bm in benchmarks:
127 if not runBenchmark(bm, harnessArgs, vmOpts):
128 failed.append(bm)
129
130 if len(failed) != 0:
131 mx.abort('Benchmark failures: ' + str(failed))
132
133 def dacapo(args):
134 """run one or more DaCapo benchmarks"""
135
136 def launcher(bm, harnessArgs, extraVmOpts):
137 return sanitycheck.getDacapo(bm, harnessArgs).test(get_vm(), extraVmOpts=extraVmOpts)
138
139 _run_benchmark(args, sanitycheck.dacapoSanityWarmup.keys(), launcher)
140
141 def scaladacapo(args):
142 """run one or more Scala DaCapo benchmarks"""
143
144 def launcher(bm, harnessArgs, extraVmOpts):
145 return sanitycheck.getScalaDacapo(bm, harnessArgs).test(get_vm(), extraVmOpts=extraVmOpts)
146
147 _run_benchmark(args, sanitycheck.dacapoScalaSanityWarmup.keys(), launcher)
148
149 # This is different than the 'jmh' commmand in that it
150 # looks for internal JMH benchmarks (i.e. those that
151 # depend on the JMH library).
152 def microbench(args):
153 """run JMH microbenchmark projects"""
154 parser = ArgumentParser(prog='mx microbench', description=microbench.__doc__,
155 usage="%(prog)s [command options|VM options] [-- [JMH options]]")
156 parser.add_argument('--jar', help='Explicitly specify micro-benchmark location')
157 known_args, args = parser.parse_known_args(args)
158
159 vmArgs, jmhArgs = mx.extract_VM_args(args, useDoubleDash=True)
160
161 # look for -f in JMH arguments
162 containsF = False
163 forking = True
164 for i in range(len(jmhArgs)):
165 arg = jmhArgs[i]
166 if arg.startswith('-f'):
167 containsF = True
168 if arg == '-f' and (i+1) < len(jmhArgs):
169 arg += jmhArgs[i+1]
170 try:
171 if int(arg[2:]) == 0:
172 forking = False
173 except ValueError:
174 pass
175
176 if known_args.jar:
177 # use the specified jar
178 args = ['-jar', known_args.jar]
179 if not forking:
180 args += vmArgs
181 else:
182 # default to -f1 if not specified otherwise
183 if not containsF:
184 jmhArgs += ['-f1']
185
186 # find all projects with a direct JMH dependency
187 jmhProjects = []
188 for p in mx.projects_opt_limit_to_suites():
189 if 'JMH' in [x.name for x in p.deps]:
190 jmhProjects.append(p.name)
191 cp = mx.classpath(jmhProjects)
192
193 # execute JMH runner
194 args = ['-cp', cp]
195 if not forking:
196 args += vmArgs
197 args += ['org.openjdk.jmh.Main']
198
199 if forking:
200 jvm = get_vm()
201 def quoteSpace(s):
202 if " " in s:
203 return '"' + s + '"'
204 return s
205
206 forkedVmArgs = map(quoteSpace, _parseVmArgs(_jdk, vmArgs))
207 args += ['--jvmArgsPrepend', ' '.join(['-' + jvm] + forkedVmArgs)]
208 run_vm(args + jmhArgs)
209
210 def ctw(args, extraVMarguments=None):
211 """run CompileTheWorld"""
212
213 defaultCtwopts = '-Inline'
214
215 parser = ArgumentParser(prog='mx ctw')
216 parser.add_argument('--ctwopts', action='store', help='space separated JVMCI options used for CTW compilations (default: --ctwopts="' + defaultCtwopts + '")', default=defaultCtwopts, metavar='<options>')
217 parser.add_argument('--cp', '--jar', action='store', help='jar or class path denoting classes to compile', metavar='<path>')
218
219 args, vmargs = parser.parse_known_args(args)
220
221 if args.ctwopts:
222 # Replace spaces with '#' since -G: options cannot contain spaces
223 # when they are collated in the "jvmci.options" system property
224 vmargs.append('-G:CompileTheWorldConfig=' + re.sub(r'\s+', '#', args.ctwopts))
225
226 if args.cp:
227 cp = os.path.abspath(args.cp)
228 else:
229 cp = join(_jdk.home, 'lib', 'modules', 'bootmodules.jimage')
230 vmargs.append('-G:CompileTheWorldExcludeMethodFilter=sun.awt.X11.*.*')
231
232 # suppress menubar and dock when running on Mac; exclude x11 classes as they may cause vm crashes (on Solaris)
233 vmargs = ['-Djava.awt.headless=true'] + vmargs
234
235 if _vm.jvmciMode == 'disabled':
236 vmargs += ['-XX:+CompileTheWorld', '-Xbootclasspath/p:' + cp]
237 else:
238 if _vm.jvmciMode == 'jit':
239 vmargs += ['-XX:+BootstrapJVMCI']
240 vmargs += ['-G:CompileTheWorldClasspath=' + cp, 'com.oracle.graal.hotspot.CompileTheWorld']
241
242 run_vm(vmargs + _noneAsEmptyList(extraVMarguments))
243
244 class UnitTestRun:
245 def __init__(self, name, args):
246 self.name = name
247 self.args = args
248
249 def run(self, suites, tasks, extraVMarguments=None):
250 for suite in suites:
251 with Task(self.name + ': hosted-product ' + suite, tasks) as t:
252 if t: unittest(['--suite', suite, '--enable-timing', '--verbose', '--fail-fast'] + self.args + _noneAsEmptyList(extraVMarguments))
253
254 class BootstrapTest:
255 def __init__(self, name, vmbuild, args, suppress=None):
256 self.name = name
257 self.args = args
258 self.suppress = suppress
259
260 def run(self, tasks, extraVMarguments=None):
261 with JVMCIMode('jit'):
262 with Task(self.name, tasks) as t:
263 if t:
264 if self.suppress:
265 out = mx.DuplicateSuppressingStream(self.suppress).write
266 else:
267 out = None
268 run_vm(self.args + _noneAsEmptyList(extraVMarguments) + ['-XX:-TieredCompilation', '-XX:+BootstrapJVMCI', '-version'], out=out)
269
270 def compiler_gate_runner(suites, unit_test_runs, bootstrap_tests, tasks, extraVMarguments=None):
271
272 # Run unit tests in hosted mode
273 with JVMCIMode('hosted'):
274 for r in unit_test_runs:
275 r.run(suites, tasks, extraVMarguments)
276
277 # Run ctw against rt.jar on server-hosted-jvmci
278 with JVMCIMode('hosted'):
279 with Task('CTW:hosted', tasks) as t:
280 if t: ctw(['--ctwopts', '-Inline +ExitVMOnException', '-esa', '-G:+CompileTheWorldMultiThreaded', '-G:-InlineDuringParsing', '-G:-CompileTheWorldVerbose', '-XX:ReservedCodeCacheSize=300m'], _noneAsEmptyList(extraVMarguments))
281
282 # bootstrap tests
283 for b in bootstrap_tests:
284 b.run(tasks, extraVMarguments)
285
286 # run dacapo sanitychecks
287 for test in sanitycheck.getDacapos(level=sanitycheck.SanityCheckLevel.Gate, gateBuildLevel='release', extraVmArguments=extraVMarguments) \
288 + sanitycheck.getScalaDacapos(level=sanitycheck.SanityCheckLevel.Gate, gateBuildLevel='release', extraVmArguments=extraVMarguments):
289 with Task(str(test) + ':' + 'release', tasks) as t:
290 if t and not test.test('jvmci'):
291 t.abort(test.name + ' Failed')
292
293 # ensure -Xbatch still works
294 with JVMCIMode('jit'):
295 with Task('DaCapo_pmd:BatchMode', tasks) as t:
296 if t: dacapo(_noneAsEmptyList(extraVMarguments) + ['-Xbatch', 'pmd'])
297
298 # ensure -Xcomp still works
299 with JVMCIMode('jit'):
300 with Task('XCompMode:product', tasks) as t:
301 if t: run_vm(_noneAsEmptyList(extraVMarguments) + ['-Xcomp', '-version'])
302
303
304 graal_unit_test_runs = [
305 UnitTestRun('UnitTests', []),
306 ]
307
308 _registers = 'o0,o1,o2,o3,f8,f9,d32,d34' if mx.get_arch() == 'sparcv9' else 'rbx,r11,r10,r14,xmm3,xmm11,xmm14'
309
310 graal_bootstrap_tests = [
311 BootstrapTest('BootstrapWithSystemAssertions', 'fastdebug', ['-esa']),
312 BootstrapTest('BootstrapWithSystemAssertionsNoCoop', 'fastdebug', ['-esa', '-XX:-UseCompressedOops', '-G:+ExitVMOnException']),
313 BootstrapTest('BootstrapWithGCVecification', 'product', ['-XX:+UnlockDiagnosticVMOptions', '-XX:+VerifyBeforeGC', '-XX:+VerifyAfterGC', '-G:+ExitVMOnException'], suppress=['VerifyAfterGC:', 'VerifyBeforeGC:']),
314 BootstrapTest('BootstrapWithG1GCVecification', 'product', ['-XX:+UnlockDiagnosticVMOptions', '-XX:-UseSerialGC', '-XX:+UseG1GC', '-XX:+VerifyBeforeGC', '-XX:+VerifyAfterGC', '-G:+ExitVMOnException'], suppress=['VerifyAfterGC:', 'VerifyBeforeGC:']),
315 BootstrapTest('BootstrapEconomyWithSystemAssertions', 'fastdebug', ['-esa', '-Djvmci.compiler=graal-economy', '-G:+ExitVMOnException']),
316 BootstrapTest('BootstrapWithExceptionEdges', 'fastdebug', ['-esa', '-G:+StressInvokeWithExceptionNode', '-G:+ExitVMOnException']),
317 BootstrapTest('BootstrapWithRegisterPressure', 'product', ['-esa', '-G:RegisterPressure=' + _registers, '-G:+ExitVMOnException']),
318 BootstrapTest('BootstrapTraceRAWithRegisterPressure', 'product', ['-esa', '-G:+TraceRA', '-G:RegisterPressure=' + _registers, '-G:+ExitVMOnException']),
319 BootstrapTest('BootstrapWithImmutableCode', 'product', ['-esa', '-G:+ImmutableCode', '-G:+VerifyPhases', '-G:+ExitVMOnException']),
320 ]
321
322 def _graal_gate_runner(args, tasks):
323 compiler_gate_runner(['graal'], graal_unit_test_runs, graal_bootstrap_tests, tasks, args.extra_vm_argument)
324
325 mx_gate.add_gate_runner(_suite, _graal_gate_runner)
326 mx_gate.add_gate_argument('--extra-vm-argument', action='append', help='add extra vm argument to gate tasks if applicable (multiple occurrences allowed)')
327
328 def _unittest_vm_launcher(vmArgs, mainClass, mainClassArgs):
329 run_vm(vmArgs + [mainClass] + mainClassArgs)
330
331 mx_unittest.set_vm_launcher('JDK9 VM launcher', _unittest_vm_launcher)
332
333 def deoptalot(args):
334 """bootstrap a VM with DeoptimizeALot and VerifyOops on
335
336 If the first argument is a number, the process will be repeated
337 this number of times. All other arguments are passed to the VM."""
338 count = 1
339 if len(args) > 0 and args[0].isdigit():
340 count = int(args[0])
341 del args[0]
342
343 for _ in range(count):
344 if not run_vm(['-XX:-TieredCompilation', '-XX:+DeoptimizeALot', '-XX:+VerifyOops'] + args + ['-version']) == 0:
345 mx.abort("Failed")
346
347 def longtests(args):
348
349 deoptalot(['15', '-Xmx48m'])
350
351 dacapo(['100', 'eclipse', '-esa'])
352
353 """
354 Extra benchmarks to run from 'bench()'.
355 """
356 extraBenchmarks = []
357
358 def bench(args):
359 """run benchmarks and parse their output for results
360
361 Results are JSON formated : {group : {benchmark : score}}."""
362 resultFile = None
363 if '-resultfile' in args:
364 index = args.index('-resultfile')
365 if index + 1 < len(args):
366 resultFile = args[index + 1]
367 del args[index]
368 del args[index]
369 else:
370 mx.abort('-resultfile must be followed by a file name')
371 resultFileCSV = None
372 if '-resultfilecsv' in args:
373 index = args.index('-resultfilecsv')
374 if index + 1 < len(args):
375 resultFileCSV = args[index + 1]
376 del args[index]
377 del args[index]
378 else:
379 mx.abort('-resultfilecsv must be followed by a file name')
380 vm = get_vm()
381 if len(args) is 0:
382 args = ['all']
383
384 vmArgs = [arg for arg in args if arg.startswith('-')]
385
386 def benchmarks_in_group(group):
387 prefix = group + ':'
388 return [a[len(prefix):] for a in args if a.startswith(prefix)]
389
390 results = {}
391 benchmarks = []
392 # DaCapo
393 if 'dacapo' in args or 'all' in args:
394 benchmarks += sanitycheck.getDacapos(level=sanitycheck.SanityCheckLevel.Benchmark)
395 else:
396 dacapos = benchmarks_in_group('dacapo')
397 for dacapo in dacapos:
398 if dacapo not in sanitycheck.dacapoSanityWarmup.keys():
399 mx.abort('Unknown DaCapo : ' + dacapo)
400 iterations = sanitycheck.dacapoSanityWarmup[dacapo][sanitycheck.SanityCheckLevel.Benchmark]
401 if iterations > 0:
402 benchmarks += [sanitycheck.getDacapo(dacapo, ['-n', str(iterations)])]
403
404 if 'scaladacapo' in args or 'all' in args:
405 benchmarks += sanitycheck.getScalaDacapos(level=sanitycheck.SanityCheckLevel.Benchmark)
406 else:
407 scaladacapos = benchmarks_in_group('scaladacapo')
408 for scaladacapo in scaladacapos:
409 if scaladacapo not in sanitycheck.dacapoScalaSanityWarmup.keys():
410 mx.abort('Unknown Scala DaCapo : ' + scaladacapo)
411 iterations = sanitycheck.dacapoScalaSanityWarmup[scaladacapo][sanitycheck.SanityCheckLevel.Benchmark]
412 if iterations > 0:
413 benchmarks += [sanitycheck.getScalaDacapo(scaladacapo, ['-n', str(iterations)])]
414
415 # Bootstrap
416 if 'bootstrap' in args or 'all' in args:
417 benchmarks += sanitycheck.getBootstraps()
418 # SPECjvm2008
419 if 'specjvm2008' in args or 'all' in args:
420 benchmarks += [sanitycheck.getSPECjvm2008(['-ikv', '-wt', '120', '-it', '120'])]
421 else:
422 specjvms = benchmarks_in_group('specjvm2008')
423 for specjvm in specjvms:
424 benchmarks += [sanitycheck.getSPECjvm2008(['-ikv', '-wt', '120', '-it', '120', specjvm])]
425
426 if 'specjbb2005' in args or 'all' in args:
427 benchmarks += [sanitycheck.getSPECjbb2005()]
428
429 if 'specjbb2013' in args: # or 'all' in args //currently not in default set
430 benchmarks += [sanitycheck.getSPECjbb2013()]
431
432 if 'ctw-full' in args:
433 benchmarks.append(sanitycheck.getCTW(vm, sanitycheck.CTWMode.Full))
434 if 'ctw-noinline' in args:
435 benchmarks.append(sanitycheck.getCTW(vm, sanitycheck.CTWMode.NoInline))
436
437 for f in extraBenchmarks:
438 f(args, vm, benchmarks)
439
440 for test in benchmarks:
441 for (groupName, res) in test.bench(vm, extraVmOpts=vmArgs).items():
442 group = results.setdefault(groupName, {})
443 group.update(res)
444 mx.log(json.dumps(results))
445 if resultFile:
446 with open(resultFile, 'w') as f:
447 f.write(json.dumps(results))
448 if resultFileCSV:
449 with open(resultFileCSV, 'w') as f:
450 for key1, value1 in results.iteritems():
451 f.write('%s;\n' % (str(key1)))
452 for key2, value2 in sorted(value1.iteritems()):
453 f.write('%s; %s;\n' % (str(key2), str(value2)))
454
455 def specjvm2008(args):
456 """run one or more SPECjvm2008 benchmarks"""
457
458 def launcher(bm, harnessArgs, extraVmOpts):
459 return sanitycheck.getSPECjvm2008(harnessArgs + [bm]).bench(get_vm(), extraVmOpts=extraVmOpts)
460
461 availableBenchmarks = set(sanitycheck.specjvm2008Names)
462 if "all" not in args:
463 # only add benchmark groups if we are not running "all"
464 for name in sanitycheck.specjvm2008Names:
465 parts = name.rsplit('.', 1)
466 if len(parts) > 1:
467 assert len(parts) == 2
468 group = parts[0]
469 availableBenchmarks.add(group)
470
471 _run_benchmark(args, sorted(availableBenchmarks), launcher)
472
473 def specjbb2013(args):
474 """run the composite SPECjbb2013 benchmark"""
475
476 def launcher(bm, harnessArgs, extraVmOpts):
477 assert bm is None
478 return sanitycheck.getSPECjbb2013(harnessArgs).bench(get_vm(), extraVmOpts=extraVmOpts)
479
480 _run_benchmark(args, None, launcher)
481
482 def specjbb2005(args):
483 """run the composite SPECjbb2005 benchmark"""
484
485 def launcher(bm, harnessArgs, extraVmOpts):
486 assert bm is None
487 return sanitycheck.getSPECjbb2005(harnessArgs).bench(get_vm(), extraVmOpts=extraVmOpts)
488
489 _run_benchmark(args, None, launcher)
490
491 def _parseVmArgs(jdk, args, addDefaultArgs=True):
492 args = mx.expand_project_in_args(args, insitu=False)
493 jacocoArgs = mx_gate.get_jacoco_agent_args()
494 if jacocoArgs:
495 args = jacocoArgs + args
496
497 # Support for -G: options
498 def translateGOption(arg):
499 if arg.startswith('-G:+'):
500 if '=' in arg:
501 mx.abort('Mixing + and = in -G: option specification: ' + arg)
502 arg = '-Djvmci.option.' + arg[len('-G:+'):] + '=true'
503 elif arg.startswith('-G:-'):
504 if '=' in arg:
505 mx.abort('Mixing - and = in -G: option specification: ' + arg)
506 arg = '-Djvmci.option.' + arg[len('-G:+'):] + '=false'
507 elif arg.startswith('-G:'):
508 arg = '-Djvmci.option.' + arg[len('-G:'):]
509 return arg
510 args = map(translateGOption, args)
511
512 bcp = [mx.distribution('truffle:TRUFFLE_API').classpath_repr()]
513 if _jvmciModes[_vm.jvmciMode]:
514 bcpDeps = [mx.distribution(d) for d in _graalDists]
515 if bcpDeps:
516 bcp.extend([d.classpath_repr() for d in bcpDeps])
517 args = ['-Xbootclasspath/p:' + os.pathsep.join(bcp)] + args
518
519 # Set the default JVMCI compiler
520 jvmciCompiler = _compilers[-1]
521 args = ['-Djvmci.compiler=' + jvmciCompiler] + args
522
523 if '-version' in args:
524 ignoredArgs = args[args.index('-version') + 1:]
525 if len(ignoredArgs) > 0:
526 mx.log("Warning: The following options will be ignored by the vm because they come after the '-version' argument: " + ' '.join(ignoredArgs))
527 return jdk.processArgs(args, addDefaultArgs=addDefaultArgs)
528
529 def run_java(jdk, args, nonZeroIsFatal=True, out=None, err=None, cwd=None, timeout=None, env=None, addDefaultArgs=True):
530
531 args = _parseVmArgs(jdk, args, addDefaultArgs=addDefaultArgs)
532
533 jvmciModeArgs = _jvmciModes[_vm.jvmciMode]
534 cmd = [jdk.java] + ['-' + get_vm()] + jvmciModeArgs + args
535 return mx.run(cmd, nonZeroIsFatal=nonZeroIsFatal, out=out, err=err, cwd=cwd)
536
537 def run_vm(args, vm=None, nonZeroIsFatal=True, out=None, err=None, cwd=None, timeout=None, debugLevel=None, vmbuild=None):
538 """run a Java program by executing the java executable in a JVMCI JDK"""
539
540 return run_java(mx.get_jdk(), args, nonZeroIsFatal=nonZeroIsFatal, out=out, err=err, cwd=cwd, timeout=timeout)
541
542 class GraalArchiveParticipant:
543 def __init__(self, dist):
544 self.dist = dist
545
546 def __opened__(self, arc, srcArc, services):
547 self.services = services
548 self.arc = arc
549
550 def __add__(self, arcname, contents):
551 if arcname.startswith('META-INF/jvmci.providers/'):
552 provider = arcname[len('META-INF/jvmci.providers/'):]
553 for service in contents.strip().split(os.linesep):
554 assert service
555 self.services.setdefault(service, []).append(provider)
556 return True
557 elif arcname.endswith('_OptionDescriptors.class'):
558 # Need to create service files for the providers of the
559 # jdk.vm.ci.options.Options service created by
560 # jdk.vm.ci.options.processor.OptionProcessor.
561 provider = arcname[:-len('.class'):].replace('/', '.')
562 self.services.setdefault('jdk.vm.ci.options.OptionDescriptors', []).append(provider)
563 return False
564
565 def __addsrc__(self, arcname, contents):
566 return False
567
568 def __closing__(self):
569 pass
570
571 mx.update_commands(_suite, {
572 'vm': [run_vm, '[-options] class [args...]'],
573 'ctw': [ctw, '[-vmoptions|noinline|nocomplex|full]'],
574 'dacapo': [dacapo, '[VM options] benchmarks...|"all" [DaCapo options]'],
575 'scaladacapo': [scaladacapo, '[VM options] benchmarks...|"all" [Scala DaCapo options]'],
576 'specjvm2008': [specjvm2008, '[VM options] benchmarks...|"all" [SPECjvm2008 options]'],
577 'specjbb2013': [specjbb2013, '[VM options] [-- [SPECjbb2013 options]]'],
578 'specjbb2005': [specjbb2005, '[VM options] [-- [SPECjbb2005 options]]'],
579 'bench' : [bench, '[-resultfile file] [all(default)|dacapo|specjvm2008|bootstrap]'],
580 'microbench' : [microbench, '[VM options] [-- [JMH options]]'],
581 'deoptalot' : [deoptalot, '[n]'],
582 'longtests' : [longtests, ''],
583 })
584
585 mx.add_argument('-M', '--jvmci-mode', action='store', choices=sorted(_jvmciModes.viewkeys()), help='the JVM variant type to build/run (default: ' + _vm.jvmciMode + ')')
586
587 def mx_post_parse_cmd_line(opts):
588 if opts.jvmci_mode is not None:
589 _vm.update(opts.jvmci_mode)
590 for dist in [mx.distribution(d) for d in _graalDists]:
591 dist.set_archiveparticipant(GraalArchiveParticipant(dist))