< prev index next >

src/hotspot/share/opto/addnode.cpp

Print this page

 809   }
 810 
 811   return nullptr;                  // No progress
 812 }
 813 
 814 //------------------------------bottom_type------------------------------------
 815 // Bottom-type is the pointer-type with unknown offset.
 816 const Type *AddPNode::bottom_type() const {
 817   if (in(Address) == nullptr)  return TypePtr::BOTTOM;
 818   const TypePtr *tp = in(Address)->bottom_type()->isa_ptr();
 819   if( !tp ) return Type::TOP;   // TOP input means TOP output
 820   assert( in(Offset)->Opcode() != Op_ConP, "" );
 821   const Type *t = in(Offset)->bottom_type();
 822   if( t == Type::TOP )
 823     return tp->add_offset(Type::OffsetTop);
 824   const TypeX *tx = t->is_intptr_t();
 825   intptr_t txoffset = Type::OffsetBot;
 826   if (tx->is_con()) {   // Left input is an add of a constant?
 827     txoffset = tx->get_con();
 828   }






 829   return tp->add_offset(txoffset);
 830 }
 831 
 832 //------------------------------Value------------------------------------------
 833 const Type* AddPNode::Value(PhaseGVN* phase) const {
 834   // Either input is TOP ==> the result is TOP
 835   const Type *t1 = phase->type( in(Address) );
 836   const Type *t2 = phase->type( in(Offset) );
 837   if( t1 == Type::TOP ) return Type::TOP;
 838   if( t2 == Type::TOP ) return Type::TOP;
 839 
 840   // Left input is a pointer
 841   const TypePtr *p1 = t1->isa_ptr();
 842   // Right input is an int
 843   const TypeX *p2 = t2->is_intptr_t();
 844   // Add 'em
 845   intptr_t p2offset = Type::OffsetBot;
 846   if (p2->is_con()) {   // Left input is an add of a constant?
 847     p2offset = p2->get_con();
 848   }






 849   return p1->add_offset(p2offset);
 850 }
 851 
 852 //------------------------Ideal_base_and_offset--------------------------------
 853 // Split an oop pointer into a base and offset.
 854 // (The offset might be Type::OffsetBot in the case of an array.)
 855 // Return the base, or null if failure.
 856 Node* AddPNode::Ideal_base_and_offset(Node* ptr, PhaseValues* phase,
 857                                       // second return value:
 858                                       intptr_t& offset) {
 859   if (ptr->is_AddP()) {
 860     Node* base = ptr->in(AddPNode::Base);
 861     Node* addr = ptr->in(AddPNode::Address);
 862     Node* offs = ptr->in(AddPNode::Offset);
 863     if (base == addr || base->is_top()) {
 864       offset = phase->find_intptr_t_con(offs, Type::OffsetBot);
 865       if (offset != Type::OffsetBot) {
 866         return addr;
 867       }
 868     }

 809   }
 810 
 811   return nullptr;                  // No progress
 812 }
 813 
 814 //------------------------------bottom_type------------------------------------
 815 // Bottom-type is the pointer-type with unknown offset.
 816 const Type *AddPNode::bottom_type() const {
 817   if (in(Address) == nullptr)  return TypePtr::BOTTOM;
 818   const TypePtr *tp = in(Address)->bottom_type()->isa_ptr();
 819   if( !tp ) return Type::TOP;   // TOP input means TOP output
 820   assert( in(Offset)->Opcode() != Op_ConP, "" );
 821   const Type *t = in(Offset)->bottom_type();
 822   if( t == Type::TOP )
 823     return tp->add_offset(Type::OffsetTop);
 824   const TypeX *tx = t->is_intptr_t();
 825   intptr_t txoffset = Type::OffsetBot;
 826   if (tx->is_con()) {   // Left input is an add of a constant?
 827     txoffset = tx->get_con();
 828   }
 829   if (tp->isa_aryptr()) {
 830     // In the case of a flat inline type array, each field has its
 831     // own slice so we need to extract the field being accessed from
 832     // the address computation
 833     return tp->is_aryptr()->add_field_offset_and_offset(txoffset);
 834   }
 835   return tp->add_offset(txoffset);
 836 }
 837 
 838 //------------------------------Value------------------------------------------
 839 const Type* AddPNode::Value(PhaseGVN* phase) const {
 840   // Either input is TOP ==> the result is TOP
 841   const Type *t1 = phase->type( in(Address) );
 842   const Type *t2 = phase->type( in(Offset) );
 843   if( t1 == Type::TOP ) return Type::TOP;
 844   if( t2 == Type::TOP ) return Type::TOP;
 845 
 846   // Left input is a pointer
 847   const TypePtr *p1 = t1->isa_ptr();
 848   // Right input is an int
 849   const TypeX *p2 = t2->is_intptr_t();
 850   // Add 'em
 851   intptr_t p2offset = Type::OffsetBot;
 852   if (p2->is_con()) {   // Left input is an add of a constant?
 853     p2offset = p2->get_con();
 854   }
 855   if (p1->isa_aryptr()) {
 856     // In the case of a flat inline type array, each field has its
 857     // own slice so we need to extract the field being accessed from
 858     // the address computation
 859     return p1->is_aryptr()->add_field_offset_and_offset(p2offset);
 860   }
 861   return p1->add_offset(p2offset);
 862 }
 863 
 864 //------------------------Ideal_base_and_offset--------------------------------
 865 // Split an oop pointer into a base and offset.
 866 // (The offset might be Type::OffsetBot in the case of an array.)
 867 // Return the base, or null if failure.
 868 Node* AddPNode::Ideal_base_and_offset(Node* ptr, PhaseValues* phase,
 869                                       // second return value:
 870                                       intptr_t& offset) {
 871   if (ptr->is_AddP()) {
 872     Node* base = ptr->in(AddPNode::Base);
 873     Node* addr = ptr->in(AddPNode::Address);
 874     Node* offs = ptr->in(AddPNode::Offset);
 875     if (base == addr || base->is_top()) {
 876       offset = phase->find_intptr_t_con(offs, Type::OffsetBot);
 877       if (offset != Type::OffsetBot) {
 878         return addr;
 879       }
 880     }
< prev index next >