< prev index next >

src/hotspot/share/opto/escape.cpp

Print this page

3505   (void)add_edge(ptadr, src);
3506   src->set_arraycopy_src();
3507   // Add edge from destination object to arraycopy node.
3508   (void)add_edge(dst, ptadr);
3509   dst->set_arraycopy_dst();
3510 }
3511 
3512 bool ConnectionGraph::is_oop_field(Node* n, int offset, bool* unsafe) {
3513   const Type* adr_type = n->as_AddP()->bottom_type();
3514   BasicType bt = T_INT;
3515   if (offset == Type::OffsetBot) {
3516     // Check only oop fields.
3517     if (!adr_type->isa_aryptr() ||
3518         adr_type->isa_aryptr()->elem() == Type::BOTTOM ||
3519         adr_type->isa_aryptr()->elem()->make_oopptr() != nullptr) {
3520       // OffsetBot is used to reference array's element. Ignore first AddP.
3521       if (find_second_addp(n, n->in(AddPNode::Base)) == nullptr) {
3522         bt = T_OBJECT;
3523       }
3524     }
3525   } else if (offset != oopDesc::klass_offset_in_bytes()) {
3526     if (adr_type->isa_instptr()) {
3527       ciField* field = _compile->alias_type(adr_type->isa_instptr())->field();
3528       if (field != nullptr) {
3529         bt = field->layout_type();
3530       } else {
3531         // Check for unsafe oop field access
3532         if (has_oop_node_outs(n)) {
3533           bt = T_OBJECT;
3534           (*unsafe) = true;
3535         }
3536       }
3537     } else if (adr_type->isa_aryptr()) {
3538       if (offset == arrayOopDesc::length_offset_in_bytes()) {
3539         // Ignore array length load.
3540       } else if (find_second_addp(n, n->in(AddPNode::Base)) != nullptr) {
3541         // Ignore first AddP.
3542       } else {
3543         const Type* elemtype = adr_type->isa_aryptr()->elem();
3544         bt = elemtype->array_element_basic_type();
3545       }

4513         alloc->as_Allocate()->_is_scalar_replaceable = true;
4514       }
4515       set_escape_state(ptnode_adr(n->_idx), es NOT_PRODUCT(COMMA trace_propagate_message(ptn))); // CheckCastPP escape state
4516       // in order for an object to be scalar-replaceable, it must be:
4517       //   - a direct allocation (not a call returning an object)
4518       //   - non-escaping
4519       //   - eligible to be a unique type
4520       //   - not determined to be ineligible by escape analysis
4521       set_map(alloc, n);
4522       set_map(n, alloc);
4523       const TypeOopPtr* tinst = t->cast_to_instance_id(ni);
4524       igvn->hash_delete(n);
4525       igvn->set_type(n,  tinst);
4526       n->raise_bottom_type(tinst);
4527       igvn->hash_insert(n);
4528       record_for_optimizer(n);
4529       // Allocate an alias index for the header fields. Accesses to
4530       // the header emitted during macro expansion wouldn't have
4531       // correct memory state otherwise.
4532       _compile->get_alias_index(tinst->add_offset(oopDesc::mark_offset_in_bytes()));
4533       _compile->get_alias_index(tinst->add_offset(oopDesc::klass_offset_in_bytes()));
4534       if (alloc->is_Allocate() && (t->isa_instptr() || t->isa_aryptr())) {
4535         // Add a new NarrowMem projection for each existing NarrowMem projection with new adr type
4536         InitializeNode* init = alloc->as_Allocate()->initialization();
4537         assert(init != nullptr, "can't find Initialization node for this Allocate node");
4538         auto process_narrow_proj = [&](NarrowMemProjNode* proj) {
4539           const TypePtr* adr_type = proj->adr_type();
4540           const TypePtr* new_adr_type = tinst->add_offset(adr_type->offset());
4541           if (adr_type != new_adr_type && !init->already_has_narrow_mem_proj_with_adr_type(new_adr_type)) {
4542             // Do NOT remove the next line: ensure a new alias index is allocated for the instance type.
4543             uint alias_idx = _compile->get_alias_index(new_adr_type);
4544             assert(_compile->get_general_index(alias_idx) == _compile->get_alias_index(adr_type), "new adr type should be narrowed down from existing adr type");
4545             NarrowMemProjNode* new_proj = new NarrowMemProjNode(init, new_adr_type);
4546             igvn->set_type(new_proj, new_proj->bottom_type());
4547             record_for_optimizer(new_proj);
4548             set_map(proj, new_proj); // record it so ConnectionGraph::find_inst_mem() can find it
4549           }
4550         };
4551         init->for_each_narrow_mem_proj_with_new_uses(process_narrow_proj);
4552 
4553         // First, put on the worklist all Field edges from Connection Graph

3505   (void)add_edge(ptadr, src);
3506   src->set_arraycopy_src();
3507   // Add edge from destination object to arraycopy node.
3508   (void)add_edge(dst, ptadr);
3509   dst->set_arraycopy_dst();
3510 }
3511 
3512 bool ConnectionGraph::is_oop_field(Node* n, int offset, bool* unsafe) {
3513   const Type* adr_type = n->as_AddP()->bottom_type();
3514   BasicType bt = T_INT;
3515   if (offset == Type::OffsetBot) {
3516     // Check only oop fields.
3517     if (!adr_type->isa_aryptr() ||
3518         adr_type->isa_aryptr()->elem() == Type::BOTTOM ||
3519         adr_type->isa_aryptr()->elem()->make_oopptr() != nullptr) {
3520       // OffsetBot is used to reference array's element. Ignore first AddP.
3521       if (find_second_addp(n, n->in(AddPNode::Base)) == nullptr) {
3522         bt = T_OBJECT;
3523       }
3524     }
3525   } else if (offset != Type::klass_offset()) {
3526     if (adr_type->isa_instptr()) {
3527       ciField* field = _compile->alias_type(adr_type->isa_instptr())->field();
3528       if (field != nullptr) {
3529         bt = field->layout_type();
3530       } else {
3531         // Check for unsafe oop field access
3532         if (has_oop_node_outs(n)) {
3533           bt = T_OBJECT;
3534           (*unsafe) = true;
3535         }
3536       }
3537     } else if (adr_type->isa_aryptr()) {
3538       if (offset == arrayOopDesc::length_offset_in_bytes()) {
3539         // Ignore array length load.
3540       } else if (find_second_addp(n, n->in(AddPNode::Base)) != nullptr) {
3541         // Ignore first AddP.
3542       } else {
3543         const Type* elemtype = adr_type->isa_aryptr()->elem();
3544         bt = elemtype->array_element_basic_type();
3545       }

4513         alloc->as_Allocate()->_is_scalar_replaceable = true;
4514       }
4515       set_escape_state(ptnode_adr(n->_idx), es NOT_PRODUCT(COMMA trace_propagate_message(ptn))); // CheckCastPP escape state
4516       // in order for an object to be scalar-replaceable, it must be:
4517       //   - a direct allocation (not a call returning an object)
4518       //   - non-escaping
4519       //   - eligible to be a unique type
4520       //   - not determined to be ineligible by escape analysis
4521       set_map(alloc, n);
4522       set_map(n, alloc);
4523       const TypeOopPtr* tinst = t->cast_to_instance_id(ni);
4524       igvn->hash_delete(n);
4525       igvn->set_type(n,  tinst);
4526       n->raise_bottom_type(tinst);
4527       igvn->hash_insert(n);
4528       record_for_optimizer(n);
4529       // Allocate an alias index for the header fields. Accesses to
4530       // the header emitted during macro expansion wouldn't have
4531       // correct memory state otherwise.
4532       _compile->get_alias_index(tinst->add_offset(oopDesc::mark_offset_in_bytes()));
4533       _compile->get_alias_index(tinst->add_offset(Type::klass_offset()));
4534       if (alloc->is_Allocate() && (t->isa_instptr() || t->isa_aryptr())) {
4535         // Add a new NarrowMem projection for each existing NarrowMem projection with new adr type
4536         InitializeNode* init = alloc->as_Allocate()->initialization();
4537         assert(init != nullptr, "can't find Initialization node for this Allocate node");
4538         auto process_narrow_proj = [&](NarrowMemProjNode* proj) {
4539           const TypePtr* adr_type = proj->adr_type();
4540           const TypePtr* new_adr_type = tinst->add_offset(adr_type->offset());
4541           if (adr_type != new_adr_type && !init->already_has_narrow_mem_proj_with_adr_type(new_adr_type)) {
4542             // Do NOT remove the next line: ensure a new alias index is allocated for the instance type.
4543             uint alias_idx = _compile->get_alias_index(new_adr_type);
4544             assert(_compile->get_general_index(alias_idx) == _compile->get_alias_index(adr_type), "new adr type should be narrowed down from existing adr type");
4545             NarrowMemProjNode* new_proj = new NarrowMemProjNode(init, new_adr_type);
4546             igvn->set_type(new_proj, new_proj->bottom_type());
4547             record_for_optimizer(new_proj);
4548             set_map(proj, new_proj); // record it so ConnectionGraph::find_inst_mem() can find it
4549           }
4550         };
4551         init->for_each_narrow_mem_proj_with_new_uses(process_narrow_proj);
4552 
4553         // First, put on the worklist all Field edges from Connection Graph
< prev index next >