comparison mx/commands.py @ 11514:dc3c8df55905

added support for pylint and fixed errors/warnings it found
author Doug Simon <doug.simon@oracle.com>
date Tue, 03 Sep 2013 16:33:41 +0200
parents 38acec26d535
children d4537043ccc8
comparison
equal deleted inserted replaced
11513:8d4e5e08d83f 11514:dc3c8df55905
43 """ The VMs that can be built and run along with an optional description. Only VMs with a 43 """ The VMs that can be built and run along with an optional description. Only VMs with a
44 description are listed in the dialogue for setting the default VM (see _get_vm()). """ 44 description are listed in the dialogue for setting the default VM (see _get_vm()). """
45 _vmChoices = { 45 _vmChoices = {
46 'graal' : 'All compilation is performed with Graal. This includes bootstrapping Graal itself unless -XX:-BootstrapGraal is used.', 46 'graal' : 'All compilation is performed with Graal. This includes bootstrapping Graal itself unless -XX:-BootstrapGraal is used.',
47 'server' : 'Normal compilation is performed with the tiered system (i.e., client + server), Truffle compilation is performed with Graal. Use this for optimal Truffle performance.', 47 'server' : 'Normal compilation is performed with the tiered system (i.e., client + server), Truffle compilation is performed with Graal. Use this for optimal Truffle performance.',
48 'client' : None, # normal compilation with client compiler, explicit compilation (e.g., by Truffle) with Graal 48 'client' : None, # normal compilation with client compiler, explicit compilation (e.g., by Truffle) with Graal
49 'server-nograal' : None, # all compilation with tiered system (i.e., client + server), Graal omitted 49 'server-nograal' : None, # all compilation with tiered system (i.e., client + server), Graal omitted
50 'client-nograal' : None, # all compilation with client compiler, Graal omitted 50 'client-nograal' : None, # all compilation with client compiler, Graal omitted
51 'original' : None, # default VM copied from bootstrap JDK 51 'original' : None, # default VM copied from bootstrap JDK
52 } 52 }
53 53
54 """ The VM that will be run by the 'vm' command and built by default by the 'build' command. 54 """ The VM that will be run by the 'vm' command and built by default by the 'build' command.
55 This can be set via the global '--vm' option or the DEFAULT_VM environment variable. 55 This can be set via the global '--vm' option or the DEFAULT_VM environment variable.
56 It can also be temporarily set by using of a VM context manager object in a 'with' statement. """ 56 It can also be temporarily set by using of a VM context manager object in a 'with' statement. """
99 with open(envPath, 'a') as fp: 99 with open(envPath, 'a') as fp:
100 print >> fp, 'DEFAULT_VM=' + vm 100 print >> fp, 'DEFAULT_VM=' + vm
101 _vm = vm 101 _vm = vm
102 return vm 102 return vm
103 103
104 """ 104 """
105 A context manager that can be used with the 'with' statement to set the VM 105 A context manager that can be used with the 'with' statement to set the VM
106 used by all VM executions within the scope of the 'with' statement. For example: 106 used by all VM executions within the scope of the 'with' statement. For example:
107 107
108 with VM('server'): 108 with VM('server'):
109 dacapo(['pmd']) 109 dacapo(['pmd'])
114 assert build is None or build in _vmbuildChoices 114 assert build is None or build in _vmbuildChoices
115 self.vm = vm if vm else _vm 115 self.vm = vm if vm else _vm
116 self.build = build if build else _vmbuild 116 self.build = build if build else _vmbuild
117 self.previousVm = _vm 117 self.previousVm = _vm
118 self.previousBuild = _vmbuild 118 self.previousBuild = _vmbuild
119 119
120 def __enter__(self): 120 def __enter__(self):
121 global _vm, _vmbuild 121 global _vm, _vmbuild
122 _vm = self.vm 122 _vm = self.vm
123 _vmbuild = self.build 123 _vmbuild = self.build
124 124
125 def __exit__(self, exc_type, exc_value, traceback): 125 def __exit__(self, exc_type, exc_value, traceback):
126 global _vm, _vmbuild 126 global _vm, _vmbuild
127 _vm = self.previousVm 127 _vm = self.previousVm
128 _vmbuild = self.previousBuild 128 _vmbuild = self.previousBuild
129 129
130 def _chmodDir(chmodFlags, dirname, fnames): 130 def _chmodDir(chmodFlags, dirname, fnames):
131 os.chmod(dirname, chmodFlags) 131 os.chmod(dirname, chmodFlags)
132 for name in fnames: 132 for name in fnames:
133 os.chmod(os.path.join(dirname, name), chmodFlags) 133 os.chmod(os.path.join(dirname, name), chmodFlags)
134 134
142 def rmIfExists(name): 142 def rmIfExists(name):
143 if os.path.isdir(name): 143 if os.path.isdir(name):
144 shutil.rmtree(name) 144 shutil.rmtree(name)
145 elif os.path.isfile(name): 145 elif os.path.isfile(name):
146 os.unlink(name) 146 os.unlink(name)
147 147
148 rmIfExists(join(_graal_home, 'build')) 148 rmIfExists(join(_graal_home, 'build'))
149 rmIfExists(join(_graal_home, 'build-nograal')) 149 rmIfExists(join(_graal_home, 'build-nograal'))
150 rmIfExists(_jdksDir()) 150 rmIfExists(_jdksDir())
151 rmIfExists(mx.distribution('GRAAL').path) 151 rmIfExists(mx.distribution('GRAAL').path)
152 152
153 def export(args): 153 def export(args):
154 """create a GraalVM zip file for distribution""" 154 """create a GraalVM zip file for distribution"""
155 155
156 parser = ArgumentParser(prog='mx export'); 156 parser = ArgumentParser(prog='mx export')
157 parser.add_argument('--omit-vm-build', action='store_false', dest='vmbuild', help='omit VM build step') 157 parser.add_argument('--omit-vm-build', action='store_false', dest='vmbuild', help='omit VM build step')
158 parser.add_argument('--omit-dist-init', action='store_false', dest='distInit', help='omit class files and IDE configurations from distribution') 158 parser.add_argument('--omit-dist-init', action='store_false', dest='distInit', help='omit class files and IDE configurations from distribution')
159 parser.add_argument('zipfile', nargs=REMAINDER, metavar='zipfile') 159 parser.add_argument('zipfile', nargs=REMAINDER, metavar='zipfile')
160 160
161 args = parser.parse_args(args) 161 args = parser.parse_args(args)
198 def _run_benchmark(args, availableBenchmarks, runBenchmark): 198 def _run_benchmark(args, availableBenchmarks, runBenchmark):
199 199
200 vmOpts, benchmarksAndOptions = _extract_VM_args(args, useDoubleDash=availableBenchmarks is None) 200 vmOpts, benchmarksAndOptions = _extract_VM_args(args, useDoubleDash=availableBenchmarks is None)
201 201
202 if availableBenchmarks is None: 202 if availableBenchmarks is None:
203 harnessArgs = benchmarksAndOptions 203 harnessArgs = benchmarksAndOptions
204 return runBenchmark(None, harnessArgs, vmOpts) 204 return runBenchmark(None, harnessArgs, vmOpts)
205 205
206 if len(benchmarksAndOptions) == 0: 206 if len(benchmarksAndOptions) == 0:
207 mx.abort('at least one benchmark name or "all" must be specified') 207 mx.abort('at least one benchmark name or "all" must be specified')
208 benchmarks = list(itertools.takewhile(lambda x: not x.startswith('-'), benchmarksAndOptions)) 208 benchmarks = list(itertools.takewhile(lambda x: not x.startswith('-'), benchmarksAndOptions))
209 harnessArgs = benchmarksAndOptions[len(benchmarks):] 209 harnessArgs = benchmarksAndOptions[len(benchmarks):]
210 210
211 if 'all' in benchmarks: 211 if 'all' in benchmarks:
212 benchmarks = availableBenchmarks 212 benchmarks = availableBenchmarks
213 else: 213 else:
214 for bm in benchmarks: 214 for bm in benchmarks:
226 def dacapo(args): 226 def dacapo(args):
227 """run one or more DaCapo benchmarks""" 227 """run one or more DaCapo benchmarks"""
228 228
229 def launcher(bm, harnessArgs, extraVmOpts): 229 def launcher(bm, harnessArgs, extraVmOpts):
230 return sanitycheck.getDacapo(bm, harnessArgs).test(_get_vm(), extraVmOpts=extraVmOpts) 230 return sanitycheck.getDacapo(bm, harnessArgs).test(_get_vm(), extraVmOpts=extraVmOpts)
231 231
232 _run_benchmark(args, sanitycheck.dacapoSanityWarmup.keys(), launcher) 232 _run_benchmark(args, sanitycheck.dacapoSanityWarmup.keys(), launcher)
233 233
234 def scaladacapo(args): 234 def scaladacapo(args):
235 """run one or more Scala DaCapo benchmarks""" 235 """run one or more Scala DaCapo benchmarks"""
236 236
330 330
331 assert defaultVM is not None, 'Could not find default VM in ' + jvmCfg 331 assert defaultVM is not None, 'Could not find default VM in ' + jvmCfg
332 if mx.get_os() != 'windows': 332 if mx.get_os() != 'windows':
333 chmodRecursive(jdk, 0755) 333 chmodRecursive(jdk, 0755)
334 shutil.move(join(_vmLibDirInJdk(jdk), defaultVM), join(_vmLibDirInJdk(jdk), 'original')) 334 shutil.move(join(_vmLibDirInJdk(jdk), defaultVM), join(_vmLibDirInJdk(jdk), 'original'))
335 335
336 336
337 with open(jvmCfg, 'w') as fp: 337 with open(jvmCfg, 'w') as fp:
338 for line in jvmCfgLines: 338 for line in jvmCfgLines:
339 fp.write(line) 339 fp.write(line)
340 340
346 else: 346 else:
347 if not exists(jdk): 347 if not exists(jdk):
348 if _installed_jdks and mx._opts.verbose: 348 if _installed_jdks and mx._opts.verbose:
349 mx.log("Could not find JDK directory at " + jdk) 349 mx.log("Could not find JDK directory at " + jdk)
350 _handle_missing_VM(build, vmToCheck if vmToCheck else 'graal') 350 _handle_missing_VM(build, vmToCheck if vmToCheck else 'graal')
351 351
352 if installGraalJar: 352 if installGraalJar:
353 _installGraalJarInJdks(mx.distribution('GRAAL')) 353 _installGraalJarInJdks(mx.distribution('GRAAL'))
354 354
355 if vmToCheck is not None: 355 if vmToCheck is not None:
356 jvmCfg = _vmCfgInJdk(jdk) 356 jvmCfg = _vmCfgInJdk(jdk)
357 found = False 357 found = False
358 with open(jvmCfg) as f: 358 with open(jvmCfg) as f:
359 for line in f: 359 for line in f:
360 if line.strip() == '-' + vmToCheck + ' KNOWN': 360 if line.strip() == '-' + vmToCheck + ' KNOWN':
361 found = True 361 found = True
362 break 362 break
363 if not found: 363 if not found:
364 _handle_missing_VM(build, vmToCheck) 364 _handle_missing_VM(build, vmToCheck)
365 365
366 return jdk 366 return jdk
367 367
368 def _installGraalJarInJdks(graalDist): 368 def _installGraalJarInJdks(graalDist):
369 graalJar = graalDist.path 369 graalJar = graalDist.path
370 graalOptions = join(_graal_home, 'graal.options') 370 graalOptions = join(_graal_home, 'graal.options')
376 # do a copy and then a move to get atomic updating (on Unix) of graal.jar in the JRE 376 # do a copy and then a move to get atomic updating (on Unix) of graal.jar in the JRE
377 fd, tmp = tempfile.mkstemp(suffix='', prefix='graal.jar', dir=jreLibDir) 377 fd, tmp = tempfile.mkstemp(suffix='', prefix='graal.jar', dir=jreLibDir)
378 shutil.copyfile(graalJar, tmp) 378 shutil.copyfile(graalJar, tmp)
379 os.close(fd) 379 os.close(fd)
380 shutil.move(tmp, join(jreLibDir, 'graal.jar')) 380 shutil.move(tmp, join(jreLibDir, 'graal.jar'))
381 381
382 if exists(graalOptions): 382 if exists(graalOptions):
383 shutil.copy(graalOptions, join(jreLibDir, 'graal.options')) 383 shutil.copy(graalOptions, join(jreLibDir, 'graal.options'))
384 384
385 # run a command in the windows SDK Debug Shell 385 # run a command in the windows SDK Debug Shell
386 def _runInDebugShell(cmd, workingDir, logFile=None, findInOutput=None, respondTo={}): 386 def _runInDebugShell(cmd, workingDir, logFile=None, findInOutput=None, respondTo=None):
387 if respondTo is None:
388 respondTo = {}
387 newLine = os.linesep 389 newLine = os.linesep
388 STARTTOKEN = 'RUNINDEBUGSHELL_STARTSEQUENCE' 390 startToken = 'RUNINDEBUGSHELL_STARTSEQUENCE'
389 ENDTOKEN = 'RUNINDEBUGSHELL_ENDSEQUENCE' 391 endToken = 'RUNINDEBUGSHELL_ENDSEQUENCE'
390 392
391 winSDK = mx.get_env('WIN_SDK', 'C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\') 393 winSDK = mx.get_env('WIN_SDK', 'C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\')
392 394
393 if not exists(winSDK): 395 if not exists(winSDK):
394 mx.abort("Could not find Windows SDK : '" + winSDK + "' does not exist") 396 mx.abort("Could not find Windows SDK : '" + winSDK + "' does not exist")
395 397
396 if not exists(join(winSDK, 'Bin', 'SetEnv.cmd')): 398 if not exists(join(winSDK, 'Bin', 'SetEnv.cmd')):
397 mx.abort("Invalid Windows SDK path (" + winSDK + ") : could not find Bin/SetEnv.cmd (you can use the WIN_SDK environment variable to specify an other path)") 399 mx.abort("Invalid Windows SDK path (" + winSDK + ") : could not find Bin/SetEnv.cmd (you can use the WIN_SDK environment variable to specify an other path)")
398 400
399 p = subprocess.Popen('cmd.exe /E:ON /V:ON /K ""' + winSDK + '/Bin/SetEnv.cmd" & echo ' + STARTTOKEN + '"', \ 401 p = subprocess.Popen('cmd.exe /E:ON /V:ON /K ""' + winSDK + '/Bin/SetEnv.cmd" & echo ' + startToken + '"', \
400 shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, creationflags=subprocess.CREATE_NEW_PROCESS_GROUP) 402 shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, creationflags=subprocess.CREATE_NEW_PROCESS_GROUP)
401 stdout = p.stdout 403 stdout = p.stdout
402 stdin = p.stdin 404 stdin = p.stdin
403 if logFile: 405 if logFile:
404 log = open(logFile, 'w') 406 log = open(logFile, 'w')
405 ret = False 407 ret = False
406 while True: 408 while True:
407 409
408 # encoding may be None on windows plattforms 410 # encoding may be None on windows plattforms
409 if sys.stdout.encoding is None: 411 if sys.stdout.encoding is None:
410 encoding = 'utf-8' 412 encoding = 'utf-8'
411 else: 413 else:
412 encoding = sys.stdout.encoding 414 encoding = sys.stdout.encoding
413 415
414 line = stdout.readline().decode(encoding) 416 line = stdout.readline().decode(encoding)
415 if logFile: 417 if logFile:
416 log.write(line.encode('utf-8')) 418 log.write(line.encode('utf-8'))
417 line = line.strip() 419 line = line.strip()
418 mx.log(line) 420 mx.log(line)
419 if line == STARTTOKEN: 421 if line == startToken:
420 stdin.write('cd /D ' + workingDir + ' & ' + cmd + ' & echo ' + ENDTOKEN + newLine) 422 stdin.write('cd /D ' + workingDir + ' & ' + cmd + ' & echo ' + endToken + newLine)
421 for regex in respondTo.keys(): 423 for regex in respondTo.keys():
422 match = regex.search(line) 424 match = regex.search(line)
423 if match: 425 if match:
424 stdin.write(respondTo[regex] + newLine) 426 stdin.write(respondTo[regex] + newLine)
425 if findInOutput: 427 if findInOutput:
426 match = findInOutput.search(line) 428 match = findInOutput.search(line)
427 if match: 429 if match:
428 ret = True 430 ret = True
429 if line == ENDTOKEN: 431 if line == endToken:
430 if not findInOutput: 432 if not findInOutput:
431 stdin.write('echo ERRXXX%errorlevel%' + newLine) 433 stdin.write('echo ERRXXX%errorlevel%' + newLine)
432 else: 434 else:
433 break 435 break
434 if line.startswith('ERRXXX'): 436 if line.startswith('ERRXXX'):
435 if line == 'ERRXXX0': 437 if line == 'ERRXXX0':
436 ret = True 438 ret = True
437 break; 439 break
438 stdin.write('exit' + newLine) 440 stdin.write('exit' + newLine)
439 if logFile: 441 if logFile:
440 log.close() 442 log.close()
441 return ret 443 return ret
442 444
454 'ALT_OUTPUTDIR' : 'Build directory', 456 'ALT_OUTPUTDIR' : 'Build directory',
455 'HOTSPOT_BUILD_JOBS' : 'Number of CPUs used by make (default: ' + str(multiprocessing.cpu_count()) + ')', 457 'HOTSPOT_BUILD_JOBS' : 'Number of CPUs used by make (default: ' + str(multiprocessing.cpu_count()) + ')',
456 'INSTALL' : 'Install the built VM into the JDK? (default: y)', 458 'INSTALL' : 'Install the built VM into the JDK? (default: y)',
457 'ZIP_DEBUGINFO_FILES' : 'Install zipped debug symbols file? (default: 0)', 459 'ZIP_DEBUGINFO_FILES' : 'Install zipped debug symbols file? (default: 0)',
458 } 460 }
459 461
460 mx.log('HotSpot build variables that can be set by the -D option to "mx build":') 462 mx.log('HotSpot build variables that can be set by the -D option to "mx build":')
461 mx.log('') 463 mx.log('')
462 for n in sorted(buildVars.iterkeys()): 464 for n in sorted(buildVars.iterkeys()):
463 mx.log(n) 465 mx.log(n)
464 mx.log(textwrap.fill(buildVars[n], initial_indent=' ', subsequent_indent=' ', width=200)) 466 mx.log(textwrap.fill(buildVars[n], initial_indent=' ', subsequent_indent=' ', width=200))
465 467
466 mx.log('') 468 mx.log('')
467 mx.log('Note that these variables can be given persistent values in the file ' + join(_graal_home, 'mx', 'env') + ' (see \'mx about\').') 469 mx.log('Note that these variables can be given persistent values in the file ' + join(_graal_home, 'mx', 'env') + ' (see \'mx about\').')
468 470
469 def build(args, vm=None): 471 def build(args, vm=None):
470 """build the VM binary 472 """build the VM binary
471 473
472 The global '--vm' and '--vmbuild' options select which VM type and build target to build.""" 474 The global '--vm' and '--vmbuild' options select which VM type and build target to build."""
473 475
484 mx.abort('To specify the ' + firstBuildTarget + ' VM build target, you need to use the global "--vmbuild" option. For example:\n' + 486 mx.abort('To specify the ' + firstBuildTarget + ' VM build target, you need to use the global "--vmbuild" option. For example:\n' +
485 ' mx --vmbuild ' + firstBuildTarget + ' build') 487 ' mx --vmbuild ' + firstBuildTarget + ' build')
486 return result 488 return result
487 489
488 # Call mx.build to compile the Java sources 490 # Call mx.build to compile the Java sources
489 parser=AP() 491 parser = AP()
490 parser.add_argument('--export-dir', help='directory to which graal.jar and graal.options will be copied', metavar='<path>') 492 parser.add_argument('--export-dir', help='directory to which graal.jar and graal.options will be copied', metavar='<path>')
491 parser.add_argument('-D', action='append', help='set a HotSpot build variable (run \'mx buildvars\' to list variables)', metavar='name=value') 493 parser.add_argument('-D', action='append', help='set a HotSpot build variable (run \'mx buildvars\' to list variables)', metavar='name=value')
492 opts2 = mx.build(['--source', '1.7'] + args, parser=parser) 494 opts2 = mx.build(['--source', '1.7'] + args, parser=parser)
493 assert len(opts2.remainder) == 0 495 assert len(opts2.remainder) == 0
494 496
518 elif vm.startswith('client'): 520 elif vm.startswith('client'):
519 buildSuffix = '1' 521 buildSuffix = '1'
520 else: 522 else:
521 assert vm == 'graal', vm 523 assert vm == 'graal', vm
522 buildSuffix = 'graal' 524 buildSuffix = 'graal'
523 525
524 if _installed_jdks: 526 if _installed_jdks:
525 if not mx.ask_yes_no("You are going to build while --installed-jdks is set (" + _installed_jdks + ") are you sure you want to continue", 'n'): 527 if not mx.ask_yes_no("You are going to build because --installed-jdks is set (" + _installed_jdks + ") - are you sure you want to continue", 'n'):
526 mx.abort(1) 528 mx.abort(1)
527 529
528 for build in builds: 530 for build in builds:
529 if build == 'ide-build-target': 531 if build == 'ide-build-target':
530 build = os.environ.get('IDE_BUILD_TARGET', None) 532 build = os.environ.get('IDE_BUILD_TARGET', None)
531 if build is None or len(build) == 0: 533 if build is None or len(build) == 0:
532 continue 534 continue
577 mksHome = mx.get_env('MKS_HOME', 'C:\\cygwin\\bin') 579 mksHome = mx.get_env('MKS_HOME', 'C:\\cygwin\\bin')
578 580
579 variant = {'client': 'compiler1', 'server': 'compiler2'}.get(vm, vm) 581 variant = {'client': 'compiler1', 'server': 'compiler2'}.get(vm, vm)
580 project_config = variant + '_' + build 582 project_config = variant + '_' + build
581 _runInDebugShell('msbuild ' + _graal_home + r'\build\vs-amd64\jvm.vcproj /p:Configuration=' + project_config + ' /target:clean', _graal_home) 583 _runInDebugShell('msbuild ' + _graal_home + r'\build\vs-amd64\jvm.vcproj /p:Configuration=' + project_config + ' /target:clean', _graal_home)
582 winCompileCmd = r'set HotSpotMksHome=' + mksHome + r'& set OUT_DIR=' + jdk + r'& set JAVA_HOME=' + jdk + r'& set path=%JAVA_HOME%\bin;%path%;%HotSpotMksHome%& cd /D "' +_graal_home + r'\make\windows"& call create.bat ' + _graal_home 584 winCompileCmd = r'set HotSpotMksHome=' + mksHome + r'& set OUT_DIR=' + jdk + r'& set JAVA_HOME=' + jdk + r'& set path=%JAVA_HOME%\bin;%path%;%HotSpotMksHome%& cd /D "' + _graal_home + r'\make\windows"& call create.bat ' + _graal_home
583 print(winCompileCmd) 585 print(winCompileCmd)
584 winCompileSuccess = re.compile(r"^Writing \.vcxproj file:") 586 winCompileSuccess = re.compile(r"^Writing \.vcxproj file:")
585 if not _runInDebugShell(winCompileCmd, _graal_home, compilelogfile, winCompileSuccess): 587 if not _runInDebugShell(winCompileCmd, _graal_home, compilelogfile, winCompileSuccess):
586 mx.log('Error executing create command') 588 mx.log('Error executing create command')
587 return 589 return
590 mx.log('Error building project') 592 mx.log('Error building project')
591 return 593 return
592 else: 594 else:
593 cpus = multiprocessing.cpu_count() 595 cpus = multiprocessing.cpu_count()
594 runCmd = [mx.gmake_cmd()] 596 runCmd = [mx.gmake_cmd()]
595 runCmd.append(build + buildSuffix) 597 runCmd.append(build + buildSuffix)
596 env = os.environ.copy() 598 env = os.environ.copy()
597 599
598 if opts2.D: 600 if opts2.D:
599 for nv in opts2.D: 601 for nv in opts2.D:
600 name, value = nv.split('=', 1) 602 name, value = nv.split('=', 1)
601 env[name.strip()] = value 603 env[name.strip()] = value
602 604
603 env.setdefault('ARCH_DATA_MODEL', '64') 605 env.setdefault('ARCH_DATA_MODEL', '64')
604 env.setdefault('LANG', 'C') 606 env.setdefault('LANG', 'C')
605 env.setdefault('HOTSPOT_BUILD_JOBS', str(cpus)) 607 env.setdefault('HOTSPOT_BUILD_JOBS', str(cpus))
606 env.setdefault('ALT_BOOTDIR', mx.java().jdk) 608 env.setdefault('ALT_BOOTDIR', mx.java().jdk)
607 if not mx._opts.verbose: 609 if not mx._opts.verbose:
645 with open(jvmCfg) as f: 647 with open(jvmCfg) as f:
646 for line in f: 648 for line in f:
647 if line.strip() == vmKnown.strip(): 649 if line.strip() == vmKnown.strip():
648 found = True 650 found = True
649 lines.append(line) 651 lines.append(line)
650 652
651 if not found: 653 if not found:
652 mx.log('Appending "' + prefix + 'KNOWN" to ' + jvmCfg) 654 mx.log('Appending "' + prefix + 'KNOWN" to ' + jvmCfg)
653 if mx.get_os() != 'windows': 655 if mx.get_os() != 'windows':
654 os.chmod(jvmCfg, 0755) 656 os.chmod(jvmCfg, 0755)
655 with open(jvmCfg, 'w') as f: 657 with open(jvmCfg, 'w') as f:
699 # Exclude all compiler tests and snippets 701 # Exclude all compiler tests and snippets
700 excludes = ['com.oracle.graal.compiler.tests.*', 'com.oracle.graal.jtt.*'] 702 excludes = ['com.oracle.graal.compiler.tests.*', 'com.oracle.graal.jtt.*']
701 for p in mx.projects(): 703 for p in mx.projects():
702 excludes += _find_classes_with_annotations(p, None, ['@Snippet', '@ClassSubstitution', '@Test'], includeInnerClasses=True).keys() 704 excludes += _find_classes_with_annotations(p, None, ['@Snippet', '@ClassSubstitution', '@Test'], includeInnerClasses=True).keys()
703 excludes += p.find_classes_with_matching_source_line(None, lambda line: 'JaCoCo Exclude' in line, includeInnerClasses=True).keys() 705 excludes += p.find_classes_with_matching_source_line(None, lambda line: 'JaCoCo Exclude' in line, includeInnerClasses=True).keys()
704 706
705 includes = ['com.oracle.graal.*'] 707 includes = ['com.oracle.graal.*']
706 agentOptions = { 708 agentOptions = {
707 'append' : 'true' if _jacoco == 'append' else 'false', 709 'append' : 'true' if _jacoco == 'append' else 'false',
708 'bootclasspath' : 'true', 710 'bootclasspath' : 'true',
709 'includes' : ':'.join(includes), 711 'includes' : ':'.join(includes),
714 if '-d64' not in args: 716 if '-d64' not in args:
715 args = ['-d64'] + args 717 args = ['-d64'] + args
716 718
717 exe = join(jdk, 'bin', mx.exe_suffix('java')) 719 exe = join(jdk, 'bin', mx.exe_suffix('java'))
718 pfx = _vm_prefix.split() if _vm_prefix is not None else [] 720 pfx = _vm_prefix.split() if _vm_prefix is not None else []
719 721
720 if '-version' in args: 722 if '-version' in args:
721 ignoredArgs = args[args.index('-version')+1:] 723 ignoredArgs = args[args.index('-version') + 1:]
722 if len(ignoredArgs) > 0: 724 if len(ignoredArgs) > 0:
723 mx.log("Warning: The following options will be ignored by the vm because they come after the '-version' argument: " + ' '.join(ignoredArgs)) 725 mx.log("Warning: The following options will be ignored by the vm because they come after the '-version' argument: " + ' '.join(ignoredArgs))
724 726
725 return mx.run(pfx + [exe, '-' + vm] + args, nonZeroIsFatal=nonZeroIsFatal, out=out, err=err, cwd=cwd, timeout=timeout) 727 return mx.run(pfx + [exe, '-' + vm] + args, nonZeroIsFatal=nonZeroIsFatal, out=out, err=err, cwd=cwd, timeout=timeout)
726 728
727 def _find_classes_with_annotations(p, pkgRoot, annotations, includeInnerClasses=False): 729 def _find_classes_with_annotations(p, pkgRoot, annotations, includeInnerClasses=False):
728 """ 730 """
729 Scan the sources of project 'p' for Java source files containing a line starting with 'annotation' 731 Scan the sources of project 'p' for Java source files containing a line starting with 'annotation'
730 (ignoring preceding whitespace) and return the fully qualified class name for each Java 732 (ignoring preceding whitespace) and return the fully qualified class name for each Java
731 source file matched in a list. 733 source file matched in a list.
732 """ 734 """
733 735
734 matches = lambda line : len([a for a in annotations if line == a or line.startswith(a + '(')]) != 0 736 matches = lambda line : len([a for a in annotations if line == a or line.startswith(a + '(')]) != 0
735 return p.find_classes_with_matching_source_line(pkgRoot, matches, includeInnerClasses) 737 return p.find_classes_with_matching_source_line(pkgRoot, matches, includeInnerClasses)
736 738
737 def _extract_VM_args(args, allowClasspath=False, useDoubleDash=False): 739 def _extract_VM_args(args, allowClasspath=False, useDoubleDash=False):
738 """ 740 """
740 """ 742 """
741 for i in range(0, len(args)): 743 for i in range(0, len(args)):
742 if useDoubleDash: 744 if useDoubleDash:
743 if args[i] == '--': 745 if args[i] == '--':
744 vmArgs = args[:i] 746 vmArgs = args[:i]
745 remainder = args[i + 1:] 747 remainder = args[i + 1:]
746 return vmArgs, remainder 748 return vmArgs, remainder
747 else: 749 else:
748 if not args[i].startswith('-'): 750 if not args[i].startswith('-'):
749 if i != 0 and (args[i - 1] == '-cp' or args[i - 1] == '-classpath'): 751 if i != 0 and (args[i - 1] == '-cp' or args[i - 1] == '-classpath'):
750 if not allowClasspath: 752 if not allowClasspath:
751 mx.abort('Cannot supply explicit class path option') 753 mx.abort('Cannot supply explicit class path option')
752 else: 754 else:
753 continue 755 continue
754 vmArgs = args[:i] 756 vmArgs = args[:i]
755 remainder = args[i:] 757 remainder = args[i:]
756 return vmArgs, remainder 758 return vmArgs, remainder
757 759
758 return args, [] 760 return args, []
759 761
760 def _run_tests(args, harness, annotations, testfile): 762 def _run_tests(args, harness, annotations, testfile):
761 763
762 764
763 vmArgs, tests = _extract_VM_args(args) 765 vmArgs, tests = _extract_VM_args(args)
764 for t in tests: 766 for t in tests:
765 if t.startswith('-'): 767 if t.startswith('-'):
766 mx.abort('VM option ' + t + ' must precede ' + tests[0]) 768 mx.abort('VM option ' + t + ' must precede ' + tests[0])
767 769
768 def containsAny(c, substrings):
769 for s in substrings:
770 if s in c:
771 return True
772 return False
773
774 candidates = [] 770 candidates = []
775 for p in mx.projects(): 771 for p in mx.projects():
776 if mx.java().javaCompliance < p.javaCompliance: 772 if mx.java().javaCompliance < p.javaCompliance:
777 continue 773 continue
778 candidates += _find_classes_with_annotations(p, None, annotations).keys() 774 candidates += _find_classes_with_annotations(p, None, annotations).keys()
833 829
834 _unittestHelpSuffix = """ 830 _unittestHelpSuffix = """
835 831
836 If filters are supplied, only tests whose fully qualified name 832 If filters are supplied, only tests whose fully qualified name
837 includes a filter as a substring are run. 833 includes a filter as a substring are run.
838 834
839 For example, this command line: 835 For example, this command line:
840 836
841 mx unittest -G:Dump= -G:MethodFilter=BC_aload.* -G:+PrintCFG BC_aload 837 mx unittest -G:Dump= -G:MethodFilter=BC_aload.* -G:+PrintCFG BC_aload
842 838
843 will run all JUnit test classes that contain 'BC_aload' in their 839 will run all JUnit test classes that contain 'BC_aload' in their
844 fully qualified name and will pass these options to the VM: 840 fully qualified name and will pass these options to the VM:
845 841
846 -G:Dump= -G:MethodFilter=BC_aload.* -G:+PrintCFG 842 -G:Dump= -G:MethodFilter=BC_aload.* -G:+PrintCFG
847 843
848 To get around command line length limitations on some OSes, the 844 To get around command line length limitations on some OSes, the
849 JUnit class names to be executed are written to a file that a 845 JUnit class names to be executed are written to a file that a
850 custom JUnit wrapper reads and passes onto JUnit proper. The 846 custom JUnit wrapper reads and passes onto JUnit proper. The
853 (unlike the temporary file otherwise used). 849 (unlike the temporary file otherwise used).
854 850
855 As with all other commands, using the global '-v' before 'unittest' 851 As with all other commands, using the global '-v' before 'unittest'
856 command will cause mx to show the complete command line 852 command will cause mx to show the complete command line
857 it uses to run the VM. 853 it uses to run the VM.
858 """ 854 """
859 855
860 def unittest(args): 856 def unittest(args):
861 """run the JUnit tests (all testcases){0}""" 857 """run the JUnit tests (all testcases){0}"""
862 858
863 _unittest(args, ['@Test', '@LongTest', '@Parameters']) 859 _unittest(args, ['@Test', '@LongTest', '@Parameters'])
875 def buildvms(args): 871 def buildvms(args):
876 """build one or more VMs in various configurations""" 872 """build one or more VMs in various configurations"""
877 873
878 vmsDefault = ','.join(_vmChoices.keys()) 874 vmsDefault = ','.join(_vmChoices.keys())
879 vmbuildsDefault = ','.join(_vmbuildChoices) 875 vmbuildsDefault = ','.join(_vmbuildChoices)
880 876
881 parser = ArgumentParser(prog='mx buildvms'); 877 parser = ArgumentParser(prog='mx buildvms')
882 parser.add_argument('--vms', help='a comma separated list of VMs to build (default: ' + vmsDefault + ')', metavar='<args>', default=vmsDefault) 878 parser.add_argument('--vms', help='a comma separated list of VMs to build (default: ' + vmsDefault + ')', metavar='<args>', default=vmsDefault)
883 parser.add_argument('--builds', help='a comma separated list of build types (default: ' + vmbuildsDefault + ')', metavar='<args>', default=vmbuildsDefault) 879 parser.add_argument('--builds', help='a comma separated list of build types (default: ' + vmbuildsDefault + ')', metavar='<args>', default=vmbuildsDefault)
884 parser.add_argument('-n', '--no-check', action='store_true', help='omit running "java -version" after each build') 880 parser.add_argument('-n', '--no-check', action='store_true', help='omit running "java -version" after each build')
885 parser.add_argument('-c', '--console', action='store_true', help='send build output to console instead of log file') 881 parser.add_argument('-c', '--console', action='store_true', help='send build output to console instead of log file')
886 882
897 logFile = join(v + '-' + vmbuild + '.log') 893 logFile = join(v + '-' + vmbuild + '.log')
898 log = open(join(_graal_home, logFile), 'wb') 894 log = open(join(_graal_home, logFile), 'wb')
899 start = time.time() 895 start = time.time()
900 mx.log('BEGIN: ' + v + '-' + vmbuild + '\t(see: ' + logFile + ')') 896 mx.log('BEGIN: ' + v + '-' + vmbuild + '\t(see: ' + logFile + ')')
901 # Run as subprocess so that output can be directed to a file 897 # Run as subprocess so that output can be directed to a file
902 subprocess.check_call([sys.executable, '-u', join('mxtool', 'mx.py'), '--vm', v, '--vmbuild', vmbuild, 'build'], cwd=_graal_home, stdout=log, stderr=subprocess.STDOUT) 898 subprocess.check_call([sys.executable, '-u', join('mxtool', 'mx.py'), '--vm', v, '--vmbuild',
899 vmbuild, 'build'], cwd=_graal_home, stdout=log, stderr=subprocess.STDOUT)
903 duration = datetime.timedelta(seconds=time.time() - start) 900 duration = datetime.timedelta(seconds=time.time() - start)
904 mx.log('END: ' + v + '-' + vmbuild + '\t[' + str(duration) + ']') 901 mx.log('END: ' + v + '-' + vmbuild + '\t[' + str(duration) + ']')
905 else: 902 else:
906 with VM(v, vmbuild): 903 with VM(v, vmbuild):
907 build([]) 904 build([])
936 self.duration = datetime.timedelta(seconds=self.end - self.start) 933 self.duration = datetime.timedelta(seconds=self.end - self.start)
937 mx.log(time.strftime('gate: %d %b %Y %H:%M:%S: ABORT: ') + self.title + ' [' + str(self.duration) + ']') 934 mx.log(time.strftime('gate: %d %b %Y %H:%M:%S: ABORT: ') + self.title + ' [' + str(self.duration) + ']')
938 mx.abort(codeOrMessage) 935 mx.abort(codeOrMessage)
939 return self 936 return self
940 937
941 parser = ArgumentParser(prog='mx gate'); 938 parser = ArgumentParser(prog='mx gate')
942 parser.add_argument('-j', '--omit-java-clean', action='store_false', dest='cleanJava', help='omit cleaning Java native code') 939 parser.add_argument('-j', '--omit-java-clean', action='store_false', dest='cleanJava', help='omit cleaning Java native code')
943 parser.add_argument('-n', '--omit-native-clean', action='store_false', dest='cleanNative', help='omit cleaning and building native code') 940 parser.add_argument('-n', '--omit-native-clean', action='store_false', dest='cleanNative', help='omit cleaning and building native code')
944 parser.add_argument('-g', '--only-build-graalvm', action='store_false', dest='buildNonGraal', help='only build the Graal VM') 941 parser.add_argument('-g', '--only-build-graalvm', action='store_false', dest='buildNonGraal', help='only build the Graal VM')
945 parser.add_argument('--jacocout', help='specify the output directory for jacoco report') 942 parser.add_argument('--jacocout', help='specify the output directory for jacoco report')
946 943
947 args = parser.parse_args(args) 944 args = parser.parse_args(args)
948 945
949 global _jacoco 946 global _jacoco
950 947
951 tasks = [] 948 tasks = []
952 total = Task('Gate') 949 total = Task('Gate')
953 try: 950 try:
954 951
955 t = Task('Clean') 952 t = Task('Clean')
976 t = Task('Canonicalization Check') 973 t = Task('Canonicalization Check')
977 mx.log(time.strftime('%d %b %Y %H:%M:%S - Ensuring mx/projects files are canonicalized...')) 974 mx.log(time.strftime('%d %b %Y %H:%M:%S - Ensuring mx/projects files are canonicalized...'))
978 if mx.canonicalizeprojects([]) != 0: 975 if mx.canonicalizeprojects([]) != 0:
979 t.abort('Rerun "mx canonicalizeprojects" and check-in the modified mx/projects files.') 976 t.abort('Rerun "mx canonicalizeprojects" and check-in the modified mx/projects files.')
980 tasks.append(t.stop()) 977 tasks.append(t.stop())
981 978
982 t = Task('BuildJava') 979 t = Task('BuildJava')
983 build(['--no-native', '--jdt-warning-as-error']) 980 build(['--no-native', '--jdt-warning-as-error'])
984 tasks.append(t.stop()) 981 tasks.append(t.stop())
985 982
986 t = Task('Checkstyle') 983 t = Task('Checkstyle')
987 if mx.checkstyle([]) != 0: 984 if mx.checkstyle([]) != 0:
988 t.abort('Checkstyle warnings were found') 985 t.abort('Checkstyle warnings were found')
989 tasks.append(t.stop()) 986 tasks.append(t.stop())
990 987
991 if exists('jacoco.exec'): 988 if exists('jacoco.exec'):
992 os.unlink('jacoco.exec') 989 os.unlink('jacoco.exec')
993 990
994 if args.jacocout is not None: 991 if args.jacocout is not None:
995 _jacoco = 'append' 992 _jacoco = 'append'
996 else: 993 else:
997 _jacoco = 'off' 994 _jacoco = 'off'
998 995
1007 1004
1008 with VM('graal', 'product'): 1005 with VM('graal', 'product'):
1009 t = Task('BootstrapWithGCVerification:product') 1006 t = Task('BootstrapWithGCVerification:product')
1010 vm(['-XX:+UnlockDiagnosticVMOptions', '-XX:+VerifyBeforeGC', '-XX:+VerifyAfterGC', '-version']) 1007 vm(['-XX:+UnlockDiagnosticVMOptions', '-XX:+VerifyBeforeGC', '-XX:+VerifyAfterGC', '-version'])
1011 tasks.append(t.stop()) 1008 tasks.append(t.stop())
1012 1009
1013 with VM('graal', 'product'): 1010 with VM('graal', 'product'):
1014 t = Task('BootstrapWithG1GCVerification:product') 1011 t = Task('BootstrapWithG1GCVerification:product')
1015 vm(['-XX:+UnlockDiagnosticVMOptions', '-XX:-UseSerialGC','-XX:+UseG1GC','-XX:+UseNewCode','-XX:+VerifyBeforeGC', '-XX:+VerifyAfterGC', '-version']) 1012 vm(['-XX:+UnlockDiagnosticVMOptions', '-XX:-UseSerialGC', '-XX:+UseG1GC', '-XX:+UseNewCode', '-XX:+VerifyBeforeGC', '-XX:+VerifyAfterGC', '-version'])
1016 tasks.append(t.stop()) 1013 tasks.append(t.stop())
1017 1014
1018 with VM('graal', 'product'): 1015 with VM('graal', 'product'):
1019 t = Task('BootstrapWithRegisterPressure:product') 1016 t = Task('BootstrapWithRegisterPressure:product')
1020 vm(['-G:RegisterPressure=rbx,r11,r10,r14,xmm3,xmm11,xmm14', '-esa', '-version']) 1017 vm(['-G:RegisterPressure=rbx,r11,r10,r14,xmm3,xmm11,xmm14', '-esa', '-version'])
1023 with VM('graal', 'product'): 1020 with VM('graal', 'product'):
1024 t = Task('BootstrapWithAOTConfiguration:product') 1021 t = Task('BootstrapWithAOTConfiguration:product')
1025 vm(['-G:+AOTCompilation', '-G:+VerifyPhases', '-esa', '-version']) 1022 vm(['-G:+AOTCompilation', '-G:+VerifyPhases', '-esa', '-version'])
1026 tasks.append(t.stop()) 1023 tasks.append(t.stop())
1027 1024
1028 with VM('server', 'product'): # hosted mode 1025 with VM('server', 'product'): # hosted mode
1029 t = Task('UnitTests:hosted-product') 1026 t = Task('UnitTests:hosted-product')
1030 unittest([]) 1027 unittest([])
1031 tasks.append(t.stop()) 1028 tasks.append(t.stop())
1032 1029
1033 for vmbuild in ['fastdebug', 'product']: 1030 for vmbuild in ['fastdebug', 'product']:
1037 t.abort(test.name + ' Failed') 1034 t.abort(test.name + ' Failed')
1038 tasks.append(t.stop()) 1035 tasks.append(t.stop())
1039 1036
1040 if args.jacocout is not None: 1037 if args.jacocout is not None:
1041 jacocoreport([args.jacocout]) 1038 jacocoreport([args.jacocout])
1042 1039
1043 _jacoco = 'off' 1040 _jacoco = 'off'
1044 1041
1045 t = Task('CleanAndBuildGraalVisualizer') 1042 t = Task('CleanAndBuildGraalVisualizer')
1046 mx.run(['ant', '-f', join(_graal_home, 'visualizer', 'build.xml'), '-q', 'clean', 'build']) 1043 mx.run(['ant', '-f', join(_graal_home, 'visualizer', 'build.xml'), '-q', 'clean', 'build'])
1047 tasks.append(t.stop()) 1044 tasks.append(t.stop())
1058 for theVm in ['client', 'server']: 1055 for theVm in ['client', 'server']:
1059 with VM(theVm, vmbuild): 1056 with VM(theVm, vmbuild):
1060 t = Task('DaCapo_pmd:' + theVm + ':' + vmbuild) 1057 t = Task('DaCapo_pmd:' + theVm + ':' + vmbuild)
1061 dacapo(['pmd']) 1058 dacapo(['pmd'])
1062 tasks.append(t.stop()) 1059 tasks.append(t.stop())
1063 1060
1064 t = Task('UnitTests:' + theVm + ':' + vmbuild) 1061 t = Task('UnitTests:' + theVm + ':' + vmbuild)
1065 unittest(['-XX:CompileCommand=exclude,*::run*', 'graal.api']) 1062 unittest(['-XX:CompileCommand=exclude,*::run*', 'graal.api'])
1066 tasks.append(t.stop()) 1063 tasks.append(t.stop())
1067 1064
1068 except KeyboardInterrupt: 1065 except KeyboardInterrupt:
1078 mx.log('Gate task times:') 1075 mx.log('Gate task times:')
1079 for t in tasks: 1076 for t in tasks:
1080 mx.log(' ' + str(t.duration) + '\t' + t.title) 1077 mx.log(' ' + str(t.duration) + '\t' + t.title)
1081 mx.log(' =======') 1078 mx.log(' =======')
1082 mx.log(' ' + str(total.duration)) 1079 mx.log(' ' + str(total.duration))
1083 1080
1084 def deoptalot(args): 1081 def deoptalot(args):
1085 """bootstrap a fastdebug Graal VM with DeoptimizeALot and VerifyOops on 1082 """bootstrap a fastdebug Graal VM with DeoptimizeALot and VerifyOops on
1086 1083
1087 If the first argument is a number, the process will be repeated 1084 If the first argument is a number, the process will be repeated
1088 this number of times. All other arguments are passed to the VM.""" 1085 this number of times. All other arguments are passed to the VM."""
1089 count = 1 1086 count = 1
1090 if len(args) > 0 and args[0].isdigit(): 1087 if len(args) > 0 and args[0].isdigit():
1091 count = int(args[0]) 1088 count = int(args[0])
1092 del args[0] 1089 del args[0]
1093 1090
1094 for _ in range(count): 1091 for _ in range(count):
1095 if not vm(['-XX:+DeoptimizeALot', '-XX:+VerifyOops'] + args + ['-version'], vmbuild='fastdebug') == 0: 1092 if not vm(['-XX:+DeoptimizeALot', '-XX:+VerifyOops'] + args + ['-version'], vmbuild='fastdebug') == 0:
1096 mx.abort("Failed") 1093 mx.abort("Failed")
1097 1094
1098 def longtests(args): 1095 def longtests(args):
1099 1096
1100 deoptalot(['15', '-Xmx48m']) 1097 deoptalot(['15', '-Xmx48m'])
1101 1098
1102 dacapo(['100', 'eclipse', '-esa']) 1099 dacapo(['100', 'eclipse', '-esa'])
1103 1100
1104 def gv(args): 1101 def gv(args):
1105 """run the Graal Visualizer""" 1102 """run the Graal Visualizer"""
1106 with open(join(_graal_home, '.graal_visualizer.log'), 'w') as fp: 1103 with open(join(_graal_home, '.graal_visualizer.log'), 'w') as fp:
1131 else: 1128 else:
1132 mx.abort('-resultfile must be followed by a file name') 1129 mx.abort('-resultfile must be followed by a file name')
1133 vm = _get_vm() 1130 vm = _get_vm()
1134 if len(args) is 0: 1131 if len(args) is 0:
1135 args = ['all'] 1132 args = ['all']
1136 1133
1137 vmArgs = [arg for arg in args if arg.startswith('-')] 1134 vmArgs = [arg for arg in args if arg.startswith('-')]
1138 1135
1139 def benchmarks_in_group(group): 1136 def benchmarks_in_group(group):
1140 prefix = group + ':' 1137 prefix = group + ':'
1141 return [a[len(prefix):] for a in args if a.startswith(prefix)] 1138 return [a[len(prefix):] for a in args if a.startswith(prefix)]
1142 1139
1143 results = {} 1140 results = {}
1144 benchmarks = [] 1141 benchmarks = []
1145 #DaCapo 1142 # DaCapo
1146 if ('dacapo' in args or 'all' in args): 1143 if ('dacapo' in args or 'all' in args):
1147 benchmarks += sanitycheck.getDacapos(level=sanitycheck.SanityCheckLevel.Benchmark) 1144 benchmarks += sanitycheck.getDacapos(level=sanitycheck.SanityCheckLevel.Benchmark)
1148 else: 1145 else:
1149 dacapos = benchmarks_in_group('dacapo') 1146 dacapos = benchmarks_in_group('dacapo')
1150 for dacapo in dacapos: 1147 for dacapo in dacapos:
1163 mx.abort('Unknown Scala DaCapo : ' + scaladacapo) 1160 mx.abort('Unknown Scala DaCapo : ' + scaladacapo)
1164 iterations = sanitycheck.dacapoScalaSanityWarmup[scaladacapo][sanitycheck.SanityCheckLevel.Benchmark] 1161 iterations = sanitycheck.dacapoScalaSanityWarmup[scaladacapo][sanitycheck.SanityCheckLevel.Benchmark]
1165 if (iterations > 0): 1162 if (iterations > 0):
1166 benchmarks += [sanitycheck.getScalaDacapo(scaladacapo, ['-n', str(iterations)])] 1163 benchmarks += [sanitycheck.getScalaDacapo(scaladacapo, ['-n', str(iterations)])]
1167 1164
1168 #Bootstrap 1165 # Bootstrap
1169 if ('bootstrap' in args or 'all' in args): 1166 if ('bootstrap' in args or 'all' in args):
1170 benchmarks += sanitycheck.getBootstraps() 1167 benchmarks += sanitycheck.getBootstraps()
1171 #SPECjvm2008 1168 # SPECjvm2008
1172 if ('specjvm2008' in args or 'all' in args): 1169 if ('specjvm2008' in args or 'all' in args):
1173 benchmarks += [sanitycheck.getSPECjvm2008(['-ikv', '-wt', '120', '-it', '120'])] 1170 benchmarks += [sanitycheck.getSPECjvm2008(['-ikv', '-wt', '120', '-it', '120'])]
1174 else: 1171 else:
1175 specjvms = benchmarks_in_group('specjvm2008') 1172 specjvms = benchmarks_in_group('specjvm2008')
1176 for specjvm in specjvms: 1173 for specjvm in specjvms:
1177 benchmarks += [sanitycheck.getSPECjvm2008(['-ikv', '-wt', '120', '-it', '120', specjvm])] 1174 benchmarks += [sanitycheck.getSPECjvm2008(['-ikv', '-wt', '120', '-it', '120', specjvm])]
1178 1175
1179 if ('specjbb2005' in args or 'all' in args): 1176 if ('specjbb2005' in args or 'all' in args):
1180 benchmarks += [sanitycheck.getSPECjbb2005()] 1177 benchmarks += [sanitycheck.getSPECjbb2005()]
1181 1178
1182 if ('specjbb2013' in args): # or 'all' in args //currently not in default set 1179 if ('specjbb2013' in args): # or 'all' in args //currently not in default set
1183 benchmarks += [sanitycheck.getSPECjbb2013()] 1180 benchmarks += [sanitycheck.getSPECjbb2013()]
1184 1181
1185 if ('ctw-full' in args): 1182 if ('ctw-full' in args):
1186 benchmarks.append(sanitycheck.getCTW(vm, sanitycheck.CTWMode.Full)) 1183 benchmarks.append(sanitycheck.getCTW(vm, sanitycheck.CTWMode.Full))
1187 if ('ctw-noinline' in args): 1184 if ('ctw-noinline' in args):
1188 benchmarks.append(sanitycheck.getCTW(vm, sanitycheck.CTWMode.NoInline)) 1185 benchmarks.append(sanitycheck.getCTW(vm, sanitycheck.CTWMode.NoInline))
1189 if ('ctw-nocomplex' in args): 1186 if ('ctw-nocomplex' in args):
1198 with open(resultFile, 'w') as f: 1195 with open(resultFile, 'w') as f:
1199 f.write(json.dumps(results)) 1196 f.write(json.dumps(results))
1200 1197
1201 def specjvm2008(args): 1198 def specjvm2008(args):
1202 """run one or more SPECjvm2008 benchmarks""" 1199 """run one or more SPECjvm2008 benchmarks"""
1203 1200
1204 def launcher(bm, harnessArgs, extraVmOpts): 1201 def launcher(bm, harnessArgs, extraVmOpts):
1205 return sanitycheck.getSPECjvm2008(harnessArgs + [bm]).bench(_get_vm(), extraVmOpts=extraVmOpts) 1202 return sanitycheck.getSPECjvm2008(harnessArgs + [bm]).bench(_get_vm(), extraVmOpts=extraVmOpts)
1206 1203
1207 availableBenchmarks = set(sanitycheck.specjvm2008Names) 1204 availableBenchmarks = set(sanitycheck.specjvm2008Names)
1208 for name in sanitycheck.specjvm2008Names: 1205 for name in sanitycheck.specjvm2008Names:
1209 parts = name.rsplit('.', 1) 1206 parts = name.rsplit('.', 1)
1210 if len(parts) > 1: 1207 if len(parts) > 1:
1211 assert len(parts) == 2 1208 assert len(parts) == 2
1212 group = parts[0] 1209 group = parts[0]
1213 print group 1210 print group
1214 availableBenchmarks.add(group) 1211 availableBenchmarks.add(group)
1215 1212
1216 _run_benchmark(args, sorted(availableBenchmarks), launcher) 1213 _run_benchmark(args, sorted(availableBenchmarks), launcher)
1217 1214
1218 def specjbb2013(args): 1215 def specjbb2013(args):
1219 """runs the composite SPECjbb2013 benchmark""" 1216 """runs the composite SPECjbb2013 benchmark"""
1220 1217
1221 def launcher(bm, harnessArgs, extraVmOpts): 1218 def launcher(bm, harnessArgs, extraVmOpts):
1222 assert bm is None 1219 assert bm is None
1223 return sanitycheck.getSPECjbb2013(harnessArgs).bench(_get_vm(), extraVmOpts=extraVmOpts) 1220 return sanitycheck.getSPECjbb2013(harnessArgs).bench(_get_vm(), extraVmOpts=extraVmOpts)
1224 1221
1225 _run_benchmark(args, None, launcher) 1222 _run_benchmark(args, None, launcher)
1226 1223
1227 def specjbb2005(args): 1224 def specjbb2005(args):
1228 """runs the composite SPECjbb2005 benchmark""" 1225 """runs the composite SPECjbb2005 benchmark"""
1229 1226
1230 def launcher(bm, harnessArgs, extraVmOpts): 1227 def launcher(bm, harnessArgs, extraVmOpts):
1231 assert bm is None 1228 assert bm is None
1232 return sanitycheck.getSPECjbb2005(harnessArgs).bench(_get_vm(), extraVmOpts=extraVmOpts) 1229 return sanitycheck.getSPECjbb2005(harnessArgs).bench(_get_vm(), extraVmOpts=extraVmOpts)
1233 1230
1234 _run_benchmark(args, None, launcher) 1231 _run_benchmark(args, None, launcher)
1235 1232
1236 def hsdis(args, copyToDir=None): 1233 def hsdis(args, copyToDir=None):
1237 """download the hsdis library 1234 """download the hsdis library
1238 1235
1252 """disassemble HexCodeFiles embedded in text files 1249 """disassemble HexCodeFiles embedded in text files
1253 1250
1254 Run a tool over the input files to convert all embedded HexCodeFiles 1251 Run a tool over the input files to convert all embedded HexCodeFiles
1255 to a disassembled format.""" 1252 to a disassembled format."""
1256 1253
1257 parser = ArgumentParser(prog='mx hcfdis'); 1254 parser = ArgumentParser(prog='mx hcfdis')
1258 parser.add_argument('-m', '--map', help='address to symbol map applied to disassembler output') 1255 parser.add_argument('-m', '--map', help='address to symbol map applied to disassembler output')
1259 parser.add_argument('files', nargs=REMAINDER, metavar='files...') 1256 parser.add_argument('files', nargs=REMAINDER, metavar='files...')
1260 1257
1261 args = parser.parse_args(args) 1258 args = parser.parse_args(args)
1262 1259
1263 path = join(_graal_home, 'lib', 'hcfdis-1.jar') 1260 path = join(_graal_home, 'lib', 'hcfdis-1.jar')
1264 if not exists(path): 1261 if not exists(path):
1265 mx.download(path, ['http://lafo.ssw.uni-linz.ac.at/hcfdis-1.jar']) 1262 mx.download(path, ['http://lafo.ssw.uni-linz.ac.at/hcfdis-1.jar'])
1266 mx.run_java(['-jar', path] + args.files) 1263 mx.run_java(['-jar', path] + args.files)
1267 1264
1268 if args.map is not None: 1265 if args.map is not None:
1269 addressRE = re.compile(r'0[xX]([A-Fa-f0-9]+)') 1266 addressRE = re.compile(r'0[xX]([A-Fa-f0-9]+)')
1270 with open(args.map) as fp: 1267 with open(args.map) as fp:
1271 lines = fp.read().splitlines() 1268 lines = fp.read().splitlines()
1272 symbols = dict() 1269 symbols = dict()
1273 for l in lines: 1270 for l in lines:
1274 addressAndSymbol = l.split(' ', 1) 1271 addressAndSymbol = l.split(' ', 1)
1275 if len(addressAndSymbol) == 2: 1272 if len(addressAndSymbol) == 2:
1276 address, symbol = addressAndSymbol; 1273 address, symbol = addressAndSymbol
1277 if address.startswith('0x'): 1274 if address.startswith('0x'):
1278 address = long(address, 16) 1275 address = long(address, 16)
1279 symbols[address] = symbol 1276 symbols[address] = symbol
1280 for f in args.files: 1277 for f in args.files:
1281 with open(f) as fp: 1278 with open(f) as fp:
1282 lines = fp.read().splitlines() 1279 lines = fp.read().splitlines()
1362 'The VM selected by --vm and --vmbuild options is under this directory (i.e., ' + 1359 'The VM selected by --vm and --vmbuild options is under this directory (i.e., ' +
1363 join('<path>', '<jdk-version>', '<vmbuild>', 'jre', 'lib', '<vm>', mx.add_lib_prefix(mx.add_lib_suffix('jvm'))) + ')', default=None, metavar='<path>') 1360 join('<path>', '<jdk-version>', '<vmbuild>', 'jre', 'lib', '<vm>', mx.add_lib_prefix(mx.add_lib_suffix('jvm'))) + ')', default=None, metavar='<path>')
1364 1361
1365 if (_vmSourcesAvailable): 1362 if (_vmSourcesAvailable):
1366 mx.add_argument('--vm', action='store', dest='vm', choices=_vmChoices.keys(), help='the VM type to build/run') 1363 mx.add_argument('--vm', action='store', dest='vm', choices=_vmChoices.keys(), help='the VM type to build/run')
1367 mx.add_argument('--vmbuild', action='store', dest='vmbuild', choices=_vmbuildChoices, help='the VM build to build/run (default: ' + _vmbuildChoices[0] +')') 1364 mx.add_argument('--vmbuild', action='store', dest='vmbuild', choices=_vmbuildChoices, help='the VM build to build/run (default: ' + _vmbuildChoices[0] + ')')
1368 mx.add_argument('--ecl', action='store_true', dest='make_eclipse_launch', help='create launch configuration for running VM execution(s) in Eclipse') 1365 mx.add_argument('--ecl', action='store_true', dest='make_eclipse_launch', help='create launch configuration for running VM execution(s) in Eclipse')
1369 mx.add_argument('--vmprefix', action='store', dest='vm_prefix', help='prefix for running the VM (e.g. "/usr/bin/gdb --args")', metavar='<prefix>') 1366 mx.add_argument('--vmprefix', action='store', dest='vm_prefix', help='prefix for running the VM (e.g. "/usr/bin/gdb --args")', metavar='<prefix>')
1370 mx.add_argument('--gdb', action='store_const', const='/usr/bin/gdb --args', dest='vm_prefix', help='alias for --vmprefix "/usr/bin/gdb --args"') 1367 mx.add_argument('--gdb', action='store_const', const='/usr/bin/gdb --args', dest='vm_prefix', help='alias for --vmprefix "/usr/bin/gdb --args"')
1371 1368
1372 commands.update({ 1369 commands.update({
1373 'export': [export, '[-options] [zipfile]'], 1370 'export': [export, '[-options] [zipfile]'],
1374 }) 1371 })
1375 1372
1376 mx.commands.update(commands) 1373 mx._commands.update(commands)
1377 1374
1378 def mx_post_parse_cmd_line(opts):# 1375 def mx_post_parse_cmd_line(opts): #
1379 # TODO _minVersion check could probably be part of a Suite in mx? 1376 # TODO _minVersion check could probably be part of a Suite in mx?
1380 if (mx.java().version < _minVersion) : 1377 if (mx.java().version < _minVersion) :
1381 mx.abort('Requires Java version ' + str(_minVersion) + ' or greater, got version ' + str(mx.java().version)) 1378 mx.abort('Requires Java version ' + str(_minVersion) + ' or greater, got version ' + str(mx.java().version))
1382 1379
1383 if (_vmSourcesAvailable): 1380 if (_vmSourcesAvailable):