1.1 --- a/src/cpu/x86/vm/interp_masm_x86_32.cpp Wed Oct 09 11:05:17 2013 -0700 1.2 +++ b/src/cpu/x86/vm/interp_masm_x86_32.cpp Wed Oct 09 16:32:21 2013 +0200 1.3 @@ -1046,6 +1046,98 @@ 1.4 } 1.5 } 1.6 1.7 +void InterpreterMacroAssembler::profile_obj_type(Register obj, const Address& mdo_addr) { 1.8 + Label update, next, none; 1.9 + 1.10 + verify_oop(obj); 1.11 + 1.12 + testptr(obj, obj); 1.13 + jccb(Assembler::notZero, update); 1.14 + orptr(mdo_addr, TypeEntries::null_seen); 1.15 + jmpb(next); 1.16 + 1.17 + bind(update); 1.18 + load_klass(obj, obj); 1.19 + 1.20 + xorptr(obj, mdo_addr); 1.21 + testptr(obj, TypeEntries::type_klass_mask); 1.22 + jccb(Assembler::zero, next); // klass seen before, nothing to 1.23 + // do. The unknown bit may have been 1.24 + // set already but no need to check. 1.25 + 1.26 + testptr(obj, TypeEntries::type_unknown); 1.27 + jccb(Assembler::notZero, next); // already unknown. Nothing to do anymore. 1.28 + 1.29 + cmpptr(mdo_addr, 0); 1.30 + jccb(Assembler::equal, none); 1.31 + cmpptr(mdo_addr, TypeEntries::null_seen); 1.32 + jccb(Assembler::equal, none); 1.33 + // There is a chance that the checks above (re-reading profiling 1.34 + // data from memory) fail if another thread has just set the 1.35 + // profiling to this obj's klass 1.36 + xorptr(obj, mdo_addr); 1.37 + testptr(obj, TypeEntries::type_klass_mask); 1.38 + jccb(Assembler::zero, next); 1.39 + 1.40 + // different than before. Cannot keep accurate profile. 1.41 + orptr(mdo_addr, TypeEntries::type_unknown); 1.42 + jmpb(next); 1.43 + 1.44 + bind(none); 1.45 + // first time here. Set profile type. 1.46 + movptr(mdo_addr, obj); 1.47 + 1.48 + bind(next); 1.49 +} 1.50 + 1.51 +void InterpreterMacroAssembler::profile_arguments_type(Register mdp, Register callee, Register tmp, bool is_virtual) { 1.52 + if (!ProfileInterpreter) { 1.53 + return; 1.54 + } 1.55 + 1.56 + if (MethodData::profile_arguments()) { 1.57 + Label profile_continue; 1.58 + 1.59 + test_method_data_pointer(mdp, profile_continue); 1.60 + 1.61 + int off_to_start = is_virtual ? in_bytes(VirtualCallData::virtual_call_data_size()) : in_bytes(CounterData::counter_data_size()); 1.62 + 1.63 + cmpb(Address(mdp, in_bytes(DataLayout::tag_offset()) - off_to_start), is_virtual ? DataLayout::virtual_call_type_data_tag : DataLayout::call_type_data_tag); 1.64 + jcc(Assembler::notEqual, profile_continue); 1.65 + 1.66 + Label done; 1.67 + int off_to_args = in_bytes(TypeStackSlotEntries::args_data_offset()); 1.68 + addptr(mdp, off_to_args); 1.69 + 1.70 + for (int i = 0; i < TypeProfileArgsLimit; i++) { 1.71 + if (i > 0) { 1.72 + movl(tmp, Address(mdp, in_bytes(TypeStackSlotEntries::cell_count_offset())-off_to_args)); 1.73 + subl(tmp, i*TypeStackSlotEntries::per_arg_count()); 1.74 + cmpl(tmp, TypeStackSlotEntries::per_arg_count()); 1.75 + jcc(Assembler::less, done); 1.76 + } 1.77 + movptr(tmp, Address(callee, Method::const_offset())); 1.78 + load_unsigned_short(tmp, Address(tmp, ConstMethod::size_of_parameters_offset())); 1.79 + subl(tmp, Address(mdp, in_bytes(TypeStackSlotEntries::stack_slot_offset(i))-off_to_args)); 1.80 + subl(tmp, 1); 1.81 + Address arg_addr = argument_address(tmp); 1.82 + movptr(tmp, arg_addr); 1.83 + 1.84 + Address mdo_arg_addr(mdp, in_bytes(TypeStackSlotEntries::type_offset(i))-off_to_args); 1.85 + profile_obj_type(tmp, mdo_arg_addr); 1.86 + 1.87 + int to_add = in_bytes(TypeStackSlotEntries::per_arg_size()); 1.88 + addptr(mdp, to_add); 1.89 + off_to_args += to_add; 1.90 + } 1.91 + 1.92 + bind(done); 1.93 + 1.94 + movptr(Address(rbp, frame::interpreter_frame_mdx_offset * wordSize), mdp); 1.95 + 1.96 + bind(profile_continue); 1.97 + } 1.98 +} 1.99 1.100 void InterpreterMacroAssembler::profile_call(Register mdp) { 1.101 if (ProfileInterpreter) {