676 }
677
678 return nullptr; // No progress
679 }
680
681 //------------------------------bottom_type------------------------------------
682 // Bottom-type is the pointer-type with unknown offset.
683 const Type *AddPNode::bottom_type() const {
684 if (in(Address) == nullptr) return TypePtr::BOTTOM;
685 const TypePtr *tp = in(Address)->bottom_type()->isa_ptr();
686 if( !tp ) return Type::TOP; // TOP input means TOP output
687 assert( in(Offset)->Opcode() != Op_ConP, "" );
688 const Type *t = in(Offset)->bottom_type();
689 if( t == Type::TOP )
690 return tp->add_offset(Type::OffsetTop);
691 const TypeX *tx = t->is_intptr_t();
692 intptr_t txoffset = Type::OffsetBot;
693 if (tx->is_con()) { // Left input is an add of a constant?
694 txoffset = tx->get_con();
695 }
696 return tp->add_offset(txoffset);
697 }
698
699 //------------------------------Value------------------------------------------
700 const Type* AddPNode::Value(PhaseGVN* phase) const {
701 // Either input is TOP ==> the result is TOP
702 const Type *t1 = phase->type( in(Address) );
703 const Type *t2 = phase->type( in(Offset) );
704 if( t1 == Type::TOP ) return Type::TOP;
705 if( t2 == Type::TOP ) return Type::TOP;
706
707 // Left input is a pointer
708 const TypePtr *p1 = t1->isa_ptr();
709 // Right input is an int
710 const TypeX *p2 = t2->is_intptr_t();
711 // Add 'em
712 intptr_t p2offset = Type::OffsetBot;
713 if (p2->is_con()) { // Left input is an add of a constant?
714 p2offset = p2->get_con();
715 }
716 return p1->add_offset(p2offset);
717 }
718
719 //------------------------Ideal_base_and_offset--------------------------------
720 // Split an oop pointer into a base and offset.
721 // (The offset might be Type::OffsetBot in the case of an array.)
722 // Return the base, or null if failure.
723 Node* AddPNode::Ideal_base_and_offset(Node* ptr, PhaseValues* phase,
724 // second return value:
725 intptr_t& offset) {
726 if (ptr->is_AddP()) {
727 Node* base = ptr->in(AddPNode::Base);
728 Node* addr = ptr->in(AddPNode::Address);
729 Node* offs = ptr->in(AddPNode::Offset);
730 if (base == addr || base->is_top()) {
731 offset = phase->find_intptr_t_con(offs, Type::OffsetBot);
732 if (offset != Type::OffsetBot) {
733 return addr;
734 }
735 }
|
676 }
677
678 return nullptr; // No progress
679 }
680
681 //------------------------------bottom_type------------------------------------
682 // Bottom-type is the pointer-type with unknown offset.
683 const Type *AddPNode::bottom_type() const {
684 if (in(Address) == nullptr) return TypePtr::BOTTOM;
685 const TypePtr *tp = in(Address)->bottom_type()->isa_ptr();
686 if( !tp ) return Type::TOP; // TOP input means TOP output
687 assert( in(Offset)->Opcode() != Op_ConP, "" );
688 const Type *t = in(Offset)->bottom_type();
689 if( t == Type::TOP )
690 return tp->add_offset(Type::OffsetTop);
691 const TypeX *tx = t->is_intptr_t();
692 intptr_t txoffset = Type::OffsetBot;
693 if (tx->is_con()) { // Left input is an add of a constant?
694 txoffset = tx->get_con();
695 }
696 if (tp->isa_aryptr()) {
697 // In the case of a flat inline type array, each field has its
698 // own slice so we need to extract the field being accessed from
699 // the address computation
700 return tp->is_aryptr()->add_field_offset_and_offset(txoffset);
701 }
702 return tp->add_offset(txoffset);
703 }
704
705 //------------------------------Value------------------------------------------
706 const Type* AddPNode::Value(PhaseGVN* phase) const {
707 // Either input is TOP ==> the result is TOP
708 const Type *t1 = phase->type( in(Address) );
709 const Type *t2 = phase->type( in(Offset) );
710 if( t1 == Type::TOP ) return Type::TOP;
711 if( t2 == Type::TOP ) return Type::TOP;
712
713 // Left input is a pointer
714 const TypePtr *p1 = t1->isa_ptr();
715 // Right input is an int
716 const TypeX *p2 = t2->is_intptr_t();
717 // Add 'em
718 intptr_t p2offset = Type::OffsetBot;
719 if (p2->is_con()) { // Left input is an add of a constant?
720 p2offset = p2->get_con();
721 }
722 if (p1->isa_aryptr()) {
723 // In the case of a flat inline type array, each field has its
724 // own slice so we need to extract the field being accessed from
725 // the address computation
726 return p1->is_aryptr()->add_field_offset_and_offset(p2offset);
727 }
728 return p1->add_offset(p2offset);
729 }
730
731 //------------------------Ideal_base_and_offset--------------------------------
732 // Split an oop pointer into a base and offset.
733 // (The offset might be Type::OffsetBot in the case of an array.)
734 // Return the base, or null if failure.
735 Node* AddPNode::Ideal_base_and_offset(Node* ptr, PhaseValues* phase,
736 // second return value:
737 intptr_t& offset) {
738 if (ptr->is_AddP()) {
739 Node* base = ptr->in(AddPNode::Base);
740 Node* addr = ptr->in(AddPNode::Address);
741 Node* offs = ptr->in(AddPNode::Offset);
742 if (base == addr || base->is_top()) {
743 offset = phase->find_intptr_t_con(offs, Type::OffsetBot);
744 if (offset != Type::OffsetBot) {
745 return addr;
746 }
747 }
|