changeset 11447:3653d3a66d3b

ReadNode: minor refactoring in push()
author Bernhard Urban <bernhard.urban@jku.at>
date Wed, 28 Aug 2013 21:36:30 +0200
parents 124662d7d103
children 8fa34d155cb0 5d5bfb75dae0
files graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java
diffstat 1 files changed, 22 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java	Wed Aug 28 21:28:58 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java	Wed Aug 28 21:36:30 2013 +0200
@@ -104,29 +104,31 @@
 
     @Override
     public boolean push(PiNode parent) {
-        if (location() instanceof ConstantLocationNode) {
-            long displacement = ((ConstantLocationNode) location()).getDisplacement();
-            if (parent.stamp() instanceof ObjectStamp) {
-                ObjectStamp piStamp = (ObjectStamp) parent.stamp();
-                ResolvedJavaType receiverType = piStamp.type();
-                if (receiverType != null) {
-                    ResolvedJavaField field = receiverType.findInstanceFieldWithOffset(displacement);
+        if (!(location() instanceof ConstantLocationNode && parent.stamp() instanceof ObjectStamp && parent.object().stamp() instanceof ObjectStamp)) {
+            return false;
+        }
 
-                    if (field != null && parent.object().stamp() instanceof ObjectStamp) {
-                        ResolvedJavaType declaringClass = field.getDeclaringClass();
-                        ObjectStamp piValueStamp = (ObjectStamp) parent.object().stamp();
-                        ResolvedJavaType piValueType = ObjectStamp.typeOrNull(piValueStamp);
-                        if (piValueType != null && declaringClass.isAssignableFrom(piValueType)) {
-                            if (piStamp.nonNull() == piValueStamp.nonNull() && piStamp.alwaysNull() == piValueStamp.alwaysNull()) {
-                                replaceFirstInput(parent, parent.object());
-                                return true;
-                            }
-                        }
-                    }
-                }
+        ObjectStamp piStamp = (ObjectStamp) parent.stamp();
+        ResolvedJavaType receiverType = piStamp.type();
+        if (receiverType == null) {
+            return false;
+        }
+
+        ResolvedJavaField field = receiverType.findInstanceFieldWithOffset(((ConstantLocationNode) location()).getDisplacement());
+        if (field == null) {
+            // field was not declared by receiverType
+            return false;
+        }
+
+        ObjectStamp valueStamp = (ObjectStamp) parent.object().stamp();
+        ResolvedJavaType valueType = ObjectStamp.typeOrNull(valueStamp);
+        if (valueType != null && field.getDeclaringClass().isAssignableFrom(valueType)) {
+            if (piStamp.nonNull() == valueStamp.nonNull() && piStamp.alwaysNull() == valueStamp.alwaysNull()) {
+                replaceFirstInput(parent, parent.object());
+                return true;
             }
+        }
 
-        }
         return false;
     }