Mercurial > hg > graal-compiler
diff graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultVirtualFrame.java @ 9278:8cf939b349dd
Frame API: automatically change frame slot type for uninitialized slots
author | Andreas Woess <andreas.woess@jku.at> |
---|---|
date | Wed, 24 Apr 2013 14:14:22 +0200 |
parents | 07f8d136a05e |
children | cd1a1d92b3e3 |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultVirtualFrame.java Wed Apr 24 13:35:14 2013 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultVirtualFrame.java Wed Apr 24 14:14:22 2013 +0200 @@ -156,8 +156,13 @@ } private void verifySet(FrameSlot slot, Class accessType) throws FrameSlotTypeException { - if (slot.getType() != accessType) { - throw new FrameSlotTypeException(); + Class<?> slotType = slot.getType(); + if (slotType != accessType) { + if (slotType == null) { + slot.setType(accessType); + } else { + throw new FrameSlotTypeException(); + } } int slotIndex = slot.getIndex(); if (slotIndex >= tags.length) { @@ -168,25 +173,21 @@ private void verifyGet(FrameSlot slot, Class accessType) throws FrameSlotTypeException { Class<?> slotType = slot.getType(); - int slotIndex = slot.getIndex(); if (slotType != accessType) { - if (slotType == null) { + if (slotType == null && accessType == Object.class) { slot.setType(Object.class); this.setObject(slot, descriptor.getTypeConversion().getDefaultValue()); - if (accessType != Object.class) { - throw new FrameSlotTypeException(); - } } else { throw new FrameSlotTypeException(); } } + int slotIndex = slot.getIndex(); if (slotIndex >= tags.length) { resize(); } - Class tag = tags[slotIndex]; - if (tag != slotType) { + if (tags[slotIndex] != accessType) { descriptor.getTypeConversion().updateFrameSlot(this, slot, getValue(slot)); - if (tags[slotIndex] != slotType) { + if (tags[slotIndex] != accessType) { throw new FrameSlotTypeException(); } }