changeset 23195:6270677f430d

Add assertion check for monitors and lock depth
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Wed, 16 Dec 2015 18:46:03 -0800
parents d7e8407137ae
children 6af2a84b8f4c
files graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FrameState.java
diffstat 1 files changed, 16 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FrameState.java	Wed Dec 16 17:17:00 2015 -0800
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FrameState.java	Wed Dec 16 18:46:03 2015 -0800
@@ -547,6 +547,12 @@
                 assertTrue(state != null, "must be non-null");
             }
         }
+        if (monitorIds() != null && monitorIds().size() > 0) {
+            int depth = outerLockDepth();
+            for (MonitorIdNode monitor : monitorIds()) {
+                assertTrue(monitor.getLockDepth() == depth++, "wrong depth");
+            }
+        }
         assertTrue(locksSize() == monitorIdCount(), "mismatch in number of locks");
         for (ValueNode value : values) {
             assertTrue(value == null || !value.isDeleted(), "frame state must not contain deleted nodes");
@@ -555,6 +561,16 @@
         return super.verify();
     }
 
+    private int outerLockDepth() {
+        int depth = 0;
+        FrameState outer = outerFrameState;
+        while (outer != null) {
+            depth += outer.monitorIdCount();
+            outer = outer.outerFrameState;
+        }
+        return depth;
+    }
+
     @Override
     public void applyToNonVirtual(NodeClosure<? super ValueNode> closure) {
         for (ValueNode value : values) {