< prev index next >

src/hotspot/share/opto/addnode.cpp

Print this page

 659   }
 660 
 661   return nullptr;                  // No progress
 662 }
 663 
 664 //------------------------------bottom_type------------------------------------
 665 // Bottom-type is the pointer-type with unknown offset.
 666 const Type *AddPNode::bottom_type() const {
 667   if (in(Address) == nullptr)  return TypePtr::BOTTOM;
 668   const TypePtr *tp = in(Address)->bottom_type()->isa_ptr();
 669   if( !tp ) return Type::TOP;   // TOP input means TOP output
 670   assert( in(Offset)->Opcode() != Op_ConP, "" );
 671   const Type *t = in(Offset)->bottom_type();
 672   if( t == Type::TOP )
 673     return tp->add_offset(Type::OffsetTop);
 674   const TypeX *tx = t->is_intptr_t();
 675   intptr_t txoffset = Type::OffsetBot;
 676   if (tx->is_con()) {   // Left input is an add of a constant?
 677     txoffset = tx->get_con();
 678   }






 679   return tp->add_offset(txoffset);
 680 }
 681 
 682 //------------------------------Value------------------------------------------
 683 const Type* AddPNode::Value(PhaseGVN* phase) const {
 684   // Either input is TOP ==> the result is TOP
 685   const Type *t1 = phase->type( in(Address) );
 686   const Type *t2 = phase->type( in(Offset) );
 687   if( t1 == Type::TOP ) return Type::TOP;
 688   if( t2 == Type::TOP ) return Type::TOP;
 689 
 690   // Left input is a pointer
 691   const TypePtr *p1 = t1->isa_ptr();
 692   // Right input is an int
 693   const TypeX *p2 = t2->is_intptr_t();
 694   // Add 'em
 695   intptr_t p2offset = Type::OffsetBot;
 696   if (p2->is_con()) {   // Left input is an add of a constant?
 697     p2offset = p2->get_con();
 698   }






 699   return p1->add_offset(p2offset);
 700 }
 701 
 702 //------------------------Ideal_base_and_offset--------------------------------
 703 // Split an oop pointer into a base and offset.
 704 // (The offset might be Type::OffsetBot in the case of an array.)
 705 // Return the base, or null if failure.
 706 Node* AddPNode::Ideal_base_and_offset(Node* ptr, PhaseValues* phase,
 707                                       // second return value:
 708                                       intptr_t& offset) {
 709   if (ptr->is_AddP()) {
 710     Node* base = ptr->in(AddPNode::Base);
 711     Node* addr = ptr->in(AddPNode::Address);
 712     Node* offs = ptr->in(AddPNode::Offset);
 713     if (base == addr || base->is_top()) {
 714       offset = phase->find_intptr_t_con(offs, Type::OffsetBot);
 715       if (offset != Type::OffsetBot) {
 716         return addr;
 717       }
 718     }

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