< prev index next >

src/share/vm/opto/addnode.cpp

Print this page




 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 (t1->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 t1->is_aryptr()->with_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       }




 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()->with_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 >