changeset 10050:55bf0dc8e281

Merge
author Lukas Stadler <lukas.stadler@jku.at>
date Fri, 14 Jun 2013 16:28:10 +0200
parents ec8dd267d882 (current diff) 0b30da13d86b (diff)
children 215a4291e387
files
diffstat 7 files changed, 37 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CodeUtil.java	Fri Jun 14 16:27:26 2013 +0200
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CodeUtil.java	Fri Jun 14 16:28:10 2013 +0200
@@ -53,7 +53,7 @@
      * @return {@code true} if the value is a power of two; {@code false} otherwise
      */
     public static boolean isPowerOf2(int val) {
-        return val != 0 && (val & val - 1) == 0;
+        return val > 0 && (val & val - 1) == 0;
     }
 
     /**
@@ -63,7 +63,7 @@
      * @return {@code true} if the value is a power of two; {@code false} otherwise
      */
     public static boolean isPowerOf2(long val) {
-        return val != 0 && (val & val - 1) == 0;
+        return val > 0 && (val & val - 1) == 0;
     }
 
     /**
@@ -74,7 +74,7 @@
      * @return the log base 2 of the value
      */
     public static int log2(int val) {
-        assert val > 0 && isPowerOf2(val);
+        assert val > 0;
         return 31 - Integer.numberOfLeadingZeros(val);
     }
 
@@ -86,7 +86,7 @@
      * @return the log base 2 of the value
      */
     public static int log2(long val) {
-        assert val > 0 && isPowerOf2(val);
+        assert val > 0;
         return 63 - Long.numberOfLeadingZeros(val);
     }
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java	Fri Jun 14 16:27:26 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java	Fri Jun 14 16:28:10 2013 +0200
@@ -89,7 +89,7 @@
         }
         // Don't throw away the code as we assume this is a rare event
         // that will periodically occur.
-        DeoptimizeNode.deopt(InvalidateReprofile, OptimizedTypeCheckViolated);
+        DeoptimizeNode.deopt(DeoptimizationAction.None, OptimizedTypeCheckViolated);
         return falseValue;
     }
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PiNode.java	Fri Jun 14 16:27:26 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PiNode.java	Fri Jun 14 16:28:10 2013 +0200
@@ -35,7 +35,6 @@
 public class PiNode extends FloatingGuardedNode implements LIRLowerable, Virtualizable, Node.IterableNodeType, GuardingNode {
 
     @Input private ValueNode object;
-    @Input private FixedNode anchor;
 
     public ValueNode object() {
         return object;
@@ -46,10 +45,9 @@
         this.object = object;
     }
 
-    public PiNode(ValueNode object, Stamp stamp, FixedNode anchor) {
-        super(stamp);
+    public PiNode(ValueNode object, Stamp stamp, GuardingNode anchor) {
+        super(stamp, anchor);
         this.object = object;
-        this.anchor = anchor;
     }
 
     @Override
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeArrayCastNode.java	Fri Jun 14 16:27:26 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeArrayCastNode.java	Fri Jun 14 16:28:10 2013 +0200
@@ -42,11 +42,15 @@
         this.length = length;
     }
 
-    public UnsafeArrayCastNode(ValueNode object, ValueNode length, Stamp stamp, ValueNode anchor) {
+    public UnsafeArrayCastNode(ValueNode object, ValueNode length, Stamp stamp, GuardingNode anchor) {
         super(object, stamp, anchor);
         this.length = length;
     }
 
+    private UnsafeArrayCastNode(ValueNode object, ValueNode length, Stamp stamp, ValueNode anchor) {
+        this(object, length, stamp, (GuardingNode) anchor);
+    }
+
     @Override
     public ValueNode canonical(CanonicalizerTool tool) {
         if (!(object() instanceof ArrayLengthProvider) || length() != ((ArrayLengthProvider) object()).length()) {
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeCastNode.java	Fri Jun 14 16:27:26 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeCastNode.java	Fri Jun 14 16:28:10 2013 +0200
@@ -36,8 +36,12 @@
         super(object, stamp);
     }
 
+    public UnsafeCastNode(ValueNode object, Stamp stamp, GuardingNode anchor) {
+        super(object, stamp, anchor);
+    }
+
     public UnsafeCastNode(ValueNode object, Stamp stamp, ValueNode anchor) {
-        super(object, stamp, (FixedNode) anchor);
+        this(object, stamp, (GuardingNode) anchor);
     }
 
     public UnsafeCastNode(ValueNode object, ResolvedJavaType toType, boolean exactType, boolean nonNull) {
@@ -100,7 +104,7 @@
     public static native <T> T unsafeCast(Object object, @ConstantNodeParameter Stamp stamp);
 
     @NodeIntrinsic
-    public static native <T> T unsafeCast(Object object, @ConstantNodeParameter Stamp stamp, ValueNode anchor);
+    public static native <T> T unsafeCast(Object object, @ConstantNodeParameter Stamp stamp, GuardingNode anchor);
 
     @SuppressWarnings("unused")
     @NodeIntrinsic
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java	Fri Jun 14 16:27:26 2013 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java	Fri Jun 14 16:28:10 2013 +0200
@@ -491,15 +491,13 @@
             LoadHubNode receiverHub = graph.add(new LoadHubNode(receiver, typeHub.kind()));
             CompareNode typeCheck = CompareNode.createCompareNode(Condition.EQ, receiverHub, typeHub);
             FixedGuardNode guard = graph.add(new FixedGuardNode(typeCheck, DeoptimizationReason.TypeCheckedInliningViolated, DeoptimizationAction.InvalidateReprofile));
-            ValueAnchorNode anchor = graph.add(new ValueAnchorNode());
             assert invoke.predecessor() != null;
 
-            ValueNode anchoredReceiver = createAnchoredReceiver(graph, anchor, type, receiver, true);
+            ValueNode anchoredReceiver = createAnchoredReceiver(graph, guard, type, receiver, true);
             invoke.callTarget().replaceFirstInput(receiver, anchoredReceiver);
 
             graph.addBeforeFixed(invoke.asNode(), receiverHub);
             graph.addBeforeFixed(invoke.asNode(), guard);
-            graph.addBeforeFixed(invoke.asNode(), anchor);
         }
 
         @Override
@@ -1227,9 +1225,13 @@
         }
     }
 
-    private static PiNode createAnchoredReceiver(StructuredGraph graph, FixedNode anchor, ResolvedJavaType commonType, ValueNode receiver, boolean exact) {
+    private static PiNode createAnchoredReceiver(StructuredGraph graph, GuardingNode anchor, ResolvedJavaType commonType, ValueNode receiver, boolean exact) {
+        return createAnchoredReceiver(graph, anchor, receiver, exact ? StampFactory.exactNonNull(commonType) : StampFactory.declaredNonNull(commonType));
+    }
+
+    private static PiNode createAnchoredReceiver(StructuredGraph graph, GuardingNode anchor, ValueNode receiver, Stamp stamp) {
         // to avoid that floating reads on receiver fields float above the type check
-        return graph.unique(new PiNode(receiver, exact ? StampFactory.exactNonNull(commonType) : StampFactory.declaredNonNull(commonType), anchor));
+        return graph.unique(new PiNode(receiver, stamp, anchor));
     }
 
     // TODO (chaeubl): cleanup this method
@@ -1298,9 +1300,17 @@
 
         FrameState stateAfter = invoke.stateAfter();
         assert stateAfter == null || stateAfter.isAlive();
-        GuardingNode receiverNullCheckNode = null;
         if (receiverNullCheck) {
-            receiverNullCheckNode = receiverNullCheck(invoke);
+            GuardingNode receiverNullCheckNode = receiverNullCheck(invoke);
+            if (receiverNullCheckNode != null) {
+                ValueNode receiver = invoke.callTarget().arguments().get(0);
+                Stamp piStamp = receiver.stamp();
+                if (piStamp instanceof ObjectStamp) {
+                    piStamp = piStamp.join(StampFactory.objectNonNull());
+                }
+                ValueNode anchoredReceiver = createAnchoredReceiver(graph, receiverNullCheckNode, receiver, piStamp);
+                invoke.callTarget().replaceFirstInput(receiver, anchoredReceiver);
+            }
         }
 
         IdentityHashMap<Node, Node> replacements = new IdentityHashMap<>();
@@ -1313,18 +1323,7 @@
             if (node == entryPointNode || node == entryPointNode.stateAfter()) {
                 // Do nothing.
             } else if (node instanceof LocalNode) {
-                int localIndex = ((LocalNode) node).index();
-                ValueNode parameter = parameters.get(localIndex);
-                if (receiverNullCheckNode != null && localIndex == 0) {
-                    Stamp piStamp = parameter.stamp();
-                    if (piStamp instanceof ObjectStamp) {
-                        piStamp = piStamp.join(StampFactory.objectNonNull());
-                    }
-                    PiNode piReceiver = graph.add(new PiNode(parameter, piStamp));
-                    piReceiver.setGuard(receiverNullCheckNode);
-                    parameter = piReceiver;
-                }
-                replacements.put(node, parameter);
+                replacements.put(node, parameters.get(((LocalNode) node).index()));
             } else {
                 nodes.add(node);
                 if (node instanceof ReturnNode) {
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeClosure.java	Fri Jun 14 16:27:26 2013 +0200
+++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeClosure.java	Fri Jun 14 16:28:10 2013 +0200
@@ -349,9 +349,7 @@
                         locksMatch &= obj.locksEqual(startObj);
                     }
 
-                    assert virtual < states.size() || locksMatch : "mismatching lock counts at " + merge;
-
-                    if (virtual < states.size()) {
+                    if (virtual < states.size() || !locksMatch) {
                         if (singleValue == null) {
                             PhiNode materializedValuePhi = getCachedPhi(object, Kind.Object);
                             mergeEffects.addFloatingNode(materializedValuePhi, "materializedPhi");