def _unittest_config_participant(config): vmArgs, mainClass, mainClassArgs = config cpIndex, cp = mx.find_classpath_arg(vmArgs) if cp: cp = _uniqify(cp.split(os.pathsep)) if isJDK8: # Remove entries from class path that are in Graal or on the boot class path redundantClasspathEntries = set() for dist in [entry.dist() for entry in _jvmci_classpath]: redundantClasspathEntries.update((d.output_dir() for d in dist.archived_deps() if d.isJavaProject())) redundantClasspathEntries.add(dist.path) cp = os.pathsep.join([e for e in cp if e not in redundantClasspathEntries]) vmArgs[cpIndex] = cp else: redundantClasspathEntries = set() for dist in [entry.dist() for entry in _jvmci_classpath] + _bootclasspath_appends: redundantClasspathEntries.update(mx.classpath(dist, preferProjects=False, jdk=jdk).split(os.pathsep)) redundantClasspathEntries.update(mx.classpath(dist, preferProjects=True, jdk=jdk).split(os.pathsep)) if hasattr(dist, 'overlaps'): for o in dist.overlaps: path = mx.distribution(o).classpath_repr() if path: redundantClasspathEntries.add(path) # Remove entries from the class path that are in the deployed modules cp = [classpathEntry for classpathEntry in cp if classpathEntry not in redundantClasspathEntries] vmArgs[cpIndex] = os.pathsep.join(cp) if isJDK8: # Run the VM in a mode where application/test classes can # access JVMCI loaded classes. vmArgs.append('-XX:-UseJVMCIClassLoader') return (vmArgs, mainClass, mainClassArgs)
def _path_args(depNames=None): """ Gets the VM args for putting the dependencies named in `depNames` on the class path and module path (if running on JDK9 or later). :param names: a Dependency, str or list containing Dependency/str objects. If None, then all registered dependencies are used. """ jdk = mx.get_jdk() if jdk.javaCompliance >= '1.9': modules = [ as_java_module(dist, jdk) for dist in _suite.dists if get_java_module_info(dist) ] if modules: # Partition resources between the class path and module path modulepath = [] classpath = [] cpEntryToModule = {m.dist.path: m for m in modules} for e in mx.classpath(depNames).split(os.pathsep): if cpEntryToModule.has_key(e): modulepath.append(cpEntryToModule[e].jarpath) else: classpath.append(e) # The Truffle modules must be eagerly loaded as they could be referenced from # the main class hence the --add-modules argument return [ '--add-modules=' + ','.join([m.name for m in modules]), '--module-path=' + os.pathsep.join(modulepath), '-cp', os.pathsep.join(classpath) ] return ['-cp', mx.classpath(depNames)]
def getPythonBenchmarksProfiling(vm, profile_option=None): success, error, matcher = getSuccessErrorMatcher() benchmarks = pythonProfilerBenchmarks tests = [] for benchmark, arg in benchmarks.iteritems(): script = "edu.uci.python.benchmark/src/benchmarks/" + benchmark + ".py" if (profile_option is not None): cmd = [ '-cp', mx.classpath("edu.uci.python.shell"), "edu.uci.python.shell.Shell", script, arg, profile_option, "-sort" ] else: cmd = [ '-cp', mx.classpath("edu.uci.python.shell"), "edu.uci.python.shell.Shell", script, arg ] vmOpts = ['-Xms2g', '-Xmx2g'] tests.append( ZippyTest("Python-" + benchmark, cmd, successREs=[success], failureREs=[error], scoreMatchers=[matcher], vmOpts=vmOpts)) return tests
def _path_args(depNames=None): """ Gets the VM args for putting the dependencies named in `depNames` on the class path and module path (if running on JDK9 or later). :param names: a Dependency, str or list containing Dependency/str objects. If None, then all registered dependencies are used. """ jdk = mx.get_jdk() if jdk.javaCompliance >= '1.9': modules = [as_java_module(dist, jdk) for dist in _suite.dists if get_java_module_info(dist)] if modules: # Partition resources between the class path and module path modulepath = [] classpath = [] cpEntryToModule = {m.dist.path : m for m in modules} for e in mx.classpath(depNames).split(os.pathsep): if cpEntryToModule.has_key(e): modulepath.append(cpEntryToModule[e].jarpath) else: classpath.append(e) # The Truffle modules must be eagerly loaded as they could be referenced from # the main class hence the --add-modules argument return ['--add-modules=' + ','.join([m.name for m in modules]), '--module-path=' + os.pathsep.join(modulepath), '-cp', os.pathsep.join(classpath)] return ['-cp', mx.classpath(depNames)]
def build(self): if hasattr(self.args, "jdt") and self.args.jdt and not self.args.force_javac: return _output_dir = join(_suite.dir, self.subject.outputDir) cp = mx.classpath('com.oracle.truffle.js.snapshot') tool_main_class = 'com.oracle.truffle.js.snapshot.SnapshotTool' _output_dir_bin = join(_output_dir, "bin") mx.ensure_dir_exists(_output_dir_bin) mx.run_java(['-cp', cp, tool_main_class, '--binary', '--internal'] + ['--outdir=' + _output_dir_bin], cwd=_output_dir_bin) _output_dir_src_gen = join(_output_dir, "src_gen") mx.ensure_dir_exists(_output_dir_src_gen) mx.run_java(['-cp', cp, tool_main_class, '--java', '--internal'] + ['--outdir=' + _output_dir_src_gen], cwd=_output_dir_src_gen) compliance = mx.JavaCompliance("1.8") jdk = mx.get_jdk(compliance, tag=mx.DEFAULT_JDK_TAG) java_file_list = [] for root, _, files in os.walk(_output_dir_src_gen, followlinks=True): java_file_list += [ join(root, name) for name in files if name.endswith('.java') ] java_file_list = sorted(java_file_list) # for reproducibility mx.run([ jdk.javac, '-source', str(compliance), '-target', str(compliance), '-classpath', mx.classpath('com.oracle.truffle.js.parser'), '-d', _output_dir_bin ] + java_file_list)
def _unittest_config_participant(config): """modifies the classpath to use the Sulong distribution jars instead of the classfiles to enable the use of Java's ServiceLoader""" (vmArgs, mainClass, mainClassArgs) = config cpIndex, _ = mx.find_classpath_arg(vmArgs) junitCp = mx.classpath("com.oracle.mxtool.junit") sulongCp = ':'.join([mx.classpath(mx.distribution(distr), jdk=mx.get_jdk(tag='jvmci')) for distr in sulongDistributions]) vmArgs[cpIndex] = junitCp + ":" + sulongCp return (vmArgs, mainClass, mainClassArgs)
def unittest_use_distribution_jars(config): """use the distribution jars instead of the class files""" vmArgs, mainClass, mainClassArgs = config cpIndex, _ = mx.find_classpath_arg(vmArgs) junitCP = [mx.classpath("com.oracle.mxtool.junit")] rubyCP = [mx.classpath(mx.distribution(distr)) for distr in rubyDists] vmArgs[cpIndex] = ":".join(junitCP + rubyCP) return (vmArgs, mainClass, mainClassArgs)
def create_classpath(self, benchArg): harness_project = RenaissanceNativeImageBenchmarkSuite.RenaissanceProject( 'harness', benchmark_scalaversion(benchArg), self) group_project = RenaissanceNativeImageBenchmarkSuite.RenaissanceProject( benchmark_group(benchArg), benchmark_scalaversion(benchArg), self, harness_project) return ':'.join( [mx.classpath(harness_project), mx.classpath(group_project)])
def _unittest_config_participant(config): vmArgs, mainClass, mainClassArgs = config cpIndex, cp = mx.find_classpath_arg(vmArgs) if cp: cp = _uniqify(cp.split(os.pathsep)) if isJDK8: # Remove entries from class path that are in Graal or on the boot class path redundantClasspathEntries = set() for dist in [entry.dist() for entry in _jvmci_classpath]: redundantClasspathEntries.update( (d.output_dir() for d in dist.archived_deps() if d.isJavaProject())) redundantClasspathEntries.add(dist.path) cp = os.pathsep.join( [e for e in cp if e not in redundantClasspathEntries]) vmArgs[cpIndex] = cp else: redundantClasspathEntries = set() for dist in [entry.dist() for entry in _jvmci_classpath ] + _bootclasspath_appends: redundantClasspathEntries.update( mx.classpath(dist, preferProjects=False, jdk=jdk).split(os.pathsep)) redundantClasspathEntries.update( mx.classpath(dist, preferProjects=True, jdk=jdk).split(os.pathsep)) if hasattr(dist, 'overlaps'): for o in dist.overlaps: path = mx.distribution(o).classpath_repr() if path: redundantClasspathEntries.add(path) # Remove entries from the class path that are in the deployed modules cp = [ classpathEntry for classpathEntry in cp if classpathEntry not in redundantClasspathEntries ] vmArgs[cpIndex] = os.pathsep.join(cp) # JVMCI is dynamically exported to Graal when JVMCI is initialized. This is too late # for the junit harness which uses reflection to find @Test methods. In addition, the # tests widely use JVMCI classes so JVMCI needs to also export all its packages to # ALL-UNNAMED. jvmci = [ m for m in jdk.get_modules() if m.name == 'jdk.internal.vm.ci' ][0] vmArgs.extend([ '--add-exports=' + jvmci.name + '/' + p + '=jdk.internal.vm.compiler,ALL-UNNAMED' for p in jvmci.packages ]) if isJDK8: # Run the VM in a mode where application/test classes can # access JVMCI loaded classes. vmArgs.append('-XX:-UseJVMCIClassLoader') return (vmArgs, mainClass, mainClassArgs)
def create_pre014_classpath(self, benchmarkName): custom_harness = pre014_requires_recompiled_harness( benchmarkName, self.version()) harness_project = RenaissanceNativeImageBenchmarkSuite.RenaissancePre014Project( 'harness', custom_harness, self) group_project = RenaissanceNativeImageBenchmarkSuite.RenaissancePre014Project( pre014_benchmark_group(benchmarkName, self.version()), custom_harness, self, harness_project) return ':'.join( [mx.classpath(harness_project), mx.classpath(group_project)])
def _unittest_config_participant(config): """modifies the classpath to use the Sulong distribution jars instead of the classfiles to enable the use of Java's ServiceLoader""" (vmArgs, mainClass, mainClassArgs) = config cpIndex, _ = mx.find_classpath_arg(vmArgs) junitCp = mx.classpath("com.oracle.mxtool.junit") sulongCp = ':'.join([ mx.classpath(mx.distribution(distr), jdk=mx.get_jdk(tag='jvmci')) for distr in sulongDistributions ]) vmArgs[cpIndex] = junitCp + ":" + sulongCp return (vmArgs, mainClass, mainClassArgs)
def getPythonBenchmarksProfiling(vm, profile_option=None): success, error, matcher = getSuccessErrorMatcher() benchmarks = pythonProfilerBenchmarks tests = [] for benchmark, arg in benchmarks.iteritems(): script = "edu.uci.python.benchmark/src/benchmarks/" + benchmark + ".py" if (profile_option is not None): cmd = ['-cp', mx.classpath("edu.uci.python.shell"), "edu.uci.python.shell.Shell", script, arg, profile_option, "-sort"] else : cmd = ['-cp', mx.classpath("edu.uci.python.shell"), "edu.uci.python.shell.Shell", script, arg] vmOpts = ['-Xms2g', '-Xmx2g'] tests.append(ZippyTest("Python-" + benchmark, cmd, successREs=[success], failureREs=[error], scoreMatchers=[matcher], vmOpts=vmOpts)) return tests
def build(self): outputDir = self.subject.output_dir() snapshotToolDistribution = 'graal-js:TRUFFLE_JS_SNAPSHOT_TOOL' pythonCmd = join(_suite.mxDir, 'python2/python') moduleSet = self.modulesToSnapshot() outputDirBin = join(outputDir, 'lib') mx.ensure_dir_exists(outputDirBin) macroFiles = [] # Lttng is disabled by default on all platforms macroFiles.append('src/nolttng_macros.py') # performance counters are enabled by default only on Windows if _currentOs is not 'windows': macroFiles.append('src/noperfctr_macros.py') # DTrace is disabled explicitly by the --without-dtrace option # ETW is enabled by default only on Windows if _currentOs is not 'windows': macroFiles.append('src/notrace_macros.py') mx.run([pythonCmd, 'tools/expand-js-modules.py', outputDir] + [join('lib', m) for m in moduleSet] + macroFiles, cwd=_suite.dir) if not (hasattr(self.args, "jdt") and self.args.jdt and not self.args.force_javac): mx.run_java(['-cp', mx.classpath([snapshotToolDistribution]), mx.distribution(snapshotToolDistribution).mainClass, '--binary', '--outdir=' + outputDirBin, '--indir=' + outputDirBin] + ['--file=' + m for m in moduleSet], cwd=outputDirBin) mx.run([pythonCmd, join(_suite.dir, 'tools/snapshot2c.py'), 'node_snapshots.h'] + [join('lib', m + '.bin') for m in moduleSet], cwd=outputDir)
def prepareJalangiCmdLine(args): from mx_graal_nodejs import _setEnvVar, setupNodeEnvironment _node = mx.suite('graal-nodejs') mode, vmArgs, progArgs = setupNodeEnvironment(args) _setEnvVar('NODE_JVM_CLASSPATH', mx.classpath(['NODEPROF'])) _setEnvVar('NODE_JVM_OPTIONS', ' '.join(vmArgs)) return [join(_node.dir, 'out', mode, 'node')] + progArgs
def ruby_command(args): """runs Ruby""" java_home = os.getenv('JAVA_HOME', '/usr') java = os.getenv('JAVACMD', java_home + '/bin/java') argv0 = java vmArgs, rubyArgs, user_classpath, print_command, classic = extractArguments( args) classpath = mx.classpath(['TRUFFLE_API', 'RUBY']).split(':') truffle_api, classpath = classpath[0], classpath[1:] classpath += user_classpath assert os.path.basename(truffle_api) == "truffle-api.jar" vmArgs = [ # '-Xss2048k', '-Xbootclasspath/p:' + truffle_api, '-cp', ':'.join(classpath), ] + vmArgs vmArgs = vmArgs + ['org.jruby.Main'] if not classic: vmArgs = vmArgs + ['-X+T'] allArgs = vmArgs + rubyArgs env = setup_jruby_home() if print_command: if mx.get_opts().verbose: log('Environment variables:') for key in sorted(env.keys()): log(key + '=' + env[key]) log(java + ' ' + ' '.join(map(pipes.quote, allArgs))) return os.execve(java, [argv0] + allArgs, env)
def setupNodeEnvironment(args): javaHome = _getJdkHome() _setEnvVar('JAVA_HOME', javaHome) if mx.suite('compiler', fatalIfMissing=False) is None: _setEnvVar('GRAAL_SDK_JAR_PATH', mx.distribution('sdk:GRAAL_SDK').path) _setEnvVar('TRUFFLE_JAR_PATH', mx.distribution('truffle:TRUFFLE_API').path) _setEnvVar('LAUNCHER_COMMON_JAR_PATH', mx.distribution('sdk:LAUNCHER_COMMON').path) _setEnvVar('TRUFFLENODE_JAR_PATH', mx.distribution('TRUFFLENODE').path) _setEnvVar('NODE_JVM_CLASSPATH', mx.classpath(['tools:CHROMEINSPECTOR', 'tools:TRUFFLE_PROFILER', 'TRUFFLENODE'])) setLibraryPath() prevPATH = os.environ['PATH'] _setEnvVar('PATH', "%s:%s" % (join(_suite.mxDir, 'fake_launchers'), prevPATH)) args = args if args else [] mode, vmArgs, progArgs = _parseArgs(args) if mx.suite('graal-enterprise', fatalIfMissing=False): # explicitly require the enterprise compiler configuration vmArgs += ['-Dgraal.CompilerConfiguration=enterprise'] if mx.suite('compiler', fatalIfMissing=False): vmArgs += ['-Djvmci.Compiler=graal', '-XX:+UnlockExperimentalVMOptions', '-XX:+EnableJVMCI'] if isinstance(_suite, BinarySuite): mx.logv('%s is a binary suite' % _suite.name) tarfilepath = mx.distribution('TRUFFLENODE_GRAALVM_SUPPORT').path with tarfile.open(tarfilepath, 'r:') as tar: mx.logv('Extracting {} to {}'.format(tarfilepath, _suite.dir)) tar.extractall(_suite.dir) return mode, vmArgs, progArgs
def olc(args): """offline compile a list of methods See Patterns below for a description of the format expected for "patterns..." The output traced by this command is not guaranteed to be the same as the output for a compilation performed at runtime. The code produced by a compiler is sensitive to the compilation context such as what classes have been resolved etc. Use "mx olc -help" to see what other options this command accepts. --- Patterns --- {0}""" i = 0 insCP = [] olcArgs = [] while i < len(args): arg = args[i] if arg in ['-cp', '-classpath']: insCP += [mx.expand_project_in_class_path_arg(args[i + 1])] i += 1 else: olcArgs += [arg] i += 1 insCP = pathsep.join(insCP) mx.run_java([ '-ea', '-esa', '-cp', mx.classpath() + pathsep + insCP, 'com.oracle.max.vm.ext.maxri.Compile' ] + olcArgs)
def build(self): outputDir = self.subject.output_dir() snapshotToolDistribution = 'graal-js:TRUFFLE_JS_SNAPSHOT_TOOL' moduleSet = self.modulesToSnapshot() outputDirBin = join(outputDir, 'lib') mx.ensure_dir_exists(outputDirBin) macroFiles = [join('tools', 'js2c_macros', 'check_macros.py')] # DTrace is disabled explicitly by the --without-dtrace option # ETW is enabled by default only on Windows if not _is_windows: macroFiles.append(join('tools', 'js2c_macros', 'notrace_macros.py')) mx.run(python_cmd() + [join('tools', 'expand-js-modules.py'), outputDir] + [join('lib', m) for m in moduleSet] + macroFiles, cwd=_suite.dir) if not (hasattr(self.args, "jdt") and self.args.jdt and not self.args.force_javac): mx.run_java([ '-cp', mx.classpath([snapshotToolDistribution]), mx.distribution(snapshotToolDistribution).mainClass, '--binary', '--wrapped', '--outdir=' + outputDirBin, '--indir=' + outputDirBin ] + ['--file=' + m for m in moduleSet], cwd=outputDirBin) mx.run( python_cmd() + [join(_suite.dir, 'tools', 'snapshot2c.py'), 'node_snapshots.h'] + [join('lib', m + '.bin') for m in moduleSet], cwd=outputDir)
def jacocoreport(args): """create a JaCoCo coverage report Creates the report from the 'jacoco.exec' file in the current directory. Default output directory is 'coverage', but an alternative can be provided as an argument.""" dist_name = "MX_JACOCO_REPORT" dist = mx.distribution(dist_name) jdk = mx.get_jdk(dist.javaCompliance) out = 'coverage' if len(args) == 1: out = args[0] elif len(args) > 1: mx.abort('jacocoreport takes only one argument : an output directory') # list of strings of the form "project-dir:binary-dir" includedirs = [] for p in mx.projects(): projsetting = getattr(p, 'jacoco', '') if projsetting == 'include' or projsetting == '': if isinstance(p, mx.ClasspathDependency): includedirs.append(p.dir + ":" + p.classpath_repr(jdk)) mx.run_java([ '-cp', mx.classpath([dist_name], jdk=jdk), '-jar', dist.path, '--in', 'jacoco.exec', '--out', out ] + sorted(includedirs), jdk=jdk)
def do_run_python(args, extraVmArgs=None, jdk=None, **kwargs): check_vm_env = os.environ.get('ZIPPY_MUST_USE_GRAAL') if check_vm_env: if check_vm_env == '1': check_vm(must_be_jvmci=True) elif check_vm_env == '0': check_vm() vmArgs, zippyArgs = mx.extract_VM_args(args) vmArgs = ['-cp', mx.classpath(["edu.uci.python"])] if not jdk: jdk = get_jdk() vmArgs += _graal_heuristics_options() # default: assertion checking is enabled if extraVmArgs is None or not '-da' in extraVmArgs: vmArgs += ['-ea', '-esa'] if extraVmArgs: vmArgs += extraVmArgs # vmArgs = _sanitize_vmArgs(jdk, vmArgs) # if len(zippyArgs) > 0: vmArgs.append("edu.uci.python.shell.Shell") # else: # print 'Interactive shell is not implemented yet..' # sys.exit(1) return mx.run_java(vmArgs + args, jdk=jdk, **kwargs)
def jaotc_test(args): """run (acceptance) tests for the AOT compiler (jaotc)""" _check_jaotc_support() all_tests = ['HelloWorld', 'java.base', 'javac'] parser = ArgumentParser(prog='mx jaotc-test') parser.add_argument("--list", default=None, action="store_true", help="Print the list of available jaotc tests.") parser.add_argument('tests', help='tests to run (omit to run all tests)', nargs=ZERO_OR_MORE) args = parser.parse_args(args) if args.list: print("The following jaotc tests are available:\n") for name in all_tests: print(" " + name) return tests = args.tests or all_tests for test in tests: mx.log('Testing `{}`'.format(test)) if test == 'HelloWorld': test_class(classpath=mx.classpath('JAOTC_TEST'), main_class='jdk.tools.jaotc.test.HelloWorld') elif test == 'javac': test_javac('jdk.tools.jaotc') elif test == 'java.base': test_modules( classpath=mx.project('jdk.tools.jaotc.test').output_dir(), main_class='jdk.tools.jaotc.test.HelloWorld', modules=['java.base']) else: mx.abort('Unknown jaotc test: {}'.format(test))
def ruby_command(args): """runs Ruby""" java_home = os.getenv('JAVA_HOME', '/usr') java = os.getenv('JAVACMD', java_home + '/bin/java') argv0 = java vmArgs, rubyArgs, user_classpath, print_command = extractArguments(args) classpath = mx.classpath(['TRUFFLE_API', 'RUBY']).split(':') truffle_api, classpath = classpath[0], classpath[1:] assert os.path.basename(truffle_api) == "truffle-api.jar" # Give precedence to graal classpath and VM options classpath = user_classpath + classpath vmArgs = vmArgs + [ # '-Xss2048k', '-Xbootclasspath/a:' + truffle_api, '-cp', ':'.join(classpath), 'org.jruby.truffle.Main' ] allArgs = vmArgs + ['-X+T'] + rubyArgs env = setup_jruby_home() if print_command: if mx.get_opts().verbose: log('Environment variables:') for key in sorted(env.keys()): log(key + '=' + env[key]) log(java + ' ' + ' '.join(map(pipes.quote, allArgs))) return os.execve(java, [argv0] + allArgs, env)
def _find_classes_by_annotated_methods(annotations, suite): """ Scan distributions from binary suite dependencies for classes contain at least one method with an annotation from 'annotations' and return a dictionary from fully qualified class names to the distribution containing the class. """ binarySuiteDists = [ d for d in mx.dependencies(opt_limit_to_suite=True) if d.isJARDistribution() and isinstance(d.suite, mx.BinarySuite) and ( not suite or suite == d.suite) ] if len(binarySuiteDists) != 0: # Ensure Java support class is built mx.build(['--dependencies', 'com.oracle.mxtool.junit']) # Create map from jar file to the binary suite distribution defining it jars = {d.classpath_repr(): d for d in binarySuiteDists} cp = mx.classpath(['com.oracle.mxtool.junit'] + [d.name for d in binarySuiteDists]) out = mx.OutputCapture() mx.run_java(['-cp', cp] + ['com.oracle.mxtool.junit.FindClassesByAnnotatedMethods'] + annotations + jars.keys(), out=out) candidates = {} for line in out.data.strip().split('\n'): name, jar = line.split(' ') # Record class name to the binary suite distribution containing it candidates[name] = jars[jar] return candidates return {}
def testgen(args): '''generate the expected output for unit tests, and All/Failing test classes''' parser = ArgumentParser(prog='r testgen') parser.add_argument('--tests', action='store', default=_all_unit_tests(), help='pattern to match test classes') args = parser.parse_args(args) # check we are in the home directory if os.getcwd() != _fastr_suite.dir: mx.abort('must run rtestgen from FastR home directory') # check the version of GnuR against FastR try: fastr_version = subprocess.check_output([mx.get_jdk().java, '-cp', mx.classpath('com.oracle.truffle.r.runtime'), 'com.oracle.truffle.r.runtime.RVersionNumber']) gnur_version = subprocess.check_output(['R', '--version']) if not gnur_version.startswith(fastr_version): mx.abort('R version is incompatible with FastR, please update to ' + fastr_version) except subprocess.CalledProcessError: mx.abort('RVersionNumber.main failed') # clean the test project to invoke the test analyzer AP testOnly = ['--projects', 'com.oracle.truffle.r.test'] mx.clean(['--no-dist', ] + testOnly) mx.build(testOnly) # now just invoke junit with the appropriate options mx.log("generating expected output for packages: ") for pkg in args.tests.split(','): mx.log(" " + str(pkg)) junit(['--tests', args.tests, '--gen-expected-output', '--gen-expected-quiet'])
def jol(args): """Java Object Layout""" joljar = mx.library('JOL_CLI').get_path(resolve=True) commands = [ 'estimates', 'externals', 'footprint', 'heapdump', 'heapdumpstats', 'idealpack', 'internals', 'shapes', 'string-compress', 'help' ] command = 'internals' if len(args) == 0: command = 'help' elif args[0] in commands: command, args = args[0], args[1:] # classpath operations if command in ['estimates', 'externals', 'footprint', 'internals']: candidates = mx.findclass( args, logToConsole=False, matcher=lambda s, classname: s == classname or classname.endswith( '.' + s) or classname.endswith('$' + s)) if len(candidates) > 0: args = mx.select_items(sorted(candidates)) if len(args) > 0: args = ['-cp', mx.classpath(jdk=mx.get_jdk())] + args mx.run_java([ '-javaagent:' + joljar, '-cp', joljar, 'org.openjdk.jol.Main', command ] + args)
def do_run_r(args, command, extraVmArgs=None, jdk=None, nonZeroIsFatal=True): ''' This is the basic function that runs a FastR process, where args have already been parsed. Args: args: a list of command arguments command: e.g. 'R', implicitly defines the entry class (can be None for AOT) extraVmArgs: additional vm arguments jdk: jdk (an mx.JDKConfig instance) to use nonZeroIsFatal: whether to terminate the execution run fails By default a non-zero return code will cause an mx.abort, unless nonZeroIsFatal=False The assumption is that the VM is already built and available. ''' setREnvironment() if not jdk: jdk = get_default_jdk() vmArgs = ['-cp', mx.classpath(_r_command_project)] vmArgs += _graal_options() if extraVmArgs is None or not '-da' in extraVmArgs: # unless explicitly disabled we enable assertion checking vmArgs += ['-ea', '-esa'] if extraVmArgs: vmArgs += extraVmArgs vmArgs = _sanitize_vmArgs(jdk, vmArgs) if command: vmArgs.append(_command_class_dict[command.lower()]) return mx.run_java(vmArgs + args, nonZeroIsFatal=nonZeroIsFatal, jdk=jdk)
def rcmplib(args): '''compare FastR library R sources against GnuR''' parser = ArgumentParser(prog='mx rcmplib') parser.add_argument('--gnurhome', action='store', help='path to GnuR sources', required=True) parser.add_argument('--package', action='store', help='package to check', default="base") parser.add_argument('--paths', action='store_true', help='print full paths of files that differ') parser.add_argument('--diffapp', action='store', help='diff application', default="diff") args = parser.parse_args(args) cmpArgs = [] cmpArgs.append("--gnurhome") cmpArgs.append(args.gnurhome) cmpArgs.append("--package") cmpArgs.append(args.package) if args.paths: cmpArgs.append("--paths") cmpArgs.append("--diffapp") cmpArgs.append(args.diffapp) cp = mx.classpath([pcp.name for pcp in mx.projects_opt_limit_to_suites()]) mx.run_java( ['-cp', cp, 'com.oracle.truffle.r.test.tools.cmpr.CompareLibR'] + cmpArgs)
def _run_test_suite(location, library_names, custom_args, default_vm_args, max_heap, stack_size, main_class, nonZeroIsFatal, cwd): _fetch_test_suite(location, library_names) _vm_args, _prog_args = parse_js_args(custom_args) _vm_args = _append_default_js_vm_args(vm_args=_vm_args, max_heap=max_heap, stack_size=stack_size) _cp = mx.classpath(['TRUFFLE_JS_TESTS'] + (['tools:CHROMEINSPECTOR', 'tools:TRUFFLE_PROFILER'] if mx.suite('tools', fatalIfMissing=False) is not None else [])) _vm_args = ['-ea', '-esa', '-cp', _cp] + default_vm_args + _vm_args return mx.run_java(_vm_args + [main_class] + _prog_args, nonZeroIsFatal=nonZeroIsFatal, cwd=cwd)
def _sigtest_generate(args, suite=None, projects=None): """run sigtest generator for Java projects with API""" sigtestlib = mx.library('SIGTEST').get_path(resolve=True) nonTestProjects = [p for p in mx.projects() if _should_test_project(p)] if not nonTestProjects: return 0 javaCompliance = max([p.javaCompliance for p in nonTestProjects]) for p in nonTestProjects: sigtestResults = p.dir + os.sep + 'snapshot.sigtest' jdk = mx.get_jdk(javaCompliance) cmd = [ '-cp', mx._cygpathU2W(sigtestlib), 'com.sun.tdk.signaturetest.Setup', '-Static', '-FileName', sigtestResults, '-ClassPath', mx.classpath(p, jdk=jdk) + os.pathsep + jdk.bootclasspath(), ] for pkg in mx._find_packages(p): cmd = cmd + ['-PackageWithoutSubpackages', pkg] exitcode = mx.run_java(cmd, nonZeroIsFatal=False, jdk=mx.get_jdk(javaCompliance)) if exitcode != 95: mx.abort('Exit code was ' + str(exitcode) + ' while generating ' + sigtestResults) if not exists(sigtestResults): mx.abort('Cannot generate ' + sigtestResults) mx.log("Sigtest snapshot generated to " + sigtestResults) return 0
def rbdiag(args): '''Diagnoses FastR builtins -v Verbose output including the list of unimplemented specializations -n Ignore RNull as an argument type -m Ignore RMissing as an argument type --sweep Performs the 'chimney-sweeping'. The sample combination selection method is determined automatically. --sweep-lite Performs the 'chimney-sweeping'. The diagonal sample selection method is used. --sweep-total Performs the 'chimney-sweeping'. The total sample selection method is used. If no builtin is specified, all registered builtins are diagnosed. Examples: mx rbdiag mx rbdiag colSums colMeans -v mx rbdiag scan -m -n mx rbdiag colSums --sweep ''' cp = mx.classpath('com.oracle.truffle.r.nodes.test') setREnvironment() os.environ["FASTR_TESTGEN_GNUR"] = "internal" # this should work for Linux and Mac: os.environ["TZDIR"] = "/usr/share/zoneinfo/" mx.run_java(['-cp', cp, 'com.oracle.truffle.r.nodes.test.RBuiltinDiagnostics'] + args)
def microbench(args): """run JMH microbenchmark projects""" parser = ArgumentParser( prog='mx microbench', description=microbench.__doc__, usage="%(prog)s [command options|VM options] [-- [JMH options]]") parser.add_argument('--jar', help='Explicitly specify micro-benchmark location') known_args, args = parser.parse_known_args(args) vmArgs, jmhArgs = mx.extract_VM_args(args, useDoubleDash=True) if JVMCI_VERSION < 9: if isJVMCIEnabled( get_vm()) and '-XX:-UseJVMCIClassLoader' not in vmArgs: vmArgs = ['-XX:-UseJVMCIClassLoader'] + vmArgs # look for -f in JMH arguments forking = True for i in range(len(jmhArgs)): arg = jmhArgs[i] if arg.startswith('-f'): if arg == '-f' and (i + 1) < len(jmhArgs): arg += jmhArgs[i + 1] try: if int(arg[2:]) == 0: forking = False except ValueError: pass if known_args.jar: # use the specified jar args = ['-jar', known_args.jar] if not forking: args += vmArgs else: # find all projects with a direct JMH dependency jmhProjects = [] for p in mx.projects_opt_limit_to_suites(): if 'JMH' in [x.name for x in p.deps]: jmhProjects.append(p.name) cp = mx.classpath(jmhProjects) # execute JMH runner args = ['-cp', cp] if not forking: args += vmArgs args += ['org.openjdk.jmh.Main'] if forking: jdk = get_jvmci_jdk() jvm = get_vm() def quoteSpace(s): if " " in s: return '"' + s + '"' return s forkedVmArgs = map(quoteSpace, jdk.parseVmArgs(vmArgs)) args += ['--jvmArgsPrepend', ' '.join(['-' + jvm] + forkedVmArgs)] run_vm(args + jmhArgs)
def test(args): """run some or all of the Maxine tests The Maxine sources include a variety of tests that can be run by a special launcher. These include JUnit tests, VM micro tests, certain benchmark suites and output comparison tests, amongst others. Use "mx test -help" to see what other options this command accepts.""" maxineTesterDir = join(_maxine_home, 'maxine-tester') if isdir(maxineTesterDir): for root, _, files in os.walk(maxineTesterDir): for name in files: if name.rsplit(', ', 1) in ['stdout', 'stderr', 'passed', 'failed', 'command']: os.remove(join(root, name)) else: os.mkdir(maxineTesterDir) class Tee: def __init__(self, f): self.f = f def eat(self, line): mx.log(line.rstrip()) self.f.write(line) console = join(maxineTesterDir, 'console') with open(console, 'w', 0) as f: tee = Tee(f) java = mx.java() mx.run_java(['-cp', mx.classpath(), 'test.com.sun.max.vm.MaxineTester', '-output-dir=maxine-tester', '-refvm=' + java.java, '-refvm-args=' + ' '.join(java.java_args)] + args, out=tee.eat, err=subprocess.STDOUT)
def _find_classes_by_annotated_methods(annotations, suite): """ Scan distributions from binary suite dependencies for classes contain at least one method with an annotation from 'annotations' and return a dictionary from fully qualified class names to the distribution containing the class. """ binarySuiteDists = [d for d in mx.dependencies(opt_limit_to_suite=True) if d.isJARDistribution() and isinstance(d.suite, mx.BinarySuite) and (not suite or suite == d.suite)] if len(binarySuiteDists) != 0: # Ensure Java support class is built mx.build(['--dependencies', 'com.oracle.mxtool.junit']) # Create map from jar file to the binary suite distribution defining it jars = {d.classpath_repr() : d for d in binarySuiteDists} cp = mx.classpath(['com.oracle.mxtool.junit'] + [d.name for d in binarySuiteDists]) out = mx.OutputCapture() mx.run_java(['-cp', cp] + ['com.oracle.mxtool.junit.FindClassesByAnnotatedMethods'] + annotations + jars.keys(), out=out) candidates = {} for line in out.data.strip().split('\n'): name, jar = line.split(' ') # Record class name to the binary suite distribution containing it candidates[name] = jars[jar] return candidates return {}
def store_jvm_args(self): distributions = [dep.name for dep in self.subject.buildDependencies] jvm_args = mx.get_runtime_jvm_args(distributions) properties = [] while jvm_args: arg = jvm_args.pop(0) if arg == '-cp': classpath = self.relativize(jvm_args.pop(0)).split(':') else: properties.append(self.relativize(arg)) sulong_libs = mx_subst.path_substitutions.substitute( '-Dpolyglot.llvm.libraryPath=<path:SULONG_LIBS>') properties.append(self.relativize(sulong_libs)) boot_dists = ['GRAAL_SDK', 'TRUFFLE_API', 'LAUNCHER_COMMON'] bootclasspath = self.relativize(mx.classpath(boot_dists)).split(':') for jar in bootclasspath: classpath.remove(jar) with open(self.jvm_args_file, 'w') as f: f.write('bootclasspath=\\\n' + ':\\\n'.join(bootclasspath) + '\n\n') f.write('classpath=\\\n' + ':\\\n'.join(classpath) + '\n\n') f.write('properties=(\n"' + '"\n"'.join(properties) + '"\n)\n')
def jaotc_run(tests, group): for test in tests: mx.log('Testing `{}`'.format(test)) group_config = jaotc_group_config[group] test_info = jaotc_test_info[test] test_type = jaotc_test_info[test]['type'] if test_type == 'app': test_class( opts_set=group_config['class'], classpath=mx.classpath('JAOTC_TEST'), main_class=test_info['main'] ) elif test_type == 'javac': test_javac('jdk.tools.jaotc', group_config['javac']) elif test_type == 'modules': cp = jaotc_test_info[test].get('cp') cp = cp() if cp else None test_modules( opts_set=group_config['modules'], classpath=cp, main_class=test_info['main'], modules=test_info['modules'], vm_args=test_info.get('vm_args'), program_args=test_info.get('program_args'), commands=test_info.get('commands'), ) else: mx.abort('Unknown jaotc test: {}'.format(test))
def run_mg_internal(args, verbose=False, extraVmArgs=None, env=None, jdk=None, **kwargs): vmArgs, mgArgs = mx.extract_VM_args(args) vmArgs = ['-cp', mx.classpath(["edu.uci.megaguards"])] vmArgs.append("edu.uci.megaguards.shell.MGMain") if not jdk: jdk = get_jdk() out = mx.OutputCapture() _out = out if not verbose else mx.TeeOutputCapture(out) out_err = mx.OutputCapture() _out_err = out if not verbose else mx.TeeOutputCapture(out_err) n = 3 for t in range(n): retcode = mx.run_java(vmArgs + [mgArgs], out=_out, err=_out_err, jdk=jdk, **kwargs) if retcode == 0: break return out.data
def jaotc_test(args): """run (acceptance) tests for the AOT compiler (jaotc)""" all_tests = ['HelloWorld', 'java.base', 'javac'] parser = ArgumentParser(prog='mx jaotc-test') parser.add_argument("--list", default=None, action="store_true", help="Print the list of available jaotc tests.") parser.add_argument('tests', help='tests to run (omit to run all tests)', nargs=ZERO_OR_MORE) args = parser.parse_args(args) if args.list: print "The following jaotc tests are available:\n" for name in all_tests: print " " + name return tests = args.tests or all_tests for test in tests: mx.log('Testing `{}`'.format(test)) if test == 'HelloWorld': test_class( classpath=mx.classpath('JAOTC_TEST'), main_class='jdk.tools.jaotc.test.HelloWorld' ) elif test == 'javac': test_javac('jdk.tools.jaotc') elif test == 'java.base': test_modules( classpath=mx.project('jdk.tools.jaotc.test').output_dir(), main_class='jdk.tools.jaotc.test.HelloWorld', modules=['java.base'] ) else: mx.abort('Unknown jaotc test: {}'.format(test))
def helloworld(args): """run the 'hello world' program on the Maxine VM""" mx.run( [join(_vmdir, 'maxvm'), '-cp', mx.classpath('com.oracle.max.tests')] + args + ['test.output.HelloWorld'], env=ldenv)
def __exit__(self, exc_type, exc_value, traceback): if self.mapFiles: try: with tempfile.NamedTemporaryFile() as inputFile: with tempfile.NamedTemporaryFile() as mapFile: if len(self.capture.data) != 0: inputFile.write(self.capture.data) inputFile.flush() for e in self.mapFiles: with open(e, 'r') as m: shutil.copyfileobj(m, mapFile) mapFile.flush() retraceOut = mx.OutputCapture() proguard_cp = mx.classpath( ['PROGUARD_RETRACE', 'PROGUARD']) mx.run([ jdk.java, '-cp', proguard_cp, 'proguard.retrace.ReTrace', mapFile.name, inputFile.name ], out=retraceOut) if self.capture.data != retraceOut.data: mx.log('>>>> BEGIN UNSTRIPPED OUTPUT') mx.log(retraceOut.data) mx.log('<<<< END UNSTRIPPED OUTPUT') except BaseException as e: mx.log( 'Error unstripping output from VM execution with stripped jars: ' + str(e)) return None
def _unittest(args, annotations, prefixCp="", blacklist=None, whitelist=None, verbose=False, fail_fast=False, enable_timing=False, regex=None, color=False, eager_stacktrace=False, gc_after_test=False, suite=None): testfile = os.environ.get('MX_TESTFILE', None) if testfile is None: (_, testfile) = tempfile.mkstemp(".testclasses", "mxtool") os.close(_) mainClass = 'com.oracle.mxtool.junit.MxJUnitWrapper' if not exists(join(mx.project('com.oracle.mxtool.junit').output_dir(), mainClass.replace('.', os.sep) + '.class')): mx.build(['--only', 'com.oracle.mxtool.junit']) coreCp = mx.classpath(['com.oracle.mxtool.junit']) coreArgs = [] if verbose: coreArgs.append('-JUnitVerbose') if fail_fast: coreArgs.append('-JUnitFailFast') if enable_timing: coreArgs.append('-JUnitEnableTiming') if color: coreArgs.append('-JUnitColor') if eager_stacktrace: coreArgs.append('-JUnitEagerStackTrace') if gc_after_test: coreArgs.append('-JUnitGCAfterTest') def harness(unittestCp, vmLauncher, vmArgs): prefixArgs = ['-esa', '-ea'] if gc_after_test: prefixArgs.append('-XX:-DisableExplicitGC') with open(testfile) as fp: testclasses = [l.rstrip() for l in fp.readlines()] cp = prefixCp + coreCp + os.pathsep + unittestCp # suppress menubar and dock when running on Mac vmArgs = prefixArgs + ['-Djava.awt.headless=true'] + vmArgs + ['-cp', mx._separatedCygpathU2W(cp)] # Execute Junit directly when one test is being run. This simplifies # replaying the VM execution in a native debugger (e.g., gdb). mainClassArgs = coreArgs + (testclasses if len(testclasses) == 1 else ['@' + mx._cygpathU2W(testfile)]) config = (vmArgs, mainClass, mainClassArgs) for p in _config_participants: config = p(config) vmLauncher.launcher(*config) vmLauncher = _vm_launcher if vmLauncher is None: jdk = mx.get_jdk() def _run_vm(vmArgs, mainClass, mainClassArgs): mx.run_java(vmArgs + [mainClass] + mainClassArgs, jdk=jdk) vmLauncher = _VMLauncher('default VM launcher', _run_vm, jdk) try: _run_tests(args, harness, vmLauncher, annotations, testfile, blacklist, whitelist, regex, mx.suite(suite) if suite else None) finally: if os.environ.get('MX_TESTFILE') is None: os.remove(testfile)
def microbench(args): """run JMH microbenchmark projects""" parser = ArgumentParser( prog="mx microbench", description=microbench.__doc__, usage="%(prog)s [command options|VM options] [-- [JMH options]]", ) parser.add_argument("--jar", help="Explicitly specify micro-benchmark location") known_args, args = parser.parse_known_args(args) vmArgs, jmhArgs = mx.extract_VM_args(args, useDoubleDash=True) if JVMCI_VERSION < 9: if isJVMCIEnabled(get_vm()) and "-XX:-UseJVMCIClassLoader" not in vmArgs: vmArgs = ["-XX:-UseJVMCIClassLoader"] + vmArgs # look for -f in JMH arguments forking = True for i in range(len(jmhArgs)): arg = jmhArgs[i] if arg.startswith("-f"): if arg == "-f" and (i + 1) < len(jmhArgs): arg += jmhArgs[i + 1] try: if int(arg[2:]) == 0: forking = False except ValueError: pass if known_args.jar: # use the specified jar args = ["-jar", known_args.jar] if not forking: args += vmArgs else: # find all projects with a direct JMH dependency jmhProjects = [] for p in mx.projects_opt_limit_to_suites(): if "JMH" in [x.name for x in p.deps]: jmhProjects.append(p.name) cp = mx.classpath(jmhProjects) # execute JMH runner args = ["-cp", cp] if not forking: args += vmArgs args += ["org.openjdk.jmh.Main"] if forking: jdk = get_jvmci_jdk() jvm = get_vm() def quoteSpace(s): if " " in s: return '"' + s + '"' return s forkedVmArgs = map(quoteSpace, jdk.parseVmArgs(vmArgs)) args += ["--jvmArgsPrepend", " ".join(["-" + jvm] + forkedVmArgs)] run_vm(args + jmhArgs)
def sldebug(args): """run a simple command line debugger for the Simple Language""" vmArgs, slArgs = mx.extract_VM_args(args, useDoubleDash=True) mx.run_java( vmArgs + ["-cp", mx.classpath("com.oracle.truffle.sl.tools"), "com.oracle.truffle.sl.tools.debug.SLREPL"] + slArgs )
def sl(args): """run an SL program""" vmArgs, slArgs = mx.extract_VM_args(args) mx.run_java( vmArgs + ["-cp", mx.classpath(["TRUFFLE_API", "com.oracle.truffle.sl"]), "com.oracle.truffle.sl.SLLanguage"] + slArgs )
def loggen(args): """(re)generate Java source for VMLogger interfaces Run VMLoggerGenerator.java to update the Auto implementations of @VMLoggerInterface interfaces. The exit code is non-zero if a Java source file was modified.""" return mx.run_java(['-cp', mx.classpath('com.oracle.max.vm'), 'com.sun.max.vm.log.hosted.VMLoggerGenerator'])
def t1xgen(args): """(re)generate content in T1XTemplateSource.java Run T1XTemplateGenerator.java to generate the auto-generated templates in T1XTemplateSource.java. The exit code is non-zero if the auto-generated part of T1XTemplateSource.java was modified.""" return mx.run_java(['-cp', mx.classpath('com.oracle.max.vm.ext.t1x'), 'com.oracle.max.vm.ext.t1x.T1XTemplateGenerator'])
def view(args): """browse the boot image under the Inspector Browse a Maxine boot image under the Inspector. Use "mx view -help" to see what the Inspector options are.""" mx.run_java(['-cp', mx.classpath(), 'com.sun.max.ins.MaxineInspector', '-vmdir=' + _vmdir, '-mode=image'] + args)
def extraVmArgs(self): # find all projects with a direct JMH dependency jmhProjects = [] for p in mx.projects_opt_limit_to_suites(): if 'JMH' in [x.name for x in p.deps]: jmhProjects.append(p) cp = mx.classpath([p.name for p in jmhProjects], jdk=mx.get_jdk()) return ['-cp', cp]
def microbench(self, args): """run JMH microbenchmark projects""" parser = ArgumentParser(prog='mx microbench', description=microbench.__doc__, usage="%(prog)s [command options|VM options] [-- [JMH options]]") parser.add_argument('--jar', help='Explicitly specify micro-benchmark location') self.add_arguments(parser) known_args, args = parser.parse_known_args(args) vmArgs, jmhArgs = mx.extract_VM_args(args, useDoubleDash=True) vmArgs = self.parseVmArgs(vmArgs) # look for -f in JMH arguments forking = True for i in range(len(jmhArgs)): arg = jmhArgs[i] if arg.startswith('-f'): if arg == '-f' and (i+1) < len(jmhArgs): arg += jmhArgs[i+1] try: if int(arg[2:]) == 0: forking = False except ValueError: pass if known_args.jar: # use the specified jar args = ['-jar', known_args.jar] if not forking: args += vmArgs # we do not know the compliance level of the jar - assuming 1.8 self.javaCompliance = mx.JavaCompliance('1.8') else: # find all projects with a direct JMH dependency jmhProjects = [] for p in mx.projects_opt_limit_to_suites(): if 'JMH' in [x.name for x in p.deps]: jmhProjects.append(p) # get java compliance - 1.8 is minimum since we build jmh-runner with java 8 self.javaCompliance = max([p.javaCompliance for p in jmhProjects] + [mx.JavaCompliance('1.8')]) cp = mx.classpath([p.name for p in jmhProjects], jdk=mx.get_jdk(self.javaCompliance)) # execute JMH runner args = ['-cp', cp] if not forking: args += vmArgs args += ['org.openjdk.jmh.Main'] if forking: def quoteSpace(s): if " " in s: return '"' + s + '"' return s forkedVmArgs = map(quoteSpace, self.parseForkedVmArgs(vmArgs)) args += ['--jvmArgsPrepend', ' '.join(forkedVmArgs)] self.run_java(args + jmhArgs)
def getPythonBenchmarksNoPeeling(vm): success, error, matcher = getSuccessErrorMatcher() benchmarks = pythonGeneratorBenchmarks tests = [] for benchmark, arg in benchmarks.iteritems(): script = "edu.uci.python.benchmark/src/benchmarks/" + benchmark + ".py" cmd = ['-cp', mx.classpath("edu.uci.python.shell"), "edu.uci.python.shell.Shell", script, arg, "-no-generator-peeling"] tests.append(ZippyTest("Python-" + benchmark, cmd, successREs=[success], failureREs=[error], scoreMatchers=[matcher], vmOpts=benchVmOpts)) return tests
def jvmtigen(args): """(re)generate Java source for JVMTI native function interfaces Run JniFunctionsGenerator.java to update the methods in JVMTIFunctions.java by adding a prologue and epilogue to the @VM_ENTRY_POINT annotated methods in JVMTIFunctionsSource.java. The exit code is non-zero if a Java source file was modified.""" return mx.run_java(['-cp', mx.classpath('com.oracle.max.vm.ext.jvmti'), 'com.sun.max.vm.ext.jvmti.JVMTIFunctionsGenerator'])
def jnigen(args): """(re)generate Java source for native function interfaces (i.e. JNI, JMM, VM) Run JniFunctionsGenerator.java to update the methods in [Jni|JMM|VM]Functions.java by adding a prologue and epilogue to the @VM_ENTRY_POINT annotated methods in [Jni|JMM|VM]FunctionsSource.java. The exit code is non-zero if a Java source file was modified.""" return mx.run_java(['-cp', mx.classpath('com.oracle.max.vm'), 'com.sun.max.vm.jni.JniFunctionsGenerator'])
def getPythonObjectBenchmarksFlexStorageEvolution(vm): success, error, matcher = getSuccessErrorMatcher() benchmarks = pythonObjectBenchmarks tests = [] for benchmark, arg in benchmarks.iteritems(): script = "edu.uci.python.benchmark/src/benchmarks/" + benchmark + ".py" cmd = ['-cp', mx.classpath("edu.uci.python.shell"), "edu.uci.python.shell.Shell", script, arg, "-flexible-storage-evolution"] tests.append(ZippyTest("Python-" + benchmark, cmd, successREs=[success], failureREs=[error], scoreMatchers=[matcher], vmOpts=benchVmOpts)) return tests
def rbcheck(args): '''check FastR builtins against GnuR''' parser = ArgumentParser(prog='mx rbcheck') parser.add_argument('--check-internal', action='store_const', const='--check-internal', help='check .Internal functions') parser.add_argument('--unknown-to-gnur', action='store_const', const='--unknown-to-gnur', help='list builtins not in GnuR FUNCTAB') parser.add_argument('--todo', action='store_const', const='--todo', help='show unimplemented') parser.add_argument('--no-eval-args', action='store_const', const='--no-eval-args', help='list functions that do not evaluate their args') parser.add_argument('--visibility', action='store_const', const='--visibility', help='list visibility specification') parser.add_argument('--printGnuRFunctions', action='store', help='ask GnuR to "print" value of functions') parser.add_argument('--packageBase', action='store', help='directory to be recursively scanned for R sources (used to get frequencies for builtins)') parser.add_argument('--interactive', action='store_const', const='--interactive', help='interactive querying of the word frequencies') args = parser.parse_args(args) class_map = mx.project('com.oracle.truffle.r.nodes').find_classes_with_matching_source_line(None, lambda line: "@RBuiltin" in line, True) classes = [] for className, path in class_map.iteritems(): classNameX = className.split("$")[0] if '$' in className else className if not classNameX.endswith('Factory'): classes.append([className, path]) class_map = mx.project('com.oracle.truffle.r.nodes.builtin').find_classes_with_matching_source_line(None, lambda line: "@RBuiltin" in line, True) for className, path in class_map.iteritems(): classNameX = className.split("$")[0] if '$' in className else className if not classNameX.endswith('Factory'): classes.append([className, path]) (_, testfile) = tempfile.mkstemp(".classes", "mx") os.close(_) with open(testfile, 'w') as f: for c in classes: f.write(c[0] + ',' + c[1][0] + '\n') analyzeArgs = [] if args.check_internal: analyzeArgs.append(args.check_internal) if args.unknown_to_gnur: analyzeArgs.append(args.unknown_to_gnur) if args.todo: analyzeArgs.append(args.todo) if args.no_eval_args: analyzeArgs.append(args.no_eval_args) if args.visibility: analyzeArgs.append(args.visibility) if args.interactive: analyzeArgs.append(args.interactive) if args.printGnuRFunctions: analyzeArgs.append('--printGnuRFunctions') analyzeArgs.append(args.printGnuRFunctions) if args.packageBase: analyzeArgs.append('--packageBase') analyzeArgs.append(args.packageBase) analyzeArgs.append(testfile) cp = mx.classpath('com.oracle.truffle.r.test') mx.run_java(['-cp', cp, 'com.oracle.truffle.r.test.tools.AnalyzeRBuiltin'] + analyzeArgs)
def getPython2Benchmarks(vm): success, error, matcher = getSuccessErrorMatcher() benchmarks = python2Benchmarks tests = [] for benchmark, arg in benchmarks.iteritems(): script = "edu.uci.python.benchmark/src/benchmarks/" + benchmark + ".py" cmd = ['-cp', mx.classpath("edu.uci.python.shell"), "edu.uci.python.shell.Shell", script, arg] vmOpts = ['-Xms2g', '-Xmx2g'] tests.append(ZippyTest("Python-" + benchmark, cmd, successREs=[success], failureREs=[error], scoreMatchers=[matcher], vmOpts=vmOpts)) return tests
def ruby_command(args): """runs Ruby""" vmArgs, rubyArgs = extractArguments(args) classpath = mx.classpath(['TRUFFLE_API', 'RUBY']).split(':') truffle_api, classpath = classpath[0], classpath[1:] assert os.path.basename(truffle_api) == "truffle-api.jar" vmArgs += ['-Xbootclasspath/p:' + truffle_api] vmArgs += ['-cp', ':'.join(classpath)] vmArgs += ['org.jruby.Main', '-X+T'] env = setup_jruby_home() mx.run_java(vmArgs + rubyArgs, env=env)
def nm(args): """print the contents of a boot image Print the contents of a boot image in a textual form. If not specified, the following path will be used for the boot image file: {0} Use "mx nm -help" to see what other options this command accepts.""" mx.run_java(['-cp', mx.classpath(), 'com.sun.max.vm.hosted.BootImagePrinter'] + args + [join(_vmdir, 'maxine.vm')])
def _cp(args): parser = ArgumentParser(prog='mx mxt-classpath') parser.add_argument('--project', action='store', help='name of entity') parser.add_argument('--noResolve', action='store_true', help='noResolve') parser.add_argument('--ignoreSelf', action='store_true', help='ignoreSelf') args = parser.parse_args(args) result = mx.classpath(args.project, resolve=not args.noResolve, includeSelf=not args.ignoreSelf) print 'classpath for: ', args.project comps = result.split(':') for comp in comps: print comp
def jol(args): """Java Object Layout""" joljar = mx.library('JOL_INTERNALS').get_path(resolve=True) candidates = mx.findclass(args, logToConsole=False, matcher=lambda s, classname: s == classname or classname.endswith('.' + s) or classname.endswith('$' + s)) if len(candidates) > 0: candidates = mx.select_items(sorted(candidates)) else: # mx.findclass can be mistaken, don't give up yet candidates = args mx.run_java(['-javaagent:' + joljar, '-cp', os.pathsep.join([mx.classpath(jdk=mx.get_jdk()), joljar]), "org.openjdk.jol.MainObjectInternals"] + candidates)