< prev index next >

src/hotspot/share/opto/macro.cpp

Print this page
@@ -2198,13 +2198,26 @@
    // region inputs are now complete
    transform_later(region);
    _igvn.replace_node(_callprojs.fallthrough_proj, region);
  
    Node *memproj = transform_later(new ProjNode(call, TypeFunc::Memory));
-   mem_phi->init_req(1, memproj );
+ 
+   // held_monitor_count increased in slowpath (complete_monitor_locking_C_inc_held_monitor_count), need compensate a decreament here
+   // this minimizes control flow changes here and add redundant count updates only in slowpath
+   Node* thread = transform_later(new ThreadLocalNode());
+   Node* dec_count = make_load(slow_ctrl, memproj, thread, in_bytes(JavaThread::held_monitor_count_offset()), TypeInt::INT, TypeInt::INT->basic_type());
+   Node* new_dec_count = transform_later(new SubINode(dec_count, intcon(1)));
+   Node *compensate_dec = make_store(slow_ctrl, memproj, thread, in_bytes(JavaThread::held_monitor_count_offset()), new_dec_count, T_INT);
+   mem_phi->init_req(1, compensate_dec);
    transform_later(mem_phi);
-   _igvn.replace_node(_callprojs.fallthrough_memproj, mem_phi);
+ 
+   // held_monitor_count increases in all path's post-dominate
+   Node* inc_count = make_load(region, mem_phi, thread, in_bytes(JavaThread::held_monitor_count_offset()), TypeInt::INT, TypeInt::INT->basic_type());
+   Node* new_inc_count = transform_later(new AddINode(inc_count, intcon(1)));
+   Node *store = make_store(region, mem_phi, thread, in_bytes(JavaThread::held_monitor_count_offset()), new_inc_count, T_INT);
+ 
+   _igvn.replace_node(_callprojs.fallthrough_memproj, store);
  }
  
  //------------------------------expand_unlock_node----------------------
  void PhaseMacroExpand::expand_unlock_node(UnlockNode *unlock) {
  

@@ -2254,11 +2267,16 @@
  
    Node *memproj = transform_later(new ProjNode(call, TypeFunc::Memory) );
    mem_phi->init_req(1, memproj );
    mem_phi->init_req(2, mem);
    transform_later(mem_phi);
-   _igvn.replace_node(_callprojs.fallthrough_memproj, mem_phi);
+ 
+   Node* count = make_load(region, mem_phi, thread, in_bytes(JavaThread::held_monitor_count_offset()), TypeInt::INT, TypeInt::INT->basic_type());
+   Node* newcount = transform_later(new SubINode(count, intcon(1)));
+   Node *store = make_store(region, mem_phi, thread, in_bytes(JavaThread::held_monitor_count_offset()), newcount, T_INT);
+ 
+   _igvn.replace_node(_callprojs.fallthrough_memproj, store);
  }
  
  void PhaseMacroExpand::expand_subtypecheck_node(SubTypeCheckNode *check) {
    assert(check->in(SubTypeCheckNode::Control) == NULL, "should be pinned");
    Node* bol = check->unique_out();
< prev index next >