src/share/vm/opto/ifnode.cpp

Print this page


   1 /*
   2  * Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  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 // Portions of code courtesy of Clifford Click
  26 
  27 // Optimization - Graph Style
  28 
  29 #include "incls/_precompiled.incl"
  30 #include "incls/_ifnode.cpp.incl"
  31 
  32 
  33 extern int explicit_null_checks_elided;
  34 
  35 //=============================================================================
  36 //------------------------------Value------------------------------------------
  37 // Return a tuple for whichever arm of the IF is reachable
  38 const Type *IfNode::Value( PhaseTransform *phase ) const {
  39   if( !in(0) ) return Type::TOP;
  40   if( phase->type(in(0)) == Type::TOP )
  41     return Type::TOP;
  42   const Type *t = phase->type(in(1));
  43   if( t == Type::TOP )          // data is undefined
  44     return TypeTuple::IFNEITHER; // unreachable altogether
  45   if( t == TypeInt::ZERO )      // zero, or false
  46     return TypeTuple::IFFALSE;  // only false branch is reachable
  47   if( t == TypeInt::ONE )       // 1, or true
  48     return TypeTuple::IFTRUE;   // only true branch is reachable
  49   assert( t == TypeInt::BOOL, "expected boolean type" );
  50 
  51   return TypeTuple::IFBOTH;     // No progress


   1 /*
   2  * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  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 "memory/allocation.inline.hpp"
  27 #include "opto/addnode.hpp"
  28 #include "opto/cfgnode.hpp"
  29 #include "opto/connode.hpp"
  30 #include "opto/phaseX.hpp"
  31 #include "opto/runtime.hpp"
  32 #include "opto/subnode.hpp"
  33 
  34 // Portions of code courtesy of Clifford Click
  35 
  36 // Optimization - Graph Style
  37 



  38 
  39 extern int explicit_null_checks_elided;
  40 
  41 //=============================================================================
  42 //------------------------------Value------------------------------------------
  43 // Return a tuple for whichever arm of the IF is reachable
  44 const Type *IfNode::Value( PhaseTransform *phase ) const {
  45   if( !in(0) ) return Type::TOP;
  46   if( phase->type(in(0)) == Type::TOP )
  47     return Type::TOP;
  48   const Type *t = phase->type(in(1));
  49   if( t == Type::TOP )          // data is undefined
  50     return TypeTuple::IFNEITHER; // unreachable altogether
  51   if( t == TypeInt::ZERO )      // zero, or false
  52     return TypeTuple::IFFALSE;  // only false branch is reachable
  53   if( t == TypeInt::ONE )       // 1, or true
  54     return TypeTuple::IFTRUE;   // only true branch is reachable
  55   assert( t == TypeInt::BOOL, "expected boolean type" );
  56 
  57   return TypeTuple::IFBOTH;     // No progress