< prev index next >

src/share/vm/opto/multnode.cpp

Print this page




  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/callnode.hpp"
  27 #include "opto/cfgnode.hpp"
  28 #include "opto/matcher.hpp"
  29 #include "opto/mathexactnode.hpp"
  30 #include "opto/multnode.hpp"
  31 #include "opto/opcodes.hpp"
  32 #include "opto/phaseX.hpp"
  33 #include "opto/regmask.hpp"
  34 #include "opto/type.hpp"



  35 
  36 //=============================================================================
  37 //------------------------------MultiNode--------------------------------------
  38 const RegMask &MultiNode::out_RegMask() const {
  39   return RegMask::Empty;
  40 }
  41 
  42 Node *MultiNode::match( const ProjNode *proj, const Matcher *m ) { return proj->clone(); }
  43 
  44 //------------------------------proj_out---------------------------------------
  45 // Get a named projection
  46 ProjNode* MultiNode::proj_out(uint which_proj) const {
  47   assert(Opcode() != Op_If || which_proj == (uint)true || which_proj == (uint)false, "must be 1 or 0");
  48   assert(Opcode() != Op_If || outcnt() == 2, "bad if #1");
  49   for( DUIterator_Fast imax, i = fast_outs(imax); i < imax; i++ ) {
  50     Node *p = fast_out(i);
  51     if (p->is_Proj()) {
  52       ProjNode *proj = p->as_Proj();
  53       if (proj->_con == which_proj) {
  54         assert(Opcode() != Op_If || proj->Opcode() == (which_proj?Op_IfTrue:Op_IfFalse), "bad if #2");


 131 }
 132 
 133 //------------------------------Value------------------------------------------
 134 const Type *ProjNode::Value( PhaseTransform *phase ) const {
 135   if (in(0) == NULL) return Type::TOP;
 136   return proj_type(phase->type(in(0)));
 137 }
 138 
 139 //------------------------------out_RegMask------------------------------------
 140 // Pass the buck uphill
 141 const RegMask &ProjNode::out_RegMask() const {
 142   return RegMask::Empty;
 143 }
 144 
 145 //------------------------------ideal_reg--------------------------------------
 146 uint ProjNode::ideal_reg() const {
 147   return bottom_type()->ideal_reg();
 148 }
 149 
 150 //-------------------------------is_uncommon_trap_proj----------------------------
 151 // Return true if proj is the form of "proj->[region->..]call_uct"
 152 bool ProjNode::is_uncommon_trap_proj(Deoptimization::DeoptReason reason) {

 153   int path_limit = 10;
 154   Node* out = this;
 155   for (int ct = 0; ct < path_limit; ct++) {
 156     out = out->unique_ctrl_out();
 157     if (out == NULL)
 158       return false;
 159     if (out->is_CallStaticJava()) {
 160       int req = out->as_CallStaticJava()->uncommon_trap_request();

 161       if (req != 0) {
 162         Deoptimization::DeoptReason trap_reason = Deoptimization::trap_request_reason(req);
 163         if (trap_reason == reason || reason == Deoptimization::Reason_none) {
 164            return true;
 165         }
 166       }
 167       return false; // don't do further after call
 168     }
 169     if (out->Opcode() != Op_Region)
 170       return false;
 171   }
 172   return false;
 173 }
 174 
 175 //-------------------------------is_uncommon_trap_if_pattern-------------------------
 176 // Return true  for "if(test)-> proj -> ...
 177 //                          |
 178 //                          V
 179 //                      other_proj->[region->..]call_uct"
 180 //
 181 // "must_reason_predicate" means the uct reason must be Reason_predicate
 182 bool ProjNode::is_uncommon_trap_if_pattern(Deoptimization::DeoptReason reason) {
 183   Node *in0 = in(0);
 184   if (!in0->is_If()) return false;
 185   // Variation of a dead If node.
 186   if (in0->outcnt() < 2)  return false;
 187   IfNode* iff = in0->as_If();
 188 
 189   // we need "If(Conv2B(Opaque1(...)))" pattern for reason_predicate
 190   if (reason != Deoptimization::Reason_none) {
 191     if (iff->in(1)->Opcode() != Op_Conv2B ||
 192        iff->in(1)->in(1)->Opcode() != Op_Opaque1) {
 193       return false;
 194     }
 195   }
 196 
 197   ProjNode* other_proj = iff->proj_out(1-_con);
 198   if (other_proj == NULL) // Should never happen, but make Parfait happy.
 199       return false;
 200   if (other_proj->is_uncommon_trap_proj(reason)) {

 201     assert(reason == Deoptimization::Reason_none ||
 202            Compile::current()->is_predicate_opaq(iff->in(1)->in(1)), "should be on the list");
 203     return true;
 204   }
 205   return false;
 206 }


  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/callnode.hpp"
  27 #include "opto/cfgnode.hpp"
  28 #include "opto/matcher.hpp"
  29 #include "opto/mathexactnode.hpp"
  30 #include "opto/multnode.hpp"
  31 #include "opto/opcodes.hpp"
  32 #include "opto/phaseX.hpp"
  33 #include "opto/regmask.hpp"
  34 #include "opto/type.hpp"
  35 #if INCLUDE_ALL_GCS
  36 #include "gc_implementation/shenandoah/c2/shenandoahSupport.hpp"
  37 #endif
  38 
  39 //=============================================================================
  40 //------------------------------MultiNode--------------------------------------
  41 const RegMask &MultiNode::out_RegMask() const {
  42   return RegMask::Empty;
  43 }
  44 
  45 Node *MultiNode::match( const ProjNode *proj, const Matcher *m ) { return proj->clone(); }
  46 
  47 //------------------------------proj_out---------------------------------------
  48 // Get a named projection
  49 ProjNode* MultiNode::proj_out(uint which_proj) const {
  50   assert(Opcode() != Op_If || which_proj == (uint)true || which_proj == (uint)false, "must be 1 or 0");
  51   assert(Opcode() != Op_If || outcnt() == 2, "bad if #1");
  52   for( DUIterator_Fast imax, i = fast_outs(imax); i < imax; i++ ) {
  53     Node *p = fast_out(i);
  54     if (p->is_Proj()) {
  55       ProjNode *proj = p->as_Proj();
  56       if (proj->_con == which_proj) {
  57         assert(Opcode() != Op_If || proj->Opcode() == (which_proj?Op_IfTrue:Op_IfFalse), "bad if #2");


 134 }
 135 
 136 //------------------------------Value------------------------------------------
 137 const Type *ProjNode::Value( PhaseTransform *phase ) const {
 138   if (in(0) == NULL) return Type::TOP;
 139   return proj_type(phase->type(in(0)));
 140 }
 141 
 142 //------------------------------out_RegMask------------------------------------
 143 // Pass the buck uphill
 144 const RegMask &ProjNode::out_RegMask() const {
 145   return RegMask::Empty;
 146 }
 147 
 148 //------------------------------ideal_reg--------------------------------------
 149 uint ProjNode::ideal_reg() const {
 150   return bottom_type()->ideal_reg();
 151 }
 152 
 153 //-------------------------------is_uncommon_trap_proj----------------------------
 154 // Return uncommon trap call node if proj is for "proj->[region->..]call_uct"
 155 // NULL otherwise
 156 CallStaticJavaNode* ProjNode::is_uncommon_trap_proj(Deoptimization::DeoptReason reason) {
 157   int path_limit = 10;
 158   Node* out = this;
 159   for (int ct = 0; ct < path_limit; ct++) {
 160     out = out->unique_ctrl_out();
 161     if (out == NULL)
 162       return NULL;
 163     if (out->is_CallStaticJava()) {
 164       CallStaticJavaNode* call = out->as_CallStaticJava();
 165       int req = call->uncommon_trap_request();
 166       if (req != 0) {
 167         Deoptimization::DeoptReason trap_reason = Deoptimization::trap_request_reason(req);
 168         if (trap_reason == reason || reason == Deoptimization::Reason_none) {
 169           return call;
 170         }
 171       }
 172       return NULL; // don't do further after call
 173     }
 174     if (out->Opcode() != Op_Region)
 175       return NULL;
 176   }
 177   return NULL;
 178 }
 179 
 180 //-------------------------------is_uncommon_trap_if_pattern-------------------------
 181 // Return uncommon trap call node for    "if(test)-> proj -> ...
 182 //                                                 |
 183 //                                                 V
 184 //                                             other_proj->[region->..]call_uct"
 185 // NULL otherwise
 186 // "must_reason_predicate" means the uct reason must be Reason_predicate
 187 CallStaticJavaNode* ProjNode::is_uncommon_trap_if_pattern(Deoptimization::DeoptReason reason) {
 188   Node *in0 = in(0);
 189   if (!in0->is_If()) return NULL;
 190   // Variation of a dead If node.
 191   if (in0->outcnt() < 2)  return NULL;
 192   IfNode* iff = in0->as_If();
 193 
 194   // we need "If(Conv2B(Opaque1(...)))" pattern for reason_predicate
 195   if (reason != Deoptimization::Reason_none) {
 196     if (iff->in(1)->Opcode() != Op_Conv2B ||
 197        iff->in(1)->in(1)->Opcode() != Op_Opaque1) {
 198       return NULL;
 199     }
 200   }
 201 
 202   ProjNode* other_proj = iff->proj_out(1-_con);
 203   if (other_proj == NULL) // Should never happen, but make Parfait happy.
 204       return NULL;
 205   CallStaticJavaNode* call = other_proj->is_uncommon_trap_proj(reason);
 206   if (call != NULL) {
 207     assert(reason == Deoptimization::Reason_none ||
 208            Compile::current()->is_predicate_opaq(iff->in(1)->in(1)), "should be on the list");
 209     return call;
 210   }
 211   return NULL;
 212 }
< prev index next >