Mercurial > hg > graal-jvmci-8
comparison src/cpu/x86/vm/interp_masm_x86_32.cpp @ 12962:5ccbab1c69f3
8026251: New type profiling points: parameters to methods
Summary: x86 interpreter and c1 type profiling for parameters on method entries
Reviewed-by: kvn, twisti
author | roland |
---|---|
date | Tue, 22 Oct 2013 09:51:47 +0200 |
parents | ce0cc25bc5e2 |
children | ea79ab313e98 |
comparison
equal
deleted
inserted
replaced
12961:4748b3308cda | 12962:5ccbab1c69f3 |
---|---|
21 * questions. | 21 * questions. |
22 * | 22 * |
23 */ | 23 */ |
24 | 24 |
25 #include "precompiled.hpp" | 25 #include "precompiled.hpp" |
26 #include "interp_masm_x86_32.hpp" | 26 #include "interp_masm_x86.hpp" |
27 #include "interpreter/interpreter.hpp" | 27 #include "interpreter/interpreter.hpp" |
28 #include "interpreter/interpreterRuntime.hpp" | 28 #include "interpreter/interpreterRuntime.hpp" |
29 #include "oops/arrayOop.hpp" | 29 #include "oops/arrayOop.hpp" |
30 #include "oops/markOop.hpp" | 30 #include "oops/markOop.hpp" |
31 #include "oops/methodData.hpp" | 31 #include "oops/methodData.hpp" |
1044 update_mdp_by_constant(mdp, in_bytes(BranchData::branch_data_size())); | 1044 update_mdp_by_constant(mdp, in_bytes(BranchData::branch_data_size())); |
1045 bind (profile_continue); | 1045 bind (profile_continue); |
1046 } | 1046 } |
1047 } | 1047 } |
1048 | 1048 |
1049 void InterpreterMacroAssembler::profile_obj_type(Register obj, const Address& mdo_addr) { | |
1050 Label update, next, none; | |
1051 | |
1052 verify_oop(obj); | |
1053 | |
1054 testptr(obj, obj); | |
1055 jccb(Assembler::notZero, update); | |
1056 orptr(mdo_addr, TypeEntries::null_seen); | |
1057 jmpb(next); | |
1058 | |
1059 bind(update); | |
1060 load_klass(obj, obj); | |
1061 | |
1062 xorptr(obj, mdo_addr); | |
1063 testptr(obj, TypeEntries::type_klass_mask); | |
1064 jccb(Assembler::zero, next); // klass seen before, nothing to | |
1065 // do. The unknown bit may have been | |
1066 // set already but no need to check. | |
1067 | |
1068 testptr(obj, TypeEntries::type_unknown); | |
1069 jccb(Assembler::notZero, next); // already unknown. Nothing to do anymore. | |
1070 | |
1071 cmpptr(mdo_addr, 0); | |
1072 jccb(Assembler::equal, none); | |
1073 cmpptr(mdo_addr, TypeEntries::null_seen); | |
1074 jccb(Assembler::equal, none); | |
1075 // There is a chance that the checks above (re-reading profiling | |
1076 // data from memory) fail if another thread has just set the | |
1077 // profiling to this obj's klass | |
1078 xorptr(obj, mdo_addr); | |
1079 testptr(obj, TypeEntries::type_klass_mask); | |
1080 jccb(Assembler::zero, next); | |
1081 | |
1082 // different than before. Cannot keep accurate profile. | |
1083 orptr(mdo_addr, TypeEntries::type_unknown); | |
1084 jmpb(next); | |
1085 | |
1086 bind(none); | |
1087 // first time here. Set profile type. | |
1088 movptr(mdo_addr, obj); | |
1089 | |
1090 bind(next); | |
1091 } | |
1092 | |
1093 void InterpreterMacroAssembler::profile_arguments_type(Register mdp, Register callee, Register tmp, bool is_virtual) { | |
1094 if (!ProfileInterpreter) { | |
1095 return; | |
1096 } | |
1097 | |
1098 if (MethodData::profile_arguments() || MethodData::profile_return()) { | |
1099 Label profile_continue; | |
1100 | |
1101 test_method_data_pointer(mdp, profile_continue); | |
1102 | |
1103 int off_to_start = is_virtual ? in_bytes(VirtualCallData::virtual_call_data_size()) : in_bytes(CounterData::counter_data_size()); | |
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); | |
1106 jcc(Assembler::notEqual, profile_continue); | |
1107 | |
1108 if (MethodData::profile_arguments()) { | |
1109 Label done; | |
1110 int off_to_args = in_bytes(TypeEntriesAtCall::args_data_offset()); | |
1111 addptr(mdp, off_to_args); | |
1112 | |
1113 for (int i = 0; i < TypeProfileArgsLimit; i++) { | |
1114 if (i > 0 || MethodData::profile_return()) { | |
1115 // If return value type is profiled we may have no argument to profile | |
1116 movl(tmp, Address(mdp, in_bytes(TypeEntriesAtCall::cell_count_offset())-off_to_args)); | |
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; | |
1137 } | |
1138 | |
1139 if (MethodData::profile_return()) { | |
1140 movl(tmp, Address(mdp, in_bytes(TypeEntriesAtCall::cell_count_offset())-off_to_args)); | |
1141 subl(tmp, TypeProfileArgsLimit*TypeStackSlotEntries::per_arg_count()); | |
1142 } | |
1143 | |
1144 bind(done); | |
1145 | |
1146 if (MethodData::profile_return()) { | |
1147 // We're right after the type profile for the last | |
1148 // argument. tmp is the number of cell left in the | |
1149 // CallTypeData/VirtualCallTypeData to reach its end. Non null | |
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())); | |
1159 } | |
1160 | |
1161 // mdp points right after the end of the | |
1162 // CallTypeData/VirtualCallTypeData, right after the cells for the | |
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); | |
1197 | |
1198 bind(profile_continue); | |
1199 } | |
1200 } | |
1201 | |
1202 void InterpreterMacroAssembler::profile_call(Register mdp) { | 1049 void InterpreterMacroAssembler::profile_call(Register mdp) { |
1203 if (ProfileInterpreter) { | 1050 if (ProfileInterpreter) { |
1204 Label profile_continue; | 1051 Label profile_continue; |
1205 | 1052 |
1206 // If no method data exists, go to profile_continue. | 1053 // If no method data exists, go to profile_continue. |