src/cpu/x86/vm/methodHandles_x86.cpp

changeset 1765
4a9cc99938e3
parent 1739
76c1d7d13ec5
child 1858
c640000b7cc1
     1.1 --- a/src/cpu/x86/vm/methodHandles_x86.cpp	Thu Mar 25 16:54:59 2010 -0700
     1.2 +++ b/src/cpu/x86/vm/methodHandles_x86.cpp	Fri Mar 26 11:10:26 2010 -0400
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright 1997-2009 Sun Microsystems, Inc.  All Rights Reserved.
     1.6 + * Copyright 1997-2010 Sun Microsystems, Inc.  All Rights Reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -60,13 +60,13 @@
    1.11  }
    1.12  
    1.13  #ifdef ASSERT
    1.14 -static void verify_argslot(MacroAssembler* _masm, Register rax_argslot,
    1.15 +static void verify_argslot(MacroAssembler* _masm, Register argslot_reg,
    1.16                             const char* error_message) {
    1.17    // Verify that argslot lies within (rsp, rbp].
    1.18    Label L_ok, L_bad;
    1.19 -  __ cmpptr(rax_argslot, rbp);
    1.20 +  __ cmpptr(argslot_reg, rbp);
    1.21    __ jccb(Assembler::above, L_bad);
    1.22 -  __ cmpptr(rsp, rax_argslot);
    1.23 +  __ cmpptr(rsp, argslot_reg);
    1.24    __ jccb(Assembler::below, L_ok);
    1.25    __ bind(L_bad);
    1.26    __ stop(error_message);
    1.27 @@ -178,22 +178,6 @@
    1.28  
    1.29    // Now move the argslot down, to point to the opened-up space.
    1.30    __ lea(rax_argslot, Address(rax_argslot, arg_slots, Address::times_ptr));
    1.31 -
    1.32 -  if (TaggedStackInterpreter && arg_mask != _INSERT_NO_MASK) {
    1.33 -    // The caller has specified a bitmask of tags to put into the opened space.
    1.34 -    // This only works when the arg_slots value is an assembly-time constant.
    1.35 -    int constant_arg_slots = arg_slots.as_constant() / stack_move_unit();
    1.36 -    int tag_offset = Interpreter::tag_offset_in_bytes() - Interpreter::value_offset_in_bytes();
    1.37 -    for (int slot = 0; slot < constant_arg_slots; slot++) {
    1.38 -      BasicType slot_type   = ((arg_mask & (1 << slot)) == 0 ? T_OBJECT : T_INT);
    1.39 -      int       slot_offset = Interpreter::stackElementSize() * slot;
    1.40 -      Address   tag_addr(rax_argslot, slot_offset + tag_offset);
    1.41 -      __ movptr(tag_addr, frame::tag_for_basic_type(slot_type));
    1.42 -    }
    1.43 -    // Note that the new argument slots are tagged properly but contain
    1.44 -    // garbage at this point.  The value portions must be initialized
    1.45 -    // by the caller.  (Especially references!)
    1.46 -  }
    1.47  }
    1.48  
    1.49  // Helper to remove argument slots from the stack.
    1.50 @@ -206,18 +190,9 @@
    1.51                               (!arg_slots.is_register() ? rsp : arg_slots.as_register()));
    1.52  
    1.53  #ifdef ASSERT
    1.54 -  {
    1.55 -    // Verify that [argslot..argslot+size) lies within (rsp, rbp).
    1.56 -    Label L_ok, L_bad;
    1.57 -    __ lea(rbx_temp, Address(rax_argslot, arg_slots, Address::times_ptr));
    1.58 -    __ cmpptr(rbx_temp, rbp);
    1.59 -    __ jccb(Assembler::above, L_bad);
    1.60 -    __ cmpptr(rsp, rax_argslot);
    1.61 -    __ jccb(Assembler::below, L_ok);
    1.62 -    __ bind(L_bad);
    1.63 -    __ stop("deleted argument(s) must fall within current frame");
    1.64 -    __ bind(L_ok);
    1.65 -  }
    1.66 +  // Verify that [argslot..argslot+size) lies within (rsp, rbp).
    1.67 +  __ lea(rbx_temp, Address(rax_argslot, arg_slots, Address::times_ptr));
    1.68 +  verify_argslot(_masm, rbx_temp, "deleted argument(s) must fall within current frame");
    1.69    if (arg_slots.is_register()) {
    1.70      Label L_ok, L_bad;
    1.71      __ cmpptr(arg_slots.as_register(), (int32_t) NULL_WORD);
    1.72 @@ -321,12 +296,6 @@
    1.73    Address rcx_amh_conversion( rcx_recv, sun_dyn_AdapterMethodHandle::conversion_offset_in_bytes() );
    1.74    Address vmarg;                // __ argument_address(vmargslot)
    1.75  
    1.76 -  int tag_offset = -1;
    1.77 -  if (TaggedStackInterpreter) {
    1.78 -    tag_offset = Interpreter::tag_offset_in_bytes() - Interpreter::value_offset_in_bytes();
    1.79 -    assert(tag_offset = wordSize, "stack grows as expected");
    1.80 -  }
    1.81 -
    1.82    const int java_mirror_offset = klassOopDesc::klass_part_offset_in_bytes() + Klass::java_mirror_offset_in_bytes();
    1.83  
    1.84    if (have_entry(ek)) {
    1.85 @@ -372,11 +341,8 @@
    1.86        __ mov(rsp, rsi);   // cut the stack back to where the caller started
    1.87  
    1.88        // Repush the arguments as if coming from the interpreter.
    1.89 -      if (TaggedStackInterpreter)  __ push(frame::tag_for_basic_type(T_INT));
    1.90        __ push(rdx_code);
    1.91 -      if (TaggedStackInterpreter)  __ push(frame::tag_for_basic_type(T_OBJECT));
    1.92        __ push(rcx_fail);
    1.93 -      if (TaggedStackInterpreter)  __ push(frame::tag_for_basic_type(T_OBJECT));
    1.94        __ push(rax_want);
    1.95  
    1.96        Register rbx_method = rbx_temp;
    1.97 @@ -397,7 +363,6 @@
    1.98        // Do something that is at least causes a valid throw from the interpreter.
    1.99        __ bind(no_method);
   1.100        __ pop(rax_want);
   1.101 -      if (TaggedStackInterpreter)  __ pop(rcx_fail);
   1.102        __ pop(rcx_fail);
   1.103        __ push(rax_want);
   1.104        __ push(rcx_fail);
   1.105 @@ -510,18 +475,10 @@
   1.106    case _bound_long_direct_mh:
   1.107      {
   1.108        bool direct_to_method = (ek >= _bound_ref_direct_mh);
   1.109 -      BasicType arg_type = T_ILLEGAL;
   1.110 -      if (ek == _bound_long_mh || ek == _bound_long_direct_mh) {
   1.111 -        arg_type = T_LONG;
   1.112 -      } else if (ek == _bound_int_mh || ek == _bound_int_direct_mh) {
   1.113 -        arg_type = T_INT;
   1.114 -      } else {
   1.115 -        assert(ek == _bound_ref_mh || ek == _bound_ref_direct_mh, "must be ref");
   1.116 -        arg_type = T_OBJECT;
   1.117 -      }
   1.118 -      int arg_slots = type2size[arg_type];
   1.119 -      int arg_mask  = (arg_type == T_OBJECT ? _INSERT_REF_MASK :
   1.120 -                       arg_slots == 1       ? _INSERT_INT_MASK :  _INSERT_LONG_MASK);
   1.121 +      BasicType arg_type  = T_ILLEGAL;
   1.122 +      int       arg_mask  = _INSERT_NO_MASK;
   1.123 +      int       arg_slots = -1;
   1.124 +      get_ek_bound_mh_info(ek, arg_type, arg_mask, arg_slots);
   1.125  
   1.126        // make room for the new argument:
   1.127        __ movl(rax_argslot, rcx_bmh_vmargslot);
   1.128 @@ -660,13 +617,10 @@
   1.129          }
   1.130          break;
   1.131        default:
   1.132 -        assert(false, "");
   1.133 +        ShouldNotReachHere();
   1.134        }
   1.135 -      goto finish_int_conversion;
   1.136 -    }
   1.137  
   1.138 -  finish_int_conversion:
   1.139 -    {
   1.140 +      // Do the requested conversion and store the value.
   1.141        Register rbx_vminfo = rbx_temp;
   1.142        __ movl(rbx_vminfo, rcx_amh_conversion);
   1.143        assert(CONV_VMINFO_SHIFT == 0, "preshifted");
   1.144 @@ -692,7 +646,7 @@
   1.145        __ shrl(rdx_temp /*, rcx*/);
   1.146  
   1.147        __ bind(done);
   1.148 -      __ movl(vmarg, rdx_temp);
   1.149 +      __ movl(vmarg, rdx_temp);  // Store the value.
   1.150        __ xchgptr(rcx, rbx_vminfo);                // restore rcx_recv
   1.151  
   1.152        __ jump_to_method_handle_entry(rcx_recv, rdx_temp);
   1.153 @@ -715,9 +669,14 @@
   1.154        switch (ek) {
   1.155        case _adapter_opt_i2l:
   1.156          {
   1.157 +#ifdef _LP64
   1.158 +          __ movslq(rdx_temp, vmarg1);  // Load sign-extended
   1.159 +          __ movq(vmarg1, rdx_temp);    // Store into first slot
   1.160 +#else
   1.161            __ movl(rdx_temp, vmarg1);
   1.162 -          __ sarl(rdx_temp, 31);  // __ extend_sign()
   1.163 +          __ sarl(rdx_temp, BitsPerInt - 1);  // __ extend_sign()
   1.164            __ movl(vmarg2, rdx_temp); // store second word
   1.165 +#endif
   1.166          }
   1.167          break;
   1.168        case _adapter_opt_unboxl:
   1.169 @@ -727,14 +686,19 @@
   1.170            int value_offset = java_lang_boxing_object::value_offset_in_bytes(T_LONG);
   1.171            assert(value_offset == java_lang_boxing_object::value_offset_in_bytes(T_DOUBLE), "");
   1.172            __ null_check(rdx_temp, value_offset);
   1.173 +#ifdef _LP64
   1.174 +          __ movq(rbx_temp, Address(rdx_temp, value_offset));
   1.175 +          __ movq(vmarg1, rbx_temp);
   1.176 +#else
   1.177            __ movl(rbx_temp, Address(rdx_temp, value_offset + 0*BytesPerInt));
   1.178            __ movl(rdx_temp, Address(rdx_temp, value_offset + 1*BytesPerInt));
   1.179            __ movl(vmarg1, rbx_temp);
   1.180            __ movl(vmarg2, rdx_temp);
   1.181 +#endif
   1.182          }
   1.183          break;
   1.184        default:
   1.185 -        assert(false, "");
   1.186 +        ShouldNotReachHere();
   1.187        }
   1.188  
   1.189        __ movptr(rcx_recv, rcx_mh_vmtarget);
   1.190 @@ -768,20 +732,9 @@
   1.191        if (ek == _adapter_opt_f2d) {
   1.192          __ fld_s(vmarg);        // load float to ST0
   1.193          __ fstp_s(vmarg);       // store single
   1.194 -      } else if (!TaggedStackInterpreter) {
   1.195 +      } else {
   1.196          __ fld_d(vmarg);        // load double to ST0
   1.197          __ fstp_s(vmarg);       // store single
   1.198 -      } else {
   1.199 -        Address vmarg_tag = vmarg.plus_disp(tag_offset);
   1.200 -        Address vmarg2    = vmarg.plus_disp(Interpreter::stackElementSize());
   1.201 -        // vmarg2_tag does not participate in this code
   1.202 -        Register rbx_tag = rbx_temp;
   1.203 -        __ movl(rbx_tag, vmarg_tag); // preserve tag
   1.204 -        __ movl(rdx_temp, vmarg2); // get second word of double
   1.205 -        __ movl(vmarg_tag, rdx_temp); // align with first word
   1.206 -        __ fld_d(vmarg);        // load double to ST0
   1.207 -        __ movl(vmarg_tag, rbx_tag); // restore tag
   1.208 -        __ fstp_s(vmarg);       // store single
   1.209        }
   1.210  #endif //_LP64
   1.211  
   1.212 @@ -812,19 +765,8 @@
   1.213    case _adapter_opt_rot_2_up:
   1.214    case _adapter_opt_rot_2_down:
   1.215      {
   1.216 -      int rotate = 0, swap_slots = 0;
   1.217 -      switch ((int)ek) {
   1.218 -      case _adapter_opt_swap_1:     swap_slots = 1; break;
   1.219 -      case _adapter_opt_swap_2:     swap_slots = 2; break;
   1.220 -      case _adapter_opt_rot_1_up:   swap_slots = 1; rotate++; break;
   1.221 -      case _adapter_opt_rot_1_down: swap_slots = 1; rotate--; break;
   1.222 -      case _adapter_opt_rot_2_up:   swap_slots = 2; rotate++; break;
   1.223 -      case _adapter_opt_rot_2_down: swap_slots = 2; rotate--; break;
   1.224 -      default: assert(false, "");
   1.225 -      }
   1.226 -
   1.227 -      // the real size of the move must be doubled if TaggedStackInterpreter:
   1.228 -      int swap_bytes = (int)( swap_slots * Interpreter::stackElementWords() * wordSize );
   1.229 +      int swap_bytes = 0, rotate = 0;
   1.230 +      get_ek_adapter_opt_swap_rot_info(ek, swap_bytes, rotate);
   1.231  
   1.232        // 'argslot' is the position of the first argument to swap
   1.233        __ movl(rax_argslot, rcx_amh_vmargslot);
   1.234 @@ -925,8 +867,8 @@
   1.235  
   1.236        // 'stack_move' is negative number of words to duplicate
   1.237        Register rdx_stack_move = rdx_temp;
   1.238 -      __ movl(rdx_stack_move, rcx_amh_conversion);
   1.239 -      __ sarl(rdx_stack_move, CONV_STACK_MOVE_SHIFT);
   1.240 +      __ movl2ptr(rdx_stack_move, rcx_amh_conversion);
   1.241 +      __ sarptr(rdx_stack_move, CONV_STACK_MOVE_SHIFT);
   1.242  
   1.243        int argslot0_num = 0;
   1.244        Address argslot0 = __ argument_address(RegisterOrConstant(argslot0_num));
   1.245 @@ -988,8 +930,8 @@
   1.246  
   1.247        // 'stack_move' is number of words to drop
   1.248        Register rdi_stack_move = rdi;
   1.249 -      __ movl(rdi_stack_move, rcx_amh_conversion);
   1.250 -      __ sarl(rdi_stack_move, CONV_STACK_MOVE_SHIFT);
   1.251 +      __ movl2ptr(rdi_stack_move, rcx_amh_conversion);
   1.252 +      __ sarptr(rdi_stack_move, CONV_STACK_MOVE_SHIFT);
   1.253        remove_arg_slots(_masm, rdi_stack_move,
   1.254                         rax_argslot, rbx_temp, rdx_temp);
   1.255  
   1.256 @@ -1014,11 +956,7 @@
   1.257    case _adapter_opt_spread_more:
   1.258      {
   1.259        // spread an array out into a group of arguments
   1.260 -      int length_constant = -1;
   1.261 -      switch (ek) {
   1.262 -      case _adapter_opt_spread_0: length_constant = 0; break;
   1.263 -      case _adapter_opt_spread_1: length_constant = 1; break;
   1.264 -      }
   1.265 +      int length_constant = get_ek_adapter_opt_spread_info(ek);
   1.266  
   1.267        // find the address of the array argument
   1.268        __ movl(rax_argslot, rcx_amh_vmargslot);
   1.269 @@ -1079,8 +1017,8 @@
   1.270          __ lea(rdx_argslot_limit, Address(rax_argslot, Interpreter::stackElementSize()));
   1.271          // 'stack_move' is negative number of words to insert
   1.272          Register rdi_stack_move = rdi;
   1.273 -        __ movl(rdi_stack_move, rcx_amh_conversion);
   1.274 -        __ sarl(rdi_stack_move, CONV_STACK_MOVE_SHIFT);
   1.275 +        __ movl2ptr(rdi_stack_move, rcx_amh_conversion);
   1.276 +        __ sarptr(rdi_stack_move, CONV_STACK_MOVE_SHIFT);
   1.277          Register rsi_temp = rsi_array;  // spill this
   1.278          insert_arg_slots(_masm, rdi_stack_move, -1,
   1.279                           rax_argslot, rbx_temp, rsi_temp);
   1.280 @@ -1114,10 +1052,6 @@
   1.281          __ movptr(rbx_temp, Address(rsi_source, 0));
   1.282          __ movptr(Address(rax_argslot, 0), rbx_temp);
   1.283          __ addptr(rsi_source, type2aelembytes(elem_type));
   1.284 -        if (TaggedStackInterpreter) {
   1.285 -          __ movptr(Address(rax_argslot, tag_offset),
   1.286 -                    frame::tag_for_basic_type(elem_type));
   1.287 -        }
   1.288          __ addptr(rax_argslot, Interpreter::stackElementSize());
   1.289          __ cmpptr(rax_argslot, rdx_argslot_limit);
   1.290          __ jccb(Assembler::less, loop);
   1.291 @@ -1131,11 +1065,7 @@
   1.292            __ movptr(rbx_temp, Address(rsi_array, elem_offset));
   1.293            __ movptr(Address(rax_argslot, slot_offset), rbx_temp);
   1.294            elem_offset += type2aelembytes(elem_type);
   1.295 -          if (TaggedStackInterpreter) {
   1.296 -            __ movptr(Address(rax_argslot, slot_offset + tag_offset),
   1.297 -                      frame::tag_for_basic_type(elem_type));
   1.298 -          }
   1.299 -          slot_offset += Interpreter::stackElementSize();
   1.300 +           slot_offset += Interpreter::stackElementSize();
   1.301          }
   1.302        }
   1.303  

mercurial