< prev index next >

src/share/vm/opto/ifnode.cpp

Print this page




  28 #include "opto/addnode.hpp"
  29 #include "opto/castnode.hpp"
  30 #include "opto/cfgnode.hpp"
  31 #include "opto/connode.hpp"
  32 #include "opto/loopnode.hpp"
  33 #include "opto/phaseX.hpp"
  34 #include "opto/runtime.hpp"
  35 #include "opto/rootnode.hpp"
  36 #include "opto/subnode.hpp"
  37 
  38 // Portions of code courtesy of Clifford Click
  39 
  40 // Optimization - Graph Style
  41 
  42 
  43 extern int explicit_null_checks_elided;
  44 
  45 //=============================================================================
  46 //------------------------------Value------------------------------------------
  47 // Return a tuple for whichever arm of the IF is reachable
  48 const Type *IfNode::Value( PhaseTransform *phase ) const {
  49   if( !in(0) ) return Type::TOP;
  50   if( phase->type(in(0)) == Type::TOP )
  51     return Type::TOP;
  52   const Type *t = phase->type(in(1));
  53   if( t == Type::TOP )          // data is undefined
  54     return TypeTuple::IFNEITHER; // unreachable altogether
  55   if( t == TypeInt::ZERO )      // zero, or false
  56     return TypeTuple::IFFALSE;  // only false branch is reachable
  57   if( t == TypeInt::ONE )       // 1, or true
  58     return TypeTuple::IFTRUE;   // only true branch is reachable
  59   assert( t == TypeInt::BOOL, "expected boolean type" );
  60 
  61   return TypeTuple::IFBOTH;     // No progress
  62 }
  63 
  64 const RegMask &IfNode::out_RegMask() const {
  65   return RegMask::Empty;
  66 }
  67 
  68 //------------------------------split_if---------------------------------------


1510     if( dist < 0 ) return NULL;
1511 
1512     dist--;
1513     prev_dom = dom;
1514     dom = up_one_dom( dom );
1515     if( !dom ) return NULL;
1516   }
1517 
1518   // Check that we did not follow a loop back to ourselves
1519   if( this == dom )
1520     return NULL;
1521 
1522   if( dist > 2 )              // Add to count of NULL checks elided
1523     explicit_null_checks_elided++;
1524 
1525   return prev_dom;
1526 }
1527 
1528 //------------------------------Identity---------------------------------------
1529 // If the test is constant & we match, then we are the input Control
1530 Node *IfProjNode::Identity(PhaseTransform *phase) {
1531   // Can only optimize if cannot go the other way
1532   const TypeTuple *t = phase->type(in(0))->is_tuple();
1533   if (t == TypeTuple::IFNEITHER ||
1534       // kill dead branch first otherwise the IfNode's control will
1535       // have 2 control uses (the IfNode that doesn't go away because
1536       // it still has uses and this branch of the
1537       // If). Node::has_special_unique_user() will cause this node to
1538       // be reprocessed once the dead branch is killed.
1539       (always_taken(t) && in(0)->outcnt() == 1)) {
1540     // IfNode control
1541     return in(0)->in(0);
1542   }
1543   // no progress
1544   return this;
1545 }
1546 
1547 #ifndef PRODUCT
1548 //-------------------------------related---------------------------------------
1549 // An IfProjNode's related node set consists of its input (an IfNode) including
1550 // the IfNode's condition, plus all of its outputs at level 1. In compact mode,




  28 #include "opto/addnode.hpp"
  29 #include "opto/castnode.hpp"
  30 #include "opto/cfgnode.hpp"
  31 #include "opto/connode.hpp"
  32 #include "opto/loopnode.hpp"
  33 #include "opto/phaseX.hpp"
  34 #include "opto/runtime.hpp"
  35 #include "opto/rootnode.hpp"
  36 #include "opto/subnode.hpp"
  37 
  38 // Portions of code courtesy of Clifford Click
  39 
  40 // Optimization - Graph Style
  41 
  42 
  43 extern int explicit_null_checks_elided;
  44 
  45 //=============================================================================
  46 //------------------------------Value------------------------------------------
  47 // Return a tuple for whichever arm of the IF is reachable
  48 const Type* IfNode::Value(PhaseGVN* phase) const {
  49   if( !in(0) ) return Type::TOP;
  50   if( phase->type(in(0)) == Type::TOP )
  51     return Type::TOP;
  52   const Type *t = phase->type(in(1));
  53   if( t == Type::TOP )          // data is undefined
  54     return TypeTuple::IFNEITHER; // unreachable altogether
  55   if( t == TypeInt::ZERO )      // zero, or false
  56     return TypeTuple::IFFALSE;  // only false branch is reachable
  57   if( t == TypeInt::ONE )       // 1, or true
  58     return TypeTuple::IFTRUE;   // only true branch is reachable
  59   assert( t == TypeInt::BOOL, "expected boolean type" );
  60 
  61   return TypeTuple::IFBOTH;     // No progress
  62 }
  63 
  64 const RegMask &IfNode::out_RegMask() const {
  65   return RegMask::Empty;
  66 }
  67 
  68 //------------------------------split_if---------------------------------------


1510     if( dist < 0 ) return NULL;
1511 
1512     dist--;
1513     prev_dom = dom;
1514     dom = up_one_dom( dom );
1515     if( !dom ) return NULL;
1516   }
1517 
1518   // Check that we did not follow a loop back to ourselves
1519   if( this == dom )
1520     return NULL;
1521 
1522   if( dist > 2 )              // Add to count of NULL checks elided
1523     explicit_null_checks_elided++;
1524 
1525   return prev_dom;
1526 }
1527 
1528 //------------------------------Identity---------------------------------------
1529 // If the test is constant & we match, then we are the input Control
1530 Node* IfProjNode::Identity(PhaseGVN* phase) {
1531   // Can only optimize if cannot go the other way
1532   const TypeTuple *t = phase->type(in(0))->is_tuple();
1533   if (t == TypeTuple::IFNEITHER ||
1534       // kill dead branch first otherwise the IfNode's control will
1535       // have 2 control uses (the IfNode that doesn't go away because
1536       // it still has uses and this branch of the
1537       // If). Node::has_special_unique_user() will cause this node to
1538       // be reprocessed once the dead branch is killed.
1539       (always_taken(t) && in(0)->outcnt() == 1)) {
1540     // IfNode control
1541     return in(0)->in(0);
1542   }
1543   // no progress
1544   return this;
1545 }
1546 
1547 #ifndef PRODUCT
1548 //-------------------------------related---------------------------------------
1549 // An IfProjNode's related node set consists of its input (an IfNode) including
1550 // the IfNode's condition, plus all of its outputs at level 1. In compact mode,


< prev index next >