comparison mx/mx_graal.py @ 21578:a880844225e4

Merge with f41409c6ff26923655747d1a36ac51892b1153ac
author Michael Van De Vanter <michael.van.de.vanter@oracle.com>
date Thu, 28 May 2015 21:11:28 -0700
parents 9c2c8e4b5333 1de4d7e69f85
children a004616f72e5
comparison
equal deleted inserted replaced
21577:8a01110bfbaf 21578:a880844225e4
45 _vmSourcesAvailable = exists(join(_graal_home, 'make')) and exists(join(_graal_home, 'src')) 45 _vmSourcesAvailable = exists(join(_graal_home, 'make')) and exists(join(_graal_home, 'src'))
46 46
47 """ The VMs that can be built and run along with an optional description. Only VMs with a 47 """ The VMs that can be built and run along with an optional description. Only VMs with a
48 description are listed in the dialogue for setting the default VM (see _get_vm()). """ 48 description are listed in the dialogue for setting the default VM (see _get_vm()). """
49 _vmChoices = { 49 _vmChoices = {
50 'graal' : 'Normal compilation is performed with a tiered system (C1 + Graal), Truffle compilation is performed with Graal.', 50 'jvmci' : 'Normal compilation is performed with a tiered system (C1 + Graal), Truffle compilation is performed with Graal.',
51 'server' : 'Normal compilation is performed with a tiered system (C1 + C2), Truffle compilation is performed with Graal. Use this for optimal Truffle performance.', 51 'server' : 'Normal compilation is performed with a tiered system (C1 + C2), Truffle compilation is performed with Graal. Use this for optimal Truffle performance.',
52 'client' : None, # normal compilation with client compiler, explicit compilation (e.g., by Truffle) with Graal 52 'client' : None, # normal compilation with client compiler, explicit compilation (e.g., by Truffle) with Graal
53 'server-nograal' : None, # all compilation with tiered system (i.e., client + server), Graal omitted 53 'server-nojvmci' : None, # all compilation with tiered system (i.e., client + server), JVMCI omitted
54 'client-nograal' : None, # all compilation with client compiler, Graal omitted 54 'client-nojvmci' : None, # all compilation with client compiler, JVMCI omitted
55 'original' : None, # default VM copied from bootstrap JDK 55 'original' : None, # default VM copied from bootstrap JDK
56 } 56 }
57 57
58 """ The VM that will be run by the 'vm' command and built by default by the 'build' command. 58 """ The VM that will be run by the 'vm' command and built by default by the 'build' command.
59 This can be set via the global '--vm' option or the DEFAULT_VM environment variable. 59 This can be set via the global '--vm' option or the DEFAULT_VM environment variable.
85 85
86 # max version (first _unsupported_ version) 86 # max version (first _unsupported_ version)
87 _untilVersion = None 87 _untilVersion = None
88 88
89 class JDKDeployedDist: 89 class JDKDeployedDist:
90 def __init__(self, name, isExtension=False, isGraalClassLoader=False): 90 def __init__(self, name, isExtension=False, usesJVMCIClassLoader=False):
91 self.name = name 91 self.name = name
92 self.isExtension = isExtension 92 self.isExtension = isExtension
93 self.isGraalClassLoader = isGraalClassLoader 93 self.usesJVMCIClassLoader = usesJVMCIClassLoader
94 94
95 _jdkDeployedDists = [ 95 _jdkDeployedDists = [
96 JDKDeployedDist('TRUFFLE'), 96 JDKDeployedDist('TRUFFLE'),
97 JDKDeployedDist('GRAAL_LOADER'), 97 JDKDeployedDist('JVMCI_LOADER'),
98 JDKDeployedDist('GRAAL', isGraalClassLoader=True), 98 JDKDeployedDist('GRAAL', usesJVMCIClassLoader=True),
99 JDKDeployedDist('GRAAL_TRUFFLE', isGraalClassLoader=True) 99 JDKDeployedDist('GRAAL_TRUFFLE', usesJVMCIClassLoader=True)
100 ] 100 ]
101 101
102 JDK_UNIX_PERMISSIONS_DIR = 0755 102 JDK_UNIX_PERMISSIONS_DIR = 0755
103 JDK_UNIX_PERMISSIONS_FILE = 0644 103 JDK_UNIX_PERMISSIONS_FILE = 0644
104 JDK_UNIX_PERMISSIONS_EXEC = 0755 104 JDK_UNIX_PERMISSIONS_EXEC = 0755
165 os.chmod(dirname, chmodFlagsDir) 165 os.chmod(dirname, chmodFlagsDir)
166 166
167 os.path.walk(dirname, _chmodDir, chmodFlagsDir) 167 os.path.walk(dirname, _chmodDir, chmodFlagsDir)
168 168
169 def clean(args): 169 def clean(args):
170 """clean the GraalVM source tree""" 170 """clean the source tree"""
171 opts = mx.clean(args, parser=ArgumentParser(prog='mx clean')) 171 opts = mx.clean(args, parser=ArgumentParser(prog='mx clean'))
172 172
173 if opts.native: 173 if opts.native:
174 def handleRemoveReadonly(func, path, exc): 174 def handleRemoveReadonly(func, path, exc):
175 excvalue = exc[1] 175 excvalue = exc[1]
184 shutil.rmtree(name, ignore_errors=False, onerror=handleRemoveReadonly) 184 shutil.rmtree(name, ignore_errors=False, onerror=handleRemoveReadonly)
185 elif os.path.isfile(name): 185 elif os.path.isfile(name):
186 os.unlink(name) 186 os.unlink(name)
187 187
188 rmIfExists(join(_graal_home, 'build')) 188 rmIfExists(join(_graal_home, 'build'))
189 rmIfExists(join(_graal_home, 'build-nograal')) 189 rmIfExists(join(_graal_home, 'build-nojvmci'))
190 rmIfExists(_jdksDir()) 190 rmIfExists(_jdksDir())
191 191
192 def export(args): 192 def export(args):
193 """create archives of builds split by vmbuild and vm""" 193 """create archives of builds split by vmbuild and vm"""
194 194
497 if not found: 497 if not found:
498 _handle_missing_VM(build, vmToCheck) 498 _handle_missing_VM(build, vmToCheck)
499 499
500 return jdk 500 return jdk
501 501
502 def _updateInstalledGraalOptionsFile(jdk): 502 def _updateInstalledJVMCIOptionsFile(jdk):
503 graalOptions = join(_graal_home, 'graal.options') 503 jvmciOptions = join(_graal_home, 'jvmci.options')
504 jreLibDir = join(jdk, 'jre', 'lib') 504 jreLibDir = join(jdk, 'jre', 'lib')
505 if exists(graalOptions): 505 if exists(jvmciOptions):
506 shutil.copy(graalOptions, join(jreLibDir, 'graal.options')) 506 shutil.copy(jvmciOptions, join(jreLibDir, 'jvmci.options'))
507 else: 507 else:
508 toDelete = join(jreLibDir, 'graal.options') 508 toDelete = join(jreLibDir, 'jvmci.options')
509 if exists(toDelete): 509 if exists(toDelete):
510 os.unlink(toDelete) 510 os.unlink(toDelete)
511 511
512 def _makeHotspotGeneratedSourcesDir(): 512 def _makeHotspotGeneratedSourcesDir():
513 """ 513 """
514 Gets the directory containing all the HotSpot sources generated from 514 Gets the directory containing all the HotSpot sources generated from
515 Graal Java sources. This directory will be created if it doesn't yet exist. 515 JVMCI Java sources. This directory will be created if it doesn't yet exist.
516 """ 516 """
517 hsSrcGenDir = join(mx.project('com.oracle.graal.hotspot').source_gen_dir(), 'hotspot') 517 hsSrcGenDir = join(mx.project('com.oracle.jvmci.hotspot').source_gen_dir(), 'hotspot')
518 if not exists(hsSrcGenDir): 518 if not exists(hsSrcGenDir):
519 os.makedirs(hsSrcGenDir) 519 os.makedirs(hsSrcGenDir)
520 return hsSrcGenDir 520 return hsSrcGenDir
521 521
522 def _copyToJdk(src, dst, permissions=JDK_UNIX_PERMISSIONS_FILE): 522 def _copyToJdk(src, dst, permissions=JDK_UNIX_PERMISSIONS_FILE):
541 def _eraseGenerics(className): 541 def _eraseGenerics(className):
542 if '<' in className: 542 if '<' in className:
543 return className[:className.index('<')] 543 return className[:className.index('<')]
544 return className 544 return className
545 545
546 def _classifyGraalServices(classNames, graalJars): 546 def _classifyJVMCIServices(classNames, jvmciJars):
547 classification = {} 547 classification = {}
548 if not classNames: 548 if not classNames:
549 return classification 549 return classification
550 for className in classNames: 550 for className in classNames:
551 classification[className] = None 551 classification[className] = None
552 javap = mx.java().javap 552 javap = mx.java().javap
553 output = subprocess.check_output([javap, '-cp', os.pathsep.join(graalJars)] + classNames, stderr=subprocess.STDOUT) 553 output = subprocess.check_output([javap, '-cp', os.pathsep.join(jvmciJars)] + classNames, stderr=subprocess.STDOUT)
554 lines = output.split(os.linesep) 554 lines = output.split(os.linesep)
555 for line in lines: 555 for line in lines:
556 if line.startswith('public interface '): 556 if line.startswith('public interface '):
557 declLine = line[len('public interface '):].strip() 557 declLine = line[len('public interface '):].strip()
558 for className in classNames: 558 for className in classNames:
561 afterName = declLine[len(className):] 561 afterName = declLine[len(className):]
562 if not afterName.startswith(' extends '): 562 if not afterName.startswith(' extends '):
563 classification[className] = False 563 classification[className] = False
564 break 564 break
565 superInterfaces = afterName[len(' extends '):-len(' {')].split(',') 565 superInterfaces = afterName[len(' extends '):-len(' {')].split(',')
566 if 'com.oracle.graal.api.runtime.Service' in superInterfaces: 566 if 'com.oracle.jvmci.runtime.Service' in superInterfaces:
567 classification[className] = True 567 classification[className] = True
568 break 568 break
569 maybe = [_eraseGenerics(superInterface) for superInterface in superInterfaces] 569 maybe = [_eraseGenerics(superInterface) for superInterface in superInterfaces]
570 classification[className] = maybe 570 classification[className] = maybe
571 break 571 break
573 if v is None: 573 if v is None:
574 mx.abort('Could not find interface for service ' + className + ':\n' + output) 574 mx.abort('Could not find interface for service ' + className + ':\n' + output)
575 return classification 575 return classification
576 576
577 def _extractMaybes(classification): 577 def _extractMaybes(classification):
578 maybes = [] 578 maybes = set()
579 for v in classification.values(): 579 for v in classification.values():
580 if isinstance(v, list): 580 if isinstance(v, list):
581 maybes.extend(v) 581 maybes.update(v)
582 return maybes 582 return list(maybes)
583 583
584 def _mergeClassification(classification, newClassification): 584 def _mergeClassification(classification, newClassification):
585 for className, value in classification.items(): 585 for className, value in classification.items():
586 if isinstance(value, list): 586 if isinstance(value, list):
587 classification[className] = None 587 classification[className] = None
595 else: 595 else:
596 if not classification[className]: 596 if not classification[className]:
597 classification[className] = [] 597 classification[className] = []
598 classification[className].extend(newClassification[superInterface]) 598 classification[className].extend(newClassification[superInterface])
599 599
600 def _filterGraalService(classNames, graalJars): 600 def _filterJVMCIService(classNames, jvmciJars):
601 classification = _classifyGraalServices(classNames, graalJars) 601 classification = _classifyJVMCIServices(classNames, jvmciJars)
602 needClassification = _extractMaybes(classification) 602 needClassification = _extractMaybes(classification)
603 while needClassification: 603 while needClassification:
604 _mergeClassification(classification, _classifyGraalServices(needClassification, graalJars)) 604 _mergeClassification(classification, _classifyJVMCIServices(needClassification, jvmciJars))
605 needClassification = _extractMaybes(classification) 605 needClassification = _extractMaybes(classification)
606 filtered = [] 606 filtered = []
607 for className in classNames: 607 for className in classNames:
608 if classification[className] is True: 608 if classification[className] is True:
609 filtered.append(className) 609 filtered.append(className)
610 return filtered 610 return filtered
611 611
612 def _extractGraalFiles(graalJars, servicesDir, optionsDir, cleanDestination=True): 612 def _extractJVMCIFiles(jvmciJars, servicesDir, optionsDir, cleanDestination=True):
613 if cleanDestination: 613 if cleanDestination:
614 if exists(servicesDir): 614 if exists(servicesDir):
615 shutil.rmtree(servicesDir) 615 shutil.rmtree(servicesDir)
616 if exists(optionsDir): 616 if exists(optionsDir):
617 shutil.rmtree(optionsDir) 617 shutil.rmtree(optionsDir)
619 os.makedirs(servicesDir) 619 os.makedirs(servicesDir)
620 if not exists(optionsDir): 620 if not exists(optionsDir):
621 os.makedirs(optionsDir) 621 os.makedirs(optionsDir)
622 servicesMap = {} 622 servicesMap = {}
623 optionsFiles = [] 623 optionsFiles = []
624 for jar in graalJars: 624 for jar in jvmciJars:
625 if os.path.isfile(jar): 625 if os.path.isfile(jar):
626 with zipfile.ZipFile(jar) as zf: 626 with zipfile.ZipFile(jar) as zf:
627 for member in zf.namelist(): 627 for member in zf.namelist():
628 if member.startswith('META-INF/services'): 628 if member.startswith('META-INF/services'):
629 serviceName = basename(member) 629 serviceName = basename(member)
642 targetpath = join(optionsDir, filename) 642 targetpath = join(optionsDir, filename)
643 optionsFiles.append(filename) 643 optionsFiles.append(filename)
644 with zf.open(member) as optionsFile, \ 644 with zf.open(member) as optionsFile, \
645 file(targetpath, "wb") as target: 645 file(targetpath, "wb") as target:
646 shutil.copyfileobj(optionsFile, target) 646 shutil.copyfileobj(optionsFile, target)
647 graalServices = _filterGraalService(servicesMap.keys(), graalJars) 647 jvmciServices = _filterJVMCIService(servicesMap.keys(), jvmciJars)
648 for serviceName in graalServices: 648 for serviceName in jvmciServices:
649 serviceImpls = servicesMap[serviceName] 649 serviceImpls = servicesMap[serviceName]
650 fd, tmp = tempfile.mkstemp(prefix=serviceName) 650 fd, tmp = tempfile.mkstemp(prefix=serviceName)
651 f = os.fdopen(fd, 'w+') 651 f = os.fdopen(fd, 'w+')
652 for serviceImpl in serviceImpls: 652 for serviceImpl in serviceImpls:
653 f.write(serviceImpl + os.linesep) 653 f.write(serviceImpl + os.linesep)
654 target = join(servicesDir, serviceName) 654 target = join(servicesDir, serviceName)
655 f.close() 655 f.close()
656 shutil.move(tmp, target) 656 shutil.move(tmp, target)
657 if mx.get_os() != 'windows': 657 if mx.get_os() != 'windows':
658 os.chmod(target, JDK_UNIX_PERMISSIONS_FILE) 658 os.chmod(target, JDK_UNIX_PERMISSIONS_FILE)
659 return (graalServices, optionsFiles) 659 return (jvmciServices, optionsFiles)
660 660
661 def _updateGraalFiles(jdkDir): 661 def _updateJVMCIFiles(jdkDir):
662 jreGraalDir = join(jdkDir, 'jre', 'lib', 'graal') 662 jreJVMCIDir = join(jdkDir, 'jre', 'lib', 'jvmci')
663 graalJars = [join(jreGraalDir, e) for e in os.listdir(jreGraalDir) if e.startswith('graal') and e.endswith('.jar')] 663 graalJars = [join(jreJVMCIDir, e) for e in os.listdir(jreJVMCIDir) if e.startswith('graal') and e.endswith('.jar')]
664 jreGraalServicesDir = join(jreGraalDir, 'services') 664 jreGraalServicesDir = join(jreJVMCIDir, 'services')
665 jreGraalOptionsDir = join(jreGraalDir, 'options') 665 jreGraalOptionsDir = join(jreJVMCIDir, 'options')
666 _extractGraalFiles(graalJars, jreGraalServicesDir, jreGraalOptionsDir) 666 _extractJVMCIFiles(graalJars, jreGraalServicesDir, jreGraalOptionsDir)
667 667
668 668 def _patchGraalVersionConstant(dist):
669 """
670 Patches the constant "@@graal.version@@" in the constant pool of Graal.class
671 with the computed Graal version string.
672 """
673 zfOutFd, zfOutPath = tempfile.mkstemp(suffix='', prefix=basename(dist.path) + '.', dir=dirname(dist.path))
674 zfOut = zipfile.ZipFile(zfOutPath, 'w')
675 zf = zipfile.ZipFile(dist.path, 'r')
676 for zi in zf.infolist():
677 data = zf.read(zi)
678 if zi.filename == 'com/oracle/graal/api/runtime/Graal.class':
679 versionSpec = '{:' + str(len('@@graal.version@@')) + '}'
680 versionStr = versionSpec.format(graal_version())
681 assert '@@graal.version@@' in data, 'could not find "@@graal.version@@" constant in ' + dist.path + '!' + zi.filename
682 data = data.replace('@@graal.version@@', versionStr)
683 zfOut.writestr(zi, data)
684 zfOut.close()
685 os.close(zfOutFd)
686 zf.close()
687 shutil.move(zfOutPath, dist.path)
669 688
670 def _installDistInJdks(deployableDist): 689 def _installDistInJdks(deployableDist):
671 """ 690 """
672 Installs the jar(s) for a given Distribution into all existing Graal JDKs 691 Installs the jar(s) for a given Distribution into all existing JVMCI JDKs
673 """ 692 """
674 693
675 dist = mx.distribution(deployableDist.name) 694 dist = mx.distribution(deployableDist.name)
695 if dist.name == 'GRAAL':
696 _patchGraalVersionConstant(dist)
697
676 jdks = _jdksDir() 698 jdks = _jdksDir()
677 if exists(jdks): 699 if exists(jdks):
678 for e in os.listdir(jdks): 700 for e in os.listdir(jdks):
679 jdkDir = join(jdks, e) 701 jdkDir = join(jdks, e)
680 jreLibDir = join(jdkDir, 'jre', 'lib') 702 jreLibDir = join(jdkDir, 'jre', 'lib')
681 if exists(jreLibDir): 703 if exists(jreLibDir):
682 if deployableDist.isExtension: 704 if deployableDist.isExtension:
683 targetDir = join(jreLibDir, 'ext') 705 targetDir = join(jreLibDir, 'ext')
684 elif deployableDist.isGraalClassLoader: 706 elif deployableDist.usesJVMCIClassLoader:
685 targetDir = join(jreLibDir, 'graal') 707 targetDir = join(jreLibDir, 'jvmci')
686 else: 708 else:
687 targetDir = jreLibDir 709 targetDir = jreLibDir
688 if not exists(targetDir): 710 if not exists(targetDir):
689 os.makedirs(targetDir) 711 os.makedirs(targetDir)
690 _copyToJdk(dist.path, targetDir) 712 _copyToJdk(dist.path, targetDir)
691 if dist.sourcesPath: 713 if dist.sourcesPath:
692 _copyToJdk(dist.sourcesPath, jdkDir) 714 _copyToJdk(dist.sourcesPath, jdkDir)
693 if deployableDist.isGraalClassLoader: 715 if deployableDist.usesJVMCIClassLoader:
694 # deploy service files 716 # deploy service files
695 _updateGraalFiles(jdkDir) 717 _updateJVMCIFiles(jdkDir)
696 718
697 # run a command in the windows SDK Debug Shell 719 # run a command in the windows SDK Debug Shell
698 def _runInDebugShell(cmd, workingDir, logFile=None, findInOutput=None, respondTo=None): 720 def _runInDebugShell(cmd, workingDir, logFile=None, findInOutput=None, respondTo=None):
699 if respondTo is None: 721 if respondTo is None:
700 respondTo = {} 722 respondTo = {}
837 ' mx --vmbuild ' + firstBuildTarget + ' build') 859 ' mx --vmbuild ' + firstBuildTarget + ' build')
838 return result 860 return result
839 861
840 # Call mx.build to compile the Java sources 862 # Call mx.build to compile the Java sources
841 parser = AP() 863 parser = AP()
842 parser.add_argument('--export-dir', help='directory to which graal.jar and graal.options will be copied', metavar='<path>') 864 parser.add_argument('--export-dir', help='directory to which JVMCI and Graal jars and jvmci.options will be copied', metavar='<path>')
843 parser.add_argument('-D', action='append', help='set a HotSpot build variable (run \'mx buildvars\' to list variables)', metavar='name=value') 865 parser.add_argument('-D', action='append', help='set a HotSpot build variable (run \'mx buildvars\' to list variables)', metavar='name=value')
844 opts2 = mx.build(['--source', '1.7'] + args, parser=parser) 866 opts2 = mx.build(['--source', '1.7'] + args, parser=parser)
845 assert len(opts2.remainder) == 0 867 assert len(opts2.remainder) == 0
846 868
847 if opts2.export_dir is not None: 869 if opts2.export_dir is not None:
851 assert os.path.isdir(opts2.export_dir), '{0} is not a directory'.format(opts2.export_dir) 873 assert os.path.isdir(opts2.export_dir), '{0} is not a directory'.format(opts2.export_dir)
852 874
853 defsPath = join(_graal_home, 'make', 'defs.make') 875 defsPath = join(_graal_home, 'make', 'defs.make')
854 with open(defsPath) as fp: 876 with open(defsPath) as fp:
855 defs = fp.read() 877 defs = fp.read()
856 graalJars = [] 878 jvmciJars = []
857 for jdkDist in _jdkDeployedDists: 879 for jdkDist in _jdkDeployedDists:
858 dist = mx.distribution(jdkDist.name) 880 dist = mx.distribution(jdkDist.name)
859 defLine = 'EXPORT_LIST += $(EXPORT_JRE_LIB_DIR)/' + basename(dist.path) 881 defLine = 'EXPORT_LIST += $(EXPORT_JRE_LIB_DIR)/' + basename(dist.path)
860 if jdkDist.isExtension: 882 if jdkDist.isExtension:
861 defLine = 'EXPORT_LIST += $(EXPORT_JRE_LIB_EXT_DIR)/' + basename(dist.path) 883 defLine = 'EXPORT_LIST += $(EXPORT_JRE_LIB_EXT_DIR)/' + basename(dist.path)
862 elif jdkDist.isGraalClassLoader: 884 elif jdkDist.usesJVMCIClassLoader:
863 defLine = 'EXPORT_LIST += $(EXPORT_JRE_LIB_GRAAL_DIR)/' + basename(dist.path) 885 defLine = 'EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_DIR)/' + basename(dist.path)
864 graalJars.append(dist.path) 886 jvmciJars.append(dist.path)
865 else: 887 else:
866 defLine = 'EXPORT_LIST += $(EXPORT_JRE_LIB_DIR)/' + basename(dist.path) 888 defLine = 'EXPORT_LIST += $(EXPORT_JRE_LIB_DIR)/' + basename(dist.path)
867 if defLine not in defs: 889 if defLine not in defs:
868 mx.abort('Missing following line in ' + defsPath + '\n' + defLine) 890 mx.abort('Missing following line in ' + defsPath + '\n' + defLine)
869 shutil.copy(dist.path, opts2.export_dir) 891 shutil.copy(dist.path, opts2.export_dir)
870 services, optionsFiles = _extractGraalFiles(graalJars, join(opts2.export_dir, 'services'), join(opts2.export_dir, 'options')) 892 services, optionsFiles = _extractJVMCIFiles(jvmciJars, join(opts2.export_dir, 'services'), join(opts2.export_dir, 'options'))
871 for service in services: 893 for service in services:
872 defLine = 'EXPORT_LIST += $(EXPORT_JRE_LIB_GRAAL_SERVICES_DIR)/' + service 894 defLine = 'EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_SERVICES_DIR)/' + service
873 if defLine not in defs: 895 if defLine not in defs:
874 mx.abort('Missing following line in ' + defsPath + ' for service from ' + dist.name + '\n' + defLine) 896 mx.abort('Missing following line in ' + defsPath + ' for service from ' + dist.name + '\n' + defLine)
875 for optionsFile in optionsFiles: 897 for optionsFile in optionsFiles:
876 defLine = 'EXPORT_LIST += $(EXPORT_JRE_LIB_GRAAL_OPTIONS_DIR)/' + optionsFile 898 defLine = 'EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_OPTIONS_DIR)/' + optionsFile
877 if defLine not in defs: 899 if defLine not in defs:
878 mx.abort('Missing following line in ' + defsPath + ' for options from ' + dist.name + '\n' + defLine) 900 mx.abort('Missing following line in ' + defsPath + ' for options from ' + dist.name + '\n' + defLine)
879 graalOptions = join(_graal_home, 'graal.options') 901 jvmciOptions = join(_graal_home, 'jvmci.options')
880 if exists(graalOptions): 902 if exists(jvmciOptions):
881 shutil.copy(graalOptions, opts2.export_dir) 903 shutil.copy(jvmciOptions, opts2.export_dir)
882 904
883 if not _vmSourcesAvailable or not opts2.native: 905 if not _vmSourcesAvailable or not opts2.native:
884 return 906 return
885 907
886 builds = [_vmbuild] 908 builds = [_vmbuild]
902 elif vm.startswith('server'): 924 elif vm.startswith('server'):
903 buildSuffix = '' 925 buildSuffix = ''
904 elif vm.startswith('client'): 926 elif vm.startswith('client'):
905 buildSuffix = '1' 927 buildSuffix = '1'
906 else: 928 else:
907 assert vm == 'graal', vm 929 assert vm == 'jvmci', vm
908 buildSuffix = 'graal' 930 buildSuffix = 'jvmci'
909 931
910 if _installed_jdks and _installed_jdks != _graal_home: 932 if _installed_jdks and _installed_jdks != _graal_home:
911 if not mx.ask_yes_no("Warning: building while --installed-jdks is set (" + _installed_jdks + ") is not recommanded - are you sure you want to continue", 'n'): 933 if not mx.ask_yes_no("Warning: building while --installed-jdks is set (" + _installed_jdks + ") is not recommanded - are you sure you want to continue", 'n'):
912 mx.abort(1) 934 mx.abort(1)
913 935
941 mustBuild = True 963 mustBuild = True
942 else: 964 else:
943 mustBuild = False 965 mustBuild = False
944 timestamp = os.path.getmtime(timestampFile) 966 timestamp = os.path.getmtime(timestampFile)
945 sources = [] 967 sources = []
946 for d in ['src', 'make', join('graal', 'com.oracle.graal.hotspot', 'src_gen', 'hotspot')]: 968 for d in ['src', 'make', join('graal', 'com.oracle.jvmci.hotspot', 'src_gen', 'hotspot')]:
947 for root, dirnames, files in os.walk(join(_graal_home, d)): 969 for root, dirnames, files in os.walk(join(_graal_home, d)):
948 # ignore <graal>/src/share/tools 970 # ignore <graal>/src/share/tools
949 if root == join(_graal_home, 'src', 'share'): 971 if root == join(_graal_home, 'src', 'share'):
950 dirnames.remove('tools') 972 dirnames.remove('tools')
951 sources += [join(root, name) for name in files] 973 sources += [join(root, name) for name in files]
1002 setMakeVar('ARCH_DATA_MODEL', '64', env=env) 1024 setMakeVar('ARCH_DATA_MODEL', '64', env=env)
1003 setMakeVar('HOTSPOT_BUILD_JOBS', str(cpus), env=env) 1025 setMakeVar('HOTSPOT_BUILD_JOBS', str(cpus), env=env)
1004 setMakeVar('ALT_BOOTDIR', mx.java().jdk, env=env) 1026 setMakeVar('ALT_BOOTDIR', mx.java().jdk, env=env)
1005 1027
1006 setMakeVar('MAKE_VERBOSE', 'y' if mx._opts.verbose else '') 1028 setMakeVar('MAKE_VERBOSE', 'y' if mx._opts.verbose else '')
1007 if vm.endswith('nograal'): 1029 if vm.endswith('nojvmci'):
1008 setMakeVar('INCLUDE_GRAAL', 'false') 1030 setMakeVar('INCLUDE_JVMCI', 'false')
1009 setMakeVar('ALT_OUTPUTDIR', join(_graal_home, 'build-nograal', mx.get_os()), env=env) 1031 setMakeVar('ALT_OUTPUTDIR', join(_graal_home, 'build-nojvmci', mx.get_os()), env=env)
1010 else: 1032 else:
1011 version = graal_version() 1033 version = graal_version()
1012 setMakeVar('USER_RELEASE_SUFFIX', 'graal-' + version) 1034 setMakeVar('USER_RELEASE_SUFFIX', 'jvmci-' + version)
1013 setMakeVar('GRAAL_VERSION', version) 1035 setMakeVar('INCLUDE_JVMCI', 'true')
1014 setMakeVar('INCLUDE_GRAAL', 'true')
1015 setMakeVar('INSTALL', 'y', env=env) 1036 setMakeVar('INSTALL', 'y', env=env)
1016 if mx.get_os() == 'darwin' and platform.mac_ver()[0] != '': 1037 if mx.get_os() == 'darwin' and platform.mac_ver()[0] != '':
1017 # Force use of clang on MacOS 1038 # Force use of clang on MacOS
1018 setMakeVar('USE_CLANG', 'true') 1039 setMakeVar('USE_CLANG', 'true')
1019 if mx.get_os() == 'solaris': 1040 if mx.get_os() == 'solaris':
1101 elif _vm_cwd is not None and _vm_cwd != cwd: 1122 elif _vm_cwd is not None and _vm_cwd != cwd:
1102 mx.abort("conflicting working directories: do not set --vmcwd for this command") 1123 mx.abort("conflicting working directories: do not set --vmcwd for this command")
1103 1124
1104 build = vmbuild if vmbuild else _vmbuild if _vmSourcesAvailable else 'product' 1125 build = vmbuild if vmbuild else _vmbuild if _vmSourcesAvailable else 'product'
1105 jdk = _jdk(build, vmToCheck=vm, installJars=False) 1126 jdk = _jdk(build, vmToCheck=vm, installJars=False)
1106 _updateInstalledGraalOptionsFile(jdk) 1127 _updateInstalledJVMCIOptionsFile(jdk)
1107 mx.expand_project_in_args(args) 1128 mx.expand_project_in_args(args)
1108 if _make_eclipse_launch: 1129 if _make_eclipse_launch:
1109 mx.make_eclipse_launch(args, 'graal-' + build, name=None, deps=mx.project('com.oracle.graal.hotspot').all_deps([], True)) 1130 mx.make_eclipse_launch(args, 'graal-' + build, name=None, deps=mx.project('com.oracle.graal.hotspot').all_deps([], True))
1110 if _jacoco == 'on' or _jacoco == 'append': 1131 if _jacoco == 'on' or _jacoco == 'append':
1111 jacocoagent = mx.library("JACOCOAGENT", True) 1132 jacocoagent = mx.library("JACOCOAGENT", True)
1112 # Exclude all compiler tests and snippets 1133 # Exclude all compiler tests and snippets
1113 1134
1114 includes = ['com.oracle.graal.*'] 1135 includes = ['com.oracle.graal.*', 'com.oracle.jvmci.*']
1115 baseExcludes = [] 1136 baseExcludes = []
1116 for p in mx.projects(): 1137 for p in mx.projects():
1117 projsetting = getattr(p, 'jacoco', '') 1138 projsetting = getattr(p, 'jacoco', '')
1118 if projsetting == 'exclude': 1139 if projsetting == 'exclude':
1119 baseExcludes.append(p.name) 1140 baseExcludes.append(p.name)
1289 if gc_after_test: 1310 if gc_after_test:
1290 coreArgs.append('-JUnitGCAfterTest') 1311 coreArgs.append('-JUnitGCAfterTest')
1291 1312
1292 1313
1293 def harness(projectsCp, vmArgs): 1314 def harness(projectsCp, vmArgs):
1294 if _get_vm() != 'graal': 1315 if _get_vm() != 'jvmci':
1295 prefixArgs = ['-esa', '-ea'] 1316 prefixArgs = ['-esa', '-ea']
1296 else: 1317 else:
1297 prefixArgs = ['-XX:-BootstrapGraal', '-esa', '-ea'] 1318 prefixArgs = ['-XX:-BootstrapGraal', '-esa', '-ea']
1298 if gc_after_test: 1319 if gc_after_test:
1299 prefixArgs.append('-XX:-DisableExplicitGC') 1320 prefixArgs.append('-XX:-DisableExplicitGC')
1302 1323
1303 # Remove entries from class path that are in graal.jar and 1324 # Remove entries from class path that are in graal.jar and
1304 # run the VM in a mode where application/test classes can 1325 # run the VM in a mode where application/test classes can
1305 # access core Graal classes. 1326 # access core Graal classes.
1306 cp = prefixCp + coreCp + os.pathsep + projectsCp 1327 cp = prefixCp + coreCp + os.pathsep + projectsCp
1307 if isGraalEnabled(_get_vm()): 1328 if isJVMCIEnabled(_get_vm()):
1308 excluded = set() 1329 excluded = set()
1309 for jdkDist in _jdkDeployedDists: 1330 for jdkDist in _jdkDeployedDists:
1310 dist = mx.distribution(jdkDist.name) 1331 dist = mx.distribution(jdkDist.name)
1311 excluded.update([d.output_dir() for d in dist.sorted_deps()]) 1332 excluded.update([d.output_dir() for d in dist.sorted_deps()])
1312 cp = os.pathsep.join([e for e in cp.split(os.pathsep) if e not in excluded]) 1333 cp = os.pathsep.join([e for e in cp.split(os.pathsep) if e not in excluded])
1313 vmArgs = ['-XX:-UseGraalClassLoader'] + vmArgs 1334 vmArgs = ['-XX:-UseJVMCIClassLoader'] + vmArgs
1314 1335
1315 # suppress menubar and dock when running on Mac 1336 # suppress menubar and dock when running on Mac
1316 vmArgs = ['-Djava.awt.headless=true'] + vmArgs 1337 vmArgs = ['-Djava.awt.headless=true'] + vmArgs
1317 1338
1318 if len(testclasses) == 1: 1339 if len(testclasses) == 1:
1507 else: 1528 else:
1508 with VM(v, vmbuild): 1529 with VM(v, vmbuild):
1509 build(check_dists_args) 1530 build(check_dists_args)
1510 if not args.no_check: 1531 if not args.no_check:
1511 vmargs = ['-version'] 1532 vmargs = ['-version']
1512 if v == 'graal': 1533 if v == 'jvmci':
1513 vmargs.insert(0, '-XX:-BootstrapGraal') 1534 vmargs.insert(0, '-XX:-BootstrapJVMCI')
1514 vm(vmargs, vm=v, vmbuild=vmbuild) 1535 vm(vmargs, vm=v, vmbuild=vmbuild)
1515 allDuration = datetime.timedelta(seconds=time.time() - allStart) 1536 allDuration = datetime.timedelta(seconds=time.time() - allStart)
1516 mx.log('TOTAL TIME: ' + '[' + str(allDuration) + ']') 1537 mx.log('TOTAL TIME: ' + '[' + str(allDuration) + ']')
1517 1538
1518 class Task: 1539 class Task:
1555 """run CompileTheWorld""" 1576 """run CompileTheWorld"""
1556 1577
1557 defaultCtwopts = '-Inline' 1578 defaultCtwopts = '-Inline'
1558 1579
1559 parser = ArgumentParser(prog='mx ctw') 1580 parser = ArgumentParser(prog='mx ctw')
1560 parser.add_argument('--ctwopts', action='store', help='space separated Graal options used for CTW compilations (default: --ctwopts="' + defaultCtwopts + '")', default=defaultCtwopts, metavar='<options>') 1581 parser.add_argument('--ctwopts', action='store', help='space separated JVMCI options used for CTW compilations (default: --ctwopts="' + defaultCtwopts + '")', default=defaultCtwopts, metavar='<options>')
1561 parser.add_argument('--jar', action='store', help='jar of classes to compiled instead of rt.jar', metavar='<path>') 1582 parser.add_argument('--jar', action='store', help='jar of classes to compiled instead of rt.jar', metavar='<path>')
1562 1583
1563 args, vmargs = parser.parse_known_args(args) 1584 args, vmargs = parser.parse_known_args(args)
1564 1585
1565 if args.ctwopts: 1586 if args.ctwopts:
1571 jar = join(_jdk(installJars=False), 'jre', 'lib', 'rt.jar') 1592 jar = join(_jdk(installJars=False), 'jre', 'lib', 'rt.jar')
1572 vmargs.append('-G:CompileTheWorldExcludeMethodFilter=sun.awt.X11.*.*') 1593 vmargs.append('-G:CompileTheWorldExcludeMethodFilter=sun.awt.X11.*.*')
1573 1594
1574 vmargs += ['-XX:+CompileTheWorld'] 1595 vmargs += ['-XX:+CompileTheWorld']
1575 vm_ = _get_vm() 1596 vm_ = _get_vm()
1576 if isGraalEnabled(vm_): 1597 if isJVMCIEnabled(vm_):
1577 if vm_ == 'graal': 1598 if vm_ == 'jvmci':
1578 vmargs += ['-XX:+BootstrapGraal'] 1599 vmargs += ['-XX:+BootstrapJVMCI']
1579 vmargs += ['-G:CompileTheWorldClasspath=' + jar] 1600 vmargs += ['-G:CompileTheWorldClasspath=' + jar]
1580 else: 1601 else:
1581 vmargs += ['-Xbootclasspath/p:' + jar] 1602 vmargs += ['-Xbootclasspath/p:' + jar]
1582 1603
1583 # suppress menubar and dock when running on Mac; exclude x11 classes as they may cause vm crashes (on Solaris) 1604 # suppress menubar and dock when running on Mac; exclude x11 classes as they may cause vm crashes (on Solaris)
1584 vmargs = ['-Djava.awt.headless=true'] + vmargs 1605 vmargs = ['-Djava.awt.headless=true'] + vmargs
1585 1606
1586 vm(vmargs) 1607 vm(vmargs)
1587 1608
1588 def _basic_gate_body(args, tasks): 1609 def _basic_gate_body(args, tasks):
1589 # Build server-hosted-graal now so we can run the unit tests 1610 # Build server-hosted-jvmci now so we can run the unit tests
1590 with Task('BuildHotSpotGraalHosted: product', tasks) as t: 1611 with Task('BuildHotSpotJVMCIHosted: product', tasks) as t:
1591 if t: buildvms(['--vms', 'server', '--builds', 'product', '--check-distributions']) 1612 if t: buildvms(['--vms', 'server', '--builds', 'product', '--check-distributions'])
1592 1613
1593 # Run unit tests on server-hosted-graal 1614 # Run unit tests on server-hosted-jvmci
1594 with VM('server', 'product'): 1615 with VM('server', 'product'):
1595 with Task('UnitTests:hosted-product', tasks) as t: 1616 with Task('UnitTests:hosted-product', tasks) as t:
1596 if t: unittest(['--enable-timing', '--verbose', '--fail-fast']) 1617 if t: unittest(['--enable-timing', '--verbose', '--fail-fast'])
1597 1618
1598 # Run ctw against rt.jar on server-hosted-graal 1619 # Run ctw against rt.jar on server-hosted-jvmci
1599 with VM('server', 'product'): 1620 with VM('server', 'product'):
1600 with Task('CTW:hosted-product', tasks) as t: 1621 with Task('CTW:hosted-product', tasks) as t:
1601 if t: ctw(['--ctwopts', '-Inline +ExitVMOnException', '-esa', '-G:+CompileTheWorldMultiThreaded', '-G:-CompileTheWorldVerbose']) 1622 if t: ctw(['--ctwopts', '-Inline +ExitVMOnException', '-esa', '-G:+CompileTheWorldMultiThreaded', '-G:-CompileTheWorldVerbose'])
1602 1623
1603 # Build the other VM flavors 1624 # Build the other VM flavors
1604 with Task('BuildHotSpotGraalOthers: fastdebug,product', tasks) as t: 1625 with Task('BuildHotSpotGraalOthers: fastdebug,product', tasks) as t:
1605 if t: buildvms(['--vms', 'graal,server', '--builds', 'fastdebug,product', '--check-distributions']) 1626 if t: buildvms(['--vms', 'jvmci,server', '--builds', 'fastdebug,product', '--check-distributions'])
1606 1627
1607 with VM('graal', 'fastdebug'): 1628 with VM('jvmci', 'fastdebug'):
1608 with Task('BootstrapWithSystemAssertions:fastdebug', tasks) as t: 1629 with Task('BootstrapWithSystemAssertions:fastdebug', tasks) as t:
1609 if t: vm(['-esa', '-XX:-TieredCompilation', '-version']) 1630 if t: vm(['-esa', '-XX:-TieredCompilation', '-version'])
1610 1631
1611 with VM('graal', 'fastdebug'): 1632 with VM('jvmci', 'fastdebug'):
1612 with Task('BootstrapEconomyWithSystemAssertions:fastdebug', tasks) as t: 1633 with Task('BootstrapEconomyWithSystemAssertions:fastdebug', tasks) as t:
1613 if t: vm(['-esa', '-XX:-TieredCompilation', '-G:CompilerConfiguration=economy', '-version']) 1634 if t: vm(['-esa', '-XX:-TieredCompilation', '-G:CompilerConfiguration=economy', '-version'])
1614 1635
1615 with VM('graal', 'fastdebug'): 1636 with VM('jvmci', 'fastdebug'):
1616 with Task('BootstrapWithSystemAssertionsNoCoop:fastdebug', tasks) as t: 1637 with Task('BootstrapWithSystemAssertionsNoCoop:fastdebug', tasks) as t:
1617 if t: vm(['-esa', '-XX:-TieredCompilation', '-XX:-UseCompressedOops', '-version']) 1638 if t: vm(['-esa', '-XX:-TieredCompilation', '-XX:-UseCompressedOops', '-version'])
1618 1639
1619 with VM('graal', 'fastdebug'): 1640 with VM('jvmci', 'fastdebug'):
1620 with Task('BootstrapWithExceptionEdges:fastdebug', tasks) as t: 1641 with Task('BootstrapWithExceptionEdges:fastdebug', tasks) as t:
1621 if t: vm(['-esa', '-XX:-TieredCompilation', '-G:+StressInvokeWithExceptionNode', '-version']) 1642 if t: vm(['-esa', '-XX:-TieredCompilation', '-G:+StressInvokeWithExceptionNode', '-version'])
1622 1643
1623 with VM('graal', 'product'): 1644 with VM('jvmci', 'product'):
1624 with Task('BootstrapWithGCVerification:product', tasks) as t: 1645 with Task('BootstrapWithGCVerification:product', tasks) as t:
1625 if t: 1646 if t:
1626 out = mx.DuplicateSuppressingStream(['VerifyAfterGC:', 'VerifyBeforeGC:']).write 1647 out = mx.DuplicateSuppressingStream(['VerifyAfterGC:', 'VerifyBeforeGC:']).write
1627 vm(['-XX:-TieredCompilation', '-XX:+UnlockDiagnosticVMOptions', '-XX:+VerifyBeforeGC', '-XX:+VerifyAfterGC', '-version'], out=out) 1648 vm(['-XX:-TieredCompilation', '-XX:+UnlockDiagnosticVMOptions', '-XX:+VerifyBeforeGC', '-XX:+VerifyAfterGC', '-version'], out=out)
1628 1649
1629 with VM('graal', 'product'): 1650 with VM('jvmci', 'product'):
1630 with Task('BootstrapWithG1GCVerification:product', tasks) as t: 1651 with Task('BootstrapWithG1GCVerification:product', tasks) as t:
1631 if t: 1652 if t:
1632 out = mx.DuplicateSuppressingStream(['VerifyAfterGC:', 'VerifyBeforeGC:']).write 1653 out = mx.DuplicateSuppressingStream(['VerifyAfterGC:', 'VerifyBeforeGC:']).write
1633 vm(['-XX:-TieredCompilation', '-XX:+UnlockDiagnosticVMOptions', '-XX:-UseSerialGC', '-XX:+UseG1GC', '-XX:+VerifyBeforeGC', '-XX:+VerifyAfterGC', '-version'], out=out) 1654 vm(['-XX:-TieredCompilation', '-XX:+UnlockDiagnosticVMOptions', '-XX:-UseSerialGC', '-XX:+UseG1GC', '-XX:+VerifyBeforeGC', '-XX:+VerifyAfterGC', '-version'], out=out)
1634 1655
1635 with VM('graal', 'product'): 1656 with VM('jvmci', 'product'):
1636 with Task('BootstrapWithRegisterPressure:product', tasks) as t: 1657 with Task('BootstrapWithRegisterPressure:product', tasks) as t:
1637 if t: 1658 if t:
1638 registers = 'o0,o1,o2,o3,f8,f9,d32,d34' if platform.processor() == 'sparc' else 'rbx,r11,r10,r14,xmm3,xmm11,xmm14' 1659 registers = 'o0,o1,o2,o3,f8,f9,d32,d34' if platform.processor() == 'sparc' else 'rbx,r11,r10,r14,xmm3,xmm11,xmm14'
1639 vm(['-XX:-TieredCompilation', '-G:RegisterPressure=' + registers, '-esa', '-version']) 1660 vm(['-XX:-TieredCompilation', '-G:RegisterPressure=' + registers, '-esa', '-version'])
1640 1661
1641 with VM('graal', 'product'): 1662 with VM('jvmci', 'product'):
1642 with Task('BootstrapSSAWithRegisterPressure:product', tasks) as t: 1663 with Task('BootstrapSSAWithRegisterPressure:product', tasks) as t:
1643 if t: 1664 if t:
1644 registers = 'o0,o1,o2,o3,f8,f9,d32,d34' if platform.processor() == 'sparc' else 'rbx,r11,r10,r14,xmm3,xmm11,xmm14' 1665 registers = 'o0,o1,o2,o3,f8,f9,d32,d34' if platform.processor() == 'sparc' else 'rbx,r11,r10,r14,xmm3,xmm11,xmm14'
1645 vm(['-XX:-TieredCompilation', '-G:+SSA_LIR', '-G:RegisterPressure=' + registers, '-esa', '-version']) 1666 vm(['-XX:-TieredCompilation', '-G:+SSA_LIR', '-G:RegisterPressure=' + registers, '-esa', '-version'])
1646 1667
1647 with VM('graal', 'product'): 1668 with VM('jvmci', 'product'):
1648 with Task('BootstrapWithImmutableCode:product', tasks) as t: 1669 with Task('BootstrapWithImmutableCode:product', tasks) as t:
1649 if t: vm(['-XX:-TieredCompilation', '-G:+ImmutableCode', '-G:+VerifyPhases', '-esa', '-version']) 1670 if t: vm(['-XX:-TieredCompilation', '-G:+ImmutableCode', '-G:+VerifyPhases', '-esa', '-version'])
1650 1671
1651 for vmbuild in ['fastdebug', 'product']: 1672 for vmbuild in ['fastdebug', 'product']:
1652 for test in sanitycheck.getDacapos(level=sanitycheck.SanityCheckLevel.Gate, gateBuildLevel=vmbuild) + sanitycheck.getScalaDacapos(level=sanitycheck.SanityCheckLevel.Gate, gateBuildLevel=vmbuild): 1673 for test in sanitycheck.getDacapos(level=sanitycheck.SanityCheckLevel.Gate, gateBuildLevel=vmbuild) + sanitycheck.getScalaDacapos(level=sanitycheck.SanityCheckLevel.Gate, gateBuildLevel=vmbuild):
1653 with Task(str(test) + ':' + vmbuild, tasks) as t: 1674 with Task(str(test) + ':' + vmbuild, tasks) as t:
1654 if t and not test.test('graal'): 1675 if t and not test.test('jvmci'):
1655 t.abort(test.name + ' Failed') 1676 t.abort(test.name + ' Failed')
1656 1677
1657 # ensure -Xbatch still works 1678 # ensure -Xbatch still works
1658 with VM('graal', 'product'): 1679 with VM('jvmci', 'product'):
1659 with Task('DaCapo_pmd:BatchMode:product', tasks) as t: 1680 with Task('DaCapo_pmd:BatchMode:product', tasks) as t:
1660 if t: dacapo(['-Xbatch', 'pmd']) 1681 if t: dacapo(['-Xbatch', 'pmd'])
1661 1682
1662 # ensure -Xcomp still works 1683 # ensure -Xcomp still works
1663 with VM('graal', 'product'): 1684 with VM('jvmci', 'product'):
1664 with Task('XCompMode:product', tasks) as t: 1685 with Task('XCompMode:product', tasks) as t:
1665 if t: vm(['-Xcomp', '-version']) 1686 if t: vm(['-Xcomp', '-version'])
1666 1687
1667 if args.jacocout is not None: 1688 if args.jacocout is not None:
1668 jacocoreport([args.jacocout]) 1689 jacocoreport([args.jacocout])
1673 with Task('CleanAndBuildIdealGraphVisualizer', tasks) as t: 1694 with Task('CleanAndBuildIdealGraphVisualizer', tasks) as t:
1674 if t and platform.processor() != 'sparc': 1695 if t and platform.processor() != 'sparc':
1675 buildxml = mx._cygpathU2W(join(_graal_home, 'src', 'share', 'tools', 'IdealGraphVisualizer', 'build.xml')) 1696 buildxml = mx._cygpathU2W(join(_graal_home, 'src', 'share', 'tools', 'IdealGraphVisualizer', 'build.xml'))
1676 mx.run(['ant', '-f', buildxml, '-q', 'clean', 'build'], env=_igvBuildEnv()) 1697 mx.run(['ant', '-f', buildxml, '-q', 'clean', 'build'], env=_igvBuildEnv())
1677 1698
1678 # Prevent Graal modifications from breaking the standard builds 1699 # Prevent JVMCI modifications from breaking the standard builds
1679 if args.buildNonGraal: 1700 if args.buildNonJVMCI:
1680 with Task('BuildHotSpotVarieties', tasks) as t: 1701 with Task('BuildHotSpotVarieties', tasks) as t:
1681 if t: 1702 if t:
1682 buildvms(['--vms', 'client,server', '--builds', 'fastdebug,product']) 1703 buildvms(['--vms', 'client,server', '--builds', 'fastdebug,product'])
1683 if mx.get_os() not in ['windows', 'cygwin']: 1704 if mx.get_os() not in ['windows', 'cygwin']:
1684 buildvms(['--vms', 'server-nograal', '--builds', 'product,optimized']) 1705 buildvms(['--vms', 'server-nojvmci', '--builds', 'product,optimized'])
1685 1706
1686 for vmbuild in ['product', 'fastdebug']: 1707 for vmbuild in ['product', 'fastdebug']:
1687 for theVm in ['client', 'server']: 1708 for theVm in ['client', 'server']:
1688 if not isVMSupported(theVm): 1709 if not isVMSupported(theVm):
1689 mx.log('The ' + theVm + ' VM is not supported on this platform') 1710 mx.log('The ' + theVm + ' VM is not supported on this platform')
1691 with VM(theVm, vmbuild): 1712 with VM(theVm, vmbuild):
1692 with Task('DaCapo_pmd:' + theVm + ':' + vmbuild, tasks) as t: 1713 with Task('DaCapo_pmd:' + theVm + ':' + vmbuild, tasks) as t:
1693 if t: dacapo(['pmd']) 1714 if t: dacapo(['pmd'])
1694 1715
1695 with Task('UnitTests:' + theVm + ':' + vmbuild, tasks) as t: 1716 with Task('UnitTests:' + theVm + ':' + vmbuild, tasks) as t:
1696 if t: unittest(['-XX:CompileCommand=exclude,*::run*', 'graal.api']) 1717 if t: unittest(['-XX:CompileCommand=exclude,*::run*', 'graal.api', 'java.test'])
1697 1718
1698 1719
1699 def gate(args, gate_body=_basic_gate_body): 1720 def gate(args, gate_body=_basic_gate_body):
1700 """run the tests used to validate a push 1721 """run the tests used to validate a push
1701 1722
1704 1725
1705 parser = ArgumentParser(prog='mx gate') 1726 parser = ArgumentParser(prog='mx gate')
1706 parser.add_argument('-j', '--omit-java-clean', action='store_false', dest='cleanJava', help='omit cleaning Java native code') 1727 parser.add_argument('-j', '--omit-java-clean', action='store_false', dest='cleanJava', help='omit cleaning Java native code')
1707 parser.add_argument('-n', '--omit-native-clean', action='store_false', dest='cleanNative', help='omit cleaning and building native code') 1728 parser.add_argument('-n', '--omit-native-clean', action='store_false', dest='cleanNative', help='omit cleaning and building native code')
1708 parser.add_argument('-i', '--omit-ide-clean', action='store_false', dest='cleanIde', help='omit cleaning the ide project files') 1729 parser.add_argument('-i', '--omit-ide-clean', action='store_false', dest='cleanIde', help='omit cleaning the ide project files')
1709 parser.add_argument('-g', '--only-build-graalvm', action='store_false', dest='buildNonGraal', help='only build the Graal VM') 1730 parser.add_argument('-g', '--only-build-jvmci', action='store_false', dest='buildNonJVMCI', help='only build the JVMCI VM')
1710 parser.add_argument('-t', '--task-filter', help='comma separated list of substrings to select subset of tasks to be run') 1731 parser.add_argument('-t', '--task-filter', help='comma separated list of substrings to select subset of tasks to be run')
1711 parser.add_argument('--jacocout', help='specify the output directory for jacoco report') 1732 parser.add_argument('--jacocout', help='specify the output directory for jacoco report')
1712 1733
1713 args = parser.parse_args(args) 1734 args = parser.parse_args(args)
1714 1735
1804 1825
1805 if args.task_filter: 1826 if args.task_filter:
1806 Task.filters = None 1827 Task.filters = None
1807 1828
1808 def deoptalot(args): 1829 def deoptalot(args):
1809 """bootstrap a fastdebug Graal VM with DeoptimizeALot and VerifyOops on 1830 """bootstrap a fastdebug JVMCI VM with DeoptimizeALot and VerifyOops on
1810 1831
1811 If the first argument is a number, the process will be repeated 1832 If the first argument is a number, the process will be repeated
1812 this number of times. All other arguments are passed to the VM.""" 1833 this number of times. All other arguments are passed to the VM."""
1813 count = 1 1834 count = 1
1814 if len(args) > 0 and args[0].isdigit(): 1835 if len(args) > 0 and args[0].isdigit():
2102 mx.log(x[:-1]) 2123 mx.log(x[:-1])
2103 else: 2124 else:
2104 buildOutput.append(x) 2125 buildOutput.append(x)
2105 env = os.environ.copy() 2126 env = os.environ.copy()
2106 env['JAVA_HOME'] = _jdk(vmToCheck='server') 2127 env['JAVA_HOME'] = _jdk(vmToCheck='server')
2107 env['MAVEN_OPTS'] = '-server -XX:-UseGraalClassLoader' 2128 env['MAVEN_OPTS'] = '-server -XX:-UseJVMCIClassLoader'
2108 mx.log("Building benchmarks...") 2129 mx.log("Building benchmarks...")
2109 cmd = ['mvn'] 2130 cmd = ['mvn']
2110 if args.settings: 2131 if args.settings:
2111 cmd = cmd + ['-s', args.settings] 2132 cmd = cmd + ['-s', args.settings]
2112 if args.clean: 2133 if args.clean:
2128 if '-h' in args: 2149 if '-h' in args:
2129 mx.help_(['jmh']) 2150 mx.help_(['jmh'])
2130 mx.abort(1) 2151 mx.abort(1)
2131 2152
2132 vmArgs, benchmarksAndJsons = _extract_VM_args(args) 2153 vmArgs, benchmarksAndJsons = _extract_VM_args(args)
2133 if isGraalEnabled(_get_vm()) and '-XX:-UseGraalClassLoader' not in vmArgs: 2154 if isJVMCIEnabled(_get_vm()) and '-XX:-UseJVMCIClassLoader' not in vmArgs:
2134 vmArgs = ['-XX:-UseGraalClassLoader'] + vmArgs 2155 vmArgs = ['-XX:-UseJVMCIClassLoader'] + vmArgs
2135 2156
2136 benchmarks = [b for b in benchmarksAndJsons if not b.startswith('{')] 2157 benchmarks = [b for b in benchmarksAndJsons if not b.startswith('{')]
2137 jmhArgJsons = [b for b in benchmarksAndJsons if b.startswith('{')] 2158 jmhArgJsons = [b for b in benchmarksAndJsons if b.startswith('{')]
2138 jmhOutDir = join(_graal_home, 'mx', 'jmh') 2159 jmhOutDir = join(_graal_home, 'mx', 'jmh')
2139 if not exists(jmhOutDir): 2160 if not exists(jmhOutDir):
2333 if len(args) == 1: 2354 if len(args) == 1:
2334 out = args[0] 2355 out = args[0]
2335 elif len(args) > 1: 2356 elif len(args) > 1:
2336 mx.abort('jacocoreport takes only one argument : an output directory') 2357 mx.abort('jacocoreport takes only one argument : an output directory')
2337 2358
2338 includes = ['com.oracle.graal'] 2359 includes = ['com.oracle.graal', 'com.oracle.jvmci']
2339 for p in mx.projects(): 2360 for p in mx.projects():
2340 projsetting = getattr(p, 'jacoco', '') 2361 projsetting = getattr(p, 'jacoco', '')
2341 if projsetting == 'include': 2362 if projsetting == 'include':
2342 includes.append(p.name) 2363 includes.append(p.name)
2343 2364
2365 def sldebug(args): 2386 def sldebug(args):
2366 """run a simple command line debugger for the Simple Language""" 2387 """run a simple command line debugger for the Simple Language"""
2367 vmArgs, slArgs = _extract_VM_args(args, useDoubleDash=True) 2388 vmArgs, slArgs = _extract_VM_args(args, useDoubleDash=True)
2368 vm(vmArgs + ['-cp', mx.classpath("com.oracle.truffle.sl.tools"), "com.oracle.truffle.sl.tools.debug.SLREPLServer"] + slArgs) 2389 vm(vmArgs + ['-cp', mx.classpath("com.oracle.truffle.sl.tools"), "com.oracle.truffle.sl.tools.debug.SLREPLServer"] + slArgs)
2369 2390
2370 def isGraalEnabled(vm): 2391 def isJVMCIEnabled(vm):
2371 return vm != 'original' and not vm.endswith('nograal') 2392 return vm != 'original' and not vm.endswith('nojvmci')
2372 2393
2373 def jol(args): 2394 def jol(args):
2374 """Java Object Layout""" 2395 """Java Object Layout"""
2375 joljar = mx.library('JOL_INTERNALS').get_path(resolve=True) 2396 joljar = mx.library('JOL_INTERNALS').get_path(resolve=True)
2376 candidates = mx.findclass(args, logToConsole=False, matcher=lambda s, classname: s == classname or classname.endswith('.' + s) or classname.endswith('$' + s)) 2397 candidates = mx.findclass(args, logToConsole=False, matcher=lambda s, classname: s == classname or classname.endswith('.' + s) or classname.endswith('$' + s))
2435 # TODO: improve matcher: if mx args are given, this doesn't work 2456 # TODO: improve matcher: if mx args are given, this doesn't work
2436 complt += '\t\tcase $line[1] in\n' 2457 complt += '\t\tcase $line[1] in\n'
2437 complt += '\t\t\t(vm | vmg | vmfg | unittest | jmh | dacapo | scaladacapo | specjvm2008 | specjbb2013 | specjbb2005)\n' 2458 complt += '\t\t\t(vm | vmg | vmfg | unittest | jmh | dacapo | scaladacapo | specjvm2008 | specjbb2013 | specjbb2005)\n'
2438 complt += '\t\t\t\tnoglob \\\n' 2459 complt += '\t\t\t\tnoglob \\\n'
2439 complt += '\t\t\t\t\t_arguments -s -S \\\n' 2460 complt += '\t\t\t\t\t_arguments -s -S \\\n'
2440 complt += _appendOptions("graal", r"G\:") 2461 complt += _appendOptions("jvmci", r"G\:")
2441 # TODO: fix -XX:{-,+}Use* flags 2462 # TODO: fix -XX:{-,+}Use* flags
2442 complt += _appendOptions("hotspot", r"XX\:") 2463 complt += _appendOptions("hotspot", r"XX\:")
2443 complt += '\t\t\t\t\t"-version" && ret=0 \n' 2464 complt += '\t\t\t\t\t"-version" && ret=0 \n'
2444 complt += '\t\t\t\t;;\n' 2465 complt += '\t\t\t\t;;\n'
2445 complt += '\t\tesac\n' 2466 complt += '\t\tesac\n'
2497 'optName' : '<optName>', 2518 'optName' : '<optName>',
2498 'optDefault' : '<optDefault>', 2519 'optDefault' : '<optDefault>',
2499 'optDoc' : '<optDoc>', 2520 'optDoc' : '<optDoc>',
2500 })) 2521 }))
2501 2522
2502 # gather graal options 2523 # gather JVMCI options
2503 output = StringIO.StringIO() 2524 output = StringIO.StringIO()
2504 vm(['-XX:-BootstrapGraal', '-XX:+UnlockDiagnosticVMOptions', '-G:+PrintFlags' if optionType == "graal" else '-XX:+PrintFlagsWithComments'], 2525 vm(['-XX:-BootstrapJVMCI', '-XX:+UnlockDiagnosticVMOptions', '-G:+PrintFlags' if optionType == "jvmci" else '-XX:+PrintFlagsWithComments'],
2505 vm="graal", 2526 vm="jvmci",
2506 vmbuild="optimized", 2527 vmbuild="optimized",
2507 nonZeroIsFatal=False, 2528 nonZeroIsFatal=False,
2508 out=output.write, 2529 out=output.write,
2509 err=subprocess.STDOUT) 2530 err=subprocess.STDOUT)
2510 2531