changeset 18899:8e8b4a6a85f5

Merge.
author Doug Simon <doug.simon@oracle.com>
date Wed, 21 Jan 2015 19:01:13 +0100
parents d199e643f23b (current diff) 886621ee9bdb (diff)
children 7e500c20208c
files mxtool/mx.py
diffstat 4 files changed, 205 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.virtual.bench/src/com/oracle/graal/virtual/bench/PartialEscapeBench.java	Wed Jan 21 19:01:13 2015 +0100
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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.
+ */
+package com.oracle.graal.virtual.bench;
+
+import org.openjdk.jmh.annotations.*;
+
+public class PartialEscapeBench {
+
+    private static class Thing {
+        final int id;
+        final String name;
+
+        Thing(int id, String name) {
+            this.id = id;
+            this.name = name;
+        }
+    }
+
+    @State(Scope.Thread)
+    public static class ThingsCache {
+
+        private Thing[] cache = new Thing[100];
+
+        public Thing getOrAdd(Thing input) {
+            if (cache[input.id] == null) {
+                cache[input.id] = input;
+            }
+            return cache[input.id];
+        }
+    }
+
+    @Benchmark
+    @Warmup(iterations = 30)
+    public String benchPartialEscape(ThingsCache cache) {
+        Thing thing = cache.getOrAdd(new Thing(42, "the answer!"));
+        return thing.name;
+    }
+}
--- a/mx/mx_graal.py	Wed Jan 21 19:00:46 2015 +0100
+++ b/mx/mx_graal.py	Wed Jan 21 19:01:13 2015 +0100
@@ -3,7 +3,7 @@
 #
 # ----------------------------------------------------------------------------------------------------
 #
-# Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -1023,8 +1023,15 @@
         jacocoagent = mx.library("JACOCOAGENT", True)
         # Exclude all compiler tests and snippets
 
-        baseExcludes = ['com.oracle.graal.compiler.test', 'com.oracle.graal.jtt', 'com.oracle.graal.api.meta.test', 'com.oracle.truffle.api.test', \
-                'com.oracle.truffle.api.dsl.test', 'com.oracle.graal.truffle', 'com.oracle.graal.truffle.test', 'com.oracle.graal.compiler.hsail.test']
+        includes = ['com.oracle.graal.*']
+        baseExcludes = []
+        for p in mx.projects():
+            projsetting = getattr(p, 'jacoco', '')
+            if projsetting == 'exclude':
+                baseExcludes.append(p.name)
+            if projsetting == 'include':
+                includes.append(p.name + '.*')
+
         def _filter(l):
             # filter out specific classes which are already covered by a baseExclude package
             return [clazz for clazz in l if not any([clazz.startswith(package) for package in baseExcludes])]
@@ -1034,7 +1041,6 @@
             excludes += _filter(p.find_classes_with_matching_source_line(None, lambda line: 'JaCoCo Exclude' in line, includeInnerClasses=True).keys())
 
         excludes += [package + '.*' for package in baseExcludes]
-        includes = ['com.oracle.graal.*']
         agentOptions = {
                         'append' : 'true' if _jacoco == 'append' else 'false',
                         'bootclasspath' : 'true',
@@ -1331,6 +1337,46 @@
     args = ['--whitelist', 'test/whitelist_shortunittest.txt'] + args
     unittest(args)
 
+def microbench(args):
+    """run JMH microbenchmark projects"""
+    vmArgs, jmhArgs = _extract_VM_args(args, useDoubleDash=True)
+
+    # look for -f in JMH arguments
+    containsF = False
+    forking = True
+    for i in range(len(jmhArgs)):
+        arg = jmhArgs[i]
+        if arg.startswith('-f'):
+            containsF = True
+            if arg == '-f' and (i+1) < len(jmhArgs):
+                arg += jmhArgs[i+1]
+            try:
+                if int(arg[2:]) == 0:
+                    forking = False
+            except ValueError:
+                pass
+
+    # default to -f1 if not specified otherwise
+    if not containsF:
+        jmhArgs += ['-f1']
+
+    # find all projects with the JMH dependency
+    jmhProjects = []
+    for p in mx.projects():
+        if 'JMH' in p.deps:
+            jmhProjects.append(p.name)
+    cp = mx.classpath(jmhProjects)
+
+    # execute JMH runner
+    (_, _, jvm, forkedVmArgs, _) = _parseVmArgs(vmArgs)
+    args = ['-cp', cp]
+    if not forking:
+        args += forkedVmArgs
+    args += ['org.openjdk.jmh.Main']
+    if forking:
+        args += ['--jvmArgsPrepend', ' '.join(['-' + jvm] + forkedVmArgs)]
+    vm(args + jmhArgs)
+
 def buildvms(args):
     """build one or more VMs in various configurations"""
 
@@ -1633,8 +1679,14 @@
     dacapo(['100', 'eclipse', '-esa'])
 
 def _igvFallbackJDK(env):
-    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")]
-    if igvHomes[0] != mx._java_homes[0]:
+    v8u20 = mx.VersionSpec("1.8.0_20")
+    v8u40 = mx.VersionSpec("1.8.0_40")
+    v8 = mx.VersionSpec("1.8")
+    igvHomes = [h for h in mx._java_homes if h.version >= v8 and (h.version < v8u20 or h.version >= v8u40)]
+    defaultJava = mx.java()
+    if defaultJava not in igvHomes:
+        if not igvHomes:
+            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")
         env = dict(env)
         fallbackJDK = igvHomes[0]
         mx.logv("1.8.0_20 has a known javac bug (JDK-8043926), thus falling back to " + str(fallbackJDK.version))
@@ -1643,7 +1695,8 @@
 
 def igv(args):
     """run the Ideal Graph Visualizer"""
-    with open(join(_graal_home, '.ideal_graph_visualizer.log'), 'w') as fp:
+    logFile = '.ideal_graph_visualizer.log'
+    with open(join(_graal_home, logFile), 'w') as fp:
         # When the http_proxy environment variable is set, convert it to the proxy settings that ant needs
         env = dict(os.environ)
         proxy = os.environ.get('http_proxy')
@@ -1673,7 +1726,8 @@
 
         if not exists(nbplatform):
             mx.logv('[This execution may take a while as the NetBeans platform needs to be downloaded]')
-        mx.run(['ant', '-f', mx._cygpathU2W(join(_graal_home, 'src', 'share', 'tools', 'IdealGraphVisualizer', 'build.xml')), '-l', mx._cygpathU2W(fp.name), 'run'], env=env)
+        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):
+            mx.abort("IGV ant build & launch failed. Check '" + logFile + "'. You can also try to delete 'src/share/tools/IdealGraphVisualizer/nbplatform'.")
 
 def maven_install_truffle(args):
     """install Truffle into your local Maven repository"""
@@ -2125,7 +2179,25 @@
         out = args[0]
     elif len(args) > 1:
         mx.abort('jacocoreport takes only one argument : an output directory')
-    mx.run_java(['-jar', jacocoreport.get_path(True), '--in', 'jacoco.exec', '--out', out] + [p.dir for p in mx.projects()])
+
+    includes = ['com.oracle.graal']
+    for p in mx.projects():
+        projsetting = getattr(p, 'jacoco', '')
+        if projsetting == 'include':
+            includes.append(p.name)
+
+    includedirs = set()
+    for p in mx.projects():
+        for include in includes:
+            if include in p.dir:
+                includedirs.add(p.dir)
+
+    for i in includedirs:
+        bindir = i + '/bin'
+        if not os.path.exists(bindir):
+            os.makedirs(bindir)
+
+    mx.run_java(['-jar', jacocoreport.get_path(True), '--in', 'jacoco.exec', '--out', out] + sorted(includedirs))
 
 def sl(args):
     """run an SL program"""
@@ -2366,6 +2438,7 @@
         'specjbb2005': [specjbb2005, '[VM options] [-- [SPECjbb2005 options]]'],
         'gate' : [gate, '[-options]'],
         'bench' : [bench, '[-resultfile file] [all(default)|dacapo|specjvm2008|bootstrap]'],
+        'microbench' : [microbench, '[VM options] [-- [JMH options]]'],
         'unittest' : [unittest, '[unittest options] [--] [VM options] [filters...]', _unittestHelpSuffix],
         'makejmhdeps' : [makejmhdeps, ''],
         'shortunittest' : [shortunittest, '[unittest options] [--] [VM options] [filters...]', _unittestHelpSuffix],
--- a/mx/suite.py	Wed Jan 21 19:00:46 2015 +0100
+++ b/mx/suite.py	Wed Jan 21 19:01:13 2015 +0100
@@ -169,6 +169,13 @@
         "https://search.maven.org/remotecontent?filepath=java3d/vecmath/1.3.1/vecmath-1.3.1.jar",
       ],
       "sha1" : "a0ae4f51da409fa0c20fa0ca59e6bbc9413ae71d",
+    },
+
+    "JMH" : {
+      "path" : "lib/jmh-runner-1.4.2.jar",
+      "sha1" : "f44bffaf237305512002303a306fc5ce3fa63f76",
+      "urls" : ["http://lafo.ssw.uni-linz.ac.at/jmh/jmh-runner-1.4.2.jar"],
+      "annotationProcessor" : "true"
     }
   },
 
@@ -246,6 +253,7 @@
       "checkstyle" : "com.oracle.graal.graph",
       "javaCompliance" : "1.8",
       "workingSets" : "API,Graal,Test",
+      "jacoco" : "exclude",
     },
 
     "com.oracle.graal.api.code" : {
@@ -626,6 +634,7 @@
         "com.oracle.graal.service.processor",
       ],
       "workingSets" : "Graal,Replacements",
+      "jacoco" : "exclude",
     },
 
     "com.oracle.graal.replacements.amd64" : {
@@ -660,6 +669,7 @@
       "checkstyle" : "com.oracle.graal.graph",
       "javaCompliance" : "1.8",
       "workingSets" : "Graal,Replacements,Test",
+      "jacoco" : "exclude",
     },
 
     "com.oracle.graal.replacements.verifier" : {
@@ -737,6 +747,15 @@
       "workingSets" : "Graal,Phases",
     },
 
+    "com.oracle.graal.virtual.bench" : {
+      "subDir" : "graal",
+      "sourceDirs" : ["src"],
+      "dependencies" : ["JMH"],
+      "checkstyle" : "com.oracle.graal.graph",
+      "javaCompliance" : "1.8",
+      "workingSets" : "Graal,Bench",
+    },
+
     "com.oracle.graal.loop" : {
       "subDir" : "graal",
       "sourceDirs" : ["src"],
@@ -940,6 +959,7 @@
       "checkstyle" : "com.oracle.graal.graph",
       "javaCompliance" : "1.8",
       "workingSets" : "Graal,Test",
+      "jacoco" : "exclude",
     },
 
     "com.oracle.graal.jtt" : {
@@ -952,6 +972,7 @@
       "checkstyle" : "com.oracle.graal.graph",
       "javaCompliance" : "1.8",
       "workingSets" : "Graal,Test",
+      "jacoco" : "exclude",
     },
 
     "com.oracle.graal.asm" : {
@@ -1059,6 +1080,7 @@
       ],
       "checkstyle" : "com.oracle.graal.graph",
       "javaCompliance" : "1.8",
+      "jacoco" : "exclude",
     },
 
     "com.oracle.graal.asm.hsail" : {
@@ -1113,6 +1135,7 @@
       "checkstyle" : "com.oracle.graal.graph",
       "javaCompliance" : "1.7",
       "workingSets" : "API,Truffle,Test",
+      "jacoco" : "exclude",
     },
 
     "com.oracle.truffle.api.dsl" : {
@@ -1135,6 +1158,7 @@
       "javaCompliance" : "1.7",
       "annotationProcessors" : ["com.oracle.truffle.dsl.processor"],
       "workingSets" : "API,Truffle,Codegen,Test",
+      "jacoco" : "exclude",
     },
 
     "com.oracle.truffle.dsl.processor" : {
@@ -1219,6 +1243,7 @@
       "checkstyle" : "com.oracle.graal.graph",
       "javaCompliance" : "1.8",
       "workingSets" : "Graal,Truffle",
+      "jacoco" : "exclude",
     },
 
     "com.oracle.graal.truffle.test" : {
@@ -1232,6 +1257,7 @@
       "checkstyle" : "com.oracle.graal.graph",
       "javaCompliance" : "1.8",
       "workingSets" : "Graal,Truffle,Test",
+      "jacoco" : "exclude",
     },
 
     "com.oracle.graal.truffle.hotspot" : {
--- a/mxtool/mx.py	Wed Jan 21 19:00:46 2015 +0100
+++ b/mxtool/mx.py	Wed Jan 21 19:01:13 2015 +0100
@@ -2,7 +2,7 @@
 #
 # ----------------------------------------------------------------------------------------------------
 #
-# Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -554,10 +554,17 @@
     """
     def annotation_processors_path(self):
         aps = [project(ap) for ap in self.annotation_processors()]
-        if len(aps):
-            return os.pathsep.join([ap.definedAnnotationProcessorsDist.path for ap in aps if ap.definedAnnotationProcessorsDist])
+        libAps = [dep for dep in self.all_deps([], includeLibs=True, includeSelf=False) if dep.isLibrary() and hasattr(dep, 'annotationProcessor') and getattr(dep, 'annotationProcessor').lower() == 'true']
+        if len(aps) + len(libAps):
+            return os.pathsep.join([ap.definedAnnotationProcessorsDist.path for ap in aps if ap.definedAnnotationProcessorsDist] + [lib.get_path(False) for lib in libAps])
         return None
 
+    def uses_annotation_processor_library(self):
+        for dep in self.all_deps([], includeLibs=True, includeSelf=False):
+            if dep.isLibrary() and hasattr(dep, 'annotationProcessor'):
+                return True
+        return False
+
     def update_current_annotation_processors_file(self):
         aps = self.annotation_processors()
         outOfDate = False
@@ -2138,12 +2145,24 @@
         self._extdirs = _filter_non_existant_paths(self._extdirs)
         self._endorseddirs = _filter_non_existant_paths(self._endorseddirs)
 
+    def __repr__(self):
+        return "JavaConfig(" + str(self.jdk) + ", " + str(self.debug_port) + ")"
+
+    def __str__(self):
+        return "Java " + str(self.version) + " (" + str(self.javaCompliance) + ") from " + str(self.jdk)
+
     def __hash__(self):
         return hash(self.jdk)
 
     def __cmp__(self, other):
         if isinstance(other, JavaConfig):
-            return cmp(self.javaCompliance, other.javaCompliance)
+            compilanceCmp = cmp(self.javaCompliance, other.javaCompliance)
+            if compilanceCmp:
+                return compilanceCmp
+            versionCmp = cmp(self.version, other.version)
+            if versionCmp:
+                return versionCmp
+            return cmp(self.jdk, other.jdk)
         raise TypeError()
 
     def format_cmd(self, args, addDefaultArgs):
@@ -2445,7 +2464,10 @@
                     with open(jdtProperties) as fp:
                         origContent = fp.read()
                         content = origContent
-                        if args.jdt_warning_as_error:
+                        if self.proj.uses_annotation_processor_library():
+                            # unfortunately, the command line compiler doesn't let us ignore warnings for generated files only
+                            content = content.replace('=warning', '=ignore')
+                        elif args.jdt_warning_as_error:
                             content = content.replace('=warning', '=error')
                         if not args.jdt_show_task_tags:
                             content = content + '\norg.eclipse.jdt.core.compiler.problem.tasks=ignore'
@@ -3592,11 +3614,19 @@
             os.mkdir(srcDir)
         out.element('classpathentry', {'kind' : 'src', 'path' : src})
 
-    if len(p.annotation_processors()) > 0:
+    processorPath = p.annotation_processors_path()
+    if processorPath:
         genDir = p.source_gen_dir()
         if not exists(genDir):
             os.mkdir(genDir)
-        out.element('classpathentry', {'kind' : 'src', 'path' : 'src_gen'})
+        out.open('classpathentry', {'kind' : 'src', 'path' : 'src_gen'})
+        if p.uses_annotation_processor_library():
+            # ignore warnings produced by third-party annotation processors
+            out.open('attributes')
+            out.element('attribute', {'name' : 'ignore_optional_problems', 'value' : 'true'})
+            out.close('attributes')
+        out.close('classpathentry')
+
         if files:
             files.append(genDir)
 
@@ -3776,19 +3806,18 @@
     # copy a possibly modified file to the project's .settings directory
     for name, path in esdict.iteritems():
         # ignore this file altogether if this project has no annotation processors
-        if name == "org.eclipse.jdt.apt.core.prefs" and not len(p.annotation_processors()) > 0:
+        if name == "org.eclipse.jdt.apt.core.prefs" and not processorPath:
             continue
 
         with open(path) as f:
             content = f.read()
         content = content.replace('${javaCompliance}', str(p.javaCompliance))
-        if len(p.annotation_processors()) > 0:
+        if processorPath:
             content = content.replace('org.eclipse.jdt.core.compiler.processAnnotations=disabled', 'org.eclipse.jdt.core.compiler.processAnnotations=enabled')
         update_file(join(settingsDir, name), content)
         if files:
             files.append(join(settingsDir, name))
 
-    processorPath = p.annotation_processors_path()
     if processorPath:
         out = XMLDoc()
         out.open('factorypath')