src/share/vm/opto/connode.cpp

Print this page




  37 // Optimization - Graph Style
  38 
  39 //=============================================================================
  40 //------------------------------hash-------------------------------------------
  41 uint ConNode::hash() const {
  42   return (uintptr_t)in(TypeFunc::Control) + _type->hash();
  43 }
  44 
  45 //------------------------------make-------------------------------------------
  46 ConNode *ConNode::make( Compile* C, const Type *t ) {
  47   switch( t->basic_type() ) {
  48   case T_INT:       return new (C) ConINode( t->is_int() );
  49   case T_LONG:      return new (C) ConLNode( t->is_long() );
  50   case T_FLOAT:     return new (C) ConFNode( t->is_float_constant() );
  51   case T_DOUBLE:    return new (C) ConDNode( t->is_double_constant() );
  52   case T_VOID:      return new (C) ConNode ( Type::TOP );
  53   case T_OBJECT:    return new (C) ConPNode( t->is_ptr() );
  54   case T_ARRAY:     return new (C) ConPNode( t->is_aryptr() );
  55   case T_ADDRESS:   return new (C) ConPNode( t->is_ptr() );
  56   case T_NARROWOOP: return new (C) ConNNode( t->is_narrowoop() );

  57   case T_METADATA:  return new (C) ConPNode( t->is_ptr() );
  58     // Expected cases:  TypePtr::NULL_PTR, any is_rawptr()
  59     // Also seen: AnyPtr(TopPTR *+top); from command line:
  60     //   r -XX:+PrintOpto -XX:CIStart=285 -XX:+CompileTheWorld -XX:CompileTheWorldStartAt=660
  61     // %%%% Stop using TypePtr::NULL_PTR to represent nulls:  use either TypeRawPtr::NULL_PTR
  62     // or else TypeOopPtr::NULL_PTR.  Then set Type::_basic_type[AnyPtr] = T_ILLEGAL
  63   }
  64   ShouldNotReachHere();
  65   return NULL;
  66 }
  67 
  68 //=============================================================================
  69 /*
  70 The major change is for CMoveP and StrComp.  They have related but slightly
  71 different problems.  They both take in TWO oops which are both null-checked
  72 independently before the using Node.  After CCP removes the CastPP's they need
  73 to pick up the guarding test edge - in this case TWO control edges.  I tried
  74 various solutions, all have problems:
  75 
  76 (1) Do nothing.  This leads to a bug where we hoist a Load from a CMoveP or a


 430   return (in(0) && remove_dead_region(phase, can_reshape)) ? this : NULL;
 431 }
 432 
 433 //------------------------------Ideal_DU_postCCP-------------------------------
 434 // Throw away cast after constant propagation
 435 Node *ConstraintCastNode::Ideal_DU_postCCP( PhaseCCP *ccp ) {
 436   const Type *t = ccp->type(in(1));
 437   ccp->hash_delete(this);
 438   set_type(t);                   // Turn into ID function
 439   ccp->hash_insert(this);
 440   return this;
 441 }
 442 
 443 
 444 //=============================================================================
 445 
 446 //------------------------------Ideal_DU_postCCP-------------------------------
 447 // If not converting int->oop, throw away cast after constant propagation
 448 Node *CastPPNode::Ideal_DU_postCCP( PhaseCCP *ccp ) {
 449   const Type *t = ccp->type(in(1));
 450   if (!t->isa_oop_ptr() || (in(1)->is_DecodeN() && Matcher::gen_narrow_oop_implicit_null_checks())) {
 451     return NULL; // do not transform raw pointers or narrow oops
 452   }
 453   return ConstraintCastNode::Ideal_DU_postCCP(ccp);
 454 }
 455 
 456 
 457 
 458 //=============================================================================
 459 //------------------------------Identity---------------------------------------
 460 // If input is already higher or equal to cast type, then this is an identity.
 461 Node *CheckCastPPNode::Identity( PhaseTransform *phase ) {
 462   // Toned down to rescue meeting at a Phi 3 different oops all implementing
 463   // the same interface.  CompileTheWorld starting at 502, kd12rc1.zip.
 464   return (phase->type(in(1)) == phase->type(this)) ? in(1) : this;
 465 }
 466 
 467 // Determine whether "n" is a node which can cause an alias of one of its inputs.  Node types
 468 // which can create aliases are: CheckCastPP, Phi, and any store (if there is also a load from
 469 // the location.)
 470 // Note:  this checks for aliases created in this compilation, not ones which may


 590   assert(t->isa_narrowoop(), "only  narrowoop here");
 591   return t->make_ptr();
 592 }
 593 
 594 Node* EncodePNode::Identity(PhaseTransform* phase) {
 595   const Type *t = phase->type( in(1) );
 596   if( t == Type::TOP ) return in(1);
 597 
 598   if (in(1)->is_DecodeN()) {
 599     // (EncodeP (DecodeN p)) -> p
 600     return in(1)->in(1);
 601   }
 602   return this;
 603 }
 604 
 605 const Type *EncodePNode::Value( PhaseTransform *phase ) const {
 606   const Type *t = phase->type( in(1) );
 607   if (t == Type::TOP) return Type::TOP;
 608   if (t == TypePtr::NULL_PTR) return TypeNarrowOop::NULL_PTR;
 609 
 610   assert(t->isa_oop_ptr() || UseCompressedKlassPointers && t->isa_klassptr(), "only oopptr here");
 611   return t->make_narrowoop();
 612 }
 613 
 614 
 615 Node *EncodePNode::Ideal_DU_postCCP( PhaseCCP *ccp ) {
 616   return MemNode::Ideal_common_DU_postCCP(ccp, this, in(1));
 617 }









































 618 
 619 //=============================================================================
 620 //------------------------------Identity---------------------------------------
 621 Node *Conv2BNode::Identity( PhaseTransform *phase ) {
 622   const Type *t = phase->type( in(1) );
 623   if( t == Type::TOP ) return in(1);
 624   if( t == TypeInt::ZERO ) return in(1);
 625   if( t == TypeInt::ONE ) return in(1);
 626   if( t == TypeInt::BOOL ) return in(1);
 627   return this;
 628 }
 629 
 630 //------------------------------Value------------------------------------------
 631 const Type *Conv2BNode::Value( PhaseTransform *phase ) const {
 632   const Type *t = phase->type( in(1) );
 633   if( t == Type::TOP ) return Type::TOP;
 634   if( t == TypeInt::ZERO ) return TypeInt::ZERO;
 635   if( t == TypePtr::NULL_PTR ) return TypeInt::ZERO;
 636   const TypePtr *tp = t->isa_ptr();
 637   if( tp != NULL ) {




  37 // Optimization - Graph Style
  38 
  39 //=============================================================================
  40 //------------------------------hash-------------------------------------------
  41 uint ConNode::hash() const {
  42   return (uintptr_t)in(TypeFunc::Control) + _type->hash();
  43 }
  44 
  45 //------------------------------make-------------------------------------------
  46 ConNode *ConNode::make( Compile* C, const Type *t ) {
  47   switch( t->basic_type() ) {
  48   case T_INT:         return new (C) ConINode( t->is_int() );
  49   case T_LONG:        return new (C) ConLNode( t->is_long() );
  50   case T_FLOAT:       return new (C) ConFNode( t->is_float_constant() );
  51   case T_DOUBLE:      return new (C) ConDNode( t->is_double_constant() );
  52   case T_VOID:        return new (C) ConNode ( Type::TOP );
  53   case T_OBJECT:      return new (C) ConPNode( t->is_ptr() );
  54   case T_ARRAY:       return new (C) ConPNode( t->is_aryptr() );
  55   case T_ADDRESS:     return new (C) ConPNode( t->is_ptr() );
  56   case T_NARROWOOP:   return new (C) ConNNode( t->is_narrowoop() );
  57   case T_NARROWKLASS: return new (C) ConNKlassNode( t->is_narrowklass() );
  58   case T_METADATA:    return new (C) ConPNode( t->is_ptr() );
  59     // Expected cases:  TypePtr::NULL_PTR, any is_rawptr()
  60     // Also seen: AnyPtr(TopPTR *+top); from command line:
  61     //   r -XX:+PrintOpto -XX:CIStart=285 -XX:+CompileTheWorld -XX:CompileTheWorldStartAt=660
  62     // %%%% Stop using TypePtr::NULL_PTR to represent nulls:  use either TypeRawPtr::NULL_PTR
  63     // or else TypeOopPtr::NULL_PTR.  Then set Type::_basic_type[AnyPtr] = T_ILLEGAL
  64   }
  65   ShouldNotReachHere();
  66   return NULL;
  67 }
  68 
  69 //=============================================================================
  70 /*
  71 The major change is for CMoveP and StrComp.  They have related but slightly
  72 different problems.  They both take in TWO oops which are both null-checked
  73 independently before the using Node.  After CCP removes the CastPP's they need
  74 to pick up the guarding test edge - in this case TWO control edges.  I tried
  75 various solutions, all have problems:
  76 
  77 (1) Do nothing.  This leads to a bug where we hoist a Load from a CMoveP or a


 431   return (in(0) && remove_dead_region(phase, can_reshape)) ? this : NULL;
 432 }
 433 
 434 //------------------------------Ideal_DU_postCCP-------------------------------
 435 // Throw away cast after constant propagation
 436 Node *ConstraintCastNode::Ideal_DU_postCCP( PhaseCCP *ccp ) {
 437   const Type *t = ccp->type(in(1));
 438   ccp->hash_delete(this);
 439   set_type(t);                   // Turn into ID function
 440   ccp->hash_insert(this);
 441   return this;
 442 }
 443 
 444 
 445 //=============================================================================
 446 
 447 //------------------------------Ideal_DU_postCCP-------------------------------
 448 // If not converting int->oop, throw away cast after constant propagation
 449 Node *CastPPNode::Ideal_DU_postCCP( PhaseCCP *ccp ) {
 450   const Type *t = ccp->type(in(1));
 451   if (!t->isa_oop_ptr() || ((in(1)->is_DecodeN()) && Matcher::gen_narrow_oop_implicit_null_checks())) {
 452     return NULL; // do not transform raw pointers or narrow oops
 453   }
 454   return ConstraintCastNode::Ideal_DU_postCCP(ccp);
 455 }
 456 
 457 
 458 
 459 //=============================================================================
 460 //------------------------------Identity---------------------------------------
 461 // If input is already higher or equal to cast type, then this is an identity.
 462 Node *CheckCastPPNode::Identity( PhaseTransform *phase ) {
 463   // Toned down to rescue meeting at a Phi 3 different oops all implementing
 464   // the same interface.  CompileTheWorld starting at 502, kd12rc1.zip.
 465   return (phase->type(in(1)) == phase->type(this)) ? in(1) : this;
 466 }
 467 
 468 // Determine whether "n" is a node which can cause an alias of one of its inputs.  Node types
 469 // which can create aliases are: CheckCastPP, Phi, and any store (if there is also a load from
 470 // the location.)
 471 // Note:  this checks for aliases created in this compilation, not ones which may


 591   assert(t->isa_narrowoop(), "only  narrowoop here");
 592   return t->make_ptr();
 593 }
 594 
 595 Node* EncodePNode::Identity(PhaseTransform* phase) {
 596   const Type *t = phase->type( in(1) );
 597   if( t == Type::TOP ) return in(1);
 598 
 599   if (in(1)->is_DecodeN()) {
 600     // (EncodeP (DecodeN p)) -> p
 601     return in(1)->in(1);
 602   }
 603   return this;
 604 }
 605 
 606 const Type *EncodePNode::Value( PhaseTransform *phase ) const {
 607   const Type *t = phase->type( in(1) );
 608   if (t == Type::TOP) return Type::TOP;
 609   if (t == TypePtr::NULL_PTR) return TypeNarrowOop::NULL_PTR;
 610 
 611   assert(t->isa_oop_ptr(), "only oopptr here");
 612   return t->make_narrowoop();
 613 }
 614 
 615 
 616 Node *EncodeNarrowPtrNode::Ideal_DU_postCCP( PhaseCCP *ccp ) {
 617   return MemNode::Ideal_common_DU_postCCP(ccp, this, in(1));
 618 }
 619 
 620 Node* DecodeNKlassNode::Identity(PhaseTransform* phase) {
 621   const Type *t = phase->type( in(1) );
 622   if( t == Type::TOP ) return in(1);
 623 
 624   if (in(1)->is_EncodePKlass()) {
 625     // (DecodeNKlass (EncodePKlass p)) -> p
 626     return in(1)->in(1);
 627   }
 628   return this;
 629 }
 630 
 631 const Type *DecodeNKlassNode::Value( PhaseTransform *phase ) const {
 632   const Type *t = phase->type( in(1) );
 633   if (t == Type::TOP) return Type::TOP;
 634   assert(t != TypeNarrowKlass::NULL_PTR, "null klass?");
 635 
 636   assert(t->isa_narrowklass(), "only narrow klass ptr here");
 637   return t->make_ptr();
 638 }
 639 
 640 Node* EncodePKlassNode::Identity(PhaseTransform* phase) {
 641   const Type *t = phase->type( in(1) );
 642   if( t == Type::TOP ) return in(1);
 643 
 644   if (in(1)->is_DecodeNKlass()) {
 645     // (EncodePKlass (DecodeNKlass p)) -> p
 646     return in(1)->in(1);
 647   }
 648   return this;
 649 }
 650 
 651 const Type *EncodePKlassNode::Value( PhaseTransform *phase ) const {
 652   const Type *t = phase->type( in(1) );
 653   if (t == Type::TOP) return Type::TOP;
 654   assert (t != TypePtr::NULL_PTR, "null klass?");
 655 
 656   assert(UseCompressedKlassPointers && t->isa_klassptr(), "only klass ptr here");
 657   return t->make_narrowklass();
 658 }
 659 
 660 
 661 //=============================================================================
 662 //------------------------------Identity---------------------------------------
 663 Node *Conv2BNode::Identity( PhaseTransform *phase ) {
 664   const Type *t = phase->type( in(1) );
 665   if( t == Type::TOP ) return in(1);
 666   if( t == TypeInt::ZERO ) return in(1);
 667   if( t == TypeInt::ONE ) return in(1);
 668   if( t == TypeInt::BOOL ) return in(1);
 669   return this;
 670 }
 671 
 672 //------------------------------Value------------------------------------------
 673 const Type *Conv2BNode::Value( PhaseTransform *phase ) const {
 674   const Type *t = phase->type( in(1) );
 675   if( t == Type::TOP ) return Type::TOP;
 676   if( t == TypeInt::ZERO ) return TypeInt::ZERO;
 677   if( t == TypePtr::NULL_PTR ) return TypeInt::ZERO;
 678   const TypePtr *tp = t->isa_ptr();
 679   if( tp != NULL ) {