changeset 11332:e4a1593cc6e4

Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Fri, 16 Aug 2013 19:07:10 +0200
parents 07814c3b5dba
children a07d9113d1f6
files graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java
diffstat 1 files changed, 31 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java	Fri Aug 16 19:05:04 2013 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java	Fri Aug 16 19:07:10 2013 +0200
@@ -34,6 +34,7 @@
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.java.*;
 import com.oracle.graal.nodes.java.MethodCallTargetNode.InvokeKind;
+import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.nodes.type.*;
 import com.oracle.graal.nodes.util.*;
 import com.oracle.graal.phases.*;
@@ -489,15 +490,7 @@
                     boolean nonNull = state.isNonNull(object);
                     GuardingNode replacementAnchor = null;
                     if (nonNull) {
-                        // Search for valid instanceof anchor.
-                        for (InstanceOfNode instanceOfNode : object.usages().filter(InstanceOfNode.class)) {
-                            if (instanceOfNode.type() == checkCast.type() && state.trueConditions.containsKey(instanceOfNode)) {
-                                ValueNode v = state.trueConditions.get(instanceOfNode);
-                                if (v instanceof GuardingNode) {
-                                    replacementAnchor = (GuardingNode) v;
-                                }
-                            }
-                        }
+                        replacementAnchor = searchAnchor(GraphUtil.unproxify(object), type);
                     }
                     ValueAnchorNode anchor = null;
                     if (replacementAnchor == null) {
@@ -608,5 +601,34 @@
 
             }
         }
+
+        private GuardingNode searchAnchor(ValueNode value, ResolvedJavaType type) {
+            for (Node n : value.usages()) {
+                if (n instanceof InstanceOfNode) {
+                    InstanceOfNode instanceOfNode = (InstanceOfNode) n;
+                    if (instanceOfNode.type() == type && state.trueConditions.containsKey(instanceOfNode)) {
+                        ValueNode v = state.trueConditions.get(instanceOfNode);
+                        if (v instanceof GuardingNode) {
+                            return (GuardingNode) v;
+                        }
+                    }
+                }
+            }
+
+            for (Node n : value.usages()) {
+                if (n instanceof ValueProxy) {
+                    ValueProxy proxyNode = (ValueProxy) n;
+                    if (proxyNode.getOriginalValue() == value) {
+                        GuardingNode result = searchAnchor((ValueNode) n, type);
+                        if (result != null) {
+                            return result;
+                        }
+                    }
+
+                }
+            }
+
+            return null;
+        }
     }
 }