Mercurial > hg > graal-compiler
comparison mx/commands.py @ 3722:7c5524a4e86e
Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 16 Dec 2011 16:33:42 +0100 |
parents | 71b1204a74b4 |
children | 4e3851bab8d0 |
comparison
equal
deleted
inserted
replaced
3721:71b1204a74b4 | 3722:7c5524a4e86e |
---|---|
76 env.log('--------- ' + a + ' ------------') | 76 env.log('--------- ' + a + ' ------------') |
77 project, mainClass = config | 77 project, mainClass = config |
78 run_example(env, verbose, project, mainClass) | 78 run_example(env, verbose, project, mainClass) |
79 | 79 |
80 def dacapo(env, args): | 80 def dacapo(env, args): |
81 """run a DaCapo benchmark""" | 81 """run one or all DaCapo benchmarks""" |
82 | 82 |
83 benchmarks = { | 83 benchmarks = { |
84 'avrora': ['-n', '5'], | 84 'avrora': ['-n', '5'], |
85 'batik': ['-n', '5'], | 85 'batik': ['-n', '5'], |
86 'eclipse': ['-n', '5'], | 86 'eclipse': ['-n', '5'], |
95 'tradebeans': ['-n', '5'], | 95 'tradebeans': ['-n', '5'], |
96 'tradesoap': ['-n', '5'], | 96 'tradesoap': ['-n', '5'], |
97 'xalan': ['-n', '5'], | 97 'xalan': ['-n', '5'], |
98 } | 98 } |
99 | 99 |
100 if len(args) == 0: | 100 dacapo = env.check_get_env('DACAPO_CP') |
101 args = args[0:] | 101 if not isfile(dacapo) or not dacapo.endswith('.jar'): |
102 for bm in benchmarks: | 102 env.abort('Specified DaCapo jar file does not exist or is not a jar file: ' + dacapo) |
103 run_dacapo(env, args + ['Harness', '-n', '2'] + [bm]) | 103 |
104 return | 104 vmOpts = ['-Xms1g', '-Xmx2g', '-esa', '-cp', dacapo] |
105 else: | 105 |
106 runs = dict() | |
107 while len(args) != 0 and not args[0].startswith('-'): | |
106 bm = args[0] | 108 bm = args[0] |
107 config = benchmarks.get(bm) | 109 del args[0] |
110 config = benchmarks.get(bm) | |
108 if (config is None): | 111 if (config is None): |
109 env.abort('unknown benchmark: ' + bm + '\nselect one of: ' + str(benchmarks.keys())) | 112 env.abort('unknown benchmark: ' + bm + '\nselect one of: ' + str(benchmarks.keys())) |
110 args = args[1:] | 113 runs[bm] = config |
111 return run_dacapo(env, args + ['Harness'] + config + [bm]) | 114 |
115 if len(runs) == 0: | |
116 runs = benchmarks | |
117 | |
118 vmOpts += args | |
119 for bm in runs: | |
120 config = benchmarks.get(bm) | |
121 vm(env, vmOpts + ['Harness'] + config + [bm]) | |
112 | 122 |
113 def tests(env, args): | 123 def tests(env, args): |
114 """run a selection of the Maxine JTT tests in Graal""" | 124 """run a selection of the Maxine JTT tests in Graal""" |
115 | 125 |
116 maxine = env.check_get_env('MAXINE_HOME') | 126 maxine = env.check_get_env('MAXINE_HOME') |
157 env.abort('Unknown build type: ' + build) | 167 env.abort('Unknown build type: ' + build) |
158 | 168 |
159 def make(env, args): | 169 def make(env, args): |
160 """builds the GraalVM binary | 170 """builds the GraalVM binary |
161 | 171 |
162 The optional argument specifies what type of VM to build. | 172 The optional argument specifies what type of VM to build.""" |
163 """ | |
164 | 173 |
165 def fix_jvm_cfg(env, jdk): | 174 def fix_jvm_cfg(env, jdk): |
166 jvmCfg = join(jdk, 'jre', 'lib', 'amd64', 'jvm.cfg') | 175 jvmCfg = join(jdk, 'jre', 'lib', 'amd64', 'jvm.cfg') |
167 found = False | 176 found = False |
168 if not exists(jvmCfg): | 177 if not exists(jvmCfg): |
196 | 205 |
197 os.environ.update(ARCH_DATA_MODEL='64', LANG='C', HOTSPOT_BUILD_JOBS='3', ALT_BOOTDIR=jdk7, INSTALL='y') | 206 os.environ.update(ARCH_DATA_MODEL='64', LANG='C', HOTSPOT_BUILD_JOBS='3', ALT_BOOTDIR=jdk7, INSTALL='y') |
198 env.run([env.gmake_cmd(), build + 'graal'], cwd=join(graal_home, 'make'), err=filterXusage) | 207 env.run([env.gmake_cmd(), build + 'graal'], cwd=join(graal_home, 'make'), err=filterXusage) |
199 | 208 |
200 def vm(env, args, vm='-graal'): | 209 def vm(env, args, vm='-graal'): |
201 """run the GraalVM | 210 """run the GraalVM""" |
202 | 211 |
203 The optional leading argument specifies an alternative to the | 212 build = env.vmbuild |
204 product build should be run: @g = debug, @f = fastdebug, @o = optimized""" | |
205 | |
206 build = 'product' | |
207 buildOpts = { | |
208 '@g': 'debug', | |
209 '@f': 'fastdebug', | |
210 '@o': 'optimized' | |
211 } | |
212 | |
213 if len(args) and args[0] in buildOpts.iterkeys(): | |
214 build = buildOpts[args[0]] | |
215 del args[0] | |
216 | |
217 if env.java_dbg: | 213 if env.java_dbg: |
218 args = ['-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000'] + args | 214 args = ['-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000'] + args |
219 os.environ['MAXINE'] = env.check_get_env('GRAAL_HOME') | 215 os.environ['MAXINE'] = env.check_get_env('GRAAL_HOME') |
220 exe = join(_jdk7(env, build), 'bin', env.exe_suffix('java')) | 216 exe = join(_jdk7(env, build), 'bin', env.exe_suffix('java')) |
221 return env.run([exe, vm] + args) | 217 return env.run([exe, vm] + args) |
222 | 218 |
223 def mx_init(env): | 219 def mx_init(env): |
220 env.vmbuild = 'product' | |
221 env.add_argument('--product', action='store_const', dest='vmbuild', const='product', help='select the product VM') | |
222 env.add_argument('--debug', action='store_const', dest='vmbuild', const='debug', help='select the debug VM') | |
223 env.add_argument('--fastdebug', action='store_const', dest='vmbuild', const='fastdebug', help='select the fast debug VM') | |
224 env.add_argument('--optimized', action='store_const', dest='vmbuild', const='optimized', help='select the optimized VM') | |
224 commands = { | 225 commands = { |
225 'dacapo': [dacapo, 'benchmark [VM options]'], | 226 'dacapo': [dacapo, '[benchmark] [VM options]'], |
226 'example': [example, '[-v] example names...'], | 227 'example': [example, '[-v] example names...'], |
227 'clean': [clean, ''], | 228 'clean': [clean, ''], |
228 'make': [make, '[product|debug|fastdebug|optimized]'], | 229 'make': [make, '[product|debug|fastdebug|optimized]'], |
229 'tests': [tests, ''], | 230 'tests': [tests, ''], |
230 'vm': [vm, '[@g|@f|@o] [-options] class [args...]'], | 231 'vm': [vm, '[-options] class [args...]'], |
231 } | 232 } |
232 env.commands.update(commands) | 233 env.commands.update(commands) |
233 | |
234 def run_dacapo(env, args): | |
235 dacapo = env.check_get_env('DACAPO_CP') | |
236 if not isfile(dacapo) or not dacapo.endswith('.jar'): | |
237 env.abort('Specified DaCapo jar file does not exist or is not a jar file: ' + dacapo) | |
238 return vm(env, ['-Xms1g', '-Xmx2g', '-esa', '-cp', dacapo] + args) |