< prev index next >

src/share/vm/opto/castnode.cpp

Print this page




  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "opto/addnode.hpp"
  27 #include "opto/callnode.hpp"
  28 #include "opto/castnode.hpp"
  29 #include "opto/connode.hpp"
  30 #include "opto/matcher.hpp"
  31 #include "opto/phaseX.hpp"
  32 #include "opto/subnode.hpp"
  33 #include "opto/type.hpp"
  34 
  35 //=============================================================================
  36 // If input is already higher or equal to cast type, then this is an identity.
  37 Node* ConstraintCastNode::Identity(PhaseGVN* phase) {
  38   Node* dom = dominating_cast(phase);
  39   if (dom != NULL) {
  40     return dom;
  41   }
  42   if (_carry_dependency) {
  43     return this;
  44   }
  45   return phase->type(in(1))->higher_equal_speculative(_type) ? in(1) : this;
  46 }
  47 
  48 //------------------------------Value------------------------------------------
  49 // Take 'join' of input and cast-up type
  50 const Type* ConstraintCastNode::Value(PhaseGVN* phase) const {
  51   if (in(0) && phase->type(in(0)) == Type::TOP) return Type::TOP;
  52   const Type* ft = phase->type(in(1))->filter_speculative(_type);
  53 
  54 #ifdef ASSERT
  55   // Previous versions of this function had some special case logic,
  56   // which is no longer necessary.  Make sure of the required effects.
  57   switch (Opcode()) {
  58     case Op_CastII:


  91 
  92 Node* ConstraintCastNode::make_cast(int opcode, Node* c, Node *n, const Type *t, bool carry_dependency) {
  93   switch(opcode) {
  94   case Op_CastII: {
  95     Node* cast = new CastIINode(n, t, carry_dependency);
  96     cast->set_req(0, c);
  97     return cast;
  98   }
  99   case Op_CastPP: {
 100     Node* cast = new CastPPNode(n, t, carry_dependency);
 101     cast->set_req(0, c);
 102     return cast;
 103   }
 104   case Op_CheckCastPP: return new CheckCastPPNode(c, n, t, carry_dependency);
 105   default:
 106     fatal("Bad opcode %d", opcode);
 107   }
 108   return NULL;
 109 }
 110 
 111 TypeNode* ConstraintCastNode::dominating_cast(PhaseTransform *phase) const {
 112   Node* val = in(1);
 113   Node* ctl = in(0);
 114   int opc = Opcode();
 115   if (ctl == NULL) {
 116     return NULL;
 117   }
 118   // Range check CastIIs may all end up under a single range check and
 119   // in that case only the narrower CastII would be kept by the code
 120   // below which would be incorrect.
 121   if (is_CastII() && as_CastII()->has_range_check()) {
 122     return NULL;
 123   }
 124   if (type()->isa_rawptr() && (phase->type_or_null(val) == NULL || phase->type(val)->isa_oopptr())) {
 125     return NULL;
 126   }
 127   for (DUIterator_Fast imax, i = val->fast_outs(imax); i < imax; i++) {
 128     Node* u = val->fast_out(i);
 129     if (u != this &&
 130         u->outcnt() > 0 &&
 131         u->Opcode() == opc &&
 132         u->in(0) != NULL &&
 133         u->bottom_type()->higher_equal(type())) {
 134       if (phase->is_dominator(u->in(0), ctl)) {
 135         return u->as_Type();
 136       }
 137       if (is_CheckCastPP() && u->in(1)->is_Proj() && u->in(1)->in(0)->is_Allocate() &&
 138           u->in(0)->is_Proj() && u->in(0)->in(0)->is_Initialize() &&
 139           u->in(1)->in(0)->as_Allocate()->initialization() == u->in(0)->in(0)) {
 140         // CheckCastPP following an allocation always dominates all
 141         // use of the allocation result
 142         return u->as_Type();
 143       }
 144     }
 145   }
 146   return NULL;
 147 }
 148 
 149 #ifndef PRODUCT
 150 void ConstraintCastNode::dump_spec(outputStream *st) const {
 151   TypeNode::dump_spec(st);
 152   if (_carry_dependency) {
 153     st->print(" carry dependency");
 154   }


 266   return ConstraintCastNode::cmp(n) && ((CastIINode&)n)._range_check_dependency == _range_check_dependency;
 267 }
 268 
 269 uint CastIINode::size_of() const {
 270   return sizeof(*this);
 271 }
 272 
 273 #ifndef PRODUCT
 274 void CastIINode::dump_spec(outputStream* st) const {
 275   ConstraintCastNode::dump_spec(st);
 276   if (_range_check_dependency) {
 277     st->print(" range check dependency");
 278   }
 279 }
 280 #endif
 281 
 282 //=============================================================================
 283 //------------------------------Identity---------------------------------------
 284 // If input is already higher or equal to cast type, then this is an identity.
 285 Node* CheckCastPPNode::Identity(PhaseGVN* phase) {
 286   Node* dom = dominating_cast(phase);
 287   if (dom != NULL) {
 288     return dom;
 289   }
 290   if (_carry_dependency) {
 291     return this;
 292   }
 293   // Toned down to rescue meeting at a Phi 3 different oops all implementing
 294   // the same interface.  CompileTheWorld starting at 502, kd12rc1.zip.
 295   return (phase->type(in(1)) == phase->type(this)) ? in(1) : this;
 296 }
 297 
 298 //------------------------------Value------------------------------------------
 299 // Take 'join' of input and cast-up type, unless working with an Interface
 300 const Type* CheckCastPPNode::Value(PhaseGVN* phase) const {
 301   if( in(0) && phase->type(in(0)) == Type::TOP ) return Type::TOP;
 302 
 303   const Type *inn = phase->type(in(1));
 304   if( inn == Type::TOP ) return Type::TOP;  // No information yet
 305 
 306   const TypePtr *in_type   = inn->isa_ptr();




  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "opto/addnode.hpp"
  27 #include "opto/callnode.hpp"
  28 #include "opto/castnode.hpp"
  29 #include "opto/connode.hpp"
  30 #include "opto/matcher.hpp"
  31 #include "opto/phaseX.hpp"
  32 #include "opto/subnode.hpp"
  33 #include "opto/type.hpp"
  34 
  35 //=============================================================================
  36 // If input is already higher or equal to cast type, then this is an identity.
  37 Node* ConstraintCastNode::Identity(PhaseGVN* phase) {
  38   Node* dom = dominating_cast(phase, phase);
  39   if (dom != NULL) {
  40     return dom;
  41   }
  42   if (_carry_dependency) {
  43     return this;
  44   }
  45   return phase->type(in(1))->higher_equal_speculative(_type) ? in(1) : this;
  46 }
  47 
  48 //------------------------------Value------------------------------------------
  49 // Take 'join' of input and cast-up type
  50 const Type* ConstraintCastNode::Value(PhaseGVN* phase) const {
  51   if (in(0) && phase->type(in(0)) == Type::TOP) return Type::TOP;
  52   const Type* ft = phase->type(in(1))->filter_speculative(_type);
  53 
  54 #ifdef ASSERT
  55   // Previous versions of this function had some special case logic,
  56   // which is no longer necessary.  Make sure of the required effects.
  57   switch (Opcode()) {
  58     case Op_CastII:


  91 
  92 Node* ConstraintCastNode::make_cast(int opcode, Node* c, Node *n, const Type *t, bool carry_dependency) {
  93   switch(opcode) {
  94   case Op_CastII: {
  95     Node* cast = new CastIINode(n, t, carry_dependency);
  96     cast->set_req(0, c);
  97     return cast;
  98   }
  99   case Op_CastPP: {
 100     Node* cast = new CastPPNode(n, t, carry_dependency);
 101     cast->set_req(0, c);
 102     return cast;
 103   }
 104   case Op_CheckCastPP: return new CheckCastPPNode(c, n, t, carry_dependency);
 105   default:
 106     fatal("Bad opcode %d", opcode);
 107   }
 108   return NULL;
 109 }
 110 
 111 TypeNode* ConstraintCastNode::dominating_cast(PhaseGVN* gvn, PhaseTransform* pt) const {
 112   Node* val = in(1);
 113   Node* ctl = in(0);
 114   int opc = Opcode();
 115   if (ctl == NULL) {
 116     return NULL;
 117   }
 118   // Range check CastIIs may all end up under a single range check and
 119   // in that case only the narrower CastII would be kept by the code
 120   // below which would be incorrect.
 121   if (is_CastII() && as_CastII()->has_range_check()) {
 122     return NULL;
 123   }
 124   if (type()->isa_rawptr() && (gvn->type_or_null(val) == NULL || gvn->type(val)->isa_oopptr())) {
 125     return NULL;
 126   }
 127   for (DUIterator_Fast imax, i = val->fast_outs(imax); i < imax; i++) {
 128     Node* u = val->fast_out(i);
 129     if (u != this &&
 130         u->outcnt() > 0 &&
 131         u->Opcode() == opc &&
 132         u->in(0) != NULL &&
 133         u->bottom_type()->higher_equal(type())) {
 134       if (pt->is_dominator(u->in(0), ctl)) {
 135         return u->as_Type();
 136       }
 137       if (is_CheckCastPP() && u->in(1)->is_Proj() && u->in(1)->in(0)->is_Allocate() &&
 138           u->in(0)->is_Proj() && u->in(0)->in(0)->is_Initialize() &&
 139           u->in(1)->in(0)->as_Allocate()->initialization() == u->in(0)->in(0)) {
 140         // CheckCastPP following an allocation always dominates all
 141         // use of the allocation result
 142         return u->as_Type();
 143       }
 144     }
 145   }
 146   return NULL;
 147 }
 148 
 149 #ifndef PRODUCT
 150 void ConstraintCastNode::dump_spec(outputStream *st) const {
 151   TypeNode::dump_spec(st);
 152   if (_carry_dependency) {
 153     st->print(" carry dependency");
 154   }


 266   return ConstraintCastNode::cmp(n) && ((CastIINode&)n)._range_check_dependency == _range_check_dependency;
 267 }
 268 
 269 uint CastIINode::size_of() const {
 270   return sizeof(*this);
 271 }
 272 
 273 #ifndef PRODUCT
 274 void CastIINode::dump_spec(outputStream* st) const {
 275   ConstraintCastNode::dump_spec(st);
 276   if (_range_check_dependency) {
 277     st->print(" range check dependency");
 278   }
 279 }
 280 #endif
 281 
 282 //=============================================================================
 283 //------------------------------Identity---------------------------------------
 284 // If input is already higher or equal to cast type, then this is an identity.
 285 Node* CheckCastPPNode::Identity(PhaseGVN* phase) {
 286   Node* dom = dominating_cast(phase, phase);
 287   if (dom != NULL) {
 288     return dom;
 289   }
 290   if (_carry_dependency) {
 291     return this;
 292   }
 293   // Toned down to rescue meeting at a Phi 3 different oops all implementing
 294   // the same interface.  CompileTheWorld starting at 502, kd12rc1.zip.
 295   return (phase->type(in(1)) == phase->type(this)) ? in(1) : this;
 296 }
 297 
 298 //------------------------------Value------------------------------------------
 299 // Take 'join' of input and cast-up type, unless working with an Interface
 300 const Type* CheckCastPPNode::Value(PhaseGVN* phase) const {
 301   if( in(0) && phase->type(in(0)) == Type::TOP ) return Type::TOP;
 302 
 303   const Type *inn = phase->type(in(1));
 304   if( inn == Type::TOP ) return Type::TOP;  // No information yet
 305 
 306   const TypePtr *in_type   = inn->isa_ptr();


< prev index next >