1.1 --- a/src/share/vm/c1/c1_GraphBuilder.cpp Wed Oct 09 11:05:17 2013 -0700 1.2 +++ b/src/share/vm/c1/c1_GraphBuilder.cpp Wed Oct 09 16:32:21 2013 +0200 1.3 @@ -1658,6 +1658,42 @@ 1.4 return compilation()->dependency_recorder(); 1.5 } 1.6 1.7 +// How many arguments do we want to profile? 1.8 +Values* GraphBuilder::args_list_for_profiling(int& start, bool may_have_receiver) { 1.9 + int n = 0; 1.10 + assert(start == 0, "should be initialized"); 1.11 + if (MethodData::profile_arguments()) { 1.12 + ciProfileData* data = method()->method_data()->bci_to_data(bci()); 1.13 + if (data->is_CallTypeData() || data->is_VirtualCallTypeData()) { 1.14 + n = data->is_CallTypeData() ? data->as_CallTypeData()->number_of_arguments() : data->as_VirtualCallTypeData()->number_of_arguments(); 1.15 + bool has_receiver = may_have_receiver && Bytecodes::has_receiver(method()->java_code_at_bci(bci())); 1.16 + start = has_receiver ? 1 : 0; 1.17 + } 1.18 + } 1.19 + if (n > 0) { 1.20 + return new Values(n); 1.21 + } 1.22 + return NULL; 1.23 +} 1.24 + 1.25 +// Collect arguments that we want to profile in a list 1.26 +Values* GraphBuilder::collect_args_for_profiling(Values* args, bool may_have_receiver) { 1.27 + int start = 0; 1.28 + Values* obj_args = args_list_for_profiling(start, may_have_receiver); 1.29 + if (obj_args == NULL) { 1.30 + return NULL; 1.31 + } 1.32 + int s = obj_args->size(); 1.33 + for (int i = start, j = 0; j < s; i++) { 1.34 + if (args->at(i)->type()->is_object_kind()) { 1.35 + obj_args->push(args->at(i)); 1.36 + j++; 1.37 + } 1.38 + } 1.39 + assert(s == obj_args->length(), "missed on arg?"); 1.40 + return obj_args; 1.41 +} 1.42 + 1.43 1.44 void GraphBuilder::invoke(Bytecodes::Code code) { 1.45 bool will_link; 1.46 @@ -1957,7 +1993,7 @@ 1.47 } else if (exact_target != NULL) { 1.48 target_klass = exact_target->holder(); 1.49 } 1.50 - profile_call(target, recv, target_klass); 1.51 + profile_call(target, recv, target_klass, collect_args_for_profiling(args, false), false); 1.52 } 1.53 } 1.54 1.55 @@ -3509,7 +3545,7 @@ 1.56 recv = args->at(0); 1.57 null_check(recv); 1.58 } 1.59 - profile_call(callee, recv, NULL); 1.60 + profile_call(callee, recv, NULL, collect_args_for_profiling(args, true), true); 1.61 } 1.62 } 1.63 } 1.64 @@ -3763,7 +3799,28 @@ 1.65 compilation()->set_would_profile(true); 1.66 1.67 if (profile_calls()) { 1.68 - profile_call(callee, recv, holder_known ? callee->holder() : NULL); 1.69 + int start = 0; 1.70 + Values* obj_args = args_list_for_profiling(start, has_receiver); 1.71 + if (obj_args != NULL) { 1.72 + int s = obj_args->size(); 1.73 + // if called through method handle invoke, some arguments may have been popped 1.74 + for (int i = args_base+start, j = 0; j < obj_args->size() && i < state()->stack_size(); ) { 1.75 + Value v = state()->stack_at_inc(i); 1.76 + if (v->type()->is_object_kind()) { 1.77 + obj_args->push(v); 1.78 + j++; 1.79 + } 1.80 + } 1.81 +#ifdef ASSERT 1.82 + { 1.83 + bool ignored_will_link; 1.84 + ciSignature* declared_signature = NULL; 1.85 + ciMethod* real_target = method()->get_method_at_bci(bci(), ignored_will_link, &declared_signature); 1.86 + assert(s == obj_args->length() || real_target->is_method_handle_intrinsic(), "missed on arg?"); 1.87 + } 1.88 +#endif 1.89 + } 1.90 + profile_call(callee, recv, holder_known ? callee->holder() : NULL, obj_args, true); 1.91 } 1.92 } 1.93 1.94 @@ -4251,8 +4308,8 @@ 1.95 } 1.96 #endif // PRODUCT 1.97 1.98 -void GraphBuilder::profile_call(ciMethod* callee, Value recv, ciKlass* known_holder) { 1.99 - append(new ProfileCall(method(), bci(), callee, recv, known_holder)); 1.100 +void GraphBuilder::profile_call(ciMethod* callee, Value recv, ciKlass* known_holder, Values* obj_args, bool inlined) { 1.101 + append(new ProfileCall(method(), bci(), callee, recv, known_holder, obj_args, inlined)); 1.102 } 1.103 1.104 void GraphBuilder::profile_invocation(ciMethod* callee, ValueStack* state) {