def vm(args): """launch the Maxine VM Run the Maxine VM with the given options and arguments. A class path component with a '@' prefix is expanded to be the class path of the project named after the '@'. The expansion of the MAXVM_OPTIONS environment variable is inserted before any other VM options specified on the command line. Use "mx vm -help" to see what other options this command accepts.""" cwdArgs = check_cwd_change(args) cwd = cwdArgs[0] vmArgs = cwdArgs[1] mx.expand_project_in_args(vmArgs) maxvmOptions = os.getenv('MAXVM_OPTIONS', '').split() debug_port = mx.java().debug_port if debug_port is not None: maxvmOptions += [ '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=' + str(debug_port) ] mx.run([join(_vmdir, 'maxvm')] + maxvmOptions + vmArgs, cwd=cwd, env=ldenv)
def parseVmArgs(self, args, addDefaultArgs=True): args = mx.expand_project_in_args(args, insitu=False) jacocoArgs = mx_gate.get_jacoco_agent_args() if jacocoArgs: args = jacocoArgs + args args = [ '-Xbootclasspath/p:' + dep.classpath_repr() for dep in _jvmci_bootclasspath_prepends ] + args jvmciModeArgs = _jvmciModes[_vm.jvmciMode] if jvmciModeArgs: bcpDeps = [jdkDist.dist() for jdkDist in jdkDeployedDists] if bcpDeps: args = [ '-Xbootclasspath/p:' + os.pathsep.join([d.classpath_repr() for d in bcpDeps]) ] + args # Set the default JVMCI compiler for jdkDist in reversed(jdkDeployedDists): assert isinstance(jdkDist, JvmciJDKDeployedDist), jdkDist if jdkDist._compilers: jvmciCompiler = jdkDist._compilers[-1] args = ['-Djvmci.compiler=' + jvmciCompiler] + args break if '-version' in args: ignoredArgs = args[args.index('-version') + 1:] if len(ignoredArgs) > 0: mx.log( "Warning: The following options will be ignored by the vm because they come after the '-version' argument: " + ' '.join(ignoredArgs)) return self.processArgs(args, addDefaultArgs=addDefaultArgs)
def parseVmArgs(self, args, addDefaultArgs=True): args = mx.expand_project_in_args(args, insitu=False) jacocoArgs = mx_gate.get_jacoco_agent_args() if jacocoArgs: args = jacocoArgs + args args = [ '-Xbootclasspath/p:' + dep.classpath_repr() for dep in _jvmci_bootclasspath_prepends ] + args # Remove JVMCI jars from class path. They are only necessary when # compiling with a javac from JDK8 or earlier. cpIndex, cp = mx.find_classpath_arg(args) if cp: excluded = frozenset([dist.path for dist in _suite.dists]) cp = os.pathsep.join( [e for e in cp.split(os.pathsep) if e not in excluded]) args[cpIndex] = cp if '-version' in args: ignoredArgs = args[args.index('-version') + 1:] if len(ignoredArgs) > 0: mx.log( "Warning: The following options will be ignored by the vm because they come after the '-version' argument: " + ' '.join(ignoredArgs)) return self.processArgs(args, addDefaultArgs=addDefaultArgs)
def parseVmArgs(self, args, addDefaultArgs=True): args = mx.expand_project_in_args(args, insitu=False) jacocoArgs = mx_gate.get_jacoco_agent_args() if jacocoArgs: args = jacocoArgs + args args = ['-Xbootclasspath/p:' + dep.classpath_repr() for dep in _jvmci_bootclasspath_prepends] + args # Remove JVMCI jars from class path. They are only necessary when # compiling with a javac from JDK8 or earlier. cpIndex, cp = mx.find_classpath_arg(args) if cp: excluded = frozenset([dist.path for dist in _suite.dists]) cp = os.pathsep.join([e for e in cp.split(os.pathsep) if e not in excluded]) args[cpIndex] = cp jvmciModeArgs = _jvmciModes[_vm.jvmciMode] if jvmciModeArgs: bcpDeps = [jdkDist.dist() for jdkDist in jdkDeployedDists] if bcpDeps: args = ['-Xbootclasspath/p:' + os.pathsep.join([d.classpath_repr() for d in bcpDeps])] + args # Set the default JVMCI compiler for jdkDist in reversed(jdkDeployedDists): assert isinstance(jdkDist, JvmciJDKDeployedDist), jdkDist if jdkDist._compilers: jvmciCompiler = jdkDist._compilers[-1] args = ['-Djvmci.compiler=' + jvmciCompiler] + args break if '-version' in args: ignoredArgs = args[args.index('-version') + 1:] if len(ignoredArgs) > 0: mx.log("Warning: The following options will be ignored by the vm because they come after the '-version' argument: " + ' '.join(ignoredArgs)) return self.processArgs(args, addDefaultArgs=addDefaultArgs)
def parseVmArgs(self, args, addDefaultArgs=True): args = mx.expand_project_in_args(args, insitu=False) jacocoArgs = mx_gate.get_jacoco_agent_args() if jacocoArgs: args = jacocoArgs + args args = ['-Xbootclasspath/p:' + dep.classpath_repr() for dep in _jvmci_bootclasspath_prepends] + args jvmciModeArgs = _jvmciModes[_vm.jvmciMode] if jvmciModeArgs: bcpDeps = [jdkDist.dist() for jdkDist in jdkDeployedDists] if bcpDeps: args = ['-Xbootclasspath/p:' + os.pathsep.join([d.classpath_repr() for d in bcpDeps])] + args # Set the default JVMCI compiler for jdkDist in reversed(jdkDeployedDists): assert isinstance(jdkDist, JvmciJDKDeployedDist), jdkDist if jdkDist._compilers: jvmciCompiler = jdkDist._compilers[-1] args = ['-Djvmci.compiler=' + jvmciCompiler] + args break if '-version' in args: ignoredArgs = args[args.index('-version') + 1:] if len(ignoredArgs) > 0: mx.log("Warning: The following options will be ignored by the vm because they come after the '-version' argument: " + ' '.join(ignoredArgs)) return self.processArgs(args, addDefaultArgs=addDefaultArgs)
def _parseVmArgs(jdk, args, addDefaultArgs=True): args = mx.expand_project_in_args(args, insitu=False) jacocoArgs = mx_gate.get_jacoco_agent_args() if jacocoArgs: args = jacocoArgs + args # Support for -G: options def translateGOption(arg): if arg.startswith('-G:+'): if '=' in arg: mx.abort('Mixing + and = in -G: option specification: ' + arg) arg = '-Dgraal.' + arg[len('-G:+'):] + '=true' elif arg.startswith('-G:-'): if '=' in arg: mx.abort('Mixing - and = in -G: option specification: ' + arg) arg = '-Dgraal.' + arg[len('-G:+'):] + '=false' elif arg.startswith('-G:'): if '=' not in arg: mx.abort( 'Missing "=" in non-boolean -G: option specification: ' + arg) arg = '-Dgraal.' + arg[len('-G:'):] return arg args = map(translateGOption, args) if '-G:+PrintFlags' in args and '-Xcomp' not in args: mx.warn( 'Using -G:+PrintFlags may have no effect without -Xcomp as Graal initialization is lazy' ) bcp = [] if _jvmciModes[_vm.jvmciMode]: if _add_jvmci_to_bootclasspath: bcp.append(mx.library('JVMCI').classpath_repr()) bcp.extend([d.get_classpath_repr() for d in _bootClasspathDists]) if bcp: args = ['-Xbootclasspath/p:' + os.pathsep.join(bcp)] + args # Remove JVMCI from class path. It's only there to support compilation. cpIndex, cp = mx.find_classpath_arg(args) if cp: jvmciLib = mx.library('JVMCI').path cp = os.pathsep.join( [e for e in cp.split(os.pathsep) if e != jvmciLib]) args[cpIndex] = cp # Set the default JVMCI compiler jvmciCompiler = _compilers[-1] args = ['-Djvmci.compiler=' + jvmciCompiler] + args if '-version' in args: ignoredArgs = args[args.index('-version') + 1:] if len(ignoredArgs) > 0: mx.log( "Warning: The following options will be ignored by the vm because they come after the '-version' argument: " + ' '.join(ignoredArgs)) return jdk.processArgs(args, addDefaultArgs=addDefaultArgs)
def parseVmArgs(self, args, addDefaultArgs=True): args = mx.expand_project_in_args(args, insitu=False) jacocoArgs = mx_gate.get_jacoco_agent_args() if jacocoArgs: args = jacocoArgs + args # Support for -G: options def translateGOption(arg): if arg.startswith('-G:+'): if '=' in arg: mx.abort('Mixing + and = in -G: option specification: ' + arg) arg = '-Djvmci.option.' + arg[len('-G:+'):] + '=true' elif arg.startswith('-G:-'): if '=' in arg: mx.abort('Mixing - and = in -G: option specification: ' + arg) arg = '-Djvmci.option.' + arg[len('-G:+'):] + '=false' elif arg.startswith('-G:'): arg = '-Djvmci.option.' + arg[len('-G:'):] return arg args = map(translateGOption, args) args = [ '-Xbootclasspath/p:' + dep.classpath_repr() for dep in _jvmci_bootclasspath_prepends ] + args jvmciModeArgs = _jvmciModes[_vm.jvmciMode] if jvmciModeArgs: bcpDeps = [jdkDist.dist() for jdkDist in jdkDeployedDists] if bcpDeps: args = [ '-Xbootclasspath/p:' + os.pathsep.join([d.classpath_repr() for d in bcpDeps]) ] + args # Set the default JVMCI compiler for jdkDist in reversed(jdkDeployedDists): assert isinstance(jdkDist, JvmciJDKDeployedDist), jdkDist if jdkDist._compilers: jvmciCompiler = jdkDist._compilers[-1] args = ['-Djvmci.compiler=' + jvmciCompiler] + args break if '-version' in args: ignoredArgs = args[args.index('-version') + 1:] if len(ignoredArgs) > 0: mx.log( "Warning: The following options will be ignored by the vm because they come after the '-version' argument: " + ' '.join(ignoredArgs)) return self.processArgs(args, addDefaultArgs=addDefaultArgs)
def _parseVmArgs(jdk, args, addDefaultArgs=True): args = mx.expand_project_in_args(args, insitu=False) jacocoArgs = mx_gate.get_jacoco_agent_args() if jacocoArgs: args = jacocoArgs + args # Support for -G: options def translateGOption(arg): if arg.startswith("-G:+"): if "=" in arg: mx.abort("Mixing + and = in -G: option specification: " + arg) arg = "-Dgraal." + arg[len("-G:+") :] + "=true" elif arg.startswith("-G:-"): if "=" in arg: mx.abort("Mixing - and = in -G: option specification: " + arg) arg = "-Dgraal." + arg[len("-G:+") :] + "=false" elif arg.startswith("-G:"): if "=" not in arg: mx.abort('Missing "=" in non-boolean -G: option specification: ' + arg) arg = "-Dgraal." + arg[len("-G:") :] return arg args = map(translateGOption, args) if "-G:+PrintFlags" in args and "-Xcomp" not in args: mx.warn("Using -G:+PrintFlags may have no effect without -Xcomp as Graal initialization is lazy") bcp = [mx.distribution("truffle:TRUFFLE_API").classpath_repr()] if _jvmciModes[_vm.jvmciMode]: bcp.extend([d.get_classpath_repr() for d in _bootClasspathDists]) args = ["-Xbootclasspath/p:" + os.pathsep.join(bcp)] + args # Remove JVMCI from class path. It's only there to support compilation. cpIndex, cp = mx.find_classpath_arg(args) if cp: jvmciLib = mx.library("JVMCI").path cp = os.pathsep.join([e for e in cp.split(os.pathsep) if e != jvmciLib]) args[cpIndex] = cp # Set the default JVMCI compiler jvmciCompiler = _compilers[-1] args = ["-Djvmci.compiler=" + jvmciCompiler] + args if "-version" in args: ignoredArgs = args[args.index("-version") + 1 :] if len(ignoredArgs) > 0: mx.log( "Warning: The following options will be ignored by the vm because they come after the '-version' argument: " + " ".join(ignoredArgs) ) return jdk.processArgs(args, addDefaultArgs=addDefaultArgs)
def _parseVmArgs(jdk, args, addDefaultArgs=True): args = mx.expand_project_in_args(args, insitu=False) jacocoArgs = mx_gate.get_jacoco_agent_args() if jacocoArgs: args = jacocoArgs + args # Support for -G: options def translateGOption(arg): if arg.startswith('-G:+'): if '=' in arg: mx.abort('Mixing + and = in -G: option specification: ' + arg) arg = '-Dgraal.' + arg[len('-G:+'):] + '=true' elif arg.startswith('-G:-'): if '=' in arg: mx.abort('Mixing - and = in -G: option specification: ' + arg) arg = '-Dgraal.' + arg[len('-G:+'):] + '=false' elif arg.startswith('-G:'): if '=' not in arg: mx.abort('Missing "=" in non-boolean -G: option specification: ' + arg) arg = '-Dgraal.' + arg[len('-G:'):] return arg # add default graal.options.file and translate -G: options options_file = join(mx.primary_suite().dir, 'graal.options') options_file_arg = ['-Dgraal.options.file=' + options_file] if exists(options_file) else [] args = options_file_arg + map(translateGOption, args) if '-G:+PrintFlags' in args and '-Xcomp' not in args: mx.warn('Using -G:+PrintFlags may have no effect without -Xcomp as Graal initialization is lazy') bcp = [mx.distribution('truffle:TRUFFLE_API').classpath_repr()] if _jvmciModes[_vm.jvmciMode]: bcp.extend([d.get_classpath_repr() for d in _bootClasspathDists]) args = ['-Xbootclasspath/p:' + os.pathsep.join(bcp)] + args # Remove JVMCI from class path. It's only there to support compilation. cpIndex, cp = mx.find_classpath_arg(args) if cp: jvmciLib = mx.library('JVMCI').path cp = os.pathsep.join([e for e in cp.split(os.pathsep) if e != jvmciLib]) args[cpIndex] = cp # Set the default JVMCI compiler jvmciCompiler = _compilers[-1] args = ['-Djvmci.Compiler=' + jvmciCompiler] + args if '-version' in args: ignoredArgs = args[args.index('-version') + 1:] if len(ignoredArgs) > 0: mx.log("Warning: The following options will be ignored by the vm because they come after the '-version' argument: " + ' '.join(ignoredArgs)) return jdk.processArgs(args, addDefaultArgs=addDefaultArgs)
def vm(args): """launch the Maxine VM Run the Maxine VM with the given options and arguments. A class path component with a '@' prefix is expanded to be the class path of the project named after the '@'. The expansion of the MAXVM_OPTIONS environment variable is inserted before any other VM options specified on the command line. Use "mx vm -help" to see what other options this command accepts.""" cwdArgs = check_cwd_change(args) cwd = cwdArgs[0] vmArgs = cwdArgs[1] mx.expand_project_in_args(vmArgs) maxvmOptions = os.getenv('MAXVM_OPTIONS', '').split() debug_args = mx.get_jdk().debug_args if debug_args is not []: maxvmOptions += debug_args mx.run([join(_vmdir, 'maxvm')] + maxvmOptions + vmArgs, cwd=cwd, env=ldenv)
def vm(args): """launch the Maxine VM Run the Maxine VM with the given options and arguments. A class path component with a '@' prefix is expanded to be the class path of the project named after the '@'. The expansion of the MAXVM_OPTIONS environment variable is inserted before any other VM options specified on the command line. Use "mx vm -help" to see what other options this command accepts.""" cwdArgs = check_cwd_change(args) cwd = cwdArgs[0] vmArgs = cwdArgs[1] mx.expand_project_in_args(vmArgs) maxvmOptions = os.getenv('MAXVM_OPTIONS', '').split() debug_port = mx.java().debug_port if debug_port is not None: maxvmOptions += ['-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=' + str(debug_port)] mx.run([join(_vmdir, 'maxvm')] + maxvmOptions + vmArgs, cwd=cwd)
def parseVmArgs(self, args, addDefaultArgs=True): args = mx.expand_project_in_args(args, insitu=False) jacocoArgs = mx_gate.get_jacoco_agent_args() if jacocoArgs: args = jacocoArgs + args args = ['-Xbootclasspath/p:' + dep.classpath_repr() for dep in _jvmci_bootclasspath_prepends] + args # Remove JVMCI jars from class path. They are only necessary when # compiling with a javac from JDK8 or earlier. cpIndex, cp = mx.find_classpath_arg(args) if cp: excluded = frozenset([dist.path for dist in _suite.dists]) cp = os.pathsep.join([e for e in cp.split(os.pathsep) if e not in excluded]) args[cpIndex] = cp if '-version' in args: ignoredArgs = args[args.index('-version') + 1:] if len(ignoredArgs) > 0: mx.log("Warning: The following options will be ignored by the vm because they come after the '-version' argument: " + ' '.join(ignoredArgs)) return self.processArgs(args, addDefaultArgs=addDefaultArgs)
def _parseVmArgs(jdk, args, addDefaultArgs=True): args = mx.expand_project_in_args(args, insitu=False) jacocoArgs = mx_gate.get_jacoco_agent_args() if jacocoArgs: args = jacocoArgs + args # Support for -G: options def translateGOption(arg): if arg.startswith('-G:+'): if '=' in arg: mx.abort('Mixing + and = in -G: option specification: ' + arg) arg = '-Djvmci.option.' + arg[len('-G:+'):] + '=true' elif arg.startswith('-G:-'): if '=' in arg: mx.abort('Mixing - and = in -G: option specification: ' + arg) arg = '-Djvmci.option.' + arg[len('-G:+'):] + '=false' elif arg.startswith('-G:'): arg = '-Djvmci.option.' + arg[len('-G:'):] return arg args = map(translateGOption, args) bcp = [mx.distribution('truffle:TRUFFLE_API').classpath_repr()] if _jvmciModes[_vm.jvmciMode]: bcp.extend([d.get_classpath_repr() for d in _bootClasspathDists]) args = ['-Xbootclasspath/p:' + os.pathsep.join(bcp)] + args # Set the default JVMCI compiler jvmciCompiler = _compilers[-1] args = ['-Djvmci.compiler=' + jvmciCompiler] + args if '-version' in args: ignoredArgs = args[args.index('-version') + 1:] if len(ignoredArgs) > 0: mx.log( "Warning: The following options will be ignored by the vm because they come after the '-version' argument: " + ' '.join(ignoredArgs)) return jdk.processArgs(args, addDefaultArgs=addDefaultArgs)
def _parseVmArgs(args, addDefaultArgs=True): args = mx.expand_project_in_args(args, insitu=False) argsPrefix = [] jacocoArgs = mx_gate.get_jacoco_agent_args() if jacocoArgs: argsPrefix.extend(jacocoArgs) # Check for -G: options def checkGOption(arg): if arg.startswith('-G:+'): if '=' in arg: mx.abort('Mixing + and = in -G: option specification: ' + arg) translation = '-Dgraal.' + arg[len('-G:+'):] + '=true' elif arg.startswith('-G:-'): if '=' in arg: mx.abort('Mixing - and = in -G: option specification: ' + arg) translation = '-Dgraal.' + arg[len('-G:+'):] + '=false' elif arg.startswith('-G:'): if '=' not in arg: mx.abort('Missing "=" in non-boolean -G: option specification: ' + arg) translation = '-Dgraal.' + arg[len('-G:'):] else: return arg mx.warn('Support for -G options is deprecated and will soon be removed. Replace "' + arg + '" with "' + translation + '"') return translation # add default graal.options.file options_file = join(mx.primary_suite().dir, 'graal.options') if exists(options_file): argsPrefix.append('-Dgraal.options.file=' + options_file) args = [checkGOption(a) for a in args] if '-Dgraal.PrintFlags=true' in args and '-Xcomp' not in args: mx.warn('Using -Dgraal.PrintFlags=true may have no effect without -Xcomp as Graal initialization is lazy') if isJDK8: argsPrefix.append('-Djvmci.class.path.append=' + os.pathsep.join((e.get_path() for e in _jvmci_classpath))) argsPrefix.append('-Xbootclasspath/a:' + os.pathsep.join([dep.classpath_repr() for dep in _bootclasspath_appends])) else: deployedDists = [entry.dist() for entry in _jvmci_classpath] + \ [e for e in _bootclasspath_appends if e.isJARDistribution()] deployedModules = [as_java_module(dist, jdk) for dist in deployedDists] # Set or update module path to include Graal and its dependencies as modules graalModulepath = [] for deployedModule in deployedModules: graalModulepath.extend([jmd.jarpath for jmd in deployedModule.modulepath if jmd.jarpath]) graalModulepath.append(deployedModule.jarpath) graalModulepath = _uniqify(graalModulepath) # Update added exports to include concealed JDK packages required by Graal addedExports = {} args = _extract_added_exports(args, addedExports) for deployedModule in deployedModules: for concealingModule, packages in deployedModule.concealedRequires.iteritems(): # No need to explicitly export JVMCI - it's exported via reflection if concealingModule != 'jdk.vm.ci': for package in packages: addedExports.setdefault(concealingModule + '/' + package, set()).add(deployedModule.name) for export, targets in addedExports.iteritems(): argsPrefix.append('-XaddExports:' + export + '=' + ','.join(sorted(targets))) # Extend or set -modulepath argument mpUpdated = False for mpIndex in range(len(args)): if args[mpIndex] in ['-modulepath', '-mp']: assert mpIndex + 1 < len(args), 'VM option ' + args[mpIndex] + ' requires an argument' args[mpIndex + 1] = os.pathsep.join(_uniqify(args[mpIndex + 1].split(os.pathsep) + graalModulepath)) mpUpdated = True break if not mpUpdated: argsPrefix.append('-modulepath') argsPrefix.append(os.pathsep.join(graalModulepath)) # Set the JVMCI compiler to Graal argsPrefix.append('-Djvmci.Compiler=graal') if '-version' in args: ignoredArgs = args[args.index('-version') + 1:] if len(ignoredArgs) > 0: mx.log("Warning: The following options will be ignored by the VM because they come after the '-version' argument: " + ' '.join(ignoredArgs)) return jdk.processArgs(argsPrefix + args, addDefaultArgs=addDefaultArgs)
def _parseVmArgs(args, addDefaultArgs=True): args = mx.expand_project_in_args(args, insitu=False) argsPrefix = [] jacocoArgs = mx_gate.get_jacoco_agent_args() if jacocoArgs: argsPrefix.extend(jacocoArgs) # add default graal.options.file options_file = join(mx.primary_suite().dir, 'graal.options') if exists(options_file): argsPrefix.append('-Dgraal.options.file=' + options_file) if isJDK8: argsPrefix.append('-Djvmci.class.path.append=' + os.pathsep.join((e.get_path() for e in _jvmci_classpath))) argsPrefix.append('-Xbootclasspath/a:' + os.pathsep.join([dep.classpath_repr() for dep in _bootclasspath_appends])) else: deployedDists = [entry.dist() for entry in _jvmci_classpath] + \ [e for e in _bootclasspath_appends if e.isJARDistribution()] deployedModules = [as_java_module(dist, jdk) for dist in deployedDists] # Set or update module path to include Graal and its dependencies as modules graalModulepath = [] for deployedModule in deployedModules: graalModulepath.extend([jmd.jarpath for jmd in deployedModule.modulepath if jmd.jarpath]) graalModulepath.append(deployedModule.jarpath) graalModulepath = _uniqify(graalModulepath) # Update added exports to include concealed JDK packages required by Graal addedExports = {} args = _extract_added_exports(args, addedExports) for deployedModule in deployedModules: for concealingModule, packages in deployedModule.concealedRequires.iteritems(): # No need to explicitly export JVMCI - it's exported via reflection if concealingModule != 'jdk.vm.ci': for package in packages: addedExports.setdefault(concealingModule + '/' + package, set()).add(deployedModule.name) for export, targets in addedExports.iteritems(): argsPrefix.append('--add-exports=' + export + '=' + ','.join(sorted(targets))) # Extend or set --module-path argument mpUpdated = False for mpIndex in range(len(args)): if args[mpIndex] == '--module-path': assert mpIndex + 1 < len(args), 'VM option ' + args[mpIndex] + ' requires an argument' args[mpIndex + 1] = os.pathsep.join(_uniqify(args[mpIndex + 1].split(os.pathsep) + graalModulepath)) mpUpdated = True break elif args[mpIndex].startswith('--module-path='): mp = args[mpIndex][len('--module-path='):] args[mpIndex] = '--module-path=' + os.pathsep.join(_uniqify(mp.split(os.pathsep) + graalModulepath)) mpUpdated = True break if not mpUpdated: argsPrefix.append('--module-path=' + os.pathsep.join(graalModulepath)) if '-version' in args: ignoredArgs = args[args.index('-version') + 1:] if len(ignoredArgs) > 0: mx.log("Warning: The following options will be ignored by the VM because they come after the '-version' argument: " + ' '.join(ignoredArgs)) return jdk.processArgs(argsPrefix + args, addDefaultArgs=addDefaultArgs)
def _parseVmArgs(args, addDefaultArgs=True): args = mx.expand_project_in_args(args, insitu=False) argsPrefix = [] jacocoArgs = mx_gate.get_jacoco_agent_args() if jacocoArgs: argsPrefix.extend(jacocoArgs) # add default graal.options.file options_file = join(mx.primary_suite().dir, 'graal.options') if exists(options_file): argsPrefix.append('-Dgraal.options.file=' + options_file) if isJDK8: argsPrefix.append('-Djvmci.class.path.append=' + os.pathsep.join((e.get_path() for e in _jvmci_classpath))) argsPrefix.append('-Xbootclasspath/a:' + os.pathsep.join( [dep.classpath_repr() for dep in _bootclasspath_appends])) else: deployedDists = [entry.dist() for entry in _jvmci_classpath] + \ [e for e in _bootclasspath_appends if e.isJARDistribution()] deployedModules = [as_java_module(dist, jdk) for dist in deployedDists] # Set or update module path to include Graal and its dependencies as modules graalModulepath = [] for deployedModule in deployedModules: graalModulepath.extend([ jmd.jarpath for jmd in deployedModule.modulepath if jmd.jarpath ]) graalModulepath.append(deployedModule.jarpath) graalModulepath = _uniqify(graalModulepath) # Update added exports to include concealed JDK packages required by Graal addedExports = {} args = _extract_added_exports(args, addedExports) for deployedModule in deployedModules: for concealingModule, packages in deployedModule.concealedRequires.iteritems( ): # No need to explicitly export JVMCI - it's exported via reflection if concealingModule != 'jdk.vm.ci': for package in packages: addedExports.setdefault( concealingModule + '/' + package, set()).add(deployedModule.name) for export, targets in addedExports.iteritems(): argsPrefix.append('--add-exports=' + export + '=' + ','.join(sorted(targets))) # Extend or set --module-path argument mpUpdated = False for mpIndex in range(len(args)): if args[mpIndex] == '--module-path': assert mpIndex + 1 < len(args), 'VM option ' + args[ mpIndex] + ' requires an argument' args[mpIndex + 1] = os.pathsep.join( _uniqify(args[mpIndex + 1].split(os.pathsep) + graalModulepath)) mpUpdated = True break elif args[mpIndex].startswith('--module-path='): mp = args[mpIndex][len('--module-path='):] args[mpIndex] = '--module-path=' + os.pathsep.join( _uniqify(mp.split(os.pathsep) + graalModulepath)) mpUpdated = True break if not mpUpdated: argsPrefix.append('--module-path=' + os.pathsep.join(graalModulepath)) if '-version' in args: ignoredArgs = args[args.index('-version') + 1:] if len(ignoredArgs) > 0: mx.log( "Warning: The following options will be ignored by the VM because they come after the '-version' argument: " + ' '.join(ignoredArgs)) return jdk.processArgs(argsPrefix + args, addDefaultArgs=addDefaultArgs)
def inspect(args): """launch a given program under the Inspector Run Maxine under the Inspector. The arguments accepted by this command are those accepted by the 'mx vm' command plus the Inspector specific options. To debug a program in the Inspector, simply replace 'vm' on the command line that launches the program with 'inspect'. Use "mx inspect --help" to see what the Inspector options are. These options must be specified with a '--' prefix so that they can be distinguished from the VM options. The inspect command also accepts the same system property related options as the 'image' command except that a '--' prefix must be used (e.g. '--os Darwin --bits 32'). Use "mx help image" for more detail. Use "mx vm -help" to see what the VM options are.""" saveClassDir = join(_vmdir, 'inspected_classes') maxvmOptions = os.getenv('MAXVM_OPTIONS', '').split() vmArgs = ['-XX:SaveClassDir=' + saveClassDir, '-XX:+TrapOnError'] + maxvmOptions insArgs = ['-vmdir=' + _vmdir] if not isdir(saveClassDir): os.makedirs(saveClassDir) sysProps = [] insCP = [] i = 0 remote = False while i < len(args): arg = args[i] if arg.startswith('-XX:LogFile='): logFile = arg.split('=', 1)[1] vmArgs += [arg] os.environ['TELE_LOG_FILE'] = 'tele-' + logFile elif arg in ['-cp', '-classpath']: vmArgs += [arg, args[i + 1]] insCP += [mx.expand_project_in_class_path_arg(args[i + 1])] i += 1 elif arg == '-jar': vmArgs += ['-jar', args[i + 1]] insCP += [args[i + 1]] i += 1 elif arg == '--remote': remote = True elif arg in ['--platform', '--cpu', '--isa', '--os', '--endianness', '--bits', '--page', '--nsig']: name = arg.lstrip('-') i += 1 value = args[i] sysProps += ['-Dmax.' + name + '=' + value] elif arg.startswith('--cp='): insCP += [arg[len('--cp='):]] elif arg.startswith('--'): # chomp leading '-' insArgs += [arg[1:]] elif arg.startswith('-XX:SaveClassDir='): vmArgs += [arg] saveClassDir = arg.split('=', 1)[1] if not isdir(saveClassDir): os.makedirs(saveClassDir) elif arg.startswith('-'): vmArgs += [arg] else: # This is the main class argument; copy it and any following # arguments to the VM verbatim vmArgs += args[i:] break i += 1 insCP += [saveClassDir] insCP = pathsep.join(insCP) insArgs += ['-cp=' + insCP] mx.expand_project_in_args(vmArgs) cmd = mx.java().format_cmd(sysProps + ['-cp', mx.classpath() + pathsep + insCP, 'com.sun.max.ins.MaxineInspector'] + insArgs + ['-a=' + ' '.join(vmArgs)]) if mx.get_os() == 'darwin' and not remote: # The -E option propagates the environment variables into the sudo process mx.run(['sudo', '-E', '-p', 'Debugging is a privileged operation on Mac OS X.\nPlease enter your "sudo" password:'] + cmd) else: mx.run(cmd)
def inspect(args): """launch a given program under the Inspector Run Maxine under the Inspector. The arguments accepted by this command are those accepted by the 'mx vm' command plus the Inspector specific options. To debug a program in the Inspector, simply replace 'vm' on the command line that launches the program with 'inspect'. Use "mx inspect --help" to see what the Inspector options are. These options must be specified with a '--' prefix so that they can be distinguished from the VM options. The inspect command also accepts the same system property related options as the 'image' command except that a '--' prefix must be used (e.g. '--os Darwin --bits 32'). Use "mx help image" for more detail. Use "mx vm -help" to see what the VM options are.""" saveClassDir = join(_vmdir, 'inspected_classes') maxvmOptions = os.getenv('MAXVM_OPTIONS', '').split() vmArgs = ['-XX:SaveClassDir=' + saveClassDir, '-XX:+TrapOnError'] + maxvmOptions insArgs = ['-vmdir=' + _vmdir] if not isdir(saveClassDir): os.makedirs(saveClassDir) sysProps = [] sysProps += ['-Xbootclasspath/a:' + mx.distribution('GRAAL').path] insCP = [] cwdArgs = check_cwd_change(args) cwd = cwdArgs[0] args = cwdArgs[1] i = 0 remote = False while i < len(args): arg = args[i] if arg.startswith('-XX:LogFile='): logFile = arg.split('=', 1)[1] vmArgs += [arg] os.environ['TELE_LOG_FILE'] = 'tele-' + logFile elif arg in ['-cp', '-classpath']: vmArgs += [arg, args[i + 1]] insCP += [mx.expand_project_in_class_path_arg(args[i + 1])] i += 1 elif arg == '-jar': vmArgs += ['-jar', args[i + 1]] insCP += [args[i + 1]] i += 1 elif arg == '--remote': remote = True elif arg in ['--platform', '--cpu', '--isa', '--os', '--endianness', '--bits', '--page', '--nsig']: name = arg.lstrip('-') i += 1 value = args[i] sysProps += ['-Dmax.' + name + '=' + value] elif arg.startswith('--cp='): insCP += [arg[len('--cp='):]] elif arg.startswith('--'): # chomp leading '-' insArgs += [arg[1:]] elif arg.startswith('-XX:SaveClassDir='): vmArgs += [arg] saveClassDir = arg.split('=', 1)[1] if not isdir(saveClassDir): os.makedirs(saveClassDir) elif arg.startswith('-'): vmArgs += [arg] else: # This is the main class argument; copy it and any following # arguments to the VM verbatim vmArgs += args[i:] break i += 1 insCP += [saveClassDir] insCP = pathsep.join(insCP) insArgs += ['-cp=' + insCP] mx.expand_project_in_args(vmArgs) cmd = mx.java().format_cmd(sysProps + ['-cp', sanitized_classpath() + pathsep + insCP, 'com.sun.max.ins.MaxineInspector'] + insArgs + ['-a=' + ' '.join(vmArgs)]) if mx.get_os() == 'darwin' and not remote: # The -E option propagates the environment variables into the sudo process mx.run(['sudo', '-E', '-p', 'Debugging is a privileged operation on Mac OS X.\nPlease enter your "sudo" password:'] + cmd, cwd=cwd) else: mx.run(cmd, cwd=cwd)
def _parseVmArgs(args, addDefaultArgs=True): args = mx.expand_project_in_args(args, insitu=False) argsPrefix = [] jacocoArgs = mx_gate.get_jacoco_agent_args() if jacocoArgs: argsPrefix.extend(jacocoArgs) # add default graal.options.file options_file = join(mx.primary_suite().dir, 'graal.options') if exists(options_file): argsPrefix.append('-Dgraal.options.file=' + options_file) if isJDK8: argsPrefix.append('-Djvmci.class.path.append=' + os.pathsep.join((e.get_path() for e in _jvmci_classpath))) argsPrefix.append('-Xbootclasspath/a:' + os.pathsep.join( [dep.classpath_repr() for dep in _bootclasspath_appends])) else: deployedDists = [entry.dist() for entry in _jvmci_classpath] + \ [e for e in _bootclasspath_appends if e.isJARDistribution()] deployedModules = [as_java_module(dist, jdk) for dist in deployedDists] # Set or update module path to include Graal and its dependencies as modules jdkModuleNames = frozenset([m.name for m in jdk.get_modules()]) graalModulepath = [] graalUpgrademodulepath = [] def _addToModulepath(modules): for m in modules: if m.jarpath: modulepath = graalModulepath if m.name not in jdkModuleNames else graalUpgrademodulepath if m not in modulepath: modulepath.append(m) for deployedModule in deployedModules: _addToModulepath(deployedModule.modulepath) _addToModulepath([deployedModule]) # Extend or set --module-path argument mpUpdated = False for mpIndex in range(len(args)): assert not args[mpIndex].startswith('--upgrade-module-path') if args[mpIndex] == '--module-path': assert mpIndex + 1 < len(args), 'VM option ' + args[ mpIndex] + ' requires an argument' args[mpIndex + 1] = os.pathsep.join( _uniqify(args[mpIndex + 1].split(os.pathsep) + [m.jarpath for m in graalModulepath])) mpUpdated = True break elif args[mpIndex].startswith('--module-path='): mp = args[mpIndex][len('--module-path='):] args[mpIndex] = '--module-path=' + os.pathsep.join( _uniqify( mp.split(os.pathsep) + [m.jarpath for m in graalModulepath])) mpUpdated = True break if not mpUpdated: argsPrefix.append( '--module-path=' + os.pathsep.join([m.jarpath for m in graalModulepath])) if graalUpgrademodulepath: argsPrefix.append( '--upgrade-module-path=' + os.pathsep.join([m.jarpath for m in graalUpgrademodulepath])) if '-version' in args: ignoredArgs = args[args.index('-version') + 1:] if len(ignoredArgs) > 0: mx.log( "Warning: The following options will be ignored by the VM because they come after the '-version' argument: " + ' '.join(ignoredArgs)) return jdk.processArgs(argsPrefix + args, addDefaultArgs=addDefaultArgs)