< prev index next >

src/hotspot/share/opto/addnode.cpp

Print this page

 750   }
 751 
 752   return NULL;                  // No progress
 753 }
 754 
 755 //------------------------------bottom_type------------------------------------
 756 // Bottom-type is the pointer-type with unknown offset.
 757 const Type *AddPNode::bottom_type() const {
 758   if (in(Address) == NULL)  return TypePtr::BOTTOM;
 759   const TypePtr *tp = in(Address)->bottom_type()->isa_ptr();
 760   if( !tp ) return Type::TOP;   // TOP input means TOP output
 761   assert( in(Offset)->Opcode() != Op_ConP, "" );
 762   const Type *t = in(Offset)->bottom_type();
 763   if( t == Type::TOP )
 764     return tp->add_offset(Type::OffsetTop);
 765   const TypeX *tx = t->is_intptr_t();
 766   intptr_t txoffset = Type::OffsetBot;
 767   if (tx->is_con()) {   // Left input is an add of a constant?
 768     txoffset = tx->get_con();
 769   }






 770   return tp->add_offset(txoffset);
 771 }
 772 
 773 //------------------------------Value------------------------------------------
 774 const Type* AddPNode::Value(PhaseGVN* phase) const {
 775   // Either input is TOP ==> the result is TOP
 776   const Type *t1 = phase->type( in(Address) );
 777   const Type *t2 = phase->type( in(Offset) );
 778   if( t1 == Type::TOP ) return Type::TOP;
 779   if( t2 == Type::TOP ) return Type::TOP;
 780 
 781   // Left input is a pointer
 782   const TypePtr *p1 = t1->isa_ptr();
 783   // Right input is an int
 784   const TypeX *p2 = t2->is_intptr_t();
 785   // Add 'em
 786   intptr_t p2offset = Type::OffsetBot;
 787   if (p2->is_con()) {   // Left input is an add of a constant?
 788     p2offset = p2->get_con();
 789   }






 790   return p1->add_offset(p2offset);
 791 }
 792 
 793 //------------------------Ideal_base_and_offset--------------------------------
 794 // Split an oop pointer into a base and offset.
 795 // (The offset might be Type::OffsetBot in the case of an array.)
 796 // Return the base, or NULL if failure.
 797 Node* AddPNode::Ideal_base_and_offset(Node* ptr, PhaseTransform* phase,
 798                                       // second return value:
 799                                       intptr_t& offset) {
 800   if (ptr->is_AddP()) {
 801     Node* base = ptr->in(AddPNode::Base);
 802     Node* addr = ptr->in(AddPNode::Address);
 803     Node* offs = ptr->in(AddPNode::Offset);
 804     if (base == addr || base->is_top()) {
 805       offset = phase->find_intptr_t_con(offs, Type::OffsetBot);
 806       if (offset != Type::OffsetBot) {
 807         return addr;
 808       }
 809     }

 750   }
 751 
 752   return NULL;                  // No progress
 753 }
 754 
 755 //------------------------------bottom_type------------------------------------
 756 // Bottom-type is the pointer-type with unknown offset.
 757 const Type *AddPNode::bottom_type() const {
 758   if (in(Address) == NULL)  return TypePtr::BOTTOM;
 759   const TypePtr *tp = in(Address)->bottom_type()->isa_ptr();
 760   if( !tp ) return Type::TOP;   // TOP input means TOP output
 761   assert( in(Offset)->Opcode() != Op_ConP, "" );
 762   const Type *t = in(Offset)->bottom_type();
 763   if( t == Type::TOP )
 764     return tp->add_offset(Type::OffsetTop);
 765   const TypeX *tx = t->is_intptr_t();
 766   intptr_t txoffset = Type::OffsetBot;
 767   if (tx->is_con()) {   // Left input is an add of a constant?
 768     txoffset = tx->get_con();
 769   }
 770   if (tp->isa_aryptr()) {
 771     // In the case of a flattened inline type array, each field has its
 772     // own slice so we need to extract the field being accessed from
 773     // the address computation
 774     return tp->is_aryptr()->add_field_offset_and_offset(txoffset);
 775   }
 776   return tp->add_offset(txoffset);
 777 }
 778 
 779 //------------------------------Value------------------------------------------
 780 const Type* AddPNode::Value(PhaseGVN* phase) const {
 781   // Either input is TOP ==> the result is TOP
 782   const Type *t1 = phase->type( in(Address) );
 783   const Type *t2 = phase->type( in(Offset) );
 784   if( t1 == Type::TOP ) return Type::TOP;
 785   if( t2 == Type::TOP ) return Type::TOP;
 786 
 787   // Left input is a pointer
 788   const TypePtr *p1 = t1->isa_ptr();
 789   // Right input is an int
 790   const TypeX *p2 = t2->is_intptr_t();
 791   // Add 'em
 792   intptr_t p2offset = Type::OffsetBot;
 793   if (p2->is_con()) {   // Left input is an add of a constant?
 794     p2offset = p2->get_con();
 795   }
 796   if (p1->isa_aryptr()) {
 797     // In the case of a flattened inline type array, each field has its
 798     // own slice so we need to extract the field being accessed from
 799     // the address computation
 800     return p1->is_aryptr()->add_field_offset_and_offset(p2offset);
 801   }
 802   return p1->add_offset(p2offset);
 803 }
 804 
 805 //------------------------Ideal_base_and_offset--------------------------------
 806 // Split an oop pointer into a base and offset.
 807 // (The offset might be Type::OffsetBot in the case of an array.)
 808 // Return the base, or NULL if failure.
 809 Node* AddPNode::Ideal_base_and_offset(Node* ptr, PhaseTransform* phase,
 810                                       // second return value:
 811                                       intptr_t& offset) {
 812   if (ptr->is_AddP()) {
 813     Node* base = ptr->in(AddPNode::Base);
 814     Node* addr = ptr->in(AddPNode::Address);
 815     Node* offs = ptr->in(AddPNode::Offset);
 816     if (base == addr || base->is_top()) {
 817       offset = phase->find_intptr_t_con(offs, Type::OffsetBot);
 818       if (offset != Type::OffsetBot) {
 819         return addr;
 820       }
 821     }
< prev index next >