581 } else {
582 offset = array_base + j * element_size;
583 }
584
585 const Type *field_type;
586 // The next code is taken from Parse::do_get_xxx().
587 if (basic_elem_type == T_OBJECT || basic_elem_type == T_ARRAY) {
588 if (!elem_type->is_loaded()) {
589 field_type = TypeInstPtr::BOTTOM;
590 } else if (field != NULL && field->is_constant()) {
591 // This can happen if the constant oop is non-perm.
592 ciObject* con = field->constant_value().as_object();
593 // Do not "join" in the previous type; it doesn't add value,
594 // and may yield a vacuous result if the field is of interface type.
595 field_type = TypeOopPtr::make_from_constant(con)->isa_oopptr();
596 assert(field_type != NULL, "field singleton type must be consistent");
597 } else {
598 field_type = TypeOopPtr::make_from_klass(elem_type->as_klass());
599 }
600 if (UseCompressedOops) {
601 field_type = field_type->is_oopptr()->make_narrowoop();
602 basic_elem_type = T_NARROWOOP;
603 }
604 } else {
605 field_type = Type::get_const_basic_type(basic_elem_type);
606 }
607
608 const TypeOopPtr *field_addr_type = res_type->add_offset(offset)->isa_oopptr();
609
610 Node *field_val = value_from_mem(mem, basic_elem_type, field_type, field_addr_type, alloc);
611 if (field_val == NULL) {
612 // we weren't able to find a value for this field,
613 // give up on eliminating this allocation
614 alloc->_is_scalar_replaceable = false; // don't try again
615 // remove any extra entries we added to the safepoint
616 uint last = sfpt->req() - 1;
617 for (int k = 0; k < j; k++) {
618 sfpt->del_req(last--);
619 }
620 // rollback processed safepoints
621 while (safepoints_done.length() > 0) {
649 sfpt->_idx);
650 field->print();
651 int field_idx = C->get_alias_index(field_addr_type);
652 tty->print(" (alias_idx=%d)", field_idx);
653 } else { // Array's element
654 tty->print("=== At SafePoint node %d can't find value of array element [%d]",
655 sfpt->_idx, j);
656 }
657 tty->print(", which prevents elimination of: ");
658 if (res == NULL)
659 alloc->dump();
660 else
661 res->dump();
662 }
663 #endif
664 return false;
665 }
666 if (UseCompressedOops && field_type->isa_narrowoop()) {
667 // Enable "DecodeN(EncodeP(Allocate)) --> Allocate" transformation
668 // to be able scalar replace the allocation.
669 _igvn.set_delay_transform(false);
670 field_val = DecodeNNode::decode(&_igvn, field_val);
671 _igvn.set_delay_transform(true);
672 }
673 sfpt->add_req(field_val);
674 }
675 JVMState *jvms = sfpt->jvms();
676 jvms->set_endoff(sfpt->req());
677 // Now make a pass over the debug information replacing any references
678 // to the allocated object with "sobj"
679 int start = jvms->debug_start();
680 int end = jvms->debug_end();
681 for (int i = start; i < end; i++) {
682 if (sfpt->in(i) == res) {
683 sfpt->set_req(i, sobj);
684 }
685 }
686 safepoints_done.append_if_missing(sfpt); // keep it for rollback
687 }
688 return true;
689 }
690
691 // Process users of eliminated allocation.
692 void PhaseMacroExpand::process_users_of_allocation(AllocateNode *alloc) {
|
581 } else {
582 offset = array_base + j * element_size;
583 }
584
585 const Type *field_type;
586 // The next code is taken from Parse::do_get_xxx().
587 if (basic_elem_type == T_OBJECT || basic_elem_type == T_ARRAY) {
588 if (!elem_type->is_loaded()) {
589 field_type = TypeInstPtr::BOTTOM;
590 } else if (field != NULL && field->is_constant()) {
591 // This can happen if the constant oop is non-perm.
592 ciObject* con = field->constant_value().as_object();
593 // Do not "join" in the previous type; it doesn't add value,
594 // and may yield a vacuous result if the field is of interface type.
595 field_type = TypeOopPtr::make_from_constant(con)->isa_oopptr();
596 assert(field_type != NULL, "field singleton type must be consistent");
597 } else {
598 field_type = TypeOopPtr::make_from_klass(elem_type->as_klass());
599 }
600 if (UseCompressedOops) {
601 field_type = field_type->make_narrowoop();
602 basic_elem_type = T_NARROWOOP;
603 }
604 } else {
605 field_type = Type::get_const_basic_type(basic_elem_type);
606 }
607
608 const TypeOopPtr *field_addr_type = res_type->add_offset(offset)->isa_oopptr();
609
610 Node *field_val = value_from_mem(mem, basic_elem_type, field_type, field_addr_type, alloc);
611 if (field_val == NULL) {
612 // we weren't able to find a value for this field,
613 // give up on eliminating this allocation
614 alloc->_is_scalar_replaceable = false; // don't try again
615 // remove any extra entries we added to the safepoint
616 uint last = sfpt->req() - 1;
617 for (int k = 0; k < j; k++) {
618 sfpt->del_req(last--);
619 }
620 // rollback processed safepoints
621 while (safepoints_done.length() > 0) {
649 sfpt->_idx);
650 field->print();
651 int field_idx = C->get_alias_index(field_addr_type);
652 tty->print(" (alias_idx=%d)", field_idx);
653 } else { // Array's element
654 tty->print("=== At SafePoint node %d can't find value of array element [%d]",
655 sfpt->_idx, j);
656 }
657 tty->print(", which prevents elimination of: ");
658 if (res == NULL)
659 alloc->dump();
660 else
661 res->dump();
662 }
663 #endif
664 return false;
665 }
666 if (UseCompressedOops && field_type->isa_narrowoop()) {
667 // Enable "DecodeN(EncodeP(Allocate)) --> Allocate" transformation
668 // to be able scalar replace the allocation.
669 if (field_val->is_EncodeP()) {
670 field_val = field_val->in(1);
671 } else {
672 field_val = transform_later(new (C, 2) DecodeNNode(field_val, field_val->bottom_type()->make_ptr()));
673 }
674 }
675 sfpt->add_req(field_val);
676 }
677 JVMState *jvms = sfpt->jvms();
678 jvms->set_endoff(sfpt->req());
679 // Now make a pass over the debug information replacing any references
680 // to the allocated object with "sobj"
681 int start = jvms->debug_start();
682 int end = jvms->debug_end();
683 for (int i = start; i < end; i++) {
684 if (sfpt->in(i) == res) {
685 sfpt->set_req(i, sobj);
686 }
687 }
688 safepoints_done.append_if_missing(sfpt); // keep it for rollback
689 }
690 return true;
691 }
692
693 // Process users of eliminated allocation.
694 void PhaseMacroExpand::process_users_of_allocation(AllocateNode *alloc) {
|