< prev index next >

src/hotspot/share/opto/escape.cpp

Print this page

3423   (void)add_edge(ptadr, src);
3424   src->set_arraycopy_src();
3425   // Add edge from destination object to arraycopy node.
3426   (void)add_edge(dst, ptadr);
3427   dst->set_arraycopy_dst();
3428 }
3429 
3430 bool ConnectionGraph::is_oop_field(Node* n, int offset, bool* unsafe) {
3431   const Type* adr_type = n->as_AddP()->bottom_type();
3432   BasicType bt = T_INT;
3433   if (offset == Type::OffsetBot) {
3434     // Check only oop fields.
3435     if (!adr_type->isa_aryptr() ||
3436         adr_type->isa_aryptr()->elem() == Type::BOTTOM ||
3437         adr_type->isa_aryptr()->elem()->make_oopptr() != nullptr) {
3438       // OffsetBot is used to reference array's element. Ignore first AddP.
3439       if (find_second_addp(n, n->in(AddPNode::Base)) == nullptr) {
3440         bt = T_OBJECT;
3441       }
3442     }
3443   } else if (offset != oopDesc::klass_offset_in_bytes()) {
3444     if (adr_type->isa_instptr()) {
3445       ciField* field = _compile->alias_type(adr_type->isa_instptr())->field();
3446       if (field != nullptr) {
3447         bt = field->layout_type();
3448       } else {
3449         // Check for unsafe oop field access
3450         if (n->has_out_with(Op_StoreP, Op_LoadP, Op_StoreN, Op_LoadN) ||
3451             n->has_out_with(Op_GetAndSetP, Op_GetAndSetN, Op_CompareAndExchangeP, Op_CompareAndExchangeN) ||
3452             n->has_out_with(Op_CompareAndSwapP, Op_CompareAndSwapN, Op_WeakCompareAndSwapP, Op_WeakCompareAndSwapN) ||
3453             BarrierSet::barrier_set()->barrier_set_c2()->escape_has_out_with_unsafe_object(n)) {
3454           bt = T_OBJECT;
3455           (*unsafe) = true;
3456         }
3457       }
3458     } else if (adr_type->isa_aryptr()) {
3459       if (offset == arrayOopDesc::length_offset_in_bytes()) {
3460         // Ignore array length load.
3461       } else if (find_second_addp(n, n->in(AddPNode::Base)) != nullptr) {
3462         // Ignore first AddP.
3463       } else {

4422         alloc->as_Allocate()->_is_scalar_replaceable = true;
4423       }
4424       set_escape_state(ptnode_adr(n->_idx), es NOT_PRODUCT(COMMA trace_propagate_message(ptn))); // CheckCastPP escape state
4425       // in order for an object to be scalar-replaceable, it must be:
4426       //   - a direct allocation (not a call returning an object)
4427       //   - non-escaping
4428       //   - eligible to be a unique type
4429       //   - not determined to be ineligible by escape analysis
4430       set_map(alloc, n);
4431       set_map(n, alloc);
4432       const TypeOopPtr* tinst = t->cast_to_instance_id(ni);
4433       igvn->hash_delete(n);
4434       igvn->set_type(n,  tinst);
4435       n->raise_bottom_type(tinst);
4436       igvn->hash_insert(n);
4437       record_for_optimizer(n);
4438       // Allocate an alias index for the header fields. Accesses to
4439       // the header emitted during macro expansion wouldn't have
4440       // correct memory state otherwise.
4441       _compile->get_alias_index(tinst->add_offset(oopDesc::mark_offset_in_bytes()));
4442       _compile->get_alias_index(tinst->add_offset(oopDesc::klass_offset_in_bytes()));
4443       if (alloc->is_Allocate() && (t->isa_instptr() || t->isa_aryptr())) {
4444 
4445         // First, put on the worklist all Field edges from Connection Graph
4446         // which is more accurate than putting immediate users from Ideal Graph.
4447         for (EdgeIterator e(ptn); e.has_next(); e.next()) {
4448           PointsToNode* tgt = e.get();
4449           if (tgt->is_Arraycopy()) {
4450             continue;
4451           }
4452           Node* use = tgt->ideal_node();
4453           assert(tgt->is_Field() && use->is_AddP(),
4454                  "only AddP nodes are Field edges in CG");
4455           if (use->outcnt() > 0) { // Don't process dead nodes
4456             Node* addp2 = find_second_addp(use, use->in(AddPNode::Base));
4457             if (addp2 != nullptr) {
4458               assert(alloc->is_AllocateArray(),"array allocation was expected");
4459               alloc_worklist.append_if_missing(addp2);
4460             }
4461             alloc_worklist.append_if_missing(use);
4462           }

3423   (void)add_edge(ptadr, src);
3424   src->set_arraycopy_src();
3425   // Add edge from destination object to arraycopy node.
3426   (void)add_edge(dst, ptadr);
3427   dst->set_arraycopy_dst();
3428 }
3429 
3430 bool ConnectionGraph::is_oop_field(Node* n, int offset, bool* unsafe) {
3431   const Type* adr_type = n->as_AddP()->bottom_type();
3432   BasicType bt = T_INT;
3433   if (offset == Type::OffsetBot) {
3434     // Check only oop fields.
3435     if (!adr_type->isa_aryptr() ||
3436         adr_type->isa_aryptr()->elem() == Type::BOTTOM ||
3437         adr_type->isa_aryptr()->elem()->make_oopptr() != nullptr) {
3438       // OffsetBot is used to reference array's element. Ignore first AddP.
3439       if (find_second_addp(n, n->in(AddPNode::Base)) == nullptr) {
3440         bt = T_OBJECT;
3441       }
3442     }
3443   } else if (offset != Type::klass_offset()) {
3444     if (adr_type->isa_instptr()) {
3445       ciField* field = _compile->alias_type(adr_type->isa_instptr())->field();
3446       if (field != nullptr) {
3447         bt = field->layout_type();
3448       } else {
3449         // Check for unsafe oop field access
3450         if (n->has_out_with(Op_StoreP, Op_LoadP, Op_StoreN, Op_LoadN) ||
3451             n->has_out_with(Op_GetAndSetP, Op_GetAndSetN, Op_CompareAndExchangeP, Op_CompareAndExchangeN) ||
3452             n->has_out_with(Op_CompareAndSwapP, Op_CompareAndSwapN, Op_WeakCompareAndSwapP, Op_WeakCompareAndSwapN) ||
3453             BarrierSet::barrier_set()->barrier_set_c2()->escape_has_out_with_unsafe_object(n)) {
3454           bt = T_OBJECT;
3455           (*unsafe) = true;
3456         }
3457       }
3458     } else if (adr_type->isa_aryptr()) {
3459       if (offset == arrayOopDesc::length_offset_in_bytes()) {
3460         // Ignore array length load.
3461       } else if (find_second_addp(n, n->in(AddPNode::Base)) != nullptr) {
3462         // Ignore first AddP.
3463       } else {

4422         alloc->as_Allocate()->_is_scalar_replaceable = true;
4423       }
4424       set_escape_state(ptnode_adr(n->_idx), es NOT_PRODUCT(COMMA trace_propagate_message(ptn))); // CheckCastPP escape state
4425       // in order for an object to be scalar-replaceable, it must be:
4426       //   - a direct allocation (not a call returning an object)
4427       //   - non-escaping
4428       //   - eligible to be a unique type
4429       //   - not determined to be ineligible by escape analysis
4430       set_map(alloc, n);
4431       set_map(n, alloc);
4432       const TypeOopPtr* tinst = t->cast_to_instance_id(ni);
4433       igvn->hash_delete(n);
4434       igvn->set_type(n,  tinst);
4435       n->raise_bottom_type(tinst);
4436       igvn->hash_insert(n);
4437       record_for_optimizer(n);
4438       // Allocate an alias index for the header fields. Accesses to
4439       // the header emitted during macro expansion wouldn't have
4440       // correct memory state otherwise.
4441       _compile->get_alias_index(tinst->add_offset(oopDesc::mark_offset_in_bytes()));
4442       _compile->get_alias_index(tinst->add_offset(Type::klass_offset()));
4443       if (alloc->is_Allocate() && (t->isa_instptr() || t->isa_aryptr())) {
4444 
4445         // First, put on the worklist all Field edges from Connection Graph
4446         // which is more accurate than putting immediate users from Ideal Graph.
4447         for (EdgeIterator e(ptn); e.has_next(); e.next()) {
4448           PointsToNode* tgt = e.get();
4449           if (tgt->is_Arraycopy()) {
4450             continue;
4451           }
4452           Node* use = tgt->ideal_node();
4453           assert(tgt->is_Field() && use->is_AddP(),
4454                  "only AddP nodes are Field edges in CG");
4455           if (use->outcnt() > 0) { // Don't process dead nodes
4456             Node* addp2 = find_second_addp(use, use->in(AddPNode::Base));
4457             if (addp2 != nullptr) {
4458               assert(alloc->is_AllocateArray(),"array allocation was expected");
4459               alloc_worklist.append_if_missing(addp2);
4460             }
4461             alloc_worklist.append_if_missing(use);
4462           }
< prev index next >