# HG changeset patch # User Tom Rodriguez # Date 1466632557 25200 # Node ID 387870951564fdd24bc66dd24da3f2525eaf2c1d # Parent 927a39cd7ddddab26ee27bb8aee6f13f73352786 Remove old DEFAULT_VM machinery diff -r 927a39cd7ddd -r 387870951564 mx.jvmci/mx_jvmci.py --- a/mx.jvmci/mx_jvmci.py Tue Jun 21 14:36:31 2016 -0700 +++ b/mx.jvmci/mx_jvmci.py Wed Jun 22 14:55:57 2016 -0700 @@ -46,8 +46,6 @@ _vmChoices = { 'server' : 'Normal compilation is performed with a tiered system (C1 + C2 or Graal) and Graal is available for hosted compilation.', 'client' : None, # VM compilation with client compiler, hosted compilation with Graal - 'server-nojvmci' : None, # all compilation with tiered system (i.e., client + server), JVMCI omitted - 'client-nojvmci' : None, # all compilation with client compiler, JVMCI omitted 'original' : None, # default VM copied from bootstrap JDK } @@ -68,9 +66,8 @@ _JVMCI_JDK_TAG = 'jvmci' """ The VM that will be run by the 'vm' command and built by default by the 'build' command. - This can be set via the global '--vm' option or the DEFAULT_VM environment variable. - It can also be temporarily set by using of a VM context manager object in a 'with' statement. """ -_vm = None + It can be temporarily set by using a VM context manager object in a 'with' statement. """ +_vm = 'server' class JVMCIMode: def __init__(self, jvmciMode): @@ -204,7 +201,6 @@ targetDir = join(jdkDir, _hs_deploy_map[m.name]) mx.logv('Deploying {} from {} to {}'.format(m.name, dist.name, targetDir)) tar.extract(m, targetDir) - updateJvmCfg(jdkDir, get_vm()) """ List of distributions that are deployed into a JDK by mx. @@ -272,32 +268,9 @@ def get_vm(): """ - Gets the configured VM, presenting a dialogue if there is no currently configured VM. + Gets the configured VM. """ - global _vm - if _vm: - return _vm - vm = mx.get_env('DEFAULT_VM') - envPath = join(_suite.mxDir, 'env') - if vm and vm in _vmAliases: - if exists(envPath): - with open(envPath) as fp: - if 'DEFAULT_VM=' + vm in fp.read(): - mx.log('Please update the DEFAULT_VM value in ' + envPath + ' to replace "' + vm + '" with "' + _vmAliases[vm] + '"') - vm = _vmAliases[vm] - if vm is None: - items = [k for k in _vmChoices.keys() if _vmChoices[k] is not None] - if len(items) > 1: - if not mx.is_interactive(): - mx.abort('Need to specify VM with --vm option or DEFAULT_VM environment variable') - mx.log('Please select the VM to be executed from the following: ') - descriptions = [_vmChoices[k] for k in _vmChoices.keys() if _vmChoices[k] is not None] - vm = mx.select_items(items, descriptions, allowMultiple=False) - mx.ask_persist_env('DEFAULT_VM', vm) - else: - vm = items[0] - _vm = vm - return vm + return _vm """ A context manager that can be used with the 'with' statement to set the VM @@ -549,24 +522,13 @@ if not exists(jvmCfg): mx.abort(jvmCfg + ' does not exist') - defaultVM = None jvmCfgLines = [] with open(jvmCfg) as f: - for line in f: - if line.startswith('-') and defaultVM is None: - parts = line.split() - if len(parts) == 2: - assert parts[1] == 'KNOWN', parts[1] - defaultVM = parts[0][1:] - jvmCfgLines += ['# default VM is a copy of the unmodified ' + defaultVM + ' VM\n'] - jvmCfgLines += ['-original KNOWN\n'] - else: - # skip lines which we cannot parse (e.g. '-hotspot ALIASED_TO -client') - mx.log("WARNING: skipping not parsable line \"" + line + "\"") - else: - jvmCfgLines += [line] + jvmCfgLines = f.readlines() - assert defaultVM is not None, 'Could not find default VM in ' + jvmCfg + jvmCfgLines += ['-original KNOWN\n'] + + defaultVM = 'server' chmodRecursive(jdkDir, JDK_UNIX_PERMISSIONS_DIR) shutil.move(join(vmLibDirInJdk(jdkDir), defaultVM), join(vmLibDirInJdk(jdkDir), 'original')) @@ -1080,98 +1042,6 @@ mx.build(['--source', '1.7'] + args, parser=parser) - -def updateJvmCfg(jdkDir, vm): - jvmCfg = getVmCfgInJdk(jdkDir) - if not exists(jvmCfg): - mx.abort(jvmCfg + ' does not exist') - - def getVMEntry(vm): - """Return the set of lines that should be in jvm.cfg for this vm configuration""" - known = '-' + vm + ' ' + 'KNOWN\n' - cfgLines = [] - cfgLines.append(known) - for alias, aliased in _vmAliases.iteritems(): - if vm == aliased: - cfgLines.append('-' + alias + ' ALIASED_TO -' + aliased + '\n') - return known, cfgLines - - # Compute the cfg entries for the currently selected VM and the default VM, - # if a default VM has been set. - vmKnown, vmLines = getVMEntry(vm) - defaultVMLines = [] - defaultVM = mx.get_env('DEFAULT_VM') - if defaultVM: - if defaultVM == vm: - defaultVM = None - else: - defaultVMPath = join(vmLibDirInJdk(jdkDir), defaultVM, _lib('jvm')) - if not exists(defaultVMPath): - mx.log('Warning: The default VM is "' + defaultVM + '" but it hasn\'t been built yet so "-' + vm + '" will be the default.') - defaultVM = None - else: - defaultVMKnown, defaultVMLines = getVMEntry(defaultVM) - - # The default VM should always be set as the default, so read the existing jvm.cfg - # and strip out any lines that mention the vm or the defaultVM, splitting the file - # into a possible comment prefix and all the rest of the lines from the jvm.cfg. - # Note that this will enforce the defaultVM even if the default hasn't been built. - prefix = [] - suffix = [] - lines = [] - outOfOrder = False - foundVm = False - foundDefaultVM = defaultVM == None - with open(jvmCfg) as f: - for line in f: - lines.append(line) - if line.strip() == vmKnown.strip(): - foundVm = True - continue - if line.endswith(' ALIASED_TO -' + vm + '\n'): - continue - if defaultVM and line.strip() == defaultVMKnown.strip(): - foundDefaultVM = True - outOfOrder = foundVm - continue - if defaultVM and line.endswith(' ALIASED_TO -' + defaultVM + '\n'): - continue - if line.startswith('#') and len(suffix) == 0: - prefix.append(line) - else: - suffix.append(line) - - - # Build the new jvm.cfg out of the comment prefix, the entries for any default VM, - # the entries for the currently selected VM followed by the remaining lines. - allLines = prefix + defaultVMLines + vmLines + suffix - - if allLines != lines: - # The computed jvm.cfg is different from what's on disk so try to explain - # what effect the newly written one will have. - if outOfOrder: - # Both vm and defaultVM were already in the jvm.cfg but in a different order - # so vm was the default. The new jvm.cfg sets defaultVM as the default. - mx.log('Resetting "' + defaultVM + '" as default in ' + jvmCfg) - else: - if defaultVM: - if not foundDefaultVM: - # The defaultVM was missing so it's being set to the default. - mx.log('Setting default JVM to "-' + defaultVM + '" in ' + jvmCfg) - if not foundVm: - # vm wasn't found so it's added but is not the default. - mx.log('Adding JVM "-' + vm + '" in ' + jvmCfg) - else: - # No defaultVM was specified or it was the same as vm, so - # vm will be the default. - mx.log('Setting default JVM to "-' + vm + '" in ' + jvmCfg) - - if mx.get_os() != 'windows': - os.chmod(jvmCfg, JDK_UNIX_PERMISSIONS_FILE) - with open(jvmCfg, 'w') as f: - for line in allLines: - f.write(line) - mx_gate.add_jacoco_includes(['jdk.vm.ci.*']) def run_vm(args, vm=None, nonZeroIsFatal=True, out=None, err=None, cwd=None, timeout=None, vmbuild=None): @@ -1535,12 +1405,6 @@ mx.add_argument('--gdb', action='store_const', const='/usr/bin/gdb --args', dest='vm_prefix', help='alias for --vmprefix "/usr/bin/gdb --args"') mx.add_argument('--lldb', action='store_const', const='lldb --', dest='vm_prefix', help='alias for --vmprefix "lldb --"') -# The mx builders are run inside the directory of their associated suite, -# not the primary suite, so they might not see the env file of the primary -# suite. Capture DEFAULT_VM in case it was only defined in the primary -# suite. -mx.add_ide_envvar('DEFAULT_VM') - _jvmci_bootstrap_jdk = None def get_jvmci_bootstrap_jdk():