391 |
391 |
392 assert(dest_method->is_loaded(), "dest_method: typeflow responsibility"); |
392 assert(dest_method->is_loaded(), "dest_method: typeflow responsibility"); |
393 return false; |
393 return false; |
394 } |
394 } |
395 |
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 |
396 |
490 |
397 //------------------------------do_call---------------------------------------- |
491 //------------------------------do_call---------------------------------------- |
398 // Handle your basic call. Inline if we can & want to, else just setup call. |
492 // Handle your basic call. Inline if we can & want to, else just setup call. |
399 void Parse::do_call() { |
493 void Parse::do_call() { |
400 // It's likely we are going to add debug info soon. |
494 // It's likely we are going to add debug info soon. |