changeset 19966:8964b0b777b7

Reduce amount of work done by Node.verify by default
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Thu, 19 Mar 2015 17:48:48 -0700
parents 9bd252b8e3ad
children a5ee3e32dc62
files graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java
diffstat 2 files changed, 18 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java	Thu Mar 19 17:25:16 2015 -0700
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java	Thu Mar 19 17:48:48 2015 -0700
@@ -37,9 +37,11 @@
  */
 public class Graph {
 
-    static class Options {
+    public static class Options {
         @Option(help = "Verify graphs often during compilation when assertions are turned on", type = OptionType.Debug)//
         public static final OptionValue<Boolean> VerifyGraalGraphs = new OptionValue<>(true);
+        @Option(help = "Perform expensive verification of graph inputs, usages, successors and predecessors", type = OptionType.Debug)//
+        public static final OptionValue<Boolean> VerifyGraalGraphEdges = new OptionValue<>(false);
     }
 
     public final String name;
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java	Thu Mar 19 17:25:16 2015 -0700
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java	Thu Mar 19 17:48:48 2015 -0700
@@ -851,7 +851,6 @@
         for (Node input : inputs()) {
             assertFalse(input.isDeleted(), "input was deleted");
             assertTrue(input.isAlive(), "input is not alive yet, i.e., it was not yet added to the graph");
-            assertTrue(input.usages().contains(this), "missing usage in input %s", input);
         }
         return true;
     }
@@ -859,7 +858,22 @@
     public boolean verify() {
         assertTrue(isAlive(), "cannot verify inactive nodes (id=%d)", id);
         assertTrue(graph() != null, "null graph");
+        if (Options.VerifyGraalGraphEdges.getValue()) {
+            verifyEdges();
+        }
+        return true;
+    }
+
+    /**
+     * Perform expensive verification of inputs, usages, predecessors and successors.
+     *
+     * @return true
+     */
+    public boolean verifyEdges() {
         verifyInputs();
+        for (Node input : inputs()) {
+            assertTrue(input.usages().contains(this), "missing usage in input %s", input);
+        }
         for (Node successor : successors()) {
             assertTrue(successor.predecessor() == this, "missing predecessor in %s (actual: %s)", successor, successor.predecessor());
             assertTrue(successor.graph() == graph(), "mismatching graph in successor %s", successor);