# HG changeset patch # User Thomas Wuerthinger # Date 1322147673 -3600 # Node ID 7c26db3259c60c3e4bf75e0b42a429301314b79b # Parent 221133c5ed6c30dccb54af70d2904d3e2763bdc2# Parent 60d31b1fada5bf4ba6a938e918ea1796c1f12c4d Merge. diff -r 221133c5ed6c -r 7c26db3259c6 pytools/commands.py --- a/pytools/commands.py Thu Nov 24 16:14:21 2011 +0100 +++ b/pytools/commands.py Thu Nov 24 16:14:33 2011 +0100 @@ -38,36 +38,72 @@ def bootstrap(env, args): return env.run_vm(args + ['-version']) -def avrora(env, args): - return env.run_dacapo(args + ['Harness', '--preserve', '-n', '20', 'avrora']) - -def batik(env, args): - return env.run_dacapo(args + ['Harness', '--preserve', '-n', '20', 'batik']) +def example(env, args): + """run some or all Graal examples""" + examples = { + 'safeadd': ['com.oracle.max.graal.examples.safeadd', 'com.oracle.max.graal.examples.safeadd.Main'], + 'vectorlib': ['com.oracle.max.graal.examples.vectorlib', 'com.oracle.max.graal.examples.vectorlib.Main'], + } -def eclipse(env, args): - return env.run_dacapo(args + ['Harness', '--preserve', '-n', '20', 'eclipse']) + def run_example(env, verbose, project, mainClass): + cp = env.mx().pdb().classpath(project) + sharedArgs = ['-Xcomp', '-XX:CompileOnly=Main', mainClass] + + res = [] + env.log("=== Server VM ===") + printArg = '-XX:+PrintCompilation' if verbose else '-XX:-PrintCompilation' + res.append(env.run_vm(['-cp', cp, printArg] + sharedArgs, vm="-server")) + env.log("=== Graal VM ===") + printArg = '-G:+PrintCompilation' if verbose else '-G:-PrintCompilation' + res.append(env.run_vm(['-cp', cp, printArg, '-G:-Extend', '-G:-Inline'] + sharedArgs)) + env.log("=== Graal VM with extensions ===") + res.append(env.run_vm(['-cp', cp, printArg, '-G:+Extend', '-G:-Inline'] + sharedArgs)) + + if len([x for x in res if x != 0]) != 0: + return 1 + return 0 -def fop(env, args): - return env.run_dacapo(args + ['Harness', '--preserve', '-n', '100', 'fop']) - -def h2(env, args): - return env.run_dacapo(args + ['Harness', '--preserve', '-n', '10', 'h2']) + verbose = False + if '-v' in args: + verbose = True + args = [a for a in args if a != '-v'] -def jython(env, args): - return env.run_dacapo(args + ['Harness', '--preserve', '-n', '10', 'jython']) - -def lusearch(env, args): - return env.run_dacapo(args + ['Harness', '--preserve', '-n', '5', 'lusearch']) + if len(args) == 0: + args = examples.keys() + for a in args: + config = examples.get(a) + if config is None: + env.log('unknown example: ' + a + ' {available examples = ' + str(examples.keys()) + '}') + else: + env.log('--------- ' + a + ' ------------') + project, mainClass = config + run_example(env, verbose, project, mainClass) -def pmd(env, args): - return env.run_dacapo(args + ['Harness', '--preserve', '-n', '10', 'pmd']) - -def tradebeans(env, args): - return env.run_dacapo(args + ['Harness', '--preserve', '-n', '20', 'tradebeans']) - -def xalan(env, args): - return env.run_dacapo(args + ['Harness', '--preserve', '-n', '20', 'xalan']) - +def dacapo(env, args): + """run a DaCapo benchmark""" + + benchmarks = { + 'avrora': ['--preserve', '-n', '20'], + 'batik': ['-n', '20'], + 'eclipse': ['-n', '20'], + 'fop': ['-n', '100'], + 'h2': ['-n', '10'], + 'jython': ['-n', '10'], + 'lusearch': ['-n', '5'], + 'pmd': ['-n', '10'], + 'tradebeans': ['-n', '20'], + 'xalan': ['-n', '20'], + } + + if len(args) == 0: + env.abort('which benchmark?\nselect one of: ' + str(benchmarks.keys())) + bm = args[0] + config = benchmarks.get(bm) + if (config is None): + env.abort('unknown benchmark: ' + bm + '\nselect one of: ' + str(benchmarks.keys())) + args = args[1:] + return env.run_dacapo(args + ['Harness'] + config + [bm]) + def tests(env, args): """run a selection of the Maxine JTT tests in Graal""" @@ -165,19 +201,12 @@ # used in the call to str.format(). # Extensions should update this table directly table = { - 'avrora': [avrora, ''], - 'batik': [batik, ''], + 'dacapo': [dacapo, 'benchmark [VM options]'], + 'example': [example, '[-v] example names...'], 'bootstrap': [bootstrap, ''], 'clean': [clean, ''], - 'fop': [fop, ''], - 'h2': [h2, ''], - 'jython': [jython, ''], - 'lusearch': [lusearch, ''], - 'pmd': [pmd, ''], - 'tradebeans': [tradebeans, ''], - 'tests': [tests, ''], 'help': [help_, '[command]'], 'make': [make, ''], - 'xalan': [xalan, ''], + 'tests': [tests, ''], 'vm': [vm, ''], } diff -r 221133c5ed6c -r 7c26db3259c6 pytools/gl.py --- a/pytools/gl.py Thu Nov 24 16:14:21 2011 +0100 +++ b/pytools/gl.py Thu Nov 24 16:14:33 2011 +0100 @@ -56,6 +56,7 @@ self.dacapo = os.getenv('DACAPO') self.jdk7 = os.getenv('JDK7') self.maxine = os.getenv('MAXINE') + self._mx = None ArgumentParser.__init__(self, prog='gl') @@ -109,11 +110,13 @@ return name def run_dacapo(self, args): + if self.dacapo is None: + self.abort('Need to specify DaCapo jar with --dacapo option or DACAPO environment variable') if not isfile(self.dacapo) or not self.dacapo.endswith('.jar'): self.abort('Specified DaCapo jar file does not exist or is not a jar file: ' + self.dacapo) return self.run_vm(['-Xms1g', '-Xmx2g', '-esa', '-XX:-GraalBailoutIsFatal', '-G:-QuietBailout', '-cp', self.dacapo] + args) - def run_vm(self, args): + def run_vm(self, args, vm='-graal'): if self.maxine is None: configFile = join(dirname(sys.argv[0]), 'glrc') self.abort('Path to Maxine code base must be specified with -M option or MAXINE environment variable (in ' + configFile + ')') @@ -122,7 +125,7 @@ os.environ['MAXINE'] = self.maxine exe = join(self.jdk7, 'bin', self.exe('java')) - return self.run([exe, '-graal'] + args) + return self.run([exe, vm] + args) def run(self, args, nonZeroIsFatal=True, out=None, err=None, cwd=None): """ @@ -195,6 +198,16 @@ """ raises a SystemExit exception with the provided exit code """ raise SystemExit(code) + def mx(self): + if (self._mx is None): + p = join(self.maxine, 'com.oracle.max.shell') + sys.path.insert(0, p) + import mx + self._mx = mx.Env() + self._mx.maxine_home = self.maxine + self._mx.parse_cmd_line([]) + return self._mx + def main(env): configFile = join(dirname(sys.argv[0]), 'glrc') env.load_config_file(configFile)