changeset 10911:3c398866d634

Frame.isInitialized: add method substitution and suppress AIOOBE if frame size < descriptor size.
author Andreas Woess <andreas.woess@jku.at>
date Tue, 30 Jul 2013 13:07:48 +0200
parents b61c13ad27d0
children 4ea54634f03e
files graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/FrameWithoutBoxing.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/FrameWithoutBoxingSubstitutions.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultVirtualFrame.java
diffstat 3 files changed, 22 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/FrameWithoutBoxing.java	Mon Jul 29 17:13:00 2013 -0700
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/FrameWithoutBoxing.java	Tue Jul 30 13:07:48 2013 +0200
@@ -283,6 +283,14 @@
 
     @Override
     public boolean isInitialized(FrameSlot slot) {
-        return tags[slot.getIndex()] != FrameSlotKind.Illegal.ordinal();
+        try {
+            return tags[slot.getIndex()] != 0;
+        } catch (ArrayIndexOutOfBoundsException ex) {
+            CompilerDirectives.transferToInterpreter();
+            if (slot.getIndex() >= 0 && slot.getIndex() < descriptor.getSize()) {
+                return false;
+            }
+            throw ex;
+        }
     }
 }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/FrameWithoutBoxingSubstitutions.java	Mon Jul 29 17:13:00 2013 -0700
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/FrameWithoutBoxingSubstitutions.java	Tue Jul 30 13:07:48 2013 +0200
@@ -209,4 +209,9 @@
     public static MaterializedFrame materialize(FrameWithoutBoxing frame) {
         return MaterializeFrameNode.materialize(frame);
     }
+
+    @MethodSubstitution(isStatic = false, forced = true)
+    public static boolean isInitialized(FrameWithoutBoxing frame, FrameSlot slot) {
+        return getTag(frame, slot) != 0;
+    }
 }
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultVirtualFrame.java	Mon Jul 29 17:13:00 2013 -0700
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultVirtualFrame.java	Tue Jul 30 13:07:48 2013 +0200
@@ -204,6 +204,13 @@
 
     @Override
     public boolean isInitialized(FrameSlot slot) {
-        return tags[slot.getIndex()] != FrameSlotKind.Illegal.ordinal();
+        try {
+            return tags[slot.getIndex()] != 0;
+        } catch (ArrayIndexOutOfBoundsException ex) {
+            if (slot.getIndex() >= 0 && slot.getIndex() < descriptor.getSize()) {
+                return false;
+            }
+            throw ex;
+        }
     }
 }