hotspot/src/share/vm/opto/phaseX.cpp
changeset 6752 9a3b09fd5745
parent 5901 c046f8e9c52b
child 7397 5b173b4ca846
--- a/hotspot/src/share/vm/opto/phaseX.cpp	Wed Sep 29 16:53:42 2010 -0700
+++ b/hotspot/src/share/vm/opto/phaseX.cpp	Thu Sep 30 18:31:45 2010 -0700
@@ -844,10 +844,33 @@
   }
 #endif
 
+#ifdef ASSERT
+  Node* prev = NULL;
+  uint rep_cnt = 0;
+#endif
+  uint loop_count = 0;
+
   // Pull from worklist; transform node;
   // If node has changed: update edge info and put uses on worklist.
   while( _worklist.size() ) {
     Node *n  = _worklist.pop();
+    if (++loop_count >= K * C->unique()) {
+      debug_only(n->dump(4);)
+      assert(false, "infinite loop in PhaseIterGVN::optimize");
+      C->record_method_not_compilable("infinite loop in PhaseIterGVN::optimize");
+      return;
+    }
+#ifdef ASSERT
+    if (n == prev) {
+      if (++rep_cnt > 3) {
+        n->dump(4);
+        assert(false, "loop in Ideal transformation");
+      }
+    } else {
+      rep_cnt = 0;
+    }
+    prev = n;
+#endif
     if (TraceIterativeGVN && Verbose) {
       tty->print("  Pop ");
       NOT_PRODUCT( n->dump(); )