# HG changeset patch # User Bernhard Urban # Date 1392310767 -3600 # Node ID 392b6ac8da3656855cda8addbfe7424a618095a2 # Parent 35783e78eaefc67e2df7efe893ca4960b262e087 Allow using run_java without the arguments from -J -Ja -Jp. Factor out the argument processing of mx_graal.vm and use it to pass tested-vm args down through the jmh harness diff -r 35783e78eaef -r 392b6ac8da36 mx/mx_graal.py --- a/mx/mx_graal.py Thu Feb 13 17:07:36 2014 +0100 +++ b/mx/mx_graal.py Thu Feb 13 17:59:27 2014 +0100 @@ -712,7 +712,7 @@ """run the fastdebug build of VM selected by the '--vm' option""" return vm(args, vmbuild='fastdebug') -def vm(args, vm=None, nonZeroIsFatal=True, out=None, err=None, cwd=None, timeout=None, vmbuild=None): +def _parseVmArgs(args, vm=None, cwd=None, vmbuild=None): """run the VM selected by the '--vm' option""" if vm is None: @@ -761,7 +761,11 @@ 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 mx.run(pfx + [exe, '-' + vm] + args, nonZeroIsFatal=nonZeroIsFatal, out=out, err=err, cwd=cwd, timeout=timeout) + return (pfx, exe, vm, args, cwd) + +def vm(args, vm=None, nonZeroIsFatal=True, out=None, err=None, cwd=None, timeout=None, vmbuild=None): + (pfx_, exe_, vm_, args_, cwd) = _parseVmArgs(args, vm, cwd, vmbuild) + return mx.run(pfx_ + [exe_, '-' + vm_] + args_, nonZeroIsFatal=nonZeroIsFatal, out=out, err=err, cwd=cwd, timeout=timeout) def _find_classes_with_annotations(p, pkgRoot, annotations, includeInnerClasses=False): """ @@ -1293,7 +1297,7 @@ microJar = os.path.join(absoluteMicro, "target", "microbenchmarks.jar") if not exists(microJar): mx.logv('JMH: ignored ' + absoluteMicro + " because it doesn't contain the expected jar file ('" + microJar + "')") - continue + continue if benchmarks: def _addBenchmark(x): if x.startswith("Benchmark:"): @@ -1306,8 +1310,7 @@ numBench[0] += 1 matchedSuites.add(micros) - - mx.run_java(['-jar', microJar, "-l"], cwd = jmhPath, out = _addBenchmark) + mx.run_java(['-jar', microJar, "-l"], cwd = jmhPath, out = _addBenchmark, addDefaultArgs = False) else: matchedSuites.add(micros) @@ -1322,11 +1325,16 @@ for suite in matchedSuites: absoluteMicro = os.path.join(jmhPath, suite) - vm(['-jar', os.path.join(absoluteMicro, "target", "microbenchmarks.jar"), + (pfx, exe, vm, forkedVmArgs, _) = _parseVmArgs(vmArgs) + if pfx: + mx.warn("JMH ignores prefix: \"" + pfx + "\"") + mx.run_java( + ['-jar', os.path.join(absoluteMicro, "target", "microbenchmarks.jar"), "-f", "1", "-i", "10", "-wi", "10", - "--jvmArgs", " ".join(["-" + _get_vm()] + vmArgs)] + regex, - vm = 'original', + "--jvm", exe, + "--jvmArgs", " ".join(["-" + vm] + forkedVmArgs)] + regex, + addDefaultArgs = False, cwd = jmhPath) diff -r 35783e78eaef -r 392b6ac8da36 mxtool/mx.py --- a/mxtool/mx.py Thu Feb 13 17:07:36 2014 +0100 +++ b/mxtool/mx.py Thu Feb 13 17:59:27 2014 +0100 @@ -1053,8 +1053,8 @@ assert _java is not None return _java -def run_java(args, nonZeroIsFatal=True, out=None, err=None, cwd=None): - return run(java().format_cmd(args), nonZeroIsFatal=nonZeroIsFatal, out=out, err=err, cwd=cwd) +def run_java(args, nonZeroIsFatal=True, out=None, err=None, cwd=None, addDefaultArgs=True): + return run(java().format_cmd(args, addDefaultArgs), nonZeroIsFatal=nonZeroIsFatal, out=out, err=err, cwd=cwd) def _kill_process_group(pid): pgid = os.getpgid(pid) @@ -1333,8 +1333,11 @@ if self.debug_port is not None: self.java_args += ['-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=' + str(self.debug_port)] - def format_cmd(self, args): - return [self.java] + self.java_args_pfx + self.java_args + self.java_args_sfx + args + def format_cmd(self, args, addDefaultArgs): + if addDefaultArgs: + return [self.java] + self.java_args_pfx + self.java_args + self.java_args_sfx + args + else: + return [self.java] + args def bootclasspath(self): if self._bootclasspath is None: