383 // iter().get_method_holder_index() 384 assert( dest_method->is_loaded(), "ciTypeFlow should not let us get here" ); 385 // Interface classes can be loaded & linked and never get around to 386 // being initialized. Uncommon-trap for not-initialized static or 387 // v-calls. Let interface calls happen. 388 ciInstanceKlass* holder_klass = dest_method->holder(); 389 if (!holder_klass->is_being_initialized() && 390 !holder_klass->is_initialized() && 391 !holder_klass->is_interface()) { 392 uncommon_trap(Deoptimization::Reason_uninitialized, 393 Deoptimization::Action_reinterpret, 394 holder_klass); 395 return true; 396 } 397 398 assert(dest_method->is_loaded(), "dest_method: typeflow responsibility"); 399 return false; 400 } 401 402 #ifdef ASSERT 403 static bool check_type(ciType* t1, ciType* t2) { 404 // Either oop-oop or prim-prim pair. 405 if (t1->is_primitive_type() && t2->is_primitive_type()) { 406 return t1->size() == t2->size(); // argument sizes should match 407 } else { 408 return !t1->is_primitive_type() && !t2->is_primitive_type(); // oop-oop 409 } 410 } 411 412 static bool check_inlined_mh_linker_info(ciMethod* symbolic_info, ciMethod* resolved_method) { 413 assert(symbolic_info->is_method_handle_intrinsic(), "sanity"); 414 assert(!resolved_method->is_method_handle_intrinsic(), "sanity"); 415 416 if (!symbolic_info->is_loaded() || !resolved_method->is_loaded()) { 417 return true; // Don't compare unloaded methods. 418 } 419 // Linkers have appendix argument which is not passed to callee. 420 int has_appendix = MethodHandles::has_member_arg(symbolic_info->intrinsic_id()) ? 1 : 0; 421 if (symbolic_info->arg_size() != (resolved_method->arg_size() + has_appendix)) { 422 return false; // Total size of arguments on stack mismatch. 423 } 424 if (!symbolic_info->return_type()->is_void()) { 425 // Only check the return type if the symbolic method is not void 426 // i.e. the return value of the resolved method can be dropped 427 if (!check_type(symbolic_info->return_type(), resolved_method->return_type())) { 428 return false; // Return value size or type mismatch encountered. 429 } 430 } 431 432 switch (symbolic_info->intrinsic_id()) { 433 case vmIntrinsics::_linkToVirtual: 434 case vmIntrinsics::_linkToInterface: 435 case vmIntrinsics::_linkToSpecial: { 436 if (resolved_method->is_static()) return false; 437 break; 438 } 439 case vmIntrinsics::_linkToStatic: { 440 if (!resolved_method->is_static()) return false; 441 break; 442 } 443 } 444 445 ciSignature* symbolic_sig = symbolic_info->signature(); 446 ciSignature* resolved_sig = resolved_method->signature(); 447 448 if (symbolic_sig->count() + (symbolic_info->is_static() ? 0 : 1) != 449 resolved_sig->count() + (resolved_method->is_static() ? 0 : 1) + has_appendix) { 450 return false; // Argument count mismatch 451 } 452 453 int sbase = 0, rbase = 0; 454 int arg_count = MIN2(symbolic_sig->count() - has_appendix, resolved_sig->count()); 455 ciType* recv_type = NULL; 456 if (symbolic_info->is_static() && !resolved_method->is_static()) { 457 recv_type = symbolic_sig->type_at(0); 458 sbase = 1; 459 } else if (!symbolic_info->is_static() && resolved_method->is_static()) { 460 recv_type = resolved_sig->type_at(0); 461 rbase = 1; 462 } 463 if (recv_type != NULL && recv_type->is_primitive_type()) { 464 return false; // Receiver should be an oop. 465 } 466 for (int i = 0; i < arg_count; i++) { 467 if (!check_type(symbolic_sig->type_at(sbase + i), resolved_sig->type_at(rbase + i))) { 468 return false; // Argument size or type mismatch encountered. 469 } 470 } 471 return true; 472 } 473 474 static bool is_call_consistent_with_jvms(JVMState* jvms, CallGenerator* cg) { 475 ciMethod* symbolic_info = jvms->method()->get_method_at_bci(jvms->bci()); 476 ciMethod* resolved_method = cg->method(); 477 478 if (CallGenerator::is_inlined_mh_linker(jvms, resolved_method)) { 479 return check_inlined_mh_linker_info(symbolic_info, resolved_method); 480 } else { 481 // Method name & descriptor should stay the same. 482 return (symbolic_info->get_Method()->name() == resolved_method->get_Method()->name()) && 483 (symbolic_info->get_Method()->signature() == resolved_method->get_Method()->signature()); 484 } 485 } 486 487 static bool check_call_consistency(JVMState* jvms, CallGenerator* cg) { 488 if (!is_call_consistent_with_jvms(jvms, cg)) { 489 tty->print_cr("JVMS:"); 490 jvms->dump(); 491 tty->print_cr("Bytecode info:"); 492 jvms->method()->get_method_at_bci(jvms->bci())->print(); tty->cr(); 493 tty->print_cr("Resolved method:"); 494 cg->method()->print(); tty->cr(); 495 return false; 496 } 497 return true; 498 } 499 #endif // ASSERT | 383 // iter().get_method_holder_index() 384 assert( dest_method->is_loaded(), "ciTypeFlow should not let us get here" ); 385 // Interface classes can be loaded & linked and never get around to 386 // being initialized. Uncommon-trap for not-initialized static or 387 // v-calls. Let interface calls happen. 388 ciInstanceKlass* holder_klass = dest_method->holder(); 389 if (!holder_klass->is_being_initialized() && 390 !holder_klass->is_initialized() && 391 !holder_klass->is_interface()) { 392 uncommon_trap(Deoptimization::Reason_uninitialized, 393 Deoptimization::Action_reinterpret, 394 holder_klass); 395 return true; 396 } 397 398 assert(dest_method->is_loaded(), "dest_method: typeflow responsibility"); 399 return false; 400 } 401 402 #ifdef ASSERT 403 static bool is_call_consistent_with_jvms(JVMState* jvms, CallGenerator* cg) { 404 ciMethod* symbolic_info = jvms->method()->get_method_at_bci(jvms->bci()); 405 ciMethod* resolved_method = cg->method(); 406 407 if (CallGenerator::is_inlined_method_handle_intrinsic(jvms, resolved_method)) { 408 return CallGenerator::ensure_mh_intrinsic_matches_target_method(symbolic_info, resolved_method); 409 } else { 410 // Method name & descriptor should stay the same. 411 return (symbolic_info->get_Method()->name() == resolved_method->get_Method()->name()) && 412 (symbolic_info->get_Method()->signature() == resolved_method->get_Method()->signature()); 413 } 414 } 415 416 static bool check_call_consistency(JVMState* jvms, CallGenerator* cg) { 417 if (!is_call_consistent_with_jvms(jvms, cg)) { 418 tty->print_cr("JVMS:"); 419 jvms->dump(); 420 tty->print_cr("Bytecode info:"); 421 jvms->method()->get_method_at_bci(jvms->bci())->print(); tty->cr(); 422 tty->print_cr("Resolved method:"); 423 cg->method()->print(); tty->cr(); 424 return false; 425 } 426 return true; 427 } 428 #endif // ASSERT |