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 "c1/c1_IR.hpp" 27 #include "c1/c1_Instruction.hpp" 28 #include "c1/c1_InstructionPrinter.hpp" 29 #include "c1/c1_ValueStack.hpp" 30 #include "ci/ciObjArrayKlass.hpp" 31 #include "ci/ciTypeArrayKlass.hpp" 32 33 34 // Implementation of Instruction 35 36 37 int Instruction::dominator_depth() { 38 int result = -1; 39 if (block()) { 40 result = block()->dominator_depth(); 41 } 42 assert(result != -1 || this->as_Local(), "Only locals have dominator depth -1"); 43 return result; 44 } 45 46 Instruction::Condition Instruction::mirror(Condition cond) { 47 switch (cond) { 48 case eql: return eql; 49 case neq: return neq; 50 case lss: return gtr; 51 case leq: return geq; 95 } 96 97 98 void Instruction::state_values_do(ValueVisitor* f) { 99 if (state_before() != NULL) { 100 state_before()->values_do(f); 101 } 102 if (exception_state() != NULL){ 103 exception_state()->values_do(f); 104 } 105 } 106 107 ciType* Instruction::exact_type() const { 108 ciType* t = declared_type(); 109 if (t != NULL && t->is_klass()) { 110 return t->as_klass()->exact_klass(); 111 } 112 return NULL; 113 } 114 115 116 #ifndef PRODUCT 117 void Instruction::check_state(ValueStack* state) { 118 if (state != NULL) { 119 state->verify(); 120 } 121 } 122 123 124 void Instruction::print() { 125 InstructionPrinter ip; 126 print(ip); 127 } 128 129 130 void Instruction::print_line() { 131 InstructionPrinter ip; 132 ip.print_line(this); 133 } 134 203 } 204 205 206 ciType* NewTypeArray::exact_type() const { 207 return ciTypeArrayKlass::make(elt_type()); 208 } 209 210 ciType* NewObjectArray::exact_type() const { 211 return ciObjArrayKlass::make(klass()); 212 } 213 214 ciType* NewArray::declared_type() const { 215 return exact_type(); 216 } 217 218 ciType* NewInstance::exact_type() const { 219 return klass(); 220 } 221 222 ciType* NewInstance::declared_type() const { 223 return exact_type(); 224 } 225 226 ciType* CheckCast::declared_type() const { 227 return klass(); 228 } 229 230 // Implementation of ArithmeticOp 231 232 bool ArithmeticOp::is_commutative() const { 233 switch (op()) { 234 case Bytecodes::_iadd: // fall through 235 case Bytecodes::_ladd: // fall through 236 case Bytecodes::_fadd: // fall through 237 case Bytecodes::_dadd: // fall through 238 case Bytecodes::_imul: // fall through 239 case Bytecodes::_lmul: // fall through 240 case Bytecodes::_fmul: // fall through 241 case Bytecodes::_dmul: return true; 242 default : return false; | 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 "c1/c1_IR.hpp" 27 #include "c1/c1_Instruction.hpp" 28 #include "c1/c1_InstructionPrinter.hpp" 29 #include "c1/c1_ValueStack.hpp" 30 #include "ci/ciObjArrayKlass.hpp" 31 #include "ci/ciTypeArrayKlass.hpp" 32 #include "ci/ciValueArrayKlass.hpp" 33 #include "ci/ciValueKlass.hpp" 34 35 36 // Implementation of Instruction 37 38 39 int Instruction::dominator_depth() { 40 int result = -1; 41 if (block()) { 42 result = block()->dominator_depth(); 43 } 44 assert(result != -1 || this->as_Local(), "Only locals have dominator depth -1"); 45 return result; 46 } 47 48 Instruction::Condition Instruction::mirror(Condition cond) { 49 switch (cond) { 50 case eql: return eql; 51 case neq: return neq; 52 case lss: return gtr; 53 case leq: return geq; 97 } 98 99 100 void Instruction::state_values_do(ValueVisitor* f) { 101 if (state_before() != NULL) { 102 state_before()->values_do(f); 103 } 104 if (exception_state() != NULL){ 105 exception_state()->values_do(f); 106 } 107 } 108 109 ciType* Instruction::exact_type() const { 110 ciType* t = declared_type(); 111 if (t != NULL && t->is_klass()) { 112 return t->as_klass()->exact_klass(); 113 } 114 return NULL; 115 } 116 117 bool Instruction::is_flattened_array() const { 118 if (ValueArrayFlatten) { 119 ciType* type = declared_type(); 120 if (type != NULL && 121 type->is_value_array_klass() && 122 type->as_value_array_klass()->element_klass()->as_value_klass()->flatten_array()) { 123 return true; 124 } 125 } 126 127 return false; 128 } 129 130 #ifndef PRODUCT 131 void Instruction::check_state(ValueStack* state) { 132 if (state != NULL) { 133 state->verify(); 134 } 135 } 136 137 138 void Instruction::print() { 139 InstructionPrinter ip; 140 print(ip); 141 } 142 143 144 void Instruction::print_line() { 145 InstructionPrinter ip; 146 ip.print_line(this); 147 } 148 217 } 218 219 220 ciType* NewTypeArray::exact_type() const { 221 return ciTypeArrayKlass::make(elt_type()); 222 } 223 224 ciType* NewObjectArray::exact_type() const { 225 return ciObjArrayKlass::make(klass()); 226 } 227 228 ciType* NewArray::declared_type() const { 229 return exact_type(); 230 } 231 232 ciType* NewInstance::exact_type() const { 233 return klass(); 234 } 235 236 ciType* NewInstance::declared_type() const { 237 return exact_type(); 238 } 239 240 Value NewValueTypeInstance::depends_on() { 241 if (_depends_on != this) { 242 if (_depends_on->as_NewValueTypeInstance() != NULL) { 243 return _depends_on->as_NewValueTypeInstance()->depends_on(); 244 } 245 } 246 return _depends_on; 247 } 248 249 ciType* NewValueTypeInstance::exact_type() const { 250 return klass(); 251 } 252 253 ciType* NewValueTypeInstance::declared_type() const { 254 return exact_type(); 255 } 256 257 ciType* CheckCast::declared_type() const { 258 return klass(); 259 } 260 261 // Implementation of ArithmeticOp 262 263 bool ArithmeticOp::is_commutative() const { 264 switch (op()) { 265 case Bytecodes::_iadd: // fall through 266 case Bytecodes::_ladd: // fall through 267 case Bytecodes::_fadd: // fall through 268 case Bytecodes::_dadd: // fall through 269 case Bytecodes::_imul: // fall through 270 case Bytecodes::_lmul: // fall through 271 case Bytecodes::_fmul: // fall through 272 case Bytecodes::_dmul: return true; 273 default : return false; |