548 return result;
549 }
550
551 // ------------------------------------------------------------------
552 // Add new receiver and sort data by receiver's profile count.
553 void ciCallProfile::add_receiver(ciKlass* receiver, int receiver_count) {
554 // Add new receiver and sort data by receiver's counts when we have space
555 // for it otherwise replace the less called receiver (less called receiver
556 // is placed to the last array element which is not used).
557 // First array's element contains most called receiver.
558 int i = _limit;
559 for (; i > 0 && receiver_count > _receiver_count[i-1]; i--) {
560 _receiver[i] = _receiver[i-1];
561 _receiver_count[i] = _receiver_count[i-1];
562 }
563 _receiver[i] = receiver;
564 _receiver_count[i] = receiver_count;
565 if (_limit < MorphismLimit) _limit++;
566 }
567
568 // ------------------------------------------------------------------
569 // ciMethod::find_monomorphic_target
570 //
571 // Given a certain calling environment, find the monomorphic target
572 // for the call. Return NULL if the call is not monomorphic in
573 // its calling environment, or if there are only abstract methods.
574 // The returned method is never abstract.
575 // Note: If caller uses a non-null result, it must inform dependencies
576 // via assert_unique_concrete_method or assert_leaf_type.
577 ciMethod* ciMethod::find_monomorphic_target(ciInstanceKlass* caller,
578 ciInstanceKlass* callee_holder,
579 ciInstanceKlass* actual_recv) {
580 check_is_loaded();
581
582 if (actual_recv->is_interface()) {
583 // %%% We cannot trust interface types, yet. See bug 6312651.
584 return NULL;
585 }
586
587 ciMethod* root_m = resolve_invoke(caller, actual_recv);
|
548 return result;
549 }
550
551 // ------------------------------------------------------------------
552 // Add new receiver and sort data by receiver's profile count.
553 void ciCallProfile::add_receiver(ciKlass* receiver, int receiver_count) {
554 // Add new receiver and sort data by receiver's counts when we have space
555 // for it otherwise replace the less called receiver (less called receiver
556 // is placed to the last array element which is not used).
557 // First array's element contains most called receiver.
558 int i = _limit;
559 for (; i > 0 && receiver_count > _receiver_count[i-1]; i--) {
560 _receiver[i] = _receiver[i-1];
561 _receiver_count[i] = _receiver_count[i-1];
562 }
563 _receiver[i] = receiver;
564 _receiver_count[i] = receiver_count;
565 if (_limit < MorphismLimit) _limit++;
566 }
567
568 // Return true if profiling provides a type for the argument nb to the
569 // call at bci. type is the profiled type.
570 // If the profile reports that the argument may be null, return false
571 // at least for now.
572 bool ciMethod::argument_profiled_type(int bci, int nb, ciKlass*& type) {
573 if (MethodData::profile_parameters() && method_data() != NULL && method_data()->is_mature()) {
574 ciProfileData* data = method_data()->bci_to_data(bci);
575 if (data != NULL) {
576 if (data->is_VirtualCallTypeData()) {
577 assert(java_code_at_bci(bci) == Bytecodes::_invokevirtual ||
578 java_code_at_bci(bci) == Bytecodes::_invokeinterface, "unexpected bytecode");
579 ciVirtualCallTypeData* call = (ciVirtualCallTypeData*)data->as_VirtualCallTypeData();
580 if (nb >= call->number_of_arguments()) {
581 return false;
582 }
583 type = call->valid_argument_type(nb);
584 if (type != NULL && !call->argument_maybe_null(nb)) {
585 return true;
586 }
587 } else if (data->is_CallTypeData()) {
588 assert(java_code_at_bci(bci) == Bytecodes::_invokestatic ||
589 java_code_at_bci(bci) == Bytecodes::_invokespecial ||
590 java_code_at_bci(bci) == Bytecodes::_invokedynamic, "unexpected bytecode");
591 ciCallTypeData* call = (ciCallTypeData*)data->as_CallTypeData();
592 if (nb >= call->number_of_arguments()) {
593 return false;
594 }
595 type = call->valid_argument_type(nb);
596 if (type != NULL && !call->argument_maybe_null(nb)) {
597 return true;
598 }
599 }
600 }
601 }
602 return false;
603 }
604
605 // Return true if profiling provides a type for the return value from
606 // the call at bci. type is the profiled type.
607 // If the profile reports that the argument may be null, return false
608 // at least for now.
609 bool ciMethod::return_profiled_type(int bci, ciKlass*& type) {
610 if (MethodData::profile_return() && method_data() != NULL && method_data()->is_mature()) {
611 ciProfileData* data = method_data()->bci_to_data(bci);
612 if (data != NULL) {
613 if (data->is_VirtualCallTypeData()) {
614 assert(java_code_at_bci(bci) == Bytecodes::_invokevirtual ||
615 java_code_at_bci(bci) == Bytecodes::_invokeinterface, "unexpected bytecode");
616 ciVirtualCallTypeData* call = (ciVirtualCallTypeData*)data->as_VirtualCallTypeData();
617 type = call->valid_return_type();
618 if (type != NULL && !call->return_maybe_null()) {
619 return true;
620 }
621 } else if (data->is_CallTypeData()) {
622 assert(java_code_at_bci(bci) == Bytecodes::_invokestatic ||
623 java_code_at_bci(bci) == Bytecodes::_invokespecial ||
624 java_code_at_bci(bci) == Bytecodes::_invokedynamic, "unexpected bytecode");
625 ciCallTypeData* call = (ciCallTypeData*)data->as_CallTypeData();
626 type = call->valid_return_type();
627 if (type != NULL && !call->return_maybe_null()) {
628 return true;
629 }
630 }
631 }
632 }
633 return false;
634 }
635
636 // Return true if profiling provides a type for the parameter nb to
637 // this method. type is the profiled type.
638 // If the profile reports that the argument may be null, return false
639 // at least for now.
640 bool ciMethod::parameter_profiled_type(int nb, ciKlass*& type) {
641 if (MethodData::profile_parameters() && method_data() != NULL && method_data()->is_mature()) {
642 ciParametersTypeData* parameters = method_data()->parameters_type_data();
643 if (parameters != NULL && nb < parameters->number_of_parameters()) {
644 type = parameters->valid_parameter_type(nb);
645 if (type != NULL && !parameters->parameter_maybe_null(nb)) {
646 return true;
647 }
648 }
649 }
650 return false;
651 }
652
653
654 // ------------------------------------------------------------------
655 // ciMethod::find_monomorphic_target
656 //
657 // Given a certain calling environment, find the monomorphic target
658 // for the call. Return NULL if the call is not monomorphic in
659 // its calling environment, or if there are only abstract methods.
660 // The returned method is never abstract.
661 // Note: If caller uses a non-null result, it must inform dependencies
662 // via assert_unique_concrete_method or assert_leaf_type.
663 ciMethod* ciMethod::find_monomorphic_target(ciInstanceKlass* caller,
664 ciInstanceKlass* callee_holder,
665 ciInstanceKlass* actual_recv) {
666 check_is_loaded();
667
668 if (actual_recv->is_interface()) {
669 // %%% We cannot trust interface types, yet. See bug 6312651.
670 return NULL;
671 }
672
673 ciMethod* root_m = resolve_invoke(caller, actual_recv);
|