src/share/vm/opto/doCall.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/opto

src/share/vm/opto/doCall.cpp

Print this page
rev 6132 : 8031755: Type speculation should be used to optimize explicit null checks
Summary: feed profiling data about reference nullness to type speculation.
Reviewed-by:


 614     // If the return type of the method is not loaded, assert that the
 615     // value we got is a null.  Otherwise, we need to recompile.
 616     if (!rtype->is_loaded()) {
 617 #ifndef PRODUCT
 618       if (PrintOpto && (Verbose || WizardMode)) {
 619         method()->print_name(); tty->print_cr(" asserting nullness of result at bci: %d", bci());
 620         cg->method()->print_name(); tty->cr();
 621       }
 622 #endif
 623       if (C->log() != NULL) {
 624         C->log()->elem("assert_null reason='return' klass='%d'",
 625                        C->log()->identify(rtype));
 626       }
 627       // If there is going to be a trap, put it at the next bytecode:
 628       set_bci(iter().next_bci());
 629       null_assert(peek());
 630       set_bci(iter().cur_bci()); // put it back
 631     }
 632     BasicType ct = ctype->basic_type();
 633     if (ct == T_OBJECT || ct == T_ARRAY) {
 634       ciKlass* better_type = method()->return_profiled_type(bci());
 635       if (UseTypeSpeculation && better_type != NULL) {
 636         // If profiling reports a single type for the return value,
 637         // feed it to the type system so it can propagate it as a
 638         // speculative type
 639         record_profile_for_speculation(stack(sp()-1), better_type);
 640       }
 641     }
 642   }
 643 
 644   // Restart record of parsing work after possible inlining of call
 645 #ifndef PRODUCT
 646   parse_histogram()->set_initial_state(bc());
 647 #endif
 648 }
 649 
 650 //---------------------------catch_call_exceptions-----------------------------
 651 // Put a Catch and CatchProj nodes behind a just-created call.
 652 // Send their caught exceptions to the proper handler.
 653 // This may be used after a call to the rethrow VM stub,
 654 // when it is needed to process unloaded exception classes.
 655 void Parse::catch_call_exceptions(ciExceptionHandlerStream& handlers) {
 656   // Exceptions are delivered through this channel:
 657   Node* i_o = this->i_o();
 658 
 659   // Add a CatchNode.
 660   GrowableArray<int>* bcis = new (C->node_arena()) GrowableArray<int>(C->node_arena(), 8, 0, -1);




 614     // If the return type of the method is not loaded, assert that the
 615     // value we got is a null.  Otherwise, we need to recompile.
 616     if (!rtype->is_loaded()) {
 617 #ifndef PRODUCT
 618       if (PrintOpto && (Verbose || WizardMode)) {
 619         method()->print_name(); tty->print_cr(" asserting nullness of result at bci: %d", bci());
 620         cg->method()->print_name(); tty->cr();
 621       }
 622 #endif
 623       if (C->log() != NULL) {
 624         C->log()->elem("assert_null reason='return' klass='%d'",
 625                        C->log()->identify(rtype));
 626       }
 627       // If there is going to be a trap, put it at the next bytecode:
 628       set_bci(iter().next_bci());
 629       null_assert(peek());
 630       set_bci(iter().cur_bci()); // put it back
 631     }
 632     BasicType ct = ctype->basic_type();
 633     if (ct == T_OBJECT || ct == T_ARRAY) {
 634       record_profiled_return_for_speculation();






 635     }
 636   }
 637 
 638   // Restart record of parsing work after possible inlining of call
 639 #ifndef PRODUCT
 640   parse_histogram()->set_initial_state(bc());
 641 #endif
 642 }
 643 
 644 //---------------------------catch_call_exceptions-----------------------------
 645 // Put a Catch and CatchProj nodes behind a just-created call.
 646 // Send their caught exceptions to the proper handler.
 647 // This may be used after a call to the rethrow VM stub,
 648 // when it is needed to process unloaded exception classes.
 649 void Parse::catch_call_exceptions(ciExceptionHandlerStream& handlers) {
 650   // Exceptions are delivered through this channel:
 651   Node* i_o = this->i_o();
 652 
 653   // Add a CatchNode.
 654   GrowableArray<int>* bcis = new (C->node_arena()) GrowableArray<int>(C->node_arena(), 8, 0, -1);


src/share/vm/opto/doCall.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File