# HG changeset patch # User Roland Schatz # Date 1433845042 -7200 # Node ID 1965441ace7bf7b1d48b544fb4f5c5e4b60e0582 # Parent 30b03297ba94a5afd9746bf30da92fe836a29e5c Use wordKind/wordSize instead of hardcoded long/64 in address calculations. diff -r 30b03297ba94 -r 1965441ace7b graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/DefaultHotSpotLoweringProvider.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/DefaultHotSpotLoweringProvider.java Tue Jun 09 11:06:32 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/DefaultHotSpotLoweringProvider.java Tue Jun 09 12:17:22 2015 +0200 @@ -327,7 +327,7 @@ } } - private static void lowerLoadMethodNode(LoadMethodNode loadMethodNode) { + private void lowerLoadMethodNode(LoadMethodNode loadMethodNode) { StructuredGraph graph = loadMethodNode.graph(); HotSpotResolvedJavaMethod method = (HotSpotResolvedJavaMethod) loadMethodNode.getMethod(); ReadNode metaspaceMethod = createReadVirtualMethod(graph, loadMethodNode.getHub(), method, loadMethodNode.getReceiverType()); @@ -446,11 +446,11 @@ return false; } - private static ReadNode createReadVirtualMethod(StructuredGraph graph, ValueNode hub, HotSpotResolvedJavaMethod method, ResolvedJavaType receiverType) { + private ReadNode createReadVirtualMethod(StructuredGraph graph, ValueNode hub, HotSpotResolvedJavaMethod method, ResolvedJavaType receiverType) { return createReadVirtualMethod(graph, hub, method.vtableEntryOffset(receiverType)); } - private static ReadNode createReadVirtualMethod(StructuredGraph graph, ValueNode hub, int vtableEntryOffset) { + private ReadNode createReadVirtualMethod(StructuredGraph graph, ValueNode hub, int vtableEntryOffset) { assert vtableEntryOffset > 0; // We use LocationNode.ANY_LOCATION for the reads that access the vtable // entry as HotSpot does not guarantee that this is a final value. diff -r 30b03297ba94 -r 1965441ace7b graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/DefaultJavaLoweringProvider.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/DefaultJavaLoweringProvider.java Tue Jun 09 11:06:32 2015 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/DefaultJavaLoweringProvider.java Tue Jun 09 12:17:22 2015 +0200 @@ -127,8 +127,8 @@ GraphUtil.removeFixedWithUnusedInputs(n); } - protected static AddressNode createOffsetAddress(StructuredGraph graph, ValueNode object, long offset) { - ValueNode o = ConstantNode.forLong(offset, graph); + protected AddressNode createOffsetAddress(StructuredGraph graph, ValueNode object, long offset) { + ValueNode o = ConstantNode.forIntegerKind(target.wordKind, offset, graph); return graph.unique(new OffsetAddressNode(object, o)); } @@ -188,13 +188,19 @@ } public AddressNode createArrayAddress(StructuredGraph graph, ValueNode array, Kind elementKind, ValueNode index) { - ValueNode longIndex = graph.unique(new SignExtendNode(index, 64)); + ValueNode wordIndex; + if (target.wordSize > 4) { + wordIndex = graph.unique(new SignExtendNode(index, target.wordSize * 8)); + } else { + assert target.wordSize == 4 : "unsupported word size"; + wordIndex = index; + } int shift = CodeUtil.log2(arrayScalingFactor(elementKind)); - ValueNode scaledIndex = graph.unique(new LeftShiftNode(longIndex, ConstantNode.forInt(shift, graph))); + ValueNode scaledIndex = graph.unique(new LeftShiftNode(wordIndex, ConstantNode.forInt(shift, graph))); int base = arrayBaseOffset(elementKind); - ValueNode offset = graph.unique(new AddNode(scaledIndex, ConstantNode.forLong(base, graph))); + ValueNode offset = graph.unique(new AddNode(scaledIndex, ConstantNode.forIntegerKind(target.wordKind, base, graph))); return graph.unique(new OffsetAddressNode(array, offset)); }