changeset 7302:f9f40467383e

Fixes for new Word type
author Christian Wimmer <christian.wimmer@oracle.com>
date Fri, 04 Jan 2013 15:08:18 -0800
parents 6e68b27928c8
children 7952e3cfa6ed 570d8e4c6dfb d7c1266a26c7
files graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/StampTool.java graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeVerificationPhase.java
diffstat 3 files changed, 22 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/StampTool.java	Fri Jan 04 12:45:50 2013 -0800
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/StampTool.java	Fri Jan 04 15:08:18 2013 -0800
@@ -135,17 +135,19 @@
         if (shift.lowerBound() == shift.upperBound()) {
             long shiftMask = kind == Kind.Int ? 0x1FL : 0x3FL;
             long shiftCount = shift.lowerBound() & shiftMask;
-            long lowerBound;
-            long upperBound;
-            if (value.lowerBound() < 0) {
-                lowerBound = 0;
-                upperBound = IntegerStamp.defaultMask(kind) >>> shiftCount;
-            } else {
-                lowerBound = value.lowerBound() >>> shiftCount;
-                upperBound = value.upperBound() >>> shiftCount;
+            if (shiftCount != 0) {
+                long lowerBound;
+                long upperBound;
+                if (value.lowerBound() < 0) {
+                    lowerBound = 0;
+                    upperBound = IntegerStamp.defaultMask(kind) >>> shiftCount;
+                } else {
+                    lowerBound = value.lowerBound() >>> shiftCount;
+                    upperBound = value.upperBound() >>> shiftCount;
+                }
+                long mask = value.mask() >>> shiftCount;
+                return StampFactory.forInteger(kind, lowerBound, upperBound, mask);
             }
-            long mask = value.mask() >>> shiftCount;
-            return StampFactory.forInteger(kind, lowerBound, upperBound, mask);
         }
         long mask = IntegerStamp.maskFor(kind, value.lowerBound(), value.upperBound());
         return stampForMask(kind, mask);
--- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java	Fri Jan 04 12:45:50 2013 -0800
+++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java	Fri Jan 04 15:08:18 2013 -0800
@@ -283,7 +283,13 @@
             return true;
         }
         if (node instanceof LoadIndexedNode) {
-            return isWord(((LoadIndexedNode) node).array().objectStamp().type().getComponentType());
+            ValueNode array = ((LoadIndexedNode) node).array();
+            if (array.objectStamp().type() == null) {
+                // There are cases where the array does not have a known type yet. Assume it is not a word type.
+                // TODO disallow LoadIndexedNode for word arrays?
+                return false;
+            }
+            return isWord(array.objectStamp().type().getComponentType());
         }
         if (node.kind() == Kind.Object) {
             return isWord(node.objectStamp().type());
--- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeVerificationPhase.java	Fri Jan 04 12:45:50 2013 -0800
+++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeVerificationPhase.java	Fri Jan 04 15:08:18 2013 -0800
@@ -58,8 +58,9 @@
                 } else if (usage instanceof StoreFieldNode) {
                     verify(!isWord(node) || ((StoreFieldNode) usage).object() != node, node, usage, "cannot store to word value");
                 } else if (usage instanceof CheckCastNode) {
-                    verify(!isWord(node), node, usage, "word value cannot be cast");
-                    verify(!isWord(((CheckCastNode) usage).type()), node, usage, "cannot cast to word value");
+                    boolean expectWord = isWord(node);
+                    verify(isWord(node) == expectWord, node, usage, "word cannot be cast to object, and vice versa");
+                    verify(isWord(((CheckCastNode) usage).type()) == expectWord, node, usage, "word cannot be cast to object, and vice versa");
                 } else if (usage instanceof LoadIndexedNode) {
                     verify(!isWord(node) || ((LoadIndexedNode) usage).array() != node, node, usage, "cannot load from word value");
                     verify(!isWord(node) || ((LoadIndexedNode) usage).index() != node, node, usage, "cannot use word value as index");