changeset 8515:6ed17512f672

-Merge
author Christos Kotselidis <christos.kotselidis@oracle.com>
date Mon, 25 Mar 2013 16:31:26 +0100
parents 32e57c4e0e9d (current diff) 149dee7367e0 (diff)
children c1385bb5851b
files graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraalMethodSubstitutions.java mx/commands.py
diffstat 11 files changed, 86 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java	Mon Mar 25 16:20:07 2013 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java	Mon Mar 25 16:31:26 2013 +0100
@@ -152,7 +152,9 @@
                     // to be valid for the entire run of the VM.
                     Assumptions assumptions = new Assumptions(false);
                     ReplacementsInstaller installer = new HotSpotReplacementsInstaller(runtime, assumptions, runtime.getGraalRuntime().getTarget());
-                    GraalMethodSubstitutions.installIntrinsics(installer);
+                    for (ReplacementsProvider provider : ServiceLoader.loadInstalled(ReplacementsProvider.class)) {
+                        provider.installReplacements(installer);
+                    }
                     runtime.installReplacements(graalRuntime.getBackend(), installer, assumptions);
                 }
             });
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/OnStackReplacementPhase.java	Mon Mar 25 16:20:07 2013 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/OnStackReplacementPhase.java	Mon Mar 25 16:31:26 2013 +0100
@@ -79,16 +79,17 @@
             NodeIterable<EntryMarkerNode> osrNodes = graph.getNodes(EntryMarkerNode.class);
             osr = osrNodes.first();
             if (osr == null) {
-                throw new BailoutException("no OnStackReplacementNode generated");
+                throw new BailoutException("No OnStackReplacementNode generated");
             }
             if (osrNodes.count() > 1) {
-                throw new GraalInternalError("multiple OnStackReplacementNodes generated");
+                // this can happen with JSR inlining
+                throw new BailoutException("Multiple OnStackReplacementNodes generated");
             }
             if (osr.stateAfter().locksSize() != 0) {
-                throw new BailoutException("osr with locks not supported");
+                throw new BailoutException("OSR with locks not supported");
             }
             if (osr.stateAfter().stackSize() != 0) {
-                throw new BailoutException("osr with stack entries not supported: " + osr.stateAfter().toString(Verbosity.Debugger));
+                throw new BailoutException("OSR with stack entries not supported: " + osr.stateAfter().toString(Verbosity.Debugger));
             }
             LoopEx osrLoop = null;
             LoopsData loops = new LoopsData(graph);
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java	Mon Mar 25 16:20:07 2013 +0100
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java	Mon Mar 25 16:31:26 2013 +0100
@@ -1128,7 +1128,7 @@
             frameState.pushReturn(resultType, result);
             return invoke;
         } else {
-            ExceptionObjectNode exceptionEdge = (ExceptionObjectNode) handleException(null, bci());
+            DispatchBeginNode exceptionEdge = handleException(null, bci());
             InvokeWithExceptionNode invoke = currentGraph.add(new InvokeWithExceptionNode(callTarget, exceptionEdge, bci()));
             ValueNode result = append(invoke);
             frameState.pushReturn(resultType, result);
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/InvokeWithExceptionNode.java	Mon Mar 25 16:20:07 2013 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/InvokeWithExceptionNode.java	Mon Mar 25 16:31:26 2013 +0100
@@ -35,7 +35,7 @@
 public class InvokeWithExceptionNode extends ControlSplitNode implements Node.IterableNodeType, Invoke, MemoryCheckpoint, LIRLowerable {
 
     @Successor private BeginNode next;
-    @Successor private ExceptionObjectNode exceptionEdge;
+    @Successor private DispatchBeginNode exceptionEdge;
     @Input private final CallTargetNode callTarget;
     @Input private FrameState stateAfter;
     private final int bci;
@@ -43,7 +43,7 @@
     private boolean useForInlining;
     private double inliningRelevance;
 
-    public InvokeWithExceptionNode(CallTargetNode callTarget, ExceptionObjectNode exceptionEdge, int bci) {
+    public InvokeWithExceptionNode(CallTargetNode callTarget, DispatchBeginNode exceptionEdge, int bci) {
         super(callTarget.returnStamp());
         this.exceptionEdge = exceptionEdge;
         this.bci = bci;
@@ -53,11 +53,11 @@
         this.inliningRelevance = Double.NaN;
     }
 
-    public ExceptionObjectNode exceptionEdge() {
+    public DispatchBeginNode exceptionEdge() {
         return exceptionEdge;
     }
 
-    public void setExceptionEdge(ExceptionObjectNode x) {
+    public void setExceptionEdge(DispatchBeginNode x) {
         updatePredecessor(exceptionEdge, x);
         exceptionEdge = x;
     }
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java	Mon Mar 25 16:20:07 2013 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java	Mon Mar 25 16:31:26 2013 +0100
@@ -448,7 +448,7 @@
             PhiNode exceptionObjectPhi = null;
             if (invoke instanceof InvokeWithExceptionNode) {
                 InvokeWithExceptionNode invokeWithException = (InvokeWithExceptionNode) invoke;
-                ExceptionObjectNode exceptionEdge = invokeWithException.exceptionEdge();
+                ExceptionObjectNode exceptionEdge = (ExceptionObjectNode) invokeWithException.exceptionEdge();
 
                 exceptionMerge = graph.add(new MergeNode());
                 exceptionMerge.setProbability(exceptionEdge.probability());
@@ -484,7 +484,7 @@
             // replace the invoke exception edge
             if (invoke instanceof InvokeWithExceptionNode) {
                 InvokeWithExceptionNode invokeWithExceptionNode = (InvokeWithExceptionNode) invoke;
-                ExceptionObjectNode exceptionEdge = invokeWithExceptionNode.exceptionEdge();
+                ExceptionObjectNode exceptionEdge = (ExceptionObjectNode) invokeWithExceptionNode.exceptionEdge();
                 exceptionEdge.replaceAtUsages(exceptionObjectPhi);
                 exceptionEdge.setNext(null);
                 GraphUtil.killCFG(invokeWithExceptionNode.exceptionEdge());
@@ -656,7 +656,7 @@
                 assert exceptionMerge != null && exceptionObjectPhi != null;
 
                 InvokeWithExceptionNode invokeWithException = (InvokeWithExceptionNode) invoke;
-                ExceptionObjectNode exceptionEdge = invokeWithException.exceptionEdge();
+                ExceptionObjectNode exceptionEdge = (ExceptionObjectNode) invokeWithException.exceptionEdge();
                 FrameState stateAfterException = exceptionEdge.stateAfter();
 
                 ExceptionObjectNode newExceptionEdge = (ExceptionObjectNode) exceptionEdge.copyWithInputs();
@@ -1063,7 +1063,7 @@
             if (unwindNode != null) {
                 assert unwindNode.predecessor() != null;
                 assert invokeWithException.exceptionEdge().successors().count() == 1;
-                ExceptionObjectNode obj = invokeWithException.exceptionEdge();
+                ExceptionObjectNode obj = (ExceptionObjectNode) invokeWithException.exceptionEdge();
                 stateAtExceptionEdge = obj.stateAfter();
                 UnwindNode unwindDuplicate = (UnwindNode) duplicates.get(unwindNode);
                 obj.replaceAtUsages(unwindDuplicate.exception());
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.replacements/src/META-INF/services/com.oracle.graal.replacements.ReplacementsProvider	Mon Mar 25 16:31:26 2013 +0100
@@ -0,0 +1,1 @@
+com.oracle.graal.replacements.GraalMethodSubstitutions
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraalMethodSubstitutions.java	Mon Mar 25 16:20:07 2013 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraalMethodSubstitutions.java	Mon Mar 25 16:31:26 2013 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, 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
@@ -27,9 +27,9 @@
 /**
  * Method substitutions that are VM-independent.
  */
-public class GraalMethodSubstitutions {
+public class GraalMethodSubstitutions implements ReplacementsProvider {
 
-    public static void installIntrinsics(ReplacementsInstaller installer) {
+    public void installReplacements(ReplacementsInstaller installer) {
         if (GraalOptions.Intrinsify) {
             installer.installSubstitutions(MathSubstitutionsX86.class);
             installer.installSubstitutions(DoubleSubstitutions.class);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsProvider.java	Mon Mar 25 16:31:26 2013 +0100
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013, 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.replacements;
+
+/**
+ * Interface for service providers that install replacements into the compiler.
+ */
+public interface ReplacementsProvider {
+
+    void installReplacements(ReplacementsInstaller installer);
+}
--- a/mx/commands.py	Mon Mar 25 16:20:07 2013 +0100
+++ b/mx/commands.py	Mon Mar 25 16:31:26 2013 +0100
@@ -1025,6 +1025,8 @@
     vm = _vm
     if len(args) is 0:
         args = ['all']
+        
+    vmArgs = [arg for arg in args if arg.startswith('-')]
 
     def benchmarks_in_group(group):
         prefix = group + ':'
@@ -1069,7 +1071,7 @@
         benchmarks += [sanitycheck.getSPECjbb2013()]
 
     for test in benchmarks:
-        for (groupName, res) in test.bench(vm).items():
+        for (groupName, res) in test.bench(vm, opts=vmArgs).items():
             group = results.setdefault(groupName, {})
             group.update(res)
     mx.log(json.dumps(results))
--- a/mxtool/mx	Mon Mar 25 16:20:07 2013 +0100
+++ b/mxtool/mx	Mon Mar 25 16:31:26 2013 +0100
@@ -37,14 +37,27 @@
     exit 1
 fi
 
-python <<END
+# Not all systems (e.g. Mac OS X) have 'python2' on the path.
+type python2.7 >/dev/null 2>&1
+if [ $? -eq 0 ]; then
+    python_exe=python2.7
+else
+    type python2 > /dev/null 2>&1
+    if [ $? -eq 0]; then
+        python_exe=python2
+    else
+        python_exe=python
+    fi
+fi
+
+$python_exe <<END
 import sys
 major, minor, micro, _, _ = sys.version_info
 if major != 2 or minor != 7:
     raise SystemExit('The mx.py script requires Python 2.7, not {0}.{1}.{2}'.format(major, minor, micro))
 END
 if [ $? -eq 0 ]; then
-    exec python -u "$dir/mx.py" "$@"
+    exec $python_exe -u "$dir/mx.py" "$@"
 fi
 
 #end of file
--- a/mxtool/mx.py	Mon Mar 25 16:20:07 2013 +0100
+++ b/mxtool/mx.py	Mon Mar 25 16:31:26 2013 +0100
@@ -1658,16 +1658,28 @@
             dname = name[1:]
             d = distribution(dname)
             fd, tmp = tempfile.mkstemp(suffix='', prefix=basename(d.path) + '.', dir=dirname(d.path))
+            services = tempfile.mkdtemp(suffix='', prefix=basename(d.path) + '.', dir=dirname(d.path))
             zf = zipfile.ZipFile(tmp, 'w')
             for p in sorted_deps(d.deps):
                 outputDir = p.output_dir()
                 for root, _, files in os.walk(outputDir):
-                    for f in files:
-                        relpath = root[len(outputDir) + 1:]
-                        arcname = join(relpath, f).replace(os.sep, '/')
-                        zf.write(join(root, f), arcname)
+                    relpath = root[len(outputDir) + 1:]
+                    if relpath == join('META-INF', 'services'):
+                        for f in files:
+                            with open(join(services, f), 'a') as outfile:
+                                with open(join(root, f), 'r') as infile:
+                                    for line in infile:
+                                        outfile.write(line)
+                    else:
+                        for f in files:
+                            arcname = join(relpath, f).replace(os.sep, '/')
+                            zf.write(join(root, f), arcname)
+            for f in os.listdir(services):
+                arcname = join('META-INF', 'services', f).replace(os.sep, '/')
+                zf.write(join(services, f), arcname)
             zf.close()
             os.close(fd)
+            shutil.rmtree(services)
             # Atomic on Unix
             shutil.move(tmp, d.path)
             #print time.time(), 'move:', tmp, '->', d.path