src/share/vm/opto/lcm.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 6746907 Sdiff src/share/vm/opto

src/share/vm/opto/lcm.cpp

Print this page




  41 
  42   // Make sure the ptr-is-null path appears to be uncommon!
  43   float f = end()->as_MachIf()->_prob;
  44   if( proj->Opcode() == Op_IfTrue ) f = 1.0f - f;
  45   if( f > PROB_UNLIKELY_MAG(4) ) return;
  46 
  47   uint bidx = 0;                // Capture index of value into memop
  48   bool was_store;               // Memory op is a store op
  49 
  50   // Get the successor block for if the test ptr is non-null
  51   Block* not_null_block;  // this one goes with the proj
  52   Block* null_block;
  53   if (_nodes[_nodes.size()-1] == proj) {
  54     null_block     = _succs[0];
  55     not_null_block = _succs[1];
  56   } else {
  57     assert(_nodes[_nodes.size()-2] == proj, "proj is one or the other");
  58     not_null_block = _succs[0];
  59     null_block     = _succs[1];
  60   }



  61 
  62   // Search the exception block for an uncommon trap.
  63   // (See Parse::do_if and Parse::do_ifnull for the reason
  64   // we need an uncommon trap.  Briefly, we need a way to
  65   // detect failure of this optimization, as in 6366351.)
  66   {
  67     bool found_trap = false;
  68     for (uint i1 = 0; i1 < null_block->_nodes.size(); i1++) {
  69       Node* nn = null_block->_nodes[i1];
  70       if (nn->is_MachCall() &&
  71           nn->as_MachCall()->entry_point() ==
  72           SharedRuntime::uncommon_trap_blob()->instructions_begin()) {
  73         const Type* trtype = nn->in(TypeFunc::Parms)->bottom_type();
  74         if (trtype->isa_int() && trtype->is_int()->is_con()) {
  75           jint tr_con = trtype->is_int()->get_con();
  76           Deoptimization::DeoptReason reason = Deoptimization::trap_request_reason(tr_con);
  77           Deoptimization::DeoptAction action = Deoptimization::trap_request_action(tr_con);
  78           assert((int)reason < (int)BitsPerInt, "recode bit map");
  79           if (is_set_nth_bit(allowed_reasons, (int) reason)
  80               && action != Deoptimization::Action_none) {


 132       // If the value being nul-checked is in another slot, it means we
 133       // are storing the checked value, which does NOT check the value!
 134       if( mach->in(2) != val ) continue;
 135       break;                    // Found a memory op?
 136     case Op_StrComp:
 137     case Op_AryEq:
 138       // Not a legit memory op for implicit null check regardless of
 139       // embedded loads
 140       continue;
 141     default:                    // Also check for embedded loads
 142       if( !mach->needs_anti_dependence_check() )
 143         continue;               // Not an memory op; skip it
 144       break;
 145     }
 146     // check if the offset is not too high for implicit exception
 147     {
 148       intptr_t offset = 0;
 149       const TypePtr *adr_type = NULL;  // Do not need this return value here
 150       const Node* base = mach->get_base_and_disp(offset, adr_type);
 151       if (base == NULL || base == NodeSentinel) {




 152         // cannot reason about it; is probably not implicit null exception
 153       } else {
 154         const TypePtr* tptr = base->bottom_type()->is_ptr();
 155         // Give up if offset is not a compile-time constant
 156         if( offset == Type::OffsetBot || tptr->_offset == Type::OffsetBot )
 157           continue;
 158         offset += tptr->_offset; // correct if base is offseted
 159         if( MacroAssembler::needs_explicit_null_check(offset) )
 160           continue;             // Give up is reference is beyond 4K page size
 161       }
 162     }
 163 
 164     // Check ctrl input to see if the null-check dominates the memory op
 165     Block *cb = cfg->_bbs[mach->_idx];
 166     cb = cb->_idom;             // Always hoist at least 1 block
 167     if( !was_store ) {          // Stores can be hoisted only one block
 168       while( cb->_dom_depth > (_dom_depth + 1))
 169         cb = cb->_idom;         // Hoist loads as far as we want
 170       // The non-null-block should dominate the memory op, too. Live
 171       // range spilling will insert a spill in the non-null-block if it is




  41 
  42   // Make sure the ptr-is-null path appears to be uncommon!
  43   float f = end()->as_MachIf()->_prob;
  44   if( proj->Opcode() == Op_IfTrue ) f = 1.0f - f;
  45   if( f > PROB_UNLIKELY_MAG(4) ) return;
  46 
  47   uint bidx = 0;                // Capture index of value into memop
  48   bool was_store;               // Memory op is a store op
  49 
  50   // Get the successor block for if the test ptr is non-null
  51   Block* not_null_block;  // this one goes with the proj
  52   Block* null_block;
  53   if (_nodes[_nodes.size()-1] == proj) {
  54     null_block     = _succs[0];
  55     not_null_block = _succs[1];
  56   } else {
  57     assert(_nodes[_nodes.size()-2] == proj, "proj is one or the other");
  58     not_null_block = _succs[0];
  59     null_block     = _succs[1];
  60   }
  61   while (null_block->is_Empty() == Block::empty_with_goto) {
  62     null_block     = null_block->_succs[0];
  63   }
  64 
  65   // Search the exception block for an uncommon trap.
  66   // (See Parse::do_if and Parse::do_ifnull for the reason
  67   // we need an uncommon trap.  Briefly, we need a way to
  68   // detect failure of this optimization, as in 6366351.)
  69   {
  70     bool found_trap = false;
  71     for (uint i1 = 0; i1 < null_block->_nodes.size(); i1++) {
  72       Node* nn = null_block->_nodes[i1];
  73       if (nn->is_MachCall() &&
  74           nn->as_MachCall()->entry_point() ==
  75           SharedRuntime::uncommon_trap_blob()->instructions_begin()) {
  76         const Type* trtype = nn->in(TypeFunc::Parms)->bottom_type();
  77         if (trtype->isa_int() && trtype->is_int()->is_con()) {
  78           jint tr_con = trtype->is_int()->get_con();
  79           Deoptimization::DeoptReason reason = Deoptimization::trap_request_reason(tr_con);
  80           Deoptimization::DeoptAction action = Deoptimization::trap_request_action(tr_con);
  81           assert((int)reason < (int)BitsPerInt, "recode bit map");
  82           if (is_set_nth_bit(allowed_reasons, (int) reason)
  83               && action != Deoptimization::Action_none) {


 135       // If the value being nul-checked is in another slot, it means we
 136       // are storing the checked value, which does NOT check the value!
 137       if( mach->in(2) != val ) continue;
 138       break;                    // Found a memory op?
 139     case Op_StrComp:
 140     case Op_AryEq:
 141       // Not a legit memory op for implicit null check regardless of
 142       // embedded loads
 143       continue;
 144     default:                    // Also check for embedded loads
 145       if( !mach->needs_anti_dependence_check() )
 146         continue;               // Not an memory op; skip it
 147       break;
 148     }
 149     // check if the offset is not too high for implicit exception
 150     {
 151       intptr_t offset = 0;
 152       const TypePtr *adr_type = NULL;  // Do not need this return value here
 153       const Node* base = mach->get_base_and_disp(offset, adr_type);
 154       if (base == NULL || base == NodeSentinel) {
 155         // Narrow oop address doesn't have base, only index
 156         if( val->bottom_type()->isa_narrowoop() &&
 157             MacroAssembler::needs_explicit_null_check(offset) )
 158           continue;             // Give up if offset is beyond page size
 159         // cannot reason about it; is probably not implicit null exception
 160       } else {
 161         const TypePtr* tptr = base->bottom_type()->is_ptr();
 162         // Give up if offset is not a compile-time constant
 163         if( offset == Type::OffsetBot || tptr->_offset == Type::OffsetBot )
 164           continue;
 165         offset += tptr->_offset; // correct if base is offseted
 166         if( MacroAssembler::needs_explicit_null_check(offset) )
 167           continue;             // Give up is reference is beyond 4K page size
 168       }
 169     }
 170 
 171     // Check ctrl input to see if the null-check dominates the memory op
 172     Block *cb = cfg->_bbs[mach->_idx];
 173     cb = cb->_idom;             // Always hoist at least 1 block
 174     if( !was_store ) {          // Stores can be hoisted only one block
 175       while( cb->_dom_depth > (_dom_depth + 1))
 176         cb = cb->_idom;         // Hoist loads as far as we want
 177       // The non-null-block should dominate the memory op, too. Live
 178       // range spilling will insert a spill in the non-null-block if it is


src/share/vm/opto/lcm.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File