< prev index next >

src/hotspot/share/opto/macro.cpp

Print this page




 706                  use->in(ArrayCopyNode::Dest) == res) {
 707         // ok to eliminate
 708       } else if (use->is_SafePoint()) {
 709         SafePointNode* sfpt = use->as_SafePoint();
 710         if (sfpt->is_Call() && sfpt->as_Call()->has_non_debug_use(res)) {
 711           // Object is passed as argument.
 712           DEBUG_ONLY(disq_node = use;)
 713           NOT_PRODUCT(fail_eliminate = "Object is passed as argument";)
 714           can_eliminate = false;
 715         }
 716         Node* sfptMem = sfpt->memory();
 717         if (sfptMem == NULL || sfptMem->is_top()) {
 718           DEBUG_ONLY(disq_node = use;)
 719           NOT_PRODUCT(fail_eliminate = "NULL or TOP memory";)
 720           can_eliminate = false;
 721         } else {
 722           safepoints.append_if_missing(sfpt);
 723         }
 724       } else if (use->is_ValueType() && use->isa_ValueType()->get_oop() == res) {
 725         // ok to eliminate


 726       } else if (use->Opcode() != Op_CastP2X) { // CastP2X is used by card mark
 727         if (use->is_Phi()) {
 728           if (use->outcnt() == 1 && use->unique_out()->Opcode() == Op_Return) {
 729             NOT_PRODUCT(fail_eliminate = "Object is return value";)
 730           } else {
 731             NOT_PRODUCT(fail_eliminate = "Object is referenced by Phi";)
 732           }
 733           DEBUG_ONLY(disq_node = use;)
 734         } else {
 735           if (use->Opcode() == Op_Return) {
 736             NOT_PRODUCT(fail_eliminate = "Object is return value";)
 737           } else {
 738             NOT_PRODUCT(fail_eliminate = "Object is referenced by node";)
 739           }
 740           DEBUG_ONLY(disq_node = use;)
 741         }
 742         can_eliminate = false;
 743       } else {
 744         assert(use->Opcode() == Op_CastP2X, "should be");
 745         assert(!use->has_out_with(Op_OrL), "should have been removed because oop is never null");


1045 
1046         // Set control to top. IGVN will remove the remaining projections
1047         ac->set_req(0, top());
1048         ac->replace_edge(res, top());
1049 
1050         // Disconnect src right away: it can help find new
1051         // opportunities for allocation elimination
1052         Node* src = ac->in(ArrayCopyNode::Src);
1053         ac->replace_edge(src, top());
1054         // src can be top at this point if src and dest of the
1055         // arraycopy were the same
1056         if (src->outcnt() == 0 && !src->is_top()) {
1057           _igvn.remove_dead_node(src);
1058         }
1059 
1060         _igvn._worklist.push(ac);
1061       } else if (use->is_ValueType()) {
1062         assert(use->isa_ValueType()->get_oop() == res, "unexpected value type use");
1063          _igvn.rehash_node_delayed(use);
1064         use->isa_ValueType()->set_oop(_igvn.zerocon(T_VALUETYPE));


1065       } else {
1066         eliminate_gc_barrier(use);
1067       }
1068       j -= (oc1 - res->outcnt());
1069     }
1070     assert(res->outcnt() == 0, "all uses of allocated objects must be deleted");
1071     _igvn.remove_dead_node(res);
1072   }
1073 
1074   //
1075   // Process other users of allocation's projections
1076   //
1077   if (_resproj != NULL && _resproj->outcnt() != 0) {
1078     // First disconnect stores captured by Initialize node.
1079     // If Initialize node is eliminated first in the following code,
1080     // it will kill such stores and DUIterator_Last will assert.
1081     for (DUIterator_Fast jmax, j = _resproj->fast_outs(jmax);  j < jmax; j++) {
1082       Node *use = _resproj->fast_out(j);
1083       if (use->is_AddP()) {
1084         // raw memory addresses used only by the initialization


1687   // Plug slow-path into result merge point
1688   result_region    ->init_req( slow_result_path, ctrl );
1689   result_phi_rawoop->init_req( slow_result_path, slow_result);
1690   result_phi_rawmem->init_req( slow_result_path, _memproj_fallthrough );
1691   transform_later(result_region);
1692   transform_later(result_phi_rawoop);
1693   transform_later(result_phi_rawmem);
1694   transform_later(result_phi_i_o);
1695   // This completes all paths into the result merge point
1696 }
1697 
1698 
1699 // Helper for PhaseMacroExpand::expand_allocate_common.
1700 // Initializes the newly-allocated storage.
1701 Node* PhaseMacroExpand::initialize_object(AllocateNode* alloc,
1702                                           Node* control, Node* rawmem, Node* object,
1703                                           Node* klass_node, Node* length,
1704                                           Node* size_in_bytes) {
1705   InitializeNode* init = alloc->initialization();
1706   // Store the klass & mark bits
1707   Node* mark_node = NULL;
1708   // For now only enable fast locking for non-array types
1709   if ((EnableValhalla || UseBiasedLocking) && length == NULL) {
1710     mark_node = make_load(control, rawmem, klass_node, in_bytes(Klass::prototype_header_offset()), TypeRawPtr::BOTTOM, T_ADDRESS);
1711   } else {
1712     mark_node = makecon(TypeRawPtr::make((address)markOopDesc::prototype()));
1713   }
1714   rawmem = make_store(control, rawmem, object, oopDesc::mark_offset_in_bytes(), mark_node, T_ADDRESS);
1715 
1716   rawmem = make_store(control, rawmem, object, oopDesc::klass_offset_in_bytes(), klass_node, T_METADATA);
1717   int header_size = alloc->minimum_header_size();  // conservatively small
1718 
1719   // Array length
1720   if (length != NULL) {         // Arrays need length field
1721     rawmem = make_store(control, rawmem, object, arrayOopDesc::length_offset_in_bytes(), length, T_INT);
1722     // conservatively small header size:
1723     header_size = arrayOopDesc::base_offset_in_bytes(T_BYTE);
1724     ciKlass* k = _igvn.type(klass_node)->is_klassptr()->klass();
1725     if (k->is_array_klass())    // we know the exact header size in most cases:
1726       header_size = Klass::layout_helper_header_size(k->layout_helper());
1727   }
1728 
1729   // Clear the object body, if necessary.
1730   if (init == NULL) {
1731     // The init has somehow disappeared; be cautious and clear everything.
1732     //
1733     // This can happen if a node is allocated but an uncommon trap occurs
1734     // immediately.  In this case, the Initialize gets associated with the




 706                  use->in(ArrayCopyNode::Dest) == res) {
 707         // ok to eliminate
 708       } else if (use->is_SafePoint()) {
 709         SafePointNode* sfpt = use->as_SafePoint();
 710         if (sfpt->is_Call() && sfpt->as_Call()->has_non_debug_use(res)) {
 711           // Object is passed as argument.
 712           DEBUG_ONLY(disq_node = use;)
 713           NOT_PRODUCT(fail_eliminate = "Object is passed as argument";)
 714           can_eliminate = false;
 715         }
 716         Node* sfptMem = sfpt->memory();
 717         if (sfptMem == NULL || sfptMem->is_top()) {
 718           DEBUG_ONLY(disq_node = use;)
 719           NOT_PRODUCT(fail_eliminate = "NULL or TOP memory";)
 720           can_eliminate = false;
 721         } else {
 722           safepoints.append_if_missing(sfpt);
 723         }
 724       } else if (use->is_ValueType() && use->isa_ValueType()->get_oop() == res) {
 725         // ok to eliminate
 726       } else if (use->is_Store()) {
 727         // store to mark work
 728       } else if (use->Opcode() != Op_CastP2X) { // CastP2X is used by card mark
 729         if (use->is_Phi()) {
 730           if (use->outcnt() == 1 && use->unique_out()->Opcode() == Op_Return) {
 731             NOT_PRODUCT(fail_eliminate = "Object is return value";)
 732           } else {
 733             NOT_PRODUCT(fail_eliminate = "Object is referenced by Phi";)
 734           }
 735           DEBUG_ONLY(disq_node = use;)
 736         } else {
 737           if (use->Opcode() == Op_Return) {
 738             NOT_PRODUCT(fail_eliminate = "Object is return value";)
 739           } else {
 740             NOT_PRODUCT(fail_eliminate = "Object is referenced by node";)
 741           }
 742           DEBUG_ONLY(disq_node = use;)
 743         }
 744         can_eliminate = false;
 745       } else {
 746         assert(use->Opcode() == Op_CastP2X, "should be");
 747         assert(!use->has_out_with(Op_OrL), "should have been removed because oop is never null");


1047 
1048         // Set control to top. IGVN will remove the remaining projections
1049         ac->set_req(0, top());
1050         ac->replace_edge(res, top());
1051 
1052         // Disconnect src right away: it can help find new
1053         // opportunities for allocation elimination
1054         Node* src = ac->in(ArrayCopyNode::Src);
1055         ac->replace_edge(src, top());
1056         // src can be top at this point if src and dest of the
1057         // arraycopy were the same
1058         if (src->outcnt() == 0 && !src->is_top()) {
1059           _igvn.remove_dead_node(src);
1060         }
1061 
1062         _igvn._worklist.push(ac);
1063       } else if (use->is_ValueType()) {
1064         assert(use->isa_ValueType()->get_oop() == res, "unexpected value type use");
1065          _igvn.rehash_node_delayed(use);
1066         use->isa_ValueType()->set_oop(_igvn.zerocon(T_VALUETYPE));
1067       } else if (use->is_Store()) {
1068         _igvn.replace_node(use, use->in(MemNode::Memory));
1069       } else {
1070         eliminate_gc_barrier(use);
1071       }
1072       j -= (oc1 - res->outcnt());
1073     }
1074     assert(res->outcnt() == 0, "all uses of allocated objects must be deleted");
1075     _igvn.remove_dead_node(res);
1076   }
1077 
1078   //
1079   // Process other users of allocation's projections
1080   //
1081   if (_resproj != NULL && _resproj->outcnt() != 0) {
1082     // First disconnect stores captured by Initialize node.
1083     // If Initialize node is eliminated first in the following code,
1084     // it will kill such stores and DUIterator_Last will assert.
1085     for (DUIterator_Fast jmax, j = _resproj->fast_outs(jmax);  j < jmax; j++) {
1086       Node *use = _resproj->fast_out(j);
1087       if (use->is_AddP()) {
1088         // raw memory addresses used only by the initialization


1691   // Plug slow-path into result merge point
1692   result_region    ->init_req( slow_result_path, ctrl );
1693   result_phi_rawoop->init_req( slow_result_path, slow_result);
1694   result_phi_rawmem->init_req( slow_result_path, _memproj_fallthrough );
1695   transform_later(result_region);
1696   transform_later(result_phi_rawoop);
1697   transform_later(result_phi_rawmem);
1698   transform_later(result_phi_i_o);
1699   // This completes all paths into the result merge point
1700 }
1701 
1702 
1703 // Helper for PhaseMacroExpand::expand_allocate_common.
1704 // Initializes the newly-allocated storage.
1705 Node* PhaseMacroExpand::initialize_object(AllocateNode* alloc,
1706                                           Node* control, Node* rawmem, Node* object,
1707                                           Node* klass_node, Node* length,
1708                                           Node* size_in_bytes) {
1709   InitializeNode* init = alloc->initialization();
1710   // Store the klass & mark bits
1711   Node* mark_node = alloc->make_ideal_mark(&_igvn, object, control, rawmem, klass_node);
1712   if (!mark_node->is_Con()) {
1713     transform_later(mark_node);



1714   }
1715   rawmem = make_store(control, rawmem, object, oopDesc::mark_offset_in_bytes(), mark_node, TypeX_X->basic_type());
1716 
1717   rawmem = make_store(control, rawmem, object, oopDesc::klass_offset_in_bytes(), klass_node, T_METADATA);
1718   int header_size = alloc->minimum_header_size();  // conservatively small
1719 
1720   // Array length
1721   if (length != NULL) {         // Arrays need length field
1722     rawmem = make_store(control, rawmem, object, arrayOopDesc::length_offset_in_bytes(), length, T_INT);
1723     // conservatively small header size:
1724     header_size = arrayOopDesc::base_offset_in_bytes(T_BYTE);
1725     ciKlass* k = _igvn.type(klass_node)->is_klassptr()->klass();
1726     if (k->is_array_klass())    // we know the exact header size in most cases:
1727       header_size = Klass::layout_helper_header_size(k->layout_helper());
1728   }
1729 
1730   // Clear the object body, if necessary.
1731   if (init == NULL) {
1732     // The init has somehow disappeared; be cautious and clear everything.
1733     //
1734     // This can happen if a node is allocated but an uncommon trap occurs
1735     // immediately.  In this case, the Initialize gets associated with the


< prev index next >