< prev index next >

src/hotspot/share/opto/addnode.cpp

Print this page

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






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






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

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