# HG changeset patch # User Andreas Woess # Date 1413393625 -7200 # Node ID 315d56483616fbb7da514d6573d317b717cf2543 # Parent b72ce1826bd056d056bdcf47971cc7105e98f297 Truffle: use long constants for offset calculation diff -r b72ce1826bd0 -r 315d56483616 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/FrameWithoutBoxing.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/FrameWithoutBoxing.java Wed Oct 15 19:25:43 2014 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/FrameWithoutBoxing.java Wed Oct 15 19:20:25 2014 +0200 @@ -35,10 +35,10 @@ * frame object would show up very late and would be hard to identify. */ public final class FrameWithoutBoxing implements VirtualFrame, MaterializedFrame { - private static final int OBJECT_BASE_OFFSET = Unsafe.ARRAY_OBJECT_BASE_OFFSET; - private static final int OBJECT_INDEX_SCALE = Unsafe.ARRAY_OBJECT_INDEX_SCALE; - private static final int PRIMITIVE_BASE_OFFSET = Unsafe.ARRAY_INT_BASE_OFFSET; - private static final int PRIMITIVE_INDEX_SCALE = Unsafe.ARRAY_INT_INDEX_SCALE * 2; + private static final long OBJECT_BASE_OFFSET = Unsafe.ARRAY_OBJECT_BASE_OFFSET; + private static final long OBJECT_INDEX_SCALE = Unsafe.ARRAY_OBJECT_INDEX_SCALE; + private static final long PRIMITIVE_BASE_OFFSET = Unsafe.ARRAY_INT_BASE_OFFSET; + private static final long PRIMITIVE_INDEX_SCALE = Unsafe.ARRAY_INT_INDEX_SCALE * 2; private final FrameDescriptor descriptor; private final Object[] arguments; @@ -86,7 +86,7 @@ private Object getObjectUnsafe(FrameSlot slot) { int slotIndex = slot.getIndex(); - return CompilerDirectives.unsafeGetObject(getLocals(), (long) slotIndex * OBJECT_INDEX_SCALE + OBJECT_BASE_OFFSET, this.getTags()[slotIndex] == FrameSlotKind.Object.ordinal(), slot); + return CompilerDirectives.unsafeGetObject(getLocals(), OBJECT_BASE_OFFSET + slotIndex * OBJECT_INDEX_SCALE, this.getTags()[slotIndex] == FrameSlotKind.Object.ordinal(), slot); } @Override @@ -96,7 +96,7 @@ } private void setObjectUnsafe(FrameSlot slot, Object value) { - CompilerDirectives.unsafePutObject(getLocals(), (long) slot.getIndex() * OBJECT_INDEX_SCALE + OBJECT_BASE_OFFSET, value, slot); + CompilerDirectives.unsafePutObject(getLocals(), OBJECT_BASE_OFFSET + slot.getIndex() * OBJECT_INDEX_SCALE, value, slot); } @Override @@ -107,7 +107,7 @@ private byte getByteUnsafe(FrameSlot slot) { int slotIndex = slot.getIndex(); - return CompilerDirectives.unsafeGetByte(getPrimitiveLocals(), (long) slotIndex * PRIMITIVE_INDEX_SCALE + PRIMITIVE_BASE_OFFSET, this.getTags()[slotIndex] == FrameSlotKind.Byte.ordinal(), slot); + return CompilerDirectives.unsafeGetByte(getPrimitiveLocals(), PRIMITIVE_BASE_OFFSET + slotIndex * PRIMITIVE_INDEX_SCALE, this.getTags()[slotIndex] == FrameSlotKind.Byte.ordinal(), slot); } @Override @@ -117,7 +117,7 @@ } private void setByteUnsafe(FrameSlot slot, byte value) { - CompilerDirectives.unsafePutByte(getPrimitiveLocals(), (long) slot.getIndex() * PRIMITIVE_INDEX_SCALE + PRIMITIVE_BASE_OFFSET, value, slot); + CompilerDirectives.unsafePutByte(getPrimitiveLocals(), PRIMITIVE_BASE_OFFSET + slot.getIndex() * PRIMITIVE_INDEX_SCALE, value, slot); } @Override @@ -128,8 +128,7 @@ private boolean getBooleanUnsafe(FrameSlot slot) { int slotIndex = slot.getIndex(); - return CompilerDirectives.unsafeGetBoolean(getPrimitiveLocals(), (long) slotIndex * PRIMITIVE_INDEX_SCALE + PRIMITIVE_BASE_OFFSET, - this.getTags()[slotIndex] == FrameSlotKind.Boolean.ordinal(), slot); + return CompilerDirectives.unsafeGetBoolean(getPrimitiveLocals(), PRIMITIVE_BASE_OFFSET + slotIndex * PRIMITIVE_INDEX_SCALE, this.getTags()[slotIndex] == FrameSlotKind.Boolean.ordinal(), slot); } @Override @@ -139,7 +138,7 @@ } private void setBooleanUnsafe(FrameSlot slot, boolean value) { - CompilerDirectives.unsafePutBoolean(getPrimitiveLocals(), (long) slot.getIndex() * PRIMITIVE_INDEX_SCALE + PRIMITIVE_BASE_OFFSET, value, slot); + CompilerDirectives.unsafePutBoolean(getPrimitiveLocals(), PRIMITIVE_BASE_OFFSET + slot.getIndex() * PRIMITIVE_INDEX_SCALE, value, slot); } @Override @@ -150,8 +149,7 @@ private float getFloatUnsafe(FrameSlot slot) { int slotIndex = slot.getIndex(); - return CompilerDirectives.unsafeGetFloat(getPrimitiveLocals(), (long) slotIndex * PRIMITIVE_INDEX_SCALE + PRIMITIVE_BASE_OFFSET, this.getTags()[slotIndex] == FrameSlotKind.Float.ordinal(), - slot); + return CompilerDirectives.unsafeGetFloat(getPrimitiveLocals(), PRIMITIVE_BASE_OFFSET + slotIndex * PRIMITIVE_INDEX_SCALE, this.getTags()[slotIndex] == FrameSlotKind.Float.ordinal(), slot); } @Override @@ -161,7 +159,7 @@ } private void setFloatUnsafe(FrameSlot slot, float value) { - CompilerDirectives.unsafePutFloat(getPrimitiveLocals(), (long) slot.getIndex() * PRIMITIVE_INDEX_SCALE + PRIMITIVE_BASE_OFFSET, value, slot); + CompilerDirectives.unsafePutFloat(getPrimitiveLocals(), PRIMITIVE_BASE_OFFSET + slot.getIndex() * PRIMITIVE_INDEX_SCALE, value, slot); } @Override @@ -172,7 +170,7 @@ private long getLongUnsafe(FrameSlot slot) { int slotIndex = slot.getIndex(); - return CompilerDirectives.unsafeGetLong(getPrimitiveLocals(), (long) slotIndex * PRIMITIVE_INDEX_SCALE + PRIMITIVE_BASE_OFFSET, this.getTags()[slotIndex] == FrameSlotKind.Long.ordinal(), slot); + return CompilerDirectives.unsafeGetLong(getPrimitiveLocals(), PRIMITIVE_BASE_OFFSET + slotIndex * PRIMITIVE_INDEX_SCALE, this.getTags()[slotIndex] == FrameSlotKind.Long.ordinal(), slot); } @Override @@ -182,7 +180,7 @@ } private void setLongUnsafe(FrameSlot slot, long value) { - CompilerDirectives.unsafePutLong(getPrimitiveLocals(), (long) slot.getIndex() * PRIMITIVE_INDEX_SCALE + PRIMITIVE_BASE_OFFSET, value, slot); + CompilerDirectives.unsafePutLong(getPrimitiveLocals(), PRIMITIVE_BASE_OFFSET + slot.getIndex() * PRIMITIVE_INDEX_SCALE, value, slot); } @Override @@ -193,7 +191,7 @@ private int getIntUnsafe(FrameSlot slot) { int slotIndex = slot.getIndex(); - return CompilerDirectives.unsafeGetInt(getPrimitiveLocals(), (long) slotIndex * PRIMITIVE_INDEX_SCALE + PRIMITIVE_BASE_OFFSET, this.getTags()[slotIndex] == FrameSlotKind.Int.ordinal(), slot); + return CompilerDirectives.unsafeGetInt(getPrimitiveLocals(), PRIMITIVE_BASE_OFFSET + slotIndex * PRIMITIVE_INDEX_SCALE, this.getTags()[slotIndex] == FrameSlotKind.Int.ordinal(), slot); } @Override @@ -203,7 +201,7 @@ } private void setIntUnsafe(FrameSlot slot, int value) { - CompilerDirectives.unsafePutInt(getPrimitiveLocals(), (long) slot.getIndex() * PRIMITIVE_INDEX_SCALE + PRIMITIVE_BASE_OFFSET, value, slot); + CompilerDirectives.unsafePutInt(getPrimitiveLocals(), PRIMITIVE_BASE_OFFSET + slot.getIndex() * PRIMITIVE_INDEX_SCALE, value, slot); } @Override @@ -214,8 +212,7 @@ private double getDoubleUnsafe(FrameSlot slot) { int slotIndex = slot.getIndex(); - return CompilerDirectives.unsafeGetDouble(getPrimitiveLocals(), (long) slotIndex * PRIMITIVE_INDEX_SCALE + PRIMITIVE_BASE_OFFSET, this.getTags()[slotIndex] == FrameSlotKind.Double.ordinal(), - slot); + return CompilerDirectives.unsafeGetDouble(getPrimitiveLocals(), PRIMITIVE_BASE_OFFSET + slotIndex * PRIMITIVE_INDEX_SCALE, this.getTags()[slotIndex] == FrameSlotKind.Double.ordinal(), slot); } @Override @@ -225,7 +222,7 @@ } private void setDoubleUnsafe(FrameSlot slot, double value) { - CompilerDirectives.unsafePutDouble(getPrimitiveLocals(), (long) slot.getIndex() * PRIMITIVE_INDEX_SCALE + PRIMITIVE_BASE_OFFSET, value, slot); + CompilerDirectives.unsafePutDouble(getPrimitiveLocals(), PRIMITIVE_BASE_OFFSET + slot.getIndex() * PRIMITIVE_INDEX_SCALE, value, slot); } @Override