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




 376   // caller  = method()
 377   // iter().get_method_holder_index()
 378   assert( dest_method->is_loaded(), "ciTypeFlow should not let us get here" );
 379   // Interface classes can be loaded & linked and never get around to
 380   // being initialized.  Uncommon-trap for not-initialized static or
 381   // v-calls.  Let interface calls happen.
 382   ciInstanceKlass* holder_klass = dest_method->holder();
 383   if (!holder_klass->is_being_initialized() &&
 384       !holder_klass->is_initialized() &&
 385       !holder_klass->is_interface()) {
 386     uncommon_trap(Deoptimization::Reason_uninitialized,
 387                   Deoptimization::Action_reinterpret,
 388                   holder_klass);
 389     return true;
 390   }
 391 
 392   assert(dest_method->is_loaded(), "dest_method: typeflow responsibility");
 393   return false;
 394 }
 395 






























































































 396 
 397 //------------------------------do_call----------------------------------------
 398 // Handle your basic call.  Inline if we can & want to, else just setup call.
 399 void Parse::do_call() {
 400   // It's likely we are going to add debug info soon.
 401   // Also, if we inline a guy who eventually needs debug info for this JVMS,
 402   // our contribution to it is cleaned up right here.
 403   kill_dead_locals();
 404 
 405   C->print_inlining_assert_ready();
 406 
 407   // Set frequently used booleans
 408   const bool is_virtual = bc() == Bytecodes::_invokevirtual;
 409   const bool is_virtual_or_interface = is_virtual || bc() == Bytecodes::_invokeinterface;
 410   const bool has_receiver = Bytecodes::has_receiver(bc());
 411 
 412   // Find target being called
 413   bool             will_link;
 414   ciSignature*     declared_signature = NULL;
 415   ciMethod*        orig_callee  = iter().get_method(will_link, &declared_signature);  // callee in the bytecode


 554       return;
 555     }
 556   }
 557 
 558   if (cg->is_inline()) {
 559     // Accumulate has_loops estimate
 560     C->set_has_loops(C->has_loops() || cg->method()->has_loops());
 561     C->env()->notice_inlined_method(cg->method());
 562   }
 563 
 564   // Reset parser state from [new_]jvms, which now carries results of the call.
 565   // Return value (if any) is already pushed on the stack by the cg.
 566   add_exception_states_from(new_jvms);
 567   if (new_jvms->map()->control() == top()) {
 568     stop_and_kill_map();
 569   } else {
 570     assert(new_jvms->same_calls_as(jvms), "method/bci left unchanged");
 571     set_jvms(new_jvms);
 572   }
 573 


 574   if (!stopped()) {
 575     // This was some sort of virtual call, which did a null check for us.
 576     // Now we can assert receiver-not-null, on the normal return path.
 577     if (receiver != NULL && cg->is_virtual()) {
 578       Node* cast = cast_not_null(receiver);
 579       // %%% assert(receiver == cast, "should already have cast the receiver");
 580     }
 581 
 582     // Round double result after a call from strict to non-strict code
 583     round_double_result(cg->method());
 584 
 585     ciType* rtype = cg->method()->return_type();
 586     ciType* ctype = declared_signature->return_type();
 587 
 588     if (Bytecodes::has_optional_appendix(iter().cur_bc_raw()) || is_signature_polymorphic) {
 589       // Be careful here with return types.
 590       if (ctype != rtype) {
 591         BasicType rt = rtype->basic_type();
 592         BasicType ct = ctype->basic_type();
 593         if (ct == T_VOID) {




 376   // caller  = method()
 377   // iter().get_method_holder_index()
 378   assert( dest_method->is_loaded(), "ciTypeFlow should not let us get here" );
 379   // Interface classes can be loaded & linked and never get around to
 380   // being initialized.  Uncommon-trap for not-initialized static or
 381   // v-calls.  Let interface calls happen.
 382   ciInstanceKlass* holder_klass = dest_method->holder();
 383   if (!holder_klass->is_being_initialized() &&
 384       !holder_klass->is_initialized() &&
 385       !holder_klass->is_interface()) {
 386     uncommon_trap(Deoptimization::Reason_uninitialized,
 387                   Deoptimization::Action_reinterpret,
 388                   holder_klass);
 389     return true;
 390   }
 391 
 392   assert(dest_method->is_loaded(), "dest_method: typeflow responsibility");
 393   return false;
 394 }
 395 
 396 #ifdef ASSERT
 397 static bool check_type(ciType* t1, ciType* t2) {
 398   // Either oop-oop or prim-prim pair.
 399   if (t1->is_primitive_type() && t2->is_primitive_type()) {
 400     return t1->size() == t2->size(); // argument sizes should match
 401   } else {
 402     return !t1->is_primitive_type() && !t2->is_primitive_type(); // oop-oop
 403   }
 404 }
 405 
 406 static bool check_inlined_mh_linker_info(ciMethod* symbolic_info, ciMethod* resolved_method) {
 407   assert(symbolic_info->is_method_handle_intrinsic(), "sanity");
 408   assert(!resolved_method->is_method_handle_intrinsic(), "sanity");
 409 
 410   if (!symbolic_info->is_loaded() || !resolved_method->is_loaded()) {
 411     return true; // Don't compare unloaded methods.
 412   }
 413   // Linkers have appendix argument which is not passed to callee.
 414   int has_appendix = MethodHandles::has_member_arg(symbolic_info->intrinsic_id()) ? 1 : 0;
 415   if (symbolic_info->arg_size() != (resolved_method->arg_size() + has_appendix)) {
 416     return false; // Total size of arguments on stack mismatch.
 417   }
 418   if (!check_type(symbolic_info->return_type(), resolved_method->return_type())) {
 419     return false; // Return value size or type mismatch encountered.
 420   }
 421 
 422   switch (symbolic_info->intrinsic_id()) {
 423     case vmIntrinsics::_linkToVirtual:
 424     case vmIntrinsics::_linkToInterface:
 425     case vmIntrinsics::_linkToSpecial: {
 426       if (resolved_method->is_static())  return false;
 427       break;
 428     }
 429     case vmIntrinsics::_linkToStatic: {
 430       if (!resolved_method->is_static())  return false;
 431       break;
 432     }
 433   }
 434 
 435   ciSignature* symbolic_sig = symbolic_info->signature();
 436   ciSignature* resolved_sig = resolved_method->signature();
 437 
 438   if (symbolic_sig->count() + (symbolic_info->is_static() ? 0 : 1) !=
 439       resolved_sig->count() + (resolved_method->is_static() ? 0 : 1) + has_appendix) {
 440     return false; // Argument count mismatch
 441   }
 442 
 443   int sbase = 0, rbase = 0;
 444   int arg_count = MIN2(symbolic_sig->count() - has_appendix, resolved_sig->count());
 445   ciType* recv_type = NULL;
 446   if (symbolic_info->is_static() && !resolved_method->is_static()) {
 447     recv_type = symbolic_sig->type_at(0);
 448     sbase = 1;
 449   } else if (!symbolic_info->is_static() && resolved_method->is_static()) {
 450     recv_type = resolved_sig->type_at(0);
 451     rbase = 1;
 452   }
 453   if (recv_type != NULL && recv_type->is_primitive_type()) {
 454     return false; // Receiver should be an oop.
 455   }
 456   for (int i = 0; i < arg_count; i++) {
 457     if (!check_type(symbolic_sig->type_at(sbase + i), resolved_sig->type_at(rbase + i))) {
 458       return false; // Argument size or type mismatch encountered.
 459     }
 460   }
 461   return true;
 462 }
 463 
 464 static bool is_call_consistent_with_jvms(JVMState* jvms, CallGenerator* cg) {
 465   ciMethod* symbolic_info = jvms->method()->get_method_at_bci(jvms->bci());
 466   ciMethod* resolved_method = cg->method();
 467 
 468   if (CallGenerator::is_inlined_mh_linker(jvms, resolved_method)) {
 469     return check_inlined_mh_linker_info(symbolic_info, resolved_method);
 470   } else {
 471     // Method name & descriptor should stay the same.
 472     return (symbolic_info->get_Method()->name() == resolved_method->get_Method()->name()) &&
 473            (symbolic_info->get_Method()->signature() == resolved_method->get_Method()->signature());
 474   }
 475 }
 476 
 477 static bool check_call_consistency(JVMState* jvms, CallGenerator* cg) {
 478   if (!is_call_consistent_with_jvms(jvms, cg)) {
 479     tty->print_cr("JVMS:");
 480     jvms->dump();
 481     tty->print_cr("Bytecode info:");
 482     jvms->method()->get_method_at_bci(jvms->bci())->print(); tty->cr();
 483     tty->print_cr("Resolved method:");
 484     cg->method()->print(); tty->cr();
 485     return false;
 486   }
 487   return true;
 488 }
 489 #endif // ASSERT
 490 
 491 //------------------------------do_call----------------------------------------
 492 // Handle your basic call.  Inline if we can & want to, else just setup call.
 493 void Parse::do_call() {
 494   // It's likely we are going to add debug info soon.
 495   // Also, if we inline a guy who eventually needs debug info for this JVMS,
 496   // our contribution to it is cleaned up right here.
 497   kill_dead_locals();
 498 
 499   C->print_inlining_assert_ready();
 500 
 501   // Set frequently used booleans
 502   const bool is_virtual = bc() == Bytecodes::_invokevirtual;
 503   const bool is_virtual_or_interface = is_virtual || bc() == Bytecodes::_invokeinterface;
 504   const bool has_receiver = Bytecodes::has_receiver(bc());
 505 
 506   // Find target being called
 507   bool             will_link;
 508   ciSignature*     declared_signature = NULL;
 509   ciMethod*        orig_callee  = iter().get_method(will_link, &declared_signature);  // callee in the bytecode


 648       return;
 649     }
 650   }
 651 
 652   if (cg->is_inline()) {
 653     // Accumulate has_loops estimate
 654     C->set_has_loops(C->has_loops() || cg->method()->has_loops());
 655     C->env()->notice_inlined_method(cg->method());
 656   }
 657 
 658   // Reset parser state from [new_]jvms, which now carries results of the call.
 659   // Return value (if any) is already pushed on the stack by the cg.
 660   add_exception_states_from(new_jvms);
 661   if (new_jvms->map()->control() == top()) {
 662     stop_and_kill_map();
 663   } else {
 664     assert(new_jvms->same_calls_as(jvms), "method/bci left unchanged");
 665     set_jvms(new_jvms);
 666   }
 667 
 668   assert(check_call_consistency(jvms, cg), "inconsistent info");
 669 
 670   if (!stopped()) {
 671     // This was some sort of virtual call, which did a null check for us.
 672     // Now we can assert receiver-not-null, on the normal return path.
 673     if (receiver != NULL && cg->is_virtual()) {
 674       Node* cast = cast_not_null(receiver);
 675       // %%% assert(receiver == cast, "should already have cast the receiver");
 676     }
 677 
 678     // Round double result after a call from strict to non-strict code
 679     round_double_result(cg->method());
 680 
 681     ciType* rtype = cg->method()->return_type();
 682     ciType* ctype = declared_signature->return_type();
 683 
 684     if (Bytecodes::has_optional_appendix(iter().cur_bc_raw()) || is_signature_polymorphic) {
 685       // Be careful here with return types.
 686       if (ctype != rtype) {
 687         BasicType rt = rtype->basic_type();
 688         BasicType ct = ctype->basic_type();
 689         if (ct == T_VOID) {


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