src/share/vm/opto/callnode.cpp

changeset 3311
1bd45abaa507
parent 2314
f95d63e2154a
child 3406
e9a5e0a812c8
     1.1 --- a/src/share/vm/opto/callnode.cpp	Wed Nov 16 01:39:50 2011 -0800
     1.2 +++ b/src/share/vm/opto/callnode.cpp	Wed Nov 16 09:13:57 2011 -0800
     1.3 @@ -1071,8 +1071,11 @@
     1.4    init_class_id(Class_SafePointScalarObject);
     1.5  }
     1.6  
     1.7 -bool SafePointScalarObjectNode::pinned() const { return true; }
     1.8 -bool SafePointScalarObjectNode::depends_only_on_test() const { return false; }
     1.9 +// Do not allow value-numbering for SafePointScalarObject node.
    1.10 +uint SafePointScalarObjectNode::hash() const { return NO_HASH; }
    1.11 +uint SafePointScalarObjectNode::cmp( const Node &n ) const {
    1.12 +  return (&n == this); // Always fail except on self
    1.13 +}
    1.14  
    1.15  uint SafePointScalarObjectNode::ideal_reg() const {
    1.16    return 0; // No matching to machine instruction
    1.17 @@ -1096,7 +1099,6 @@
    1.18    if (cached != NULL) {
    1.19      return (SafePointScalarObjectNode*)cached;
    1.20    }
    1.21 -  Compile* C = Compile::current();
    1.22    SafePointScalarObjectNode* res = (SafePointScalarObjectNode*)Node::clone();
    1.23    res->_first_index += jvms_adj;
    1.24    sosn_map->Insert((void*)this, (void*)res);
    1.25 @@ -1142,6 +1144,8 @@
    1.26  
    1.27  Node* AllocateArrayNode::Ideal(PhaseGVN *phase, bool can_reshape) {
    1.28    if (remove_dead_region(phase, can_reshape))  return this;
    1.29 +  // Don't bother trying to transform a dead node
    1.30 +  if (in(0) && in(0)->is_top())  return NULL;
    1.31  
    1.32    const Type* type = phase->type(Ideal_length());
    1.33    if (type->isa_int() && type->is_int()->_hi < 0) {
    1.34 @@ -1522,13 +1526,16 @@
    1.35  
    1.36    // perform any generic optimizations first (returns 'this' or NULL)
    1.37    Node *result = SafePointNode::Ideal(phase, can_reshape);
    1.38 +  if (result != NULL)  return result;
    1.39 +  // Don't bother trying to transform a dead node
    1.40 +  if (in(0) && in(0)->is_top())  return NULL;
    1.41  
    1.42    // Now see if we can optimize away this lock.  We don't actually
    1.43    // remove the locking here, we simply set the _eliminate flag which
    1.44    // prevents macro expansion from expanding the lock.  Since we don't
    1.45    // modify the graph, the value returned from this function is the
    1.46    // one computed above.
    1.47 -  if (result == NULL && can_reshape && EliminateLocks && !is_eliminated()) {
    1.48 +  if (can_reshape && EliminateLocks && (!is_eliminated() || is_coarsened())) {
    1.49      //
    1.50      // If we are locking an unescaped object, the lock/unlock is unnecessary
    1.51      //
    1.52 @@ -1537,8 +1544,16 @@
    1.53      if (cgr != NULL)
    1.54        es = cgr->escape_state(obj_node());
    1.55      if (es != PointsToNode::UnknownEscape && es != PointsToNode::GlobalEscape) {
    1.56 -      // Mark it eliminated to update any counters
    1.57 -      this->set_eliminated();
    1.58 +      if (!is_eliminated()) {
    1.59 +        // Mark it eliminated to update any counters
    1.60 +        this->set_eliminated();
    1.61 +      } else {
    1.62 +        assert(is_coarsened(), "sanity");
    1.63 +        // The lock could be marked eliminated by lock coarsening
    1.64 +        // code during first IGVN before EA. Clear coarsened flag
    1.65 +        // to eliminate all associated locks/unlocks.
    1.66 +        this->clear_coarsened();
    1.67 +      }
    1.68        return result;
    1.69      }
    1.70  
    1.71 @@ -1546,7 +1561,7 @@
    1.72      // Try lock coarsening
    1.73      //
    1.74      PhaseIterGVN* iter = phase->is_IterGVN();
    1.75 -    if (iter != NULL) {
    1.76 +    if (iter != NULL && !is_eliminated()) {
    1.77  
    1.78        GrowableArray<AbstractLockNode*>   lock_ops;
    1.79  
    1.80 @@ -1602,7 +1617,7 @@
    1.81            lock->set_eliminated();
    1.82            lock->set_coarsened();
    1.83          }
    1.84 -      } else if (result != NULL && ctrl->is_Region() &&
    1.85 +      } else if (ctrl->is_Region() &&
    1.86                   iter->_worklist.member(ctrl)) {
    1.87          // We weren't able to find any opportunities but the region this
    1.88          // lock is control dependent on hasn't been processed yet so put
    1.89 @@ -1623,7 +1638,10 @@
    1.90  Node *UnlockNode::Ideal(PhaseGVN *phase, bool can_reshape) {
    1.91  
    1.92    // perform any generic optimizations first (returns 'this' or NULL)
    1.93 -  Node * result = SafePointNode::Ideal(phase, can_reshape);
    1.94 +  Node *result = SafePointNode::Ideal(phase, can_reshape);
    1.95 +  if (result != NULL)  return result;
    1.96 +  // Don't bother trying to transform a dead node
    1.97 +  if (in(0) && in(0)->is_top())  return NULL;
    1.98  
    1.99    // Now see if we can optimize away this unlock.  We don't actually
   1.100    // remove the unlocking here, we simply set the _eliminate flag which
   1.101 @@ -1631,7 +1649,7 @@
   1.102    // modify the graph, the value returned from this function is the
   1.103    // one computed above.
   1.104    // Escape state is defined after Parse phase.
   1.105 -  if (result == NULL && can_reshape && EliminateLocks && !is_eliminated()) {
   1.106 +  if (can_reshape && EliminateLocks && (!is_eliminated() || is_coarsened())) {
   1.107      //
   1.108      // If we are unlocking an unescaped object, the lock/unlock is unnecessary.
   1.109      //
   1.110 @@ -1640,8 +1658,16 @@
   1.111      if (cgr != NULL)
   1.112        es = cgr->escape_state(obj_node());
   1.113      if (es != PointsToNode::UnknownEscape && es != PointsToNode::GlobalEscape) {
   1.114 -      // Mark it eliminated to update any counters
   1.115 -      this->set_eliminated();
   1.116 +      if (!is_eliminated()) {
   1.117 +        // Mark it eliminated to update any counters
   1.118 +        this->set_eliminated();
   1.119 +      } else {
   1.120 +        assert(is_coarsened(), "sanity");
   1.121 +        // The lock could be marked eliminated by lock coarsening
   1.122 +        // code during first IGVN before EA. Clear coarsened flag
   1.123 +        // to eliminate all associated locks/unlocks.
   1.124 +        this->clear_coarsened();
   1.125 +      }
   1.126      }
   1.127    }
   1.128    return result;

mercurial