< prev index next >

src/hotspot/share/c1/c1_Instruction.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 "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 "utilities/bitMap.inline.hpp"
  33 
  34 
  35 // Implementation of Instruction
  36 
  37 
  38 int Instruction::dominator_depth() {
  39   int result = -1;
  40   if (block()) {
  41     result = block()->dominator_depth();
  42   }
  43   assert(result != -1 || this->as_Local(), "Only locals have dominator depth -1");
  44   return result;
  45 }
  46 
  47 Instruction::Condition Instruction::mirror(Condition cond) {
  48   switch (cond) {
  49     case eql: return eql;

  89   Instruction* p = NULL;
  90   Instruction* q = block();
  91   while (q != this) {
  92     assert(q != NULL, "this is not in the block's instruction list");
  93     p = q; q = q->next();
  94   }
  95   return p;
  96 }
  97 
  98 
  99 void Instruction::state_values_do(ValueVisitor* f) {
 100   if (state_before() != NULL) {
 101     state_before()->values_do(f);
 102   }
 103   if (exception_state() != NULL){
 104     exception_state()->values_do(f);
 105   }
 106 }
 107 
 108 ciType* Instruction::exact_type() const {
 109   ciType* t =  declared_type();
 110   if (t != NULL && t->is_klass()) {
 111     return t->as_klass()->exact_klass();
 112   }
 113   return NULL;
 114 }
 115 




























































 116 
 117 #ifndef PRODUCT
 118 void Instruction::check_state(ValueStack* state) {
 119   if (state != NULL) {
 120     state->verify();
 121   }
 122 }
 123 
 124 
 125 void Instruction::print() {
 126   InstructionPrinter ip;
 127   print(ip);
 128 }
 129 
 130 
 131 void Instruction::print_line() {
 132   InstructionPrinter ip;
 133   ip.print_line(this);
 134 }
 135 

 156     }
 157   }
 158 
 159   if (!this->check_flag(NeedsRangeCheckFlag)) {
 160     return false;
 161   }
 162 
 163   return true;
 164 }
 165 
 166 
 167 ciType* Constant::exact_type() const {
 168   if (type()->is_object() && type()->as_ObjectType()->is_loaded()) {
 169     return type()->as_ObjectType()->exact_type();
 170   }
 171   return NULL;
 172 }
 173 
 174 ciType* LoadIndexed::exact_type() const {
 175   ciType* array_type = array()->exact_type();
 176   if (array_type != NULL) {
 177     assert(array_type->is_array_klass(), "what else?");
 178     ciArrayKlass* ak = (ciArrayKlass*)array_type;
 179 
 180     if (ak->element_type()->is_instance_klass()) {
 181       ciInstanceKlass* ik = (ciInstanceKlass*)ak->element_type();
 182       if (ik->is_loaded() && ik->is_final()) {
 183         return ik;
 184       }
 185     }
 186   }
 187   return Instruction::exact_type();
 188 }
 189 
 190 
 191 ciType* LoadIndexed::declared_type() const {



 192   ciType* array_type = array()->declared_type();
 193   if (array_type == NULL || !array_type->is_loaded()) {
 194     return NULL;
 195   }
 196   assert(array_type->is_array_klass(), "what else?");
 197   ciArrayKlass* ak = (ciArrayKlass*)array_type;
 198   return ak->element_type();
 199 }
 200 














 201 
 202 ciType* LoadField::declared_type() const {
 203   return field()->type();
 204 }
 205 
 206 
 207 ciType* NewTypeArray::exact_type() const {
 208   return ciTypeArrayKlass::make(elt_type());
 209 }
 210 
 211 ciType* NewObjectArray::exact_type() const {
 212   return ciObjArrayKlass::make(klass());




 213 }
 214 
 215 ciType* NewArray::declared_type() const {
 216   return exact_type();
 217 }
 218 
 219 ciType* NewInstance::exact_type() const {
 220   return klass();
 221 }
 222 
 223 ciType* NewInstance::declared_type() const {
 224   return exact_type();
 225 }
 226 








 227 ciType* CheckCast::declared_type() const {
 228   return klass();
 229 }
 230 
 231 // Implementation of ArithmeticOp
 232 
 233 bool ArithmeticOp::is_commutative() const {
 234   switch (op()) {
 235     case Bytecodes::_iadd: // fall through
 236     case Bytecodes::_ladd: // fall through
 237     case Bytecodes::_fadd: // fall through
 238     case Bytecodes::_dadd: // fall through
 239     case Bytecodes::_imul: // fall through
 240     case Bytecodes::_lmul: // fall through
 241     case Bytecodes::_fmul: // fall through
 242     case Bytecodes::_dmul: return true;
 243     default              : return false;
 244   }
 245 }
 246 

 302 }
 303 
 304 
 305 void StateSplit::state_values_do(ValueVisitor* f) {
 306   Instruction::state_values_do(f);
 307   if (state() != NULL) state()->values_do(f);
 308 }
 309 
 310 
 311 void BlockBegin::state_values_do(ValueVisitor* f) {
 312   StateSplit::state_values_do(f);
 313 
 314   if (is_set(BlockBegin::exception_entry_flag)) {
 315     for (int i = 0; i < number_of_exception_states(); i++) {
 316       exception_state_at(i)->values_do(f);
 317     }
 318   }
 319 }
 320 
 321 



































 322 // Implementation of Invoke
 323 
 324 
 325 Invoke::Invoke(Bytecodes::Code code, ValueType* result_type, Value recv, Values* args,
 326                ciMethod* target, ValueStack* state_before)
 327   : StateSplit(result_type, state_before)
 328   , _code(code)
 329   , _recv(recv)
 330   , _args(args)
 331   , _target(target)
 332 {
 333   set_flag(TargetIsLoadedFlag,   target->is_loaded());
 334   set_flag(TargetIsFinalFlag,    target_is_loaded() && target->is_final_method());

 335 
 336   assert(args != NULL, "args must exist");
 337 #ifdef ASSERT
 338   AssertValues assert_value;
 339   values_do(&assert_value);
 340 #endif
 341 
 342   // provide an initial guess of signature size.
 343   _signature = new BasicTypeList(number_of_arguments() + (has_receiver() ? 1 : 0));
 344   if (has_receiver()) {
 345     _signature->append(as_BasicType(receiver()->type()));



 346   }
 347   for (int i = 0; i < number_of_arguments(); i++) {
 348     ValueType* t = argument_at(i)->type();

 349     BasicType bt = as_BasicType(t);
 350     _signature->append(bt);



 351   }
 352 }
 353 
 354 
 355 void Invoke::state_values_do(ValueVisitor* f) {
 356   StateSplit::state_values_do(f);
 357   if (state_before() != NULL) state_before()->values_do(f);
 358   if (state()        != NULL) state()->values_do(f);
 359 }
 360 
 361 ciType* Invoke::declared_type() const {
 362   ciSignature* declared_signature = state()->scope()->method()->get_declared_signature_at_bci(state()->bci());
 363   ciType *t = declared_signature->return_type();
 364   assert(t->basic_type() != T_VOID, "need return value of void method?");
 365   return t;
 366 }
 367 
 368 // Implementation of Contant
 369 intx Constant::hash() const {
 370   if (state_before() == NULL) {

 843       // check that all necessary phi functions are present
 844       for_each_stack_value(existing_state, index, existing_value) {
 845         assert(existing_value->as_Phi() != NULL && existing_value->as_Phi()->block() == this, "phi function required");
 846       }
 847       for_each_local_value(existing_state, index, existing_value) {
 848         assert(existing_value == new_state->local_at(index) || (existing_value->as_Phi() != NULL && existing_value->as_Phi()->as_Phi()->block() == this), "phi function required");
 849       }
 850 #endif
 851 
 852     } else {
 853       TRACE_PHI(tty->print_cr("creating phi functions on demand"));
 854 
 855       // create necessary phi functions for stack
 856       for_each_stack_value(existing_state, index, existing_value) {
 857         Value new_value = new_state->stack_at(index);
 858         Phi* existing_phi = existing_value->as_Phi();
 859 
 860         if (new_value != existing_value && (existing_phi == NULL || existing_phi->block() != this)) {
 861           existing_state->setup_phi_for_stack(this, index);
 862           TRACE_PHI(tty->print_cr("creating phi-function %c%d for stack %d", existing_state->stack_at(index)->type()->tchar(), existing_state->stack_at(index)->id(), index));


 863         }
 864       }
 865 
 866       // create necessary phi functions for locals
 867       for_each_local_value(existing_state, index, existing_value) {
 868         Value new_value = new_state->local_at(index);
 869         Phi* existing_phi = existing_value->as_Phi();
 870 
 871         if (new_value == NULL || new_value->type()->tag() != existing_value->type()->tag()) {
 872           existing_state->invalidate_local(index);
 873           TRACE_PHI(tty->print_cr("invalidating local %d because of type mismatch", index));
 874         } else if (new_value != existing_value && (existing_phi == NULL || existing_phi->block() != this)) {
 875           existing_state->setup_phi_for_local(this, index);
 876           TRACE_PHI(tty->print_cr("creating phi-function %c%d for local %d", existing_state->local_at(index)->type()->tchar(), existing_state->local_at(index)->id(), index));


 877         }
 878       }
 879     }
 880 
 881     assert(existing_state->caller_state() == new_state->caller_state(), "caller states must be equal");
 882 
 883   } else {
 884     assert(false, "stack or locks not matching (invalid bytecodes)");
 885     return false;
 886   }
 887 
 888   TRACE_PHI(tty->print_cr("********** try_merge for block B%d successful", block_id()));
 889 
 890   return true;
 891 }
 892 
 893 
 894 #ifndef PRODUCT
 895 void BlockBegin::print_block() {
 896   InstructionPrinter ip;

1023   ip1.print_instr(x);
1024 
1025   stringStream strStream2;
1026   InstructionPrinter ip2(1, &strStream2);
1027   ip2.print_instr(y);
1028 
1029   stringStream ss;
1030   ss.print("Assertion %s %s %s in method %s", strStream1.as_string(), ip2.cond_name(cond), strStream2.as_string(), strStream.as_string());
1031 
1032   _message = ss.as_string();
1033 }
1034 #endif
1035 
1036 void RangeCheckPredicate::check_state() {
1037   assert(state()->kind() != ValueStack::EmptyExceptionState && state()->kind() != ValueStack::ExceptionState, "will deopt with empty state");
1038 }
1039 
1040 void ProfileInvoke::state_values_do(ValueVisitor* f) {
1041   if (state() != NULL) state()->values_do(f);
1042 }


  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 "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/ciFlatArrayKlass.hpp"
  31 #include "ci/ciInlineKlass.hpp"
  32 #include "ci/ciObjArrayKlass.hpp"
  33 #include "ci/ciTypeArrayKlass.hpp"
  34 #include "utilities/bitMap.inline.hpp"
  35 
  36 
  37 // Implementation of Instruction
  38 
  39 
  40 int Instruction::dominator_depth() {
  41   int result = -1;
  42   if (block()) {
  43     result = block()->dominator_depth();
  44   }
  45   assert(result != -1 || this->as_Local(), "Only locals have dominator depth -1");
  46   return result;
  47 }
  48 
  49 Instruction::Condition Instruction::mirror(Condition cond) {
  50   switch (cond) {
  51     case eql: return eql;

  91   Instruction* p = NULL;
  92   Instruction* q = block();
  93   while (q != this) {
  94     assert(q != NULL, "this is not in the block's instruction list");
  95     p = q; q = q->next();
  96   }
  97   return p;
  98 }
  99 
 100 
 101 void Instruction::state_values_do(ValueVisitor* f) {
 102   if (state_before() != NULL) {
 103     state_before()->values_do(f);
 104   }
 105   if (exception_state() != NULL){
 106     exception_state()->values_do(f);
 107   }
 108 }
 109 
 110 ciType* Instruction::exact_type() const {
 111   ciType* t = declared_type();
 112   if (t != NULL && t->is_klass()) {
 113     return t->as_klass()->exact_klass();
 114   }
 115   return NULL;
 116 }
 117 
 118 ciKlass* Instruction::as_loaded_klass_or_null() const {
 119   ciType* type = declared_type();
 120   if (type != NULL && type->is_klass()) {
 121     ciKlass* klass = type->as_klass();
 122     if (klass->is_loaded()) {
 123       return klass;
 124     }
 125   }
 126   return NULL;
 127 }
 128 
 129 bool Instruction::is_loaded_flattened_array() const {
 130   if (UseFlatArray) {
 131     ciType* type = declared_type();
 132     return type != NULL && type->is_flat_array_klass();
 133   }
 134   return false;
 135 }
 136 
 137 bool Instruction::maybe_flattened_array() {
 138   if (UseFlatArray) {
 139     ciType* type = declared_type();
 140     if (type != NULL) {
 141       if (type->is_obj_array_klass() && !type->as_obj_array_klass()->is_elem_null_free()) {
 142         // The runtime type of [LMyValue might be [QMyValue due to [QMyValue <: [LMyValue.
 143         ciKlass* element_klass = type->as_obj_array_klass()->element_klass();
 144         if (element_klass->can_be_inline_klass() && (!element_klass->is_inlinetype() || element_klass->as_inline_klass()->flatten_array())) {
 145           return true;
 146         }
 147       } else if (type->is_flat_array_klass()) {
 148         return true;
 149       } else if (type->is_klass() && type->as_klass()->is_java_lang_Object()) {
 150         // This can happen as a parameter to System.arraycopy()
 151         return true;
 152       }
 153     } else {
 154       // Type info gets lost during Phi merging (Phi, IfOp, etc), but we might be storing into a
 155       // flattened array, so we should do a runtime check.
 156       return true;
 157     }
 158   }
 159   return false;
 160 }
 161 
 162 bool Instruction::maybe_null_free_array() {
 163   ciType* type = declared_type();
 164   if (type != NULL) {
 165     if (type->is_obj_array_klass()) {
 166       // Due to array covariance, the runtime type might be a null-free array.
 167       if (type->as_obj_array_klass()->can_be_inline_array_klass()) {
 168         return true;
 169       }
 170     }
 171   } else {
 172     // Type info gets lost during Phi merging (Phi, IfOp, etc), but we might be storing into a
 173     // null-free array, so we should do a runtime check.
 174     return true;
 175   }
 176   return false;
 177 }
 178 
 179 #ifndef PRODUCT
 180 void Instruction::check_state(ValueStack* state) {
 181   if (state != NULL) {
 182     state->verify();
 183   }
 184 }
 185 
 186 
 187 void Instruction::print() {
 188   InstructionPrinter ip;
 189   print(ip);
 190 }
 191 
 192 
 193 void Instruction::print_line() {
 194   InstructionPrinter ip;
 195   ip.print_line(this);
 196 }
 197 

 218     }
 219   }
 220 
 221   if (!this->check_flag(NeedsRangeCheckFlag)) {
 222     return false;
 223   }
 224 
 225   return true;
 226 }
 227 
 228 
 229 ciType* Constant::exact_type() const {
 230   if (type()->is_object() && type()->as_ObjectType()->is_loaded()) {
 231     return type()->as_ObjectType()->exact_type();
 232   }
 233   return NULL;
 234 }
 235 
 236 ciType* LoadIndexed::exact_type() const {
 237   ciType* array_type = array()->exact_type();
 238   if (delayed() == NULL && array_type != NULL) {
 239     assert(array_type->is_array_klass(), "what else?");
 240     ciArrayKlass* ak = (ciArrayKlass*)array_type;
 241 
 242     if (ak->element_type()->is_instance_klass()) {
 243       ciInstanceKlass* ik = (ciInstanceKlass*)ak->element_type();
 244       if (ik->is_loaded() && ik->is_final()) {
 245         return ik;
 246       }
 247     }
 248   }
 249   return Instruction::exact_type();
 250 }
 251 

 252 ciType* LoadIndexed::declared_type() const {
 253   if (delayed() != NULL) {
 254     return delayed()->field()->type();
 255   }
 256   ciType* array_type = array()->declared_type();
 257   if (array_type == NULL || !array_type->is_loaded()) {
 258     return NULL;
 259   }
 260   assert(array_type->is_array_klass(), "what else?");
 261   ciArrayKlass* ak = (ciArrayKlass*)array_type;
 262   return ak->element_type();
 263 }
 264 
 265 bool StoreIndexed::is_exact_flattened_array_store() const {
 266   if (array()->is_loaded_flattened_array() && value()->as_Constant() == NULL && value()->declared_type() != NULL) {
 267     ciKlass* element_klass = array()->declared_type()->as_flat_array_klass()->element_klass();
 268     ciKlass* actual_klass = value()->declared_type()->as_klass();
 269 
 270     // The following check can fail with inlining:
 271     //     void test45_inline(Object[] oa, Object o, int index) { oa[index] = o; }
 272     //     void test45(MyValue1[] va, int index, MyValue2 v) { test45_inline(va, v, index); }
 273     if (element_klass == actual_klass) {
 274       return true;
 275     }
 276   }
 277   return false;
 278 }
 279 
 280 ciType* LoadField::declared_type() const {
 281   return field()->type();
 282 }
 283 
 284 
 285 ciType* NewTypeArray::exact_type() const {
 286   return ciTypeArrayKlass::make(elt_type());
 287 }
 288 
 289 ciType* NewObjectArray::exact_type() const {
 290   return ciArrayKlass::make(klass(), is_null_free());
 291 }
 292 
 293 ciType* NewMultiArray::exact_type() const {
 294   return _klass;
 295 }
 296 
 297 ciType* NewArray::declared_type() const {
 298   return exact_type();
 299 }
 300 
 301 ciType* NewInstance::exact_type() const {
 302   return klass();
 303 }
 304 
 305 ciType* NewInstance::declared_type() const {
 306   return exact_type();
 307 }
 308 
 309 ciType* NewInlineTypeInstance::exact_type() const {
 310   return klass();
 311 }
 312 
 313 ciType* NewInlineTypeInstance::declared_type() const {
 314   return exact_type();
 315 }
 316 
 317 ciType* CheckCast::declared_type() const {
 318   return klass();
 319 }
 320 
 321 // Implementation of ArithmeticOp
 322 
 323 bool ArithmeticOp::is_commutative() const {
 324   switch (op()) {
 325     case Bytecodes::_iadd: // fall through
 326     case Bytecodes::_ladd: // fall through
 327     case Bytecodes::_fadd: // fall through
 328     case Bytecodes::_dadd: // fall through
 329     case Bytecodes::_imul: // fall through
 330     case Bytecodes::_lmul: // fall through
 331     case Bytecodes::_fmul: // fall through
 332     case Bytecodes::_dmul: return true;
 333     default              : return false;
 334   }
 335 }
 336 

 392 }
 393 
 394 
 395 void StateSplit::state_values_do(ValueVisitor* f) {
 396   Instruction::state_values_do(f);
 397   if (state() != NULL) state()->values_do(f);
 398 }
 399 
 400 
 401 void BlockBegin::state_values_do(ValueVisitor* f) {
 402   StateSplit::state_values_do(f);
 403 
 404   if (is_set(BlockBegin::exception_entry_flag)) {
 405     for (int i = 0; i < number_of_exception_states(); i++) {
 406       exception_state_at(i)->values_do(f);
 407     }
 408   }
 409 }
 410 
 411 
 412 StoreField::StoreField(Value obj, int offset, ciField* field, Value value, bool is_static,
 413                        ValueStack* state_before, bool needs_patching)
 414   : AccessField(obj, offset, field, is_static, state_before, needs_patching)
 415   , _value(value)
 416   , _enclosing_field(NULL)
 417 {
 418   set_flag(NeedsWriteBarrierFlag, as_ValueType(field_type())->is_object());
 419 #ifdef ASSERT
 420   AssertValues assert_value;
 421   values_do(&assert_value);
 422 #endif
 423   pin();
 424   if (value->as_NewInlineTypeInstance() != NULL) {
 425     value->as_NewInlineTypeInstance()->set_not_larva_anymore();
 426   }
 427 }
 428 
 429 StoreIndexed::StoreIndexed(Value array, Value index, Value length, BasicType elt_type, Value value,
 430                            ValueStack* state_before, bool check_boolean, bool mismatched)
 431   : AccessIndexed(array, index, length, elt_type, state_before, mismatched)
 432   , _value(value), _check_boolean(check_boolean)
 433 {
 434   set_flag(NeedsWriteBarrierFlag, (as_ValueType(elt_type)->is_object()));
 435   set_flag(NeedsStoreCheckFlag, (as_ValueType(elt_type)->is_object()));
 436 #ifdef ASSERT
 437   AssertValues assert_value;
 438   values_do(&assert_value);
 439 #endif
 440   pin();
 441   if (value->as_NewInlineTypeInstance() != NULL) {
 442     value->as_NewInlineTypeInstance()->set_not_larva_anymore();
 443   }
 444 }
 445 
 446 
 447 // Implementation of Invoke
 448 
 449 
 450 Invoke::Invoke(Bytecodes::Code code, ValueType* result_type, Value recv, Values* args,
 451                ciMethod* target, ValueStack* state_before, bool null_free)
 452   : StateSplit(result_type, state_before)
 453   , _code(code)
 454   , _recv(recv)
 455   , _args(args)
 456   , _target(target)
 457 {
 458   set_flag(TargetIsLoadedFlag,   target->is_loaded());
 459   set_flag(TargetIsFinalFlag,    target_is_loaded() && target->is_final_method());
 460   set_null_free(null_free);
 461 
 462   assert(args != NULL, "args must exist");
 463 #ifdef ASSERT
 464   AssertValues assert_value;
 465   values_do(&assert_value);
 466 #endif
 467 
 468   // provide an initial guess of signature size.
 469   _signature = new BasicTypeList(number_of_arguments() + (has_receiver() ? 1 : 0));
 470   if (has_receiver()) {
 471     _signature->append(as_BasicType(receiver()->type()));
 472     if (receiver()->as_NewInlineTypeInstance() != NULL) {
 473       receiver()->as_NewInlineTypeInstance()->set_not_larva_anymore();
 474     }
 475   }
 476   for (int i = 0; i < number_of_arguments(); i++) {
 477     Value v = argument_at(i);
 478     ValueType* t = v->type();
 479     BasicType bt = as_BasicType(t);
 480     _signature->append(bt);
 481     if (v->as_NewInlineTypeInstance() != NULL) {
 482       v->as_NewInlineTypeInstance()->set_not_larva_anymore();
 483     }
 484   }
 485 }
 486 
 487 
 488 void Invoke::state_values_do(ValueVisitor* f) {
 489   StateSplit::state_values_do(f);
 490   if (state_before() != NULL) state_before()->values_do(f);
 491   if (state()        != NULL) state()->values_do(f);
 492 }
 493 
 494 ciType* Invoke::declared_type() const {
 495   ciSignature* declared_signature = state()->scope()->method()->get_declared_signature_at_bci(state()->bci());
 496   ciType *t = declared_signature->return_type();
 497   assert(t->basic_type() != T_VOID, "need return value of void method?");
 498   return t;
 499 }
 500 
 501 // Implementation of Contant
 502 intx Constant::hash() const {
 503   if (state_before() == NULL) {

 976       // check that all necessary phi functions are present
 977       for_each_stack_value(existing_state, index, existing_value) {
 978         assert(existing_value->as_Phi() != NULL && existing_value->as_Phi()->block() == this, "phi function required");
 979       }
 980       for_each_local_value(existing_state, index, existing_value) {
 981         assert(existing_value == new_state->local_at(index) || (existing_value->as_Phi() != NULL && existing_value->as_Phi()->as_Phi()->block() == this), "phi function required");
 982       }
 983 #endif
 984 
 985     } else {
 986       TRACE_PHI(tty->print_cr("creating phi functions on demand"));
 987 
 988       // create necessary phi functions for stack
 989       for_each_stack_value(existing_state, index, existing_value) {
 990         Value new_value = new_state->stack_at(index);
 991         Phi* existing_phi = existing_value->as_Phi();
 992 
 993         if (new_value != existing_value && (existing_phi == NULL || existing_phi->block() != this)) {
 994           existing_state->setup_phi_for_stack(this, index);
 995           TRACE_PHI(tty->print_cr("creating phi-function %c%d for stack %d", existing_state->stack_at(index)->type()->tchar(), existing_state->stack_at(index)->id(), index));
 996           if (new_value->as_NewInlineTypeInstance() != NULL) {new_value->as_NewInlineTypeInstance()->set_not_larva_anymore(); }
 997           if (existing_value->as_NewInlineTypeInstance() != NULL) {existing_value->as_NewInlineTypeInstance()->set_not_larva_anymore(); }
 998         }
 999       }
1000 
1001       // create necessary phi functions for locals
1002       for_each_local_value(existing_state, index, existing_value) {
1003         Value new_value = new_state->local_at(index);
1004         Phi* existing_phi = existing_value->as_Phi();
1005 
1006         if (new_value == NULL || new_value->type()->tag() != existing_value->type()->tag()) {
1007           existing_state->invalidate_local(index);
1008           TRACE_PHI(tty->print_cr("invalidating local %d because of type mismatch", index));
1009         } else if (new_value != existing_value && (existing_phi == NULL || existing_phi->block() != this)) {
1010           existing_state->setup_phi_for_local(this, index);
1011           TRACE_PHI(tty->print_cr("creating phi-function %c%d for local %d", existing_state->local_at(index)->type()->tchar(), existing_state->local_at(index)->id(), index));
1012           if (new_value->as_NewInlineTypeInstance() != NULL) {new_value->as_NewInlineTypeInstance()->set_not_larva_anymore(); }
1013           if (existing_value->as_NewInlineTypeInstance() != NULL) {existing_value->as_NewInlineTypeInstance()->set_not_larva_anymore(); }
1014         }
1015       }
1016     }
1017 
1018     assert(existing_state->caller_state() == new_state->caller_state(), "caller states must be equal");
1019 
1020   } else {
1021     assert(false, "stack or locks not matching (invalid bytecodes)");
1022     return false;
1023   }
1024 
1025   TRACE_PHI(tty->print_cr("********** try_merge for block B%d successful", block_id()));
1026 
1027   return true;
1028 }
1029 
1030 
1031 #ifndef PRODUCT
1032 void BlockBegin::print_block() {
1033   InstructionPrinter ip;

1160   ip1.print_instr(x);
1161 
1162   stringStream strStream2;
1163   InstructionPrinter ip2(1, &strStream2);
1164   ip2.print_instr(y);
1165 
1166   stringStream ss;
1167   ss.print("Assertion %s %s %s in method %s", strStream1.as_string(), ip2.cond_name(cond), strStream2.as_string(), strStream.as_string());
1168 
1169   _message = ss.as_string();
1170 }
1171 #endif
1172 
1173 void RangeCheckPredicate::check_state() {
1174   assert(state()->kind() != ValueStack::EmptyExceptionState && state()->kind() != ValueStack::ExceptionState, "will deopt with empty state");
1175 }
1176 
1177 void ProfileInvoke::state_values_do(ValueVisitor* f) {
1178   if (state() != NULL) state()->values_do(f);
1179 }
1180 
< prev index next >