Mercurial > hg > graal-jvmci-8
comparison src/share/vm/c1/c1_GraphBuilder.cpp @ 12875:d13d7aba8c12
8023657: New type profiling points: arguments to call
Summary: x86 interpreter and c1 type profiling for arguments at calls
Reviewed-by: kvn, twisti
author | roland |
---|---|
date | Wed, 09 Oct 2013 16:32:21 +0200 |
parents | 1b64d46620a3 |
children | ce0cc25bc5e2 |
comparison
equal
deleted
inserted
replaced
12874:46ef27bcacb3 | 12875:d13d7aba8c12 |
---|---|
1656 Dependencies* GraphBuilder::dependency_recorder() const { | 1656 Dependencies* GraphBuilder::dependency_recorder() const { |
1657 assert(DeoptC1, "need debug information"); | 1657 assert(DeoptC1, "need debug information"); |
1658 return compilation()->dependency_recorder(); | 1658 return compilation()->dependency_recorder(); |
1659 } | 1659 } |
1660 | 1660 |
1661 // How many arguments do we want to profile? | |
1662 Values* GraphBuilder::args_list_for_profiling(int& start, bool may_have_receiver) { | |
1663 int n = 0; | |
1664 assert(start == 0, "should be initialized"); | |
1665 if (MethodData::profile_arguments()) { | |
1666 ciProfileData* data = method()->method_data()->bci_to_data(bci()); | |
1667 if (data->is_CallTypeData() || data->is_VirtualCallTypeData()) { | |
1668 n = data->is_CallTypeData() ? data->as_CallTypeData()->number_of_arguments() : data->as_VirtualCallTypeData()->number_of_arguments(); | |
1669 bool has_receiver = may_have_receiver && Bytecodes::has_receiver(method()->java_code_at_bci(bci())); | |
1670 start = has_receiver ? 1 : 0; | |
1671 } | |
1672 } | |
1673 if (n > 0) { | |
1674 return new Values(n); | |
1675 } | |
1676 return NULL; | |
1677 } | |
1678 | |
1679 // Collect arguments that we want to profile in a list | |
1680 Values* GraphBuilder::collect_args_for_profiling(Values* args, bool may_have_receiver) { | |
1681 int start = 0; | |
1682 Values* obj_args = args_list_for_profiling(start, may_have_receiver); | |
1683 if (obj_args == NULL) { | |
1684 return NULL; | |
1685 } | |
1686 int s = obj_args->size(); | |
1687 for (int i = start, j = 0; j < s; i++) { | |
1688 if (args->at(i)->type()->is_object_kind()) { | |
1689 obj_args->push(args->at(i)); | |
1690 j++; | |
1691 } | |
1692 } | |
1693 assert(s == obj_args->length(), "missed on arg?"); | |
1694 return obj_args; | |
1695 } | |
1696 | |
1661 | 1697 |
1662 void GraphBuilder::invoke(Bytecodes::Code code) { | 1698 void GraphBuilder::invoke(Bytecodes::Code code) { |
1663 bool will_link; | 1699 bool will_link; |
1664 ciSignature* declared_signature = NULL; | 1700 ciSignature* declared_signature = NULL; |
1665 ciMethod* target = stream()->get_method(will_link, &declared_signature); | 1701 ciMethod* target = stream()->get_method(will_link, &declared_signature); |
1955 if (cha_monomorphic_target != NULL) { | 1991 if (cha_monomorphic_target != NULL) { |
1956 target_klass = cha_monomorphic_target->holder(); | 1992 target_klass = cha_monomorphic_target->holder(); |
1957 } else if (exact_target != NULL) { | 1993 } else if (exact_target != NULL) { |
1958 target_klass = exact_target->holder(); | 1994 target_klass = exact_target->holder(); |
1959 } | 1995 } |
1960 profile_call(target, recv, target_klass); | 1996 profile_call(target, recv, target_klass, collect_args_for_profiling(args, false), false); |
1961 } | 1997 } |
1962 } | 1998 } |
1963 | 1999 |
1964 Invoke* result = new Invoke(code, result_type, recv, args, vtable_index, target, state_before); | 2000 Invoke* result = new Invoke(code, result_type, recv, args, vtable_index, target, state_before); |
1965 // push result | 2001 // push result |
3507 Value recv = NULL; | 3543 Value recv = NULL; |
3508 if (has_receiver) { | 3544 if (has_receiver) { |
3509 recv = args->at(0); | 3545 recv = args->at(0); |
3510 null_check(recv); | 3546 null_check(recv); |
3511 } | 3547 } |
3512 profile_call(callee, recv, NULL); | 3548 profile_call(callee, recv, NULL, collect_args_for_profiling(args, true), true); |
3513 } | 3549 } |
3514 } | 3550 } |
3515 } | 3551 } |
3516 | 3552 |
3517 Intrinsic* result = new Intrinsic(result_type, id, args, has_receiver, state_before, | 3553 Intrinsic* result = new Intrinsic(result_type, id, args, has_receiver, state_before, |
3761 // Note that we'd collect profile data in this method if we wanted it. | 3797 // Note that we'd collect profile data in this method if we wanted it. |
3762 // this may be redundant here... | 3798 // this may be redundant here... |
3763 compilation()->set_would_profile(true); | 3799 compilation()->set_would_profile(true); |
3764 | 3800 |
3765 if (profile_calls()) { | 3801 if (profile_calls()) { |
3766 profile_call(callee, recv, holder_known ? callee->holder() : NULL); | 3802 int start = 0; |
3803 Values* obj_args = args_list_for_profiling(start, has_receiver); | |
3804 if (obj_args != NULL) { | |
3805 int s = obj_args->size(); | |
3806 // if called through method handle invoke, some arguments may have been popped | |
3807 for (int i = args_base+start, j = 0; j < obj_args->size() && i < state()->stack_size(); ) { | |
3808 Value v = state()->stack_at_inc(i); | |
3809 if (v->type()->is_object_kind()) { | |
3810 obj_args->push(v); | |
3811 j++; | |
3812 } | |
3813 } | |
3814 #ifdef ASSERT | |
3815 { | |
3816 bool ignored_will_link; | |
3817 ciSignature* declared_signature = NULL; | |
3818 ciMethod* real_target = method()->get_method_at_bci(bci(), ignored_will_link, &declared_signature); | |
3819 assert(s == obj_args->length() || real_target->is_method_handle_intrinsic(), "missed on arg?"); | |
3820 } | |
3821 #endif | |
3822 } | |
3823 profile_call(callee, recv, holder_known ? callee->holder() : NULL, obj_args, true); | |
3767 } | 3824 } |
3768 } | 3825 } |
3769 | 3826 |
3770 // Introduce a new callee continuation point - if the callee has | 3827 // Introduce a new callee continuation point - if the callee has |
3771 // more than one return instruction or the return does not allow | 3828 // more than one return instruction or the return does not allow |
4249 void GraphBuilder::print_stats() { | 4306 void GraphBuilder::print_stats() { |
4250 vmap()->print(); | 4307 vmap()->print(); |
4251 } | 4308 } |
4252 #endif // PRODUCT | 4309 #endif // PRODUCT |
4253 | 4310 |
4254 void GraphBuilder::profile_call(ciMethod* callee, Value recv, ciKlass* known_holder) { | 4311 void GraphBuilder::profile_call(ciMethod* callee, Value recv, ciKlass* known_holder, Values* obj_args, bool inlined) { |
4255 append(new ProfileCall(method(), bci(), callee, recv, known_holder)); | 4312 append(new ProfileCall(method(), bci(), callee, recv, known_holder, obj_args, inlined)); |
4256 } | 4313 } |
4257 | 4314 |
4258 void GraphBuilder::profile_invocation(ciMethod* callee, ValueStack* state) { | 4315 void GraphBuilder::profile_invocation(ciMethod* callee, ValueStack* state) { |
4259 append(new ProfileInvoke(callee, state)); | 4316 append(new ProfileInvoke(callee, state)); |
4260 } | 4317 } |