< prev index next >

src/hotspot/share/opto/addnode.cpp

Print this page




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






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






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




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


< prev index next >