Mercurial > hg > graal-jvmci-8
comparison mx.jvmci/mx_jvmci.py @ 22493:63b12d69147d
added JVMCI JDK factory; clarified distinction between VM aliases and real VMs; removed left-over "graal" references; rename 'vm' function to 'run_vm'
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 31 Aug 2015 17:26:06 +0200 |
parents | f22fd96605ee |
children | df5a7841f92a |
comparison
equal
deleted
inserted
replaced
22492:f22fd96605ee | 22493:63b12d69147d |
---|---|
46 'server' : 'Normal compilation is performed with a tiered system (C1 + C2) and Graal is available for hosted compilation.', | 46 'server' : 'Normal compilation is performed with a tiered system (C1 + C2) and Graal is available for hosted compilation.', |
47 'client' : None, # VM compilation with client compiler, hosted compilation with Graal | 47 'client' : None, # VM compilation with client compiler, hosted compilation with Graal |
48 'server-nojvmci' : None, # all compilation with tiered system (i.e., client + server), JVMCI omitted | 48 'server-nojvmci' : None, # all compilation with tiered system (i.e., client + server), JVMCI omitted |
49 'client-nojvmci' : None, # all compilation with client compiler, JVMCI omitted | 49 'client-nojvmci' : None, # all compilation with client compiler, JVMCI omitted |
50 'original' : None, # default VM copied from bootstrap JDK | 50 'original' : None, # default VM copied from bootstrap JDK |
51 'graal' : None, # alias for jvmci | |
52 'server-nograal' : None, # alias for server-nojvmci | |
53 'client-nograal' : None, # alias for client-nojvmci | |
54 } | 51 } |
52 | |
53 # Aliases for legacy VM names | |
54 _vmAliases = { | |
55 'graal' : 'jvmci', | |
56 'server-nograal' : 'server-nojvmci', | |
57 'client-nograal' : 'client-nograal', | |
58 } | |
59 | |
60 _JVMCI_JDK_TAG = 'jvmci' | |
55 | 61 |
56 """ The VM that will be run by the 'vm' command and built by default by the 'build' command. | 62 """ The VM that will be run by the 'vm' command and built by default by the 'build' command. |
57 This can be set via the global '--vm' option or the DEFAULT_VM environment variable. | 63 This can be set via the global '--vm' option or the DEFAULT_VM environment variable. |
58 It can also be temporarily set by using of a VM context manager object in a 'with' statement. """ | 64 It can also be temporarily set by using of a VM context manager object in a 'with' statement. """ |
59 _vm = None | 65 _vm = None |
158 def dist(self): | 164 def dist(self): |
159 name = mx.instantiatedDistributionName(self._name, dict(vm=get_vm(), vmbuild=_vmbuild), context=self._name) | 165 name = mx.instantiatedDistributionName(self._name, dict(vm=get_vm(), vmbuild=_vmbuild), context=self._name) |
160 return mx.distribution(name) | 166 return mx.distribution(name) |
161 | 167 |
162 def deploy(self, jdkDir): | 168 def deploy(self, jdkDir): |
169 vmbuild = _vmbuildFromJdkDir(jdkDir) | |
170 if vmbuild != _vmbuild: | |
171 return | |
163 _hs_deploy_map = { | 172 _hs_deploy_map = { |
164 'jvmti.h' : 'include', | 173 'jvmti.h' : 'include', |
165 'sa-jdi.jar' : 'lib', | 174 'sa-jdi.jar' : 'lib', |
166 _lib('jvm') : join(relativeVmLibDirInJdk(), get_vm()), | 175 _lib('jvm') : join(relativeVmLibDirInJdk(), get_vm()), |
167 _lib_dbg('jvm') : join(relativeVmLibDirInJdk(), get_vm()), | 176 _lib_dbg('jvm') : join(relativeVmLibDirInJdk(), get_vm()), |
176 if m.name in _hs_deploy_map: | 185 if m.name in _hs_deploy_map: |
177 targetDir = join(jdkDir, _hs_deploy_map[m.name]) | 186 targetDir = join(jdkDir, _hs_deploy_map[m.name]) |
178 mx.logv('Deploying {} from {} to {}'.format(m.name, dist.name, targetDir)) | 187 mx.logv('Deploying {} from {} to {}'.format(m.name, dist.name, targetDir)) |
179 tar.extract(m, targetDir) | 188 tar.extract(m, targetDir) |
180 updateJvmCfg(jdkDir, get_vm()) | 189 updateJvmCfg(jdkDir, get_vm()) |
190 | |
181 """ | 191 """ |
182 List of distributions that are deployed into a JDK by mx. | 192 List of distributions that are deployed into a JDK by mx. |
183 """ | 193 """ |
184 jdkDeployedDists = [ | 194 jdkDeployedDists = [ |
185 LibJDKDeployedDist('JVMCI_SERVICE', partOfHotSpot=True), | 195 LibJDKDeployedDist('JVMCI_SERVICE', partOfHotSpot=True), |
210 """ | 220 """ |
211 Get the base directory in which the JDKs cloned from $JAVA_HOME exist. | 221 Get the base directory in which the JDKs cloned from $JAVA_HOME exist. |
212 """ | 222 """ |
213 return _installed_jdks | 223 return _installed_jdks |
214 | 224 |
215 def get_vm_prefix(): | 225 def get_vm_prefix(asList=True): |
216 """ | 226 """ |
217 Get the prefix for running the VM ("/usr/bin/gdb --args"). | 227 Get the prefix for running the VM ("/usr/bin/gdb --args"). |
218 """ | 228 """ |
229 if asList: | |
230 return _vm_prefix.split() if _vm_prefix is not None else [] | |
219 return _vm_prefix | 231 return _vm_prefix |
220 | 232 |
221 def get_vm_choices(): | 233 def get_vm_choices(): |
222 return _vmChoices | 234 """ |
235 Get the names of available VMs. | |
236 """ | |
237 return _vmChoices.viewkeys() | |
238 | |
239 def dealiased_vm(vm): | |
240 """ | |
241 If 'vm' is an alias, returns the aliased name otherwise returns 'vm'. | |
242 """ | |
243 if vm and vm in _vmAliases: | |
244 return _vmAliases[vm] | |
245 return vm | |
223 | 246 |
224 def get_vm(): | 247 def get_vm(): |
225 """ | 248 """ |
226 Gets the configured VM, presenting a dialogue if there is no currently configured VM. | 249 Gets the configured VM, presenting a dialogue if there is no currently configured VM. |
227 """ | 250 """ |
228 global _vm | 251 global _vm |
229 if _vm: | 252 if _vm: |
230 return _vm | 253 return _vm |
231 vm = mx.get_env('DEFAULT_VM') | 254 vm = mx.get_env('DEFAULT_VM') |
232 envPath = join(_suite.mxDir, 'env') | 255 envPath = join(_suite.mxDir, 'env') |
233 if vm and 'graal' in vm: | 256 if vm and vm in _vmAliases: |
234 if exists(envPath): | 257 if exists(envPath): |
235 with open(envPath) as fp: | 258 with open(envPath) as fp: |
236 if 'DEFAULT_VM=' + vm in fp.read(): | 259 if 'DEFAULT_VM=' + vm in fp.read(): |
237 mx.log('Please update the DEFAULT_VM value in ' + envPath + ' to replace "graal" with "jvmci"') | 260 mx.log('Please update the DEFAULT_VM value in ' + envPath + ' to replace "' + vm + '" with "' + _vmAliases[vm] + '"') |
238 vm = vm.replace('graal', 'jvmci') | 261 vm = _vmAliases[vm] |
239 if vm is None: | 262 if vm is None: |
240 if not mx.is_interactive(): | 263 if not mx.is_interactive(): |
241 mx.abort('Need to specify VM with --vm option or DEFAULT_VM environment variable') | 264 mx.abort('Need to specify VM with --vm option or DEFAULT_VM environment variable') |
242 mx.log('Please select the VM to be executed from the following: ') | 265 mx.log('Please select the VM to be executed from the following: ') |
243 items = [k for k in _vmChoices.keys() if _vmChoices[k] is not None] | 266 items = [k for k in _vmChoices.keys() if _vmChoices[k] is not None] |
297 hgcfg = mx.HgConfig() | 320 hgcfg = mx.HgConfig() |
298 hgcfg.check() | 321 hgcfg.check() |
299 infos['revision'] = hgcfg.tip('.') + ('+' if hgcfg.isDirty('.') else '') | 322 infos['revision'] = hgcfg.tip('.') + ('+' if hgcfg.isDirty('.') else '') |
300 # TODO: infos['repository'] | 323 # TODO: infos['repository'] |
301 | 324 |
302 infos['jdkversion'] = str(mx.get_jdk().version) | 325 infos['jdkversion'] = str(get_jvmci_bootstrap_jdk().version) |
303 | 326 |
304 infos['architecture'] = mx.get_arch() | 327 infos['architecture'] = mx.get_arch() |
305 infos['platform'] = mx.get_os() | 328 infos['platform'] = mx.get_os() |
306 | 329 |
307 if mx.get_os != 'windows': | 330 if mx.get_os != 'windows': |
321 with open(jsonFileName, 'w') as f: | 344 with open(jsonFileName, 'w') as f: |
322 print >> f, json.dumps(d) | 345 print >> f, json.dumps(d) |
323 return jsonFileName | 346 return jsonFileName |
324 | 347 |
325 | 348 |
326 def _genFileName(archivtype, middle): | 349 def _genFileName(archivetype, middle): |
327 idPrefix = infos['revision'] + '_' | 350 idPrefix = infos['revision'] + '_' |
328 idSuffix = '.tar.gz' | 351 idSuffix = '.tar.gz' |
329 return join(_suite.dir, "graalvm_" + archivtype + "_" + idPrefix + middle + idSuffix) | 352 return join(_suite.dir, "graalvm_" + archivetype + "_" + idPrefix + middle + idSuffix) |
330 | 353 |
331 def _genFileArchPlatformName(archivtype, middle): | 354 def _genFileArchPlatformName(archivetype, middle): |
332 return _genFileName(archivtype, infos['platform'] + '_' + infos['architecture'] + '_' + middle) | 355 return _genFileName(archivetype, infos['platform'] + '_' + infos['architecture'] + '_' + middle) |
333 | 356 |
334 | 357 |
335 # archive different build types of hotspot | 358 # archive different build types of hotspot |
336 for vmBuild in _vmbuildChoices: | 359 for vmBuild in _vmbuildChoices: |
337 jdkDir = join(_jdksDir(), vmBuild) | 360 jdkDir = join(_jdksDir(), vmBuild) |
437 if mxos == "windows" or mxos == "cygwin": | 460 if mxos == "windows" or mxos == "cygwin": |
438 return join(jdkDir, 'jre', 'lib', mx.get_arch(), jvmCfgFile) | 461 return join(jdkDir, 'jre', 'lib', mx.get_arch(), jvmCfgFile) |
439 return join(vmLibDirInJdk(jdkDir), jvmCfgFile) | 462 return join(vmLibDirInJdk(jdkDir), jvmCfgFile) |
440 | 463 |
441 def _jdksDir(): | 464 def _jdksDir(): |
442 return os.path.abspath(join(_installed_jdks if _installed_jdks else _suite.dir, 'jdk' + str(mx.get_jdk().version))) | 465 return os.path.abspath(join(_installed_jdks if _installed_jdks else _suite.dir, 'jdk' + str(get_jvmci_bootstrap_jdk().version))) |
443 | 466 |
444 def _handle_missing_VM(bld, vm=None): | 467 def _handle_missing_VM(bld, vm=None): |
445 if not vm: | 468 if not vm: |
446 vm = get_vm() | 469 vm = get_vm() |
447 mx.log('The ' + bld + ' ' + vm + ' VM has not been created') | 470 mx.log('The ' + bld + ' ' + vm + ' VM has not been created') |
450 with VM(vm, bld): | 473 with VM(vm, bld): |
451 build([]) | 474 build([]) |
452 return | 475 return |
453 mx.abort('You need to run "mx --vm ' + vm + ' --vmbuild ' + bld + ' build" to build the selected VM') | 476 mx.abort('You need to run "mx --vm ' + vm + ' --vmbuild ' + bld + ' build" to build the selected VM') |
454 | 477 |
478 def check_VM_exists(vm, jdkDir, build=None): | |
479 if not build: | |
480 build = _vmbuild | |
481 jvmCfg = getVmCfgInJdk(jdkDir) | |
482 found = False | |
483 with open(jvmCfg) as f: | |
484 for line in f: | |
485 if line.strip() == '-' + vm + ' KNOWN': | |
486 found = True | |
487 break | |
488 if not found: | |
489 _handle_missing_VM(build, vm) | |
490 | |
455 def get_jvmci_jdk_dir(build=None, vmToCheck=None, create=False, deployDists=True): | 491 def get_jvmci_jdk_dir(build=None, vmToCheck=None, create=False, deployDists=True): |
456 """ | 492 """ |
457 Gets the path of the JVMCI JDK corresponding to 'build' (or '_vmbuild'), creating it | 493 Gets the path of the JVMCI JDK corresponding to 'build' (or '_vmbuild'), creating it |
458 first if it does not exist and 'create' is True. If the JDK was created or | 494 first if it does not exist and 'create' is True. If the JDK was created or |
459 'deployDists' is True, then the JDK deployable distributions are deployed into | 495 'deployDists' is True, then the JDK deployable distributions are deployed into |
461 """ | 497 """ |
462 if not build: | 498 if not build: |
463 build = _vmbuild | 499 build = _vmbuild |
464 jdkDir = join(_jdksDir(), build) | 500 jdkDir = join(_jdksDir(), build) |
465 if create: | 501 if create: |
466 srcJdk = mx.get_jdk().home | 502 srcJdk = get_jvmci_bootstrap_jdk().home |
467 if not exists(jdkDir): | 503 if not exists(jdkDir): |
468 mx.log('Creating ' + jdkDir + ' from ' + srcJdk) | 504 mx.log('Creating ' + jdkDir + ' from ' + srcJdk) |
469 shutil.copytree(srcJdk, jdkDir) | 505 shutil.copytree(srcJdk, jdkDir) |
470 | 506 |
471 # Make a copy of the default VM so that this JDK can be | 507 # Make a copy of the default VM so that this JDK can be |
664 jdks = _jdksDir() | 700 jdks = _jdksDir() |
665 if exists(jdks): | 701 if exists(jdks): |
666 for e in os.listdir(jdks): | 702 for e in os.listdir(jdks): |
667 jdkDir = join(jdks, e) | 703 jdkDir = join(jdks, e) |
668 deployableDist.deploy(jdkDir) | 704 deployableDist.deploy(jdkDir) |
705 | |
706 def _vmbuildFromJdkDir(jdkDir): | |
707 """ | |
708 Determines the VM build corresponding to 'jdkDir'. | |
709 """ | |
710 jdksDir = _jdksDir() | |
711 assert jdkDir.startswith(jdksDir) | |
712 vmbuild = os.path.relpath(jdkDir, jdksDir) | |
713 assert vmbuild in _vmbuildChoices, 'The vmbuild derived from ' + jdkDir + ' is unknown: ' + vmbuild | |
714 return vmbuild | |
669 | 715 |
670 def _check_for_obsolete_jvmci_files(): | 716 def _check_for_obsolete_jvmci_files(): |
671 jdks = _jdksDir() | 717 jdks = _jdksDir() |
672 if exists(jdks): | 718 if exists(jdks): |
673 for e in os.listdir(jdks): | 719 for e in os.listdir(jdks): |
763 | 809 |
764 def buildvars(args): | 810 def buildvars(args): |
765 """describe the variables that can be set by the -D option to the 'mx build' commmand""" | 811 """describe the variables that can be set by the -D option to the 'mx build' commmand""" |
766 | 812 |
767 buildVars = { | 813 buildVars = { |
768 'ALT_BOOTDIR' : 'The location of the bootstrap JDK installation (default: ' + mx.get_jdk().home + ')', | 814 'ALT_BOOTDIR' : 'The location of the bootstrap JDK installation (default: ' + get_jvmci_bootstrap_jdk().home + ')', |
769 'ALT_OUTPUTDIR' : 'Build directory', | 815 'ALT_OUTPUTDIR' : 'Build directory', |
770 'HOTSPOT_BUILD_JOBS' : 'Number of CPUs used by make (default: ' + str(mx.cpu_count()) + ')', | 816 'HOTSPOT_BUILD_JOBS' : 'Number of CPUs used by make (default: ' + str(mx.cpu_count()) + ')', |
771 'INSTALL' : 'Install the built VM into the JDK? (default: y)', | 817 'INSTALL' : 'Install the built VM into the JDK? (default: y)', |
772 'ZIP_DEBUGINFO_FILES' : 'Install zipped debug symbols file? (default: 0)', | 818 'ZIP_DEBUGINFO_FILES' : 'Install zipped debug symbols file? (default: 0)', |
773 } | 819 } |
778 mx.log(n) | 824 mx.log(n) |
779 mx.log(textwrap.fill(buildVars[n], initial_indent=' ', subsequent_indent=' ', width=200)) | 825 mx.log(textwrap.fill(buildVars[n], initial_indent=' ', subsequent_indent=' ', width=200)) |
780 | 826 |
781 mx.log('') | 827 mx.log('') |
782 mx.log('Note that these variables can be given persistent values in the file ' + join(_suite.mxDir, 'env') + ' (see \'mx about\').') | 828 mx.log('Note that these variables can be given persistent values in the file ' + join(_suite.mxDir, 'env') + ' (see \'mx about\').') |
783 | |
784 cached_graal_version = None | |
785 | 829 |
786 def _hotspotReplaceResultsVar(m): | 830 def _hotspotReplaceResultsVar(m): |
787 var = m.group(1) | 831 var = m.group(1) |
788 if var == 'os': | 832 if var == 'os': |
789 return _hotspotOs(mx.get_os()) | 833 return _hotspotOs(mx.get_os()) |
840 else: | 884 else: |
841 assert self.vm == 'jvmci', self.vm | 885 assert self.vm == 'jvmci', self.vm |
842 buildSuffix = 'jvmci' | 886 buildSuffix = 'jvmci' |
843 | 887 |
844 if isWindows: | 888 if isWindows: |
845 t_compilelogfile = mx._cygpathU2W(os.path.join(_suite.dir, "graalCompile.log")) | 889 t_compilelogfile = mx._cygpathU2W(os.path.join(_suite.dir, "jvmciCompile.log")) |
846 mksHome = mx.get_env('MKS_HOME', 'C:\\cygwin\\bin') | 890 mksHome = mx.get_env('MKS_HOME', 'C:\\cygwin\\bin') |
847 | 891 |
848 variant = _hotspotGetVariant(self.vm) | 892 variant = _hotspotGetVariant(self.vm) |
849 project_config = variant + '_' + self.vmbuild | 893 project_config = variant + '_' + self.vmbuild |
850 jvmciHome = mx._cygpathU2W(_suite.dir) | 894 jvmciHome = mx._cygpathU2W(_suite.dir) |
851 _runInDebugShell('msbuild ' + jvmciHome + r'\build\vs-amd64\jvm.vcproj /p:Configuration=' + project_config + ' /target:clean', jvmciHome) | 895 _runInDebugShell('msbuild ' + jvmciHome + r'\build\vs-amd64\jvm.vcproj /p:Configuration=' + project_config + ' /target:clean', jvmciHome) |
852 winCompileCmd = r'set HotSpotMksHome=' + mksHome + r'& set JAVA_HOME=' + mx._cygpathU2W(mx.get_jdk().home) + r'& set path=%JAVA_HOME%\bin;%path%;%HotSpotMksHome%& cd /D "' + jvmciHome + r'\make\windows"& call create.bat ' + jvmciHome | 896 winCompileCmd = r'set HotSpotMksHome=' + mksHome + r'& set JAVA_HOME=' + mx._cygpathU2W(get_jvmci_bootstrap_jdk().home) + r'& set path=%JAVA_HOME%\bin;%path%;%HotSpotMksHome%& cd /D "' + jvmciHome + r'\make\windows"& call create.bat ' + jvmciHome |
853 print winCompileCmd | 897 print winCompileCmd |
854 winCompileSuccess = re.compile(r"^Writing \.vcxproj file:") | 898 winCompileSuccess = re.compile(r"^Writing \.vcxproj file:") |
855 if not _runInDebugShell(winCompileCmd, jvmciHome, t_compilelogfile, winCompileSuccess): | 899 if not _runInDebugShell(winCompileCmd, jvmciHome, t_compilelogfile, winCompileSuccess): |
856 mx.abort('Error executing create command') | 900 mx.abort('Error executing create command') |
857 winBuildCmd = 'msbuild ' + jvmciHome + r'\build\vs-amd64\jvm.vcxproj /p:Configuration=' + project_config + ' /p:Platform=x64' | 901 winBuildCmd = 'msbuild ' + jvmciHome + r'\build\vs-amd64\jvm.vcxproj /p:Configuration=' + project_config + ' /p:Platform=x64' |
883 name, value = nv.split('=', 1) | 927 name, value = nv.split('=', 1) |
884 setMakeVar(name.strip(), value) | 928 setMakeVar(name.strip(), value) |
885 | 929 |
886 setMakeVar('ARCH_DATA_MODEL', '64', env=env) | 930 setMakeVar('ARCH_DATA_MODEL', '64', env=env) |
887 setMakeVar('HOTSPOT_BUILD_JOBS', str(cpus), env=env) | 931 setMakeVar('HOTSPOT_BUILD_JOBS', str(cpus), env=env) |
888 setMakeVar('ALT_BOOTDIR', mx.get_jdk().home, env=env) | 932 setMakeVar('ALT_BOOTDIR', get_jvmci_bootstrap_jdk().home, env=env) |
889 # setMakeVar("EXPORT_PATH", jdk) | 933 # setMakeVar("EXPORT_PATH", jdk) |
890 | 934 |
891 setMakeVar('MAKE_VERBOSE', 'y' if mx._opts.verbose else '') | 935 setMakeVar('MAKE_VERBOSE', 'y' if mx._opts.verbose else '') |
892 if self.vm.endswith('nojvmci'): | 936 if self.vm.endswith('nojvmci'): |
893 setMakeVar('INCLUDE_JVMCI', 'false') | 937 setMakeVar('INCLUDE_JVMCI', 'false') |
941 | 985 |
942 def needsBuild(self, newestInput): | 986 def needsBuild(self, newestInput): |
943 newestOutput = self.newestOutput() | 987 newestOutput = self.newestOutput() |
944 for d in ['src', 'make', join('jvmci', 'jdk.internal.jvmci.hotspot', 'src_gen', 'hotspot')]: # TODO should this be replaced by a dependency to the project? | 988 for d in ['src', 'make', join('jvmci', 'jdk.internal.jvmci.hotspot', 'src_gen', 'hotspot')]: # TODO should this be replaced by a dependency to the project? |
945 for root, dirnames, files in os.walk(join(_suite.dir, d)): | 989 for root, dirnames, files in os.walk(join(_suite.dir, d)): |
946 # ignore <graal>/src/share/tools | 990 # ignore src/share/tools |
947 if root == join(_suite.dir, 'src', 'share'): | 991 if root == join(_suite.dir, 'src', 'share'): |
948 dirnames.remove('tools') | 992 dirnames.remove('tools') |
949 for f in (join(root, name) for name in files): | 993 for f in (join(root, name) for name in files): |
950 ts = mx.TimeStampFile(f) | 994 ts = mx.TimeStampFile(f) |
951 if newestOutput: | 995 if newestOutput: |
1043 if line.startswith('#'): | 1087 if line.startswith('#'): |
1044 f.write(line) | 1088 f.write(line) |
1045 continue | 1089 continue |
1046 if not written: | 1090 if not written: |
1047 f.write(vmKnown) | 1091 f.write(vmKnown) |
1048 if vm == 'jvmci': | 1092 for alias, aliased in _vmAliases.iteritems(): |
1049 # Legacy support | 1093 if vm == aliased: |
1050 f.write('-graal ALIASED_TO -jvmci\n') | 1094 f.write('-' + alias + ' ALIASED_TO -' + aliased + '\n') |
1051 written = True | 1095 written = True |
1052 if line.startswith(prefix): | 1096 if line.startswith(prefix): |
1053 line = vmKnown | 1097 line = vmKnown |
1054 if written: | 1098 if written: |
1055 continue | 1099 continue |
1056 f.write(line) | 1100 f.write(line) |
1057 | 1101 |
1058 mx_gate.add_jacoco_includes(['jdk.internal.jvmci.*']) | 1102 mx_gate.add_jacoco_includes(['jdk.internal.jvmci.*']) |
1059 | 1103 |
1060 def parseVmArgs(args, vm=None, cwd=None, vmbuild=None): | 1104 def run_vm(args, vm=None, nonZeroIsFatal=True, out=None, err=None, cwd=None, timeout=None, vmbuild=None): |
1061 """run the VM selected by the '--vm' option""" | 1105 """ |
1062 | 1106 Runs a Java program by executing the java executable in a JVMCI JDK. |
1063 if vm is None: | 1107 """ |
1064 vm = get_vm() | 1108 jdkTag = mx.get_jdk_option().tag |
1065 | 1109 if jdkTag and jdkTag != _JVMCI_JDK_TAG: |
1066 if not isVMSupported(vm): | 1110 mx.abort('The "--jdk" option must have the tag "' + _JVMCI_JDK_TAG + '" when running a command requiring a JVMCI VM') |
1067 mx.abort('The ' + vm + ' is not supported on this platform') | 1111 jdk = get_jvmci_jdk(vmbuild=vmbuild) |
1068 | 1112 return jdk.run_java(args, vm=vm, nonZeroIsFatal=nonZeroIsFatal, out=out, err=err, cwd=cwd, timeout=timeout) |
1069 if cwd is None: | |
1070 cwd = _vm_cwd | |
1071 elif _vm_cwd is not None and _vm_cwd != cwd: | |
1072 mx.abort("conflicting working directories: do not set --vmcwd for this command") | |
1073 | |
1074 build = vmbuild if vmbuild else _vmbuild | |
1075 jdkDir = get_jvmci_jdk_dir(build, vmToCheck=vm, deployDists=False) | |
1076 _updateInstalledJVMCIOptionsFile(jdkDir) | |
1077 mx.expand_project_in_args(args) | |
1078 if _make_eclipse_launch: | |
1079 mx.make_eclipse_launch(_suite, args, _suite.name + '-' + build, name=None, deps=mx.dependencies()) | |
1080 jacocoArgs = mx_gate.get_jacoco_agent_args() | |
1081 if jacocoArgs: | |
1082 args = jacocoArgs + args | |
1083 exe = join(jdkDir, 'bin', mx.exe_suffix('java')) | |
1084 pfx = _vm_prefix.split() if _vm_prefix is not None else [] | |
1085 | |
1086 # Support for -G: options | |
1087 jvmciArgs = [] | |
1088 nonJvmciArgs = [] | |
1089 existingJvmciOptionsProperty = None | |
1090 for a in args: | |
1091 if a.startswith('-G:'): | |
1092 jvmciArg = a[len('-G:'):] | |
1093 assert ' ' not in jvmciArg, 'space not supported in JVMCI arg: ' + a | |
1094 jvmciArgs.append(a[len('-G:'):]) | |
1095 else: | |
1096 if a.startswith('-Djvmci.options=') or a == '-Djvmci.options': | |
1097 existingJvmciOptionsProperty = a | |
1098 nonJvmciArgs.append(a) | |
1099 if jvmciArgs: | |
1100 if existingJvmciOptionsProperty: | |
1101 mx.abort('defining jvmci.option property is incompatible with defining one or more -G: options: ' + existingJvmciOptionsProperty) | |
1102 args = ['-Djvmci.options=' + ' '.join(jvmciArgs)] + nonJvmciArgs | |
1103 | |
1104 if '-version' in args: | |
1105 ignoredArgs = args[args.index('-version') + 1:] | |
1106 if len(ignoredArgs) > 0: | |
1107 mx.log("Warning: The following options will be ignored by the vm because they come after the '-version' argument: " + ' '.join(ignoredArgs)) | |
1108 | |
1109 args = mx.get_jdk().processArgs(args) | |
1110 return (pfx, exe, vm, args, cwd) | |
1111 | |
1112 def vm(args, vm=None, nonZeroIsFatal=True, out=None, err=None, cwd=None, timeout=None, vmbuild=None): | |
1113 (pfx_, exe_, vm_, args_, cwd) = parseVmArgs(args, vm, cwd, vmbuild) | |
1114 return mx.run(pfx_ + [exe_, '-' + vm_] + args_, nonZeroIsFatal=nonZeroIsFatal, out=out, err=err, cwd=cwd, timeout=timeout) | |
1115 | 1113 |
1116 def _unittest_config_participant(config): | 1114 def _unittest_config_participant(config): |
1117 vmArgs, mainClass, mainClassArgs = config | 1115 vmArgs, mainClass, mainClassArgs = config |
1118 if isJVMCIEnabled(get_vm()): | 1116 if isJVMCIEnabled(get_vm()): |
1119 # Remove entries from class path that are in JVMCI loaded jars | 1117 # Remove entries from class path that are in JVMCI loaded jars |
1131 vmArgs = ['-XX:-UseJVMCIClassLoader'] + vmArgs | 1129 vmArgs = ['-XX:-UseJVMCIClassLoader'] + vmArgs |
1132 return (vmArgs, mainClass, mainClassArgs) | 1130 return (vmArgs, mainClass, mainClassArgs) |
1133 return config | 1131 return config |
1134 | 1132 |
1135 def _unittest_vm_launcher(vmArgs, mainClass, mainClassArgs): | 1133 def _unittest_vm_launcher(vmArgs, mainClass, mainClassArgs): |
1136 vm(vmArgs + [mainClass] + mainClassArgs) | 1134 run_vm(vmArgs + [mainClass] + mainClassArgs) |
1137 | 1135 |
1138 mx_unittest.add_config_participant(_unittest_config_participant) | 1136 mx_unittest.add_config_participant(_unittest_config_participant) |
1139 mx_unittest.set_vm_launcher('JVMCI VM launcher', _unittest_vm_launcher) | 1137 mx_unittest.set_vm_launcher('JVMCI VM launcher', _unittest_vm_launcher) |
1140 | 1138 |
1141 def shortunittest(args): | 1139 def shortunittest(args): |
1159 args = parser.parse_args(args) | 1157 args = parser.parse_args(args) |
1160 vms = args.vms.split(',') | 1158 vms = args.vms.split(',') |
1161 builds = args.builds.split(',') | 1159 builds = args.builds.split(',') |
1162 | 1160 |
1163 allStart = time.time() | 1161 allStart = time.time() |
1164 for v in vms: | 1162 for vm in vms: |
1165 if not isVMSupported(v): | 1163 if not isVMSupported(vm): |
1166 mx.log('The ' + v + ' VM is not supported on this platform - skipping') | 1164 mx.log('The ' + vm + ' VM is not supported on this platform - skipping') |
1167 continue | 1165 continue |
1168 | 1166 |
1169 for vmbuild in builds: | 1167 for vmbuild in builds: |
1170 if v == 'original' and vmbuild != 'product': | 1168 if vm == 'original' and vmbuild != 'product': |
1171 continue | 1169 continue |
1172 if not args.console: | 1170 if not args.console: |
1173 logFile = join(v + '-' + vmbuild + '.log') | 1171 logFile = join(vm + '-' + vmbuild + '.log') |
1174 log = open(join(_suite.dir, logFile), 'wb') | 1172 log = open(join(_suite.dir, logFile), 'wb') |
1175 start = time.time() | 1173 start = time.time() |
1176 mx.log('BEGIN: ' + v + '-' + vmbuild + '\t(see: ' + logFile + ')') | 1174 mx.log('BEGIN: ' + vm + '-' + vmbuild + '\t(see: ' + logFile + ')') |
1177 verbose = ['-v'] if mx._opts.verbose else [] | 1175 verbose = ['-v'] if mx._opts.verbose else [] |
1178 # Run as subprocess so that output can be directed to a file | 1176 # Run as subprocess so that output can be directed to a file |
1179 cmd = [sys.executable, '-u', mx.__file__] + verbose + ['--vm', v, '--vmbuild', vmbuild, 'build'] | 1177 cmd = [sys.executable, '-u', mx.__file__] + verbose + ['--vm', vm, '--vmbuild', vmbuild, 'build'] |
1180 mx.logv("executing command: " + str(cmd)) | 1178 mx.logv("executing command: " + str(cmd)) |
1181 subprocess.check_call(cmd, cwd=_suite.dir, stdout=log, stderr=subprocess.STDOUT) | 1179 subprocess.check_call(cmd, cwd=_suite.dir, stdout=log, stderr=subprocess.STDOUT) |
1182 duration = datetime.timedelta(seconds=time.time() - start) | 1180 duration = datetime.timedelta(seconds=time.time() - start) |
1183 mx.log('END: ' + v + '-' + vmbuild + '\t[' + str(duration) + ']') | 1181 mx.log('END: ' + vm + '-' + vmbuild + '\t[' + str(duration) + ']') |
1184 else: | 1182 else: |
1185 with VM(v, vmbuild): | 1183 with VM(vm, vmbuild): |
1186 build([]) | 1184 build([]) |
1187 if not args.no_check: | 1185 if not args.no_check: |
1188 vmargs = ['-version'] | 1186 vmargs = ['-version'] |
1189 if v == 'jvmci': | 1187 if vm == 'jvmci': |
1190 vmargs.insert(0, '-XX:-BootstrapJVMCI') | 1188 vmargs.insert(0, '-XX:-BootstrapJVMCI') |
1191 vm(vmargs, vm=v, vmbuild=vmbuild) | 1189 run_vm(vmargs, vm=vm, vmbuild=vmbuild) |
1192 allDuration = datetime.timedelta(seconds=time.time() - allStart) | 1190 allDuration = datetime.timedelta(seconds=time.time() - allStart) |
1193 mx.log('TOTAL TIME: ' + '[' + str(allDuration) + ']') | 1191 mx.log('TOTAL TIME: ' + '[' + str(allDuration) + ']') |
1194 | 1192 |
1195 | 1193 |
1196 def _jvmci_gate_runner(args, tasks): | 1194 def _jvmci_gate_runner(args, tasks): |
1238 if len(args) > 0 and args[0].isdigit(): | 1236 if len(args) > 0 and args[0].isdigit(): |
1239 count = int(args[0]) | 1237 count = int(args[0]) |
1240 del args[0] | 1238 del args[0] |
1241 | 1239 |
1242 for _ in range(count): | 1240 for _ in range(count): |
1243 if not vm(['-XX:-TieredCompilation', '-XX:+DeoptimizeALot', '-XX:+VerifyOops'] + args + ['-version']) == 0: | 1241 if not run_vm(['-XX:-TieredCompilation', '-XX:+DeoptimizeALot', '-XX:+VerifyOops'] + args + ['-version']) == 0: |
1244 mx.abort("Failed") | 1242 mx.abort("Failed") |
1245 | 1243 |
1246 def longtests(args): | 1244 def longtests(args): |
1247 | 1245 |
1248 deoptalot(['15', '-Xmx48m']) | 1246 deoptalot(['15', '-Xmx48m']) |
1381 allDeps.append(dep) | 1379 allDeps.append(dep) |
1382 d = mx.JARDistribution(_suite, name=artifactId, subDir=_suite.dir, path=path, sourcesPath=path, deps=allDeps, \ | 1380 d = mx.JARDistribution(_suite, name=artifactId, subDir=_suite.dir, path=path, sourcesPath=path, deps=allDeps, \ |
1383 mainClass=None, excludedLibs=[], distDependencies=[], javaCompliance=None, platformDependent=False, theLicense=None) | 1381 mainClass=None, excludedLibs=[], distDependencies=[], javaCompliance=None, platformDependent=False, theLicense=None) |
1384 d.make_archive() | 1382 d.make_archive() |
1385 env = os.environ.copy() | 1383 env = os.environ.copy() |
1386 env['JAVA_HOME'] = get_jvmci_jdk_dir(vmToCheck='server') | 1384 jdkDir = get_jvmci_jdk_dir() |
1385 check_VM_exists('server', jdkDir) | |
1386 env['JAVA_HOME'] = jdkDir | |
1387 env['MAVEN_OPTS'] = '-server -XX:-UseJVMCIClassLoader' | 1387 env['MAVEN_OPTS'] = '-server -XX:-UseJVMCIClassLoader' |
1388 cmd = ['mvn', 'install:install-file', '-DgroupId=' + groupId, '-DartifactId=' + artifactId, | 1388 cmd = ['mvn', 'install:install-file', '-DgroupId=' + groupId, '-DartifactId=' + artifactId, |
1389 '-Dversion=1.0-SNAPSHOT', '-Dpackaging=jar', '-Dfile=' + d.path] | 1389 '-Dversion=1.0-SNAPSHOT', '-Dpackaging=jar', '-Dfile=' + d.path] |
1390 if not mx._opts.verbose: | 1390 if not mx._opts.verbose: |
1391 cmd.append('-q') | 1391 cmd.append('-q') |
1438 if mx._opts.verbose: | 1438 if mx._opts.verbose: |
1439 mx.log(x[:-1]) | 1439 mx.log(x[:-1]) |
1440 else: | 1440 else: |
1441 buildOutput.append(x) | 1441 buildOutput.append(x) |
1442 env = os.environ.copy() | 1442 env = os.environ.copy() |
1443 env['JAVA_HOME'] = get_jvmci_jdk_dir(vmToCheck='server') | 1443 jdkDir = get_jvmci_jdk_dir() |
1444 check_VM_exists('server', jdkDir) | |
1445 env['JAVA_HOME'] = jdkDir | |
1444 env['MAVEN_OPTS'] = '-server -XX:-UseJVMCIClassLoader' | 1446 env['MAVEN_OPTS'] = '-server -XX:-UseJVMCIClassLoader' |
1445 mx.log("Building benchmarks...") | 1447 mx.log("Building benchmarks...") |
1446 cmd = ['mvn'] | 1448 cmd = ['mvn'] |
1447 if args.settings: | 1449 if args.settings: |
1448 cmd = cmd + ['-s', args.settings] | 1450 cmd = cmd + ['-s', args.settings] |
1531 if benchmarks: | 1533 if benchmarks: |
1532 regex.append(r".*(" + "|".join(benchmarks) + ").*") | 1534 regex.append(r".*(" + "|".join(benchmarks) + ").*") |
1533 | 1535 |
1534 for suite in matchedSuites: | 1536 for suite in matchedSuites: |
1535 absoluteMicro = os.path.join(jmhPath, suite) | 1537 absoluteMicro = os.path.join(jmhPath, suite) |
1536 (pfx, exe, vm, forkedVmArgs, _) = parseVmArgs(vmArgs) | 1538 jdk = get_jvmci_jdk() |
1539 vm = get_vm() | |
1540 pfx = get_vm_prefix() | |
1541 forkedVmArgs = jdk.parseVmArgs(vmArgs) | |
1537 def quoteSpace(s): | 1542 def quoteSpace(s): |
1538 if " " in s: | 1543 if " " in s: |
1539 return '"' + s + '"' | 1544 return '"' + s + '"' |
1540 return s | 1545 return s |
1541 | 1546 |
1542 forkedVmArgs = map(quoteSpace, forkedVmArgs) | 1547 forkedVmArgs = map(quoteSpace, forkedVmArgs) |
1543 if pfx: | 1548 if pfx: |
1544 mx.log("JMH ignores prefix: \"" + ' '.join(pfx) + "\"") | 1549 mx.log("JMH ignores prefix: \"" + ' '.join(pfx) + "\"") |
1545 javaArgs = ['-jar', os.path.join(absoluteMicro, "target", "microbenchmarks.jar"), | 1550 javaArgs = ['-jar', os.path.join(absoluteMicro, "target", "microbenchmarks.jar"), |
1546 '--jvm', exe, | 1551 '--jvm', jdk.java, |
1547 '--jvmArgs', ' '.join(["-" + vm] + forkedVmArgs)] | 1552 '--jvmArgs', ' '.join(["-" + vm] + forkedVmArgs)] |
1548 for k, v in jmhArgs.iteritems(): | 1553 for k, v in jmhArgs.iteritems(): |
1549 javaArgs.append(k) | 1554 javaArgs.append(k) |
1550 if len(str(v)): | 1555 if len(str(v)): |
1551 javaArgs.append(str(v)) | 1556 javaArgs.append(str(v)) |
1644 candidates = mx.select_items(sorted(candidates)) | 1649 candidates = mx.select_items(sorted(candidates)) |
1645 else: | 1650 else: |
1646 # mx.findclass can be mistaken, don't give up yet | 1651 # mx.findclass can be mistaken, don't give up yet |
1647 candidates = args | 1652 candidates = args |
1648 | 1653 |
1649 vm(['-javaagent:' + joljar, '-cp', os.pathsep.join([mx.classpath(), joljar]), "org.openjdk.jol.MainObjectInternals"] + candidates) | 1654 run_vm(['-javaagent:' + joljar, '-cp', os.pathsep.join([mx.classpath(), joljar]), "org.openjdk.jol.MainObjectInternals"] + candidates) |
1650 | 1655 |
1651 mx.update_commands(_suite, { | 1656 mx.update_commands(_suite, { |
1652 'build': [build, ''], | 1657 'build': [build, ''], |
1653 'buildjmh': [buildjmh, '[-options]'], | 1658 'buildjmh': [buildjmh, '[-options]'], |
1654 'buildvars': [buildvars, ''], | 1659 'buildvars': [buildvars, ''], |
1660 'igv' : [igv, ''], | 1665 'igv' : [igv, ''], |
1661 'jdkhome': [print_jdkhome, ''], | 1666 'jdkhome': [print_jdkhome, ''], |
1662 'jmh': [jmh, '[VM options] [filters|JMH-args-as-json...]'], | 1667 'jmh': [jmh, '[VM options] [filters|JMH-args-as-json...]'], |
1663 'makejmhdeps' : [makejmhdeps, ''], | 1668 'makejmhdeps' : [makejmhdeps, ''], |
1664 'shortunittest' : [shortunittest, '[unittest options] [--] [VM options] [filters...]', mx_unittest.unittestHelpSuffix], | 1669 'shortunittest' : [shortunittest, '[unittest options] [--] [VM options] [filters...]', mx_unittest.unittestHelpSuffix], |
1665 'vm': [vm, '[-options] class [args...]'], | 1670 'vm': [run_vm, '[-options] class [args...]'], |
1666 'deoptalot' : [deoptalot, '[n]'], | 1671 'deoptalot' : [deoptalot, '[n]'], |
1667 'longtests' : [longtests, ''], | 1672 'longtests' : [longtests, ''], |
1668 'jol' : [jol, ''], | 1673 'jol' : [jol, ''], |
1669 'makefile' : [mx_jvmci_makefile.build_makefile, 'build makefiles for JDK build', None, {'keepUnsatisfiedDependencies': True}], | 1674 'makefile' : [mx_jvmci_makefile.build_makefile, 'build makefiles for JDK build', None, {'keepUnsatisfiedDependencies': True}], |
1670 }) | 1675 }) |
1672 mx.add_argument('--vmcwd', dest='vm_cwd', help='current directory will be changed to <path> before the VM is executed', default=None, metavar='<path>') | 1677 mx.add_argument('--vmcwd', dest='vm_cwd', help='current directory will be changed to <path> before the VM is executed', default=None, metavar='<path>') |
1673 mx.add_argument('--installed-jdks', help='the base directory in which the JDKs cloned from $JAVA_HOME exist. ' + | 1678 mx.add_argument('--installed-jdks', help='the base directory in which the JDKs cloned from $JAVA_HOME exist. ' + |
1674 'The VM selected by --vm and --vmbuild options is under this directory (i.e., ' + | 1679 'The VM selected by --vm and --vmbuild options is under this directory (i.e., ' + |
1675 join('<path>', '<jdk-version>', '<vmbuild>', 'jre', 'lib', '<vm>', mx.add_lib_prefix(mx.add_lib_suffix('jvm'))) + ')', default=None, metavar='<path>') | 1680 join('<path>', '<jdk-version>', '<vmbuild>', 'jre', 'lib', '<vm>', mx.add_lib_prefix(mx.add_lib_suffix('jvm'))) + ')', default=None, metavar='<path>') |
1676 | 1681 |
1677 mx.add_argument('--vm', action='store', dest='vm', choices=_vmChoices.keys(), help='the VM type to build/run') | 1682 mx.add_argument('--vm', action='store', dest='vm', choices=_vmChoices.keys() + _vmAliases.keys(), help='the VM type to build/run') |
1678 mx.add_argument('--vmbuild', action='store', dest='vmbuild', choices=_vmbuildChoices, help='the VM build to build/run (default: ' + _vmbuildChoices[0] + ')') | 1683 mx.add_argument('--vmbuild', action='store', dest='vmbuild', choices=_vmbuildChoices, help='the VM build to build/run (default: ' + _vmbuildChoices[0] + ')') |
1679 mx.add_argument('--ecl', action='store_true', dest='make_eclipse_launch', help='create launch configuration for running VM execution(s) in Eclipse') | 1684 mx.add_argument('--ecl', action='store_true', dest='make_eclipse_launch', help='create launch configuration for running VM execution(s) in Eclipse') |
1680 mx.add_argument('--vmprefix', action='store', dest='vm_prefix', help='prefix for running the VM (e.g. "/usr/bin/gdb --args")', metavar='<prefix>') | 1685 mx.add_argument('--vmprefix', action='store', dest='vm_prefix', help='prefix for running the VM (e.g. "/usr/bin/gdb --args")', metavar='<prefix>') |
1681 mx.add_argument('--gdb', action='store_const', const='/usr/bin/gdb --args', dest='vm_prefix', help='alias for --vmprefix "/usr/bin/gdb --args"') | 1686 mx.add_argument('--gdb', action='store_const', const='/usr/bin/gdb --args', dest='vm_prefix', help='alias for --vmprefix "/usr/bin/gdb --args"') |
1682 mx.add_argument('--lldb', action='store_const', const='lldb --', dest='vm_prefix', help='alias for --vmprefix "lldb --"') | 1687 mx.add_argument('--lldb', action='store_const', const='lldb --', dest='vm_prefix', help='alias for --vmprefix "lldb --"') |
1720 for service, providers in self.jvmciServices.iteritems(): | 1725 for service, providers in self.jvmciServices.iteritems(): |
1721 arcname = 'META-INF/jvmci.services/' + service | 1726 arcname = 'META-INF/jvmci.services/' + service |
1722 # Convert providers to a set before printing to remove duplicates | 1727 # Convert providers to a set before printing to remove duplicates |
1723 self.arc.zf.writestr(arcname, '\n'.join(frozenset(providers))+ '\n') | 1728 self.arc.zf.writestr(arcname, '\n'.join(frozenset(providers))+ '\n') |
1724 | 1729 |
1730 _jvmci_bootstrap_jdk = None | |
1731 | |
1732 def get_jvmci_bootstrap_jdk(): | |
1733 """ | |
1734 Gets the JDK from which a JVMCI JDK is created. | |
1735 """ | |
1736 global _jvmci_bootstrap_jdk | |
1737 if not _jvmci_bootstrap_jdk: | |
1738 def _versionCheck(version): | |
1739 return version >= _minVersion and (not _untilVersion or version >= _untilVersion) | |
1740 versionDesc = ">=" + str(_minVersion) | |
1741 if _untilVersion: | |
1742 versionDesc += " and <=" + str(_untilVersion) | |
1743 _jvmci_bootstrap_jdk = mx.get_jdk(_versionCheck, versionDescription=versionDesc, tag='default') | |
1744 return _jvmci_bootstrap_jdk | |
1745 | |
1746 class JVMCIJDKConfig(mx.JDKConfig): | |
1747 def __init__(self, vmbuild): | |
1748 # Ignore the deployable distributions here - they are only deployed during building. | |
1749 # This significantly reduces the latency of the "mx java" command. | |
1750 self.vmbuild = vmbuild | |
1751 jdkDir = get_jvmci_jdk_dir(build=self.vmbuild, create=True, deployDists=False) | |
1752 mx.JDKConfig.__init__(self, jdkDir, tag=_JVMCI_JDK_TAG) | |
1753 | |
1754 def parseVmArgs(self, args, addDefaultArgs=True): | |
1755 args = mx.expand_project_in_args(args, insitu=False) | |
1756 jacocoArgs = mx_gate.get_jacoco_agent_args() | |
1757 if jacocoArgs: | |
1758 args = jacocoArgs + args | |
1759 | |
1760 # Support for -G: options | |
1761 jvmciArgs = [] | |
1762 nonJvmciArgs = [] | |
1763 existingJvmciOptionsProperty = None | |
1764 for a in args: | |
1765 if a.startswith('-G:'): | |
1766 jvmciArg = a[len('-G:'):] | |
1767 assert ' ' not in jvmciArg, 'space not supported in JVMCI arg: ' + a | |
1768 jvmciArgs.append(a[len('-G:'):]) | |
1769 else: | |
1770 if a.startswith('-Djvmci.options=') or a == '-Djvmci.options': | |
1771 existingJvmciOptionsProperty = a | |
1772 nonJvmciArgs.append(a) | |
1773 if jvmciArgs: | |
1774 if existingJvmciOptionsProperty: | |
1775 mx.abort('defining jvmci.option property is incompatible with defining one or more -G: options: ' + existingJvmciOptionsProperty) | |
1776 args = ['-Djvmci.options=' + ' '.join(jvmciArgs)] + nonJvmciArgs | |
1777 | |
1778 if '-version' in args: | |
1779 ignoredArgs = args[args.index('-version') + 1:] | |
1780 if len(ignoredArgs) > 0: | |
1781 mx.log("Warning: The following options will be ignored by the vm because they come after the '-version' argument: " + ' '.join(ignoredArgs)) | |
1782 return self.processArgs(args, addDefaultArgs=addDefaultArgs) | |
1783 | |
1784 # Overrides JDKConfig | |
1785 def run_java(self, args, vm=None, nonZeroIsFatal=True, out=None, err=None, cwd=None, timeout=None, env=None, addDefaultArgs=True): | |
1786 if vm is None: | |
1787 vm = get_vm() | |
1788 | |
1789 if not isVMSupported(vm): | |
1790 mx.abort('The ' + vm + ' is not supported on this platform') | |
1791 | |
1792 if cwd is None: | |
1793 cwd = _vm_cwd | |
1794 elif _vm_cwd is not None and _vm_cwd != cwd: | |
1795 mx.abort("conflicting working directories: do not set --vmcwd for this command") | |
1796 | |
1797 _updateInstalledJVMCIOptionsFile(self.home) | |
1798 | |
1799 args = self.parseVmArgs(args, addDefaultArgs=addDefaultArgs) | |
1800 if _make_eclipse_launch: | |
1801 mx.make_eclipse_launch(_suite, args, _suite.name + '-' + build, name=None, deps=mx.dependencies()) | |
1802 | |
1803 pfx = _vm_prefix.split() if _vm_prefix is not None else [] | |
1804 cmd = pfx + [self.java] + ['-' + vm] + args | |
1805 return mx.run(cmd, nonZeroIsFatal=nonZeroIsFatal, out=out, err=err, cwd=cwd) | |
1806 | |
1807 """ | |
1808 The dict of JVMCI JDKs indexed by vmbuild names. | |
1809 """ | |
1810 _jvmci_jdks = {} | |
1811 | |
1812 def get_jvmci_jdk(vmbuild=None): | |
1813 """ | |
1814 Gets the JVMCI JDK corresponding to 'vmbuild'. | |
1815 """ | |
1816 if not vmbuild: | |
1817 vmbuild = _vmbuild | |
1818 jdk = _jvmci_jdks.get(vmbuild) | |
1819 if jdk is None: | |
1820 jdk = JVMCIJDKConfig(vmbuild) | |
1821 _jvmci_jdks[vmbuild] = jdk | |
1822 return jdk | |
1823 | |
1824 class JVMCIJDKFactory(mx.JDKFactory): | |
1825 def getJDKConfig(self): | |
1826 jdk = get_jvmci_jdk(_vmbuild) | |
1827 check_VM_exists(get_vm(), jdk.home) | |
1828 return jdk | |
1829 | |
1830 def description(self): | |
1831 return "JVMCI JDK" | |
1832 | |
1725 def mx_post_parse_cmd_line(opts): | 1833 def mx_post_parse_cmd_line(opts): |
1726 # TODO _minVersion check could probably be part of a Suite in mx? | 1834 mx.addJDKFactory(_JVMCI_JDK_TAG, mx.JavaCompliance('8'), JVMCIJDKFactory()) |
1727 def _versionCheck(version): | 1835 mx.set_java_command_default_jdk_tag(_JVMCI_JDK_TAG) |
1728 return version >= _minVersion and (not _untilVersion or version >= _untilVersion) | 1836 |
1729 versionDesc = ">=" + str(_minVersion) | 1837 # Execute for the side-effect of checking that the |
1730 if _untilVersion: | 1838 # boot strap JDK has a compatible version |
1731 versionDesc += " and <=" + str(_untilVersion) | 1839 get_jvmci_bootstrap_jdk() |
1732 mx.get_jdk(_versionCheck, versionDescription=versionDesc, defaultJdk=True) | 1840 |
1733 | 1841 jdkTag = mx.get_jdk_option().tag |
1734 if hasattr(opts, 'vm') and opts.vm is not None: | 1842 if hasattr(opts, 'vm') and opts.vm is not None: |
1735 global _vm | 1843 global _vm |
1736 _vm = opts.vm | 1844 _vm = dealiased_vm(opts.vm) |
1737 _vm = _vm.replace('graal', 'jvmci') | 1845 if jdkTag and jdkTag != _JVMCI_JDK_TAG: |
1846 mx.warn('Ignoring "--vm" option as "--jdk" tag is not "' + _JVMCI_JDK_TAG + '"') | |
1738 if hasattr(opts, 'vmbuild') and opts.vmbuild is not None: | 1847 if hasattr(opts, 'vmbuild') and opts.vmbuild is not None: |
1739 global _vmbuild | 1848 global _vmbuild |
1740 _vmbuild = opts.vmbuild | 1849 _vmbuild = opts.vmbuild |
1850 if jdkTag and jdkTag != _JVMCI_JDK_TAG: | |
1851 mx.warn('Ignoring "--vmbuild" option as "--jdk" tag is not "' + _JVMCI_JDK_TAG + '"') | |
1852 | |
1741 global _make_eclipse_launch | 1853 global _make_eclipse_launch |
1742 _make_eclipse_launch = getattr(opts, 'make_eclipse_launch', False) | 1854 _make_eclipse_launch = getattr(opts, 'make_eclipse_launch', False) |
1743 global _vm_cwd | 1855 global _vm_cwd |
1744 _vm_cwd = opts.vm_cwd | 1856 _vm_cwd = opts.vm_cwd |
1745 global _installed_jdks | 1857 global _installed_jdks |