8230091: Add verification of clean_catch_blocks
authorneliasso
Mon, 26 Aug 2019 11:36:45 +0200
changeset 57904 4f38fcd65577
parent 57903 5e2576c303a2
child 57905 55723932d06e
8230091: Add verification of clean_catch_blocks Reviewed-by: rbackman, kvn
src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp
src/hotspot/share/gc/z/c2/zBarrierSetC2.hpp
--- a/src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp	Wed Aug 28 11:19:09 2019 +0200
+++ b/src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp	Mon Aug 26 11:36:45 2019 +0200
@@ -1217,7 +1217,7 @@
 }
 
 // Sort out the loads that are between a call ant its catch blocks
-static void process_catch_cleanup_candidate(PhaseIdealLoop* phase, LoadNode* load) {
+static void process_catch_cleanup_candidate(PhaseIdealLoop* phase, LoadNode* load, bool verify) {
   bool trace = phase->C->directive()->ZTraceLoadBarriersOption;
 
   Node* ctrl = get_ctrl_normalized(phase, load);
@@ -1228,6 +1228,7 @@
   Node* catch_node = ctrl->isa_Proj()->raw_out(0);
   if (catch_node->is_Catch()) {
     if (catch_node->outcnt() > 1) {
+      assert(!verify, "All loads should already have been moved");
       call_catch_cleanup_one(phase, load, ctrl);
     } else {
       if (trace) tty->print_cr("Call catch cleanup with only one catch: load %i ", load->_idx);
@@ -1245,6 +1246,7 @@
   if (mode == LoopOptsZBarrierInsertion) {
     // First make sure all loads between call and catch are moved to the catch block
     clean_catch_blocks(phase);
+    DEBUG_ONLY(clean_catch_blocks(phase, true /* verify */);)
 
     // Then expand barriers on all loads
     insert_load_barriers(phase);
@@ -1398,7 +1400,7 @@
 // Sometimes the loads use will be at a place dominated by all catch blocks, then we need
 // a load in each catch block, and a Phi at the dominated use.
 
-void ZBarrierSetC2::clean_catch_blocks(PhaseIdealLoop* phase) const {
+void ZBarrierSetC2::clean_catch_blocks(PhaseIdealLoop* phase, bool verify) const {
 
   Compile *C = phase->C;
   uint new_ids = C->unique();
@@ -1425,7 +1427,7 @@
       LoadNode* load = n->isa_Load();
       // only care about loads that will have a barrier
       if (load_require_barrier(load)) {
-        process_catch_cleanup_candidate(phase, load);
+        process_catch_cleanup_candidate(phase, load, verify);
       }
     }
   }
--- a/src/hotspot/share/gc/z/c2/zBarrierSetC2.hpp	Wed Aug 28 11:19:09 2019 +0200
+++ b/src/hotspot/share/gc/z/c2/zBarrierSetC2.hpp	Mon Aug 26 11:36:45 2019 +0200
@@ -207,7 +207,7 @@
 private:
   // Load barrier insertion and expansion internal
   void insert_barriers_on_unsafe(PhaseIdealLoop* phase) const;
-  void clean_catch_blocks(PhaseIdealLoop* phase) const;
+  void clean_catch_blocks(PhaseIdealLoop* phase, bool verify = false) const;
   void insert_load_barriers(PhaseIdealLoop* phase) const;
   LoadNode* insert_one_loadbarrier(PhaseIdealLoop* phase, LoadNode* load, Node* ctrl) const;
   void insert_one_loadbarrier_inner(PhaseIdealLoop* phase, LoadNode* load, Node* ctrl, VectorSet visited) const;