hotspot/src/share/vm/opto/memnode.cpp
changeset 2532 da0b1680593b
parent 2348 4e71ed4c2709
child 3904 007a45522a7f
equal deleted inserted replaced
2531:c974c3e10bf7 2532:da0b1680593b
   216     return this;
   216     return this;
   217   ctl = in(MemNode::Control);
   217   ctl = in(MemNode::Control);
   218   // Don't bother trying to transform a dead node
   218   // Don't bother trying to transform a dead node
   219   if( ctl && ctl->is_top() )  return NodeSentinel;
   219   if( ctl && ctl->is_top() )  return NodeSentinel;
   220 
   220 
       
   221   PhaseIterGVN *igvn = phase->is_IterGVN();
       
   222   // Wait if control on the worklist.
       
   223   if (ctl && can_reshape && igvn != NULL) {
       
   224     Node* bol = NULL;
       
   225     Node* cmp = NULL;
       
   226     if (ctl->in(0)->is_If()) {
       
   227       assert(ctl->is_IfTrue() || ctl->is_IfFalse(), "sanity");
       
   228       bol = ctl->in(0)->in(1);
       
   229       if (bol->is_Bool())
       
   230         cmp = ctl->in(0)->in(1)->in(1);
       
   231     }
       
   232     if (igvn->_worklist.member(ctl) ||
       
   233         (bol != NULL && igvn->_worklist.member(bol)) ||
       
   234         (cmp != NULL && igvn->_worklist.member(cmp)) ) {
       
   235       // This control path may be dead.
       
   236       // Delay this memory node transformation until the control is processed.
       
   237       phase->is_IterGVN()->_worklist.push(this);
       
   238       return NodeSentinel; // caller will return NULL
       
   239     }
       
   240   }
   221   // Ignore if memory is dead, or self-loop
   241   // Ignore if memory is dead, or self-loop
   222   Node *mem = in(MemNode::Memory);
   242   Node *mem = in(MemNode::Memory);
   223   if( phase->type( mem ) == Type::TOP ) return NodeSentinel; // caller will return NULL
   243   if( phase->type( mem ) == Type::TOP ) return NodeSentinel; // caller will return NULL
   224   assert( mem != this, "dead loop in MemNode::Ideal" );
   244   assert( mem != this, "dead loop in MemNode::Ideal" );
   225 
   245 
   226   Node *address = in(MemNode::Address);
   246   Node *address = in(MemNode::Address);
   227   const Type *t_adr = phase->type( address );
   247   const Type *t_adr = phase->type( address );
   228   if( t_adr == Type::TOP )              return NodeSentinel; // caller will return NULL
   248   if( t_adr == Type::TOP )              return NodeSentinel; // caller will return NULL
   229 
   249 
   230   PhaseIterGVN *igvn = phase->is_IterGVN();
   250   if( can_reshape && igvn != NULL &&
   231   if( can_reshape && igvn != NULL && igvn->_worklist.member(address) ) {
   251       (igvn->_worklist.member(address) || phase->type(address) != adr_type()) ) {
   232     // The address's base and type may change when the address is processed.
   252     // The address's base and type may change when the address is processed.
   233     // Delay this mem node transformation until the address is processed.
   253     // Delay this mem node transformation until the address is processed.
   234     phase->is_IterGVN()->_worklist.push(this);
   254     phase->is_IterGVN()->_worklist.push(this);
   235     return NodeSentinel; // caller will return NULL
   255     return NodeSentinel; // caller will return NULL
   236   }
   256   }
       
   257 
       
   258 #ifdef ASSERT
       
   259   Node* base = NULL;
       
   260   if (address->is_AddP())
       
   261     base = address->in(AddPNode::Base);
       
   262   assert(base == NULL || t_adr->isa_rawptr() ||
       
   263         !phase->type(base)->higher_equal(TypePtr::NULL_PTR), "NULL+offs not RAW address?");
       
   264 #endif
   237 
   265 
   238   // Avoid independent memory operations
   266   // Avoid independent memory operations
   239   Node* old_mem = mem;
   267   Node* old_mem = mem;
   240 
   268 
   241   // The code which unhooks non-raw memories from complete (macro-expanded)
   269   // The code which unhooks non-raw memories from complete (macro-expanded)
  1305       phase->C->get_alias_index(phase->type(address)->is_ptr()) != Compile::AliasIdxRaw ) {
  1333       phase->C->get_alias_index(phase->type(address)->is_ptr()) != Compile::AliasIdxRaw ) {
  1306     ctrl = ctrl->in(0);
  1334     ctrl = ctrl->in(0);
  1307     set_req(MemNode::Control,ctrl);
  1335     set_req(MemNode::Control,ctrl);
  1308   }
  1336   }
  1309 
  1337 
  1310   // Check for useless control edge in some common special cases
  1338   intptr_t ignore = 0;
  1311   if (in(MemNode::Control) != NULL) {
  1339   Node*    base   = AddPNode::Ideal_base_and_offset(address, phase, ignore);
  1312     intptr_t ignore = 0;
  1340   if (base != NULL
  1313     Node*    base   = AddPNode::Ideal_base_and_offset(address, phase, ignore);
  1341       && phase->C->get_alias_index(phase->type(address)->is_ptr()) != Compile::AliasIdxRaw) {
  1314     if (base != NULL
  1342     // Check for useless control edge in some common special cases
       
  1343     if (in(MemNode::Control) != NULL
  1315         && phase->type(base)->higher_equal(TypePtr::NOTNULL)
  1344         && phase->type(base)->higher_equal(TypePtr::NOTNULL)
  1316         && phase->C->get_alias_index(phase->type(address)->is_ptr()) != Compile::AliasIdxRaw
       
  1317         && all_controls_dominate(base, phase->C->start())) {
  1345         && all_controls_dominate(base, phase->C->start())) {
  1318       // A method-invariant, non-null address (constant or 'this' argument).
  1346       // A method-invariant, non-null address (constant or 'this' argument).
  1319       set_req(MemNode::Control, NULL);
  1347       set_req(MemNode::Control, NULL);
  1320     }
  1348     }
  1321   }
  1349 
  1322 
  1350     if (EliminateAutoBox && can_reshape) {
  1323   if (EliminateAutoBox && can_reshape && in(Address)->is_AddP()) {
  1351       assert(!phase->type(base)->higher_equal(TypePtr::NULL_PTR), "the autobox pointer should be non-null");
  1324     Node* base = in(Address)->in(AddPNode::Base);
       
  1325     if (base != NULL) {
       
  1326       Compile::AliasType* atp = phase->C->alias_type(adr_type());
  1352       Compile::AliasType* atp = phase->C->alias_type(adr_type());
  1327       if (is_autobox_object(atp)) {
  1353       if (is_autobox_object(atp)) {
  1328         Node* result = eliminate_autobox(phase);
  1354         Node* result = eliminate_autobox(phase);
  1329         if (result != NULL) return result;
  1355         if (result != NULL) return result;
  1330       }
  1356       }
  1453         if (jt->empty() && !t->empty()) {
  1479         if (jt->empty() && !t->empty()) {
  1454           // This can happen if a interface-typed array narrows to a class type.
  1480           // This can happen if a interface-typed array narrows to a class type.
  1455           jt = _type;
  1481           jt = _type;
  1456         }
  1482         }
  1457 
  1483 
  1458         if (EliminateAutoBox) {
  1484         if (EliminateAutoBox && adr->is_AddP()) {
  1459           // The pointers in the autobox arrays are always non-null
  1485           // The pointers in the autobox arrays are always non-null
  1460           Node* base = in(Address)->in(AddPNode::Base);
  1486           Node* base = adr->in(AddPNode::Base);
  1461           if (base != NULL) {
  1487           if (base != NULL &&
       
  1488               !phase->type(base)->higher_equal(TypePtr::NULL_PTR)) {
  1462             Compile::AliasType* atp = phase->C->alias_type(base->adr_type());
  1489             Compile::AliasType* atp = phase->C->alias_type(base->adr_type());
  1463             if (is_autobox_cache(atp)) {
  1490             if (is_autobox_cache(atp)) {
  1464               return jt->join(TypePtr::NOTNULL)->is_ptr();
  1491               return jt->join(TypePtr::NOTNULL)->is_ptr();
  1465             }
  1492             }
  1466           }
  1493           }