Mercurial > hg > graal-compiler
comparison mx.graal/mx_graal_8.py @ 23209:f35e653aa876
moved @Option mechanism from JVMCI to Graal (GRAAL-1371)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 21 Dec 2015 16:19:35 +0100 |
parents | 274037591da2 |
children | 75a807751aa6 |
comparison
equal
deleted
inserted
replaced
23208:58eb143a8259 | 23209:f35e653aa876 |
---|---|
29 from argparse import ArgumentParser | 29 from argparse import ArgumentParser |
30 import sanitycheck | 30 import sanitycheck |
31 import re | 31 import re |
32 | 32 |
33 import mx | 33 import mx |
34 from mx_jvmci import JvmciJDKDeployedDist, jdkDeployedDists, add_bootclasspath_prepend, buildvms, get_jvmci_jdk, run_vm, VM, relativeVmLibDirInJdk, isJVMCIEnabled | 34 from mx_jvmci import JvmciJDKDeployedDist, JVMCIArchiveParticipant, jdkDeployedDists, add_bootclasspath_prepend, buildvms, get_jvmci_jdk, VM, relativeVmLibDirInJdk, isJVMCIEnabled |
35 from mx_jvmci import get_vm as _jvmci_get_vm | 35 from mx_jvmci import get_vm as _jvmci_get_vm |
36 from mx_jvmci import run_vm as _jvmci_run_vm | |
36 from mx_gate import Task | 37 from mx_gate import Task |
37 from sanitycheck import _noneAsEmptyList | 38 from sanitycheck import _noneAsEmptyList |
38 | 39 |
39 from mx_unittest import unittest | 40 from mx_unittest import unittest |
40 from mx_graal_bench import dacapo | 41 from mx_graal_bench import dacapo |
41 import mx_gate | 42 import mx_gate |
43 import mx_unittest | |
42 | 44 |
43 _suite = mx.suite('graal') | 45 _suite = mx.suite('graal') |
44 | 46 |
45 def get_vm(): | 47 def get_vm(): |
46 """ | 48 """ |
83 content.append(line.rstrip(os.linesep)) | 85 content.append(line.rstrip(os.linesep)) |
84 with open(graalProperties, 'w') as fp: | 86 with open(graalProperties, 'w') as fp: |
85 fp.write(os.linesep.join(content)) | 87 fp.write(os.linesep.join(content)) |
86 | 88 |
87 jdkDeployedDists += [ | 89 jdkDeployedDists += [ |
90 JvmciJDKDeployedDist('GRAAL_OPTIONS'), | |
88 JvmciJDKDeployedDist('GRAAL_NODEINFO'), | 91 JvmciJDKDeployedDist('GRAAL_NODEINFO'), |
89 JvmciJDKDeployedDist('GRAAL_API'), | 92 JvmciJDKDeployedDist('GRAAL_API'), |
90 JvmciJDKDeployedDist('GRAAL_COMPILER'), | 93 JvmciJDKDeployedDist('GRAAL_COMPILER'), |
91 JvmciJDKDeployedDist('GRAAL'), | 94 JvmciJDKDeployedDist('GRAAL'), |
92 GraalJDKDeployedDist(), | 95 GraalJDKDeployedDist(), |
167 | 170 |
168 args, vmargs = parser.parse_known_args(args) | 171 args, vmargs = parser.parse_known_args(args) |
169 | 172 |
170 if args.ctwopts: | 173 if args.ctwopts: |
171 # Replace spaces with '#' since -G: options cannot contain spaces | 174 # Replace spaces with '#' since -G: options cannot contain spaces |
172 # when they are collated in the "jvmci.options" system property | |
173 vmargs.append('-G:CompileTheWorldConfig=' + re.sub(r'\s+', '#', args.ctwopts)) | 175 vmargs.append('-G:CompileTheWorldConfig=' + re.sub(r'\s+', '#', args.ctwopts)) |
174 | 176 |
175 if args.cp: | 177 if args.cp: |
176 cp = os.path.abspath(args.cp) | 178 cp = os.path.abspath(args.cp) |
177 else: | 179 else: |
374 if exists(jvmLib): | 376 if exists(jvmLib): |
375 print '{:10,} {}'.format(os.path.getsize(jvmLib), jvmLib) | 377 print '{:10,} {}'.format(os.path.getsize(jvmLib), jvmLib) |
376 else: | 378 else: |
377 print '{:>10} {}'.format('<missing>', jvmLib) | 379 print '{:>10} {}'.format('<missing>', jvmLib) |
378 | 380 |
381 # Support for -G: options | |
382 def _translateGOption(arg): | |
383 if arg.startswith('-G:+'): | |
384 if '=' in arg: | |
385 mx.abort('Mixing + and = in -G: option specification: ' + arg) | |
386 arg = '-Dgraal.option.' + arg[len('-G:+'):] + '=true' | |
387 elif arg.startswith('-G:-'): | |
388 if '=' in arg: | |
389 mx.abort('Mixing - and = in -G: option specification: ' + arg) | |
390 arg = '-Dgraal.option.' + arg[len('-G:+'):] + '=false' | |
391 elif arg.startswith('-G:'): | |
392 arg = '-Dgraal.option.' + arg[len('-G:'):] | |
393 return arg | |
394 | |
395 def run_vm(*positionalargs, **kwargs): | |
396 """run a Java program by executing the java executable in a Graal JDK""" | |
397 | |
398 # convert positional args to a list so the first element can be updated | |
399 positionalargs = list(positionalargs) | |
400 args = positionalargs[0] | |
401 if '-G:+PrintFlags' in args and '-Xcomp' not in args: | |
402 mx.warn('Using -G:+PrintFlags may have no effect without -Xcomp as Graal initialization is lazy') | |
403 positionalargs[0] = map(_translateGOption, args) | |
404 return _jvmci_run_vm(*positionalargs, **kwargs) | |
405 | |
406 def _unittest_config_participant(config): | |
407 vmArgs, mainClass, mainClassArgs = config | |
408 if isJVMCIEnabled(get_vm()): | |
409 return (map(_translateGOption, vmArgs), mainClass, mainClassArgs) | |
410 return config | |
411 | |
412 mx_unittest.add_config_participant(_unittest_config_participant) | |
413 | |
379 mx.update_commands(_suite, { | 414 mx.update_commands(_suite, { |
415 'vm': [run_vm, '[-options] class [args...]'], | |
380 'jdkartifactstats' : [jdkartifactstats, ''], | 416 'jdkartifactstats' : [jdkartifactstats, ''], |
381 'ctw': [ctw, '[-vmoptions|noinline|nocomplex|full]'], | 417 'ctw': [ctw, '[-vmoptions|noinline|nocomplex|full]'], |
382 'microbench' : [microbench, '[VM options] [-- [JMH options]]'], | 418 'microbench' : [microbench, '[VM options] [-- [JMH options]]'], |
383 }) | 419 }) |
384 | 420 |
421 class GraalArchiveParticipant(JVMCIArchiveParticipant): | |
422 def __init__(self, dist): | |
423 JVMCIArchiveParticipant.__init__(self, dist) | |
424 | |
425 def __add__(self, arcname, contents): | |
426 if arcname.endswith('_OptionDescriptors.class'): | |
427 # Need to create service files for the providers of the | |
428 # com.oracle.graal.options.Options service created by | |
429 # com.oracle.graal.options.processor.OptionProcessor. | |
430 provider = arcname[:-len('.class'):].replace('/', '.') | |
431 self.services.setdefault('com.oracle.graal.options.OptionDescriptors', []).append(provider) | |
432 return JVMCIArchiveParticipant.__add__(self, arcname, contents) | |
385 | 433 |
386 def mx_post_parse_cmd_line(opts): | 434 def mx_post_parse_cmd_line(opts): |
387 add_bootclasspath_prepend(mx.distribution('truffle:TRUFFLE_API')) | 435 add_bootclasspath_prepend(mx.distribution('truffle:TRUFFLE_API')) |
436 | |
437 for jdkDist in jdkDeployedDists: | |
438 dist = jdkDist.dist() | |
439 # Replace archive participant for Graal suites | |
440 if isinstance(jdkDist, JvmciJDKDeployedDist) and dist.suite.name != 'jvmci': | |
441 dist.set_archiveparticipant(GraalArchiveParticipant(dist)) |