< prev index next >

src/hotspot/share/opto/escape.cpp

Print this page

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

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

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

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