3521 (void)add_edge(ptadr, src);
3522 src->set_arraycopy_src();
3523 // Add edge from destination object to arraycopy node.
3524 (void)add_edge(dst, ptadr);
3525 dst->set_arraycopy_dst();
3526 }
3527
3528 bool ConnectionGraph::is_oop_field(Node* n, int offset, bool* unsafe) {
3529 const Type* adr_type = n->as_AddP()->bottom_type();
3530 BasicType bt = T_INT;
3531 if (offset == Type::OffsetBot) {
3532 // Check only oop fields.
3533 if (!adr_type->isa_aryptr() ||
3534 adr_type->isa_aryptr()->elem() == Type::BOTTOM ||
3535 adr_type->isa_aryptr()->elem()->make_oopptr() != nullptr) {
3536 // OffsetBot is used to reference array's element. Ignore first AddP.
3537 if (find_second_addp(n, n->in(AddPNode::Base)) == nullptr) {
3538 bt = T_OBJECT;
3539 }
3540 }
3541 } else if (offset != oopDesc::klass_offset_in_bytes()) {
3542 if (adr_type->isa_instptr()) {
3543 ciField* field = _compile->alias_type(adr_type->isa_instptr())->field();
3544 if (field != nullptr) {
3545 bt = field->layout_type();
3546 } else {
3547 // Check for unsafe oop field access
3548 if (has_oop_node_outs(n)) {
3549 bt = T_OBJECT;
3550 (*unsafe) = true;
3551 }
3552 }
3553 } else if (adr_type->isa_aryptr()) {
3554 if (offset == arrayOopDesc::length_offset_in_bytes()) {
3555 // Ignore array length load.
3556 } else if (find_second_addp(n, n->in(AddPNode::Base)) != nullptr) {
3557 // Ignore first AddP.
3558 } else {
3559 const Type* elemtype = adr_type->isa_aryptr()->elem();
3560 bt = elemtype->array_element_basic_type();
3561 }
4529 alloc->as_Allocate()->_is_scalar_replaceable = true;
4530 }
4531 set_escape_state(ptnode_adr(n->_idx), es NOT_PRODUCT(COMMA trace_propagate_message(ptn))); // CheckCastPP escape state
4532 // in order for an object to be scalar-replaceable, it must be:
4533 // - a direct allocation (not a call returning an object)
4534 // - non-escaping
4535 // - eligible to be a unique type
4536 // - not determined to be ineligible by escape analysis
4537 set_map(alloc, n);
4538 set_map(n, alloc);
4539 const TypeOopPtr* tinst = t->cast_to_instance_id(ni);
4540 igvn->hash_delete(n);
4541 igvn->set_type(n, tinst);
4542 n->raise_bottom_type(tinst);
4543 igvn->hash_insert(n);
4544 record_for_optimizer(n);
4545 // Allocate an alias index for the header fields. Accesses to
4546 // the header emitted during macro expansion wouldn't have
4547 // correct memory state otherwise.
4548 _compile->get_alias_index(tinst->add_offset(oopDesc::mark_offset_in_bytes()));
4549 _compile->get_alias_index(tinst->add_offset(oopDesc::klass_offset_in_bytes()));
4550 if (alloc->is_Allocate() && (t->isa_instptr() || t->isa_aryptr())) {
4551 // Add a new NarrowMem projection for each existing NarrowMem projection with new adr type
4552 InitializeNode* init = alloc->as_Allocate()->initialization();
4553 assert(init != nullptr, "can't find Initialization node for this Allocate node");
4554 auto process_narrow_proj = [&](NarrowMemProjNode* proj) {
4555 const TypePtr* adr_type = proj->adr_type();
4556 const TypePtr* new_adr_type = tinst->add_offset(adr_type->offset());
4557 if (adr_type != new_adr_type && !init->already_has_narrow_mem_proj_with_adr_type(new_adr_type)) {
4558 // Do NOT remove the next line: ensure a new alias index is allocated for the instance type.
4559 uint alias_idx = _compile->get_alias_index(new_adr_type);
4560 assert(_compile->get_general_index(alias_idx) == _compile->get_alias_index(adr_type), "new adr type should be narrowed down from existing adr type");
4561 NarrowMemProjNode* new_proj = new NarrowMemProjNode(init, new_adr_type);
4562 igvn->set_type(new_proj, new_proj->bottom_type());
4563 record_for_optimizer(new_proj);
4564 set_map(proj, new_proj); // record it so ConnectionGraph::find_inst_mem() can find it
4565 }
4566 };
4567 init->for_each_narrow_mem_proj_with_new_uses(process_narrow_proj);
4568
4569 // First, put on the worklist all Field edges from Connection Graph
|
3521 (void)add_edge(ptadr, src);
3522 src->set_arraycopy_src();
3523 // Add edge from destination object to arraycopy node.
3524 (void)add_edge(dst, ptadr);
3525 dst->set_arraycopy_dst();
3526 }
3527
3528 bool ConnectionGraph::is_oop_field(Node* n, int offset, bool* unsafe) {
3529 const Type* adr_type = n->as_AddP()->bottom_type();
3530 BasicType bt = T_INT;
3531 if (offset == Type::OffsetBot) {
3532 // Check only oop fields.
3533 if (!adr_type->isa_aryptr() ||
3534 adr_type->isa_aryptr()->elem() == Type::BOTTOM ||
3535 adr_type->isa_aryptr()->elem()->make_oopptr() != nullptr) {
3536 // OffsetBot is used to reference array's element. Ignore first AddP.
3537 if (find_second_addp(n, n->in(AddPNode::Base)) == nullptr) {
3538 bt = T_OBJECT;
3539 }
3540 }
3541 } else if (offset != Type::klass_offset()) {
3542 if (adr_type->isa_instptr()) {
3543 ciField* field = _compile->alias_type(adr_type->isa_instptr())->field();
3544 if (field != nullptr) {
3545 bt = field->layout_type();
3546 } else {
3547 // Check for unsafe oop field access
3548 if (has_oop_node_outs(n)) {
3549 bt = T_OBJECT;
3550 (*unsafe) = true;
3551 }
3552 }
3553 } else if (adr_type->isa_aryptr()) {
3554 if (offset == arrayOopDesc::length_offset_in_bytes()) {
3555 // Ignore array length load.
3556 } else if (find_second_addp(n, n->in(AddPNode::Base)) != nullptr) {
3557 // Ignore first AddP.
3558 } else {
3559 const Type* elemtype = adr_type->isa_aryptr()->elem();
3560 bt = elemtype->array_element_basic_type();
3561 }
4529 alloc->as_Allocate()->_is_scalar_replaceable = true;
4530 }
4531 set_escape_state(ptnode_adr(n->_idx), es NOT_PRODUCT(COMMA trace_propagate_message(ptn))); // CheckCastPP escape state
4532 // in order for an object to be scalar-replaceable, it must be:
4533 // - a direct allocation (not a call returning an object)
4534 // - non-escaping
4535 // - eligible to be a unique type
4536 // - not determined to be ineligible by escape analysis
4537 set_map(alloc, n);
4538 set_map(n, alloc);
4539 const TypeOopPtr* tinst = t->cast_to_instance_id(ni);
4540 igvn->hash_delete(n);
4541 igvn->set_type(n, tinst);
4542 n->raise_bottom_type(tinst);
4543 igvn->hash_insert(n);
4544 record_for_optimizer(n);
4545 // Allocate an alias index for the header fields. Accesses to
4546 // the header emitted during macro expansion wouldn't have
4547 // correct memory state otherwise.
4548 _compile->get_alias_index(tinst->add_offset(oopDesc::mark_offset_in_bytes()));
4549 _compile->get_alias_index(tinst->add_offset(Type::klass_offset()));
4550 if (alloc->is_Allocate() && (t->isa_instptr() || t->isa_aryptr())) {
4551 // Add a new NarrowMem projection for each existing NarrowMem projection with new adr type
4552 InitializeNode* init = alloc->as_Allocate()->initialization();
4553 assert(init != nullptr, "can't find Initialization node for this Allocate node");
4554 auto process_narrow_proj = [&](NarrowMemProjNode* proj) {
4555 const TypePtr* adr_type = proj->adr_type();
4556 const TypePtr* new_adr_type = tinst->add_offset(adr_type->offset());
4557 if (adr_type != new_adr_type && !init->already_has_narrow_mem_proj_with_adr_type(new_adr_type)) {
4558 // Do NOT remove the next line: ensure a new alias index is allocated for the instance type.
4559 uint alias_idx = _compile->get_alias_index(new_adr_type);
4560 assert(_compile->get_general_index(alias_idx) == _compile->get_alias_index(adr_type), "new adr type should be narrowed down from existing adr type");
4561 NarrowMemProjNode* new_proj = new NarrowMemProjNode(init, new_adr_type);
4562 igvn->set_type(new_proj, new_proj->bottom_type());
4563 record_for_optimizer(new_proj);
4564 set_map(proj, new_proj); // record it so ConnectionGraph::find_inst_mem() can find it
4565 }
4566 };
4567 init->for_each_narrow_mem_proj_with_new_uses(process_narrow_proj);
4568
4569 // First, put on the worklist all Field edges from Connection Graph
|