Beispiel #1
0
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)
Beispiel #2
0
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)
Beispiel #3
0
    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')])
            cpArgs = mx.get_runtime_jvm_args([p.name for p in jmhProjects], jdk=mx.get_jdk(self.javaCompliance))

            # execute JMH runner
            if forking:
                args, cpVmArgs = self.filterVmArgs(cpArgs)
                vmArgs += cpVmArgs
            else:
                args = cpArgs + 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)
Beispiel #4
0
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)
Beispiel #5
0
    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]
Beispiel #6
0
    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)
Beispiel #7
0
    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]
Beispiel #8
0
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)

    # 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:
        jvm = get_vm()
        def quoteSpace(s):
            if " " in s:
                return '"' + s + '"'
            return s

        forkedVmArgs = map(quoteSpace, _parseVmArgs(_jdk, vmArgs))
        args += ['--jvmArgsPrepend', ' '.join(['-' + jvm] + forkedVmArgs)]
    run_vm(args + jmhArgs)
Beispiel #9
0
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)
Beispiel #10
0
def _run_tests(args, harness, vmLauncher, annotations, testfile, blacklist, whitelist, regex):


    vmArgs, tests = mx.extract_VM_args(args)
    for t in tests:
        if t.startswith('-'):
            mx.abort('VM option ' + t + ' must precede ' + tests[0])

    candidates = {}
    for p in mx.projects_opt_limit_to_suites():
        if mx.java().javaCompliance < p.javaCompliance:
            continue
        for c in _find_classes_with_annotations(p, None, annotations).keys():
            candidates[c] = p

    classes = []
    if len(tests) == 0:
        classes = candidates.keys()
        projectsCp = mx.classpath([pcp.name for pcp in mx.projects_opt_limit_to_suites() if pcp.javaCompliance <= mx.java().javaCompliance])
    else:
        projs = set()
        found = False
        if len(tests) == 1 and '#' in tests[0]:
            words = tests[0].split('#')
            if len(words) != 2:
                mx.abort("Method specification is class#method: " + tests[0])
            t, method = words

            for c, p in candidates.iteritems():
                # prefer exact matches first
                if t == c:
                    found = True
                    classes.append(c)
                    projs.add(p.name)
            if not found:
                for c, p in candidates.iteritems():
                    if t in c:
                        found = True
                        classes.append(c)
                        projs.add(p.name)
            if not found:
                mx.log('warning: no tests matched by substring "' + t)
            elif len(classes) != 1:
                mx.abort('More than one test matches substring {0} {1}'.format(t, classes))

            classes = [c + "#" + method for c in classes]
        else:
            for t in tests:
                if '#' in t:
                    mx.abort('Method specifications can only be used in a single test: ' + t)
                for c, p in candidates.iteritems():
                    if t in c:
                        found = True
                        classes.append(c)
                        projs.add(p.name)
                if not found:
                    mx.log('warning: no tests matched by substring "' + t)
        projectsCp = mx.classpath(projs)

    if blacklist:
        classes = [c for c in classes if not any((glob.match(c) for glob in blacklist))]

    if whitelist:
        classes = [c for c in classes if any((glob.match(c) for glob in whitelist))]

    if regex:
        classes = [c for c in classes if re.search(regex, c)]

    if len(classes) != 0:
        f_testfile = open(testfile, 'w')
        for c in classes:
            f_testfile.write(c + '\n')
        f_testfile.close()
        harness(projectsCp, vmLauncher, vmArgs)