8147853: "assert(t->meet(t0) == t) failed: Not monotonic" with sun/util/calendar/zi/TestZoneInfo310.java
authorroland
Thu, 21 Jan 2016 18:04:14 +0100
changeset 35600 26de15de8faa
parent 35598 8d7bc466f490
child 35601 42c6406c3146
8147853: "assert(t->meet(t0) == t) failed: Not monotonic" with sun/util/calendar/zi/TestZoneInfo310.java Summary: type of counted loop Phi may be saturated before special code to handle counted loops kicks in Reviewed-by: kvn
hotspot/src/share/vm/opto/cfgnode.cpp
--- a/hotspot/src/share/vm/opto/cfgnode.cpp	Mon Jan 25 14:09:28 2016 -1000
+++ b/hotspot/src/share/vm/opto/cfgnode.cpp	Thu Jan 21 18:04:14 2016 +0100
@@ -904,25 +904,34 @@
 
   // Check for trip-counted loop.  If so, be smarter.
   CountedLoopNode* l = r->is_CountedLoop() ? r->as_CountedLoop() : NULL;
-  if (l && l->can_be_counted_loop(phase) &&
-      ((const Node*)l->phi() == this)) { // Trip counted loop!
+  if (l && ((const Node*)l->phi() == this)) { // Trip counted loop!
     // protect against init_trip() or limit() returning NULL
-    const Node *init   = l->init_trip();
-    const Node *limit  = l->limit();
-    const Node* stride = l->stride();
-    if (init != NULL && limit != NULL && stride != NULL) {
-      const TypeInt* lo = phase->type(init)->isa_int();
-      const TypeInt* hi = phase->type(limit)->isa_int();
-      const TypeInt* stride_t = phase->type(stride)->isa_int();
-      if (lo != NULL && hi != NULL && stride_t != NULL) { // Dying loops might have TOP here
-        assert(stride_t->_hi >= stride_t->_lo, "bad stride type");
-        if (stride_t->_hi < 0) {          // Down-counter loop
-          swap(lo, hi);
-          return TypeInt::make(MIN2(lo->_lo, hi->_lo) , hi->_hi, 3);
-        } else if (stride_t->_lo >= 0) {
-          return TypeInt::make(lo->_lo, MAX2(lo->_hi, hi->_hi), 3);
+    if (l->can_be_counted_loop(phase)) {
+      const Node *init   = l->init_trip();
+      const Node *limit  = l->limit();
+      const Node* stride = l->stride();
+      if (init != NULL && limit != NULL && stride != NULL) {
+        const TypeInt* lo = phase->type(init)->isa_int();
+        const TypeInt* hi = phase->type(limit)->isa_int();
+        const TypeInt* stride_t = phase->type(stride)->isa_int();
+        if (lo != NULL && hi != NULL && stride_t != NULL) { // Dying loops might have TOP here
+          assert(stride_t->_hi >= stride_t->_lo, "bad stride type");
+          if (stride_t->_hi < 0) {          // Down-counter loop
+            swap(lo, hi);
+            return TypeInt::make(MIN2(lo->_lo, hi->_lo) , hi->_hi, 3);
+          } else if (stride_t->_lo >= 0) {
+            return TypeInt::make(lo->_lo, MAX2(lo->_hi, hi->_hi), 3);
+          }
         }
       }
+    } else if (l->in(LoopNode::LoopBackControl) != NULL &&
+               in(LoopNode::EntryControl) != NULL &&
+               phase->type(l->in(LoopNode::LoopBackControl)) == Type::TOP) {
+      // During CCP, if we saturate the type of a counted loop's Phi
+      // before the special code for counted loop above has a chance
+      // to run (that is as long as the type of the backedge's control
+      // is top), we might end up with non monotonic types
+      return phase->type(in(LoopNode::EntryControl));
     }
   }