src/cpu/x86/vm/interp_masm_x86_64.cpp

changeset 5914
d13d7aba8c12
parent 4936
aeaca88565e6
child 5921
ce0cc25bc5e2
     1.1 --- a/src/cpu/x86/vm/interp_masm_x86_64.cpp	Wed Oct 09 11:05:17 2013 -0700
     1.2 +++ b/src/cpu/x86/vm/interp_masm_x86_64.cpp	Wed Oct 09 16:32:21 2013 +0200
     1.3 @@ -1067,6 +1067,102 @@
     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 +  // There is a chance that by the time we do these checks (re-reading
    1.30 +  // profiling data from memory) another thread has set the profling
    1.31 +  // to this obj's klass and we set the profiling as unknow
    1.32 +  // erroneously
    1.33 +  cmpptr(mdo_addr, 0);
    1.34 +  jccb(Assembler::equal, none);
    1.35 +  cmpptr(mdo_addr, TypeEntries::null_seen);
    1.36 +  jccb(Assembler::equal, none);
    1.37 +  // There is a chance that the checks above (re-reading profiling
    1.38 +  // data from memory) fail if another thread has just set the
    1.39 +  // profiling to this obj's klass
    1.40 +  xorptr(obj, mdo_addr);
    1.41 +  testptr(obj, TypeEntries::type_klass_mask);
    1.42 +  jccb(Assembler::zero, next);
    1.43 +
    1.44 +  // different than before. Cannot keep accurate profile.
    1.45 +  orptr(mdo_addr, TypeEntries::type_unknown);
    1.46 +  jmpb(next);
    1.47 +
    1.48 +  bind(none);
    1.49 +  // first time here. Set profile type.
    1.50 +  movptr(mdo_addr, obj);
    1.51 +
    1.52 +  bind(next);
    1.53 +}
    1.54 +
    1.55 +void InterpreterMacroAssembler::profile_arguments_type(Register mdp, Register callee, Register tmp, bool is_virtual) {
    1.56 +  if (!ProfileInterpreter) {
    1.57 +    return;
    1.58 +  }
    1.59 +
    1.60 +  if (MethodData::profile_arguments()) {
    1.61 +    Label profile_continue;
    1.62 +
    1.63 +    test_method_data_pointer(mdp, profile_continue);
    1.64 +
    1.65 +    int off_to_start = is_virtual ? in_bytes(VirtualCallData::virtual_call_data_size()) : in_bytes(CounterData::counter_data_size());
    1.66 +
    1.67 +    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.68 +    jcc(Assembler::notEqual, profile_continue);
    1.69 +
    1.70 +    Label done;
    1.71 +    int off_to_args = in_bytes(TypeStackSlotEntries::args_data_offset());
    1.72 +    addptr(mdp, off_to_args);
    1.73 +
    1.74 +    for (int i = 0; i < TypeProfileArgsLimit; i++) {
    1.75 +      if (i > 0) {
    1.76 +        movq(tmp, Address(mdp, in_bytes(TypeStackSlotEntries::cell_count_offset())-off_to_args));
    1.77 +        subl(tmp, i*TypeStackSlotEntries::per_arg_count());
    1.78 +        cmpl(tmp, TypeStackSlotEntries::per_arg_count());
    1.79 +        jcc(Assembler::less, done);
    1.80 +      }
    1.81 +      movptr(tmp, Address(callee, Method::const_offset()));
    1.82 +      load_unsigned_short(tmp, Address(tmp, ConstMethod::size_of_parameters_offset()));
    1.83 +      subq(tmp, Address(mdp, in_bytes(TypeStackSlotEntries::stack_slot_offset(i))-off_to_args));
    1.84 +      subl(tmp, 1);
    1.85 +      Address arg_addr = argument_address(tmp);
    1.86 +      movptr(tmp, arg_addr);
    1.87 +
    1.88 +      Address mdo_arg_addr(mdp, in_bytes(TypeStackSlotEntries::type_offset(i))-off_to_args);
    1.89 +      profile_obj_type(tmp, mdo_arg_addr);
    1.90 +
    1.91 +      int to_add = in_bytes(TypeStackSlotEntries::per_arg_size());
    1.92 +      addptr(mdp, to_add);
    1.93 +      off_to_args += to_add;
    1.94 +    }
    1.95 +
    1.96 +    bind(done);
    1.97 +
    1.98 +    movptr(Address(rbp, frame::interpreter_frame_mdx_offset * wordSize), mdp);
    1.99 +
   1.100 +    bind(profile_continue);
   1.101 +  }
   1.102 +}
   1.103  
   1.104  void InterpreterMacroAssembler::profile_call(Register mdp) {
   1.105    if (ProfileInterpreter) {

mercurial