Mercurial > hg > truffle
comparison mx/mx_graal.py @ 18949:886cf229e5ee
Merge
author | Stefan Anzinger <stefan.anzinger@oracle.com> |
---|---|
date | Mon, 26 Jan 2015 21:19:36 +0100 |
parents | 926488f5d345 |
children | 43baadc1913a |
comparison
equal
deleted
inserted
replaced
18948:759d9ffc97fd | 18949:886cf229e5ee |
---|---|
1 # | 1 # |
2 # commands.py - the GraalVM specific commands | 2 # commands.py - the GraalVM specific commands |
3 # | 3 # |
4 # ---------------------------------------------------------------------------------------------------- | 4 # ---------------------------------------------------------------------------------------------------- |
5 # | 5 # |
6 # Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. | 6 # Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. |
7 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 7 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
8 # | 8 # |
9 # This code is free software; you can redistribute it and/or modify it | 9 # This code is free software; you can redistribute it and/or modify it |
10 # under the terms of the GNU General Public License version 2 only, as | 10 # under the terms of the GNU General Public License version 2 only, as |
11 # published by the Free Software Foundation. | 11 # published by the Free Software Foundation. |
1021 mx.make_eclipse_launch(args, 'graal-' + build, name=None, deps=mx.project('com.oracle.graal.hotspot').all_deps([], True)) | 1021 mx.make_eclipse_launch(args, 'graal-' + build, name=None, deps=mx.project('com.oracle.graal.hotspot').all_deps([], True)) |
1022 if _jacoco == 'on' or _jacoco == 'append': | 1022 if _jacoco == 'on' or _jacoco == 'append': |
1023 jacocoagent = mx.library("JACOCOAGENT", True) | 1023 jacocoagent = mx.library("JACOCOAGENT", True) |
1024 # Exclude all compiler tests and snippets | 1024 # Exclude all compiler tests and snippets |
1025 | 1025 |
1026 baseExcludes = ['com.oracle.graal.compiler.test', 'com.oracle.graal.jtt', 'com.oracle.graal.api.meta.test', 'com.oracle.truffle.api.test', \ | 1026 includes = ['com.oracle.graal.*'] |
1027 'com.oracle.truffle.api.dsl.test', 'com.oracle.graal.truffle', 'com.oracle.graal.truffle.test', 'com.oracle.graal.compiler.hsail.test'] | 1027 baseExcludes = [] |
1028 for p in mx.projects(): | |
1029 projsetting = getattr(p, 'jacoco', '') | |
1030 if projsetting == 'exclude': | |
1031 baseExcludes.append(p.name) | |
1032 if projsetting == 'include': | |
1033 includes.append(p.name + '.*') | |
1034 | |
1028 def _filter(l): | 1035 def _filter(l): |
1029 # filter out specific classes which are already covered by a baseExclude package | 1036 # filter out specific classes which are already covered by a baseExclude package |
1030 return [clazz for clazz in l if not any([clazz.startswith(package) for package in baseExcludes])] | 1037 return [clazz for clazz in l if not any([clazz.startswith(package) for package in baseExcludes])] |
1031 excludes = [] | 1038 excludes = [] |
1032 for p in mx.projects(): | 1039 for p in mx.projects(): |
1033 excludes += _filter(_find_classes_with_annotations(p, None, ['@Snippet', '@ClassSubstitution', '@Test'], includeInnerClasses=True).keys()) | 1040 excludes += _filter(_find_classes_with_annotations(p, None, ['@Snippet', '@ClassSubstitution', '@Test'], includeInnerClasses=True).keys()) |
1034 excludes += _filter(p.find_classes_with_matching_source_line(None, lambda line: 'JaCoCo Exclude' in line, includeInnerClasses=True).keys()) | 1041 excludes += _filter(p.find_classes_with_matching_source_line(None, lambda line: 'JaCoCo Exclude' in line, includeInnerClasses=True).keys()) |
1035 | 1042 |
1036 excludes += [package + '.*' for package in baseExcludes] | 1043 excludes += [package + '.*' for package in baseExcludes] |
1037 includes = ['com.oracle.graal.*'] | |
1038 agentOptions = { | 1044 agentOptions = { |
1039 'append' : 'true' if _jacoco == 'append' else 'false', | 1045 'append' : 'true' if _jacoco == 'append' else 'false', |
1040 'bootclasspath' : 'true', | 1046 'bootclasspath' : 'true', |
1041 'includes' : ':'.join(includes), | 1047 'includes' : ':'.join(includes), |
1042 'excludes' : ':'.join(excludes), | 1048 'excludes' : ':'.join(excludes), |
1328 def shortunittest(args): | 1334 def shortunittest(args): |
1329 """alias for 'unittest --whitelist test/whitelist_shortunittest.txt'{0}""" | 1335 """alias for 'unittest --whitelist test/whitelist_shortunittest.txt'{0}""" |
1330 | 1336 |
1331 args = ['--whitelist', 'test/whitelist_shortunittest.txt'] + args | 1337 args = ['--whitelist', 'test/whitelist_shortunittest.txt'] + args |
1332 unittest(args) | 1338 unittest(args) |
1339 | |
1340 def microbench(args): | |
1341 """run JMH microbenchmark projects""" | |
1342 vmArgs, jmhArgs = _extract_VM_args(args, useDoubleDash=True) | |
1343 | |
1344 # look for -f in JMH arguments | |
1345 containsF = False | |
1346 forking = True | |
1347 for i in range(len(jmhArgs)): | |
1348 arg = jmhArgs[i] | |
1349 if arg.startswith('-f'): | |
1350 containsF = True | |
1351 if arg == '-f' and (i+1) < len(jmhArgs): | |
1352 arg += jmhArgs[i+1] | |
1353 try: | |
1354 if int(arg[2:]) == 0: | |
1355 forking = False | |
1356 except ValueError: | |
1357 pass | |
1358 | |
1359 # default to -f1 if not specified otherwise | |
1360 if not containsF: | |
1361 jmhArgs += ['-f1'] | |
1362 | |
1363 # find all projects with the JMH dependency | |
1364 jmhProjects = [] | |
1365 for p in mx.projects(): | |
1366 if 'JMH' in p.deps: | |
1367 jmhProjects.append(p.name) | |
1368 cp = mx.classpath(jmhProjects) | |
1369 | |
1370 # execute JMH runner | |
1371 args = ['-cp', cp] | |
1372 if not forking: | |
1373 args += vmArgs | |
1374 args += ['org.openjdk.jmh.Main'] | |
1375 if forking: | |
1376 (_, _, jvm, _, _) = _parseVmArgs(vmArgs) | |
1377 args += ['--jvmArgsPrepend', ' '.join(['-' + jvm] + vmArgs)] | |
1378 vm(args + jmhArgs) | |
1333 | 1379 |
1334 def buildvms(args): | 1380 def buildvms(args): |
1335 """build one or more VMs in various configurations""" | 1381 """build one or more VMs in various configurations""" |
1336 | 1382 |
1337 vmsDefault = ','.join(_vmChoices.keys()) | 1383 vmsDefault = ','.join(_vmChoices.keys()) |
1631 deoptalot(['15', '-Xmx48m']) | 1677 deoptalot(['15', '-Xmx48m']) |
1632 | 1678 |
1633 dacapo(['100', 'eclipse', '-esa']) | 1679 dacapo(['100', 'eclipse', '-esa']) |
1634 | 1680 |
1635 def _igvFallbackJDK(env): | 1681 def _igvFallbackJDK(env): |
1636 igvHomes = [h for h in mx._java_homes if h.version < mx.VersionSpec("1.8.0_20") or h.version >= mx.VersionSpec("1.8.0_40")] | 1682 v8u20 = mx.VersionSpec("1.8.0_20") |
1637 if igvHomes[0] != mx._java_homes[0]: | 1683 v8u40 = mx.VersionSpec("1.8.0_40") |
1684 v8 = mx.VersionSpec("1.8") | |
1685 igvHomes = [h for h in mx._java_homes if h.version >= v8 and (h.version < v8u20 or h.version >= v8u40)] | |
1686 defaultJava = mx.java() | |
1687 if defaultJava not in igvHomes: | |
1688 if not igvHomes: | |
1689 mx.abort("No JDK available for building IGV. Must have JDK >= 1.8 and < 1.8.0u20 or >= 1.8.0u40 in JAVA_HOME or EXTRA_JAVA_HOMES") | |
1638 env = dict(env) | 1690 env = dict(env) |
1639 fallbackJDK = igvHomes[0] | 1691 fallbackJDK = igvHomes[0] |
1640 mx.logv("1.8.0_20 has a known javac bug (JDK-8043926), thus falling back to " + str(fallbackJDK.version)) | 1692 mx.logv("1.8.0_20 has a known javac bug (JDK-8043926), thus falling back to " + str(fallbackJDK.version)) |
1641 env['JAVA_HOME'] = str(fallbackJDK.jdk) | 1693 env['JAVA_HOME'] = str(fallbackJDK.jdk) |
1642 return env | 1694 return env |
1643 | 1695 |
1644 def igv(args): | 1696 def igv(args): |
1645 """run the Ideal Graph Visualizer""" | 1697 """run the Ideal Graph Visualizer""" |
1646 with open(join(_graal_home, '.ideal_graph_visualizer.log'), 'w') as fp: | 1698 logFile = '.ideal_graph_visualizer.log' |
1699 with open(join(_graal_home, logFile), 'w') as fp: | |
1647 # When the http_proxy environment variable is set, convert it to the proxy settings that ant needs | 1700 # When the http_proxy environment variable is set, convert it to the proxy settings that ant needs |
1648 env = dict(os.environ) | 1701 env = dict(os.environ) |
1649 proxy = os.environ.get('http_proxy') | 1702 proxy = os.environ.get('http_proxy') |
1650 if not (proxy is None) and len(proxy) > 0: | 1703 if not (proxy is None) and len(proxy) > 0: |
1651 if '://' in proxy: | 1704 if '://' in proxy: |
1671 elif supportedVersion < currentVersion: | 1724 elif supportedVersion < currentVersion: |
1672 mx.log('Supported NetBeans version in igv command should be updated to ' + str(currentVersion)) | 1725 mx.log('Supported NetBeans version in igv command should be updated to ' + str(currentVersion)) |
1673 | 1726 |
1674 if not exists(nbplatform): | 1727 if not exists(nbplatform): |
1675 mx.logv('[This execution may take a while as the NetBeans platform needs to be downloaded]') | 1728 mx.logv('[This execution may take a while as the NetBeans platform needs to be downloaded]') |
1676 mx.run(['ant', '-f', mx._cygpathU2W(join(_graal_home, 'src', 'share', 'tools', 'IdealGraphVisualizer', 'build.xml')), '-l', mx._cygpathU2W(fp.name), 'run'], env=env) | 1729 if mx.run(['ant', '-f', mx._cygpathU2W(join(_graal_home, 'src', 'share', 'tools', 'IdealGraphVisualizer', 'build.xml')), '-l', mx._cygpathU2W(fp.name), 'run'], env=env, nonZeroIsFatal=False): |
1730 mx.abort("IGV ant build & launch failed. Check '" + logFile + "'. You can also try to delete 'src/share/tools/IdealGraphVisualizer/nbplatform'.") | |
1677 | 1731 |
1678 def maven_install_truffle(args): | 1732 def maven_install_truffle(args): |
1679 """install Truffle into your local Maven repository""" | 1733 """install Truffle into your local Maven repository""" |
1680 for name in ['TRUFFLE', 'TRUFFLE-DSL-PROCESSOR']: | 1734 for name in ['TRUFFLE', 'TRUFFLE-DSL-PROCESSOR']: |
1681 mx.archive(["@" + name]) | 1735 mx.archive(["@" + name]) |
2123 out = 'coverage' | 2177 out = 'coverage' |
2124 if len(args) == 1: | 2178 if len(args) == 1: |
2125 out = args[0] | 2179 out = args[0] |
2126 elif len(args) > 1: | 2180 elif len(args) > 1: |
2127 mx.abort('jacocoreport takes only one argument : an output directory') | 2181 mx.abort('jacocoreport takes only one argument : an output directory') |
2128 mx.run_java(['-jar', jacocoreport.get_path(True), '--in', 'jacoco.exec', '--out', out] + [p.dir for p in mx.projects()]) | 2182 |
2183 includes = ['com.oracle.graal'] | |
2184 for p in mx.projects(): | |
2185 projsetting = getattr(p, 'jacoco', '') | |
2186 if projsetting == 'include': | |
2187 includes.append(p.name) | |
2188 | |
2189 includedirs = set() | |
2190 for p in mx.projects(): | |
2191 for include in includes: | |
2192 if include in p.dir: | |
2193 includedirs.add(p.dir) | |
2194 | |
2195 for i in includedirs: | |
2196 bindir = i + '/bin' | |
2197 if not os.path.exists(bindir): | |
2198 os.makedirs(bindir) | |
2199 | |
2200 mx.run_java(['-jar', jacocoreport.get_path(True), '--in', 'jacoco.exec', '--out', out] + sorted(includedirs)) | |
2129 | 2201 |
2130 def sl(args): | 2202 def sl(args): |
2131 """run an SL program""" | 2203 """run an SL program""" |
2132 vmArgs, slArgs = _extract_VM_args(args) | 2204 vmArgs, slArgs = _extract_VM_args(args) |
2133 vm(vmArgs + ['-cp', mx.classpath(["TRUFFLE", "com.oracle.truffle.sl"]), "com.oracle.truffle.sl.SLMain"] + slArgs) | 2205 vm(vmArgs + ['-cp', mx.classpath(["TRUFFLE", "com.oracle.truffle.sl"]), "com.oracle.truffle.sl.SLMain"] + slArgs) |
2364 'specjvm2008': [specjvm2008, '[VM options] benchmarks...|"all" [SPECjvm2008 options]'], | 2436 'specjvm2008': [specjvm2008, '[VM options] benchmarks...|"all" [SPECjvm2008 options]'], |
2365 'specjbb2013': [specjbb2013, '[VM options] [-- [SPECjbb2013 options]]'], | 2437 'specjbb2013': [specjbb2013, '[VM options] [-- [SPECjbb2013 options]]'], |
2366 'specjbb2005': [specjbb2005, '[VM options] [-- [SPECjbb2005 options]]'], | 2438 'specjbb2005': [specjbb2005, '[VM options] [-- [SPECjbb2005 options]]'], |
2367 'gate' : [gate, '[-options]'], | 2439 'gate' : [gate, '[-options]'], |
2368 'bench' : [bench, '[-resultfile file] [all(default)|dacapo|specjvm2008|bootstrap]'], | 2440 'bench' : [bench, '[-resultfile file] [all(default)|dacapo|specjvm2008|bootstrap]'], |
2441 'microbench' : [microbench, '[VM options] [-- [JMH options]]'], | |
2369 'unittest' : [unittest, '[unittest options] [--] [VM options] [filters...]', _unittestHelpSuffix], | 2442 'unittest' : [unittest, '[unittest options] [--] [VM options] [filters...]', _unittestHelpSuffix], |
2370 'makejmhdeps' : [makejmhdeps, ''], | 2443 'makejmhdeps' : [makejmhdeps, ''], |
2371 'shortunittest' : [shortunittest, '[unittest options] [--] [VM options] [filters...]', _unittestHelpSuffix], | 2444 'shortunittest' : [shortunittest, '[unittest options] [--] [VM options] [filters...]', _unittestHelpSuffix], |
2372 'jacocoreport' : [jacocoreport, '[output directory]'], | 2445 'jacocoreport' : [jacocoreport, '[output directory]'], |
2373 'site' : [site, '[-options]'], | 2446 'site' : [site, '[-options]'], |