548 //------------------------------Ideal------------------------------------------
549 // Return a node which is more "ideal" than the current node. Strip out
550 // control copies
551 Node *CheckCastPPNode::Ideal(PhaseGVN *phase, bool can_reshape){
552 return (in(0) && remove_dead_region(phase, can_reshape)) ? this : NULL;
553 }
554
555
556 Node* DecodeNNode::Identity(PhaseTransform* phase) {
557 const Type *t = phase->type( in(1) );
558 if( t == Type::TOP ) return in(1);
559
560 if (in(1)->is_EncodeP()) {
561 // (DecodeN (EncodeP p)) -> p
562 return in(1)->in(1);
563 }
564 return this;
565 }
566
567 const Type *DecodeNNode::Value( PhaseTransform *phase ) const {
568 if (phase->type( in(1) ) == TypeNarrowOop::NULL_PTR) {
569 return TypePtr::NULL_PTR;
570 }
571 return bottom_type();
572 }
573
574 Node* DecodeNNode::decode(PhaseTransform* phase, Node* value) {
575 if (value->is_EncodeP()) {
576 // (DecodeN (EncodeP p)) -> p
577 return value->in(1);
578 }
579 const Type* newtype = value->bottom_type();
580 if (newtype == TypeNarrowOop::NULL_PTR) {
581 return phase->transform(new (phase->C, 1) ConPNode(TypePtr::NULL_PTR));
582 } else if (newtype->isa_narrowoop()) {
583 return phase->transform(new (phase->C, 2) DecodeNNode(value, newtype->is_narrowoop()->make_oopptr()));
584 } else {
585 ShouldNotReachHere();
586 return NULL; // to make C++ compiler happy.
587 }
588 }
589
590 Node* EncodePNode::Identity(PhaseTransform* phase) {
591 const Type *t = phase->type( in(1) );
592 if( t == Type::TOP ) return in(1);
593
594 if (in(1)->is_DecodeN()) {
595 // (EncodeP (DecodeN p)) -> p
596 return in(1)->in(1);
597 }
598 return this;
599 }
600
601 const Type *EncodePNode::Value( PhaseTransform *phase ) const {
602 if (phase->type( in(1) ) == TypePtr::NULL_PTR) {
603 return TypeNarrowOop::NULL_PTR;
604 }
605 return bottom_type();
606 }
607
608 Node* EncodePNode::encode(PhaseTransform* phase, Node* value) {
609 if (value->is_DecodeN()) {
610 // (EncodeP (DecodeN p)) -> p
611 return value->in(1);
612 }
613 const Type* newtype = value->bottom_type();
614 if (newtype == TypePtr::NULL_PTR) {
615 return phase->transform(new (phase->C, 1) ConNNode(TypeNarrowOop::NULL_PTR));
616 } else if (newtype->isa_oopptr()) {
617 return phase->transform(new (phase->C, 2) EncodePNode(value, newtype->is_oopptr()->make_narrowoop()));
618 } else {
619 ShouldNotReachHere();
620 return NULL; // to make C++ compiler happy.
621 }
622 }
623
624 Node *EncodePNode::Ideal_DU_postCCP( PhaseCCP *ccp ) {
625 return MemNode::Ideal_common_DU_postCCP(ccp, this, in(1));
|
548 //------------------------------Ideal------------------------------------------
549 // Return a node which is more "ideal" than the current node. Strip out
550 // control copies
551 Node *CheckCastPPNode::Ideal(PhaseGVN *phase, bool can_reshape){
552 return (in(0) && remove_dead_region(phase, can_reshape)) ? this : NULL;
553 }
554
555
556 Node* DecodeNNode::Identity(PhaseTransform* phase) {
557 const Type *t = phase->type( in(1) );
558 if( t == Type::TOP ) return in(1);
559
560 if (in(1)->is_EncodeP()) {
561 // (DecodeN (EncodeP p)) -> p
562 return in(1)->in(1);
563 }
564 return this;
565 }
566
567 const Type *DecodeNNode::Value( PhaseTransform *phase ) const {
568 const Type *t = phase->type( in(1) );
569 if (t == Type::TOP) return Type::TOP;
570 if (t == TypeNarrowOop::NULL_PTR) return TypePtr::NULL_PTR;
571
572 assert(t->isa_narrowoop(), "only narrowoop here");
573 return t->is_narrowoop()->make_oopptr();
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 }
591
592 Node* EncodePNode::Identity(PhaseTransform* phase) {
593 const Type *t = phase->type( in(1) );
594 if( t == Type::TOP ) return in(1);
595
596 if (in(1)->is_DecodeN()) {
597 // (EncodeP (DecodeN p)) -> p
598 return in(1)->in(1);
599 }
600 return this;
601 }
602
603 const Type *EncodePNode::Value( PhaseTransform *phase ) const {
604 const Type *t = phase->type( in(1) );
605 if (t == Type::TOP) return Type::TOP;
606 if (t == TypePtr::NULL_PTR) return TypeNarrowOop::NULL_PTR;
607
608 assert(t->isa_oopptr(), "only oopptr here");
609 return t->is_oopptr()->make_narrowoop();
610 }
611
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
628 Node *EncodePNode::Ideal_DU_postCCP( PhaseCCP *ccp ) {
629 return MemNode::Ideal_common_DU_postCCP(ccp, this, in(1));
|