568 const Type *t = phase->type( in(1) ); |
568 const Type *t = phase->type( in(1) ); |
569 if (t == Type::TOP) return Type::TOP; |
569 if (t == Type::TOP) return Type::TOP; |
570 if (t == TypeNarrowOop::NULL_PTR) return TypePtr::NULL_PTR; |
570 if (t == TypeNarrowOop::NULL_PTR) return TypePtr::NULL_PTR; |
571 |
571 |
572 assert(t->isa_narrowoop(), "only narrowoop here"); |
572 assert(t->isa_narrowoop(), "only narrowoop here"); |
573 return t->is_narrowoop()->make_oopptr(); |
573 return t->make_ptr(); |
574 } |
|
575 |
|
576 Node* DecodeNNode::decode(PhaseTransform* phase, Node* value) { |
|
577 if (value->is_EncodeP()) { |
|
578 // (DecodeN (EncodeP p)) -> p |
|
579 return value->in(1); |
|
580 } |
|
581 const Type* newtype = value->bottom_type(); |
|
582 if (newtype == TypeNarrowOop::NULL_PTR) { |
|
583 return phase->transform(new (phase->C, 1) ConPNode(TypePtr::NULL_PTR)); |
|
584 } else if (newtype->isa_narrowoop()) { |
|
585 return phase->transform(new (phase->C, 2) DecodeNNode(value, newtype->is_narrowoop()->make_oopptr())); |
|
586 } else { |
|
587 ShouldNotReachHere(); |
|
588 return NULL; // to make C++ compiler happy. |
|
589 } |
|
590 } |
574 } |
591 |
575 |
592 Node* EncodePNode::Identity(PhaseTransform* phase) { |
576 Node* EncodePNode::Identity(PhaseTransform* phase) { |
593 const Type *t = phase->type( in(1) ); |
577 const Type *t = phase->type( in(1) ); |
594 if( t == Type::TOP ) return in(1); |
578 if( t == Type::TOP ) return in(1); |
604 const Type *t = phase->type( in(1) ); |
588 const Type *t = phase->type( in(1) ); |
605 if (t == Type::TOP) return Type::TOP; |
589 if (t == Type::TOP) return Type::TOP; |
606 if (t == TypePtr::NULL_PTR) return TypeNarrowOop::NULL_PTR; |
590 if (t == TypePtr::NULL_PTR) return TypeNarrowOop::NULL_PTR; |
607 |
591 |
608 assert(t->isa_oopptr(), "only oopptr here"); |
592 assert(t->isa_oopptr(), "only oopptr here"); |
609 return t->is_oopptr()->make_narrowoop(); |
593 return t->make_narrowoop(); |
610 } |
594 } |
611 |
595 |
612 Node* EncodePNode::encode(PhaseTransform* phase, Node* value) { |
|
613 if (value->is_DecodeN()) { |
|
614 // (EncodeP (DecodeN p)) -> p |
|
615 return value->in(1); |
|
616 } |
|
617 const Type* newtype = value->bottom_type(); |
|
618 if (newtype == TypePtr::NULL_PTR) { |
|
619 return phase->transform(new (phase->C, 1) ConNNode(TypeNarrowOop::NULL_PTR)); |
|
620 } else if (newtype->isa_oopptr()) { |
|
621 return phase->transform(new (phase->C, 2) EncodePNode(value, newtype->is_oopptr()->make_narrowoop())); |
|
622 } else { |
|
623 ShouldNotReachHere(); |
|
624 return NULL; // to make C++ compiler happy. |
|
625 } |
|
626 } |
|
627 |
596 |
628 Node *EncodePNode::Ideal_DU_postCCP( PhaseCCP *ccp ) { |
597 Node *EncodePNode::Ideal_DU_postCCP( PhaseCCP *ccp ) { |
629 return MemNode::Ideal_common_DU_postCCP(ccp, this, in(1)); |
598 return MemNode::Ideal_common_DU_postCCP(ccp, this, in(1)); |
630 } |
599 } |
631 |
600 |