< prev index next >

src/hotspot/share/opto/addnode.cpp

Print this page

 643   }
 644 
 645   return nullptr;                  // No progress
 646 }
 647 
 648 //------------------------------bottom_type------------------------------------
 649 // Bottom-type is the pointer-type with unknown offset.
 650 const Type *AddPNode::bottom_type() const {
 651   if (in(Address) == nullptr)  return TypePtr::BOTTOM;
 652   const TypePtr *tp = in(Address)->bottom_type()->isa_ptr();
 653   if( !tp ) return Type::TOP;   // TOP input means TOP output
 654   assert( in(Offset)->Opcode() != Op_ConP, "" );
 655   const Type *t = in(Offset)->bottom_type();
 656   if( t == Type::TOP )
 657     return tp->add_offset(Type::OffsetTop);
 658   const TypeX *tx = t->is_intptr_t();
 659   intptr_t txoffset = Type::OffsetBot;
 660   if (tx->is_con()) {   // Left input is an add of a constant?
 661     txoffset = tx->get_con();
 662   }






 663   return tp->add_offset(txoffset);
 664 }
 665 
 666 //------------------------------Value------------------------------------------
 667 const Type* AddPNode::Value(PhaseGVN* phase) const {
 668   // Either input is TOP ==> the result is TOP
 669   const Type *t1 = phase->type( in(Address) );
 670   const Type *t2 = phase->type( in(Offset) );
 671   if( t1 == Type::TOP ) return Type::TOP;
 672   if( t2 == Type::TOP ) return Type::TOP;
 673 
 674   // Left input is a pointer
 675   const TypePtr *p1 = t1->isa_ptr();
 676   // Right input is an int
 677   const TypeX *p2 = t2->is_intptr_t();
 678   // Add 'em
 679   intptr_t p2offset = Type::OffsetBot;
 680   if (p2->is_con()) {   // Left input is an add of a constant?
 681     p2offset = p2->get_con();
 682   }






 683   return p1->add_offset(p2offset);
 684 }
 685 
 686 //------------------------Ideal_base_and_offset--------------------------------
 687 // Split an oop pointer into a base and offset.
 688 // (The offset might be Type::OffsetBot in the case of an array.)
 689 // Return the base, or null if failure.
 690 Node* AddPNode::Ideal_base_and_offset(Node* ptr, PhaseValues* phase,
 691                                       // second return value:
 692                                       intptr_t& offset) {
 693   if (ptr->is_AddP()) {
 694     Node* base = ptr->in(AddPNode::Base);
 695     Node* addr = ptr->in(AddPNode::Address);
 696     Node* offs = ptr->in(AddPNode::Offset);
 697     if (base == addr || base->is_top()) {
 698       offset = phase->find_intptr_t_con(offs, Type::OffsetBot);
 699       if (offset != Type::OffsetBot) {
 700         return addr;
 701       }
 702     }

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