Merge

Fri, 13 Jan 2012 14:21:14 -0800

author
kvn
date
Fri, 13 Jan 2012 14:21:14 -0800
changeset 3422
e504fd26c073
parent 3418
5acd82522540
parent 3421
89d0a5d40008
child 3423
513351373923

Merge

     1.1 --- a/src/share/vm/opto/callnode.cpp	Fri Jan 13 06:18:47 2012 -0800
     1.2 +++ b/src/share/vm/opto/callnode.cpp	Fri Jan 13 14:21:14 2012 -0800
     1.3 @@ -1625,21 +1625,20 @@
     1.4  
     1.5  //=============================================================================
     1.6  bool LockNode::is_nested_lock_region() {
     1.7 -  Node* box = box_node();
     1.8 -  if (!box->is_BoxLock() || box->as_BoxLock()->stack_slot() <= 0)
     1.9 +  BoxLockNode* box = box_node()->as_BoxLock();
    1.10 +  int stk_slot = box->stack_slot();
    1.11 +  if (stk_slot <= 0)
    1.12      return false; // External lock or it is not Box (Phi node).
    1.13  
    1.14    // Ignore complex cases: merged locks or multiple locks.
    1.15 -  BoxLockNode* box_lock = box->as_BoxLock();
    1.16    Node* obj = obj_node();
    1.17    LockNode* unique_lock = NULL;
    1.18 -  if (!box_lock->is_simple_lock_region(&unique_lock, obj) ||
    1.19 +  if (!box->is_simple_lock_region(&unique_lock, obj) ||
    1.20        (unique_lock != this)) {
    1.21      return false;
    1.22    }
    1.23  
    1.24    // Look for external lock for the same object.
    1.25 -  int stk_slot = box_lock->stack_slot();
    1.26    SafePointNode* sfn = this->as_SafePoint();
    1.27    JVMState* youngest_jvms = sfn->jvms();
    1.28    int max_depth = youngest_jvms->depth();
    1.29 @@ -1649,7 +1648,7 @@
    1.30      // Loop over monitors
    1.31      for (int idx = 0; idx < num_mon; idx++) {
    1.32        Node* obj_node = sfn->monitor_obj(jvms, idx);
    1.33 -      BoxLockNode* box_node = BoxLockNode::box_node(sfn->monitor_box(jvms, idx));
    1.34 +      BoxLockNode* box_node = sfn->monitor_box(jvms, idx)->as_BoxLock();
    1.35        if ((box_node->stack_slot() < stk_slot) && obj_node->eqv_uncast(obj)) {
    1.36          return true;
    1.37        }
     2.1 --- a/src/share/vm/opto/locknode.cpp	Fri Jan 13 06:18:47 2012 -0800
     2.2 +++ b/src/share/vm/opto/locknode.cpp	Fri Jan 13 14:21:14 2012 -0800
     2.3 @@ -63,7 +63,7 @@
     2.4  }
     2.5  
     2.6  BoxLockNode* BoxLockNode::box_node(Node* box) {
     2.7 -  // Chase down the BoxNode
     2.8 +  // Chase down the BoxNode after RA which may spill box nodes.
     2.9    while (!box->is_BoxLock()) {
    2.10      //    if (box_node->is_SpillCopy()) {
    2.11      //      Node *m = box_node->in(1);
    2.12 @@ -84,18 +84,13 @@
    2.13    return box_node(box)->in_RegMask(0).find_first_elem();
    2.14  }
    2.15  
    2.16 -bool BoxLockNode::same_slot(Node* box1, Node* box2) {
    2.17 -  return box_node(box1)->_slot == box_node(box2)->_slot;
    2.18 -}
    2.19 -
    2.20  // Is BoxLock node used for one simple lock region (same box and obj)?
    2.21  bool BoxLockNode::is_simple_lock_region(LockNode** unique_lock, Node* obj) {
    2.22    LockNode* lock = NULL;
    2.23    bool has_one_lock = false;
    2.24    for (uint i = 0; i < this->outcnt(); i++) {
    2.25      Node* n = this->raw_out(i);
    2.26 -    if (n->is_Phi())
    2.27 -      return false; // Merged regions
    2.28 +    assert(!n->is_Phi(), "should not merge BoxLock nodes");
    2.29      if (n->is_AbstractLock()) {
    2.30        AbstractLockNode* alock = n->as_AbstractLock();
    2.31        // Check lock's box since box could be referenced by Lock's debug info.
    2.32 @@ -123,23 +118,12 @@
    2.33        FastLockNode* flock = n->as_FastLock();
    2.34        assert((flock->box_node() == this) && flock->obj_node()->eqv_uncast(obj),"");
    2.35      }
    2.36 -    if (n->is_SafePoint() && n->as_SafePoint()->jvms()) {
    2.37 -      SafePointNode* sfn = n->as_SafePoint();
    2.38 -      JVMState* youngest_jvms = sfn->jvms();
    2.39 -      int max_depth = youngest_jvms->depth();
    2.40 -      for (int depth = 1; depth <= max_depth; depth++) {
    2.41 -        JVMState* jvms = youngest_jvms->of_depth(depth);
    2.42 -        int num_mon  = jvms->nof_monitors();
    2.43 -        // Loop over monitors
    2.44 -        for (int idx = 0; idx < num_mon; idx++) {
    2.45 -          Node* obj_node = sfn->monitor_obj(jvms, idx);
    2.46 -          Node* box_node = sfn->monitor_box(jvms, idx);
    2.47 -          if (box_node == this) {
    2.48 -            assert(obj_node->eqv_uncast(obj),"");
    2.49 -          }
    2.50 -        }
    2.51 -      }
    2.52 -    }
    2.53 +    // Don't check monitor info in safepoints since the referenced object could
    2.54 +    // be different from the locked object. It could be Phi node of different
    2.55 +    // cast nodes which point to this locked object.
    2.56 +    // We assume that no other objects could be referenced in monitor info
    2.57 +    // associated with this BoxLock node because all associated locks and
    2.58 +    // unlocks are reference only this one object.
    2.59    }
    2.60  #endif
    2.61    if (unique_lock != NULL && has_one_lock) {
     3.1 --- a/src/share/vm/opto/locknode.hpp	Fri Jan 13 06:18:47 2012 -0800
     3.2 +++ b/src/share/vm/opto/locknode.hpp	Fri Jan 13 14:21:14 2012 -0800
     3.3 @@ -49,9 +49,9 @@
     3.4  
     3.5  //------------------------------BoxLockNode------------------------------------
     3.6  class BoxLockNode : public Node {
     3.7 -  const int _slot;
     3.8 -  RegMask   _inmask;
     3.9 -  bool _is_eliminated;    // indicates this lock was safely eliminated
    3.10 +  const int     _slot; // stack slot
    3.11 +  RegMask     _inmask; // OptoReg corresponding to stack slot
    3.12 +  bool _is_eliminated; // Associated locks were safely eliminated
    3.13  
    3.14  public:
    3.15    BoxLockNode( int lock );
    3.16 @@ -68,7 +68,9 @@
    3.17  
    3.18    static OptoReg::Name reg(Node* box_node);
    3.19    static BoxLockNode* box_node(Node* box_node);
    3.20 -  static bool same_slot(Node* box1, Node* box2);
    3.21 +  static bool same_slot(Node* box1, Node* box2) {
    3.22 +    return box1->as_BoxLock()->_slot == box2->as_BoxLock()->_slot;
    3.23 +  }
    3.24    int stack_slot() const { return _slot; }
    3.25  
    3.26    bool is_eliminated() const { return _is_eliminated; }
     4.1 --- a/src/share/vm/opto/macro.cpp	Fri Jan 13 06:18:47 2012 -0800
     4.2 +++ b/src/share/vm/opto/macro.cpp	Fri Jan 13 14:21:14 2012 -0800
     4.3 @@ -1802,10 +1802,14 @@
     4.4  // Mark all associated (same box and obj) lock and unlock nodes for
     4.5  // elimination if some of them marked already.
     4.6  void PhaseMacroExpand::mark_eliminated_box(Node* oldbox, Node* obj) {
     4.7 -  if (oldbox->is_BoxLock() && oldbox->as_BoxLock()->is_eliminated())
     4.8 -    return;
     4.9 +  if (oldbox->as_BoxLock()->is_eliminated())
    4.10 +    return; // This BoxLock node was processed already.
    4.11  
    4.12 -  if (oldbox->is_BoxLock() &&
    4.13 +  // New implementation (EliminateNestedLocks) has separate BoxLock
    4.14 +  // node for each locked region so mark all associated locks/unlocks as
    4.15 +  // eliminated even if different objects are referenced in one locked region
    4.16 +  // (for example, OSR compilation of nested loop inside locked scope).
    4.17 +  if (EliminateNestedLocks ||
    4.18        oldbox->as_BoxLock()->is_simple_lock_region(NULL, obj)) {
    4.19      // Box is used only in one lock region. Mark this box as eliminated.
    4.20      _igvn.hash_delete(oldbox);
    4.21 @@ -1818,7 +1822,6 @@
    4.22          AbstractLockNode* alock = u->as_AbstractLock();
    4.23          // Check lock's box since box could be referenced by Lock's debug info.
    4.24          if (alock->box_node() == oldbox) {
    4.25 -          assert(alock->obj_node()->eqv_uncast(obj), "");
    4.26            // Mark eliminated all related locks and unlocks.
    4.27            alock->set_non_esc_obj();
    4.28          }
    4.29 @@ -1829,8 +1832,7 @@
    4.30  
    4.31    // Create new "eliminated" BoxLock node and use it in monitor debug info
    4.32    // instead of oldbox for the same object.
    4.33 -  BoxLockNode* box = BoxLockNode::box_node(oldbox);
    4.34 -  BoxLockNode* newbox = box->clone()->as_BoxLock();
    4.35 +  BoxLockNode* newbox = oldbox->clone()->as_BoxLock();
    4.36  
    4.37    // Note: BoxLock node is marked eliminated only here and it is used
    4.38    // to indicate that all associated lock and unlock nodes are marked
    4.39 @@ -2047,7 +2049,7 @@
    4.40    Node* box = lock->box_node();
    4.41    Node* flock = lock->fastlock_node();
    4.42  
    4.43 -  assert(!BoxLockNode::box_node(box)->is_eliminated(), "sanity");
    4.44 +  assert(!box->as_BoxLock()->is_eliminated(), "sanity");
    4.45  
    4.46    // Make the merge point
    4.47    Node *region;
    4.48 @@ -2283,7 +2285,7 @@
    4.49    Node* obj = unlock->obj_node();
    4.50    Node* box = unlock->box_node();
    4.51  
    4.52 -  assert(!BoxLockNode::box_node(box)->is_eliminated(), "sanity");
    4.53 +  assert(!box->as_BoxLock()->is_eliminated(), "sanity");
    4.54  
    4.55    // No need for a null check on unlock
    4.56  
     5.1 --- a/src/share/vm/opto/parse1.cpp	Fri Jan 13 06:18:47 2012 -0800
     5.2 +++ b/src/share/vm/opto/parse1.cpp	Fri Jan 13 14:21:14 2012 -0800
     5.3 @@ -1604,7 +1604,16 @@
     5.4            continue;
     5.5          default:                // All normal stuff
     5.6            if (phi == NULL) {
     5.7 -            if (!check_elide_phi || !target->can_elide_SEL_phi(j)) {
     5.8 +            const JVMState* jvms = map()->jvms();
     5.9 +            if (EliminateNestedLocks &&
    5.10 +                jvms->is_mon(j) && jvms->is_monitor_box(j)) {
    5.11 +              // BoxLock nodes are not commoning.
    5.12 +              // Use old BoxLock node as merged box.
    5.13 +              assert(newin->jvms()->is_monitor_box(j), "sanity");
    5.14 +              // This assert also tests that nodes are BoxLock.
    5.15 +              assert(BoxLockNode::same_slot(n, m), "sanity");
    5.16 +              C->gvn_replace_by(n, m);
    5.17 +            } else if (!check_elide_phi || !target->can_elide_SEL_phi(j)) {
    5.18                phi = ensure_phi(j, nophi);
    5.19              }
    5.20            }
    5.21 @@ -1819,12 +1828,8 @@
    5.22    } else if (jvms->is_stk(idx)) {
    5.23      t = block()->stack_type_at(idx - jvms->stkoff());
    5.24    } else if (jvms->is_mon(idx)) {
    5.25 -    if (EliminateNestedLocks && jvms->is_monitor_box(idx)) {
    5.26 -      // BoxLock nodes are not commoning. Create Phi.
    5.27 -      t = o->bottom_type(); // TypeRawPtr::BOTTOM
    5.28 -    } else {
    5.29 -      t = TypeInstPtr::BOTTOM; // this is sufficient for a lock object
    5.30 -    }
    5.31 +    assert(!jvms->is_monitor_box(idx), "no phis for boxes");
    5.32 +    t = TypeInstPtr::BOTTOM; // this is sufficient for a lock object
    5.33    } else if ((uint)idx < TypeFunc::Parms) {
    5.34      t = o->bottom_type();  // Type::RETURN_ADDRESS or such-like.
    5.35    } else {

mercurial