3412 (void)add_edge(ptadr, src);
3413 src->set_arraycopy_src();
3414 // Add edge from destination object to arraycopy node.
3415 (void)add_edge(dst, ptadr);
3416 dst->set_arraycopy_dst();
3417 }
3418
3419 bool ConnectionGraph::is_oop_field(Node* n, int offset, bool* unsafe) {
3420 const Type* adr_type = n->as_AddP()->bottom_type();
3421 BasicType bt = T_INT;
3422 if (offset == Type::OffsetBot) {
3423 // Check only oop fields.
3424 if (!adr_type->isa_aryptr() ||
3425 adr_type->isa_aryptr()->elem() == Type::BOTTOM ||
3426 adr_type->isa_aryptr()->elem()->make_oopptr() != nullptr) {
3427 // OffsetBot is used to reference array's element. Ignore first AddP.
3428 if (find_second_addp(n, n->in(AddPNode::Base)) == nullptr) {
3429 bt = T_OBJECT;
3430 }
3431 }
3432 } else if (offset != oopDesc::klass_offset_in_bytes()) {
3433 if (adr_type->isa_instptr()) {
3434 ciField* field = _compile->alias_type(adr_type->isa_instptr())->field();
3435 if (field != nullptr) {
3436 bt = field->layout_type();
3437 } else {
3438 // Check for unsafe oop field access
3439 if (n->has_out_with(Op_StoreP, Op_LoadP, Op_StoreN, Op_LoadN) ||
3440 n->has_out_with(Op_GetAndSetP, Op_GetAndSetN, Op_CompareAndExchangeP, Op_CompareAndExchangeN) ||
3441 n->has_out_with(Op_CompareAndSwapP, Op_CompareAndSwapN, Op_WeakCompareAndSwapP, Op_WeakCompareAndSwapN) ||
3442 BarrierSet::barrier_set()->barrier_set_c2()->escape_has_out_with_unsafe_object(n)) {
3443 bt = T_OBJECT;
3444 (*unsafe) = true;
3445 }
3446 }
3447 } else if (adr_type->isa_aryptr()) {
3448 if (offset == arrayOopDesc::length_offset_in_bytes()) {
3449 // Ignore array length load.
3450 } else if (find_second_addp(n, n->in(AddPNode::Base)) != nullptr) {
3451 // Ignore first AddP.
3452 } else {
4411 alloc->as_Allocate()->_is_scalar_replaceable = true;
4412 }
4413 set_escape_state(ptnode_adr(n->_idx), es NOT_PRODUCT(COMMA trace_propagate_message(ptn))); // CheckCastPP escape state
4414 // in order for an object to be scalar-replaceable, it must be:
4415 // - a direct allocation (not a call returning an object)
4416 // - non-escaping
4417 // - eligible to be a unique type
4418 // - not determined to be ineligible by escape analysis
4419 set_map(alloc, n);
4420 set_map(n, alloc);
4421 const TypeOopPtr* tinst = t->cast_to_instance_id(ni);
4422 igvn->hash_delete(n);
4423 igvn->set_type(n, tinst);
4424 n->raise_bottom_type(tinst);
4425 igvn->hash_insert(n);
4426 record_for_optimizer(n);
4427 // Allocate an alias index for the header fields. Accesses to
4428 // the header emitted during macro expansion wouldn't have
4429 // correct memory state otherwise.
4430 _compile->get_alias_index(tinst->add_offset(oopDesc::mark_offset_in_bytes()));
4431 _compile->get_alias_index(tinst->add_offset(oopDesc::klass_offset_in_bytes()));
4432 if (alloc->is_Allocate() && (t->isa_instptr() || t->isa_aryptr())) {
4433
4434 // First, put on the worklist all Field edges from Connection Graph
4435 // which is more accurate than putting immediate users from Ideal Graph.
4436 for (EdgeIterator e(ptn); e.has_next(); e.next()) {
4437 PointsToNode* tgt = e.get();
4438 if (tgt->is_Arraycopy()) {
4439 continue;
4440 }
4441 Node* use = tgt->ideal_node();
4442 assert(tgt->is_Field() && use->is_AddP(),
4443 "only AddP nodes are Field edges in CG");
4444 if (use->outcnt() > 0) { // Don't process dead nodes
4445 Node* addp2 = find_second_addp(use, use->in(AddPNode::Base));
4446 if (addp2 != nullptr) {
4447 assert(alloc->is_AllocateArray(),"array allocation was expected");
4448 alloc_worklist.append_if_missing(addp2);
4449 }
4450 alloc_worklist.append_if_missing(use);
4451 }
|
3412 (void)add_edge(ptadr, src);
3413 src->set_arraycopy_src();
3414 // Add edge from destination object to arraycopy node.
3415 (void)add_edge(dst, ptadr);
3416 dst->set_arraycopy_dst();
3417 }
3418
3419 bool ConnectionGraph::is_oop_field(Node* n, int offset, bool* unsafe) {
3420 const Type* adr_type = n->as_AddP()->bottom_type();
3421 BasicType bt = T_INT;
3422 if (offset == Type::OffsetBot) {
3423 // Check only oop fields.
3424 if (!adr_type->isa_aryptr() ||
3425 adr_type->isa_aryptr()->elem() == Type::BOTTOM ||
3426 adr_type->isa_aryptr()->elem()->make_oopptr() != nullptr) {
3427 // OffsetBot is used to reference array's element. Ignore first AddP.
3428 if (find_second_addp(n, n->in(AddPNode::Base)) == nullptr) {
3429 bt = T_OBJECT;
3430 }
3431 }
3432 } else if (offset != Type::klass_offset()) {
3433 if (adr_type->isa_instptr()) {
3434 ciField* field = _compile->alias_type(adr_type->isa_instptr())->field();
3435 if (field != nullptr) {
3436 bt = field->layout_type();
3437 } else {
3438 // Check for unsafe oop field access
3439 if (n->has_out_with(Op_StoreP, Op_LoadP, Op_StoreN, Op_LoadN) ||
3440 n->has_out_with(Op_GetAndSetP, Op_GetAndSetN, Op_CompareAndExchangeP, Op_CompareAndExchangeN) ||
3441 n->has_out_with(Op_CompareAndSwapP, Op_CompareAndSwapN, Op_WeakCompareAndSwapP, Op_WeakCompareAndSwapN) ||
3442 BarrierSet::barrier_set()->barrier_set_c2()->escape_has_out_with_unsafe_object(n)) {
3443 bt = T_OBJECT;
3444 (*unsafe) = true;
3445 }
3446 }
3447 } else if (adr_type->isa_aryptr()) {
3448 if (offset == arrayOopDesc::length_offset_in_bytes()) {
3449 // Ignore array length load.
3450 } else if (find_second_addp(n, n->in(AddPNode::Base)) != nullptr) {
3451 // Ignore first AddP.
3452 } else {
4411 alloc->as_Allocate()->_is_scalar_replaceable = true;
4412 }
4413 set_escape_state(ptnode_adr(n->_idx), es NOT_PRODUCT(COMMA trace_propagate_message(ptn))); // CheckCastPP escape state
4414 // in order for an object to be scalar-replaceable, it must be:
4415 // - a direct allocation (not a call returning an object)
4416 // - non-escaping
4417 // - eligible to be a unique type
4418 // - not determined to be ineligible by escape analysis
4419 set_map(alloc, n);
4420 set_map(n, alloc);
4421 const TypeOopPtr* tinst = t->cast_to_instance_id(ni);
4422 igvn->hash_delete(n);
4423 igvn->set_type(n, tinst);
4424 n->raise_bottom_type(tinst);
4425 igvn->hash_insert(n);
4426 record_for_optimizer(n);
4427 // Allocate an alias index for the header fields. Accesses to
4428 // the header emitted during macro expansion wouldn't have
4429 // correct memory state otherwise.
4430 _compile->get_alias_index(tinst->add_offset(oopDesc::mark_offset_in_bytes()));
4431 _compile->get_alias_index(tinst->add_offset(Type::klass_offset()));
4432 if (alloc->is_Allocate() && (t->isa_instptr() || t->isa_aryptr())) {
4433
4434 // First, put on the worklist all Field edges from Connection Graph
4435 // which is more accurate than putting immediate users from Ideal Graph.
4436 for (EdgeIterator e(ptn); e.has_next(); e.next()) {
4437 PointsToNode* tgt = e.get();
4438 if (tgt->is_Arraycopy()) {
4439 continue;
4440 }
4441 Node* use = tgt->ideal_node();
4442 assert(tgt->is_Field() && use->is_AddP(),
4443 "only AddP nodes are Field edges in CG");
4444 if (use->outcnt() > 0) { // Don't process dead nodes
4445 Node* addp2 = find_second_addp(use, use->in(AddPNode::Base));
4446 if (addp2 != nullptr) {
4447 assert(alloc->is_AllocateArray(),"array allocation was expected");
4448 alloc_worklist.append_if_missing(addp2);
4449 }
4450 alloc_worklist.append_if_missing(use);
4451 }
|