comparison src/cpu/x86/vm/interp_masm_x86_32.cpp @ 12882:ce0cc25bc5e2

8026054: New type profiling points: type of return values at calls Summary: x86 interpreter and c1 type profiling for return values at calls Reviewed-by: kvn, twisti
author roland
date Sat, 12 Oct 2013 12:12:59 +0200
parents d13d7aba8c12
children 5ccbab1c69f3
comparison
equal deleted inserted replaced
12881:ed2c74787eb5 12882:ce0cc25bc5e2
1093 void InterpreterMacroAssembler::profile_arguments_type(Register mdp, Register callee, Register tmp, bool is_virtual) { 1093 void InterpreterMacroAssembler::profile_arguments_type(Register mdp, Register callee, Register tmp, bool is_virtual) {
1094 if (!ProfileInterpreter) { 1094 if (!ProfileInterpreter) {
1095 return; 1095 return;
1096 } 1096 }
1097 1097
1098 if (MethodData::profile_arguments()) { 1098 if (MethodData::profile_arguments() || MethodData::profile_return()) {
1099 Label profile_continue; 1099 Label profile_continue;
1100 1100
1101 test_method_data_pointer(mdp, profile_continue); 1101 test_method_data_pointer(mdp, profile_continue);
1102 1102
1103 int off_to_start = is_virtual ? in_bytes(VirtualCallData::virtual_call_data_size()) : in_bytes(CounterData::counter_data_size()); 1103 int off_to_start = is_virtual ? in_bytes(VirtualCallData::virtual_call_data_size()) : in_bytes(CounterData::counter_data_size());
1104 1104
1105 cmpb(Address(mdp, in_bytes(DataLayout::tag_offset()) - off_to_start), is_virtual ? DataLayout::virtual_call_type_data_tag : DataLayout::call_type_data_tag); 1105 cmpb(Address(mdp, in_bytes(DataLayout::tag_offset()) - off_to_start), is_virtual ? DataLayout::virtual_call_type_data_tag : DataLayout::call_type_data_tag);
1106 jcc(Assembler::notEqual, profile_continue); 1106 jcc(Assembler::notEqual, profile_continue);
1107 1107
1108 Label done; 1108 if (MethodData::profile_arguments()) {
1109 int off_to_args = in_bytes(TypeStackSlotEntries::args_data_offset()); 1109 Label done;
1110 addptr(mdp, off_to_args); 1110 int off_to_args = in_bytes(TypeEntriesAtCall::args_data_offset());
1111 1111 addptr(mdp, off_to_args);
1112 for (int i = 0; i < TypeProfileArgsLimit; i++) { 1112
1113 if (i > 0) { 1113 for (int i = 0; i < TypeProfileArgsLimit; i++) {
1114 movl(tmp, Address(mdp, in_bytes(TypeStackSlotEntries::cell_count_offset())-off_to_args)); 1114 if (i > 0 || MethodData::profile_return()) {
1115 subl(tmp, i*TypeStackSlotEntries::per_arg_count()); 1115 // If return value type is profiled we may have no argument to profile
1116 cmpl(tmp, TypeStackSlotEntries::per_arg_count()); 1116 movl(tmp, Address(mdp, in_bytes(TypeEntriesAtCall::cell_count_offset())-off_to_args));
1117 jcc(Assembler::less, done); 1117 subl(tmp, i*TypeStackSlotEntries::per_arg_count());
1118 cmpl(tmp, TypeStackSlotEntries::per_arg_count());
1119 jcc(Assembler::less, done);
1120 }
1121 movptr(tmp, Address(callee, Method::const_offset()));
1122 load_unsigned_short(tmp, Address(tmp, ConstMethod::size_of_parameters_offset()));
1123 // stack offset o (zero based) from the start of the argument
1124 // list, for n arguments translates into offset n - o - 1 from
1125 // the end of the argument list
1126 subl(tmp, Address(mdp, in_bytes(TypeEntriesAtCall::stack_slot_offset(i))-off_to_args));
1127 subl(tmp, 1);
1128 Address arg_addr = argument_address(tmp);
1129 movptr(tmp, arg_addr);
1130
1131 Address mdo_arg_addr(mdp, in_bytes(TypeEntriesAtCall::argument_type_offset(i))-off_to_args);
1132 profile_obj_type(tmp, mdo_arg_addr);
1133
1134 int to_add = in_bytes(TypeStackSlotEntries::per_arg_size());
1135 addptr(mdp, to_add);
1136 off_to_args += to_add;
1118 } 1137 }
1119 movptr(tmp, Address(callee, Method::const_offset())); 1138
1120 load_unsigned_short(tmp, Address(tmp, ConstMethod::size_of_parameters_offset())); 1139 if (MethodData::profile_return()) {
1121 subl(tmp, Address(mdp, in_bytes(TypeStackSlotEntries::stack_slot_offset(i))-off_to_args)); 1140 movl(tmp, Address(mdp, in_bytes(TypeEntriesAtCall::cell_count_offset())-off_to_args));
1122 subl(tmp, 1); 1141 subl(tmp, TypeProfileArgsLimit*TypeStackSlotEntries::per_arg_count());
1123 Address arg_addr = argument_address(tmp); 1142 }
1124 movptr(tmp, arg_addr); 1143
1125 1144 bind(done);
1126 Address mdo_arg_addr(mdp, in_bytes(TypeStackSlotEntries::type_offset(i))-off_to_args); 1145
1127 profile_obj_type(tmp, mdo_arg_addr); 1146 if (MethodData::profile_return()) {
1128 1147 // We're right after the type profile for the last
1129 int to_add = in_bytes(TypeStackSlotEntries::per_arg_size()); 1148 // argument. tmp is the number of cell left in the
1130 addptr(mdp, to_add); 1149 // CallTypeData/VirtualCallTypeData to reach its end. Non null
1131 off_to_args += to_add; 1150 // if there's a return to profile.
1151 assert(ReturnTypeEntry::static_cell_count() < TypeStackSlotEntries::per_arg_count(), "can't move past ret type");
1152 shll(tmp, exact_log2(DataLayout::cell_size));
1153 addptr(mdp, tmp);
1154 }
1155 movptr(Address(rbp, frame::interpreter_frame_mdx_offset * wordSize), mdp);
1156 } else {
1157 assert(MethodData::profile_return(), "either profile call args or call ret");
1158 update_mdp_by_constant(mdp, in_bytes(ReturnTypeEntry::size()));
1132 } 1159 }
1133 1160
1134 bind(done); 1161 // mdp points right after the end of the
1135 1162 // CallTypeData/VirtualCallTypeData, right after the cells for the
1136 movptr(Address(rbp, frame::interpreter_frame_mdx_offset * wordSize), mdp); 1163 // return value type if there's one
1164
1165 bind(profile_continue);
1166 }
1167 }
1168
1169 void InterpreterMacroAssembler::profile_return_type(Register mdp, Register ret, Register tmp) {
1170 assert_different_registers(mdp, ret, tmp, rsi);
1171 if (ProfileInterpreter && MethodData::profile_return()) {
1172 Label profile_continue, done;
1173
1174 test_method_data_pointer(mdp, profile_continue);
1175
1176 if (MethodData::profile_return_jsr292_only()) {
1177 // If we don't profile all invoke bytecodes we must make sure
1178 // it's a bytecode we indeed profile. We can't go back to the
1179 // begining of the ProfileData we intend to update to check its
1180 // type because we're right after it and we don't known its
1181 // length
1182 Label do_profile;
1183 cmpb(Address(rsi, 0), Bytecodes::_invokedynamic);
1184 jcc(Assembler::equal, do_profile);
1185 cmpb(Address(rsi, 0), Bytecodes::_invokehandle);
1186 jcc(Assembler::equal, do_profile);
1187 get_method(tmp);
1188 cmpb(Address(tmp, Method::intrinsic_id_offset_in_bytes()), vmIntrinsics::_compiledLambdaForm);
1189 jcc(Assembler::notEqual, profile_continue);
1190
1191 bind(do_profile);
1192 }
1193
1194 Address mdo_ret_addr(mdp, -in_bytes(ReturnTypeEntry::size()));
1195 mov(tmp, ret);
1196 profile_obj_type(tmp, mdo_ret_addr);
1137 1197
1138 bind(profile_continue); 1198 bind(profile_continue);
1139 } 1199 }
1140 } 1200 }
1141 1201