1.1 --- a/src/share/vm/c1/c1_GraphBuilder.cpp Fri Oct 11 19:51:31 2013 -0700 1.2 +++ b/src/share/vm/c1/c1_GraphBuilder.cpp Sat Oct 12 12:12:59 2013 +0200 1.3 @@ -1466,9 +1466,22 @@ 1.4 // State at end of inlined method is the state of the caller 1.5 // without the method parameters on stack, including the 1.6 // return value, if any, of the inlined method on operand stack. 1.7 + int invoke_bci = state()->caller_state()->bci(); 1.8 set_state(state()->caller_state()->copy_for_parsing()); 1.9 if (x != NULL) { 1.10 state()->push(x->type(), x); 1.11 + if (profile_calls() && MethodData::profile_return() && x->type()->is_object_kind()) { 1.12 + ciMethod* caller = state()->scope()->method(); 1.13 + ciMethodData* md = caller->method_data_or_null(); 1.14 + ciProfileData* data = md->bci_to_data(invoke_bci); 1.15 + if (data->is_CallTypeData() || data->is_VirtualCallTypeData()) { 1.16 + bool has_return = data->is_CallTypeData() ? ((ciCallTypeData*)data)->has_return() : ((ciVirtualCallTypeData*)data)->has_return(); 1.17 + // May not be true in case of an inlined call through a method handle intrinsic. 1.18 + if (has_return) { 1.19 + profile_return_type(x, method(), caller, invoke_bci); 1.20 + } 1.21 + } 1.22 + } 1.23 } 1.24 Goto* goto_callee = new Goto(continuation(), false); 1.25 1.26 @@ -2008,6 +2021,9 @@ 1.27 push(result_type, result); 1.28 } 1.29 } 1.30 + if (profile_calls() && MethodData::profile_return() && result_type->is_object_kind()) { 1.31 + profile_return_type(result, target); 1.32 + } 1.33 } 1.34 1.35 1.36 @@ -3556,6 +3572,10 @@ 1.37 Value value = append_split(result); 1.38 if (result_type != voidType) push(result_type, value); 1.39 1.40 + if (callee != method() && profile_calls() && MethodData::profile_return() && result_type->is_object_kind()) { 1.41 + profile_return_type(result, callee); 1.42 + } 1.43 + 1.44 // done 1.45 return true; 1.46 } 1.47 @@ -4312,6 +4332,21 @@ 1.48 append(new ProfileCall(method(), bci(), callee, recv, known_holder, obj_args, inlined)); 1.49 } 1.50 1.51 +void GraphBuilder::profile_return_type(Value ret, ciMethod* callee, ciMethod* m, int invoke_bci) { 1.52 + assert((m == NULL) == (invoke_bci < 0), "invalid method and invalid bci together"); 1.53 + if (m == NULL) { 1.54 + m = method(); 1.55 + } 1.56 + if (invoke_bci < 0) { 1.57 + invoke_bci = bci(); 1.58 + } 1.59 + ciMethodData* md = m->method_data_or_null(); 1.60 + ciProfileData* data = md->bci_to_data(invoke_bci); 1.61 + if (data->is_CallTypeData() || data->is_VirtualCallTypeData()) { 1.62 + append(new ProfileReturnType(m , invoke_bci, callee, ret)); 1.63 + } 1.64 +} 1.65 + 1.66 void GraphBuilder::profile_invocation(ciMethod* callee, ValueStack* state) { 1.67 append(new ProfileInvoke(callee, state)); 1.68 }