# HG changeset patch
# User Christian Wirth
@@ -64,11 +65,20 @@ public void test() { TruffleRuntime runtime = Truffle.getRuntime(); FrameDescriptor frameDescriptor = new FrameDescriptor(); - FrameSlot slot = frameDescriptor.addFrameSlot("localVar", FrameSlotKind.Int); + String varName = "localVar"; + FrameSlot slot = frameDescriptor.addFrameSlot(varName, FrameSlotKind.Int); TestRootNode rootNode = new TestRootNode(frameDescriptor, new AssignLocal(slot), new ReadLocal(slot)); CallTarget target = runtime.createCallTarget(rootNode); Object result = target.call(); Assert.assertEquals(42, result); + frameDescriptor.removeFrameSlot(varName); + boolean slotMissing = false; + try { + result = target.call(); + } catch (IllegalArgumentException iae) { + slotMissing = true; + } + Assert.assertTrue(slotMissing); } class TestRootNode extends RootNode { diff -r c35d86f53ace -r 54892f32714e graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameDescriptor.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameDescriptor.java Wed Feb 05 11:38:00 2014 +0100 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameDescriptor.java Wed Feb 05 11:44:10 2014 +0100 @@ -86,6 +86,14 @@ return addFrameSlot(identifier, kind); } + public void removeFrameSlot(Object identifier) { + assert identifierToSlotMap.containsKey(identifier); + slots.remove(identifierToSlotMap.get(identifier)); + identifierToSlotMap.remove(identifier); + updateVersion(); + getNotInFrameAssumption(identifier); + } + public int getSize() { return slots.size(); }