changeset 13929:f191cac04605

add assert to check format of debug info
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Tue, 11 Feb 2014 10:36:57 -0800
parents 6be4edba54ba
children 7d1d638bd7d6
files graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/BytecodeFrame.java
diffstat 1 files changed, 20 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/BytecodeFrame.java	Tue Feb 11 08:47:18 2014 -0800
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/BytecodeFrame.java	Tue Feb 11 10:36:57 2014 -0800
@@ -116,6 +116,26 @@
         this.numStack = numStack;
         this.numLocks = numLocks;
         assert !rethrowException || numStack == 1 : "must have exception on top of the stack";
+        assert validateFormat();
+    }
+
+    /**
+     * Ensure that the frame state is formatted as expected by the JVM, with null or Illegal in the
+     * slot following a double word item. This should really be checked in FrameState itself but
+     * because of Word type rewriting that can't be done. If a frame makes it into this code, then
+     * could be materialized by the JVM so it must follow the rules. it
+     */
+    private boolean validateFormat() {
+        for (int i = 0; i < numLocals + numStack; i++) {
+            if (values[i] != null) {
+                Kind kind = values[i].getKind();
+                if (kind == Kind.Long || kind == Kind.Double) {
+                    assert values.length > i + 1 : String.format("missing second word %s", this);
+                    assert values[i + 1] == null || values[i + 1].getKind() == Kind.Illegal;
+                }
+            }
+        }
+        return true;
     }
 
     /**