< prev index next >

src/hotspot/share/opto/castnode.cpp

Print this page




  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  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 


 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.
 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 


 445     break;
 446   }
 447   return NULL;
 448 }
 449 
 450 //------------------------------Identity---------------------------------------
 451 Node* CastX2PNode::Identity(PhaseGVN* phase) {
 452   if (in(1)->Opcode() == Op_CastP2X)  return in(1)->in(1);
 453   return this;
 454 }
 455 
 456 //=============================================================================
 457 //------------------------------Value------------------------------------------
 458 const Type* CastP2XNode::Value(PhaseGVN* phase) const {
 459   const Type* t = phase->type(in(1));
 460   if (t == Type::TOP) return Type::TOP;
 461   if (t->base() == Type::RawPtr && t->singleton()) {
 462     uintptr_t bits = (uintptr_t) t->is_rawptr()->get_con();
 463     return TypeX::make(bits);
 464   }
















 465   return CastP2XNode::bottom_type();
 466 }
 467 
 468 Node *CastP2XNode::Ideal(PhaseGVN *phase, bool can_reshape) {
 469   return (in(0) && remove_dead_region(phase, can_reshape)) ? this : NULL;
 470 }
 471 
 472 //------------------------------Identity---------------------------------------
 473 Node* CastP2XNode::Identity(PhaseGVN* phase) {
 474   if (in(1)->Opcode() == Op_CastX2P)  return in(1)->in(1);
 475   return this;
 476 }


  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  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/graphKit.hpp"
  31 #include "opto/matcher.hpp"
  32 #include "opto/phaseX.hpp"
  33 #include "opto/rootnode.hpp"
  34 #include "opto/subnode.hpp"
  35 #include "opto/type.hpp"
  36 #include "opto/valuetypenode.hpp"
  37 
  38 //=============================================================================
  39 // If input is already higher or equal to cast type, then this is an identity.
  40 Node* ConstraintCastNode::Identity(PhaseGVN* phase) {
  41   Node* dom = dominating_cast(phase, phase);
  42   if (dom != NULL) {
  43     return dom;
  44   }
  45   if (_carry_dependency) {
  46     return this;
  47   }
  48   return phase->type(in(1))->higher_equal_speculative(_type) ? in(1) : this;
  49 }
  50 
  51 //------------------------------Value------------------------------------------
  52 // Take 'join' of input and cast-up type
  53 const Type* ConstraintCastNode::Value(PhaseGVN* phase) const {
  54   if (in(0) && phase->type(in(0)) == Type::TOP) return Type::TOP;
  55   const Type* ft = phase->type(in(1))->filter_speculative(_type);
  56 


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


 451     break;
 452   }
 453   return NULL;
 454 }
 455 
 456 //------------------------------Identity---------------------------------------
 457 Node* CastX2PNode::Identity(PhaseGVN* phase) {
 458   if (in(1)->Opcode() == Op_CastP2X)  return in(1)->in(1);
 459   return this;
 460 }
 461 
 462 //=============================================================================
 463 //------------------------------Value------------------------------------------
 464 const Type* CastP2XNode::Value(PhaseGVN* phase) const {
 465   const Type* t = phase->type(in(1));
 466   if (t == Type::TOP) return Type::TOP;
 467   if (t->base() == Type::RawPtr && t->singleton()) {
 468     uintptr_t bits = (uintptr_t) t->is_rawptr()->get_con();
 469     return TypeX::make(bits);
 470   }
 471 
 472   if (t->is_zero_type() || !t->maybe_null()) {
 473     for (DUIterator_Fast imax, i = fast_outs(imax); i < imax; i++) {
 474       Node* u = fast_out(i);
 475       if (u->Opcode() == Op_OrL) {
 476         for (DUIterator_Fast jmax, j = u->fast_outs(jmax); j < jmax; j++) {
 477           Node* cmp = u->fast_out(j);
 478           if (cmp->Opcode() == Op_CmpL) {
 479             // Give CmpL a chance to get optimized
 480             phase->record_for_igvn(cmp);
 481           }
 482         }
 483       }
 484     }
 485   }
 486 
 487   return CastP2XNode::bottom_type();
 488 }
 489 
 490 Node *CastP2XNode::Ideal(PhaseGVN *phase, bool can_reshape) {
 491   return (in(0) && remove_dead_region(phase, can_reshape)) ? this : NULL;
 492 }
 493 
 494 //------------------------------Identity---------------------------------------
 495 Node* CastP2XNode::Identity(PhaseGVN* phase) {
 496   if (in(1)->Opcode() == Op_CastX2P)  return in(1)->in(1);
 497   return this;
 498 }
< prev index next >