src/share/vm/opto/castnode.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/opto

src/share/vm/opto/castnode.cpp

Print this page
rev 8016 : 8069191: moving predicate out of loops may cause array accesses to bypass null check
Summary: Remove CastPP nodes only during final graph reshape
Reviewed-by:


  56       break;
  57     }
  58     case Op_CastPP:
  59     if (phase->type(in(1)) == TypePtr::NULL_PTR &&
  60         _type->isa_ptr() && _type->is_ptr()->_ptr == TypePtr::NotNull)
  61     assert(ft == Type::TOP, "special case #3");
  62     break;
  63   }
  64 #endif //ASSERT
  65 
  66   return ft;
  67 }
  68 
  69 //------------------------------Ideal------------------------------------------
  70 // Return a node which is more "ideal" than the current node.  Strip out
  71 // control copies
  72 Node *ConstraintCastNode::Ideal(PhaseGVN *phase, bool can_reshape){
  73   return (in(0) && remove_dead_region(phase, can_reshape)) ? this : NULL;
  74 }
  75 
  76 //------------------------------Ideal_DU_postCCP-------------------------------
  77 // Throw away cast after constant propagation
  78 Node *ConstraintCastNode::Ideal_DU_postCCP( PhaseCCP *ccp ) {
  79   const Type *t = ccp->type(in(1));
  80   ccp->hash_delete(this);
  81   set_type(t);                   // Turn into ID function
  82   ccp->hash_insert(this);
  83   return this;
  84 }
  85 
  86 uint CastIINode::size_of() const {
  87   return sizeof(*this);
  88 }
  89 
  90 uint CastIINode::cmp(const Node &n) const {
  91   return TypeNode::cmp(n) && ((CastIINode&)n)._carry_dependency == _carry_dependency;
  92 }
  93 
  94 Node *CastIINode::Identity(PhaseTransform *phase) {
  95   if (_carry_dependency) {
  96     return this;
  97   }
  98   return ConstraintCastNode::Identity(phase);
  99 }
 100 
 101 const Type *CastIINode::Value(PhaseTransform *phase) const {
 102   const Type *res = ConstraintCastNode::Value(phase);
 103 
 104   // Try to improve the type of the CastII if we recognize a CmpI/If
 105   // pattern.


 147             if (lo_long != (jlong)lo_int) {
 148               lo_int = min_jint;
 149             }
 150             if (hi_long != (jlong)hi_int) {
 151               hi_int = max_jint;
 152             }
 153 
 154             t = TypeInt::make(lo_int, hi_int, Type::WidenMax);
 155 
 156             res = res->filter_speculative(t);
 157 
 158             return res;
 159           }
 160         }
 161       }
 162     }
 163   }
 164   return res;
 165 }
 166 
 167 Node *CastIINode::Ideal_DU_postCCP(PhaseCCP *ccp) {
 168   if (_carry_dependency) {
 169     return NULL;
 170   }
 171   return ConstraintCastNode::Ideal_DU_postCCP(ccp);
 172 }
 173 
 174 #ifndef PRODUCT
 175 void CastIINode::dump_spec(outputStream *st) const {
 176   TypeNode::dump_spec(st);
 177   if (_carry_dependency) {
 178     st->print(" carry dependency");
 179   }
 180 }
 181 #endif
 182 
 183 //=============================================================================
 184 
 185 //------------------------------Ideal_DU_postCCP-------------------------------
 186 // If not converting int->oop, throw away cast after constant propagation
 187 Node *CastPPNode::Ideal_DU_postCCP( PhaseCCP *ccp ) {
 188   const Type *t = ccp->type(in(1));
 189   if (!t->isa_oop_ptr() || ((in(1)->is_DecodeN()) && Matcher::gen_narrow_oop_implicit_null_checks())) {
 190     return NULL; // do not transform raw pointers or narrow oops
 191   }
 192   return ConstraintCastNode::Ideal_DU_postCCP(ccp);
 193 }
 194 
 195 
 196 
 197 //=============================================================================
 198 //------------------------------Identity---------------------------------------
 199 // If input is already higher or equal to cast type, then this is an identity.
 200 Node *CheckCastPPNode::Identity( PhaseTransform *phase ) {
 201   // Toned down to rescue meeting at a Phi 3 different oops all implementing
 202   // the same interface.  CompileTheWorld starting at 502, kd12rc1.zip.
 203   return (phase->type(in(1)) == phase->type(this)) ? in(1) : this;
 204 }
 205 
 206 //------------------------------Value------------------------------------------
 207 // Take 'join' of input and cast-up type, unless working with an Interface
 208 const Type *CheckCastPPNode::Value( PhaseTransform *phase ) const {
 209   if( in(0) && phase->type(in(0)) == Type::TOP ) return Type::TOP;
 210 
 211   const Type *inn = phase->type(in(1));
 212   if( inn == Type::TOP ) return Type::TOP;  // No information yet
 213 
 214   const TypePtr *in_type   = inn->isa_ptr();
 215   const TypePtr *my_type   = _type->isa_ptr();




  56       break;
  57     }
  58     case Op_CastPP:
  59     if (phase->type(in(1)) == TypePtr::NULL_PTR &&
  60         _type->isa_ptr() && _type->is_ptr()->_ptr == TypePtr::NotNull)
  61     assert(ft == Type::TOP, "special case #3");
  62     break;
  63   }
  64 #endif //ASSERT
  65 
  66   return ft;
  67 }
  68 
  69 //------------------------------Ideal------------------------------------------
  70 // Return a node which is more "ideal" than the current node.  Strip out
  71 // control copies
  72 Node *ConstraintCastNode::Ideal(PhaseGVN *phase, bool can_reshape){
  73   return (in(0) && remove_dead_region(phase, can_reshape)) ? this : NULL;
  74 }
  75 










  76 uint CastIINode::size_of() const {
  77   return sizeof(*this);
  78 }
  79 
  80 uint CastIINode::cmp(const Node &n) const {
  81   return TypeNode::cmp(n) && ((CastIINode&)n)._carry_dependency == _carry_dependency;
  82 }
  83 
  84 Node *CastIINode::Identity(PhaseTransform *phase) {
  85   if (_carry_dependency) {
  86     return this;
  87   }
  88   return ConstraintCastNode::Identity(phase);
  89 }
  90 
  91 const Type *CastIINode::Value(PhaseTransform *phase) const {
  92   const Type *res = ConstraintCastNode::Value(phase);
  93 
  94   // Try to improve the type of the CastII if we recognize a CmpI/If
  95   // pattern.


 137             if (lo_long != (jlong)lo_int) {
 138               lo_int = min_jint;
 139             }
 140             if (hi_long != (jlong)hi_int) {
 141               hi_int = max_jint;
 142             }
 143 
 144             t = TypeInt::make(lo_int, hi_int, Type::WidenMax);
 145 
 146             res = res->filter_speculative(t);
 147 
 148             return res;
 149           }
 150         }
 151       }
 152     }
 153   }
 154   return res;
 155 }
 156 







 157 #ifndef PRODUCT
 158 void CastIINode::dump_spec(outputStream *st) const {
 159   TypeNode::dump_spec(st);
 160   if (_carry_dependency) {
 161     st->print(" carry dependency");
 162   }
 163 }
 164 #endif














 165 
 166 //=============================================================================
 167 //------------------------------Identity---------------------------------------
 168 // If input is already higher or equal to cast type, then this is an identity.
 169 Node *CheckCastPPNode::Identity( PhaseTransform *phase ) {
 170   // Toned down to rescue meeting at a Phi 3 different oops all implementing
 171   // the same interface.  CompileTheWorld starting at 502, kd12rc1.zip.
 172   return (phase->type(in(1)) == phase->type(this)) ? in(1) : this;
 173 }
 174 
 175 //------------------------------Value------------------------------------------
 176 // Take 'join' of input and cast-up type, unless working with an Interface
 177 const Type *CheckCastPPNode::Value( PhaseTransform *phase ) const {
 178   if( in(0) && phase->type(in(0)) == Type::TOP ) return Type::TOP;
 179 
 180   const Type *inn = phase->type(in(1));
 181   if( inn == Type::TOP ) return Type::TOP;  // No information yet
 182 
 183   const TypePtr *in_type   = inn->isa_ptr();
 184   const TypePtr *my_type   = _type->isa_ptr();


src/share/vm/opto/castnode.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File