# HG changeset patch # User Christian Wimmer # Date 1357340898 28800 # Node ID f9f40467383e6630ab4f6b898ac26a82e67a4524 # Parent 6e68b27928c86e300984732d1edeb74e05e6467b Fixes for new Word type diff -r 6e68b27928c8 -r f9f40467383e graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/StampTool.java --- 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); diff -r 6e68b27928c8 -r f9f40467383e graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java --- 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()); diff -r 6e68b27928c8 -r f9f40467383e graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeVerificationPhase.java --- 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");