1.1 --- a/src/share/vm/opto/memnode.cpp Tue Apr 07 10:05:04 2009 -0700 1.2 +++ b/src/share/vm/opto/memnode.cpp Tue Apr 07 19:04:24 2009 -0700 1.3 @@ -218,6 +218,26 @@ 1.4 // Don't bother trying to transform a dead node 1.5 if( ctl && ctl->is_top() ) return NodeSentinel; 1.6 1.7 + PhaseIterGVN *igvn = phase->is_IterGVN(); 1.8 + // Wait if control on the worklist. 1.9 + if (ctl && can_reshape && igvn != NULL) { 1.10 + Node* bol = NULL; 1.11 + Node* cmp = NULL; 1.12 + if (ctl->in(0)->is_If()) { 1.13 + assert(ctl->is_IfTrue() || ctl->is_IfFalse(), "sanity"); 1.14 + bol = ctl->in(0)->in(1); 1.15 + if (bol->is_Bool()) 1.16 + cmp = ctl->in(0)->in(1)->in(1); 1.17 + } 1.18 + if (igvn->_worklist.member(ctl) || 1.19 + (bol != NULL && igvn->_worklist.member(bol)) || 1.20 + (cmp != NULL && igvn->_worklist.member(cmp)) ) { 1.21 + // This control path may be dead. 1.22 + // Delay this memory node transformation until the control is processed. 1.23 + phase->is_IterGVN()->_worklist.push(this); 1.24 + return NodeSentinel; // caller will return NULL 1.25 + } 1.26 + } 1.27 // Ignore if memory is dead, or self-loop 1.28 Node *mem = in(MemNode::Memory); 1.29 if( phase->type( mem ) == Type::TOP ) return NodeSentinel; // caller will return NULL 1.30 @@ -227,14 +247,22 @@ 1.31 const Type *t_adr = phase->type( address ); 1.32 if( t_adr == Type::TOP ) return NodeSentinel; // caller will return NULL 1.33 1.34 - PhaseIterGVN *igvn = phase->is_IterGVN(); 1.35 - if( can_reshape && igvn != NULL && igvn->_worklist.member(address) ) { 1.36 + if( can_reshape && igvn != NULL && 1.37 + (igvn->_worklist.member(address) || phase->type(address) != adr_type()) ) { 1.38 // The address's base and type may change when the address is processed. 1.39 // Delay this mem node transformation until the address is processed. 1.40 phase->is_IterGVN()->_worklist.push(this); 1.41 return NodeSentinel; // caller will return NULL 1.42 } 1.43 1.44 +#ifdef ASSERT 1.45 + Node* base = NULL; 1.46 + if (address->is_AddP()) 1.47 + base = address->in(AddPNode::Base); 1.48 + assert(base == NULL || t_adr->isa_rawptr() || 1.49 + !phase->type(base)->higher_equal(TypePtr::NULL_PTR), "NULL+offs not RAW address?"); 1.50 +#endif 1.51 + 1.52 // Avoid independent memory operations 1.53 Node* old_mem = mem; 1.54 1.55 @@ -1307,22 +1335,20 @@ 1.56 set_req(MemNode::Control,ctrl); 1.57 } 1.58 1.59 - // Check for useless control edge in some common special cases 1.60 - if (in(MemNode::Control) != NULL) { 1.61 - intptr_t ignore = 0; 1.62 - Node* base = AddPNode::Ideal_base_and_offset(address, phase, ignore); 1.63 - if (base != NULL 1.64 + intptr_t ignore = 0; 1.65 + Node* base = AddPNode::Ideal_base_and_offset(address, phase, ignore); 1.66 + if (base != NULL 1.67 + && phase->C->get_alias_index(phase->type(address)->is_ptr()) != Compile::AliasIdxRaw) { 1.68 + // Check for useless control edge in some common special cases 1.69 + if (in(MemNode::Control) != NULL 1.70 && phase->type(base)->higher_equal(TypePtr::NOTNULL) 1.71 - && phase->C->get_alias_index(phase->type(address)->is_ptr()) != Compile::AliasIdxRaw 1.72 && all_controls_dominate(base, phase->C->start())) { 1.73 // A method-invariant, non-null address (constant or 'this' argument). 1.74 set_req(MemNode::Control, NULL); 1.75 } 1.76 - } 1.77 - 1.78 - if (EliminateAutoBox && can_reshape && in(Address)->is_AddP()) { 1.79 - Node* base = in(Address)->in(AddPNode::Base); 1.80 - if (base != NULL) { 1.81 + 1.82 + if (EliminateAutoBox && can_reshape) { 1.83 + assert(!phase->type(base)->higher_equal(TypePtr::NULL_PTR), "the autobox pointer should be non-null"); 1.84 Compile::AliasType* atp = phase->C->alias_type(adr_type()); 1.85 if (is_autobox_object(atp)) { 1.86 Node* result = eliminate_autobox(phase); 1.87 @@ -1455,10 +1481,11 @@ 1.88 jt = _type; 1.89 } 1.90 1.91 - if (EliminateAutoBox) { 1.92 + if (EliminateAutoBox && adr->is_AddP()) { 1.93 // The pointers in the autobox arrays are always non-null 1.94 - Node* base = in(Address)->in(AddPNode::Base); 1.95 - if (base != NULL) { 1.96 + Node* base = adr->in(AddPNode::Base); 1.97 + if (base != NULL && 1.98 + !phase->type(base)->higher_equal(TypePtr::NULL_PTR)) { 1.99 Compile::AliasType* atp = phase->C->alias_type(base->adr_type()); 1.100 if (is_autobox_cache(atp)) { 1.101 return jt->join(TypePtr::NOTNULL)->is_ptr();