Mercurial > hg > graal-jvmci-8
diff graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultVirtualFrame.java @ 13201:833f8e96d0a5
Truffle: improved error mesage for accessing unknonw frame slots.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Fri, 22 Nov 2013 14:45:09 +0100 |
parents | 856a9864ed93 |
children | a12017c18d5d |
line wrap: on
line diff
--- 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]; }