# HG changeset patch # User Doug Simon # Date 1377598092 -7200 # Node ID 3ceffcb771e510c75e1f20f2d09a2315f18c7b64 # Parent 016da8e6fbeffc8a0af920965fc22d0ae010ee8d# Parent be97540098f540507a421380f17f1b53b8562a51 Merge. diff -r 016da8e6fbef -r 3ceffcb771e5 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 Tue Aug 27 12:03:31 2013 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/FrameWithoutBoxing.java Tue Aug 27 12:08:12 2013 +0200 @@ -100,6 +100,26 @@ } @Override + public byte getByte(FrameSlot slot) throws FrameSlotTypeException { + verifyGet(slot, FrameSlotKind.Byte); + return getByteUnsafe(slot); + } + + private byte getByteUnsafe(FrameSlot slot) { + return unsafe.getByte(primitiveLocals, (long) slot.getIndex() * Unsafe.ARRAY_LONG_INDEX_SCALE + Unsafe.ARRAY_LONG_BASE_OFFSET); + } + + @Override + public void setByte(FrameSlot slot, byte value) throws FrameSlotTypeException { + verifySet(slot, FrameSlotKind.Byte); + setByteUnsafe(slot, value); + } + + private void setByteUnsafe(FrameSlot slot, byte value) { + unsafe.putByte(primitiveLocals, (long) slot.getIndex() * Unsafe.ARRAY_LONG_INDEX_SCALE + Unsafe.ARRAY_LONG_BASE_OFFSET, value); + } + + @Override public boolean getBoolean(FrameSlot slot) throws FrameSlotTypeException { verifyGet(slot, FrameSlotKind.Boolean); return getBooleanUnsafe(slot); diff -r 016da8e6fbef -r 3ceffcb771e5 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/FrameWithoutBoxingSubstitutions.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/FrameWithoutBoxingSubstitutions.java Tue Aug 27 12:03:31 2013 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/FrameWithoutBoxingSubstitutions.java Tue Aug 27 12:08:12 2013 +0200 @@ -80,6 +80,18 @@ } @MethodSubstitution(isStatic = false, forced = true) + public static byte getByte(FrameWithoutBoxing frame, FrameSlot slot) { + verifyGet(frame, slot, FrameSlotKind.Byte); + return getByteUnsafe(frame, slot); + } + + @MethodSubstitution(isStatic = false, forced = true) + public static void setByte(FrameWithoutBoxing frame, FrameSlot slot, byte value) { + verifySet(frame, slot, FrameSlotKind.Byte); + setByteUnsafe(frame, slot, value); + } + + @MethodSubstitution(isStatic = false, forced = true) public static float getFloat(FrameWithoutBoxing frame, FrameSlot slot) { verifyGet(frame, slot, FrameSlotKind.Float); return getFloatUnsafe(frame, slot); @@ -148,6 +160,16 @@ } @MethodSubstitution(isStatic = false) + public static byte getByteUnsafe(FrameWithoutBoxing frame, FrameSlot slot) { + return FrameGetNode.get(Kind.Byte, frame, slot, PRIMITIVELOCALS_FIELD); + } + + @MethodSubstitution(isStatic = false) + public static void setByteUnsafe(FrameWithoutBoxing frame, FrameSlot slot, byte value) { + FrameSetNode.set(Kind.Byte, frame, slot, value, PRIMITIVELOCALS_FIELD); + } + + @MethodSubstitution(isStatic = false) public static int getIntUnsafe(FrameWithoutBoxing frame, FrameSlot slot) { return FrameGetNode.get(Kind.Int, frame, slot, PRIMITIVELOCALS_FIELD); } diff -r 016da8e6fbef -r 3ceffcb771e5 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/Frame.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/Frame.java Tue Aug 27 12:03:31 2013 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/Frame.java Tue Aug 27 12:08:12 2013 +0200 @@ -67,6 +67,23 @@ void setObject(FrameSlot slot, Object value) throws FrameSlotTypeException; /** + * Read access to a local variable of type byte. + * + * @param slot the slot of the local variable + * @return the current value of the local variable + */ + byte getByte(FrameSlot slot) throws FrameSlotTypeException; + + /** + * Write access to a local variable of type byte. + * + * @param slot the slot of the local variable + * @param value the new value of the local variable + */ + + void setByte(FrameSlot slot, byte value) throws FrameSlotTypeException; + + /** * Read access to a local variable of type boolean. * * @param slot the slot of the local variable diff -r 016da8e6fbef -r 3ceffcb771e5 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameSlotKind.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameSlotKind.java Tue Aug 27 12:03:31 2013 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameSlotKind.java Tue Aug 27 12:08:12 2013 +0200 @@ -25,5 +25,5 @@ package com.oracle.truffle.api.frame; public enum FrameSlotKind { - Illegal, Object, Long, Int, Double, Float, Boolean; + Illegal, Object, Long, Int, Double, Float, Boolean, Byte; } diff -r 016da8e6fbef -r 3ceffcb771e5 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameUtil.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameUtil.java Tue Aug 27 12:03:31 2013 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameUtil.java Tue Aug 27 12:08:12 2013 +0200 @@ -46,6 +46,25 @@ } /** + * Write access to a local variable of type {@code byte}. + * + * Sets the frame slot type to {@code byte} if it isn't already. + * + * @param slot the slot of the local variable + * @param value the new value of the local variable + */ + public static void setByteSafe(Frame frame, FrameSlot slot, byte value) { + if (slot.getKind() != FrameSlotKind.Byte) { + slot.setKind(FrameSlotKind.Byte); + } + try { + frame.setByte(slot, value); + } catch (FrameSlotTypeException e) { + throw new IllegalStateException(); + } + } + + /** * Write access to a local variable of type {@code boolean}. * * Sets the frame slot type to {@code boolean} if it isn't already. diff -r 016da8e6fbef -r 3ceffcb771e5 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/NativeFrame.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/NativeFrame.java Tue Aug 27 12:03:31 2013 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/NativeFrame.java Tue Aug 27 12:08:12 2013 +0200 @@ -57,6 +57,16 @@ } @Override + public byte getByte(FrameSlot slot) { + throw new UnsupportedOperationException("native frame"); + } + + @Override + public void setByte(FrameSlot slot, byte value) { + throw new UnsupportedOperationException("native frame"); + } + + @Override public boolean getBoolean(FrameSlot slot) { throw new UnsupportedOperationException("native frame"); } diff -r 016da8e6fbef -r 3ceffcb771e5 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultMaterializedFrame.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultMaterializedFrame.java Tue Aug 27 12:03:31 2013 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultMaterializedFrame.java Tue Aug 27 12:08:12 2013 +0200 @@ -51,6 +51,16 @@ } @Override + public byte getByte(FrameSlot slot) throws FrameSlotTypeException { + return wrapped.getByte(slot); + } + + @Override + public void setByte(FrameSlot slot, byte value) throws FrameSlotTypeException { + wrapped.setByte(slot, value); + } + + @Override public boolean getBoolean(FrameSlot slot) throws FrameSlotTypeException { return wrapped.getBoolean(slot); } diff -r 016da8e6fbef -r 3ceffcb771e5 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultVirtualFrame.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultVirtualFrame.java Tue Aug 27 12:03:31 2013 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultVirtualFrame.java Tue Aug 27 12:08:12 2013 +0200 @@ -79,6 +79,18 @@ } @Override + public byte getByte(FrameSlot slot) throws FrameSlotTypeException { + verifyGet(slot, FrameSlotKind.Byte); + return (byte) locals[slot.getIndex()]; + } + + @Override + public void setByte(FrameSlot slot, byte value) throws FrameSlotTypeException { + verifySet(slot, FrameSlotKind.Byte); + locals[slot.getIndex()] = value; + } + + @Override public boolean getBoolean(FrameSlot slot) throws FrameSlotTypeException { verifyGet(slot, FrameSlotKind.Boolean); return (boolean) locals[slot.getIndex()];