# HG changeset patch # User Christian Humer # Date 1385127909 -3600 # Node ID 833f8e96d0a557dd652958ee476a77a5bf9fd429 # Parent b96536453a74cd0735a4d97befb76e710cbfc362 Truffle: improved error mesage for accessing unknonw frame slots. diff -r b96536453a74 -r 833f8e96d0a5 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/FrameWithoutBoxing.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/FrameWithoutBoxing.java Fri Nov 22 01:50:13 2013 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/FrameWithoutBoxing.java Fri Nov 22 14:45:09 2013 +0100 @@ -239,7 +239,9 @@ int slotIndex = slot.getIndex(); if (slotIndex >= getTags().length) { CompilerDirectives.transferToInterpreter(); - resize(); + if (!resize()) { + throw new IllegalArgumentException(String.format("The frame slot '%s' is not known by the frame descriptor.", slot)); + } } getTags()[slotIndex] = (byte) accessKind.ordinal(); } @@ -248,7 +250,9 @@ int slotIndex = slot.getIndex(); if (slotIndex >= getTags().length) { CompilerDirectives.transferToInterpreter(); - resize(); + if (!resize()) { + throw new IllegalArgumentException(String.format("The frame slot '%s' is not known by the frame descriptor.", slot)); + } } byte tag = this.getTags()[slotIndex]; if (tag != accessKind.ordinal()) { @@ -289,7 +293,7 @@ } } - private void resize() { + private boolean resize() { int oldSize = tags.length; int newSize = descriptor.getSize(); if (newSize > oldSize) { @@ -297,7 +301,9 @@ Arrays.fill(locals, oldSize, newSize, descriptor.getTypeConversion().getDefaultValue()); primitiveLocals = Arrays.copyOf(primitiveLocals, newSize); tags = Arrays.copyOf(tags, newSize); + return true; } + return false; } private byte getTag(FrameSlot slot) { diff -r b96536453a74 -r 833f8e96d0a5 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 Fri Nov 22 01:50:13 2013 +0100 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultVirtualFrame.java Fri Nov 22 14:45:09 2013 +0100 @@ -160,7 +160,9 @@ public Object getValue(FrameSlot slot) { int slotIndex = slot.getIndex(); if (slotIndex >= tags.length) { - resize(); + if (!resize()) { + throw new IllegalArgumentException(String.format("The frame slot '%s' is not known by the frame descriptor.", slot)); + } } return locals[slotIndex]; } @@ -168,7 +170,9 @@ private void verifySet(FrameSlot slot, FrameSlotKind accessKind) { int slotIndex = slot.getIndex(); if (slotIndex >= tags.length) { - resize(); + if (!resize()) { + throw new IllegalArgumentException(String.format("The frame slot '%s' is not known by the frame descriptor.", slot)); + } } tags[slotIndex] = (byte) accessKind.ordinal(); } @@ -176,7 +180,9 @@ private void verifyGet(FrameSlot slot, FrameSlotKind accessKind) throws FrameSlotTypeException { int slotIndex = slot.getIndex(); if (slotIndex >= tags.length) { - resize(); + if (!resize()) { + throw new IllegalArgumentException(String.format("The frame slot '%s' is not known by the frame descriptor.", slot)); + } } byte tag = tags[slotIndex]; if (accessKind == FrameSlotKind.Object ? tag != 0 : tag != accessKind.ordinal()) { @@ -190,20 +196,24 @@ } } - private void resize() { + private boolean resize() { int oldSize = tags.length; int newSize = descriptor.getSize(); if (newSize > oldSize) { locals = Arrays.copyOf(locals, newSize); Arrays.fill(locals, oldSize, newSize, descriptor.getTypeConversion().getDefaultValue()); tags = Arrays.copyOf(tags, newSize); + return true; } + return false; } private byte getTag(FrameSlot slot) { int slotIndex = slot.getIndex(); if (slotIndex >= tags.length) { - resize(); + if (!resize()) { + throw new IllegalArgumentException(String.format("The frame slot '%s' is not known by the frame descriptor.", slot)); + } } return tags[slotIndex]; }