Beispiel #1
0
def register_graalvm_vms():
    default_host_vm_name = mx_sdk_vm_impl.graalvm_dist_name().lower().replace('_', '-')
    host_vm_names = ([default_host_vm_name.replace('-java8', '')] if '-java8' in default_host_vm_name else []) + [default_host_vm_name]
    for host_vm_name in host_vm_names:
        for config_name, java_args, launcher_args, priority in mx_sdk_vm.get_graalvm_hostvm_configs():
            mx_benchmark.java_vm_registry.add_vm(GraalVm(host_vm_name, config_name, java_args, launcher_args), _suite, priority)
        if mx_sdk_vm_impl.has_component('svm'):
            _native_image_vm_registry.add_vm(NativeImageBuildVm(host_vm_name, 'default', [], []), _suite, 10)
            _gu_vm_registry.add_vm(GuVm(host_vm_name, 'default', [], []), _suite, 10)

    # We support only EE and CE configuration for native-image benchmarks
    for short_name, config_suffix in [('niee', 'ee'), ('ni', 'ce')]:
        if any(component.short_name == short_name for component in mx_sdk_vm_impl.registered_graalvm_components(stage1=False)):
            mx_benchmark.add_java_vm(NativeImageVM('native-image', 'default-' + config_suffix, None, None, 0, False, False, False), _suite, 10)
            mx_benchmark.add_java_vm(NativeImageVM('native-image', 'llvm-' + config_suffix, None, None, 0, False, False, False, True), _suite, 10)
            break

    # Add VMs for libgraal
    if mx_sdk_vm_impl.has_component('LibGraal'):
        libgraal_location = mx_sdk_vm_impl.get_native_image_locations('LibGraal', 'jvmcicompiler')
        if libgraal_location is not None:
            import mx_graal_benchmark
            mx_graal_benchmark.build_jvmci_vm_variants('server', 'graal-core-libgraal',
                                                       ['-server', '-XX:+EnableJVMCI', '-Dgraal.CompilerConfiguration=community', '-Djvmci.Compiler=graal', '-XX:+UseJVMCINativeLibrary', '-XX:JVMCILibPath=' + dirname(libgraal_location)],
                                                       mx_graal_benchmark._graal_variants, suite=_suite, priority=15, hosted=False)
Beispiel #2
0
def gate_body(args, tasks):
    with Task('Vm: GraalVM dist names', tasks, tags=['names']) as t:
        if t:
            mx_sdk_vm.verify_graalvm_configs(suites=['vm', 'vm-enterprise'])

    with Task('Vm: Basic GraalVM Tests', tasks, tags=[VmGateTasks.compiler]) as t:
        if t and mx_sdk_vm_impl.has_component('GraalVM compiler'):
            # 1. the build must be a GraalVM
            # 2. the build must be JVMCI-enabled since the 'GraalVM compiler' component is registered
            mx_sdk_vm_impl.check_versions(mx_sdk_vm_impl.graalvm_output(), graalvm_version_regex=mx_sdk_vm_impl.graalvm_version_regex, expect_graalvm=True, check_jvmci=True)

    libgraal_suite_name = 'substratevm'
    if mx.suite(libgraal_suite_name, fatalIfMissing=False) is not None:
        import mx_substratevm
        # Use `short_name` rather than `name` since the code that follows
        # should be executed also when "LibGraal Enterprise" is registered
        if mx_sdk_vm_impl.has_component(mx_substratevm.libgraal.short_name):
            libgraal_location = mx_sdk_vm_impl.get_native_image_locations(mx_substratevm.libgraal.short_name, 'jvmcicompiler')
            if libgraal_location is None:
                mx.warn("Skipping libgraal tests: no library enabled in the LibGraal component")
            else:
                extra_vm_arguments = ['-XX:+UseJVMCICompiler', '-XX:+UseJVMCINativeLibrary', '-XX:JVMCILibPath=' + dirname(libgraal_location)]
                if args.extra_vm_argument:
                    extra_vm_arguments += args.extra_vm_argument

                # run avrora on the GraalVM binary itself
                with Task('LibGraal Compiler:Basic', tasks, tags=[VmGateTasks.libgraal]) as t:
                    if t: _test_libgraal_basic(extra_vm_arguments)
                with Task('LibGraal Compiler:FatalErrorHandling', tasks, tags=[VmGateTasks.libgraal]) as t:
                    if t: _test_libgraal_fatal_error_handling()

                with Task('LibGraal Compiler:CTW', tasks, tags=[VmGateTasks.libgraal]) as t:
                    if t: _test_libgraal_ctw(extra_vm_arguments)

                import mx_compiler
                mx_compiler.compiler_gate_benchmark_runner(tasks, extra_vm_arguments, prefix='LibGraal Compiler:')

                with Task('LibGraal Truffle:unittest', tasks, tags=[VmGateTasks.libgraal]) as t:
                    if t: _test_libgraal_truffle(extra_vm_arguments)
        else:
            mx.warn("Skipping libgraal tests: component not enabled")
    else:
        mx.warn("Skipping libgraal tests: suite '{suite}' not found. Did you forget to dynamically import it? (--dynamicimports {suite})".format(suite=libgraal_suite_name))

    gate_substratevm(tasks)
    gate_substratevm(tasks, quickbuild=True)
    gate_sulong(tasks)
    gate_python(tasks)
    gate_svm_sl_tck(tasks)
    gate_svm_truffle_tck_js(tasks)
Beispiel #3
0
def gate_body(args, tasks):
    with Task('Vm: GraalVM dist names', tasks, tags=['names']) as t:
        if t:
            mx_sdk_vm.verify_graalvm_configs(suites=['vm', 'vm-enterprise'])

    with Task('Vm: Basic GraalVM Tests', tasks, tags=[VmGateTasks.compiler]) as t:
        if t and mx_sdk_vm_impl.has_component('GraalVM compiler'):
            # 1. the build must be a GraalVM
            # 2. the build must be JVMCI-enabled since the 'GraalVM compiler' component is registered
            mx_sdk_vm_impl.check_versions(mx_sdk_vm_impl.graalvm_output(), graalvm_version_regex=mx_sdk_vm_impl.graalvm_version_regex, expect_graalvm=True, check_jvmci=True)

    if mx_sdk_vm_impl.has_component('LibGraal'):
        libgraal_location = mx_sdk_vm_impl.get_native_image_locations('LibGraal', 'jvmcicompiler')
        if libgraal_location is None:
            mx.warn("Skipping libgraal tests: no library enabled in the LibGraal component")
        else:
            extra_vm_arguments = ['-XX:+UseJVMCICompiler', '-XX:+UseJVMCINativeLibrary', '-XX:JVMCILibPath=' + dirname(libgraal_location)]
            if args.extra_vm_argument:
                extra_vm_arguments += args.extra_vm_argument

            # run avrora on the GraalVM binary itself
            with Task('LibGraal Compiler:Basic', tasks, tags=[VmGateTasks.libgraal]) as t:
                if t: _test_libgraal_basic(extra_vm_arguments)
            with Task('LibGraal Compiler:FatalErrorHandling', tasks, tags=[VmGateTasks.libgraal]) as t:
                if t: _test_libgraal_fatal_error_handling()

            with Task('LibGraal Compiler:CTW', tasks, tags=[VmGateTasks.libgraal]) as t:
                if t: _test_libgraal_ctw(extra_vm_arguments)

            import mx_compiler
            mx_compiler.compiler_gate_benchmark_runner(tasks, extra_vm_arguments, prefix='LibGraal Compiler:')

            with Task('LibGraal Truffle:unittest', tasks, tags=[VmGateTasks.libgraal]) as t:
                if t: _test_libgraal_truffle(extra_vm_arguments)
    else:
        mx.warn("Skipping libgraal tests: component not enabled")

    gate_substratevm(tasks)
    gate_sulong(tasks)
    gate_python(tasks)
    gate_svm_sl_tck(tasks)
    gate_svm_truffle_tck_js(tasks)
Beispiel #4
0
def mx_register_dynamic_suite_constituents(register_project, register_distribution):
    """
    :type register_project: (mx.Project) -> None
    :type register_distribution: (mx.Distribution) -> None
    """
    if mx_sdk_vm_impl.has_component('FastR'):
        fastr_release_env = mx.get_env('FASTR_RELEASE', None)
        if fastr_release_env != 'true':
            mx.abort(('When including FastR, please set FASTR_RELEASE to \'true\' (env FASTR_RELEASE=true mx ...). Got FASTR_RELEASE={}. '
                      'For local development, you may also want to disable recommended packages build (FASTR_NO_RECOMMENDED=true) and '
                      'capturing of system libraries (export FASTR_CAPTURE_DEPENDENCIES set to an empty value). '
                      'See building.md in FastR documentation for more details.').format(fastr_release_env))
    if register_project:
        register_project(GraalVmSymlinks())
Beispiel #5
0
def gate_body(args, tasks):
    with Task('Vm: GraalVM dist names', tasks, tags=['names']) as t:
        if t:
            mx_sdk_vm.verify_graalvm_configs(suites=['vm', 'vm-enterprise'])

    with Task('Vm: Basic GraalVM Tests', tasks,
              tags=[VmGateTasks.compiler]) as t:
        if t and mx_sdk_vm_impl.has_component('GraalVM compiler'):
            # 1. the build must be a GraalVM
            # 2. the build must be JVMCI-enabled since the 'GraalVM compiler' component is registered
            mx_sdk_vm_impl.check_versions(
                mx_sdk_vm_impl.graalvm_output(),
                graalvm_version_regex=mx_sdk_vm_impl.graalvm_version_regex,
                expect_graalvm=True,
                check_jvmci=True)

    if mx_sdk_vm_impl.has_component('LibGraal'):
        libgraal_location = mx_sdk_vm_impl.get_native_image_locations(
            'LibGraal', 'jvmcicompiler')
        if libgraal_location is None:
            mx.warn(
                "Skipping libgraal tests: no library enabled in the LibGraal component"
            )
        else:
            extra_vm_arguments = [
                '-XX:+UseJVMCICompiler', '-XX:+UseJVMCINativeLibrary',
                '-XX:JVMCILibPath=' + dirname(libgraal_location)
            ]
            if args.extra_vm_argument:
                extra_vm_arguments += args.extra_vm_argument
            import mx_compiler

            # run avrora on the GraalVM binary itself
            with Task('LibGraal Compiler:GraalVM DaCapo-avrora',
                      tasks,
                      tags=[VmGateTasks.libgraal]) as t:
                if t:
                    java_exe = join(mx_sdk_vm_impl.graalvm_home(), 'bin',
                                    'java')
                    mx.run([
                        java_exe, '-XX:+UseJVMCICompiler',
                        '-XX:+UseJVMCINativeLibrary', '-jar',
                        mx.library('DACAPO').get_path(True), 'avrora', '-n',
                        '1'
                    ])

                    # Ensure that fatal errors in libgraal route back to HotSpot
                    vmargs = [
                        '-XX:+UseJVMCICompiler', '-XX:+UseJVMCINativeLibrary',
                        '-XX:+PrintFlagsFinal',
                        '-Dlibgraal.CrashAt=length,hashCode',
                        '-Dlibgraal.CrashAtIsFatal=true'
                    ]
                    cmd = ["dacapo:avrora", "--tracker=none", "--"
                           ] + vmargs + ["--", "--preserve"]
                    out = mx.OutputCapture()
                    exitcode, bench_suite, _ = mx_benchmark.gate_mx_benchmark(
                        cmd, nonZeroIsFatal=False, out=out, err=out)
                    if exitcode == 0:
                        if 'CrashAtIsFatal: no fatalError function pointer installed' in out.data:
                            # Executing a VM that does not configure fatal errors handling
                            # in libgraal to route back through the VM.
                            pass
                        else:
                            mx.abort(
                                'Expected following benchmark to result in non-zero exit code: '
                                + ' '.join(cmd))
                    else:
                        if len(bench_suite.scratchDirs()) == 0:
                            mx.abort(
                                "No scratch dir found despite error being expected!"
                            )
                        latest_scratch_dir = bench_suite.scratchDirs()[-1]
                        seen_libjvmci_log = False
                        hs_errs = glob.glob(
                            join(latest_scratch_dir, 'hs_err_pid*.log'))
                        if not hs_errs:
                            mx.abort(
                                'Expected a file starting with "hs_err_pid" in test directory. Entries found='
                                + str(listdir(latest_scratch_dir)))

                        for hs_err in hs_errs:
                            mx.log("Verifying content of {}".format(
                                join(latest_scratch_dir, hs_err)))
                            with open(join(latest_scratch_dir, hs_err)) as fp:
                                contents = fp.read()
                            if 'libjvmci' in hs_err:
                                seen_libjvmci_log = True
                                if 'Fatal error: Forced crash' not in contents:
                                    mx.abort(
                                        'Expected "Fatal error: Forced crash" to be in contents of '
                                        + hs_err + ':' + linesep + contents)
                            else:
                                if 'Fatal error in JVMCI' not in contents:
                                    mx.abort(
                                        'Expected "Fatal error in JVMCI" to be in contents of '
                                        + hs_err + ':' + linesep + contents)

                        if 'JVMCINativeLibraryErrorFile' in out.data and not seen_libjvmci_log:
                            mx.abort(
                                'Expected a file matching "hs_err_pid*_libjvmci.log" in test directory. Entries found='
                                + str(listdir(latest_scratch_dir)))

                    # Only clean up scratch dir on success
                    for scratch_dir in bench_suite.scratchDirs():
                        mx.log(
                            "Cleaning up scratch dir after gate task completion: {}"
                            .format(scratch_dir))
                        mx.rmtree(scratch_dir)

            with Task('LibGraal Compiler:CTW',
                      tasks,
                      tags=[VmGateTasks.libgraal]) as t:
                if t:
                    mx_compiler.ctw([
                        '-DCompileTheWorld.Config=Inline=false CompilationFailureAction=ExitVM',
                        '-esa',
                        '-XX:+EnableJVMCI',
                        '-DCompileTheWorld.MultiThreaded=true',
                        '-Dgraal.InlineDuringParsing=false',
                        '-Dgraal.TrackNodeSourcePosition=true',
                        '-DCompileTheWorld.Verbose=false',
                        '-DCompileTheWorld.HugeMethodLimit=4000',
                        '-DCompileTheWorld.MaxCompiles=150000',
                        '-XX:ReservedCodeCacheSize=300m',
                    ], extra_vm_arguments)

            mx_compiler.compiler_gate_benchmark_runner(
                tasks, extra_vm_arguments, prefix='LibGraal Compiler:')

            with Task('LibGraal Truffle:unittest',
                      tasks,
                      tags=[VmGateTasks.libgraal]) as t:
                if t:

                    def _unittest_config_participant(config):
                        vmArgs, mainClass, mainClassArgs = config

                        def is_truffle_fallback(arg):
                            fallback_args = [
                                "-Dtruffle.TruffleRuntime=com.oracle.truffle.api.impl.DefaultTruffleRuntime",
                                "-Dgraalvm.ForcePolyglotInvalid=true"
                            ]
                            return arg in fallback_args

                        newVmArgs = [
                            arg for arg in vmArgs
                            if not is_truffle_fallback(arg)
                        ]
                        return (newVmArgs, mainClass, mainClassArgs)

                    mx_unittest.add_config_participant(
                        _unittest_config_participant)
                    excluded_tests = environ.get("TEST_LIBGRAAL_EXCLUDE")
                    if excluded_tests:
                        with NamedTemporaryFile(prefix='blacklist.',
                                                mode='w',
                                                delete=False) as fp:
                            fp.file.writelines(
                                [l + '\n' for l in excluded_tests.split()])
                            unittest_args = ["--blacklist", fp.name]
                    else:
                        unittest_args = []
                    unittest_args = unittest_args + [
                        "--enable-timing", "--verbose"
                    ]
                    compiler_log_file = "graal-compiler.log"
                    mx_unittest.unittest(unittest_args + extra_vm_arguments + [
                        "-Dpolyglot.engine.AllowExperimentalOptions=true",
                        "-Dpolyglot.engine.CompileImmediately=true",
                        "-Dpolyglot.engine.BackgroundCompilation=false",
                        "-Dpolyglot.engine.TraceCompilation=true",
                        "-Dpolyglot.log.file={0}".format(compiler_log_file),
                        "-Dgraalvm.locatorDisabled=true", "truffle"
                    ])
                    if exists(compiler_log_file):
                        remove(compiler_log_file)
    else:
        mx.warn("Skipping libgraal tests: component not enabled")

    gate_substratevm(tasks)
    gate_sulong(tasks)
    gate_python(tasks)
    gate_svm_sl_tck(tasks)
    gate_svm_truffle_tck_js(tasks)
Beispiel #6
0
def mx_register_dynamic_suite_constituents(register_project,
                                           register_distribution):
    """
    :type register_project: (mx.Project) -> None
    :type register_distribution: (mx.Distribution) -> None
    """
    if mx_sdk_vm_impl.has_component('FastR'):
        fastr_release_env = mx.get_env('FASTR_RELEASE', None)
        if fastr_release_env != 'true':
            mx.abort((
                'When including FastR, please set FASTR_RELEASE to \'true\' (env FASTR_RELEASE=true mx ...). Got FASTR_RELEASE={}. '
                'For local development, you may also want to disable recommended packages build (FASTR_NO_RECOMMENDED=true) and '
                'capturing of system libraries (export FASTR_CAPTURE_DEPENDENCIES set to an empty value). '
                'See building.md in FastR documentation for more details.'
            ).format(fastr_release_env))
    if register_project:
        register_project(GraalVmSymlinks())

        if mx_sdk_vm_impl.has_component('GraalWasm'):
            import mx_wasm

            class GraalVmWatProject(mx_wasm.WatProject):
                def getSourceDir(self):
                    return self.subDir

                def getBuildTask(self, args):
                    output_base = self.get_output_base()
                    return GraalVmWatBuildTask(self, args, output_base)

                def isBenchmarkProject(self):
                    return self.name.startswith("benchmarks.")

            class GraalVmWatBuildTask(mx_wasm.WatBuildTask):
                def needsBuild(self, newestInput):
                    is_needed, reason = super(GraalVmWatBuildTask,
                                              self).needsBuild(newestInput)
                    if is_needed:
                        return is_needed, reason
                    for root, filename in self.subject.getProgramSources():
                        f = join(root,
                                 mx_wasm.remove_extension(filename) + ".wasm")
                        if not os.path.exists(f):
                            return True, "symlink '{}' does not exist".format(
                                f)
                    return False, ''

                def build(self):
                    super(GraalVmWatBuildTask, self).build()
                    output_dir = self.subject.getOutputDir()
                    for root, filename in self.subject.getProgramSources():
                        src = join(
                            output_dir,
                            mx_wasm.remove_extension(filename) + ".wasm")
                        dst = join(
                            root,
                            mx_wasm.remove_extension(filename) + ".wasm")
                        if mx.is_windows():
                            mx.copyfile(src, dst)
                        else:
                            os.symlink(src, dst)

                def clean(self, forBuild=False):
                    super(GraalVmWatBuildTask, self).build()
                    for root, filename in self.subject.getProgramSources():
                        f = join(root,
                                 mx_wasm.remove_extension(filename) + ".wasm")
                        if os.path.exists(f):
                            if os.path.islink(f):
                                os.unlink(f)
                            else:
                                mx.rmtree(f)
                    output_dir = self.subject.getOutputDir()
                    if not forBuild and os.path.exists(output_dir):
                        mx.rmtree(output_dir)

            register_project(
                GraalVmWatProject(
                    suite=_suite,
                    name='benchmarks.interpreter.wasm',
                    deps=[],
                    workingSets=None,
                    subDir=join(_suite.dir, 'benchmarks', 'interpreter'),
                    theLicense=None,
                    testProject=True,
                    defaultBuild=False,
                ))
Beispiel #7
0
def gate_body(args, tasks):
    # all mx_sdk_vm_impl gate tasks can also be run as vm gate tasks
    if not args.all_suites:
        mx_sdk_vm_impl.gate_body(args, tasks)

    with Task('Vm: Basic GraalVM Tests', tasks,
              tags=[VmGateTasks.compiler]) as t:
        if t and mx_sdk_vm_impl.has_component('GraalVM compiler'):
            # 1. the build must be a GraalVM
            # 2. the build must be JVMCI-enabled since the 'GraalVM compiler' component is registered
            mx_sdk_vm_impl.check_versions(
                mx_sdk_vm_impl.graalvm_output(),
                graalvm_version_regex=mx_sdk_vm_impl.graalvm_version_regex,
                expect_graalvm=True,
                check_jvmci=True)

    if mx_sdk_vm_impl.has_component('LibGraal'):
        libgraal_location = mx_sdk_vm_impl.get_native_image_locations(
            'LibGraal', 'jvmcicompiler')
        if libgraal_location is None:
            mx.warn(
                "Skipping libgraal tests: no library enabled in the LibGraal component"
            )
        else:
            extra_vm_arguments = [
                '-XX:+UseJVMCICompiler', '-XX:+UseJVMCINativeLibrary',
                '-XX:JVMCILibPath=' + dirname(libgraal_location)
            ]
            if args.extra_vm_argument:
                extra_vm_arguments += args.extra_vm_argument
            import mx_compiler

            # run avrora on the GraalVM binary itself
            with Task('LibGraal Compiler:GraalVM DaCapo-avrora',
                      tasks,
                      tags=[VmGateTasks.libgraal]) as t:
                if t:
                    java_exe = join(mx_sdk_vm_impl.graalvm_home(), 'bin',
                                    'java')
                    mx.run([
                        java_exe, '-XX:+UseJVMCICompiler',
                        '-XX:+UseJVMCINativeLibrary', '-jar',
                        mx.library('DACAPO').get_path(True), 'avrora'
                    ])

                    # Ensure that fatal errors in libgraal route back to HotSpot
                    testdir = mkdtemp()
                    try:
                        cmd = [
                            java_exe, '-XX:+UseJVMCICompiler',
                            '-XX:+UseJVMCINativeLibrary',
                            '-Dlibgraal.CrashAt=length,hashCode',
                            '-Dlibgraal.CrashAtIsFatal=true', '-jar',
                            mx.library('DACAPO').get_path(True), 'avrora'
                        ]
                        out = mx.OutputCapture()
                        exitcode = mx.run(cmd,
                                          cwd=testdir,
                                          nonZeroIsFatal=False,
                                          out=out)
                        if exitcode == 0:
                            if 'CrashAtIsFatal: no fatalError function pointer installed' in out.data:
                                # Executing a VM that does not configure fatal errors handling
                                # in libgraal to route back through the VM.
                                pass
                            else:
                                mx.abort(
                                    'Expected following command to result in non-zero exit code: '
                                    + ' '.join(cmd))
                        else:
                            hs_err = None
                            testdir_entries = listdir(testdir)
                            for name in testdir_entries:
                                if name.startswith('hs_err_pid'
                                                   ) and name.endswith('.log'):
                                    hs_err = join(testdir, name)
                            if hs_err is None:
                                mx.abort(
                                    'Expected a file starting with "hs_err_pid" in test directory. Entries found='
                                    + str(testdir_entries))
                            with open(join(testdir, hs_err)) as fp:
                                contents = fp.read()
                            if 'Fatal error in JVMCI' not in contents:
                                mx.abort(
                                    'Expected "Fatal error in JVMCI" to be in contents of '
                                    + hs_err + ':' + linesep + contents)
                    finally:
                        mx.rmtree(testdir)

            with Task('LibGraal Compiler:CTW',
                      tasks,
                      tags=[VmGateTasks.libgraal]) as t:
                if t:
                    mx_compiler.ctw([
                        '-DCompileTheWorld.Config=Inline=false CompilationFailureAction=ExitVM',
                        '-esa',
                        '-XX:+EnableJVMCI',
                        '-DCompileTheWorld.MultiThreaded=true',
                        '-Dgraal.InlineDuringParsing=false',
                        '-Dgraal.TrackNodeSourcePosition=true',
                        '-DCompileTheWorld.Verbose=false',
                        '-DCompileTheWorld.HugeMethodLimit=4000',
                        '-DCompileTheWorld.MaxCompiles=150000',
                        '-XX:ReservedCodeCacheSize=300m',
                    ], extra_vm_arguments)

            mx_compiler.compiler_gate_benchmark_runner(
                tasks, extra_vm_arguments, prefix='LibGraal Compiler:')

            with Task('LibGraal Truffle:unittest',
                      tasks,
                      tags=[VmGateTasks.libgraal]) as t:
                if t:

                    def _unittest_config_participant(config):
                        vmArgs, mainClass, mainClassArgs = config

                        def is_truffle_fallback(arg):
                            fallback_args = [
                                "-Dtruffle.TruffleRuntime=com.oracle.truffle.api.impl.DefaultTruffleRuntime",
                                "-Dgraalvm.ForcePolyglotInvalid=true"
                            ]
                            return arg in fallback_args

                        newVmArgs = [
                            arg for arg in vmArgs
                            if not is_truffle_fallback(arg)
                        ]
                        return (newVmArgs, mainClass, mainClassArgs)

                    mx_unittest.add_config_participant(
                        _unittest_config_participant)
                    excluded_tests = environ.get("TEST_LIBGRAAL_EXCLUDE")
                    if excluded_tests:
                        with NamedTemporaryFile(prefix='blacklist.',
                                                mode='w',
                                                delete=False) as fp:
                            fp.file.writelines(
                                [l + '\n' for l in excluded_tests.split()])
                            unittest_args = ["--blacklist", fp.name]
                    else:
                        unittest_args = []
                    unittest_args = unittest_args + [
                        "--enable-timing", "--verbose"
                    ]
                    compiler_log_file = "graal-compiler.log"
                    mx_unittest.unittest(unittest_args + extra_vm_arguments + [
                        "-Dpolyglot.engine.AllowExperimentalOptions=true",
                        "-Dpolyglot.engine.CompileImmediately=true",
                        "-Dpolyglot.engine.BackgroundCompilation=false",
                        "-Dpolyglot.engine.TraceCompilation=true",
                        "-Dpolyglot.log.file={0}".format(compiler_log_file),
                        "-Dgraalvm.locatorDisabled=true", "truffle"
                    ])
                    if exists(compiler_log_file):
                        remove(compiler_log_file)
    else:
        mx.warn("Skipping libgraal tests: component not enabled")

    gate_substratevm(tasks)
    gate_sulong(tasks)
    gate_python(tasks)
    gate_svm_sl_tck(tasks)
    gate_svm_truffle_tck_js(tasks)
Beispiel #8
0
def mx_register_dynamic_suite_constituents(register_project,
                                           register_distribution):
    """
    :type register_project: (mx.Project) -> None
    :type register_distribution: (mx.Distribution) -> None
    """
    if mx_sdk_vm_impl.has_component('FastR'):
        fastr_release_env = mx.get_env('FASTR_RELEASE', None)
        if fastr_release_env != 'true':
            mx.abort((
                'When including FastR, please set FASTR_RELEASE to \'true\' (env FASTR_RELEASE=true mx ...). Got FASTR_RELEASE={}. '
                'For local development, you may also want to disable recommended packages build (FASTR_NO_RECOMMENDED=true) and '
                'capturing of system libraries (export FASTR_CAPTURE_DEPENDENCIES set to an empty value). '
                'See building.md in FastR documentation for more details.'
            ).format(fastr_release_env))
    if register_project:
        register_project(GraalVmSymlinks())

        benchmark_dist = _suite.dependency("POLYBENCH_BENCHMARKS")

        def _add_project_to_dist(destination,
                                 name,
                                 source='dependency:{name}/*'):
            if destination not in benchmark_dist.layout:
                benchmark_dist.layout[destination] = []
            benchmark_dist.layout[destination].append(source.format(name=name))
            benchmark_dist.buildDependencies.append(name)

        if mx_sdk_vm_impl.has_component('GraalWasm'):
            import mx_wasm

            class GraalVmWatProject(mx_wasm.WatProject):
                def getSourceDir(self):
                    return self.subDir

                def isBenchmarkProject(self):
                    return self.name.startswith("benchmarks.")

            register_project(
                GraalVmWatProject(
                    suite=_suite,
                    name='benchmarks.interpreter.wasm',
                    deps=[],
                    workingSets=None,
                    subDir=join(_suite.dir, 'benchmarks', 'interpreter'),
                    theLicense=None,
                    testProject=True,
                    defaultBuild=False,
                ))
            # add wasm to the layout of the benchmark distribution
            _add_project_to_dist('./interpreter/',
                                 'benchmarks.interpreter.wasm')

        if mx_sdk_vm_impl.has_component('LLVM Runtime Native'):
            register_project(
                mx.NativeProject(
                    suite=_suite,
                    name='benchmarks.interpreter.llvm.native',
                    results=['interpreter/'],
                    buildEnv={
                        'NATIVE_LLVM_CC': '<toolchainGetToolPath:native,CC>',
                    },
                    buildDependencies=[
                        'sulong:SULONG_BOOTSTRAP_TOOLCHAIN',
                    ],
                    vpath=True,
                    deps=[],
                    workingSets=None,
                    d=join(_suite.dir, 'benchmarks', 'interpreter'),
                    subDir=None,
                    srcDirs=[''],
                    output=None,
                    theLicense=None,
                    testProject=True,
                    defaultBuild=False,
                ))
            # add bitcode to the layout of the benchmark distribution
            _add_project_to_dist('./', 'benchmarks.interpreter.llvm.native')
Beispiel #9
0
def gate_body(args, tasks):
    # all mx_sdk_vm_impl gate tasks can also be run as vm gate tasks
    mx_sdk_vm_impl.gate_body(args, tasks)

    with Task('Vm: Basic GraalVM Tests', tasks,
              tags=[VmGateTasks.compiler]) as t:
        if t and mx_sdk_vm_impl.has_component('GraalVM compiler'):
            # 1. the build must be a GraalVM
            # 2. the build must be JVMCI-enabled since the 'GraalVM compiler' component is registered
            mx_sdk_vm_impl.check_versions(
                mx_sdk_vm_impl.graalvm_output(),
                graalvm_version_regex=mx_sdk_vm_impl.graalvm_version_regex,
                expect_graalvm=True,
                check_jvmci=True)

    if mx_sdk_vm_impl.has_component('LibGraal'):
        libgraal_location = mx_sdk_vm_impl.get_native_image_locations(
            'LibGraal', 'jvmcicompiler')
        if libgraal_location is None:
            mx.warn(
                "Skipping libgraal tests: no library enabled in the LibGraal component"
            )
        else:
            extra_vm_arguments = [
                '-XX:+UseJVMCICompiler', '-XX:+UseJVMCINativeLibrary',
                '-XX:JVMCILibPath=' + dirname(libgraal_location)
            ]
            if args.extra_vm_argument:
                extra_vm_arguments += args.extra_vm_argument
            import mx_compiler

            # run avrora on the GraalVM binary itself
            with Task('LibGraal Compiler:GraalVM DaCapo-avrora',
                      tasks,
                      tags=[VmGateTasks.libgraal]) as t:
                if t:
                    mx.run([
                        join(mx_sdk_vm_impl.graalvm_home(), 'bin',
                             'java'), '-XX:+UseJVMCICompiler',
                        '-XX:+UseJVMCINativeLibrary', '-jar',
                        mx.library('DACAPO').get_path(True), 'avrora'
                    ])

            with Task('LibGraal Compiler:CTW',
                      tasks,
                      tags=[VmGateTasks.libgraal]) as t:
                if t:
                    mx_compiler.ctw([
                        '-DCompileTheWorld.Config=Inline=false CompilationFailureAction=ExitVM',
                        '-esa',
                        '-XX:+EnableJVMCI',
                        '-DCompileTheWorld.MultiThreaded=true',
                        '-Dgraal.InlineDuringParsing=false',
                        '-Dgraal.TrackNodeSourcePosition=true',
                        '-DCompileTheWorld.Verbose=false',
                        '-XX:ReservedCodeCacheSize=300m',
                    ], extra_vm_arguments)

            mx_compiler.compiler_gate_benchmark_runner(
                tasks, extra_vm_arguments, prefix='LibGraal Compiler:')

            with Task('LibGraal Truffle:unittest',
                      tasks,
                      tags=[VmGateTasks.libgraal]) as t:
                if t:

                    def _unittest_config_participant(config):
                        vmArgs, mainClass, mainClassArgs = config

                        def is_truffle_fallback(arg):
                            fallback_args = [
                                "-Dtruffle.TruffleRuntime=com.oracle.truffle.api.impl.DefaultTruffleRuntime",
                                "-Dgraalvm.ForcePolyglotInvalid=true"
                            ]
                            return arg in fallback_args

                        newVmArgs = [
                            arg for arg in vmArgs
                            if not is_truffle_fallback(arg)
                        ]
                        return (newVmArgs, mainClass, mainClassArgs)

                    mx_unittest.add_config_participant(
                        _unittest_config_participant)
                    excluded_tests = environ.get("TEST_LIBGRAAL_EXCLUDE")
                    if excluded_tests:
                        with NamedTemporaryFile(prefix='blacklist.',
                                                mode='w',
                                                delete=False) as fp:
                            fp.file.writelines(
                                [l + '\n' for l in excluded_tests.split()])
                            unittest_args = ["--blacklist", fp.name]
                    else:
                        unittest_args = []
                    unittest_args = unittest_args + [
                        "--enable-timing", "--verbose"
                    ]
                    compiler_log_file = "graal-compiler.log"
                    mx_unittest.unittest(unittest_args + extra_vm_arguments + [
                        "-Dgraal.TruffleCompileImmediately=true",
                        "-Dgraal.TruffleBackgroundCompilation=false",
                        "-Dgraal.TraceTruffleCompilation=true",
                        "-Dgraalvm.locatorDisabled=true",
                        "-Dgraal.PrintCompilation=true", "-Dgraal.LogFile={0}".
                        format(compiler_log_file), "truffle"
                    ])
                    if exists(compiler_log_file):
                        remove(compiler_log_file)
    else:
        mx.warn("Skipping libgraal tests: component not enabled")

    gate_substratevm(tasks)
    gate_sulong(tasks)
    gate_python(tasks)
    gate_svm_sl_tck(tasks)
    gate_svm_truffle_tck_js(tasks)
Beispiel #10
0
def mx_register_dynamic_suite_constituents(register_project, register_distribution):
    """
    :type register_project: (mx.Project) -> None
    :type register_distribution: (mx.Distribution) -> None
    """
    if mx_sdk_vm_impl.has_component('FastR'):
        fastr_release_env = mx.get_env('FASTR_RELEASE', None)
        if fastr_release_env != 'true':
            mx.abort(('When including FastR, please set FASTR_RELEASE to \'true\' (env FASTR_RELEASE=true mx ...). Got FASTR_RELEASE={}. '
                      'For local development, you may also want to disable recommended packages build (FASTR_NO_RECOMMENDED=true) and '
                      'capturing of system libraries (export FASTR_CAPTURE_DEPENDENCIES set to an empty value). '
                      'See building.md in FastR documentation for more details.').format(fastr_release_env))
    if register_project:
        register_project(GraalVmSymlinks())

        benchmark_dist = _suite.dependency("POLYBENCH_BENCHMARKS")

        def _add_project_to_dist(destination, name, source='dependency:{name}/*'):
            if destination not in benchmark_dist.layout:
                benchmark_dist.layout[destination] = []
            benchmark_dist.layout[destination].append(source.format(name=name))
            benchmark_dist.buildDependencies.append(name)

        if mx_sdk_vm_impl.has_component('GraalWasm'):
            import mx_wasm

            class GraalVmWatProject(mx_wasm.WatProject):
                def getSourceDir(self):
                    return self.subDir

                def isBenchmarkProject(self):
                    return self.name.startswith("benchmarks.")

            register_project(GraalVmWatProject(
                suite=_suite,
                name='benchmarks.interpreter.wasm',
                deps=[],
                workingSets=None,
                subDir=join(_suite.dir, 'benchmarks', 'interpreter'),
                theLicense=None,
                testProject=True,
                defaultBuild=False,
            ))
            # add wasm to the layout of the benchmark distribution
            _add_project_to_dist('./interpreter/', 'benchmarks.interpreter.wasm')

        if mx_sdk_vm_impl.has_component('LLVM Runtime Native'):
            register_project(mx.NativeProject(
                suite=_suite,
                name='benchmarks.interpreter.llvm.native',
                results=['interpreter/'],
                buildEnv={
                    'NATIVE_LLVM_CC': '<toolchainGetToolPath:native,CC>',
                },
                buildDependencies=[
                    'sulong:SULONG_BOOTSTRAP_TOOLCHAIN',
                ],
                vpath=True,
                deps=[],
                workingSets=None,
                d=join(_suite.dir, 'benchmarks', 'interpreter'),
                subDir=None,
                srcDirs=[''],
                output=None,
                theLicense=None,
                testProject=True,
                defaultBuild=False,
            ))
            # add bitcode to the layout of the benchmark distribution
            _add_project_to_dist('./', 'benchmarks.interpreter.llvm.native')

        if mx_sdk_vm_impl.has_component('Java on Truffle'):
            java_benchmarks = join(_suite.dir, 'benchmarks', 'interpreter', 'java')
            for f in os.listdir(java_benchmarks):
                if isdir(join(java_benchmarks, f)) and not f.startswith("."):
                    main_class = basename(f)
                    simple_name = main_class.split(".")[-1]

                    project_name = 'benchmarks.interpreter.espresso.' + simple_name.lower()
                    register_project(mx.JavaProject(
                        suite=_suite,
                        subDir=None,
                        srcDirs=[join(_suite.dir, 'benchmarks', 'interpreter', 'java', main_class)],
                        deps=[],
                        name=project_name,
                        d=join(_suite.dir, 'benchmarks', 'interpreter', 'java', main_class),
                        javaCompliance='11+',
                        checkstyleProj=project_name,
                        workingSets=None,
                        theLicense=None,
                        testProject=True,
                        defaultBuild=False,
                    ))

                    dist_name = 'POLYBENCH_ESPRESSO_' + simple_name.upper()
                    register_distribution(mx_jardistribution.JARDistribution(
                        suite=_suite,
                        subDir=None,
                        srcDirs=[''],
                        sourcesPath=[],
                        deps=[project_name],
                        mainClass=main_class,
                        name=dist_name,
                        path=simple_name + '.jar',
                        platformDependent=False,
                        distDependencies=[],
                        javaCompliance='11+',
                        excludedLibs=[],
                        workingSets=None,
                        theLicense=None,
                        testProject=True,
                        defaultBuild=False,
                    ))
                    # add jars to the layout of the benchmark distribution
                    _add_project_to_dist('./interpreter/{}.jar'.format(simple_name), dist_name,
                        source='dependency:{name}/polybench-espresso-' + simple_name.lower() + '.jar')