< prev index next >

src/hotspot/share/opto/valuetypenode.cpp

Print this page




 817         if (out->is_SafePoint()) {
 818           // Let SafePointNode::Ideal() take care of re-wiring the
 819           // safepoint to the oop input instead of the value type node.
 820           igvn->rehash_node_delayed(out);
 821         }
 822       }
 823     }
 824   }
 825   return NULL;
 826 }
 827 
 828 // Search for multiple allocations of this value type
 829 // and try to replace them by dominating allocations.
 830 void ValueTypeNode::remove_redundant_allocations(PhaseIterGVN* igvn, PhaseIdealLoop* phase) {
 831   assert(EliminateAllocations, "allocation elimination should be enabled");
 832   // Search for allocations of this value type
 833   for (DUIterator_Fast imax, i = fast_outs(imax); i < imax; i++) {
 834     AllocateNode* alloc = fast_out(i)->isa_Allocate();
 835     if (alloc != NULL && alloc->result_cast() != NULL && alloc->in(AllocateNode::ValueNode) == this) {
 836       assert(!is_default(*igvn), "default value type allocation");

 837       Node* res_dom = NULL;
 838       if (is_allocated(igvn)) {
 839         // The value type is already allocated but still connected to an AllocateNode.
 840         // This can happen with late inlining when we first allocate a value type argument
 841         // but later decide to inline the call with the callee code also allocating.
 842         res_dom = get_oop();
 843       } else {
 844         // Search for a dominating allocation of the same value type
 845         for (DUIterator_Fast jmax, j = fast_outs(jmax); j < jmax; j++) {
 846           Node* out2 = fast_out(j);
 847           if (alloc != out2 && out2->is_Allocate() && out2->in(AllocateNode::ValueNode) == this &&
 848               phase->is_dominator(out2, alloc)) {
 849             AllocateNode* alloc_dom =  out2->as_Allocate();
 850             assert(alloc->in(AllocateNode::KlassNode) == alloc_dom->in(AllocateNode::KlassNode), "klasses should match");

 851             res_dom = alloc_dom->result_cast();
 852             break;
 853           }
 854         }
 855       }

 856       if (res_dom != NULL) {
 857         // Move users to dominating allocation
 858         Node* res = alloc->result_cast();
 859         igvn->replace_node(res, res_dom);
 860         // The result of the dominated allocation is now unused and will be
 861         // removed later in AllocateNode::Ideal() to not confuse loop opts.
 862         igvn->record_for_igvn(alloc);
 863 #ifdef ASSERT
 864         if (PrintEliminateAllocations) {
 865           tty->print("++++ Eliminated: %d Allocate ", alloc->_idx);
 866           dump_spec(tty);
 867           tty->cr();
 868         }
 869 #endif
 870       }
 871     }
 872   }
 873 
 874   // Process users
 875   for (DUIterator_Fast imax, i = fast_outs(imax); i < imax; i++) {
 876     Node* out = fast_out(i);
 877     if (out->is_ValueType()) {
 878       // Recursively process value type users




 817         if (out->is_SafePoint()) {
 818           // Let SafePointNode::Ideal() take care of re-wiring the
 819           // safepoint to the oop input instead of the value type node.
 820           igvn->rehash_node_delayed(out);
 821         }
 822       }
 823     }
 824   }
 825   return NULL;
 826 }
 827 
 828 // Search for multiple allocations of this value type
 829 // and try to replace them by dominating allocations.
 830 void ValueTypeNode::remove_redundant_allocations(PhaseIterGVN* igvn, PhaseIdealLoop* phase) {
 831   assert(EliminateAllocations, "allocation elimination should be enabled");
 832   // Search for allocations of this value type
 833   for (DUIterator_Fast imax, i = fast_outs(imax); i < imax; i++) {
 834     AllocateNode* alloc = fast_out(i)->isa_Allocate();
 835     if (alloc != NULL && alloc->result_cast() != NULL && alloc->in(AllocateNode::ValueNode) == this) {
 836       assert(!is_default(*igvn), "default value type allocation");
 837       Node* res = alloc->result_cast();
 838       Node* res_dom = NULL;
 839       if (is_allocated(igvn)) {
 840         // The value type is already allocated but still connected to an AllocateNode.
 841         // This can happen with late inlining when we first allocate a value type argument
 842         // but later decide to inline the call with the callee code also allocating.
 843         res_dom = get_oop();
 844       } else {
 845         // Search for a dominating allocation of the same value type
 846         for (DUIterator_Fast jmax, j = fast_outs(jmax); j < jmax; j++) {
 847           AllocateNode* alloc_dom = fast_out(j)->isa_Allocate();
 848           if (alloc_dom != NULL && alloc != alloc_dom && alloc_dom->result_cast() != NULL &&
 849               alloc_dom->in(AllocateNode::ValueNode) == this) {

 850             assert(alloc->in(AllocateNode::KlassNode) == alloc_dom->in(AllocateNode::KlassNode), "klasses should match");
 851             if (phase->is_dominator(alloc_dom->result_cast()->in(0), res->in(0))) {
 852               res_dom = alloc_dom->result_cast();
 853               break;
 854             }
 855           }
 856         }
 857       }
 858       if (res_dom != NULL) {
 859         // Move users to dominating allocation

 860         igvn->replace_node(res, res_dom);
 861         // The result of the dominated allocation is now unused and will be
 862         // removed later in AllocateNode::Ideal() to not confuse loop opts.
 863         igvn->record_for_igvn(alloc);
 864 #ifdef ASSERT
 865         if (PrintEliminateAllocations) {
 866           tty->print("++++ Eliminated: %d Allocate ", alloc->_idx);
 867           dump_spec(tty);
 868           tty->cr();
 869         }
 870 #endif
 871       }
 872     }
 873   }
 874 
 875   // Process users
 876   for (DUIterator_Fast imax, i = fast_outs(imax); i < imax; i++) {
 877     Node* out = fast_out(i);
 878     if (out->is_ValueType()) {
 879       // Recursively process value type users


< prev index next >