Exemplo n.º 1
0
def testgraal(args):
    cloneFrom = mx.get_env("GRAAL_URL")
    if not cloneFrom:
        cloneFrom = "http://github.com/graalvm/graal-core"
    graalSuiteSubDir = mx.get_env("GRAAL_SUITE_SUBDIR")

    suite = mx.suite('truffle')
    suiteDir = suite.dir
    workDir = join(suite.get_output_root(), 'sanitycheck')
    mx.ensure_dir_exists(join(workDir, suite.name))
    for f in os.listdir(suiteDir):
        subDir = os.path.join(suiteDir, f)
        if subDir == suite.get_output_root():
            continue
        src = join(suiteDir, f)
        tgt = join(workDir, suite.name, f)
        if isdir(src):
            if exists(tgt):
                shutil.rmtree(tgt)
            shutil.copytree(src, tgt)
        else:
            shutil.copy(src, tgt)

    sanityDir = join(workDir, 'sanity')
    git = mx.GitConfig()
    if exists(sanityDir):
        git.pull(sanityDir)
    else:
        git.clone(cloneFrom, sanityDir)

    sanitySuiteDir = sanityDir if graalSuiteSubDir is None else join(sanityDir, graalSuiteSubDir)
    return mx.run_mx(['--java-home=' + mx.get_jdk().home, 'gate', '-B--force-deprecation-as-warning', '--tags', 'build,test'], sanitySuiteDir)
Exemplo n.º 2
0
def gate_ruby(tasks):
    with Task('Ruby', tasks, tags=[VmGateTasks.ruby]) as t:
        if t:
            # Debug GR-9912 on Ruby gate runs. If debug_gr_9912 goes away the custom image building below is not required anymore and
            # test_ruby can be called with the original graalvm ruby-launcher
            debug_gr_9912 = 16
            native_image_context, svm = graalvm_svm()
            with native_image_context(svm.IMAGE_ASSERTION_FLAGS) as native_image:
                ruby_bindir = join(mx_vm.graalvm_output(), 'jre', 'languages', 'ruby', 'bin')
                ruby_image = native_image(['--language:ruby', '-H:Path=' + ruby_bindir, '-H:GreyToBlackObjectVisitorDiagnosticHistory=' + str(debug_gr_9912)])
                truffleruby_suite = mx.suite('truffleruby')
                truffleruby_suite.extensions.ruby_testdownstream_aot([ruby_image, 'spec', 'release'])
Exemplo n.º 3
0
def gate_sulong(tasks):
    with Task('Run SulongSuite tests as native-image', tasks, tags=[VmGateTasks.sulong]) as t:
        if t:
            lli = join(mx_vm.graalvm_output(), 'bin', 'lli')
            sulong = mx.suite('sulong')
            sulong.extensions.testLLVMImage(lli, libPath=False, unittestArgs=['--enable-timing'])

    with Task('Run Sulong interop tests as native-image', tasks, tags=[VmGateTasks.sulong]) as t:
        if t:
            sulong = mx.suite('sulong')
            native_image_context, svm = graalvm_svm()
            with native_image_context(svm.IMAGE_ASSERTION_FLAGS) as native_image:
                # TODO Use mx_vm.get_final_graalvm_distribution().find_single_source_location to rewire SULONG_LIBS
                sulong_libs = join(mx_vm.graalvm_output(), 'jre', 'languages', 'llvm')
                def distribution_paths(dname):
                    path_substitutions = {
                        'SULONG_LIBS': sulong_libs
                    }
                    return path_substitutions.get(dname, mx._get_dependency_path(dname))
                mx_subst.path_substitutions.register_with_arg('path', distribution_paths)
                sulong.extensions.runLLVMUnittests(functools.partial(svm.native_junit, native_image, build_args=['--language:llvm']))
Exemplo n.º 4
0
def graalvm_svm():
    """
    Gives access to image building withing the GraalVM release. Requires dynamic import of substratevm.
    """
    native_image_cmd = join(mx_vm.graalvm_output(), 'bin', 'native-image')
    svm = mx.suite('substratevm')
    if not exists(native_image_cmd) or not svm:
        mx.abort("Image building not accessible in GraalVM {}. Build GraalVM with native-image support".format(mx_vm.graalvm_dist_name()))
    @contextmanager
    def native_image_context(common_args=None, hosted_assertions=True):
        with svm.extensions.native_image_context(common_args, hosted_assertions, native_image_cmd=native_image_cmd) as native_image:
            yield native_image
    return native_image_context, svm.extensions
Exemplo n.º 5
0
    def build(self):
        if not self.subject.build:
            mx.log("...skip build of {}".format(self.subject))
            return
        mx.log('...perform build of {}'.format(self.subject))

        rubyDir = _suite.dir
        mavenDir = os.path.join(rubyDir, 'mxbuild', 'mvn')

        # HACK: since the maven executable plugin does not configure the
        # java executable that is used we unfortunately need to append it to the PATH
        javaHome = os.getenv('JAVA_HOME')
        if javaHome:
            os.environ["PATH"] = os.environ["JAVA_HOME"] + '/bin' + os.pathsep + os.environ["PATH"]

        mx.logv('Setting PATH to {}'.format(os.environ["PATH"]))
        mx.logv('Calling java -version')
        mx.run(['java', '-version'])

        # Truffle version

        truffle = mx.suite('truffle')
        truffle_commit = truffle.vc.parent(truffle.dir)
        maven_version_arg = '-Dtruffle.version=' + truffle_commit
        maven_repo_arg = '-Dmaven.repo.local=' + mavenDir
        
        mx.run_mx(['maven-install', '--repo', mavenDir, '--only', 'TRUFFLE_API,TRUFFLE_DEBUG,TRUFFLE_DSL_PROCESSOR,TRUFFLE_TCK'], suite=truffle)

        open(os.path.join(rubyDir, 'VERSION'), 'w').write('graal-vm\n')

        # Build jruby-truffle
        
        env = os.environ.copy()
        env['JRUBY_BUILD_MORE_QUIET'] = 'true'

        mx.run_maven(['-q', '--version', maven_repo_arg], nonZeroIsFatal=False, cwd=rubyDir, env=env)

        mx.log('Building without tests')

        mx.run_maven(['-q', '-DskipTests', maven_version_arg, maven_repo_arg], cwd=rubyDir, env=env)

        mx.log('Building complete version')

        mx.run_maven(['-q', '-Pcomplete', '-DskipTests', maven_version_arg, maven_repo_arg], cwd=rubyDir, env=env)
        mx.run(['zip', '-d', 'maven/jruby-complete/target/jruby-complete-graal-vm.jar', 'META-INF/jruby.home/lib/*'], cwd=rubyDir)
        mx.run(['bin/jruby', 'bin/gem', 'install', 'bundler', '-v', '1.10.6'], cwd=rubyDir)
    
        mx.log('...finished build of {}'.format(self.subject))
Exemplo n.º 6
0
    def build(self):
        if not self.subject.build:
            mx.log("...skip build of {}".format(self.subject))
            return
        mx.log('...perform build of {}'.format(self.subject))

        rubyDir = _suite.dir

        # HACK: since the maven executable plugin does not configure the
        # java executable that is used we unfortunately need to append it to the PATH
        javaHome = os.getenv('JAVA_HOME')
        if javaHome:
            os.environ["PATH"] = os.environ["JAVA_HOME"] + '/bin' + os.pathsep + os.environ["PATH"]

        mx.logv('Setting PATH to {}'.format(os.environ["PATH"]))
        mx.logv('Calling java -version')
        mx.run(['java', '-version'])

        # Truffle version

        truffle = mx.suite('truffle')
        truffle_commit = truffle.vc.parent(truffle.dir)

        mx.run_mx(['maven-install'], suite=truffle)

        open(join(rubyDir, 'VERSION'), 'w').write('graal-vm\n')

        # Build jruby-truffle and

        mx.run(['find', '.'], nonZeroIsFatal=False, cwd=rubyDir)
        mx.run_maven(['--version'], nonZeroIsFatal=False, cwd=rubyDir)

        mx.log('Building without tests')

        mx.run_maven(['-DskipTests', '-Dtruffle.version=' + truffle_commit], cwd=rubyDir)

        mx.log('Building complete version')

        mx.run_maven(['-Pcomplete', '-DskipTests', '-Dtruffle.version=' + truffle_commit], cwd=rubyDir)
        mx.run(['zip', '-d', 'maven/jruby-complete/target/jruby-complete-graal-vm.jar', 'META-INF/jruby.home/lib/*'], cwd=rubyDir)
        mx.run(['bin/jruby', 'bin/gem', 'install', 'bundler', '-v', '1.10.6'], cwd=rubyDir)
Exemplo n.º 7
0
        suTruffleOptions = [
            '-Dgraal.TruffleBackgroundCompilation=false',
            '-Dgraal.TruffleTimeThreshold=1000000',
            '-Dgraal.TruffleInliningMaxCallerSize=10000',
            '-Dgraal.TruffleCompilationExceptionsAreFatal=true',
            mx_subst.path_substitutions.substitute('-Dpolyglot.llvm.libraryPath=<path:SULONG_LIBS>'),
            '-Dpolyglot.llvm.libraries=libgmp.so.10']
        sulongCmdLine = suTruffleOptions + mx_sulong.getClasspathOptions() + ['-XX:-UseJVMCIClassLoader', "com.oracle.truffle.llvm.launcher.LLVMLauncher"] + ['bench.bc']
        result = self.host_vm().run(cwd, sulongCmdLine + args)

        # reset current Directory
        os.chdir(self.currentDir)

        return result

    def hosting_registry(self):
        return java_vm_registry

_suite = mx.suite("sulong")

native_vm_registry = VmRegistry("Native", known_host_registries=[java_vm_registry])
native_vm_registry.add_vm(GccVm('O0', ['-O0']), _suite)
native_vm_registry.add_vm(ClangVm('O0', ['-O0']), _suite)
native_vm_registry.add_vm(GccVm('O1', ['-O1']), _suite)
native_vm_registry.add_vm(ClangVm('O1', ['-O1']), _suite)
native_vm_registry.add_vm(GccVm('O2', ['-O2']), _suite)
native_vm_registry.add_vm(ClangVm('O2', ['-O2']), _suite)
native_vm_registry.add_vm(GccVm('O3', ['-O3']), _suite)
native_vm_registry.add_vm(ClangVm('O3', ['-O3']), _suite)
native_vm_registry.add_vm(SulongVm(), _suite, 10)
Exemplo n.º 8
0
def register_js_vms():
    if mx.suite('js-benchmarks', fatalIfMissing=False):
        import mx_js_benchmarks
        _suite = mx.suite('graal-js')
        mx_js_benchmarks.add_vm(GraalJsVm('default', []), _suite, 10)
Exemplo n.º 9
0
def _sulong_options():
    mx_sulong = mx.suite("sulong", fatalIfMissing=False)
    if mx_sulong:
        return ['-Dpolyglot.llvm.libraryPath=' + mx_sulong.dir + '/mxbuild/sulong-libs']
    else:
        return []
Exemplo n.º 10
0
import platform, subprocess
import math
from os.path import join, exists
import mx
import mx_benchmark

from mx_zippy_bench_param import benchmarks_list

# mx asv-benchmark "asv-zippy-normal:*"
# mx asv-benchmark "asv-pypy3-normal:*"
# mx asv-benchmark "asv-cpython3.5-micro:*"
# mx asv-benchmark --list
# mx asv-benchmark --generate-asv-conf
# ...

_mx_graal = mx.suite("graal-core", fatalIfMissing=False)
_suite = mx.suite('zippy')
asv_env = os.environ.get("ZIPPY_ASV_PATH")
if not asv_env:
    asv_env = _suite.dir

active_branch = _suite.vc.active_branch(_suite.vc_dir, abortOnError=False)
active_branch = ['master'] if not active_branch else [ active_branch ]
url = _suite.vc.default_pull(_suite.vc_dir).replace('.git','')
url = url if 'html' in url else "https://github.com/securesystemslab/zippy"
html_dir = asv_env + '/html'
asv_dir = asv_env + '/asv/'
asv_results_dir = asv_dir + '/results/'
machine_name = os.environ.get("MACHINE_NAME")
if not machine_name:
    machine_name = platform.node()
Exemplo n.º 11
0
def create_asm_parser(args=None, out=None):
    """create the inline assembly parser using antlr"""
    mx.suite("truffle").extensions.create_parser("com.oracle.truffle.llvm.asm.amd64", "com.oracle.truffle.llvm.asm.amd64", "InlineAssembly", COPYRIGHT_HEADER_BSD, args, out)
Exemplo n.º 12
0
from os.path import join, sep
from argparse import ArgumentParser
import mx
import mx_gate
import mx_fastr_pkgs
import os

'''
This is the launchpad for all the functions available for building/running/testing/analyzing
FastR. FastR can run with or without the Graal compiler enabled. As a convenience if the
graal-core suite is detected then the use of the Graal compiler is enabled without any
additional command line options being required to the mx command, i.e. it is as if --jdk jvmci
was passed as an mx global option.
'''

_fastr_suite = mx.suite('fastr')
'''
If this is None, then we run under the standard VM in interpreted mode only.
'''
_mx_graal = mx.suite("graal-core", fatalIfMissing=False)

_r_command_project = 'com.oracle.truffle.r.engine'
_repl_command = 'com.oracle.truffle.tools.debug.shell.client.SimpleREPLClient'
_command_class_dict = {'r': _r_command_project + ".shell.RCommand",
                       'rscript': _r_command_project + ".shell.RscriptCommand",
                        'rrepl': _repl_command,
                        'rembed': _r_command_project + ".shell.REmbedded",
                    }
# benchmarking support
def r_path():
    return join(_fastr_suite.dir, 'bin', 'R')
Exemplo n.º 13
0
def _unittest(args, annotations, prefixCp="", blacklist=None, whitelist=None, verbose=False, very_verbose=False, fail_fast=False, enable_timing=False, regex=None, color=False, eager_stacktrace=False, gc_after_test=False, suite=None, repeat=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 very_verbose:
        coreArgs.append('-JUnitVeryVerbose')
    elif 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')
    if repeat:
        coreArgs.append('-JUnitRepeat')
        coreArgs.append(repeat)


    def harness(unittestDeps, 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()]

        jdk = vmLauncher.jdk()
        vmArgs += mx.get_runtime_jvm_args(unittestDeps, cp_prefix=prefixCp+coreCp, jdk=jdk)

        # suppress menubar and dock when running on Mac
        vmArgs = prefixArgs + ['-Djava.awt.headless=true'] + vmArgs

        if jdk.javaCompliance > '1.8':
            # This is required to access jdk.internal.module.Modules for supporting
            # the @AddExports annotation.
            vmArgs = vmArgs + ['--add-exports=java.base/jdk.internal.module=ALL-UNNAMED']

        # 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)
Exemplo n.º 14
0
# or visit www.oracle.com if you need additional information or have any
# questions.
#

import re
import argparse

import mx
import mx_benchmark
import mx_espresso

from mx_benchmark import GuestVm, JavaVm
from mx_java_benchmarks import ScalaDaCapoBenchmarkSuite
from mx_java_benchmarks import _daCapoScalaConfig

_suite = mx.suite('espresso')


class EspressoVm(GuestVm, JavaVm):
    def __init__(self, config_name, options, host_vm=None):
        super(EspressoVm, self).__init__(host_vm=host_vm)
        self._config_name = config_name
        self._options = options

    def name(self):
        return 'espresso'

    def config_name(self):
        return self._config_name

    def hosting_registry(self):
Exemplo n.º 15
0
def updategraalinopenjdk(args):
    """updates the Graal sources in OpenJDK"""
    parser = ArgumentParser(prog='mx updategraalinopenjdk')
    parser.add_argument(
        '--pretty',
        help=
        'value for --pretty when logging the changes since the last JDK* tag')
    parser.add_argument('jdkrepo', help='path to the local OpenJDK repo')
    parser.add_argument('version',
                        type=int,
                        help='Java version of the OpenJDK repo')

    args = parser.parse_args(args)

    if mx_compiler.jdk.javaCompliance.value < args.version:
        mx.abort(
            'JAVA_HOME/--java-home must be Java version {} or greater: {}'.
            format(args.version, mx_compiler.jdk))

    graal_modules = [
        # JDK module jdk.internal.vm.compiler is composed of sources from:
        GraalJDKModule(
            'jdk.internal.vm.compiler',
            # 1. Classes in the compiler suite under the org.graalvm namespace except for packages
            #    or projects whose names include "truffle", "management", "core.llvm" or "replacements.llvm"
            [
                SuiteJDKInfo('compiler', ['org.graalvm'], [
                    'truffle', 'management', 'core.llvm', 'replacements.llvm'
                ]),
                # 2. Classes in the sdk suite under the org.graalvm.collections and org.graalvm.word namespaces
                SuiteJDKInfo(
                    'sdk', ['org.graalvm.collections', 'org.graalvm.word'], [])
            ]),
        # JDK module jdk.internal.vm.compiler.management is composed of sources from:
        GraalJDKModule(
            'jdk.internal.vm.compiler.management',
            # 1. Classes in the compiler suite under the org.graalvm.compiler.hotspot.management namespace
            [
                SuiteJDKInfo('compiler',
                             ['org.graalvm.compiler.hotspot.management'], [])
            ]),
        # JDK module jdk.aot is composed of sources from:
        GraalJDKModule(
            'jdk.aot',
            # 1. Classes in the compiler suite under the jdk.tools.jaotc namespace
            [SuiteJDKInfo('compiler', ['jdk.tools.jaotc'], [])]),
    ]

    # Strings to be replaced in files copied to OpenJDK.
    replacements = {
        'published by the Free Software Foundation.  Oracle designates this\n * particular file as subject to the "Classpath" exception as provided\n * by Oracle in the LICENSE file that accompanied this code.':
        'published by the Free Software Foundation.',
        _read_sibling_file('upl_substring.txt'):
        _read_sibling_file('gplv2_substring.txt')
    }

    # Strings that must not exist in OpenJDK source files. This is applied after replacements are made.
    blacklist = ['"Classpath" exception']

    jdkrepo = args.jdkrepo
    git_repo = _is_git_repo(jdkrepo)

    for m in graal_modules:
        m_src_dir = join(jdkrepo, 'src', m.name)
        if not exists(m_src_dir):
            mx.abort(jdkrepo + ' does not look like a JDK repo - ' +
                     m_src_dir + ' does not exist')

    def run_output(args, cwd=None):
        out = mx.OutputCapture()
        mx.run(args, cwd=cwd, out=out, err=out)
        return out.data

    for m in graal_modules:
        m_src_dir = join('src', m.name)
        mx.log('Checking ' + m_src_dir)
        if git_repo:
            out = run_output(['git', 'status', '-s', m_src_dir], cwd=jdkrepo)
        else:
            out = run_output(['hg', 'status', m_src_dir], cwd=jdkrepo)
        if out:
            mx.abort(jdkrepo + ' is not "clean":' + '\n' +
                     out[:min(200, len(out))] + '...')

    for dirpath, _, filenames in os.walk(join(jdkrepo, 'make')):
        for filename in filenames:
            if filename.endswith('.gmk'):
                rename_packages(join(dirpath, filename), True)

    java_package_re = re.compile(
        r"^\s*package\s+(?P<package>[a-zA-Z_][\w\.]*)\s*;$", re.MULTILINE)

    copied_source_dirs = []
    jdk_internal_vm_compiler_EXCLUDES = set()  # pylint: disable=invalid-name
    jdk_internal_vm_compiler_test_SRC = set()  # pylint: disable=invalid-name
    # Add org.graalvm.compiler.processor since it is only a dependency
    # for (most) Graal annotation processors and is not needed to
    # run Graal.
    jdk_internal_vm_compiler_EXCLUDES.add('org.graalvm.compiler.processor')
    for m in graal_modules:
        classes_dir = join(jdkrepo, 'src', m.name, 'share', 'classes')
        for info in m.suites:
            mx.log('Processing ' + m.name + ':' + info.name)
            for e in os.listdir(classes_dir):
                if any(inc in e for inc in info.includes) and not any(
                        ex in e for ex in info.excludes):
                    project_dir = join(classes_dir, e)
                    shutil.rmtree(project_dir)
                    mx.log('  removed ' + project_dir)
            suite = mx.suite(info.name)

            worklist = []

            for p in [e for e in suite.projects if e.isJavaProject()]:
                if any(inc in p.name for inc in info.includes) and not any(
                        ex in p.name for ex in info.excludes):
                    assert len(p.source_dirs()) == 1, p
                    version = 0
                    new_project_name = p.name
                    if hasattr(p, 'multiReleaseJarVersion'):
                        version = int(getattr(p, 'multiReleaseJarVersion'))
                        if version <= args.version:
                            base_project = _find_version_base_project(p)
                            new_project_name = base_project.name
                        else:
                            continue

                    for old_name, new_name in package_renamings.items():
                        if new_project_name.startswith(old_name):
                            new_project_name = new_project_name.replace(
                                old_name, new_name)

                    source_dir = p.source_dirs()[0]
                    target_dir = join(classes_dir, new_project_name, 'src')
                    copied_source_dirs.append(source_dir)

                    workitem = (version, p, source_dir, target_dir)
                    worklist.append(workitem)

            # Ensure versioned resources are copied in the right order
            # such that higher versions override lower versions.
            worklist = sorted(worklist)

            for version, p, source_dir, target_dir in worklist:
                first_file = True
                for dirpath, _, filenames in os.walk(source_dir):
                    for filename in filenames:
                        src_file = join(dirpath, filename)
                        dst_file = join(target_dir,
                                        os.path.relpath(src_file, source_dir))
                        with open(src_file) as fp:
                            contents = fp.read()
                        old_line_count = len(contents.split('\n'))
                        if filename.endswith('.java'):
                            for old_name, new_name in package_renamings.items(
                            ):
                                old_name_as_dir = old_name.replace('.', os.sep)
                                if old_name_as_dir in src_file:
                                    new_name_as_dir = new_name.replace(
                                        '.', os.sep)
                                    dst = src_file.replace(
                                        old_name_as_dir, new_name_as_dir)
                                    dst_file = join(
                                        target_dir,
                                        os.path.relpath(dst, source_dir))
                                contents = contents.replace(old_name, new_name)
                            for old_line, new_line in replacements.items():
                                contents = contents.replace(old_line, new_line)

                            match = java_package_re.search(contents)
                            if not match:
                                mx.abort(
                                    'Could not find package declaration in {}'.
                                    format(src_file))
                            java_package = match.group('package')
                            if any(ex in java_package for ex in info.excludes):
                                mx.log('  excluding ' + filename)
                                continue

                            new_line_count = len(contents.split('\n'))
                            if new_line_count > old_line_count:
                                mx.abort(
                                    'Pattern replacement caused line count to grow from {} to {} in {}'
                                    .format(old_line_count, new_line_count,
                                            src_file))
                            else:
                                if new_line_count < old_line_count:
                                    contents = contents.replace(
                                        '\npackage ', '\n' *
                                        (old_line_count - new_line_count) +
                                        '\npackage ')
                            new_line_count = len(contents.split('\n'))
                            if new_line_count != old_line_count:
                                mx.abort('Unable to correct line count for {}'.
                                         format(src_file))
                            for forbidden in blacklist:
                                if forbidden in contents:
                                    mx.abort(
                                        'Found blacklisted pattern \'{}\' in {}'
                                        .format(forbidden, src_file))
                        dst_dir = os.path.dirname(dst_file)
                        if not exists(dst_dir):
                            os.makedirs(dst_dir)
                        if first_file:
                            mx.log('  copying: ' + source_dir)
                            mx.log('       to: ' + target_dir)
                            if p.testProject or p.definedAnnotationProcessors:
                                to_exclude = p.name
                                for old_name, new_name in package_renamings.items(
                                ):
                                    if to_exclude.startswith(old_name):
                                        sfx = '' if to_exclude == old_name else to_exclude[
                                            len(old_name):]
                                        to_exclude = new_name + sfx
                                        break
                                jdk_internal_vm_compiler_EXCLUDES.add(
                                    to_exclude)
                                if p.testProject:
                                    jdk_internal_vm_compiler_test_SRC.add(
                                        to_exclude)
                            first_file = False
                        with open(dst_file, 'w') as fp:
                            fp.write(contents)

    def replace_lines(filename,
                      begin_lines,
                      end_line,
                      replace_lines,
                      old_line_check,
                      preserve_indent=False,
                      append_mode=False):
        mx.log('Updating ' + filename + '...')
        old_lines = []
        new_lines = []
        with open(filename) as fp:
            for begin_line in begin_lines:
                line = fp.readline()
                while line:
                    stripped_line = line.strip()
                    if stripped_line == begin_line:
                        new_lines.append(line)
                        break
                    new_lines.append(line)
                    line = fp.readline()
                assert line, begin_line + ' not found'

            lines = fp.readlines()
            line_in_def = True

            indent = 0
            if preserve_indent:
                line = lines[0]
                lstripped_line = line.lstrip()
                indent = len(line) - len(lstripped_line)

            if not append_mode:
                for replace in replace_lines:
                    new_lines.append(' ' * indent + replace)

            for line in lines:
                stripped_line = line.strip()
                if line_in_def:
                    if stripped_line == end_line:
                        line_in_def = False
                        new_lines.append(line)
                    else:
                        old_line_check(line)
                        if append_mode:
                            new_lines.append(line)
                    if append_mode and not line_in_def:
                        # reach end line and append new lines
                        for replace in replace_lines:
                            new_lines.append(replace)
                else:
                    new_lines.append(line)
        with open(filename, 'w') as fp:
            for line in new_lines:
                fp.write(line)
        return old_lines

    def single_column_with_continuation(line):
        parts = line.split()
        assert len(parts) == 2 and parts[1] == '\\', line

    # Update jdk.internal.vm.compiler.EXCLUDES in make/CompileJavaModules.gmk
    # to exclude all test, benchmark and annotation processor packages.
    CompileJavaModules_gmk = join(jdkrepo, 'make', 'CompileJavaModules.gmk')  # pylint: disable=invalid-name
    new_lines = []
    for pkg in sorted(jdk_internal_vm_compiler_EXCLUDES):
        new_lines.append(pkg + ' \\\n')
    begin_lines = ['jdk.internal.vm.compiler_EXCLUDES += \\']
    end_line = '#'
    old_line_check = single_column_with_continuation
    replace_lines(CompileJavaModules_gmk,
                  begin_lines,
                  end_line,
                  new_lines,
                  old_line_check,
                  preserve_indent=True)

    if args.version == 11:
        # add aot exclude
        out = run_output(['grep', 'jdk.aot_EXCLUDES', CompileJavaModules_gmk],
                         cwd=jdkrepo)
        if out:
            # replace existing exclude setting
            begin_lines = ['jdk.aot_EXCLUDES += \\']
            end_line = '#'
            new_lines = ['jdk.tools.jaotc.test \\\n']
            replace_lines(CompileJavaModules_gmk,
                          begin_lines,
                          end_line,
                          new_lines,
                          old_line_check,
                          preserve_indent=True)
        else:
            # append exclude setting after jdk.internal.vm.compiler_EXCLUDES
            new_lines = [
                '\n', 'jdk.aot_EXCLUDES += \\\n',
                '    jdk.tools.jaotc.test \\\n', '    #\n', '\n'
            ]  # indent is inlined
            replace_lines(CompileJavaModules_gmk,
                          begin_lines,
                          end_line,
                          new_lines,
                          old_line_check,
                          preserve_indent=True,
                          append_mode=True)

    # Update 'SRC' in the 'Compile graalunit tests' section of make/test/JtregGraalUnit.gmk
    # to include all test packages.
    JtregGraalUnit_gmk = join(jdkrepo, 'make', 'test', 'JtregGraalUnit.gmk')  # pylint: disable=invalid-name
    new_lines = []
    jdk_internal_vm_compiler_test_SRC.discard('jdk.tools.jaotc.test')
    jdk_internal_vm_compiler_test_SRC.discard(
        'org.graalvm.compiler.microbenchmarks')
    jdk_internal_vm_compiler_test_SRC.discard(
        'org.graalvm.compiler.virtual.bench')
    jdk_internal_vm_compiler_test_SRC.discard('org.graalvm.micro.benchmarks')
    for pkg in sorted(jdk_internal_vm_compiler_test_SRC):
        new_lines.append('$(SRC_DIR)/' + pkg + '/src \\\n')
    if args.version == 11:
        begin_lines = ['### Compile and build graalunit tests', 'SRC := \\']
    else:
        begin_lines = ['### Compile graalunit tests', 'SRC := \\']
    end_line = ', \\'
    old_line_check = single_column_with_continuation
    replace_lines(JtregGraalUnit_gmk,
                  begin_lines,
                  end_line,
                  new_lines,
                  old_line_check,
                  preserve_indent=True)

    overwritten = ''
    if not git_repo:
        mx.log('Adding new files to HG...')
        m_src_dirs = []
        for m in graal_modules:
            m_src_dirs.append(join('src', m.name))
        out = run_output([
            'hg', 'log', '-r', 'last(keyword("Update Graal"))', '--template',
            '{rev}'
        ] + m_src_dirs,
                         cwd=jdkrepo)
        last_graal_update = out.strip()

        for m in graal_modules:
            m_src_dir = join('src', m.name)
            if last_graal_update:
                overwritten += run_output([
                    'hg', 'diff', '-r', last_graal_update, '-r', 'tip',
                    m_src_dir
                ],
                                          cwd=jdkrepo)
            mx.run(['hg', 'add', m_src_dir], cwd=jdkrepo)
        mx.log('Removing old files from HG...')
        for m in graal_modules:
            m_src_dir = join('src', m.name)
            out = run_output(['hg', 'status', '-dn', m_src_dir], cwd=jdkrepo)
            if out:
                mx.run(['hg', 'rm'] + out.split(), cwd=jdkrepo)

    out = run_output(['git', 'tag', '-l', 'JDK-*'],
                     cwd=mx_compiler._suite.vc_dir)
    last_jdk_tag = sorted(out.split(), reverse=True)[0]

    pretty = args.pretty or 'format:%h %ad %>(20) %an %s'
    out = run_output([
        'git', '--no-pager', 'log', '--merges', '--abbrev-commit',
        '--pretty=' + pretty, '--first-parent', '-r', last_jdk_tag + '..HEAD'
    ] + copied_source_dirs,
                     cwd=mx_compiler._suite.vc_dir)
    changes_file = 'changes-since-{}.txt'.format(last_jdk_tag)
    with open(changes_file, 'w') as fp:
        fp.write(out)
    mx.log('Saved changes since {} to {}'.format(
        last_jdk_tag, os.path.abspath(changes_file)))
    if overwritten:
        overwritten_file = 'overwritten-diffs.txt'
        with open(overwritten_file, 'w') as fp:
            fp.write(overwritten)
        mx.warn(
            'Overwritten changes detected in OpenJDK Graal! See diffs in ' +
            os.path.abspath(overwritten_file))
Exemplo n.º 16
0
 def __init__(self):
     super(JavaHome, self).__init__(mx.suite('mx'), 'JAVA_HOME',
                                    None)
     self.include_dirs = None
Exemplo n.º 17
0
import tarfile
import os
from os.path import join
import shutil
import subprocess
from argparse import ArgumentParser

import mx
import mx_subst
import mx_sdk
import re

_suite = mx.suite('trufflecourse')

def getClasspathOptions(extra_dists=None):
    """gets the classpath of the Sulong distributions"""
    return mx.get_runtime_jvm_args((extra_dists or []))

def runPlainAST(args=None, out=None, get_classpath_options=getClasspathOptions):
    dists = ["TruffleCourse"]
    return mx.run_java(get_classpath_options(dists) + ["-XX:+EnableJVMCI","-XX:+UseJVMCICompiler"] + 
    args+ ["org.truffle.cs.samples.PlainAST.PlainAST"], out=out,jdk=mx.get_jdk())

def runMJInterpreter(args=None, out=None, get_classpath_options=getClasspathOptions):
    dists = ["TruffleCourse"]
    return mx.run_java(get_classpath_options(dists) + ["-XX:+EnableJVMCI","-XX:+UseJVMCICompiler","-Dgraal.TraceTruffleCompilation=true", "-Dgraal.PrintGraph=Network", "-Dgraal.Dump=Truffle:5", "-Dgraal.TruffleBackgroundCompilation=false"] + 
    args+ ["org.truffle.cs.mj.main.MJRuntime"], out=out,jdk=mx.get_jdk())


def runPESamples(args=None, out=None, get_classpath_options=getClasspathOptions):
    dists = ["TruffleCourse"]
Exemplo n.º 18
0
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#

import mx
import mx_sdk_vm
from mx_unittest import unittest
from mx_gate import Task, add_gate_runner

_suite = mx.suite('regex')


def _tregex_tests_gate_runner(args, tasks):
    with Task('UnitTests', tasks, tags=['default', 'all']) as t:
        if t:
            unittest([
                '--enable-timing', '--very-verbose', 'com.oracle.truffle.regex'
            ])


mx_sdk_vm.register_graalvm_component(
    mx_sdk_vm.GraalVmLanguage(
        suite=_suite,
        name='TRegex',
        short_name='rgx',
Exemplo n.º 19
0
if IS_JDK9_AND_LATER:
    # Make Truffle.getRuntime() accessible for VM introspection
    BASE_VM_ARGS.append(
        '--add-opens=jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime=ALL-UNNAMED'
    )
    BASE_VM_ARGS_TESTING.append(
        '--add-opens=jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime=ALL-UNNAMED'
    )
else:
    # Tweaks for Java 8's Parallel GC (optimized for TruffleSqueak image)
    BASE_VM_ARGS.append('-XX:OldSize=256M')  # Initial tenured generation size
    BASE_VM_ARGS.append('-XX:NewSize=1G')  # Initial new generation size
    BASE_VM_ARGS.append('-XX:MetaspaceSize=32M')  # Initial size of Metaspaces

_suite = mx.suite('trufflesqueak')
_compiler = mx.suite('compiler', fatalIfMissing=False)
_svm = mx.suite('substratevm', fatalIfMissing=False)


def _graal_vm_args(args):
    graal_args = []

    if args.trace_compilation:
        graal_args += ['-Dgraal.TraceTruffleCompilation=true']

    if args.truffle_compilation_details:
        graal_args += [
            '-Dgraal.TraceTruffleCompilationDetails=true',
            '-Dgraal.TraceTruffleExpansionSource=true'
        ]
Exemplo n.º 20
0
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
# OF THE POSSIBILITY OF SUCH DAMAGE.

import os

import mx

_graalpython_suite = mx.suite('graalpython')

py = ".py"
_BASE_PATH = os.path.join(_graalpython_suite.dir, 'graalpython',
                          'com.oracle.graal.python.benchmarks', 'python')
HARNESS_PATH = os.path.join(_BASE_PATH, 'harness.py')

PATH_BENCH = os.path.join(_BASE_PATH, 'com.oracle.graal.python.benchmarks')
PATH_MICRO = os.path.join(_BASE_PATH, 'micro')
PATH_MESO = os.path.join(_BASE_PATH, 'meso')
PATH_MACRO = os.path.join(_BASE_PATH, 'macro')
PATH_WARMUP = os.path.join(_BASE_PATH, 'warmup')
PATH_INTEROP = os.path.join(_BASE_PATH, 'host_interop')

# ----------------------------------------------------------------------------------------------------------------------
#
Exemplo n.º 21
0
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

import sys
import os
import pipes
import shutil
import tarfile
from os.path import join, exists, isdir

import mx
import mx_unittest

TimeStampFile = mx.TimeStampFile

_suite = mx.suite('jruby')

rubyDists = [
    'RUBY',
    'RUBY-TEST'
]

def deploy_binary_if_truffle_head(args):
    """If the active branch is 'truffle-head', deploy binaries for the primary suite to remote maven repository."""
    primary_branch = 'truffle-head'
    active_branch = mx.VC.get_vc(_suite.dir).active_branch(_suite.dir)
    if active_branch == primary_branch:
        return mx.command_function('deploy-binary')(args)
    else:
        mx.log('The active branch is "%s". Binaries are deployed only if the active branch is "%s".' % (active_branch, primary_branch))
        return 0
Exemplo n.º 22
0
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
# ----------------------------------------------------------------------------------------------------

import os, shutil, zipfile, re
from os.path import join, exists
from argparse import ArgumentParser, REMAINDER

import mx

_suite = mx.suite('graal-core')

def _run_netbeans_app(app_name, env=None, args=None):
    args = [] if args is None else args
    dist = app_name.upper() + '_DIST'
    name = app_name.lower()
    extractPath = join(_suite.get_output_root())
    if mx.get_os() == 'windows':
        executable = join(extractPath, name, 'bin', name + '.exe')
    else:
        executable = join(extractPath, name, 'bin', name)

    # Check whether the current installation is up-to-date
    if exists(executable) and not exists(mx.library(dist).get_path(resolve=False)):
        mx.log('Updating ' + app_name)
        shutil.rmtree(join(extractPath, name))
Exemplo n.º 23
0
import os
from os.path import join, dirname, basename, exists, abspath
from argparse import ArgumentParser
import sanitycheck
import re

import mx
from mx_gate import Task
from sanitycheck import _noneAsEmptyList

from mx_unittest import unittest
from mx_graal_bench import dacapo
import mx_gate
import mx_unittest

_suite = mx.suite('graal')

_jdk = mx.get_jdk(tag='default')
assert _jdk.javaCompliance >= "1.9"

def isJVMCIEnabled(vm):
    return True

_jvmciModes = {
    'hosted' : ['-XX:+UnlockExperimentalVMOptions', '-XX:+EnableJVMCI'],
    'jit' : ['-XX:+UnlockExperimentalVMOptions', '-XX:+EnableJVMCI', '-XX:+UseJVMCICompiler'],
    'disabled' : []
}

def get_vm():
    """
Exemplo n.º 24
0
def _bench_image_params(bench_conf):
    image_dir = os.path.join(mx.suite('substratevm').dir, 'svmbenchbuild')
    js_image_name = 'js_' + bench_conf
    image_path = os.path.join(image_dir, js_image_name)
    return image_dir, js_image_name, image_path
Exemplo n.º 25
0
# questions.
#
# ----------------------------------------------------------------------------------------------------

import os
import re
import subprocess

import mx

from mx_unittest import unittest
from mx_sigtest import sigtest
from mx_gate import Task
import mx_gate

_suite = mx.suite("truffle")


def javadoc(args, vm=None):
    """build the Javadoc for all API packages"""
    mx.javadoc(["--unified"] + args)


def build(args, vm=None):
    """build the Java sources"""
    opts2 = mx.build(["--source", "1.7"] + args)
    assert len(opts2.remainder) == 0


def sl(args):
    """run an SL program"""
Exemplo n.º 26
0
import glob
import os
from os.path import exists, join, dirname, basename, isdir
import shutil
import sys

import mx
import mx_subst
import mx_unittest
import mx_sdk

if 'RUBY_BENCHMARKS' in os.environ:
    import mx_truffleruby_benchmark

_suite = mx.suite('truffleruby')
root = _suite.dir

# Project classes


class ArchiveProject(mx.ArchivableProject):
    def __init__(self, suite, name, deps, workingSets, theLicense, **args):
        mx.ArchivableProject.__init__(self, suite, name, deps, workingSets,
                                      theLicense)
        assert 'prefix' in args
        assert 'outputDir' in args

    def output_dir(self):
        return join(self.dir, self.outputDir)
Exemplo n.º 27
0
# questions.
#
# ----------------------------------------------------------------------------------------------------

import mx
import mx_vm
import mx_subst
from mx_gate import Task

import re
import subprocess
from os.path import join, exists
import functools
from contextlib import contextmanager

_suite = mx.suite('vm')


class VmGateTasks:
    compiler = 'compiler'
    substratevm = 'substratevm'
    sulong = 'sulong'
    graal_js = 'graal-js'
    graal_nodejs = 'graal-nodejs'
    truffleruby = 'truffleruby'
    ruby = 'ruby'
    fastr = 'fastr'
    graalpython = 'graalpython'
    integration = 'integration'

Exemplo n.º 28
0
def pkgtest(args):
    '''
    Package installation/testing.
    rc: 0 for success; 1: install fail, 2: test fail, 3: install&test fail
    '''

    libinstall, install_tmp = _create_libinstall(mx.suite('fastr'))
    stacktrace_args = ['--J', '@-DR:-PrintErrorStacktracesToFile -DR:+PrintErrorStacktraces']
    if "--quiet" in args:
        global quiet
        quiet = True

    install_args = args

    class OutputCapture:
        def __init__(self):
            self.install_data = None
            self.pkg = None
            self.mode = None
            self.start_install_pattern = re.compile(r"^BEGIN processing: (?P<package>[a-zA-Z0-9\.\-]+) .*")
            self.test_pattern = re.compile(r"^(?P<status>BEGIN|END) testing: (?P<package>[a-zA-Z0-9\.\-]+) .*")
            self.time_pattern = re.compile(r"^TEST_TIME: (?P<package>[a-zA-Z0-9\.\-]+) (?P<time>[0-9\.\-]+) .*")
            self.status_pattern = re.compile(r"^(?P<package>[a-zA-Z0-9\.\-]+): (?P<status>OK|FAILED).*")
            self.install_data = dict()
            self.install_status = dict()
            self.test_info = dict()

        def __call__(self, data):
            print data,
            if data == "BEGIN package installation\n":
                self.mode = "install"
                return
            elif data == "BEGIN install status\n":
                self.mode = "install_status"
                return
            elif data == "BEGIN package tests\n":
                self.mode = "test"
                return

            if self.mode == "install":
                start_install = re.match(self.start_install_pattern, data)
                if start_install:
                    pkg_name = start_install.group(1)
                    self.pkg = pkg_name
                    self.install_data[self.pkg] = ""
                if self.pkg:
                    self.install_data[self.pkg] += data
            elif self.mode == "install_status":
                if data == "END install status\n":
                    self.mode = None
                    return
                status = re.match(self.status_pattern, data)
                pkg_name = status.group(1)
                self.install_status[pkg_name] = status.group(2) == "OK"
            elif self.mode == "test":
                test_match = re.match(self.test_pattern, data)
                if test_match:
                    begin_end = test_match.group(1)
                    pkg_name = test_match.group(2)
                    if begin_end == "END":
                        _get_test_outputs('fastr', pkg_name, self.test_info)
                else:
                    time_match = re.match(self.time_pattern, data)
                    if time_match:
                        pkg_name = time_match.group(1)
                        test_time = time_match.group(2)
                        with open(join('test', pkg_name, 'test_time'), 'w') as f:
                            f.write(test_time)
    env = os.environ.copy()
    env["TMPDIR"] = install_tmp
    env['R_LIBS_USER'] = libinstall

    # TODO enable but via installing Suggests
    #_install_vignette_support('FastR', env)

    out = OutputCapture()
    # install and test the packages, unless just listing versions
    if not '--list-versions' in install_args:
        install_args += ['--run-tests']
        if not '--print-install-status' in install_args:
            install_args += ['--print-install-status']

    _log_step('BEGIN', 'install/test', 'FastR')
    # Currently installpkgs does not set a return code (in install.cran.packages.R)
    rc = mx_fastr._installpkgs(stacktrace_args + install_args, nonZeroIsFatal=False, env=env, out=out, err=out)
    if rc == 100:
        # fatal error connecting to package repo
        mx.abort(rc)

    rc = 0
    for status in out.install_status.itervalues():
        if not status:
            rc = 1
    _log_step('END', 'install/test', 'FastR')

    single_pkg = len(out.install_status) == 1
    install_failure = single_pkg and rc == 1
    if '--run-tests' in install_args and not install_failure:
        # in order to compare the test output with GnuR we have to install/test the same
        # set of packages with GnuR, which must be present as a sibling suite
        ok_pkgs = [k for k, v in out.install_status.iteritems() if v]
        _gnur_install_test(ok_pkgs)
        _set_test_status(out.test_info)
        print 'Test Status'
        for pkg, test_status in out.test_info.iteritems():
            if test_status.status != "OK":
                rc = rc | 2
            print '{0}: {1}'.format(pkg, test_status.status)

    shutil.rmtree(install_tmp, ignore_errors=True)
    return rc
Exemplo n.º 29
0
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
# ----------------------------------------------------------------------------------------------------

import os, shutil, tarfile
from os.path import join, exists, getmtime

import mx_graal_js_benchmark
import mx, mx_sdk
from mx_gate import Task, add_gate_runner
from mx_unittest import unittest

_suite = mx.suite('graal-js')


class GraalJsDefaultTags:
    default = 'default'
    tck = 'tck'
    all = 'all'


def _graal_js_gate_runner(args, tasks):
    with Task('TestJSCommand',
              tasks,
              tags=[GraalJsDefaultTags.default, GraalJsDefaultTags.all]) as t:
        if t:
            js(['-Dtruffle.js.ProfileTime=true', '-e', '""'])
Exemplo n.º 30
0
    # Reflective access to java.lang.invoke.VarHandle*.
    GRAAL_COMPILER_FLAGS += ['--add-opens', 'java.base/java.lang.invoke=ALL-UNNAMED']
    # Reflective access to java.lang.Reference.referent.
    GRAAL_COMPILER_FLAGS += ['--add-opens', 'java.base/java.lang.ref=ALL-UNNAMED']
    # Reflective access to org.graalvm.nativeimage.impl.ImageSingletonsSupport.
    GRAAL_COMPILER_FLAGS += ['--add-exports', 'org.graalvm.graal_sdk/org.graalvm.nativeimage.impl=ALL-UNNAMED']
    # Reflective access to jdk.internal.ref.CleanerImpl$PhantomCleanableRef.
    GRAAL_COMPILER_FLAGS += ['--add-opens', 'java.base/jdk.internal.ref=ALL-UNNAMED']
    # Disable the check for JDK-8 graal version.
    GRAAL_COMPILER_FLAGS += ['-Dsubstratevm.IgnoreGraalVersionCheck=true']
    # Reflective access to java.net.URL.getURLStreamHandler.
    GRAAL_COMPILER_FLAGS += ['--add-opens', 'java.base/java.net=ALL-UNNAMED']


IMAGE_ASSERTION_FLAGS = ['-H:+VerifyGraalGraphs', '-H:+VerifyGraalGraphEdges', '-H:+VerifyPhases']
suite = mx.suite('substratevm')
svmSuites = [suite]

orig_command_gate = mx.command_function('gate')
orig_command_build = mx.command_function('build')

gate_run = False

def gate(args):
    global gate_run
    gate_run = True
    orig_command_gate(args)

def build(args, vm=None):
    if any([opt in args for opt in ['-h', '--help']]):
        orig_command_build(args, vm)
Exemplo n.º 31
0
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
# ----------------------------------------------------------------------------------------------------

import os, shutil, zipfile, re
from os.path import join, exists
from argparse import ArgumentParser, REMAINDER

import mx

_suite = mx.suite('compiler')


def run_netbeans_app(app_name, env=None, args=None):
    args = [] if args is None else args
    dist = app_name.upper() + '_DIST'
    name = app_name.lower()
    extractPath = join(_suite.get_output_root())
    if mx.get_os() == 'windows':
        executable = join(extractPath, name, 'bin', name + '.exe')
    else:
        executable = join(extractPath, name, 'bin', name)

    # Check whether the current installation is up-to-date
    versionFile = join(extractPath, name, mx.library(dist).sha1)
    if exists(executable) and not exists(versionFile):
Exemplo n.º 32
0
    def run_java(self,
                 args,
                 out=None,
                 err=None,
                 cwd=None,
                 nonZeroIsFatal=False):

        if '-version' in args:
            return super(NativeImageVM,
                         self).run_java(args,
                                        out=out,
                                        err=err,
                                        cwd=cwd,
                                        nonZeroIsFatal=nonZeroIsFatal)
        else:
            # never fatal, we handle it ourselves
            config = NativeImageVM.BenchmarkConfig()
            original_java_run_args = config.parse(args)

            executable, classpath_arguments, system_properties, image_run_args = NativeImageVM.extract_benchmark_arguments(
                original_java_run_args)
            executable_suffix = (
                '-' + config.benchmark_name) if config.benchmark_name else ''
            executable_name = (
                os.path.splitext(os.path.basename(executable[1]))[0] +
                executable_suffix if executable[0] == '-jar' else
                executable[0] + executable_suffix).lower()
            final_image_name = executable_name + '-' + self.config_name()
            stages = NativeImageVM.Stages(
                config, out, err, final_image_name, self.is_gate,
                True if self.is_gate else nonZeroIsFatal,
                os.path.abspath(cwd if cwd else os.getcwd()))

            bench_suite = mx.suite('vm')
            root_dir = config.benchmark_output_dir if config.benchmark_output_dir else mx.join(
                bench_suite.dir, 'mxbuild')
            config.output_dir = mx.join(
                os.path.abspath(root_dir), 'native-image-bench-' +
                executable_name + '-' + self.config_name())
            if not os.path.exists(config.output_dir):
                os.makedirs(config.output_dir)

            config.profile_dir = config.output_dir
            profile_path_no_extension = os.path.join(config.profile_dir,
                                                     executable_name)
            profile_file_extension = '.iprof'
            latest_profile_path = profile_path_no_extension + '-latest' + profile_file_extension
            config.config_dir = os.path.join(config.output_dir, 'config')
            if not os.path.exists(config.config_dir):
                os.makedirs(config.config_dir)
            config.log_dir = config.output_dir

            if stages.change_stage('agent'):
                profile_path = profile_path_no_extension + '-agent' + profile_file_extension
                hotspot_vm_args = [
                    '-ea', '-esa'
                ] if self.is_gate and not config.skip_agent_assertions else []
                hotspot_run_args = []
                hotspot_vm_args += [
                    '-agentlib:native-image-agent=config-output-dir=' +
                    str(config.config_dir), '-XX:-UseJVMCINativeLibrary'
                ]

                if self.hotspot_pgo:
                    hotspot_vm_args += [
                        '-Dgraal.PGOInstrument=' + profile_path
                    ]

                if self.hotspot_pgo and not self.is_gate and config.extra_agent_profile_run_args:
                    hotspot_run_args += config.extra_agent_profile_run_args
                elif config.extra_agent_run_args:
                    hotspot_run_args += config.extra_agent_run_args
                else:
                    hotspot_run_args += image_run_args

                hotspot_args = hotspot_vm_args + classpath_arguments + executable + system_properties + hotspot_run_args
                java_command = os.path.join(
                    mx_sdk_vm_impl.graalvm_home(fatalIfMissing=True), 'bin',
                    'java')
                with stages.set_command([java_command] + hotspot_args) as s:
                    s.execute_command()
                    if self.hotspot_pgo and s.exit_code == 0:
                        mx.copyfile(profile_path, latest_profile_path)

            base_image_build_args = [
                os.path.join(mx_sdk_vm_impl.graalvm_home(fatalIfMissing=True),
                             'bin', 'native-image')
            ]
            base_image_build_args += [
                '--no-fallback', '--no-server', '-g',
                '--allow-incomplete-classpath'
            ]
            base_image_build_args += [
                '-J-ea', '-J-esa', '-H:+VerifyGraalGraphs', '-H:+VerifyPhases'
            ] if self.is_gate else []
            base_image_build_args += system_properties
            base_image_build_args += classpath_arguments
            base_image_build_args += executable
            base_image_build_args += ['-H:Path=' + config.output_dir]
            base_image_build_args += [
                '-H:ConfigurationFileDirectories=' + config.config_dir
            ]

            if self.is_llvm:
                base_image_build_args += [
                    '-H:CompilerBackend=llvm',
                    '-H:Features=org.graalvm.home.HomeFinderFeature',
                    '-H:DeadlockWatchdogInterval=0'
                ]
            base_image_build_args += config.extra_image_build_arguments

            if not self.hotspot_pgo:
                # Native Image profile collection
                i = 0
                instrumented_iterations = self.pgo_instrumented_iterations if config.pgo_iteration_num is None else int(
                    config.pgo_iteration_num)
                while i < instrumented_iterations:
                    profile_path = profile_path_no_extension + '-' + str(
                        i) + profile_file_extension
                    instrumentation_image_name = executable_name + '-instrument-' + str(
                        i)
                    instrumentation_image_latest = executable_name + '-instrument-latest'

                    image_path = os.path.join(config.output_dir,
                                              instrumentation_image_name)
                    image_path_latest = os.path.join(
                        config.output_dir, instrumentation_image_latest)
                    if stages.change_stage('instrument-image', str(i)):
                        executable_name_args = [
                            '-H:Name=' + instrumentation_image_name
                        ]
                        pgo_verification_output_path = os.path.join(
                            config.output_dir,
                            instrumentation_image_name + '-probabilities.log')
                        pgo_args = [
                            '--pgo=' + latest_profile_path,
                            '-H:+VerifyPGOProfiles',
                            '-H:VerificationDumpFile=' +
                            pgo_verification_output_path
                        ]
                        instrument_args = ['--pgo-instrument'
                                           ] + ([] if i == 0 else pgo_args)
                        instrument_args += [
                            '-H:+InlineAllExplored'
                        ] if self.pgo_inline_explored else []
                        instrument_args += [
                            '-H:' +
                            ('+' if self.pgo_context_sensitive else '-') +
                            'EnablePGOContextSensitivity'
                        ]

                        with stages.set_command(base_image_build_args +
                                                executable_name_args +
                                                instrument_args) as s:
                            s.execute_command()
                            if s.exit_code == 0:
                                mx.copyfile(image_path, image_path_latest)
                            if i + 1 == instrumented_iterations and s.exit_code == 0:
                                image_size = os.stat(image_path).st_size
                                out('Instrumented image size: ' +
                                    str(image_size) + ' B')

                    if stages.change_stage('instrument-run', str(i)):
                        image_run_cmd = [image_path]
                        image_run_cmd += [
                            '-XX:ProfilesDumpFile=' + profile_path
                        ]
                        if config.extra_profile_run_args:
                            image_run_cmd += config.extra_profile_run_args
                        else:
                            image_run_cmd += image_run_args + config.extra_run_args
                        with stages.set_command(image_run_cmd) as s:
                            s.execute_command()
                            if s.exit_code == 0:
                                mx.copyfile(profile_path, latest_profile_path)

                    i += 1

            image_path = mx.join(config.output_dir, final_image_name)
            # Build the final image
            if stages.change_stage('image'):
                executable_name_args = ['-H:Name=' + final_image_name]
                pgo_verification_output_path = os.path.join(
                    config.output_dir, final_image_name + '-probabilities.log')
                pgo_args = ['--pgo=' + latest_profile_path, '-H:+VerifyPGOProfiles', '-H:VerificationDumpFile=' + pgo_verification_output_path] if self.pgo_instrumented_iterations > 0 or self.hotspot_pgo else []
                final_image_command = base_image_build_args + executable_name_args + pgo_args
                with stages.set_command(final_image_command) as s:
                    s.execute_command()

            # Execute the benchmark
            if stages.change_stage('run'):
                image_path = os.path.join(config.output_dir, final_image_name)
                image_run_cmd = [image_path
                                 ] + image_run_args + config.extra_run_args
                with stages.set_command(image_run_cmd) as s:
                    s.execute_command(True)
                    if s.exit_code == 0:
                        # The image size for benchmarks is tracked by printing on stdout and matching the rule.
                        image_size = os.stat(image_path).st_size
                        out('The executed image size for benchmark ' +
                            config.benchmark_suite_name + ':' +
                            config.benchmark_name + ' is ' + str(image_size) +
                            ' B')
Exemplo n.º 33
0
import os, shutil, zipfile, re, time, sys, datetime, platform
from os.path import join, exists, dirname, isdir
from argparse import ArgumentParser, REMAINDER
import StringIO
import xml.dom.minidom
import subprocess

import mx
import mx_gate
import mx_unittest

from mx_gate import Task
from mx_unittest import unittest

_suite = mx.suite('jvmci')

JVMCI_VERSION = 9

"""
Top level directory of the JDK source workspace.
"""
_jdkSourceRoot = dirname(_suite.dir)

_JVMCI_JDK_TAG = 'jvmci'

_minVersion = mx.VersionSpec('1.9')

# max version (first _unsupported_ version)
_untilVersion = None
Exemplo n.º 34
0
import mx
import mx_benchmark
import mx_sdk_vm
import mx_truffle
import mx_wasm_benchmark  # pylint: disable=unused-import

import os
import re
import shutil
import stat

from collections import defaultdict
from mx_gate import Task, add_gate_runner
from mx_unittest import unittest

_suite = mx.suite("wasm")

emcc_dir = mx.get_env("EMCC_DIR", None)
gcc_dir = mx.get_env("GCC_DIR", "")
wabt_dir = mx.get_env("WABT_DIR", None)

NODE_BENCH_DIR = "node"
NATIVE_BENCH_DIR = "native"

microbenchmarks = [
    "cdf",
    "digitron",
    "event-sim",
    "fft",
    "hash-join",
    "merge-join",
Exemplo n.º 35
0
def truffle_language_ensure(language_flag, version=None, native_image_root=None, early_exit=False, extract=True, debug_gr_8964=False):
    """
    Ensures that we have a valid suite for the given language_flag, by downloading a binary if necessary
    and providing the suite distribution artifacts in the native-image directory hierachy (via symlinks).
    :param language_flag: native-image language_flag whose truffle-language we want to use
    :param version: if not specified and no TRUFFLE_<LANG>_VERSION set latest binary deployed master revision gets downloaded
    :param native_image_root: the native_image_root directory where the the artifacts get installed to
    :return: language suite for the given language_flag
    """
    if not native_image_root:
        native_image_root = suite_native_image_root()

    version_env_var = 'TRUFFLE_' + language_flag.upper() + '_VERSION'
    if not version and os.environ.has_key(version_env_var):
        version = os.environ[version_env_var]

    if language_flag not in flag_suitename_map:
        mx.abort('No truffle-language uses language_flag \'' + language_flag + '\'')

    language_dir = join('languages', language_flag)
    if early_exit and exists(join(native_image_root, language_dir)):
        mx.logv('Early exit mode: Language subdir \'' + language_flag + '\' exists. Skip suite.import_suite.')
        return None

    language_entry = flag_suitename_map[language_flag]

    language_suite_name = language_entry[0]
    language_repo_name = language_entry[3] if len(language_entry) > 3 else None

    urlinfos = [
        mx.SuiteImportURLInfo(mx_urlrewrites.rewriteurl('https://curio.ssw.jku.at/nexus/content/repositories/snapshots'),
                              'binary',
                              mx.vc_system('binary'))
    ]

    failure_warning = None
    if not version and not mx.suite(language_suite_name, fatalIfMissing=False):
        # If no specific version requested use binary import of last recently deployed master version
        repo_suite_name = language_repo_name if language_repo_name else language_suite_name
        repo_url = mx_urlrewrites.rewriteurl('https://github.com/graalvm/{0}.git'.format(repo_suite_name))
        version = mx.SuiteImport.resolve_git_branchref(repo_url, 'binary', abortOnError=False)
        if not version:
            failure_warning = 'Resolving \'binary\' against ' + repo_url + ' failed'

    language_suite = suite.import_suite(
        language_suite_name,
        version=version,
        urlinfos=urlinfos,
        kind=None,
        in_subdir=bool(language_repo_name)
    )

    if not language_suite:
        if failure_warning:
            mx.warn(failure_warning)
        mx.abort('Binary suite not found and no local copy of ' + language_suite_name + ' available.')

    if not extract:
        if not exists(join(native_image_root, language_dir)):
            mx.abort('Language subdir \'' + language_flag + '\' should already exist with extract=False')
        return language_suite

    language_suite_depnames = language_entry[1]
    language_deps = language_suite.dists + language_suite.libs
    language_deps = [dep for dep in language_deps if dep.name in language_suite_depnames]
    native_image_layout(language_deps, language_dir, native_image_root, debug_gr_8964=debug_gr_8964)

    language_suite_nativedistnames = language_entry[2]
    language_nativedists = [dist for dist in language_suite.dists if dist.name in language_suite_nativedistnames]
    native_image_extract(language_nativedists, language_dir, native_image_root)

    option_properties = join(language_suite.mxDir, 'native-image.properties')
    target_path = remove_existing_symlink(join(native_image_root, language_dir, 'native-image.properties'))
    if exists(option_properties):
        if not exists(target_path):
            mx.logv('Add symlink to ' + str(option_properties))
            symlink_or_copy(option_properties, target_path, debug_gr_8964=debug_gr_8964)
    else:
        native_image_option_properties('languages', language_flag, native_image_root)
    return language_suite
Exemplo n.º 36
0
import os, shutil, zipfile, re, time, sys, datetime, platform
from os.path import join, exists, dirname, isdir
from argparse import ArgumentParser, REMAINDER
import StringIO
import xml.dom.minidom
import subprocess

import mx
import mx_gate
import mx_unittest

from mx_gate import Task
from mx_unittest import unittest

_suite = mx.suite('jvmci')
"""
Top level directory of the JDK source workspace.
"""
_jdkSourceRoot = dirname(_suite.dir)

_JVMCI_JDK_TAG = 'jvmci'

_minVersion = mx.VersionSpec('1.9')

# max version (first _unsupported_ version)
_untilVersion = None

_jvmciModes = {
    'hosted': ['-XX:+UnlockExperimentalVMOptions', '-XX:+EnableJVMCI'],
    'jit': [
Exemplo n.º 37
0
def _benchmarksDirectory():
    return join(os.path.abspath(join(mx.suite('sulong').dir, os.pardir)), 'sulong-benchmarks')
Exemplo n.º 38
0
def create_asm_parser(args=None, out=None):
    """create the inline assembly parser using antlr"""
    mx.suite("truffle").extensions.create_parser(
        "com.oracle.truffle.llvm.asm.amd64",
        "com.oracle.truffle.llvm.asm.amd64", "InlineAssembly",
        COPYRIGHT_HEADER_BSD, args, out)
Exemplo n.º 39
0
import os
from os.path import exists
import re

import mx

from mx_unittest import unittest
from mx_jackpot import jackpot
from mx_gate import Task
from urlparse import urljoin
import mx_gate
import mx_unittest
import mx_benchmark
import mx_sdk

_suite = mx.suite('tools')

class JMHRunnerToolsBenchmarkSuite(mx_benchmark.JMHRunnerBenchmarkSuite):

    def name(self):
        return "tools"

    def group(self):
        return "Graal"

    def subgroup(self):
        return "tools"

    def extraVmArgs(self):
        return ['-XX:-UseJVMCIClassLoader'] + super(JMHRunnerToolsBenchmarkSuite, self).extraVmArgs()
Exemplo n.º 40
0
        sulongCmdLine = suTruffleOptions + [
            mx_sulong.getSearchPathOption()
        ] + mx_sulong.getBitcodeLibrariesOption(
        ) + mx_sulong.getClasspathOptions() + [
            '-XX:-UseJVMCIClassLoader', "com.oracle.truffle.llvm.Sulong"
        ] + ['bench.bc']
        result = self.host_vm().run(cwd, sulongCmdLine + args)

        # reset current Directory
        os.chdir(self.currentDir)

        return result

    def hosting_registry(self):
        return java_vm_registry


_suite = mx.suite("sulong")

native_vm_registry = VmRegistry("Native",
                                known_host_registries=[java_vm_registry])
native_vm_registry.add_vm(GccVm('O0', ['-O0']), _suite)
native_vm_registry.add_vm(ClangVm('O0', ['-O0']), _suite)
native_vm_registry.add_vm(GccVm('O1', ['-O1']), _suite)
native_vm_registry.add_vm(ClangVm('O1', ['-O1']), _suite)
native_vm_registry.add_vm(GccVm('O2', ['-O2']), _suite)
native_vm_registry.add_vm(ClangVm('O2', ['-O2']), _suite)
native_vm_registry.add_vm(GccVm('O3', ['-O3']), _suite)
native_vm_registry.add_vm(ClangVm('O3', ['-O3']), _suite)
native_vm_registry.add_vm(SulongVm(), _suite, 10)
Exemplo n.º 41
0
import os
from os.path import join, exists, abspath
from argparse import ArgumentParser
import sanitycheck
import re

import mx
from mx_gate import Task
from sanitycheck import _noneAsEmptyList

from mx_unittest import unittest
from mx_graal_bench import dacapo
import mx_gate
import mx_unittest

_suite = mx.suite("graal-core")

_jdk = mx.get_jdk(tag="default")
assert _jdk.javaCompliance >= "1.9"


def isJVMCIEnabled(vm):
    return True


_jvmciModes = {
    "hosted": ["-XX:+UnlockExperimentalVMOptions", "-XX:+EnableJVMCI"],
    "jit": ["-XX:+UnlockExperimentalVMOptions", "-XX:+EnableJVMCI", "-XX:+UseJVMCICompiler"],
    "disabled": [],
}
Exemplo n.º 42
0
def _benchmarksDirectory():
    return join(os.path.abspath(join(mx.suite('sulong').dir, os.pardir)),
                'sulong-benchmarks')
Exemplo n.º 43
0
# OF THE POSSIBILITY OF SUCH DAMAGE.
#
from __future__ import print_function

import argparse
import mx
import mx_unittest
import mx_subst
import os
import mx_buildtools
import shutil

import mx_sulong


_suite = mx.suite('sulong')
_testDir = os.path.join(_suite.dir, "tests/")
_cacheDir = os.path.join(_suite.dir, "cache/tests")

_benchmarksgameSuiteDir = os.path.join(_testDir, "benchmarksgame/")
_benchmarksgameSuiteDirRoot = os.path.join(_benchmarksgameSuiteDir, "benchmarksgame-2014-08-31/benchmarksgame/bench/")
_otherDir = os.path.join(_testDir, "other/")
_inlineassemblytestsDir = os.path.join(_testDir, "inlineassemblytests/")
_llvmSuiteDir = os.path.join(_testDir, "llvm/")
_assemblySuiteDir = os.path.join(_testDir, "inlineassemblytests/")
_llvmSuiteDirRoot = os.path.join(_llvmSuiteDir, "test-suite-3.2.src/")
_gccSuiteDir = os.path.join(_testDir, "gcc/")
_gccSuiteDirRoot = os.path.join(_gccSuiteDir, "gcc-5.2.0/gcc/testsuite/")
_parserTortureSuiteDirRoot = os.path.join(_gccSuiteDir, "gcc-5.2.0/gcc/testsuite/gcc.c-torture/compile")
_nwccSuiteDir = os.path.join(_testDir, "nwcc/")
_nwccSuiteDirRoot2 = os.path.join(_nwccSuiteDir, "nwcc_0.8.3/tests/")
Exemplo n.º 44
0
GRAAL_COMPILER_FLAGS = [
    '-XX:-UseJVMCIClassLoader',
    '-XX:+UseJVMCICompiler',
    '-Dgraal.CompileGraalWithC1Only=false',
    '-XX:CICompilerCount=' + str(JVM_COMPILER_THREADS),
    '-Dtruffle.TrustAllTruffleRuntimeProviders=true',  # GR-7046
    '-Dgraal.VerifyGraalGraphs=false',
    '-Dgraal.VerifyGraalGraphEdges=false',
    '-Dgraal.VerifyGraalPhasesSize=false',
    '-Dgraal.VerifyPhases=false'
]
IMAGE_ASSERTION_FLAGS = [
    '-H:+VerifyGraalGraphs', '-H:+VerifyGraalGraphEdges', '-H:+VerifyPhases'
]

suite = mx.suite('substratevm')
svmSuites = [suite]

orig_command_build = mx.command_function('build')

allow_native_image_build = True


def build(args, vm=None):
    if any([opt in args for opt in ['-h', '--help']]):
        orig_command_build(args, vm)

    mx.log('build: Checking SubstrateVM requirements for building ...')

    if not _host_os_supported():
        mx.abort(
Exemplo n.º 45
0
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)

        _, launcher = vmLauncher
        launcher(*config)

    vmLauncher = _vm_launcher
    if vmLauncher is None:
        vmLauncher = ('default VM launcher', lambda vmArgs, mainClass, mainClassArgs: mx.run_java(vmArgs + [mainClass] + mainClassArgs))

    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)
Exemplo n.º 46
0
def truffle_language_ensure(language_flag,
                            version=None,
                            native_image_root=None,
                            early_exit=False):
    """
    Ensures that we have a valid suite for the given language_flag, by downloading a binary if necessary
    and providing the suite distribution artifacts in the native-image directory hierachy (via symlinks).
    :param language_flag: native-image language_flag whose truffle-language we want to use
    :param version: if not specified and no TRUFFLE_<LANG>_VERSION set latest binary deployed master revision gets downloaded
    :param native_image_root: the native_image_root directory where the the artifacts get installed to
    :return: language suite for the given language_flag
    """
    if not native_image_root:
        native_image_root = suite_native_image_root()

    version_env_var = 'TRUFFLE_' + language_flag.upper() + '_VERSION'
    if not version and os.environ.has_key(version_env_var):
        version = os.environ[version_env_var]

    if language_flag not in flag_suitename_map:
        mx.abort('No truffle-language uses language_flag \'' + language_flag +
                 '\'')

    language_dir = join('languages', language_flag)
    if early_exit and exists(join(native_image_root, language_dir)):
        mx.logv('Early exit mode: Language subdir \'' + language_flag +
                '\' exists. Skip suite.import_suite.')
        return None

    language_entry = flag_suitename_map[language_flag]

    language_suite_name = language_entry[0]
    language_repo_name = language_entry[3] if len(language_entry) > 3 else None

    urlinfos = [
        mx.SuiteImportURLInfo(
            mx_urlrewrites.rewriteurl(
                'https://curio.ssw.jku.at/nexus/content/repositories/snapshots'
            ), 'binary', mx.vc_system('binary'))
    ]

    failure_warning = None
    if not version and not mx.suite(language_suite_name, fatalIfMissing=False):
        # If no specific version requested use binary import of last recently deployed master version
        repo_suite_name = language_repo_name if language_repo_name else language_suite_name
        repo_url = mx_urlrewrites.rewriteurl(
            'https://github.com/graalvm/{0}.git'.format(repo_suite_name))
        version = mx.SuiteImport.resolve_git_branchref(repo_url,
                                                       'binary',
                                                       abortOnError=False)
        if not version:
            failure_warning = 'Resolving \'binary\' against ' + repo_url + ' failed'

    language_suite = suite.import_suite(language_suite_name,
                                        version=version,
                                        urlinfos=urlinfos,
                                        kind=None,
                                        in_subdir=bool(language_repo_name))

    if not language_suite:
        if failure_warning:
            mx.warn(failure_warning)
        mx.abort('Binary suite not found and no local copy of ' +
                 language_suite_name + ' available.')

    language_suite_depnames = language_entry[1]
    language_deps = language_suite.dists + language_suite.libs
    language_deps = [
        dep for dep in language_deps if dep.name in language_suite_depnames
    ]
    native_image_layout(language_deps, language_dir, native_image_root)

    language_suite_nativedistnames = language_entry[2]
    language_nativedists = [
        dist for dist in language_suite.dists
        if dist.name in language_suite_nativedistnames
    ]
    native_image_extract(language_nativedists, language_dir, native_image_root)

    option_properties = join(language_suite.mxDir, 'native-image.properties')
    target_path = remove_existing_symlink(
        join(native_image_root, language_dir, 'native-image.properties'))
    if exists(option_properties):
        mx.logv('Add symlink to ' + str(option_properties))
        relsymlink(option_properties, target_path)
    else:
        native_image_option_properties('languages', language_flag,
                                       native_image_root)
    return language_suite
Exemplo n.º 47
0
import mx

print("****** In mx_sample.py")

def function(args=None):
   print "###### In function() for target 'fun'"

_suite = mx.suite('sample')
mx.update_commands(_suite,{
  'fun' : [function]}
)
Exemplo n.º 48
0
# or visit www.oracle.com if you need additional information or have any
# questions.
#
# ----------------------------------------------------------------------------------------------------

import mx, mx_gate, mx_subst, mx_sdk, mx_graal_js, os, shutil, tarfile, tempfile

import mx_graal_nodejs_benchmark

from mx import BinarySuite, VC
from mx_gate import Task
from argparse import ArgumentParser
from os import remove, symlink, unlink
from os.path import dirname, exists, join, isdir, isfile, islink

_suite = mx.suite('graal-nodejs')
_currentOs = mx.get_os()
_currentArch = mx.get_arch()
_jdkHome = None


class GraalNodeJsTags:
    allTests = 'all'
    unitTests = 'unit'
    jniProfilerTests = 'jniprofiler'


def _graal_nodejs_post_gate_runner(args, tasks):
    _setEnvVar('NODE_INTERNAL_ERROR_CHECK', 'true')
    with Task('UnitTests',
              tasks,
Exemplo n.º 49
0
import mx
import mx_gate
import mx_fastr_pkgtest
import os
import shutil

'''
This is the launchpad for all the functions available for building/running/testing/analyzing
FastR. Ideally this code would be completely VM agnostic, i.e., be able to build/run with a variety
of VMs without change. That is currently not feasible due to the requirement that building
must use an pre-existing VM and running (for performance testing) must use a Graal-enabled VM.
It would require separate build/run steps to finesse this. However, running under a standards
VM is supported by dynamically checking if the jvmci suite is available
'''

_fastr_suite = mx.suite('fastr')
'''
If this is None, then we run under the standard VM in interpreted mode only.
Even if this is not None the global mx option --vm original forces interpreted mode
'''
_mx_jvmci = mx.suite("jvmci", fatalIfMissing=False)

class FakeJVMCI:
    def get_vm(self):
        # should only happen if jvmci vm selected
        mx.abort('FakeJVMCI.get_vm called')

    def get_jvmci_jdk(self):
        return mx.get_jdk()

    def build(self, args):
Exemplo n.º 50
0
import os, zipfile, re, shutil
from os.path import join, exists, isdir, getmtime
from argparse import ArgumentParser, RawDescriptionHelpFormatter

import mx, mx_sdk
from mx_unittest import unittest
import mx_unittest
from mx import BinarySuite, VC
from contextlib import contextmanager

import sys
_suite = mx.suite('nodeprof')


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


class OutputCapture:
    def __init__(self, outFile):
        self.outFile = outFile
        if self.outFile:
            self.fout = open(self.outFile, 'w')
        else:
            self.fout = None
Exemplo n.º 51
0
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
# ----------------------------------------------------------------------------------------------------

import mx
import mx_unittest
import mx_gate

_suite = mx.suite('sdk')


mx.update_commands(_suite, {
    'unittest': [mx_unittest.unittest, ''],
    'gate' : [mx_gate.gate, ''],
})
Exemplo n.º 52
0
import os
from os.path import exists
import re

import mx

from mx_unittest import unittest
from mx_jackpot import jackpot
from mx_gate import Task
from urlparse import urljoin
import mx_gate
import mx_unittest
import mx_benchmark
import mx_sdk

_suite = mx.suite('tools')


class JMHRunnerToolsBenchmarkSuite(mx_benchmark.JMHRunnerBenchmarkSuite):
    def name(self):
        return "tools"

    def group(self):
        return "Graal"

    def subgroup(self):
        return "tools"

    def extraVmArgs(self):
        return ['-XX:-UseJVMCIClassLoader'] + super(
            JMHRunnerToolsBenchmarkSuite, self).extraVmArgs()
Exemplo n.º 53
0
import tarfile
import os
from os.path import join
import shutil

import mx
import mx_findbugs

from mx_unittest import unittest
from mx_gate import Task, add_gate_runner
from mx_jvmci import VM, buildvms

_suite = mx.suite('sulong')
_root = join(_suite.dir, "projects/")
_parserDir = join(_root, "com.intel.llvm.ireditor")
_testDir = join(_root, "com.oracle.truffle.llvm.test/")
_toolDir = join(_root, "com.oracle.truffle.llvm.tools/")
_clangPath = _toolDir + 'tools/llvm/bin/clang'

_gccSuiteDir = join(_root, "com.oracle.truffle.llvm.test/suites/gcc/")
_gccSuiteDirRoot = join(_gccSuiteDir, 'gcc-5.2.0/gcc/testsuite/')

_llvmSuiteDir = join(_root, "com.oracle.truffle.llvm.test/suites/llvm/")
_llvmSuiteDirRoot = join(_llvmSuiteDir, 'test-suite-3.2.src')

_nwccSuiteDir = join(_root, "com.oracle.truffle.llvm.test/suites/nwcc/")

_benchGameSuiteDir = join(_root, "com.oracle.truffle.llvm.test/suites/benchmarkgame/")

_dragonEggPath = _toolDir + 'tools/dragonegg/dragonegg-3.2.src/dragonegg.so'
Exemplo n.º 54
0
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
# ----------------------------------------------------------------------------------------------------

import mx

from mx_unittest import unittest
from mx_sigtest import sigtest
from mx_gate import Task
import mx_gate

_suite = mx.suite('truffle')

def build(args, vm=None):
    """build the Java sources"""
    opts2 = mx.build(['--source', '1.7'] + args)
    assert len(opts2.remainder) == 0

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 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)
Exemplo n.º 55
0
import mx
import mx_vm
import mx_subst
import mx_unittest

import functools
import tempfile
from mx_gate import Task

from os import environ, listdir, remove
from os.path import join, exists, dirname, isdir, isfile, getsize
from tempfile import NamedTemporaryFile
from contextlib import contextmanager

_suite = mx.suite('vm')
env_tests = []


class VmGateTasks:
    compiler = 'compiler'
    substratevm = 'substratevm'
    sulong = 'sulong'
    graal_js_all = 'graal-js'
    graal_js_smoke = 'graal-js-smoke'
    graal_js_tests = 'graal-js-tests'
    graal_js_tests_compiled = 'graal-js-tests-compiled'
    graal_nodejs = 'graal-nodejs'
    truffleruby = 'truffleruby'
    ruby = 'ruby'
    python = 'python'
Exemplo n.º 56
0
def get_default_jdk():
    if mx.suite("compiler", fatalIfMissing=False):
        tag = 'jvmci'
    else:
        tag = None
    return mx.get_jdk(tag=tag)
Exemplo n.º 57
0
#
# ----------------------------------------------------------------------------------------------------

import argparse
import re
from os.path import join, exists
from tempfile import mkdtemp
from shutil import rmtree

import mx
import mx_benchmark
import mx_graal_core
from mx_benchmark import ParserEntry
from argparse import ArgumentParser

_suite = mx.suite('graal-core')

# Short-hand commands used to quickly run common benchmarks.
mx.update_commands(_suite, {
    'dacapo': [
      lambda args: createBenchmarkShortcut("dacapo", args),
      '[<benchmarks>|*] [-- [VM options] [-- [DaCapo options]]]'
    ],
    'scaladacapo': [
      lambda args: createBenchmarkShortcut("scala-dacapo", args),
      '[<benchmarks>|*] [-- [VM options] [-- [Scala DaCapo options]]]'
    ],
    'specjvm2008': [
      lambda args: createBenchmarkShortcut("specjvm2008", args),
      '[<benchmarks>|*] [-- [VM options] [-- [SPECjvm2008 options]]]'
    ],
Exemplo n.º 58
0
# questions.
#
# ----------------------------------------------------------------------------------------------------

from __future__ import print_function

import os
import re
from glob import glob

import zipfile
import mx
import mx_benchmark
import mx_java_benchmarks

_suite = mx.suite("substratevm")
_successful_stage_pattern = re.compile(r'Successfully finished the last specified stage:.*$', re.MULTILINE)


def extract_archive(path, extracted_name):
    extracted_archive = mx.join(mx.dirname(path), extracted_name)
    if not mx.exists(extracted_archive):
        # There can be multiple processes doing this so be atomic about it
        with mx.SafeDirectoryUpdater(extracted_archive, create=True) as sdu:
            with zipfile.ZipFile(path, 'r') as zf:
                zf.extractall(sdu.directory)
    return extracted_archive


def list_jars(path):
    jars = []
Exemplo n.º 59
0
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
# ----------------------------------------------------------------------------------------------------

import argparse
import re
from os.path import join, exists

import mx
import mx_benchmark
import mx_graal_core

# Short-hand commands used to quickly run common benchmarks.
mx.update_commands(mx.suite('graal-core'), {
    'dacapo': [
      lambda args: createBenchmarkShortcut("dacapo", args),
      '[<benchmarks>|*] [-- [VM options] [-- [DaCapo options]]]'
    ],
    'scaladacapo': [
      lambda args: createBenchmarkShortcut("scala-dacapo", args),
      '[<benchmarks>|*] [-- [VM options] [-- [Scala DaCapo options]]]'
    ],
    'specjvm2008': [
      lambda args: createBenchmarkShortcut("specjvm2008", args),
      '[<benchmarks>|*] [-- [VM options] [-- [SPECjvm2008 options]]]'
    ],
    'specjbb2005': [
      lambda args: mx_benchmark.benchmark(["specjbb2005"] + args),
      '[-- [VM options] [-- [SPECjbb2005 options]]]'
Exemplo n.º 60
0
import mx_sdk
import re
import mx_benchmark
import mx_sulong_benchmarks
import mx_unittest
import mx_buildtools

from mx_unittest import add_config_participant
from mx_gate import Task, add_gate_runner

import mx_testsuites

# re-export SulongTestSuite class so it can be used from suite.py
from mx_testsuites import SulongTestSuite #pylint: disable=unused-import

_suite = mx.suite('sulong')
_mx = join(_suite.dir, "mx.sulong")
_root = join(_suite.dir, "projects")
_testDir = join(_suite.dir, "tests")
_toolDir = join(_suite.dir, "cache", "tools")
_clangPath = join(_toolDir, "llvm", "bin", "clang")



# the supported GCC versions (see dragonegg.llvm.org)
supportedGCCVersions = [
    '4.6',
    '4.5',
    '4.7'
]