Mercurial > hg > graal-compiler
changeset 11427:51dcddfa25a6
Truffle: add Byte to Frame
author | Christian Wirth <christian.wirth@oracle.com> |
---|---|
date | Mon, 26 Aug 2013 18:25:40 +0200 |
parents | 7c4c1a7c875a |
children | 6f58979d0755 |
files | graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/FrameWithoutBoxing.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/Frame.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameSlotKind.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameUtil.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/NativeFrame.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultMaterializedFrame.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultVirtualFrame.java |
diffstat | 7 files changed, 89 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/FrameWithoutBoxing.java Mon Aug 26 17:10:45 2013 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/FrameWithoutBoxing.java Mon Aug 26 18:25:40 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);
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/Frame.java Mon Aug 26 17:10:45 2013 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/Frame.java Mon Aug 26 18:25:40 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
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameSlotKind.java Mon Aug 26 17:10:45 2013 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameSlotKind.java Mon Aug 26 18:25:40 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; }
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameUtil.java Mon Aug 26 17:10:45 2013 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameUtil.java Mon Aug 26 18:25:40 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.
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/NativeFrame.java Mon Aug 26 17:10:45 2013 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/NativeFrame.java Mon Aug 26 18:25:40 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"); }
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultMaterializedFrame.java Mon Aug 26 17:10:45 2013 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultMaterializedFrame.java Mon Aug 26 18:25:40 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); }
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultVirtualFrame.java Mon Aug 26 17:10:45 2013 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultVirtualFrame.java Mon Aug 26 18:25:40 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()];