Mercurial > hg > truffle
diff graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultVirtualFrame.java @ 9321:cd1a1d92b3e3
Frame API: Introduce FrameSlotKind.
author | Andreas Woess <andreas.woess@jku.at> |
---|---|
date | Thu, 25 Apr 2013 18:14:08 +0200 |
parents | 8cf939b349dd |
children | e162d9e32830 |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultVirtualFrame.java Thu Apr 25 23:17:58 2013 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultVirtualFrame.java Thu Apr 25 18:14:08 2013 +0200 @@ -33,14 +33,14 @@ private final PackedFrame caller; private final Arguments arguments; private Object[] locals; - private Class[] tags; + private byte[] tags; public DefaultVirtualFrame(FrameDescriptor descriptor, PackedFrame caller, Arguments arguments) { this.descriptor = descriptor; this.caller = caller; this.arguments = arguments; this.locals = new Object[descriptor.getSize()]; - this.tags = new Class[descriptor.getSize()]; + this.tags = new byte[descriptor.getSize()]; } @Override @@ -65,73 +65,73 @@ @Override public Object getObject(FrameSlot slot) throws FrameSlotTypeException { - verifyGet(slot, Object.class); + verifyGet(slot, FrameSlotKind.Object); return locals[slot.getIndex()]; } @Override public void setObject(FrameSlot slot, Object value) throws FrameSlotTypeException { - verifySet(slot, Object.class); + verifySet(slot, FrameSlotKind.Object); locals[slot.getIndex()] = value; } @Override public boolean getBoolean(FrameSlot slot) throws FrameSlotTypeException { - verifyGet(slot, boolean.class); + verifyGet(slot, FrameSlotKind.Boolean); return (boolean) locals[slot.getIndex()]; } @Override public void setBoolean(FrameSlot slot, boolean value) throws FrameSlotTypeException { - verifySet(slot, boolean.class); + verifySet(slot, FrameSlotKind.Boolean); locals[slot.getIndex()] = value; } @Override public int getInt(FrameSlot slot) throws FrameSlotTypeException { - verifyGet(slot, int.class); + verifyGet(slot, FrameSlotKind.Int); return (int) locals[slot.getIndex()]; } @Override public void setInt(FrameSlot slot, int value) throws FrameSlotTypeException { - verifySet(slot, int.class); + verifySet(slot, FrameSlotKind.Int); locals[slot.getIndex()] = value; } @Override public long getLong(FrameSlot slot) throws FrameSlotTypeException { - verifyGet(slot, long.class); + verifyGet(slot, FrameSlotKind.Long); return (long) locals[slot.getIndex()]; } @Override public void setLong(FrameSlot slot, long value) throws FrameSlotTypeException { - verifySet(slot, long.class); + verifySet(slot, FrameSlotKind.Long); locals[slot.getIndex()] = value; } @Override public float getFloat(FrameSlot slot) throws FrameSlotTypeException { - verifyGet(slot, float.class); + verifyGet(slot, FrameSlotKind.Float); return (float) locals[slot.getIndex()]; } @Override public void setFloat(FrameSlot slot, float value) throws FrameSlotTypeException { - verifySet(slot, float.class); + verifySet(slot, FrameSlotKind.Float); locals[slot.getIndex()] = value; } @Override public double getDouble(FrameSlot slot) throws FrameSlotTypeException { - verifyGet(slot, double.class); + verifyGet(slot, FrameSlotKind.Double); return (double) locals[slot.getIndex()]; } @Override public void setDouble(FrameSlot slot, double value) throws FrameSlotTypeException { - verifySet(slot, double.class); + verifySet(slot, FrameSlotKind.Double); locals[slot.getIndex()] = value; } @@ -147,19 +147,19 @@ assert index >= 0 && index < descriptor.getSize(); return descriptor.getTypeConversion().getDefaultValue(); } - Class tag = tags[index]; - if (tag == null) { + byte tag = tags[index]; + if (tag == FrameSlotKind.Illegal.ordinal()) { return descriptor.getTypeConversion().getDefaultValue(); } else { return locals[index]; } } - private void verifySet(FrameSlot slot, Class accessType) throws FrameSlotTypeException { - Class<?> slotType = slot.getType(); - if (slotType != accessType) { - if (slotType == null) { - slot.setType(accessType); + private void verifySet(FrameSlot slot, FrameSlotKind accessKind) throws FrameSlotTypeException { + FrameSlotKind slotKind = slot.getKind(); + if (slotKind != accessKind) { + if (slotKind == FrameSlotKind.Illegal) { + slot.setKind(accessKind); } else { throw new FrameSlotTypeException(); } @@ -168,14 +168,14 @@ if (slotIndex >= tags.length) { resize(); } - tags[slotIndex] = accessType; + tags[slotIndex] = (byte) accessKind.ordinal(); } - private void verifyGet(FrameSlot slot, Class accessType) throws FrameSlotTypeException { - Class<?> slotType = slot.getType(); - if (slotType != accessType) { - if (slotType == null && accessType == Object.class) { - slot.setType(Object.class); + private void verifyGet(FrameSlot slot, FrameSlotKind accessKind) throws FrameSlotTypeException { + FrameSlotKind slotKind = slot.getKind(); + if (slotKind != accessKind) { + if (slotKind == FrameSlotKind.Illegal && accessKind == FrameSlotKind.Object) { + slot.setKind(FrameSlotKind.Object); this.setObject(slot, descriptor.getTypeConversion().getDefaultValue()); } else { throw new FrameSlotTypeException(); @@ -185,9 +185,9 @@ if (slotIndex >= tags.length) { resize(); } - if (tags[slotIndex] != accessType) { + if (tags[slotIndex] != accessKind.ordinal()) { descriptor.getTypeConversion().updateFrameSlot(this, slot, getValue(slot)); - if (tags[slotIndex] != accessType) { + if (tags[slotIndex] != accessKind.ordinal()) { throw new FrameSlotTypeException(); } }