# HG changeset patch # User Andreas Woess # Date 1366805662 -7200 # Node ID 8cf939b349ddd45ab90444b652a98f82ef0fe875 # Parent 1fcaf6edc69db7dcfed78abc8aba1679a7483da4 Frame API: automatically change frame slot type for uninitialized slots diff -r 1fcaf6edc69d -r 8cf939b349dd 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 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(); } } diff -r 1fcaf6edc69d -r 8cf939b349dd graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java Wed Apr 24 13:35:14 2013 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java Wed Apr 24 14:14:22 2013 +0200 @@ -100,9 +100,6 @@ this.parentOffset = parentOffsetTemp; } - /** - * (db) getters added to support AST cloning for parallel execution. - */ public long getParentOffset() { return parentOffset; } diff -r 1fcaf6edc69d -r 8cf939b349dd graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/NodeFactory.java --- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/NodeFactory.java Wed Apr 24 13:35:14 2013 +0200 +++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/NodeFactory.java Wed Apr 24 14:14:22 2013 +0200 @@ -59,7 +59,7 @@ } public TypedNode createLocal(String name) { - return ReadLocalNodeFactory.create(frameDescriptor.findOrAddFrameSlot(name, Integer.class)); + return ReadLocalNodeFactory.create(frameDescriptor.findOrAddFrameSlot(name, int.class)); } public TypedNode createStringLiteral(String value) { @@ -67,7 +67,7 @@ } public StatementNode createAssignment(String name, TypedNode right) { - return WriteLocalNodeFactory.create(frameDescriptor.findOrAddFrameSlot(name, Integer.class), right); + return WriteLocalNodeFactory.create(frameDescriptor.findOrAddFrameSlot(name, int.class), right); } public StatementNode createPrint(List expressions) { @@ -123,7 +123,7 @@ } public StatementNode createReturn(TypedNode value) { - FrameSlot slot = frameDescriptor.findOrAddFrameSlot("", Integer.class); + FrameSlot slot = frameDescriptor.findOrAddFrameSlot("", int.class); if (returnValue == null) { returnValue = ReadLocalNodeFactory.create(slot); } diff -r 1fcaf6edc69d -r 8cf939b349dd graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/WriteLocalNode.java --- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/WriteLocalNode.java Wed Apr 24 13:35:14 2013 +0200 +++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/WriteLocalNode.java Wed Apr 24 14:14:22 2013 +0200 @@ -38,29 +38,13 @@ @Specialization(rewriteOn = FrameSlotTypeException.class) public int write(VirtualFrame frame, int right) throws FrameSlotTypeException { - try { - frame.setInt(slot, right); - } catch (FrameSlotTypeException e) { - if (slot.getType() == null) { - FrameUtil.setIntSafe(frame, slot, right); - } else { - throw e; - } - } + frame.setInt(slot, right); return right; } @Specialization(rewriteOn = FrameSlotTypeException.class) public boolean write(VirtualFrame frame, boolean right) throws FrameSlotTypeException { - try { - frame.setBoolean(slot, right); - } catch (FrameSlotTypeException e) { - if (slot.getType() == null) { - FrameUtil.setBooleanSafe(frame, slot, right); - } else { - throw e; - } - } + frame.setBoolean(slot, right); return right; }