hotspot/src/cpu/x86/vm/methodHandles_x86.cpp
author twisti
Tue, 23 Feb 2010 17:46:29 +0100
changeset 5028 5a7f933d81c1
parent 4564 55dfb20908d0
child 5044 7e40acdf2163
permissions -rw-r--r--
6928839: JSR 292 typo in x86 _adapter_check_cast Summary: There is a small typo in methodHandles_x86.cpp. Reviewed-by: kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
     1
/*
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
     2
 * Copyright 1997-2009 Sun Microsystems, Inc.  All Rights Reserved.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
     4
 *
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
     7
 * published by the Free Software Foundation.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
     8
 *
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    13
 * accompanied this code).
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    14
 *
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    18
 *
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    21
 * have any questions.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    22
 *
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    23
 */
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    24
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    25
#include "incls/_precompiled.incl"
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    26
#include "incls/_methodHandles_x86.cpp.incl"
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    27
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    28
#define __ _masm->
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    29
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    30
address MethodHandleEntry::start_compiled_entry(MacroAssembler* _masm,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    31
                                                address interpreted_entry) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    32
  // Just before the actual machine code entry point, allocate space
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    33
  // for a MethodHandleEntry::Data record, so that we can manage everything
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    34
  // from one base pointer.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    35
  __ align(wordSize);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    36
  address target = __ pc() + sizeof(Data);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    37
  while (__ pc() < target) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    38
    __ nop();
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    39
    __ align(wordSize);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    40
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    41
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    42
  MethodHandleEntry* me = (MethodHandleEntry*) __ pc();
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    43
  me->set_end_address(__ pc());         // set a temporary end_address
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    44
  me->set_from_interpreted_entry(interpreted_entry);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    45
  me->set_type_checking_entry(NULL);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    46
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    47
  return (address) me;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    48
}
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    49
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    50
MethodHandleEntry* MethodHandleEntry::finish_compiled_entry(MacroAssembler* _masm,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    51
                                                address start_addr) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    52
  MethodHandleEntry* me = (MethodHandleEntry*) start_addr;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    53
  assert(me->end_address() == start_addr, "valid ME");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    54
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    55
  // Fill in the real end_address:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    56
  __ align(wordSize);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    57
  me->set_end_address(__ pc());
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    58
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    59
  return me;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    60
}
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    61
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    62
#ifdef ASSERT
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    63
static void verify_argslot(MacroAssembler* _masm, Register rax_argslot,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    64
                           const char* error_message) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    65
  // Verify that argslot lies within (rsp, rbp].
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    66
  Label L_ok, L_bad;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    67
  __ cmpptr(rax_argslot, rbp);
4564
55dfb20908d0 6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents: 4562
diff changeset
    68
  __ jccb(Assembler::above, L_bad);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    69
  __ cmpptr(rsp, rax_argslot);
4564
55dfb20908d0 6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents: 4562
diff changeset
    70
  __ jccb(Assembler::below, L_ok);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    71
  __ bind(L_bad);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    72
  __ stop(error_message);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    73
  __ bind(L_ok);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    74
}
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    75
#endif
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    76
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    77
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    78
// Code generation
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    79
address MethodHandles::generate_method_handle_interpreter_entry(MacroAssembler* _masm) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    80
  // rbx: methodOop
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    81
  // rcx: receiver method handle (must load from sp[MethodTypeForm.vmslots])
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    82
  // rsi/r13: sender SP (must preserve; see prepare_to_jump_from_interpreted)
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    83
  // rdx: garbage temp, blown away
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    84
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    85
  Register rbx_method = rbx;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    86
  Register rcx_recv   = rcx;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    87
  Register rax_mtype  = rax;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    88
  Register rdx_temp   = rdx;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    89
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    90
  // emit WrongMethodType path first, to enable jccb back-branch from main path
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    91
  Label wrong_method_type;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    92
  __ bind(wrong_method_type);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    93
  __ push(rax_mtype);       // required mtype
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    94
  __ push(rcx_recv);        // bad mh (1st stacked argument)
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    95
  __ jump(ExternalAddress(Interpreter::throw_WrongMethodType_entry()));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    96
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    97
  // here's where control starts out:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    98
  __ align(CodeEntryAlignment);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    99
  address entry_point = __ pc();
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   100
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   101
  // fetch the MethodType from the method handle into rax (the 'check' register)
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   102
  {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   103
    Register tem = rbx_method;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   104
    for (jint* pchase = methodOopDesc::method_type_offsets_chain(); (*pchase) != -1; pchase++) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   105
      __ movptr(rax_mtype, Address(tem, *pchase));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   106
      tem = rax_mtype;          // in case there is another indirection
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   107
    }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   108
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   109
  Register rbx_temp = rbx_method; // done with incoming methodOop
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   110
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   111
  // given the MethodType, find out where the MH argument is buried
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   112
  __ movptr(rdx_temp, Address(rax_mtype,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   113
                              __ delayed_value(java_dyn_MethodType::form_offset_in_bytes, rbx_temp)));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   114
  __ movl(rdx_temp, Address(rdx_temp,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   115
                            __ delayed_value(java_dyn_MethodTypeForm::vmslots_offset_in_bytes, rbx_temp)));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   116
  __ movptr(rcx_recv, __ argument_address(rdx_temp));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   117
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   118
  __ check_method_handle_type(rax_mtype, rcx_recv, rdx_temp, wrong_method_type);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   119
  __ jump_to_method_handle_entry(rcx_recv, rdx_temp);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   120
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   121
  return entry_point;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   122
}
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   123
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   124
// Helper to insert argument slots into the stack.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   125
// arg_slots must be a multiple of stack_move_unit() and <= 0
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   126
void MethodHandles::insert_arg_slots(MacroAssembler* _masm,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   127
                                     RegisterOrConstant arg_slots,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   128
                                     int arg_mask,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   129
                                     Register rax_argslot,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   130
                                     Register rbx_temp, Register rdx_temp) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   131
  assert_different_registers(rax_argslot, rbx_temp, rdx_temp,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   132
                             (!arg_slots.is_register() ? rsp : arg_slots.as_register()));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   133
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   134
#ifdef ASSERT
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   135
  verify_argslot(_masm, rax_argslot, "insertion point must fall within current frame");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   136
  if (arg_slots.is_register()) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   137
    Label L_ok, L_bad;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   138
    __ cmpptr(arg_slots.as_register(), (int32_t) NULL_WORD);
4564
55dfb20908d0 6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents: 4562
diff changeset
   139
    __ jccb(Assembler::greater, L_bad);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   140
    __ testl(arg_slots.as_register(), -stack_move_unit() - 1);
4564
55dfb20908d0 6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents: 4562
diff changeset
   141
    __ jccb(Assembler::zero, L_ok);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   142
    __ bind(L_bad);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   143
    __ stop("assert arg_slots <= 0 and clear low bits");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   144
    __ bind(L_ok);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   145
  } else {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   146
    assert(arg_slots.as_constant() <= 0, "");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   147
    assert(arg_slots.as_constant() % -stack_move_unit() == 0, "");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   148
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   149
#endif //ASSERT
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   150
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   151
#ifdef _LP64
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   152
  if (arg_slots.is_register()) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   153
    // clean high bits of stack motion register (was loaded as an int)
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   154
    __ movslq(arg_slots.as_register(), arg_slots.as_register());
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   155
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   156
#endif
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   157
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   158
  // Make space on the stack for the inserted argument(s).
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   159
  // Then pull down everything shallower than rax_argslot.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   160
  // The stacked return address gets pulled down with everything else.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   161
  // That is, copy [rsp, argslot) downward by -size words.  In pseudo-code:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   162
  //   rsp -= size;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   163
  //   for (rdx = rsp + size; rdx < argslot; rdx++)
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   164
  //     rdx[-size] = rdx[0]
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   165
  //   argslot -= size;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   166
  __ mov(rdx_temp, rsp);                        // source pointer for copy
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   167
  __ lea(rsp, Address(rsp, arg_slots, Address::times_ptr));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   168
  {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   169
    Label loop;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   170
    __ bind(loop);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   171
    // pull one word down each time through the loop
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   172
    __ movptr(rbx_temp, Address(rdx_temp, 0));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   173
    __ movptr(Address(rdx_temp, arg_slots, Address::times_ptr), rbx_temp);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   174
    __ addptr(rdx_temp, wordSize);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   175
    __ cmpptr(rdx_temp, rax_argslot);
4564
55dfb20908d0 6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents: 4562
diff changeset
   176
    __ jccb(Assembler::less, loop);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   177
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   178
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   179
  // Now move the argslot down, to point to the opened-up space.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   180
  __ lea(rax_argslot, Address(rax_argslot, arg_slots, Address::times_ptr));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   181
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   182
  if (TaggedStackInterpreter && arg_mask != _INSERT_NO_MASK) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   183
    // The caller has specified a bitmask of tags to put into the opened space.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   184
    // This only works when the arg_slots value is an assembly-time constant.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   185
    int constant_arg_slots = arg_slots.as_constant() / stack_move_unit();
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   186
    int tag_offset = Interpreter::tag_offset_in_bytes() - Interpreter::value_offset_in_bytes();
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   187
    for (int slot = 0; slot < constant_arg_slots; slot++) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   188
      BasicType slot_type   = ((arg_mask & (1 << slot)) == 0 ? T_OBJECT : T_INT);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   189
      int       slot_offset = Interpreter::stackElementSize() * slot;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   190
      Address   tag_addr(rax_argslot, slot_offset + tag_offset);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   191
      __ movptr(tag_addr, frame::tag_for_basic_type(slot_type));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   192
    }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   193
    // Note that the new argument slots are tagged properly but contain
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   194
    // garbage at this point.  The value portions must be initialized
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   195
    // by the caller.  (Especially references!)
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   196
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   197
}
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   198
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   199
// Helper to remove argument slots from the stack.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   200
// arg_slots must be a multiple of stack_move_unit() and >= 0
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   201
void MethodHandles::remove_arg_slots(MacroAssembler* _masm,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   202
                                    RegisterOrConstant arg_slots,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   203
                                    Register rax_argslot,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   204
                                    Register rbx_temp, Register rdx_temp) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   205
  assert_different_registers(rax_argslot, rbx_temp, rdx_temp,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   206
                             (!arg_slots.is_register() ? rsp : arg_slots.as_register()));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   207
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   208
#ifdef ASSERT
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   209
  {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   210
    // Verify that [argslot..argslot+size) lies within (rsp, rbp).
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   211
    Label L_ok, L_bad;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   212
    __ lea(rbx_temp, Address(rax_argslot, arg_slots, Address::times_ptr));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   213
    __ cmpptr(rbx_temp, rbp);
4564
55dfb20908d0 6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents: 4562
diff changeset
   214
    __ jccb(Assembler::above, L_bad);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   215
    __ cmpptr(rsp, rax_argslot);
4564
55dfb20908d0 6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents: 4562
diff changeset
   216
    __ jccb(Assembler::below, L_ok);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   217
    __ bind(L_bad);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   218
    __ stop("deleted argument(s) must fall within current frame");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   219
    __ bind(L_ok);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   220
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   221
  if (arg_slots.is_register()) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   222
    Label L_ok, L_bad;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   223
    __ cmpptr(arg_slots.as_register(), (int32_t) NULL_WORD);
4564
55dfb20908d0 6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents: 4562
diff changeset
   224
    __ jccb(Assembler::less, L_bad);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   225
    __ testl(arg_slots.as_register(), -stack_move_unit() - 1);
4564
55dfb20908d0 6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents: 4562
diff changeset
   226
    __ jccb(Assembler::zero, L_ok);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   227
    __ bind(L_bad);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   228
    __ stop("assert arg_slots >= 0 and clear low bits");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   229
    __ bind(L_ok);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   230
  } else {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   231
    assert(arg_slots.as_constant() >= 0, "");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   232
    assert(arg_slots.as_constant() % -stack_move_unit() == 0, "");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   233
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   234
#endif //ASSERT
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   235
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   236
#ifdef _LP64
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   237
  if (false) {                  // not needed, since register is positive
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   238
    // clean high bits of stack motion register (was loaded as an int)
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   239
    if (arg_slots.is_register())
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   240
      __ movslq(arg_slots.as_register(), arg_slots.as_register());
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   241
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   242
#endif
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   243
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   244
  // Pull up everything shallower than rax_argslot.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   245
  // Then remove the excess space on the stack.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   246
  // The stacked return address gets pulled up with everything else.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   247
  // That is, copy [rsp, argslot) upward by size words.  In pseudo-code:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   248
  //   for (rdx = argslot-1; rdx >= rsp; --rdx)
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   249
  //     rdx[size] = rdx[0]
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   250
  //   argslot += size;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   251
  //   rsp += size;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   252
  __ lea(rdx_temp, Address(rax_argslot, -wordSize)); // source pointer for copy
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   253
  {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   254
    Label loop;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   255
    __ bind(loop);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   256
    // pull one word up each time through the loop
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   257
    __ movptr(rbx_temp, Address(rdx_temp, 0));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   258
    __ movptr(Address(rdx_temp, arg_slots, Address::times_ptr), rbx_temp);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   259
    __ addptr(rdx_temp, -wordSize);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   260
    __ cmpptr(rdx_temp, rsp);
4564
55dfb20908d0 6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents: 4562
diff changeset
   261
    __ jccb(Assembler::greaterEqual, loop);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   262
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   263
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   264
  // Now move the argslot up, to point to the just-copied block.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   265
  __ lea(rsp, Address(rsp, arg_slots, Address::times_ptr));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   266
  // And adjust the argslot address to point at the deletion point.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   267
  __ lea(rax_argslot, Address(rax_argslot, arg_slots, Address::times_ptr));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   268
}
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   269
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   270
#ifndef PRODUCT
4562
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents: 4478
diff changeset
   271
extern "C" void print_method_handle(oop mh);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   272
void trace_method_handle_stub(const char* adaptername,
4562
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents: 4478
diff changeset
   273
                              oop mh,
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   274
                              intptr_t* entry_sp,
4094
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   275
                              intptr_t* saved_sp,
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   276
                              intptr_t* saved_bp) {
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   277
  // called as a leaf from native code: do not block the JVM!
4094
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   278
  intptr_t* last_sp = (intptr_t*) saved_bp[frame::interpreter_frame_last_sp_offset];
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   279
  intptr_t* base_sp = (intptr_t*) saved_bp[frame::interpreter_frame_monitor_block_top_offset];
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   280
  printf("MH %s mh="INTPTR_FORMAT" sp=("INTPTR_FORMAT"+"INTX_FORMAT") stack_size="INTX_FORMAT" bp="INTPTR_FORMAT"\n",
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   281
         adaptername, (intptr_t)mh, (intptr_t)entry_sp, (intptr_t)(saved_sp - entry_sp), (intptr_t)(base_sp - last_sp), (intptr_t)saved_bp);
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   282
  if (last_sp != saved_sp)
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   283
    printf("*** last_sp="INTPTR_FORMAT"\n", (intptr_t)last_sp);
4562
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents: 4478
diff changeset
   284
  if (Verbose)  print_method_handle(mh);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   285
}
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   286
#endif //PRODUCT
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   287
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   288
// Generate an "entry" field for a method handle.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   289
// This determines how the method handle will respond to calls.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   290
void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHandles::EntryKind ek) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   291
  // Here is the register state during an interpreted call,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   292
  // as set up by generate_method_handle_interpreter_entry():
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   293
  // - rbx: garbage temp (was MethodHandle.invoke methodOop, unused)
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   294
  // - rcx: receiver method handle
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   295
  // - rax: method handle type (only used by the check_mtype entry point)
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   296
  // - rsi/r13: sender SP (must preserve; see prepare_to_jump_from_interpreted)
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   297
  // - rdx: garbage temp, can blow away
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   298
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   299
  Register rcx_recv    = rcx;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   300
  Register rax_argslot = rax;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   301
  Register rbx_temp    = rbx;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   302
  Register rdx_temp    = rdx;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   303
4094
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   304
  // This guy is set up by prepare_to_jump_from_interpreted (from interpreted calls)
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   305
  // and gen_c2i_adapter (from compiled calls):
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   306
  Register saved_last_sp = LP64_ONLY(r13) NOT_LP64(rsi);
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   307
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   308
  guarantee(java_dyn_MethodHandle::vmentry_offset_in_bytes() != 0, "must have offsets");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   309
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   310
  // some handy addresses
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   311
  Address rbx_method_fie(     rbx,      methodOopDesc::from_interpreted_offset() );
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   312
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   313
  Address rcx_mh_vmtarget(    rcx_recv, java_dyn_MethodHandle::vmtarget_offset_in_bytes() );
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   314
  Address rcx_dmh_vmindex(    rcx_recv, sun_dyn_DirectMethodHandle::vmindex_offset_in_bytes() );
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   315
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   316
  Address rcx_bmh_vmargslot(  rcx_recv, sun_dyn_BoundMethodHandle::vmargslot_offset_in_bytes() );
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   317
  Address rcx_bmh_argument(   rcx_recv, sun_dyn_BoundMethodHandle::argument_offset_in_bytes() );
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   318
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   319
  Address rcx_amh_vmargslot(  rcx_recv, sun_dyn_AdapterMethodHandle::vmargslot_offset_in_bytes() );
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   320
  Address rcx_amh_argument(   rcx_recv, sun_dyn_AdapterMethodHandle::argument_offset_in_bytes() );
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   321
  Address rcx_amh_conversion( rcx_recv, sun_dyn_AdapterMethodHandle::conversion_offset_in_bytes() );
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   322
  Address vmarg;                // __ argument_address(vmargslot)
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   323
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   324
  int tag_offset = -1;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   325
  if (TaggedStackInterpreter) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   326
    tag_offset = Interpreter::tag_offset_in_bytes() - Interpreter::value_offset_in_bytes();
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   327
    assert(tag_offset = wordSize, "stack grows as expected");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   328
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   329
4094
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   330
  const int java_mirror_offset = klassOopDesc::klass_part_offset_in_bytes() + Klass::java_mirror_offset_in_bytes();
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   331
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   332
  if (have_entry(ek)) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   333
    __ nop();                   // empty stubs make SG sick
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   334
    return;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   335
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   336
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   337
  address interp_entry = __ pc();
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   338
  if (UseCompressedOops)  __ unimplemented("UseCompressedOops");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   339
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   340
#ifndef PRODUCT
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   341
  if (TraceMethodHandles) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   342
    __ push(rax); __ push(rbx); __ push(rcx); __ push(rdx); __ push(rsi); __ push(rdi);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   343
    __ lea(rax, Address(rsp, wordSize*6)); // entry_sp
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   344
    // arguments:
4094
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   345
    __ push(rbp);               // interpreter frame pointer
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   346
    __ push(rsi);               // saved_sp
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   347
    __ push(rax);               // entry_sp
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   348
    __ push(rcx);               // mh
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   349
    __ push(rcx);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   350
    __ movptr(Address(rsp, 0), (intptr_t)entry_name(ek));
4094
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   351
    __ call_VM_leaf(CAST_FROM_FN_PTR(address, trace_method_handle_stub), 5);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   352
    __ pop(rdi); __ pop(rsi); __ pop(rdx); __ pop(rcx); __ pop(rbx); __ pop(rax);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   353
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   354
#endif //PRODUCT
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   355
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   356
  switch ((int) ek) {
4094
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   357
  case _raise_exception:
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   358
    {
4094
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   359
      // Not a real MH entry, but rather shared code for raising an exception.
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   360
      // Extra local arguments are pushed on stack, as required type at TOS+8,
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   361
      // failing object (or NULL) at TOS+4, failing bytecode type at TOS.
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   362
      // Beyond those local arguments are the PC, of course.
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   363
      Register rdx_code = rdx_temp;
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   364
      Register rcx_fail = rcx_recv;
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   365
      Register rax_want = rax_argslot;
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   366
      Register rdi_pc   = rdi;
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   367
      __ pop(rdx_code);  // TOS+0
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   368
      __ pop(rcx_fail);  // TOS+4
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   369
      __ pop(rax_want);  // TOS+8
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   370
      __ pop(rdi_pc);    // caller PC
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   371
4094
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   372
      __ mov(rsp, rsi);   // cut the stack back to where the caller started
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   373
4094
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   374
      // Repush the arguments as if coming from the interpreter.
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   375
      if (TaggedStackInterpreter)  __ push(frame::tag_for_basic_type(T_INT));
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   376
      __ push(rdx_code);
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   377
      if (TaggedStackInterpreter)  __ push(frame::tag_for_basic_type(T_OBJECT));
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   378
      __ push(rcx_fail);
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   379
      if (TaggedStackInterpreter)  __ push(frame::tag_for_basic_type(T_OBJECT));
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   380
      __ push(rax_want);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   381
4094
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   382
      Register rbx_method = rbx_temp;
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   383
      Label no_method;
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   384
      // FIXME: fill in _raise_exception_method with a suitable sun.dyn method
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   385
      __ movptr(rbx_method, ExternalAddress((address) &_raise_exception_method));
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   386
      __ testptr(rbx_method, rbx_method);
4564
55dfb20908d0 6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents: 4562
diff changeset
   387
      __ jccb(Assembler::zero, no_method);
4094
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   388
      int jobject_oop_offset = 0;
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   389
      __ movptr(rbx_method, Address(rbx_method, jobject_oop_offset));  // dereference the jobject
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   390
      __ testptr(rbx_method, rbx_method);
4564
55dfb20908d0 6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents: 4562
diff changeset
   391
      __ jccb(Assembler::zero, no_method);
4094
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   392
      __ verify_oop(rbx_method);
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   393
      __ push(rdi_pc);          // and restore caller PC
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   394
      __ jmp(rbx_method_fie);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   395
4094
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   396
      // If we get here, the Java runtime did not do its job of creating the exception.
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   397
      // Do something that is at least causes a valid throw from the interpreter.
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   398
      __ bind(no_method);
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   399
      __ pop(rax_want);
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   400
      if (TaggedStackInterpreter)  __ pop(rcx_fail);
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   401
      __ pop(rcx_fail);
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   402
      __ push(rax_want);
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   403
      __ push(rcx_fail);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   404
      __ jump(ExternalAddress(Interpreter::throw_WrongMethodType_entry()));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   405
    }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   406
    break;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   407
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   408
  case _invokestatic_mh:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   409
  case _invokespecial_mh:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   410
    {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   411
      Register rbx_method = rbx_temp;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   412
      __ movptr(rbx_method, rcx_mh_vmtarget); // target is a methodOop
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   413
      __ verify_oop(rbx_method);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   414
      // same as TemplateTable::invokestatic or invokespecial,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   415
      // minus the CP setup and profiling:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   416
      if (ek == _invokespecial_mh) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   417
        // Must load & check the first argument before entering the target method.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   418
        __ load_method_handle_vmslots(rax_argslot, rcx_recv, rdx_temp);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   419
        __ movptr(rcx_recv, __ argument_address(rax_argslot, -1));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   420
        __ null_check(rcx_recv);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   421
        __ verify_oop(rcx_recv);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   422
      }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   423
      __ jmp(rbx_method_fie);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   424
    }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   425
    break;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   426
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   427
  case _invokevirtual_mh:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   428
    {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   429
      // same as TemplateTable::invokevirtual,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   430
      // minus the CP setup and profiling:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   431
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   432
      // pick out the vtable index and receiver offset from the MH,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   433
      // and then we can discard it:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   434
      __ load_method_handle_vmslots(rax_argslot, rcx_recv, rdx_temp);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   435
      Register rbx_index = rbx_temp;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   436
      __ movl(rbx_index, rcx_dmh_vmindex);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   437
      // Note:  The verifier allows us to ignore rcx_mh_vmtarget.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   438
      __ movptr(rcx_recv, __ argument_address(rax_argslot, -1));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   439
      __ null_check(rcx_recv, oopDesc::klass_offset_in_bytes());
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   440
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   441
      // get receiver klass
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   442
      Register rax_klass = rax_argslot;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   443
      __ load_klass(rax_klass, rcx_recv);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   444
      __ verify_oop(rax_klass);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   445
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   446
      // get target methodOop & entry point
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   447
      const int base = instanceKlass::vtable_start_offset() * wordSize;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   448
      assert(vtableEntry::size() * wordSize == wordSize, "adjust the scaling in the code below");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   449
      Address vtable_entry_addr(rax_klass,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   450
                                rbx_index, Address::times_ptr,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   451
                                base + vtableEntry::method_offset_in_bytes());
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   452
      Register rbx_method = rbx_temp;
4478
c3a8af0fc6b0 6829192: JSR 292 needs to support 64-bit x86
twisti
parents: 4094
diff changeset
   453
      __ movptr(rbx_method, vtable_entry_addr);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   454
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   455
      __ verify_oop(rbx_method);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   456
      __ jmp(rbx_method_fie);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   457
    }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   458
    break;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   459
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   460
  case _invokeinterface_mh:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   461
    {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   462
      // same as TemplateTable::invokeinterface,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   463
      // minus the CP setup and profiling:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   464
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   465
      // pick out the interface and itable index from the MH.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   466
      __ load_method_handle_vmslots(rax_argslot, rcx_recv, rdx_temp);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   467
      Register rdx_intf  = rdx_temp;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   468
      Register rbx_index = rbx_temp;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   469
      __ movptr(rdx_intf,  rcx_mh_vmtarget);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   470
      __ movl(rbx_index,   rcx_dmh_vmindex);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   471
      __ movptr(rcx_recv, __ argument_address(rax_argslot, -1));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   472
      __ null_check(rcx_recv, oopDesc::klass_offset_in_bytes());
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   473
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   474
      // get receiver klass
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   475
      Register rax_klass = rax_argslot;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   476
      __ load_klass(rax_klass, rcx_recv);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   477
      __ verify_oop(rax_klass);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   478
4094
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   479
      Register rdi_temp   = rdi;
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   480
      Register rbx_method = rbx_index;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   481
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   482
      // get interface klass
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   483
      Label no_such_interface;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   484
      __ verify_oop(rdx_intf);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   485
      __ lookup_interface_method(rax_klass, rdx_intf,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   486
                                 // note: next two args must be the same:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   487
                                 rbx_index, rbx_method,
4094
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   488
                                 rdi_temp,
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   489
                                 no_such_interface);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   490
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   491
      __ verify_oop(rbx_method);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   492
      __ jmp(rbx_method_fie);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   493
      __ hlt();
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   494
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   495
      __ bind(no_such_interface);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   496
      // Throw an exception.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   497
      // For historical reasons, it will be IncompatibleClassChangeError.
4094
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   498
      __ pushptr(Address(rdx_intf, java_mirror_offset));  // required interface
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   499
      __ push(rcx_recv);        // bad receiver
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   500
      __ push((int)Bytecodes::_invokeinterface);  // who is complaining?
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   501
      __ jump(ExternalAddress(from_interpreted_entry(_raise_exception)));
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   502
    }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   503
    break;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   504
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   505
  case _bound_ref_mh:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   506
  case _bound_int_mh:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   507
  case _bound_long_mh:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   508
  case _bound_ref_direct_mh:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   509
  case _bound_int_direct_mh:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   510
  case _bound_long_direct_mh:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   511
    {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   512
      bool direct_to_method = (ek >= _bound_ref_direct_mh);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   513
      BasicType arg_type = T_ILLEGAL;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   514
      if (ek == _bound_long_mh || ek == _bound_long_direct_mh) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   515
        arg_type = T_LONG;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   516
      } else if (ek == _bound_int_mh || ek == _bound_int_direct_mh) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   517
        arg_type = T_INT;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   518
      } else {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   519
        assert(ek == _bound_ref_mh || ek == _bound_ref_direct_mh, "must be ref");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   520
        arg_type = T_OBJECT;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   521
      }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   522
      int arg_slots = type2size[arg_type];
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   523
      int arg_mask  = (arg_type == T_OBJECT ? _INSERT_REF_MASK :
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   524
                       arg_slots == 1       ? _INSERT_INT_MASK :  _INSERT_LONG_MASK);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   525
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   526
      // make room for the new argument:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   527
      __ movl(rax_argslot, rcx_bmh_vmargslot);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   528
      __ lea(rax_argslot, __ argument_address(rax_argslot));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   529
      insert_arg_slots(_masm, arg_slots * stack_move_unit(), arg_mask,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   530
                       rax_argslot, rbx_temp, rdx_temp);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   531
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   532
      // store bound argument into the new stack slot:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   533
      __ movptr(rbx_temp, rcx_bmh_argument);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   534
      Address prim_value_addr(rbx_temp, java_lang_boxing_object::value_offset_in_bytes(arg_type));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   535
      if (arg_type == T_OBJECT) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   536
        __ movptr(Address(rax_argslot, 0), rbx_temp);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   537
      } else {
4564
55dfb20908d0 6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents: 4562
diff changeset
   538
        __ load_sized_value(rdx_temp, prim_value_addr,
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   539
                            type2aelembytes(arg_type), is_signed_subword_type(arg_type));
4564
55dfb20908d0 6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents: 4562
diff changeset
   540
        __ movptr(Address(rax_argslot, 0), rdx_temp);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   541
#ifndef _LP64
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   542
        if (arg_slots == 2) {
4564
55dfb20908d0 6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents: 4562
diff changeset
   543
          __ movl(rdx_temp, prim_value_addr.plus_disp(wordSize));
55dfb20908d0 6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents: 4562
diff changeset
   544
          __ movl(Address(rax_argslot, Interpreter::stackElementSize()), rdx_temp);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   545
        }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   546
#endif //_LP64
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   547
      }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   548
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   549
      if (direct_to_method) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   550
        Register rbx_method = rbx_temp;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   551
        __ movptr(rbx_method, rcx_mh_vmtarget);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   552
        __ verify_oop(rbx_method);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   553
        __ jmp(rbx_method_fie);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   554
      } else {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   555
        __ movptr(rcx_recv, rcx_mh_vmtarget);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   556
        __ verify_oop(rcx_recv);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   557
        __ jump_to_method_handle_entry(rcx_recv, rdx_temp);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   558
      }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   559
    }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   560
    break;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   561
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   562
  case _adapter_retype_only:
4094
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   563
  case _adapter_retype_raw:
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   564
    // immediately jump to the next MH layer:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   565
    __ movptr(rcx_recv, rcx_mh_vmtarget);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   566
    __ verify_oop(rcx_recv);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   567
    __ jump_to_method_handle_entry(rcx_recv, rdx_temp);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   568
    // This is OK when all parameter types widen.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   569
    // It is also OK when a return type narrows.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   570
    break;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   571
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   572
  case _adapter_check_cast:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   573
    {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   574
      // temps:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   575
      Register rbx_klass = rbx_temp; // interesting AMH data
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   576
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   577
      // check a reference argument before jumping to the next layer of MH:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   578
      __ movl(rax_argslot, rcx_amh_vmargslot);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   579
      vmarg = __ argument_address(rax_argslot);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   580
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   581
      // What class are we casting to?
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   582
      __ movptr(rbx_klass, rcx_amh_argument); // this is a Class object!
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   583
      __ movptr(rbx_klass, Address(rbx_klass, java_lang_Class::klass_offset_in_bytes()));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   584
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   585
      Label done;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   586
      __ movptr(rdx_temp, vmarg);
5028
5a7f933d81c1 6928839: JSR 292 typo in x86 _adapter_check_cast
twisti
parents: 4564
diff changeset
   587
      __ testptr(rdx_temp, rdx_temp);
4564
55dfb20908d0 6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents: 4562
diff changeset
   588
      __ jccb(Assembler::zero, done);         // no cast if null
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   589
      __ load_klass(rdx_temp, rdx_temp);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   590
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   591
      // live at this point:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   592
      // - rbx_klass:  klass required by the target method
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   593
      // - rdx_temp:   argument klass to test
4094
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   594
      // - rcx_recv:   adapter method handle
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   595
      __ check_klass_subtype(rdx_temp, rbx_klass, rax_argslot, done);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   596
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   597
      // If we get here, the type check failed!
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   598
      // Call the wrong_method_type stub, passing the failing argument type in rax.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   599
      Register rax_mtype = rax_argslot;
4094
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   600
      __ movl(rax_argslot, rcx_amh_vmargslot);  // reload argslot field
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   601
      __ movptr(rdx_temp, vmarg);
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   602
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   603
      __ pushptr(rcx_amh_argument); // required class
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   604
      __ push(rdx_temp);            // bad object
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   605
      __ push((int)Bytecodes::_checkcast);  // who is complaining?
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   606
      __ jump(ExternalAddress(from_interpreted_entry(_raise_exception)));
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   607
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   608
      __ bind(done);
4094
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   609
      // get the new MH:
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
   610
      __ movptr(rcx_recv, rcx_mh_vmtarget);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   611
      __ jump_to_method_handle_entry(rcx_recv, rdx_temp);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   612
    }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   613
    break;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   614
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   615
  case _adapter_prim_to_prim:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   616
  case _adapter_ref_to_prim:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   617
    // handled completely by optimized cases
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   618
    __ stop("init_AdapterMethodHandle should not issue this");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   619
    break;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   620
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   621
  case _adapter_opt_i2i:        // optimized subcase of adapt_prim_to_prim
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   622
//case _adapter_opt_f2i:        // optimized subcase of adapt_prim_to_prim
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   623
  case _adapter_opt_l2i:        // optimized subcase of adapt_prim_to_prim
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   624
  case _adapter_opt_unboxi:     // optimized subcase of adapt_ref_to_prim
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   625
    {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   626
      // perform an in-place conversion to int or an int subword
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   627
      __ movl(rax_argslot, rcx_amh_vmargslot);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   628
      vmarg = __ argument_address(rax_argslot);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   629
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   630
      switch (ek) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   631
      case _adapter_opt_i2i:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   632
        __ movl(rdx_temp, vmarg);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   633
        break;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   634
      case _adapter_opt_l2i:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   635
        {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   636
          // just delete the extra slot; on a little-endian machine we keep the first
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   637
          __ lea(rax_argslot, __ argument_address(rax_argslot, 1));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   638
          remove_arg_slots(_masm, -stack_move_unit(),
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   639
                           rax_argslot, rbx_temp, rdx_temp);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   640
          vmarg = Address(rax_argslot, -Interpreter::stackElementSize());
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   641
          __ movl(rdx_temp, vmarg);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   642
        }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   643
        break;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   644
      case _adapter_opt_unboxi:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   645
        {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   646
          // Load the value up from the heap.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   647
          __ movptr(rdx_temp, vmarg);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   648
          int value_offset = java_lang_boxing_object::value_offset_in_bytes(T_INT);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   649
#ifdef ASSERT
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   650
          for (int bt = T_BOOLEAN; bt < T_INT; bt++) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   651
            if (is_subword_type(BasicType(bt)))
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   652
              assert(value_offset == java_lang_boxing_object::value_offset_in_bytes(BasicType(bt)), "");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   653
          }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   654
#endif
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   655
          __ null_check(rdx_temp, value_offset);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   656
          __ movl(rdx_temp, Address(rdx_temp, value_offset));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   657
          // We load this as a word.  Because we are little-endian,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   658
          // the low bits will be correct, but the high bits may need cleaning.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   659
          // The vminfo will guide us to clean those bits.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   660
        }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   661
        break;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   662
      default:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   663
        assert(false, "");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   664
      }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   665
      goto finish_int_conversion;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   666
    }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   667
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   668
  finish_int_conversion:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   669
    {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   670
      Register rbx_vminfo = rbx_temp;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   671
      __ movl(rbx_vminfo, rcx_amh_conversion);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   672
      assert(CONV_VMINFO_SHIFT == 0, "preshifted");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   673
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   674
      // get the new MH:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   675
      __ movptr(rcx_recv, rcx_mh_vmtarget);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   676
      // (now we are done with the old MH)
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   677
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   678
      // original 32-bit vmdata word must be of this form:
4564
55dfb20908d0 6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents: 4562
diff changeset
   679
      //    | MBZ:6 | signBitCount:8 | srcDstTypes:8 | conversionOp:8 |
55dfb20908d0 6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents: 4562
diff changeset
   680
      __ xchgptr(rcx, rbx_vminfo);                // free rcx for shifts
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   681
      __ shll(rdx_temp /*, rcx*/);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   682
      Label zero_extend, done;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   683
      __ testl(rcx, CONV_VMINFO_SIGN_FLAG);
4564
55dfb20908d0 6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents: 4562
diff changeset
   684
      __ jccb(Assembler::zero, zero_extend);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   685
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   686
      // this path is taken for int->byte, int->short
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   687
      __ sarl(rdx_temp /*, rcx*/);
4564
55dfb20908d0 6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents: 4562
diff changeset
   688
      __ jmpb(done);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   689
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   690
      __ bind(zero_extend);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   691
      // this is taken for int->char
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   692
      __ shrl(rdx_temp /*, rcx*/);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   693
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   694
      __ bind(done);
4564
55dfb20908d0 6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents: 4562
diff changeset
   695
      __ movl(vmarg, rdx_temp);
55dfb20908d0 6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents: 4562
diff changeset
   696
      __ xchgptr(rcx, rbx_vminfo);                // restore rcx_recv
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   697
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   698
      __ jump_to_method_handle_entry(rcx_recv, rdx_temp);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   699
    }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   700
    break;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   701
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   702
  case _adapter_opt_i2l:        // optimized subcase of adapt_prim_to_prim
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   703
  case _adapter_opt_unboxl:     // optimized subcase of adapt_ref_to_prim
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   704
    {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   705
      // perform an in-place int-to-long or ref-to-long conversion
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   706
      __ movl(rax_argslot, rcx_amh_vmargslot);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   707
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   708
      // on a little-endian machine we keep the first slot and add another after
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   709
      __ lea(rax_argslot, __ argument_address(rax_argslot, 1));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   710
      insert_arg_slots(_masm, stack_move_unit(), _INSERT_INT_MASK,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   711
                       rax_argslot, rbx_temp, rdx_temp);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   712
      Address vmarg1(rax_argslot, -Interpreter::stackElementSize());
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   713
      Address vmarg2 = vmarg1.plus_disp(Interpreter::stackElementSize());
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   714
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   715
      switch (ek) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   716
      case _adapter_opt_i2l:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   717
        {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   718
          __ movl(rdx_temp, vmarg1);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   719
          __ sarl(rdx_temp, 31);  // __ extend_sign()
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   720
          __ movl(vmarg2, rdx_temp); // store second word
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   721
        }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   722
        break;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   723
      case _adapter_opt_unboxl:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   724
        {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   725
          // Load the value up from the heap.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   726
          __ movptr(rdx_temp, vmarg1);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   727
          int value_offset = java_lang_boxing_object::value_offset_in_bytes(T_LONG);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   728
          assert(value_offset == java_lang_boxing_object::value_offset_in_bytes(T_DOUBLE), "");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   729
          __ null_check(rdx_temp, value_offset);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   730
          __ movl(rbx_temp, Address(rdx_temp, value_offset + 0*BytesPerInt));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   731
          __ movl(rdx_temp, Address(rdx_temp, value_offset + 1*BytesPerInt));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   732
          __ movl(vmarg1, rbx_temp);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   733
          __ movl(vmarg2, rdx_temp);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   734
        }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   735
        break;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   736
      default:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   737
        assert(false, "");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   738
      }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   739
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   740
      __ movptr(rcx_recv, rcx_mh_vmtarget);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   741
      __ jump_to_method_handle_entry(rcx_recv, rdx_temp);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   742
    }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   743
    break;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   744
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   745
  case _adapter_opt_f2d:        // optimized subcase of adapt_prim_to_prim
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   746
  case _adapter_opt_d2f:        // optimized subcase of adapt_prim_to_prim
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   747
    {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   748
      // perform an in-place floating primitive conversion
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   749
      __ movl(rax_argslot, rcx_amh_vmargslot);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   750
      __ lea(rax_argslot, __ argument_address(rax_argslot, 1));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   751
      if (ek == _adapter_opt_f2d) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   752
        insert_arg_slots(_masm, stack_move_unit(), _INSERT_INT_MASK,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   753
                         rax_argslot, rbx_temp, rdx_temp);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   754
      }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   755
      Address vmarg(rax_argslot, -Interpreter::stackElementSize());
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   756
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   757
#ifdef _LP64
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   758
      if (ek == _adapter_opt_f2d) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   759
        __ movflt(xmm0, vmarg);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   760
        __ cvtss2sd(xmm0, xmm0);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   761
        __ movdbl(vmarg, xmm0);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   762
      } else {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   763
        __ movdbl(xmm0, vmarg);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   764
        __ cvtsd2ss(xmm0, xmm0);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   765
        __ movflt(vmarg, xmm0);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   766
      }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   767
#else //_LP64
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   768
      if (ek == _adapter_opt_f2d) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   769
        __ fld_s(vmarg);        // load float to ST0
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   770
        __ fstp_s(vmarg);       // store single
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   771
      } else if (!TaggedStackInterpreter) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   772
        __ fld_d(vmarg);        // load double to ST0
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   773
        __ fstp_s(vmarg);       // store single
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   774
      } else {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   775
        Address vmarg_tag = vmarg.plus_disp(tag_offset);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   776
        Address vmarg2    = vmarg.plus_disp(Interpreter::stackElementSize());
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   777
        // vmarg2_tag does not participate in this code
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   778
        Register rbx_tag = rbx_temp;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   779
        __ movl(rbx_tag, vmarg_tag); // preserve tag
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   780
        __ movl(rdx_temp, vmarg2); // get second word of double
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   781
        __ movl(vmarg_tag, rdx_temp); // align with first word
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   782
        __ fld_d(vmarg);        // load double to ST0
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   783
        __ movl(vmarg_tag, rbx_tag); // restore tag
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   784
        __ fstp_s(vmarg);       // store single
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   785
      }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   786
#endif //_LP64
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   787
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   788
      if (ek == _adapter_opt_d2f) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   789
        remove_arg_slots(_masm, -stack_move_unit(),
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   790
                         rax_argslot, rbx_temp, rdx_temp);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   791
      }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   792
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   793
      __ movptr(rcx_recv, rcx_mh_vmtarget);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   794
      __ jump_to_method_handle_entry(rcx_recv, rdx_temp);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   795
    }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   796
    break;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   797
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   798
  case _adapter_prim_to_ref:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   799
    __ unimplemented(entry_name(ek)); // %%% FIXME: NYI
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   800
    break;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   801
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   802
  case _adapter_swap_args:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   803
  case _adapter_rot_args:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   804
    // handled completely by optimized cases
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   805
    __ stop("init_AdapterMethodHandle should not issue this");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   806
    break;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   807
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   808
  case _adapter_opt_swap_1:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   809
  case _adapter_opt_swap_2:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   810
  case _adapter_opt_rot_1_up:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   811
  case _adapter_opt_rot_1_down:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   812
  case _adapter_opt_rot_2_up:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   813
  case _adapter_opt_rot_2_down:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   814
    {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   815
      int rotate = 0, swap_slots = 0;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   816
      switch ((int)ek) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   817
      case _adapter_opt_swap_1:     swap_slots = 1; break;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   818
      case _adapter_opt_swap_2:     swap_slots = 2; break;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   819
      case _adapter_opt_rot_1_up:   swap_slots = 1; rotate++; break;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   820
      case _adapter_opt_rot_1_down: swap_slots = 1; rotate--; break;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   821
      case _adapter_opt_rot_2_up:   swap_slots = 2; rotate++; break;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   822
      case _adapter_opt_rot_2_down: swap_slots = 2; rotate--; break;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   823
      default: assert(false, "");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   824
      }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   825
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   826
      // the real size of the move must be doubled if TaggedStackInterpreter:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   827
      int swap_bytes = (int)( swap_slots * Interpreter::stackElementWords() * wordSize );
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   828
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   829
      // 'argslot' is the position of the first argument to swap
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   830
      __ movl(rax_argslot, rcx_amh_vmargslot);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   831
      __ lea(rax_argslot, __ argument_address(rax_argslot));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   832
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   833
      // 'vminfo' is the second
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   834
      Register rbx_destslot = rbx_temp;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   835
      __ movl(rbx_destslot, rcx_amh_conversion);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   836
      assert(CONV_VMINFO_SHIFT == 0, "preshifted");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   837
      __ andl(rbx_destslot, CONV_VMINFO_MASK);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   838
      __ lea(rbx_destslot, __ argument_address(rbx_destslot));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   839
      DEBUG_ONLY(verify_argslot(_masm, rbx_destslot, "swap point must fall within current frame"));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   840
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   841
      if (!rotate) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   842
        for (int i = 0; i < swap_bytes; i += wordSize) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   843
          __ movptr(rdx_temp, Address(rax_argslot , i));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   844
          __ push(rdx_temp);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   845
          __ movptr(rdx_temp, Address(rbx_destslot, i));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   846
          __ movptr(Address(rax_argslot, i), rdx_temp);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   847
          __ pop(rdx_temp);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   848
          __ movptr(Address(rbx_destslot, i), rdx_temp);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   849
        }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   850
      } else {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   851
        // push the first chunk, which is going to get overwritten
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   852
        for (int i = swap_bytes; (i -= wordSize) >= 0; ) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   853
          __ movptr(rdx_temp, Address(rax_argslot, i));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   854
          __ push(rdx_temp);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   855
        }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   856
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   857
        if (rotate > 0) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   858
          // rotate upward
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   859
          __ subptr(rax_argslot, swap_bytes);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   860
#ifdef ASSERT
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   861
          {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   862
            // Verify that argslot > destslot, by at least swap_bytes.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   863
            Label L_ok;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   864
            __ cmpptr(rax_argslot, rbx_destslot);
4564
55dfb20908d0 6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents: 4562
diff changeset
   865
            __ jccb(Assembler::aboveEqual, L_ok);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   866
            __ stop("source must be above destination (upward rotation)");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   867
            __ bind(L_ok);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   868
          }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   869
#endif
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   870
          // work argslot down to destslot, copying contiguous data upwards
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   871
          // pseudo-code:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   872
          //   rax = src_addr - swap_bytes
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   873
          //   rbx = dest_addr
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   874
          //   while (rax >= rbx) *(rax + swap_bytes) = *(rax + 0), rax--;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   875
          Label loop;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   876
          __ bind(loop);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   877
          __ movptr(rdx_temp, Address(rax_argslot, 0));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   878
          __ movptr(Address(rax_argslot, swap_bytes), rdx_temp);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   879
          __ addptr(rax_argslot, -wordSize);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   880
          __ cmpptr(rax_argslot, rbx_destslot);
4564
55dfb20908d0 6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents: 4562
diff changeset
   881
          __ jccb(Assembler::aboveEqual, loop);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   882
        } else {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   883
          __ addptr(rax_argslot, swap_bytes);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   884
#ifdef ASSERT
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   885
          {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   886
            // Verify that argslot < destslot, by at least swap_bytes.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   887
            Label L_ok;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   888
            __ cmpptr(rax_argslot, rbx_destslot);
4564
55dfb20908d0 6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents: 4562
diff changeset
   889
            __ jccb(Assembler::belowEqual, L_ok);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   890
            __ stop("source must be below destination (downward rotation)");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   891
            __ bind(L_ok);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   892
          }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   893
#endif
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   894
          // work argslot up to destslot, copying contiguous data downwards
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   895
          // pseudo-code:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   896
          //   rax = src_addr + swap_bytes
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   897
          //   rbx = dest_addr
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   898
          //   while (rax <= rbx) *(rax - swap_bytes) = *(rax + 0), rax++;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   899
          Label loop;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   900
          __ bind(loop);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   901
          __ movptr(rdx_temp, Address(rax_argslot, 0));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   902
          __ movptr(Address(rax_argslot, -swap_bytes), rdx_temp);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   903
          __ addptr(rax_argslot, wordSize);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   904
          __ cmpptr(rax_argslot, rbx_destslot);
4564
55dfb20908d0 6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents: 4562
diff changeset
   905
          __ jccb(Assembler::belowEqual, loop);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   906
        }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   907
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   908
        // pop the original first chunk into the destination slot, now free
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   909
        for (int i = 0; i < swap_bytes; i += wordSize) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   910
          __ pop(rdx_temp);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   911
          __ movptr(Address(rbx_destslot, i), rdx_temp);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   912
        }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   913
      }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   914
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   915
      __ movptr(rcx_recv, rcx_mh_vmtarget);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   916
      __ jump_to_method_handle_entry(rcx_recv, rdx_temp);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   917
    }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   918
    break;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   919
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   920
  case _adapter_dup_args:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   921
    {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   922
      // 'argslot' is the position of the first argument to duplicate
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   923
      __ movl(rax_argslot, rcx_amh_vmargslot);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   924
      __ lea(rax_argslot, __ argument_address(rax_argslot));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   925
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   926
      // 'stack_move' is negative number of words to duplicate
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   927
      Register rdx_stack_move = rdx_temp;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   928
      __ movl(rdx_stack_move, rcx_amh_conversion);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   929
      __ sarl(rdx_stack_move, CONV_STACK_MOVE_SHIFT);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   930
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   931
      int argslot0_num = 0;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   932
      Address argslot0 = __ argument_address(RegisterOrConstant(argslot0_num));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   933
      assert(argslot0.base() == rsp, "");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   934
      int pre_arg_size = argslot0.disp();
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   935
      assert(pre_arg_size % wordSize == 0, "");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   936
      assert(pre_arg_size > 0, "must include PC");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   937
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   938
      // remember the old rsp+1 (argslot[0])
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   939
      Register rbx_oldarg = rbx_temp;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   940
      __ lea(rbx_oldarg, argslot0);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   941
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   942
      // move rsp down to make room for dups
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   943
      __ lea(rsp, Address(rsp, rdx_stack_move, Address::times_ptr));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   944
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   945
      // compute the new rsp+1 (argslot[0])
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   946
      Register rdx_newarg = rdx_temp;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   947
      __ lea(rdx_newarg, argslot0);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   948
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   949
      __ push(rdi);             // need a temp
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   950
      // (preceding push must be done after arg addresses are taken!)
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   951
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   952
      // pull down the pre_arg_size data (PC)
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   953
      for (int i = -pre_arg_size; i < 0; i += wordSize) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   954
        __ movptr(rdi, Address(rbx_oldarg, i));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   955
        __ movptr(Address(rdx_newarg, i), rdi);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   956
      }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   957
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   958
      // copy from rax_argslot[0...] down to new_rsp[1...]
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   959
      // pseudo-code:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   960
      //   rbx = old_rsp+1
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   961
      //   rdx = new_rsp+1
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   962
      //   rax = argslot
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   963
      //   while (rdx < rbx) *rdx++ = *rax++
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   964
      Label loop;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   965
      __ bind(loop);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   966
      __ movptr(rdi, Address(rax_argslot, 0));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   967
      __ movptr(Address(rdx_newarg, 0), rdi);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   968
      __ addptr(rax_argslot, wordSize);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   969
      __ addptr(rdx_newarg, wordSize);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   970
      __ cmpptr(rdx_newarg, rbx_oldarg);
4564
55dfb20908d0 6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents: 4562
diff changeset
   971
      __ jccb(Assembler::less, loop);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   972
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   973
      __ pop(rdi);              // restore temp
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   974
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   975
      __ movptr(rcx_recv, rcx_mh_vmtarget);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   976
      __ jump_to_method_handle_entry(rcx_recv, rdx_temp);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   977
    }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   978
    break;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   979
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   980
  case _adapter_drop_args:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   981
    {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   982
      // 'argslot' is the position of the first argument to nuke
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   983
      __ movl(rax_argslot, rcx_amh_vmargslot);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   984
      __ lea(rax_argslot, __ argument_address(rax_argslot));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   985
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   986
      __ push(rdi);             // need a temp
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   987
      // (must do previous push after argslot address is taken)
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   988
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   989
      // 'stack_move' is number of words to drop
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   990
      Register rdi_stack_move = rdi;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   991
      __ movl(rdi_stack_move, rcx_amh_conversion);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   992
      __ sarl(rdi_stack_move, CONV_STACK_MOVE_SHIFT);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   993
      remove_arg_slots(_masm, rdi_stack_move,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   994
                       rax_argslot, rbx_temp, rdx_temp);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   995
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   996
      __ pop(rdi);              // restore temp
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   997
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   998
      __ movptr(rcx_recv, rcx_mh_vmtarget);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   999
      __ jump_to_method_handle_entry(rcx_recv, rdx_temp);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1000
    }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1001
    break;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1002
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1003
  case _adapter_collect_args:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1004
    __ unimplemented(entry_name(ek)); // %%% FIXME: NYI
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1005
    break;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1006
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1007
  case _adapter_spread_args:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1008
    // handled completely by optimized cases
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1009
    __ stop("init_AdapterMethodHandle should not issue this");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1010
    break;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1011
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1012
  case _adapter_opt_spread_0:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1013
  case _adapter_opt_spread_1:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1014
  case _adapter_opt_spread_more:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1015
    {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1016
      // spread an array out into a group of arguments
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1017
      int length_constant = -1;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1018
      switch (ek) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1019
      case _adapter_opt_spread_0: length_constant = 0; break;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1020
      case _adapter_opt_spread_1: length_constant = 1; break;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1021
      }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1022
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1023
      // find the address of the array argument
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1024
      __ movl(rax_argslot, rcx_amh_vmargslot);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1025
      __ lea(rax_argslot, __ argument_address(rax_argslot));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1026
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1027
      // grab some temps
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1028
      { __ push(rsi); __ push(rdi); }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1029
      // (preceding pushes must be done after argslot address is taken!)
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1030
#define UNPUSH_RSI_RDI \
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1031
      { __ pop(rdi); __ pop(rsi); }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1032
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1033
      // arx_argslot points both to the array and to the first output arg
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1034
      vmarg = Address(rax_argslot, 0);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1035
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1036
      // Get the array value.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1037
      Register  rsi_array       = rsi;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1038
      Register  rdx_array_klass = rdx_temp;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1039
      BasicType elem_type       = T_OBJECT;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1040
      int       length_offset   = arrayOopDesc::length_offset_in_bytes();
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1041
      int       elem0_offset    = arrayOopDesc::base_offset_in_bytes(elem_type);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1042
      __ movptr(rsi_array, vmarg);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1043
      Label skip_array_check;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1044
      if (length_constant == 0) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1045
        __ testptr(rsi_array, rsi_array);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1046
        __ jcc(Assembler::zero, skip_array_check);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1047
      }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1048
      __ null_check(rsi_array, oopDesc::klass_offset_in_bytes());
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1049
      __ load_klass(rdx_array_klass, rsi_array);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1050
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1051
      // Check the array type.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1052
      Register rbx_klass = rbx_temp;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1053
      __ movptr(rbx_klass, rcx_amh_argument); // this is a Class object!
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1054
      __ movptr(rbx_klass, Address(rbx_klass, java_lang_Class::klass_offset_in_bytes()));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1055
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1056
      Label ok_array_klass, bad_array_klass, bad_array_length;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1057
      __ check_klass_subtype(rdx_array_klass, rbx_klass, rdi, ok_array_klass);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1058
      // If we get here, the type check failed!
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1059
      __ jmp(bad_array_klass);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1060
      __ bind(ok_array_klass);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1061
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1062
      // Check length.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1063
      if (length_constant >= 0) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1064
        __ cmpl(Address(rsi_array, length_offset), length_constant);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1065
      } else {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1066
        Register rbx_vminfo = rbx_temp;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1067
        __ movl(rbx_vminfo, rcx_amh_conversion);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1068
        assert(CONV_VMINFO_SHIFT == 0, "preshifted");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1069
        __ andl(rbx_vminfo, CONV_VMINFO_MASK);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1070
        __ cmpl(rbx_vminfo, Address(rsi_array, length_offset));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1071
      }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1072
      __ jcc(Assembler::notEqual, bad_array_length);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1073
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1074
      Register rdx_argslot_limit = rdx_temp;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1075
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1076
      // Array length checks out.  Now insert any required stack slots.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1077
      if (length_constant == -1) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1078
        // Form a pointer to the end of the affected region.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1079
        __ lea(rdx_argslot_limit, Address(rax_argslot, Interpreter::stackElementSize()));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1080
        // 'stack_move' is negative number of words to insert
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1081
        Register rdi_stack_move = rdi;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1082
        __ movl(rdi_stack_move, rcx_amh_conversion);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1083
        __ sarl(rdi_stack_move, CONV_STACK_MOVE_SHIFT);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1084
        Register rsi_temp = rsi_array;  // spill this
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1085
        insert_arg_slots(_masm, rdi_stack_move, -1,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1086
                         rax_argslot, rbx_temp, rsi_temp);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1087
        // reload the array (since rsi was killed)
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1088
        __ movptr(rsi_array, vmarg);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1089
      } else if (length_constant > 1) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1090
        int arg_mask = 0;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1091
        int new_slots = (length_constant - 1);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1092
        for (int i = 0; i < new_slots; i++) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1093
          arg_mask <<= 1;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1094
          arg_mask |= _INSERT_REF_MASK;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1095
        }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1096
        insert_arg_slots(_masm, new_slots * stack_move_unit(), arg_mask,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1097
                         rax_argslot, rbx_temp, rdx_temp);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1098
      } else if (length_constant == 1) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1099
        // no stack resizing required
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1100
      } else if (length_constant == 0) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1101
        remove_arg_slots(_masm, -stack_move_unit(),
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1102
                         rax_argslot, rbx_temp, rdx_temp);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1103
      }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1104
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1105
      // Copy from the array to the new slots.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1106
      // Note: Stack change code preserves integrity of rax_argslot pointer.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1107
      // So even after slot insertions, rax_argslot still points to first argument.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1108
      if (length_constant == -1) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1109
        // [rax_argslot, rdx_argslot_limit) is the area we are inserting into.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1110
        Register rsi_source = rsi_array;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1111
        __ lea(rsi_source, Address(rsi_array, elem0_offset));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1112
        Label loop;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1113
        __ bind(loop);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1114
        __ movptr(rbx_temp, Address(rsi_source, 0));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1115
        __ movptr(Address(rax_argslot, 0), rbx_temp);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1116
        __ addptr(rsi_source, type2aelembytes(elem_type));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1117
        if (TaggedStackInterpreter) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1118
          __ movptr(Address(rax_argslot, tag_offset),
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1119
                    frame::tag_for_basic_type(elem_type));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1120
        }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1121
        __ addptr(rax_argslot, Interpreter::stackElementSize());
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1122
        __ cmpptr(rax_argslot, rdx_argslot_limit);
4564
55dfb20908d0 6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents: 4562
diff changeset
  1123
        __ jccb(Assembler::less, loop);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1124
      } else if (length_constant == 0) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1125
        __ bind(skip_array_check);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1126
        // nothing to copy
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1127
      } else {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1128
        int elem_offset = elem0_offset;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1129
        int slot_offset = 0;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1130
        for (int index = 0; index < length_constant; index++) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1131
          __ movptr(rbx_temp, Address(rsi_array, elem_offset));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1132
          __ movptr(Address(rax_argslot, slot_offset), rbx_temp);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1133
          elem_offset += type2aelembytes(elem_type);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1134
          if (TaggedStackInterpreter) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1135
            __ movptr(Address(rax_argslot, slot_offset + tag_offset),
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1136
                      frame::tag_for_basic_type(elem_type));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1137
          }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1138
          slot_offset += Interpreter::stackElementSize();
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1139
        }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1140
      }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1141
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1142
      // Arguments are spread.  Move to next method handle.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1143
      UNPUSH_RSI_RDI;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1144
      __ movptr(rcx_recv, rcx_mh_vmtarget);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1145
      __ jump_to_method_handle_entry(rcx_recv, rdx_temp);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1146
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1147
      __ bind(bad_array_klass);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1148
      UNPUSH_RSI_RDI;
4094
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
  1149
      __ pushptr(Address(rdx_array_klass, java_mirror_offset)); // required type
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
  1150
      __ pushptr(vmarg);                // bad array
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
  1151
      __ push((int)Bytecodes::_aaload); // who is complaining?
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
  1152
      __ jump(ExternalAddress(from_interpreted_entry(_raise_exception)));
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1153
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1154
      __ bind(bad_array_length);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1155
      UNPUSH_RSI_RDI;
4094
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
  1156
      __ push(rcx_recv);        // AMH requiring a certain length
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
  1157
      __ pushptr(vmarg);        // bad array
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
  1158
      __ push((int)Bytecodes::_arraylength); // who is complaining?
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 3262
diff changeset
  1159
      __ jump(ExternalAddress(from_interpreted_entry(_raise_exception)));
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1160
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1161
#undef UNPUSH_RSI_RDI
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1162
    }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1163
    break;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1164
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1165
  case _adapter_flyby:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1166
  case _adapter_ricochet:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1167
    __ unimplemented(entry_name(ek)); // %%% FIXME: NYI
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1168
    break;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1169
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1170
  default:  ShouldNotReachHere();
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1171
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1172
  __ hlt();
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1173
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1174
  address me_cookie = MethodHandleEntry::start_compiled_entry(_masm, interp_entry);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1175
  __ unimplemented(entry_name(ek)); // %%% FIXME: NYI
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1176
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1177
  init_entry(ek, MethodHandleEntry::finish_compiled_entry(_masm, me_cookie));
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
  1178
}