src/share/vm/opto/graphKit.cpp

Print this page
rev 1178 : merge with cd37471eaecc from http://hg.openjdk.java.net/jdk7/hotspot-comp/hotspot


 438     }
 439   } else {
 440     set_jvms(phi_map->jvms());
 441   }
 442 
 443   assert(!is_hidden_merge(phi_map->control()), "hidden ex. states cleared");
 444   assert(!is_hidden_merge(phi_map->i_o()), "hidden ex. states cleared");
 445   return ex_oop;
 446 }
 447 
 448 //---------------------------------java_bc-------------------------------------
 449 Bytecodes::Code GraphKit::java_bc() const {
 450   ciMethod* method = this->method();
 451   int       bci    = this->bci();
 452   if (method != NULL && bci != InvocationEntryBci)
 453     return method->java_code_at_bci(bci);
 454   else
 455     return Bytecodes::_illegal;
 456 }
 457 
 458 //------------------------------builtin_throw----------------------------------
 459 void GraphKit::builtin_throw(Deoptimization::DeoptReason reason, Node* arg) {
 460   bool must_throw = true;















 461 
 462   if (env()->jvmti_can_post_exceptions()) {

 463     // Do not try anything fancy if we're notifying the VM on every throw.
 464     // Cf. case Bytecodes::_athrow in parse2.cpp.
 465     uncommon_trap(reason, Deoptimization::Action_none,
 466                   (ciKlass*)NULL, (char*)NULL, must_throw);
 467     return;












 468   }
 469 
 470   // If this particular condition has not yet happened at this
 471   // bytecode, then use the uncommon trap mechanism, and allow for
 472   // a future recompilation if several traps occur here.
 473   // If the throw is hot, try to use a more complicated inline mechanism
 474   // which keeps execution inside the compiled code.
 475   bool treat_throw_as_hot = false;
 476   ciMethodData* md = method()->method_data();
 477 
 478   if (ProfileTraps) {
 479     if (too_many_traps(reason)) {
 480       treat_throw_as_hot = true;
 481     }
 482     // (If there is no MDO at all, assume it is early in
 483     // execution, and that any deopts are part of the
 484     // startup transient, and don't need to be remembered.)
 485 
 486     // Also, if there is a local exception handler, treat all throws
 487     // as hot if there has been at least one in this method.




 438     }
 439   } else {
 440     set_jvms(phi_map->jvms());
 441   }
 442 
 443   assert(!is_hidden_merge(phi_map->control()), "hidden ex. states cleared");
 444   assert(!is_hidden_merge(phi_map->i_o()), "hidden ex. states cleared");
 445   return ex_oop;
 446 }
 447 
 448 //---------------------------------java_bc-------------------------------------
 449 Bytecodes::Code GraphKit::java_bc() const {
 450   ciMethod* method = this->method();
 451   int       bci    = this->bci();
 452   if (method != NULL && bci != InvocationEntryBci)
 453     return method->java_code_at_bci(bci);
 454   else
 455     return Bytecodes::_illegal;
 456 }
 457 
 458 void GraphKit::uncommon_trap_if_should_post_on_exceptions(Deoptimization::DeoptReason reason,
 459                                                           bool must_throw) {
 460     // if the exception capability is set, then we will generate code
 461     // to check the JavaThread.should_post_on_exceptions flag to see
 462     // if we actually need to report exception events (for this
 463     // thread).  If we don't need to report exception events, we will
 464     // take the normal fast path provided by add_exception_events.  If
 465     // exception event reporting is enabled for this thread, we will
 466     // take the uncommon_trap in the BuildCutout below.
 467     
 468     // first must access the should_post_on_exceptions_flag in this thread's JavaThread
 469     Node* jthread = _gvn.transform(new (C, 1) ThreadLocalNode());
 470     Node* adr = basic_plus_adr(top(), jthread, in_bytes(JavaThread::should_post_on_exceptions_flag_offset()));
 471     Node* should_post_flag = make_load(control(), adr, TypeInt::INT, T_INT, Compile::AliasIdxRaw, false);
 472     
 473     // Test the should_post_on_exceptions_flag vs. 0
 474     Node* chk = _gvn.transform( new (C, 3) CmpINode(should_post_flag, intcon(0)) );
 475     Node* tst = _gvn.transform( new (C, 2) BoolNode(chk, BoolTest::eq) );
 476     
 477     // Branch to slow_path if should_post_on_exceptions_flag was true
 478     { BuildCutout unless(this, tst, PROB_MAX);
 479       // Do not try anything fancy if we're notifying the VM on every throw.
 480       // Cf. case Bytecodes::_athrow in parse2.cpp.
 481       uncommon_trap(reason, Deoptimization::Action_none,
 482                     (ciKlass*)NULL, (char*)NULL, must_throw);
 483     }
 484 
 485 }
 486 
 487 //------------------------------builtin_throw----------------------------------
 488 void GraphKit::builtin_throw(Deoptimization::DeoptReason reason, Node* arg) {
 489   bool must_throw = true;
 490 
 491   if (env()->jvmti_can_post_on_exceptions()) {
 492     // check if we must post exception events, take uncommon trap if so
 493     uncommon_trap_if_should_post_on_exceptions(reason, must_throw);
 494     // here if should_post_on_exceptions is false
 495     // continue on with the normal codegen
 496   }
 497 
 498   // If this particular condition has not yet happened at this
 499   // bytecode, then use the uncommon trap mechanism, and allow for
 500   // a future recompilation if several traps occur here.
 501   // If the throw is hot, try to use a more complicated inline mechanism
 502   // which keeps execution inside the compiled code.
 503   bool treat_throw_as_hot = false;
 504   ciMethodData* md = method()->method_data();
 505 
 506   if (ProfileTraps) {
 507     if (too_many_traps(reason)) {
 508       treat_throw_as_hot = true;
 509     }
 510     // (If there is no MDO at all, assume it is early in
 511     // execution, and that any deopts are part of the
 512     // startup transient, and don't need to be remembered.)
 513 
 514     // Also, if there is a local exception handler, treat all throws
 515     // as hot if there has been at least one in this method.