577 578 579 void ciMethod::assert_virtual_call_type_ok(int bci) { 580 assert(java_code_at_bci(bci) == Bytecodes::_invokevirtual || 581 java_code_at_bci(bci) == Bytecodes::_invokeinterface, "unexpected bytecode %s", Bytecodes::name(java_code_at_bci(bci))); 582 } 583 584 void ciMethod::assert_call_type_ok(int bci) { 585 assert(java_code_at_bci(bci) == Bytecodes::_invokestatic || 586 java_code_at_bci(bci) == Bytecodes::_invokespecial || 587 java_code_at_bci(bci) == Bytecodes::_invokedynamic, "unexpected bytecode %s", Bytecodes::name(java_code_at_bci(bci))); 588 } 589 590 /** 591 * Check whether profiling provides a type for the argument i to the 592 * call at bci bci 593 * 594 * @param [in]bci bci of the call 595 * @param [in]i argument number 596 * @param [out]type profiled type of argument, NULL if none 597 * @param [out]maybe_null true if null was seen for argument 598 * @return true if profiling exists 599 * 600 */ 601 bool ciMethod::argument_profiled_type(int bci, int i, ciKlass*& type, bool& maybe_null) { 602 if (MethodData::profile_parameters() && method_data() != NULL && method_data()->is_mature()) { 603 ciProfileData* data = method_data()->bci_to_data(bci); 604 if (data != NULL) { 605 if (data->is_VirtualCallTypeData()) { 606 assert_virtual_call_type_ok(bci); 607 ciVirtualCallTypeData* call = (ciVirtualCallTypeData*)data->as_VirtualCallTypeData(); 608 if (i >= call->number_of_arguments()) { 609 return false; 610 } 611 type = call->valid_argument_type(i); 612 maybe_null = call->argument_maybe_null(i); 613 return true; 614 } else if (data->is_CallTypeData()) { 615 assert_call_type_ok(bci); 616 ciCallTypeData* call = (ciCallTypeData*)data->as_CallTypeData(); 617 if (i >= call->number_of_arguments()) { 618 return false; 619 } 620 type = call->valid_argument_type(i); 621 maybe_null = call->argument_maybe_null(i); 622 return true; 623 } 624 } 625 } 626 return false; 627 } 628 629 /** 630 * Check whether profiling provides a type for the return value from 631 * the call at bci bci 632 * 633 * @param [in]bci bci of the call 634 * @param [out]type profiled type of argument, NULL if none 635 * @param [out]maybe_null true if null was seen for argument 636 * @return true if profiling exists 637 * 638 */ 639 bool ciMethod::return_profiled_type(int bci, ciKlass*& type, bool& maybe_null) { 640 if (MethodData::profile_return() && method_data() != NULL && method_data()->is_mature()) { 641 ciProfileData* data = method_data()->bci_to_data(bci); 642 if (data != NULL) { 643 if (data->is_VirtualCallTypeData()) { 644 assert_virtual_call_type_ok(bci); 645 ciVirtualCallTypeData* call = (ciVirtualCallTypeData*)data->as_VirtualCallTypeData(); 646 type = call->valid_return_type(); 647 maybe_null = call->return_maybe_null(); 648 return true; 649 } else if (data->is_CallTypeData()) { 650 assert_call_type_ok(bci); 651 ciCallTypeData* call = (ciCallTypeData*)data->as_CallTypeData(); 652 type = call->valid_return_type(); 653 maybe_null = call->return_maybe_null(); 654 return true; 655 } 656 } 657 } 658 return false; 659 } 660 661 /** 662 * Check whether profiling provides a type for the parameter i 663 * 664 * @param [in]i parameter number 665 * @param [out]type profiled type of parameter, NULL if none 666 * @param [out]maybe_null true if null was seen for parameter 667 * @return true if profiling exists 668 * 669 */ 670 bool ciMethod::parameter_profiled_type(int i, ciKlass*& type, bool& maybe_null) { 671 if (MethodData::profile_parameters() && method_data() != NULL && method_data()->is_mature()) { 672 ciParametersTypeData* parameters = method_data()->parameters_type_data(); 673 if (parameters != NULL && i < parameters->number_of_parameters()) { 674 type = parameters->valid_parameter_type(i); 675 maybe_null = parameters->parameter_maybe_null(i); 676 return true; 677 } 678 } 679 return false; 680 } 681 682 683 // ------------------------------------------------------------------ 684 // ciMethod::find_monomorphic_target 685 // 686 // Given a certain calling environment, find the monomorphic target 687 // for the call. Return NULL if the call is not monomorphic in 688 // its calling environment, or if there are only abstract methods. 689 // The returned method is never abstract. 690 // Note: If caller uses a non-null result, it must inform dependencies 691 // via assert_unique_concrete_method or assert_leaf_type. 692 ciMethod* ciMethod::find_monomorphic_target(ciInstanceKlass* caller, 693 ciInstanceKlass* callee_holder, 694 ciInstanceKlass* actual_recv, 695 bool check_access) { | 577 578 579 void ciMethod::assert_virtual_call_type_ok(int bci) { 580 assert(java_code_at_bci(bci) == Bytecodes::_invokevirtual || 581 java_code_at_bci(bci) == Bytecodes::_invokeinterface, "unexpected bytecode %s", Bytecodes::name(java_code_at_bci(bci))); 582 } 583 584 void ciMethod::assert_call_type_ok(int bci) { 585 assert(java_code_at_bci(bci) == Bytecodes::_invokestatic || 586 java_code_at_bci(bci) == Bytecodes::_invokespecial || 587 java_code_at_bci(bci) == Bytecodes::_invokedynamic, "unexpected bytecode %s", Bytecodes::name(java_code_at_bci(bci))); 588 } 589 590 /** 591 * Check whether profiling provides a type for the argument i to the 592 * call at bci bci 593 * 594 * @param [in]bci bci of the call 595 * @param [in]i argument number 596 * @param [out]type profiled type of argument, NULL if none 597 * @param [out]ptr_kind whether always null, never null or maybe null 598 * @return true if profiling exists 599 * 600 */ 601 bool ciMethod::argument_profiled_type(int bci, int i, ciKlass*& type, ProfilePtrKind& ptr_kind) { 602 if (MethodData::profile_parameters() && method_data() != NULL && method_data()->is_mature()) { 603 ciProfileData* data = method_data()->bci_to_data(bci); 604 if (data != NULL) { 605 if (data->is_VirtualCallTypeData()) { 606 assert_virtual_call_type_ok(bci); 607 ciVirtualCallTypeData* call = (ciVirtualCallTypeData*)data->as_VirtualCallTypeData(); 608 if (i >= call->number_of_arguments()) { 609 return false; 610 } 611 type = call->valid_argument_type(i); 612 ptr_kind = call->argument_ptr_kind(i); 613 return true; 614 } else if (data->is_CallTypeData()) { 615 assert_call_type_ok(bci); 616 ciCallTypeData* call = (ciCallTypeData*)data->as_CallTypeData(); 617 if (i >= call->number_of_arguments()) { 618 return false; 619 } 620 type = call->valid_argument_type(i); 621 ptr_kind = call->argument_ptr_kind(i); 622 return true; 623 } 624 } 625 } 626 return false; 627 } 628 629 /** 630 * Check whether profiling provides a type for the return value from 631 * the call at bci bci 632 * 633 * @param [in]bci bci of the call 634 * @param [out]type profiled type of argument, NULL if none 635 * @param [out]ptr_kind whether always null, never null or maybe null 636 * @return true if profiling exists 637 * 638 */ 639 bool ciMethod::return_profiled_type(int bci, ciKlass*& type, ProfilePtrKind& ptr_kind) { 640 if (MethodData::profile_return() && method_data() != NULL && method_data()->is_mature()) { 641 ciProfileData* data = method_data()->bci_to_data(bci); 642 if (data != NULL) { 643 if (data->is_VirtualCallTypeData()) { 644 assert_virtual_call_type_ok(bci); 645 ciVirtualCallTypeData* call = (ciVirtualCallTypeData*)data->as_VirtualCallTypeData(); 646 if (call->has_return()) { 647 type = call->valid_return_type(); 648 ptr_kind = call->return_ptr_kind(); 649 return true; 650 } 651 } else if (data->is_CallTypeData()) { 652 assert_call_type_ok(bci); 653 ciCallTypeData* call = (ciCallTypeData*)data->as_CallTypeData(); 654 if (call->has_return()) { 655 type = call->valid_return_type(); 656 ptr_kind = call->return_ptr_kind(); 657 } 658 return true; 659 } 660 } 661 } 662 return false; 663 } 664 665 /** 666 * Check whether profiling provides a type for the parameter i 667 * 668 * @param [in]i parameter number 669 * @param [out]type profiled type of parameter, NULL if none 670 * @param [out]ptr_kind whether always null, never null or maybe null 671 * @return true if profiling exists 672 * 673 */ 674 bool ciMethod::parameter_profiled_type(int i, ciKlass*& type, ProfilePtrKind& ptr_kind) { 675 if (MethodData::profile_parameters() && method_data() != NULL && method_data()->is_mature()) { 676 ciParametersTypeData* parameters = method_data()->parameters_type_data(); 677 if (parameters != NULL && i < parameters->number_of_parameters()) { 678 type = parameters->valid_parameter_type(i); 679 ptr_kind = parameters->parameter_ptr_kind(i); 680 return true; 681 } 682 } 683 return false; 684 } 685 686 687 // ------------------------------------------------------------------ 688 // ciMethod::find_monomorphic_target 689 // 690 // Given a certain calling environment, find the monomorphic target 691 // for the call. Return NULL if the call is not monomorphic in 692 // its calling environment, or if there are only abstract methods. 693 // The returned method is never abstract. 694 // Note: If caller uses a non-null result, it must inform dependencies 695 // via assert_unique_concrete_method or assert_leaf_type. 696 ciMethod* ciMethod::find_monomorphic_target(ciInstanceKlass* caller, 697 ciInstanceKlass* callee_holder, 698 ciInstanceKlass* actual_recv, 699 bool check_access) { |