# HG changeset patch # User Christian Wimmer # Date 1367432959 25200 # Node ID 37345671860c0741c4a717516fb813cfc11869d4 # Parent 1964cf13c3767abe0476ef498bc35ff68e4b92a6 Better handling of array access nodes in Word type rewriter diff -r 1964cf13c376 -r 37345671860c 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 Wed May 01 11:27:45 2013 -0700 +++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java Wed May 01 11:29:19 2013 -0700 @@ -103,9 +103,27 @@ } } - for (LoadIndexedNode load : graph.getNodes().filter(LoadIndexedNode.class).snapshot()) { - if (isWord(load)) { - load.setStamp(StampFactory.forKind(wordKind)); + for (AccessIndexedNode node : graph.getNodes().filter(AccessIndexedNode.class).snapshot()) { + ValueNode array = 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. + continue; + } + assert array.objectStamp().type().isArray(); + if (isWord(array.objectStamp().type().getComponentType())) { + /* + * The elementKind of the node is a final field, and other information such as the + * stamp depends on elementKind. Therefore, just create a new node and replace the + * old one. + */ + if (node instanceof LoadIndexedNode) { + graph.replaceFixedWithFixed(node, graph.add(new LoadIndexedNode(node.array(), node.index(), wordKind))); + } else if (node instanceof StoreIndexedNode) { + graph.replaceFixedWithFixed(node, graph.add(new StoreIndexedNode(node.array(), node.index(), wordKind, ((StoreIndexedNode) node).value()))); + } else { + throw GraalInternalError.shouldNotReachHere(); + } } } @@ -309,16 +327,6 @@ if (node.stamp() == StampFactory.forWord()) { return true; } - if (node instanceof LoadIndexedNode) { - 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()); }