# HG changeset patch # User Lukas Stadler # Date 1361983811 -3600 # Node ID 1aca91e4333de318eb050c105bb56d2d34007c84 # Parent a58851061377af4594a9acdcfb1192feade07d6e fix Word.readByte/writeByte/readShort/writeShort/readChar/writeChar diff -r a58851061377 -r 1aca91e4333d 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 Feb 27 15:59:16 2013 +0100 +++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java Wed Feb 27 17:50:11 2013 +0100 @@ -139,12 +139,14 @@ case READ: assert arguments.size() == 3; - replace(invoke, readOp(graph, arguments.get(0), arguments.get(1), invoke, arguments.get(2).asConstant().asObject())); + Kind readKind = asKind(callTargetNode.returnType()); + replace(invoke, readOp(graph, arguments.get(0), arguments.get(1), invoke, readKind, arguments.get(2).asConstant().asObject())); break; case WRITE: assert arguments.size() == 4; - replace(invoke, writeOp(graph, arguments.get(0), arguments.get(1), arguments.get(2), invoke, arguments.get(3).asConstant().asObject())); + Kind writeKind = asKind(targetMethod.getSignature().getParameterType(1, targetMethod.getDeclaringClass())); + replace(invoke, writeOp(graph, arguments.get(0), arguments.get(1), arguments.get(2), invoke, writeKind, arguments.get(3).asConstant().asObject())); break; case ZERO: @@ -254,8 +256,8 @@ return op; } - private static ValueNode readOp(StructuredGraph graph, ValueNode base, ValueNode offset, Invoke invoke, Object locationIdentity) { - IndexedLocationNode location = IndexedLocationNode.create(locationIdentity, invoke.node().kind(), 0, offset, graph, 1); + private static ValueNode readOp(StructuredGraph graph, ValueNode base, ValueNode offset, Invoke invoke, Kind readKind, Object locationIdentity) { + IndexedLocationNode location = IndexedLocationNode.create(locationIdentity, readKind, 0, offset, graph, 1); ReadNode read = graph.add(new ReadNode(base, location, invoke.node().stamp())); graph.addBeforeFixed(invoke.node(), read); // The read must not float outside its block otherwise it may float above an explicit zero @@ -264,8 +266,8 @@ return read; } - private static ValueNode writeOp(StructuredGraph graph, ValueNode base, ValueNode offset, ValueNode value, Invoke invoke, Object locationIdentity) { - IndexedLocationNode location = IndexedLocationNode.create(locationIdentity, value.kind(), 0, offset, graph, 1); + private static ValueNode writeOp(StructuredGraph graph, ValueNode base, ValueNode offset, ValueNode value, Invoke invoke, Kind writeKind, Object locationIdentity) { + IndexedLocationNode location = IndexedLocationNode.create(locationIdentity, writeKind, 0, offset, graph, 1); WriteNode write = graph.add(new WriteNode(base, value, location)); graph.addBeforeFixed(invoke.node(), write); return write; @@ -319,6 +321,14 @@ return false; } + public Kind asKind(JavaType type) { + if (type instanceof ResolvedJavaType) { + return isWord((ResolvedJavaType) type) ? wordKind : type.getKind(); + } else { + return Kind.Object; + } + } + private void changeToWord(ValueNode valueNode) { if (valueNode.isConstant() && valueNode.asConstant().getKind() == Kind.Object) { WordBase value = (WordBase) valueNode.asConstant().asObject();