changeset 13970:bbf84e85b775

Move BytecodeFrame validation into the HotSpot backend
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Tue, 18 Feb 2014 11:16:48 -0800
parents fe034af88233
children 3e5b9a4d5986
files graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/BytecodeFrame.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCompiledCode.java
diffstat 2 files changed, 21 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/BytecodeFrame.java	Tue Feb 18 10:47:13 2014 -0800
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/BytecodeFrame.java	Tue Feb 18 11:16:48 2014 -0800
@@ -116,16 +116,14 @@
         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
+     * because of Word type rewriting and alternative backends that can't be done.
      */
-    private boolean validateFormat() {
+    public boolean validateFormat() {
         for (int i = 0; i < numLocals + numStack; i++) {
             if (values[i] != null) {
                 Kind kind = values[i].getKind();
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCompiledCode.java	Tue Feb 18 10:47:13 2014 -0800
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCompiledCode.java	Tue Feb 18 11:16:48 2014 -0800
@@ -31,6 +31,7 @@
 import com.oracle.graal.api.code.CompilationResult.Data;
 import com.oracle.graal.api.code.CompilationResult.DataPatch;
 import com.oracle.graal.api.code.CompilationResult.ExceptionHandler;
+import com.oracle.graal.api.code.CompilationResult.Infopoint;
 import com.oracle.graal.api.code.CompilationResult.JumpTable;
 import com.oracle.graal.api.code.CompilationResult.Mark;
 import com.oracle.graal.api.code.CompilationResult.Site;
@@ -195,6 +196,24 @@
                 comments[i] = new Comment(annotation.position, text);
             }
         }
+        assert validateFrames();
+    }
+
+    /**
+     * Ensure that all the frames passed into HotSpot are properly formatted with an empty or
+     * illegal slot following double word slots.
+     */
+    private boolean validateFrames() {
+        for (Site site : sites) {
+            if (site instanceof Infopoint) {
+                Infopoint info = (Infopoint) site;
+                if (info.debugInfo != null) {
+                    BytecodeFrame frame = info.debugInfo.frame();
+                    assert frame == null || frame.validateFormat();
+                }
+            }
+        }
+        return true;
     }
 
     static class SiteComparator implements Comparator<Site> {