< prev index next >

src/hotspot/share/opto/phaseX.cpp

Print this page

        

@@ -769,10 +769,27 @@
 }
 
 
 
 //=============================================================================
+Node* PhaseGVN::apply_ideal(Node* k, bool can_reshape) {
+  Node* i = BarrierSet::barrier_set()->barrier_set_c2()->ideal_node(this, k, can_reshape);
+  if (i == NULL) {
+    i = k->Ideal(this, can_reshape);
+  }
+  return i;
+}
+
+Node* PhaseGVN::apply_identity(Node* k) {
+  Node* i = BarrierSet::barrier_set()->barrier_set_c2()->identity_node(this, k);
+  if (i == k) {
+    i = k->Identity(this);
+  }
+  return i;
+}
+
+//=============================================================================
 //------------------------------transform--------------------------------------
 // Return a node which computes the same function as this node, but in a
 // faster or cheaper fashion.
 Node *PhaseGVN::transform( Node *n ) {
   return transform_no_reclaim(n);

@@ -786,11 +803,11 @@
 
   // Apply the Ideal call in a loop until it no longer applies
   Node *k = n;
   NOT_PRODUCT( uint loop_count = 0; )
   while( 1 ) {
-    Node *i = k->Ideal(this, /*can_reshape=*/false);
+    Node *i = apply_ideal(k, /*can_reshape=*/false);
     if( !i ) break;
     assert( i->_idx >= k->_idx, "Idealize should return new nodes, use Identity to return old nodes" );
     k = i;
     assert(loop_count++ < K, "infinite loop in PhaseGVN::transform");
   }

@@ -823,11 +840,11 @@
     NOT_PRODUCT( set_progress(); )
     return makecon(t);          // Turn into a constant
   }
 
   // Now check for Identities
-  Node *i = k->Identity(this);  // Look for a nearby replacement
+  Node *i = apply_identity(k);  // Look for a nearby replacement
   if( i != k ) {                // Found? Return replacement!
     NOT_PRODUCT( set_progress(); )
     return i;
   }
 

@@ -1212,11 +1229,11 @@
   // Apply the Ideal call in a loop until it no longer applies
   Node* k = n;
   DEBUG_ONLY(dead_loop_check(k);)
   DEBUG_ONLY(bool is_new = (k->outcnt() == 0);)
   C->remove_modified_node(k);
-  Node* i = k->Ideal(this, /*can_reshape=*/true);
+  Node* i = apply_ideal(k, /*can_reshape=*/true);
   assert(i != k || is_new || i->outcnt() > 0, "don't return dead nodes");
 #ifndef PRODUCT
   verify_step(k);
   if (i && VerifyOpto ) {
     if (!allow_progress()) {

@@ -1254,11 +1271,11 @@
     }
     DEBUG_ONLY(dead_loop_check(k);)
     // Try idealizing again
     DEBUG_ONLY(is_new = (k->outcnt() == 0);)
     C->remove_modified_node(k);
-    i = k->Ideal(this, /*can_reshape=*/true);
+    i = apply_ideal(k, /*can_reshape=*/true);
     assert(i != k || is_new || (i->outcnt() > 0), "don't return dead nodes");
 #ifndef PRODUCT
     verify_step(k);
     if (i && VerifyOpto) {
       set_progress();

@@ -1296,11 +1313,11 @@
     subsume_node(k, con);       // Everybody using k now uses con
     return con;
   }
 
   // Now check for Identities
-  i = k->Identity(this);      // Look for a nearby replacement
+  i = apply_identity(k);      // Look for a nearby replacement
   if (i != k) {                // Found? Return replacement!
     NOT_PRODUCT(set_progress();)
     add_users_to_worklist(k);
     subsume_node(k, i);       // Everybody using k now uses i
     return i;

@@ -1374,11 +1391,11 @@
                   i++;
                 }
                 assert(!(i < imax), "sanity");
               }
             } else {
-              BarrierSet::barrier_set()->barrier_set_c2()->enqueue_useful_gc_barrier(_worklist, in);
+              BarrierSet::barrier_set()->barrier_set_c2()->enqueue_useful_gc_barrier(this, in);
             }
             if (ReduceFieldZeroing && dead->is_Load() && i == MemNode::Memory &&
                 in->is_Proj() && in->in(0) != NULL && in->in(0)->is_Initialize()) {
               // A Load that directly follows an InitializeNode is
               // going away. The Stores that follow are candidates

@@ -1650,10 +1667,17 @@
         if (u->Opcode() == Op_LoadP && ut->isa_instptr()) {
           _worklist.push(u);
         }
       }
     }
+
+    if (use->is_ShenandoahBarrier()) {
+      Node* cmp = use->find_out_with(Op_CmpP);
+      if (cmp != NULL) {
+        _worklist.push(cmp);
+      }
+    }
   }
 }
 
 /**
  * Remove the speculative part of all types that we know of

@@ -1799,10 +1823,29 @@
             if (u->Opcode() == Op_LoadP && ut->isa_instptr() && ut != type(u)) {
               worklist.push(u);
             }
           }
         }
+        if (m->is_ShenandoahBarrier()) {
+          for (DUIterator_Fast i2max, i2 = m->fast_outs(i2max); i2 < i2max; i2++) {
+            Node* p = m->fast_out(i2);
+            if (p->Opcode() == Op_CmpP) {
+              if(p->bottom_type() != type(p)) {
+                worklist.push(p);
+              }
+            } else if (p->Opcode() == Op_AddP) {
+              for (DUIterator_Fast i3max, i3 = p->fast_outs(i3max); i3 < i3max; i3++) {
+                Node* q = p->fast_out(i3);
+                if (q->is_Load()) {
+                  if(q->bottom_type() != type(q)) {
+                    worklist.push(q);
+                  }
+                }
+              }
+            }
+          }
+        }
       }
     }
   }
 }
 

@@ -2059,10 +2102,14 @@
       }
       break;
     default:
       break;
     }
+    if (UseShenandoahGC) {
+      // TODO: Should we call this for ZGC as well?
+      BarrierSet::barrier_set()->barrier_set_c2()->enqueue_useful_gc_barrier(igvn, old);
+    }
   }
 
 }
 
 //-------------------------------replace_by-----------------------------------
< prev index next >