< prev index next >

src/hotspot/share/opto/addnode.cpp

Print this page

 624   }
 625 
 626   return NULL;                  // No progress
 627 }
 628 
 629 //------------------------------bottom_type------------------------------------
 630 // Bottom-type is the pointer-type with unknown offset.
 631 const Type *AddPNode::bottom_type() const {
 632   if (in(Address) == NULL)  return TypePtr::BOTTOM;
 633   const TypePtr *tp = in(Address)->bottom_type()->isa_ptr();
 634   if( !tp ) return Type::TOP;   // TOP input means TOP output
 635   assert( in(Offset)->Opcode() != Op_ConP, "" );
 636   const Type *t = in(Offset)->bottom_type();
 637   if( t == Type::TOP )
 638     return tp->add_offset(Type::OffsetTop);
 639   const TypeX *tx = t->is_intptr_t();
 640   intptr_t txoffset = Type::OffsetBot;
 641   if (tx->is_con()) {   // Left input is an add of a constant?
 642     txoffset = tx->get_con();
 643   }






 644   return tp->add_offset(txoffset);
 645 }
 646 
 647 //------------------------------Value------------------------------------------
 648 const Type* AddPNode::Value(PhaseGVN* phase) const {
 649   // Either input is TOP ==> the result is TOP
 650   const Type *t1 = phase->type( in(Address) );
 651   const Type *t2 = phase->type( in(Offset) );
 652   if( t1 == Type::TOP ) return Type::TOP;
 653   if( t2 == Type::TOP ) return Type::TOP;
 654 
 655   // Left input is a pointer
 656   const TypePtr *p1 = t1->isa_ptr();
 657   // Right input is an int
 658   const TypeX *p2 = t2->is_intptr_t();
 659   // Add 'em
 660   intptr_t p2offset = Type::OffsetBot;
 661   if (p2->is_con()) {   // Left input is an add of a constant?
 662     p2offset = p2->get_con();
 663   }






 664   return p1->add_offset(p2offset);
 665 }
 666 
 667 //------------------------Ideal_base_and_offset--------------------------------
 668 // Split an oop pointer into a base and offset.
 669 // (The offset might be Type::OffsetBot in the case of an array.)
 670 // Return the base, or NULL if failure.
 671 Node* AddPNode::Ideal_base_and_offset(Node* ptr, PhaseTransform* phase,
 672                                       // second return value:
 673                                       intptr_t& offset) {
 674   if (ptr->is_AddP()) {
 675     Node* base = ptr->in(AddPNode::Base);
 676     Node* addr = ptr->in(AddPNode::Address);
 677     Node* offs = ptr->in(AddPNode::Offset);
 678     if (base == addr || base->is_top()) {
 679       offset = phase->find_intptr_t_con(offs, Type::OffsetBot);
 680       if (offset != Type::OffsetBot) {
 681         return addr;
 682       }
 683     }

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