changeset 53156:7c68a23014db

8217042: Shenandoah: write barrier on backedge of strip mined loop causes c2 crash at expansion time Reviewed-by: rkennke, thartmann
author roland
date Fri, 11 Jan 2019 14:27:22 +0100
parents dbbe6654948d
children c52a37f40324
files src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp
diffstat 1 files changed, 27 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp	Mon Jan 14 13:53:42 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp	Fri Jan 11 14:27:22 2019 +0100
@@ -2659,9 +2659,35 @@
     wb->pin_and_expand_helper(phase);
   }
 
+  for (uint i = 0; i < enqueue_barriers.size(); i++) {
+    Node* barrier = enqueue_barriers.at(i);
+    Node* ctrl = phase->get_ctrl(barrier);
+    IdealLoopTree* loop = phase->get_loop(ctrl);
+    if (loop->_head->is_OuterStripMinedLoop()) {
+      // Expanding a barrier here will break loop strip mining
+      // verification. Transform the loop so the loop nest doesn't
+      // appear as strip mined.
+      OuterStripMinedLoopNode* outer = loop->_head->as_OuterStripMinedLoop();
+      hide_strip_mined_loop(outer, outer->unique_ctrl_out()->as_CountedLoop(), phase);
+    }
+  }
+
+  for (int i = ShenandoahBarrierSetC2::bsc2()->state()->shenandoah_barriers_count(); i > 0; i--) {
+    int cnt = ShenandoahBarrierSetC2::bsc2()->state()->shenandoah_barriers_count();
+    ShenandoahWriteBarrierNode* wb = ShenandoahBarrierSetC2::bsc2()->state()->shenandoah_barrier(i-1);
+    Node* ctrl = phase->get_ctrl(wb);
+    IdealLoopTree* loop = phase->get_loop(ctrl);
+    if (loop->_head->is_OuterStripMinedLoop()) {
+      // Expanding a barrier here will break loop strip mining
+      // verification. Transform the loop so the loop nest doesn't
+      // appear as strip mined.
+      OuterStripMinedLoopNode* outer = loop->_head->as_OuterStripMinedLoop();
+      hide_strip_mined_loop(outer, outer->unique_ctrl_out()->as_CountedLoop(), phase);
+    }
+  }
+
   MemoryGraphFixer fixer(Compile::AliasIdxRaw, true, phase);
   Unique_Node_List uses_to_ignore;
-  Unique_Node_List outer_lsms;
   for (uint i = 0; i < enqueue_barriers.size(); i++) {
     Node* barrier = enqueue_barriers.at(i);
     Node* pre_val = barrier->in(1);
@@ -2685,9 +2711,6 @@
 
     Node* init_ctrl = ctrl;
     IdealLoopTree* loop = phase->get_loop(ctrl);
-    if (loop->_head->is_OuterStripMinedLoop()) {
-      outer_lsms.push(loop->_head);
-    }
     Node* raw_mem = fixer.find_mem(ctrl, barrier);
     Node* init_raw_mem = raw_mem;
     Node* raw_mem_for_ctrl = fixer.find_mem(ctrl, NULL);
@@ -2832,9 +2855,6 @@
     Node* val = wb->in(ValueIn);
     Node* wbproj = wb->find_out_with(Op_ShenandoahWBMemProj);
     IdealLoopTree *loop = phase->get_loop(ctrl);
-    if (loop->_head->is_OuterStripMinedLoop()) {
-      outer_lsms.push(loop->_head);
-    }
 
     assert(val->Opcode() != Op_ShenandoahWriteBarrier, "No chain of write barriers");
 
@@ -3019,14 +3039,6 @@
   }
 
   assert(ShenandoahBarrierSetC2::bsc2()->state()->shenandoah_barriers_count() == 0, "all write barrier nodes should have been replaced");
-
-  for (uint i = 0; i < outer_lsms.size(); i++) {
-    // Expanding a barrier here will break loop strip mining
-    // verification. Transform the loop so the loop nest doesn't
-    // appear as strip mined.
-    OuterStripMinedLoopNode* outer = outer_lsms.at(i)->as_OuterStripMinedLoop();
-    hide_strip_mined_loop(outer, outer->unique_ctrl_out()->as_CountedLoop(), phase);
-  }
 }
 
 void ShenandoahWriteBarrierNode::move_heap_stable_test_out_of_loop(IfNode* iff, PhaseIdealLoop* phase) {
@@ -4274,5 +4286,3 @@
     _memory_nodes.map(c->_idx, mem->in(ShenandoahWBMemProjNode::WriteBarrier)->in(ShenandoahBarrierNode::Memory));
   }
 }
-
-