comparison pytools/commands.py @ 3693:60d31b1fada5

Improved interface to the examples in the gl script.
author Doug Simon <doug.simon@oracle.com>
date Thu, 24 Nov 2011 14:09:18 +0100
parents 4a76e44544d9
children d6a0c46a73b2
comparison
equal deleted inserted replaced
3692:4a76e44544d9 3693:60d31b1fada5
36 env.run([env.gmake_cmd(), 'clean'], cwd=join(env.graal_home, 'make')) 36 env.run([env.gmake_cmd(), 'clean'], cwd=join(env.graal_home, 'make'))
37 37
38 def bootstrap(env, args): 38 def bootstrap(env, args):
39 return env.run_vm(args + ['-version']) 39 return env.run_vm(args + ['-version'])
40 40
41 def _example(env, args, project, mainClass): 41 def example(env, args):
42 cp = env.mx().pdb().classpath(project) 42 """run some or all Graal examples"""
43 sharedArgs = ['-Xcomp', '-XX:CompileOnly=Main', mainClass] 43 examples = {
44 44 'safeadd': ['com.oracle.max.graal.examples.safeadd', 'com.oracle.max.graal.examples.safeadd.Main'],
45 res = [] 45 'vectorlib': ['com.oracle.max.graal.examples.vectorlib', 'com.oracle.max.graal.examples.vectorlib.Main'],
46 print "=== Server VM ===" 46 }
47 res.append(env.run_vm(['-cp', cp,] + sharedArgs, vm="-server")) 47
48 print "=== Graal VM ===" 48 def run_example(env, verbose, project, mainClass):
49 res.append(env.run_vm(['-cp', cp, '-G:+PrintCompilation', '-G:-Extend', '-G:-Inline'] + sharedArgs)) 49 cp = env.mx().pdb().classpath(project)
50 print "=== Graal VM with extensions ===" 50 sharedArgs = ['-Xcomp', '-XX:CompileOnly=Main', mainClass]
51 res.append(env.run_vm(['-cp', cp, '-G:+PrintCompilation', '-G:+Extend', '-G:-Inline'] + sharedArgs)) 51
52 52 res = []
53 if len([x for x in res if x != 0]) != 0: 53 env.log("=== Server VM ===")
54 return 1 54 printArg = '-XX:+PrintCompilation' if verbose else '-XX:-PrintCompilation'
55 return 0 55 res.append(env.run_vm(['-cp', cp, printArg] + sharedArgs, vm="-server"))
56 56 env.log("=== Graal VM ===")
57 def safeadd(env, args): 57 printArg = '-G:+PrintCompilation' if verbose else '-G:-PrintCompilation'
58 """run the SafeAdd example""" 58 res.append(env.run_vm(['-cp', cp, printArg, '-G:-Extend', '-G:-Inline'] + sharedArgs))
59 return _example(env, args, 'com.oracle.max.graal.examples.safeadd', 'com.oracle.max.graal.examples.safeadd.Main') 59 env.log("=== Graal VM with extensions ===")
60 60 res.append(env.run_vm(['-cp', cp, printArg, '-G:+Extend', '-G:-Inline'] + sharedArgs))
61 def vectorlib(env, args): 61
62 """run the VectorLib example""" 62 if len([x for x in res if x != 0]) != 0:
63 return _example(env, args, 'com.oracle.max.graal.examples.vectorlib', 'com.oracle.max.graal.examples.vectorlib.Main') 63 return 1
64 return 0
65
66 verbose = False
67 if '-v' in args:
68 verbose = True
69 args = [a for a in args if a != '-v']
70
71 if len(args) == 0:
72 args = examples.keys()
73 for a in args:
74 config = examples.get(a)
75 if config is None:
76 env.log('unknown example: ' + a + ' {available examples = ' + str(examples.keys()) + '}')
77 else:
78 env.log('--------- ' + a + ' ------------')
79 project, mainClass = config
80 run_example(env, verbose, project, mainClass)
64 81
65 def dacapo(env, args): 82 def dacapo(env, args):
66 """run a DaCapo benchmark""" 83 """run a DaCapo benchmark"""
67 84
68 benchmarks = { 85 benchmarks = {
183 # If any of the format args are instances of Callable, then they are called with an 'env' are before being 200 # If any of the format args are instances of Callable, then they are called with an 'env' are before being
184 # used in the call to str.format(). 201 # used in the call to str.format().
185 # Extensions should update this table directly 202 # Extensions should update this table directly
186 table = { 203 table = {
187 'dacapo': [dacapo, 'benchmark [VM options]'], 204 'dacapo': [dacapo, 'benchmark [VM options]'],
205 'example': [example, '[-v] example names...'],
188 'bootstrap': [bootstrap, ''], 206 'bootstrap': [bootstrap, ''],
189 'clean': [clean, ''], 207 'clean': [clean, ''],
190 'help': [help_, '[command]'], 208 'help': [help_, '[command]'],
191 'make': [make, ''], 209 'make': [make, ''],
192 'safeadd': [safeadd, ''],
193 'tests': [tests, ''], 210 'tests': [tests, ''],
194 'vectorlib': [vectorlib, ''],
195 'vm': [vm, ''], 211 'vm': [vm, ''],
196 } 212 }