src/cpu/x86/vm/interp_masm_x86_32.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/cpu/x86/vm

src/cpu/x86/vm/interp_masm_x86_32.cpp

Print this page
rev 5468 : 8026251: New type profiling points: parameters to methods
Summary: x86 interpreter and c1 type profiling for parameters on method entries
Reviewed-by:
rev 5469 : [mq]: parameters-review


   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "interp_masm_x86_32.hpp"
  27 #include "interpreter/interpreter.hpp"
  28 #include "interpreter/interpreterRuntime.hpp"
  29 #include "oops/arrayOop.hpp"
  30 #include "oops/markOop.hpp"
  31 #include "oops/methodData.hpp"
  32 #include "oops/method.hpp"
  33 #include "prims/jvmtiExport.hpp"
  34 #include "prims/jvmtiRedefineClassesTrace.hpp"
  35 #include "prims/jvmtiThreadState.hpp"
  36 #include "runtime/basicLock.hpp"
  37 #include "runtime/biasedLocking.hpp"
  38 #include "runtime/sharedRuntime.hpp"
  39 #include "runtime/thread.inline.hpp"
  40 
  41 
  42 // Implementation of InterpreterMacroAssembler
  43 #ifdef CC_INTERP
  44 void InterpreterMacroAssembler::get_method(Register reg) {
  45   movptr(reg, Address(rbp, -(sizeof(BytecodeInterpreter) + 2 * wordSize)));
  46   movptr(reg, Address(reg, byte_offset_of(BytecodeInterpreter, _method)));


1026     // The method data pointer needs to be updated to reflect the new target.
1027     update_mdp_by_offset(mdp, in_bytes(JumpData::displacement_offset()));
1028     bind (profile_continue);
1029   }
1030 }
1031 
1032 
1033 void InterpreterMacroAssembler::profile_not_taken_branch(Register mdp) {
1034   if (ProfileInterpreter) {
1035     Label profile_continue;
1036 
1037     // If no method data exists, go to profile_continue.
1038     test_method_data_pointer(mdp, profile_continue);
1039 
1040     // We are taking a branch.  Increment the not taken count.
1041     increment_mdp_data_at(mdp, in_bytes(BranchData::not_taken_offset()));
1042 
1043     // The method data pointer needs to be updated to correspond to the next bytecode
1044     update_mdp_by_constant(mdp, in_bytes(BranchData::branch_data_size()));
1045     bind (profile_continue);
1046   }
1047 }
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) {
1203   if (ProfileInterpreter) {
1204     Label profile_continue;
1205 
1206     // If no method data exists, go to profile_continue.
1207     test_method_data_pointer(mdp, profile_continue);
1208 
1209     // We are making a call.  Increment the count.
1210     increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()));
1211 
1212     // The method data pointer needs to be updated to reflect the new target.
1213     update_mdp_by_constant(mdp, in_bytes(CounterData::counter_data_size()));
1214     bind (profile_continue);
1215   }
1216 }
1217 
1218 




   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "interp_masm_x86.hpp"
  27 #include "interpreter/interpreter.hpp"
  28 #include "interpreter/interpreterRuntime.hpp"
  29 #include "oops/arrayOop.hpp"
  30 #include "oops/markOop.hpp"
  31 #include "oops/methodData.hpp"
  32 #include "oops/method.hpp"
  33 #include "prims/jvmtiExport.hpp"
  34 #include "prims/jvmtiRedefineClassesTrace.hpp"
  35 #include "prims/jvmtiThreadState.hpp"
  36 #include "runtime/basicLock.hpp"
  37 #include "runtime/biasedLocking.hpp"
  38 #include "runtime/sharedRuntime.hpp"
  39 #include "runtime/thread.inline.hpp"
  40 
  41 
  42 // Implementation of InterpreterMacroAssembler
  43 #ifdef CC_INTERP
  44 void InterpreterMacroAssembler::get_method(Register reg) {
  45   movptr(reg, Address(rbp, -(sizeof(BytecodeInterpreter) + 2 * wordSize)));
  46   movptr(reg, Address(reg, byte_offset_of(BytecodeInterpreter, _method)));


1026     // The method data pointer needs to be updated to reflect the new target.
1027     update_mdp_by_offset(mdp, in_bytes(JumpData::displacement_offset()));
1028     bind (profile_continue);
1029   }
1030 }
1031 
1032 
1033 void InterpreterMacroAssembler::profile_not_taken_branch(Register mdp) {
1034   if (ProfileInterpreter) {
1035     Label profile_continue;
1036 
1037     // If no method data exists, go to profile_continue.
1038     test_method_data_pointer(mdp, profile_continue);
1039 
1040     // We are taking a branch.  Increment the not taken count.
1041     increment_mdp_data_at(mdp, in_bytes(BranchData::not_taken_offset()));
1042 
1043     // The method data pointer needs to be updated to correspond to the next bytecode
1044     update_mdp_by_constant(mdp, in_bytes(BranchData::branch_data_size()));
1045     bind (profile_continue);

























































































































































1046   }
1047 }
1048 
1049 void InterpreterMacroAssembler::profile_call(Register mdp) {
1050   if (ProfileInterpreter) {
1051     Label profile_continue;
1052 
1053     // If no method data exists, go to profile_continue.
1054     test_method_data_pointer(mdp, profile_continue);
1055 
1056     // We are making a call.  Increment the count.
1057     increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()));
1058 
1059     // The method data pointer needs to be updated to reflect the new target.
1060     update_mdp_by_constant(mdp, in_bytes(CounterData::counter_data_size()));
1061     bind (profile_continue);
1062   }
1063 }
1064 
1065 


src/cpu/x86/vm/interp_masm_x86_32.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File