methodHandles_sparc.cpp 39.3 KB
Newer Older
1
/*
2
 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
19 20 21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
22 23 24
 *
 */

25 26 27 28
#include "precompiled.hpp"
#include "interpreter/interpreter.hpp"
#include "memory/allocation.inline.hpp"
#include "prims/methodHandles.hpp"
29 30 31

#define __ _masm->

32 33 34 35 36 37 38 39
#ifdef PRODUCT
#define BLOCK_COMMENT(str) /* nothing */
#else
#define BLOCK_COMMENT(str) __ block_comment(str)
#endif

#define BIND(label) bind(label); BLOCK_COMMENT(#label ":")

40 41
address MethodHandleEntry::start_compiled_entry(MacroAssembler* _masm,
                                                address interpreted_entry) {
T
twisti 已提交
42 43 44
  // Just before the actual machine code entry point, allocate space
  // for a MethodHandleEntry::Data record, so that we can manage everything
  // from one base pointer.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
  __ align(wordSize);
  address target = __ pc() + sizeof(Data);
  while (__ pc() < target) {
    __ nop();
    __ align(wordSize);
  }

  MethodHandleEntry* me = (MethodHandleEntry*) __ pc();
  me->set_end_address(__ pc());         // set a temporary end_address
  me->set_from_interpreted_entry(interpreted_entry);
  me->set_type_checking_entry(NULL);

  return (address) me;
}

MethodHandleEntry* MethodHandleEntry::finish_compiled_entry(MacroAssembler* _masm,
                                                address start_addr) {
  MethodHandleEntry* me = (MethodHandleEntry*) start_addr;
  assert(me->end_address() == start_addr, "valid ME");

  // Fill in the real end_address:
  __ align(wordSize);
  me->set_end_address(__ pc());

  return me;
}


// Code generation
address MethodHandles::generate_method_handle_interpreter_entry(MacroAssembler* _masm) {
75
  // I5_savedSP/O5_savedSP: sender SP (must preserve)
T
twisti 已提交
76
  // G4 (Gargs): incoming argument list (must preserve)
77
  // G5_method:  invoke methodOop
T
twisti 已提交
78
  // G3_method_handle: receiver method handle (must load from sp[MethodTypeForm.vmslots])
79 80
  // O0, O1, O2, O3, O4: garbage temps, blown away
  Register O0_mtype   = O0;
T
twisti 已提交
81
  Register O1_scratch = O1;
82 83
  Register O2_scratch = O2;
  Register O3_scratch = O3;
84
  Register O4_argslot = O4;
85
  Register O4_argbase = O4;
T
twisti 已提交
86 87 88 89

  // emit WrongMethodType path first, to enable back-branch from main path
  Label wrong_method_type;
  __ bind(wrong_method_type);
90 91 92 93 94 95
  Label invoke_generic_slow_path;
  assert(methodOopDesc::intrinsic_id_size_in_bytes() == sizeof(u1), "");;
  __ ldub(Address(G5_method, methodOopDesc::intrinsic_id_offset_in_bytes()), O1_scratch);
  __ cmp(O1_scratch, (int) vmIntrinsics::_invokeExact);
  __ brx(Assembler::notEqual, false, Assembler::pt, invoke_generic_slow_path);
  __ delayed()->nop();
96
  __ mov(O0_mtype, G5_method_type);  // required by throw_WrongMethodType
97
  // mov(G3_method_handle, G3_method_handle);  // already in this register
T
twisti 已提交
98 99 100 101 102 103 104
  __ jump_to(AddressLiteral(Interpreter::throw_WrongMethodType_entry()), O1_scratch);
  __ delayed()->nop();

  // here's where control starts out:
  __ align(CodeEntryAlignment);
  address entry_point = __ pc();

105
  // fetch the MethodType from the method handle
T
twisti 已提交
106 107 108
  {
    Register tem = G5_method;
    for (jint* pchase = methodOopDesc::method_type_offsets_chain(); (*pchase) != -1; pchase++) {
109 110
      __ ld_ptr(Address(tem, *pchase), O0_mtype);
      tem = O0_mtype;          // in case there is another indirection
T
twisti 已提交
111 112 113 114
    }
  }

  // given the MethodType, find out where the MH argument is buried
115 116 117
  __ load_heap_oop(Address(O0_mtype,   __ delayed_value(java_dyn_MethodType::form_offset_in_bytes,        O1_scratch)), O4_argslot);
  __ ldsw(         Address(O4_argslot, __ delayed_value(java_dyn_MethodTypeForm::vmslots_offset_in_bytes, O1_scratch)), O4_argslot);
  __ add(Gargs, __ argument_offset(O4_argslot, 1), O4_argbase);
118 119 120 121 122
  // Note: argument_address uses its input as a scratch register!
  __ ld_ptr(Address(O4_argbase, -Interpreter::stackElementSize), G3_method_handle);

  trace_method_handle(_masm, "invokeExact");

123
  __ check_method_handle_type(O0_mtype, G3_method_handle, O1_scratch, wrong_method_type);
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
  __ jump_to_method_handle_entry(G3_method_handle, O1_scratch);

  // for invokeGeneric (only), apply argument and result conversions on the fly
  __ bind(invoke_generic_slow_path);
#ifdef ASSERT
  { Label L;
    __ ldub(Address(G5_method, methodOopDesc::intrinsic_id_offset_in_bytes()), O1_scratch);
    __ cmp(O1_scratch, (int) vmIntrinsics::_invokeGeneric);
    __ brx(Assembler::equal, false, Assembler::pt, L);
    __ delayed()->nop();
    __ stop("bad methodOop::intrinsic_id");
    __ bind(L);
  }
#endif //ASSERT

  // make room on the stack for another pointer:
140
  insert_arg_slots(_masm, 2 * stack_move_unit(), _INSERT_REF_MASK, O4_argbase, O1_scratch, O2_scratch, O3_scratch);
141 142 143
  // load up an adapter from the calling type (Java weaves this)
  Register O2_form    = O2_scratch;
  Register O3_adapter = O3_scratch;
144
  __ load_heap_oop(Address(O0_mtype, __ delayed_value(java_dyn_MethodType::form_offset_in_bytes,               O1_scratch)), O2_form);
145 146
  // load_heap_oop(Address(O2_form,  __ delayed_value(java_dyn_MethodTypeForm::genericInvoker_offset_in_bytes, O1_scratch)), O3_adapter);
  // deal with old JDK versions:
147
  __ add(          Address(O2_form,  __ delayed_value(java_dyn_MethodTypeForm::genericInvoker_offset_in_bytes, O1_scratch)), O3_adapter);
148 149 150 151
  __ cmp(O3_adapter, O2_form);
  Label sorry_no_invoke_generic;
  __ brx(Assembler::lessUnsigned, false, Assembler::pn, sorry_no_invoke_generic);
  __ delayed()->nop();
T
twisti 已提交
152

153 154 155 156 157 158 159 160
  __ load_heap_oop(Address(O3_adapter, 0), O3_adapter);
  __ tst(O3_adapter);
  __ brx(Assembler::zero, false, Assembler::pn, sorry_no_invoke_generic);
  __ delayed()->nop();
  __ st_ptr(O3_adapter, Address(O4_argbase, 1 * Interpreter::stackElementSize));
  // As a trusted first argument, pass the type being called, so the adapter knows
  // the actual types of the arguments and return values.
  // (Generic invokers are shared among form-families of method-type.)
161
  __ st_ptr(O0_mtype,   Address(O4_argbase, 0 * Interpreter::stackElementSize));
162 163 164
  // FIXME: assert that O3_adapter is of the right method-type.
  __ mov(O3_adapter, G3_method_handle);
  trace_method_handle(_masm, "invokeGeneric");
T
twisti 已提交
165 166
  __ jump_to_method_handle_entry(G3_method_handle, O1_scratch);

167
  __ bind(sorry_no_invoke_generic); // no invokeGeneric implementation available!
168
  __ mov(O0_mtype, G5_method_type);  // required by throw_WrongMethodType
169 170 171 172
  // mov(G3_method_handle, G3_method_handle);  // already in this register
  __ jump_to(AddressLiteral(Interpreter::throw_WrongMethodType_entry()), O1_scratch);
  __ delayed()->nop();

T
twisti 已提交
173 174 175 176 177 178 179 180
  return entry_point;
}


#ifdef ASSERT
static void verify_argslot(MacroAssembler* _masm, Register argslot_reg, Register temp_reg, const char* error_message) {
  // Verify that argslot lies within (Gargs, FP].
  Label L_ok, L_bad;
181
  BLOCK_COMMENT("{ verify_argslot");
T
twisti 已提交
182 183 184 185 186 187 188 189 190 191 192 193 194 195
#ifdef _LP64
  __ add(FP, STACK_BIAS, temp_reg);
  __ cmp(argslot_reg, temp_reg);
#else
  __ cmp(argslot_reg, FP);
#endif
  __ brx(Assembler::greaterUnsigned, false, Assembler::pn, L_bad);
  __ delayed()->nop();
  __ cmp(Gargs, argslot_reg);
  __ brx(Assembler::lessEqualUnsigned, false, Assembler::pt, L_ok);
  __ delayed()->nop();
  __ bind(L_bad);
  __ stop(error_message);
  __ bind(L_ok);
196
  BLOCK_COMMENT("} verify_argslot");
T
twisti 已提交
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252
}
#endif


// Helper to insert argument slots into the stack.
// arg_slots must be a multiple of stack_move_unit() and <= 0
void MethodHandles::insert_arg_slots(MacroAssembler* _masm,
                                     RegisterOrConstant arg_slots,
                                     int arg_mask,
                                     Register argslot_reg,
                                     Register temp_reg, Register temp2_reg, Register temp3_reg) {
  assert(temp3_reg != noreg, "temp3 required");
  assert_different_registers(argslot_reg, temp_reg, temp2_reg, temp3_reg,
                             (!arg_slots.is_register() ? Gargs : arg_slots.as_register()));

#ifdef ASSERT
  verify_argslot(_masm, argslot_reg, temp_reg, "insertion point must fall within current frame");
  if (arg_slots.is_register()) {
    Label L_ok, L_bad;
    __ cmp(arg_slots.as_register(), (int32_t) NULL_WORD);
    __ br(Assembler::greater, false, Assembler::pn, L_bad);
    __ delayed()->nop();
    __ btst(-stack_move_unit() - 1, arg_slots.as_register());
    __ br(Assembler::zero, false, Assembler::pt, L_ok);
    __ delayed()->nop();
    __ bind(L_bad);
    __ stop("assert arg_slots <= 0 and clear low bits");
    __ bind(L_ok);
  } else {
    assert(arg_slots.as_constant() <= 0, "");
    assert(arg_slots.as_constant() % -stack_move_unit() == 0, "");
  }
#endif // ASSERT

#ifdef _LP64
  if (arg_slots.is_register()) {
    // Was arg_slots register loaded as signed int?
    Label L_ok;
    __ sll(arg_slots.as_register(), BitsPerInt, temp_reg);
    __ sra(temp_reg, BitsPerInt, temp_reg);
    __ cmp(arg_slots.as_register(), temp_reg);
    __ br(Assembler::equal, false, Assembler::pt, L_ok);
    __ delayed()->nop();
    __ stop("arg_slots register not loaded as signed int");
    __ bind(L_ok);
  }
#endif

  // Make space on the stack for the inserted argument(s).
  // Then pull down everything shallower than argslot_reg.
  // The stacked return address gets pulled down with everything else.
  // That is, copy [sp, argslot) downward by -size words.  In pseudo-code:
  //   sp -= size;
  //   for (temp = sp + size; temp < argslot; temp++)
  //     temp[-size] = temp[0]
  //   argslot -= size;
253
  BLOCK_COMMENT("insert_arg_slots {");
T
twisti 已提交
254 255 256 257 258 259 260 261 262 263 264 265
  RegisterOrConstant offset = __ regcon_sll_ptr(arg_slots, LogBytesPerWord, temp3_reg);

  // Keep the stack pointer 2*wordSize aligned.
  const int TwoWordAlignmentMask = right_n_bits(LogBytesPerWord + 1);
  RegisterOrConstant masked_offset = __ regcon_andn_ptr(offset, TwoWordAlignmentMask, temp_reg);
  __ add(SP, masked_offset, SP);

  __ mov(Gargs, temp_reg);  // source pointer for copy
  __ add(Gargs, offset, Gargs);

  {
    Label loop;
266
    __ BIND(loop);
T
twisti 已提交
267 268 269 270 271 272 273 274 275 276 277
    // pull one word down each time through the loop
    __ ld_ptr(Address(temp_reg, 0), temp2_reg);
    __ st_ptr(temp2_reg, Address(temp_reg, offset));
    __ add(temp_reg, wordSize, temp_reg);
    __ cmp(temp_reg, argslot_reg);
    __ brx(Assembler::less, false, Assembler::pt, loop);
    __ delayed()->nop();  // FILLME
  }

  // Now move the argslot down, to point to the opened-up space.
  __ add(argslot_reg, offset, argslot_reg);
278
  BLOCK_COMMENT("} insert_arg_slots");
T
twisti 已提交
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314
}


// Helper to remove argument slots from the stack.
// arg_slots must be a multiple of stack_move_unit() and >= 0
void MethodHandles::remove_arg_slots(MacroAssembler* _masm,
                                     RegisterOrConstant arg_slots,
                                     Register argslot_reg,
                                     Register temp_reg, Register temp2_reg, Register temp3_reg) {
  assert(temp3_reg != noreg, "temp3 required");
  assert_different_registers(argslot_reg, temp_reg, temp2_reg, temp3_reg,
                             (!arg_slots.is_register() ? Gargs : arg_slots.as_register()));

  RegisterOrConstant offset = __ regcon_sll_ptr(arg_slots, LogBytesPerWord, temp3_reg);

#ifdef ASSERT
  // Verify that [argslot..argslot+size) lies within (Gargs, FP).
  __ add(argslot_reg, offset, temp2_reg);
  verify_argslot(_masm, temp2_reg, temp_reg, "deleted argument(s) must fall within current frame");
  if (arg_slots.is_register()) {
    Label L_ok, L_bad;
    __ cmp(arg_slots.as_register(), (int32_t) NULL_WORD);
    __ br(Assembler::less, false, Assembler::pn, L_bad);
    __ delayed()->nop();
    __ btst(-stack_move_unit() - 1, arg_slots.as_register());
    __ br(Assembler::zero, false, Assembler::pt, L_ok);
    __ delayed()->nop();
    __ bind(L_bad);
    __ stop("assert arg_slots >= 0 and clear low bits");
    __ bind(L_ok);
  } else {
    assert(arg_slots.as_constant() >= 0, "");
    assert(arg_slots.as_constant() % -stack_move_unit() == 0, "");
  }
#endif // ASSERT

315
  BLOCK_COMMENT("remove_arg_slots {");
T
twisti 已提交
316 317 318 319 320 321 322 323 324 325 326
  // Pull up everything shallower than argslot.
  // Then remove the excess space on the stack.
  // The stacked return address gets pulled up with everything else.
  // That is, copy [sp, argslot) upward by size words.  In pseudo-code:
  //   for (temp = argslot-1; temp >= sp; --temp)
  //     temp[size] = temp[0]
  //   argslot += size;
  //   sp += size;
  __ sub(argslot_reg, wordSize, temp_reg);  // source pointer for copy
  {
    Label loop;
327
    __ BIND(loop);
T
twisti 已提交
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345
    // pull one word up each time through the loop
    __ ld_ptr(Address(temp_reg, 0), temp2_reg);
    __ st_ptr(temp2_reg, Address(temp_reg, offset));
    __ sub(temp_reg, wordSize, temp_reg);
    __ cmp(temp_reg, Gargs);
    __ brx(Assembler::greaterEqual, false, Assembler::pt, loop);
    __ delayed()->nop();  // FILLME
  }

  // Now move the argslot up, to point to the just-copied block.
  __ add(Gargs, offset, Gargs);
  // And adjust the argslot address to point at the deletion point.
  __ add(argslot_reg, offset, argslot_reg);

  // Keep the stack pointer 2*wordSize aligned.
  const int TwoWordAlignmentMask = right_n_bits(LogBytesPerWord + 1);
  RegisterOrConstant masked_offset = __ regcon_andn_ptr(offset, TwoWordAlignmentMask, temp_reg);
  __ add(SP, masked_offset, SP);
346
  BLOCK_COMMENT("} remove_arg_slots");
347 348
}

T
twisti 已提交
349 350 351 352

#ifndef PRODUCT
extern "C" void print_method_handle(oop mh);
void trace_method_handle_stub(const char* adaptername,
353
                              oopDesc* mh) {
T
twisti 已提交
354 355 356
  printf("MH %s mh="INTPTR_FORMAT"\n", adaptername, (intptr_t) mh);
  print_method_handle(mh);
}
357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374
void MethodHandles::trace_method_handle(MacroAssembler* _masm, const char* adaptername) {
  if (!TraceMethodHandles)  return;
  BLOCK_COMMENT("trace_method_handle {");
  // save: Gargs, O5_savedSP
  __ save_frame(16);
  __ set((intptr_t) adaptername, O0);
  __ mov(G3_method_handle, O1);
  __ mov(G3_method_handle, L3);
  __ mov(Gargs, L4);
  __ mov(G5_method_type, L5);
  __ call_VM_leaf(L7, CAST_FROM_FN_PTR(address, trace_method_handle_stub));

  __ mov(L3, G3_method_handle);
  __ mov(L4, Gargs);
  __ mov(L5, G5_method_type);
  __ restore();
  BLOCK_COMMENT("} trace_method_handle");
}
T
twisti 已提交
375 376
#endif // PRODUCT

377 378 379 380 381 382 383 384 385 386 387 388 389 390 391
// which conversion op types are implemented here?
int MethodHandles::adapter_conversion_ops_supported_mask() {
  return ((1<<sun_dyn_AdapterMethodHandle::OP_RETYPE_ONLY)
         |(1<<sun_dyn_AdapterMethodHandle::OP_RETYPE_RAW)
         |(1<<sun_dyn_AdapterMethodHandle::OP_CHECK_CAST)
         |(1<<sun_dyn_AdapterMethodHandle::OP_PRIM_TO_PRIM)
         |(1<<sun_dyn_AdapterMethodHandle::OP_REF_TO_PRIM)
         |(1<<sun_dyn_AdapterMethodHandle::OP_SWAP_ARGS)
         |(1<<sun_dyn_AdapterMethodHandle::OP_ROT_ARGS)
         |(1<<sun_dyn_AdapterMethodHandle::OP_DUP_ARGS)
         |(1<<sun_dyn_AdapterMethodHandle::OP_DROP_ARGS)
         //|(1<<sun_dyn_AdapterMethodHandle::OP_SPREAD_ARGS) //BUG!
         );
  // FIXME: MethodHandlesTest gets a crash if we enable OP_SPREAD_ARGS.
}
T
twisti 已提交
392 393 394 395

//------------------------------------------------------------------------------
// MethodHandles::generate_method_handle_stub
//
396 397
// Generate an "entry" field for a method handle.
// This determines how the method handle will respond to calls.
398
void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHandles::EntryKind ek, TRAPS) {
T
twisti 已提交
399 400 401 402 403 404
  // Here is the register state during an interpreted call,
  // as set up by generate_method_handle_interpreter_entry():
  // - G5: garbage temp (was MethodHandle.invoke methodOop, unused)
  // - G3: receiver method handle
  // - O5_savedSP: sender SP (must preserve)

405 406 407 408 409 410 411 412 413 414
  const Register O0_argslot = O0;
  const Register O1_scratch = O1;
  const Register O2_scratch = O2;
  const Register O3_scratch = O3;
  const Register G5_index   = G5;

  // Argument registers for _raise_exception.
  const Register O0_code     = O0;
  const Register O1_actual   = O1;
  const Register O2_required = O2;
T
twisti 已提交
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440

  guarantee(java_dyn_MethodHandle::vmentry_offset_in_bytes() != 0, "must have offsets");

  // Some handy addresses:
  Address G5_method_fie(    G5_method,        in_bytes(methodOopDesc::from_interpreted_offset()));

  Address G3_mh_vmtarget(   G3_method_handle, java_dyn_MethodHandle::vmtarget_offset_in_bytes());

  Address G3_dmh_vmindex(   G3_method_handle, sun_dyn_DirectMethodHandle::vmindex_offset_in_bytes());

  Address G3_bmh_vmargslot( G3_method_handle, sun_dyn_BoundMethodHandle::vmargslot_offset_in_bytes());
  Address G3_bmh_argument(  G3_method_handle, sun_dyn_BoundMethodHandle::argument_offset_in_bytes());

  Address G3_amh_vmargslot( G3_method_handle, sun_dyn_AdapterMethodHandle::vmargslot_offset_in_bytes());
  Address G3_amh_argument ( G3_method_handle, sun_dyn_AdapterMethodHandle::argument_offset_in_bytes());
  Address G3_amh_conversion(G3_method_handle, sun_dyn_AdapterMethodHandle::conversion_offset_in_bytes());

  const int java_mirror_offset = klassOopDesc::klass_part_offset_in_bytes() + Klass::java_mirror_offset_in_bytes();

  if (have_entry(ek)) {
    __ nop();  // empty stubs make SG sick
    return;
  }

  address interp_entry = __ pc();

441
  trace_method_handle(_masm, entry_name(ek));
T
twisti 已提交
442 443 444 445 446

  switch ((int) ek) {
  case _raise_exception:
    {
      // Not a real MH entry, but rather shared code for raising an
447 448 449 450 451
      // exception.  Since we use a C2I adapter to set up the
      // interpreter state, arguments are expected in compiler
      // argument registers.
      methodHandle mh(raise_exception_method());
      address c2i_entry = methodOopDesc::make_adapters(mh, CATCH);
T
twisti 已提交
452 453 454

      __ mov(O5_savedSP, SP);  // Cut the stack back to where the caller started.

455
      Label L_no_method;
T
twisti 已提交
456 457 458 459
      // FIXME: fill in _raise_exception_method with a suitable sun.dyn method
      __ set(AddressLiteral((address) &_raise_exception_method), G5_method);
      __ ld_ptr(Address(G5_method, 0), G5_method);
      __ tst(G5_method);
460
      __ brx(Assembler::zero, false, Assembler::pn, L_no_method);
T
twisti 已提交
461 462
      __ delayed()->nop();

463
      const int jobject_oop_offset = 0;
T
twisti 已提交
464 465
      __ ld_ptr(Address(G5_method, jobject_oop_offset), G5_method);
      __ tst(G5_method);
466
      __ brx(Assembler::zero, false, Assembler::pn, L_no_method);
T
twisti 已提交
467 468 469
      __ delayed()->nop();

      __ verify_oop(G5_method);
470
      __ jump_to(AddressLiteral(c2i_entry), O3_scratch);
T
twisti 已提交
471 472 473 474
      __ delayed()->nop();

      // If we get here, the Java runtime did not do its job of creating the exception.
      // Do something that is at least causes a valid throw from the interpreter.
475 476
      __ bind(L_no_method);
      __ unimplemented("call throw_WrongMethodType_entry");
T
twisti 已提交
477 478 479 480 481 482
    }
    break;

  case _invokestatic_mh:
  case _invokespecial_mh:
    {
483
      __ load_heap_oop(G3_mh_vmtarget, G5_method);  // target is a methodOop
T
twisti 已提交
484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537
      __ verify_oop(G5_method);
      // Same as TemplateTable::invokestatic or invokespecial,
      // minus the CP setup and profiling:
      if (ek == _invokespecial_mh) {
        // Must load & check the first argument before entering the target method.
        __ load_method_handle_vmslots(O0_argslot, G3_method_handle, O1_scratch);
        __ ld_ptr(__ argument_address(O0_argslot), G3_method_handle);
        __ null_check(G3_method_handle);
        __ verify_oop(G3_method_handle);
      }
      __ jump_indirect_to(G5_method_fie, O1_scratch);
      __ delayed()->nop();
    }
    break;

  case _invokevirtual_mh:
    {
      // Same as TemplateTable::invokevirtual,
      // minus the CP setup and profiling:

      // Pick out the vtable index and receiver offset from the MH,
      // and then we can discard it:
      __ load_method_handle_vmslots(O0_argslot, G3_method_handle, O1_scratch);
      __ ldsw(G3_dmh_vmindex, G5_index);
      // Note:  The verifier allows us to ignore G3_mh_vmtarget.
      __ ld_ptr(__ argument_address(O0_argslot, -1), G3_method_handle);
      __ null_check(G3_method_handle, oopDesc::klass_offset_in_bytes());

      // Get receiver klass:
      Register O0_klass = O0_argslot;
      __ load_klass(G3_method_handle, O0_klass);
      __ verify_oop(O0_klass);

      // Get target methodOop & entry point:
      const int base = instanceKlass::vtable_start_offset() * wordSize;
      assert(vtableEntry::size() * wordSize == wordSize, "adjust the scaling in the code below");

      __ sll_ptr(G5_index, LogBytesPerWord, G5_index);
      __ add(O0_klass, G5_index, O0_klass);
      Address vtable_entry_addr(O0_klass, base + vtableEntry::method_offset_in_bytes());
      __ ld_ptr(vtable_entry_addr, G5_method);

      __ verify_oop(G5_method);
      __ jump_indirect_to(G5_method_fie, O1_scratch);
      __ delayed()->nop();
    }
    break;

  case _invokeinterface_mh:
    {
      // Same as TemplateTable::invokeinterface,
      // minus the CP setup and profiling:
      __ load_method_handle_vmslots(O0_argslot, G3_method_handle, O1_scratch);
      Register O1_intf  = O1_scratch;
538
      __ load_heap_oop(G3_mh_vmtarget, O1_intf);
T
twisti 已提交
539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565
      __ ldsw(G3_dmh_vmindex, G5_index);
      __ ld_ptr(__ argument_address(O0_argslot, -1), G3_method_handle);
      __ null_check(G3_method_handle, oopDesc::klass_offset_in_bytes());

      // Get receiver klass:
      Register O0_klass = O0_argslot;
      __ load_klass(G3_method_handle, O0_klass);
      __ verify_oop(O0_klass);

      // Get interface:
      Label no_such_interface;
      __ verify_oop(O1_intf);
      __ lookup_interface_method(O0_klass, O1_intf,
                                 // Note: next two args must be the same:
                                 G5_index, G5_method,
                                 O2_scratch,
                                 O3_scratch,
                                 no_such_interface);

      __ verify_oop(G5_method);
      __ jump_indirect_to(G5_method_fie, O1_scratch);
      __ delayed()->nop();

      __ bind(no_such_interface);
      // Throw an exception.
      // For historical reasons, it will be IncompatibleClassChangeError.
      __ unimplemented("not tested yet");
566 567 568 569
      __ ld_ptr(Address(O1_intf, java_mirror_offset), O2_required);  // required interface
      __ mov(   O0_klass,                             O1_actual);    // bad receiver
      __ jump_to(AddressLiteral(from_interpreted_entry(_raise_exception)), O3_scratch);
      __ delayed()->mov(Bytecodes::_invokeinterface,  O0_code);      // who is complaining?
T
twisti 已提交
570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592
    }
    break;

  case _bound_ref_mh:
  case _bound_int_mh:
  case _bound_long_mh:
  case _bound_ref_direct_mh:
  case _bound_int_direct_mh:
  case _bound_long_direct_mh:
    {
      const bool direct_to_method = (ek >= _bound_ref_direct_mh);
      BasicType arg_type  = T_ILLEGAL;
      int       arg_mask  = _INSERT_NO_MASK;
      int       arg_slots = -1;
      get_ek_bound_mh_info(ek, arg_type, arg_mask, arg_slots);

      // Make room for the new argument:
      __ ldsw(G3_bmh_vmargslot, O0_argslot);
      __ add(Gargs, __ argument_offset(O0_argslot), O0_argslot);

      insert_arg_slots(_masm, arg_slots * stack_move_unit(), arg_mask, O0_argslot, O1_scratch, O2_scratch, G5_index);

      // Store bound argument into the new stack slot:
593
      __ load_heap_oop(G3_bmh_argument, O1_scratch);
T
twisti 已提交
594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610
      if (arg_type == T_OBJECT) {
        __ st_ptr(O1_scratch, Address(O0_argslot, 0));
      } else {
        Address prim_value_addr(O1_scratch, java_lang_boxing_object::value_offset_in_bytes(arg_type));
        __ load_sized_value(prim_value_addr, O2_scratch, type2aelembytes(arg_type), is_signed_subword_type(arg_type));
        if (arg_slots == 2) {
          __ unimplemented("not yet tested");
#ifndef _LP64
          __ signx(O2_scratch, O3_scratch);  // Sign extend
#endif
          __ st_long(O2_scratch, Address(O0_argslot, 0));  // Uses O2/O3 on !_LP64
        } else {
          __ st_ptr( O2_scratch, Address(O0_argslot, 0));
        }
      }

      if (direct_to_method) {
611
        __ load_heap_oop(G3_mh_vmtarget, G5_method);  // target is a methodOop
T
twisti 已提交
612 613 614 615
        __ verify_oop(G5_method);
        __ jump_indirect_to(G5_method_fie, O1_scratch);
        __ delayed()->nop();
      } else {
616
        __ load_heap_oop(G3_mh_vmtarget, G3_method_handle);  // target is a methodOop
T
twisti 已提交
617 618 619 620 621 622 623 624 625
        __ verify_oop(G3_method_handle);
        __ jump_to_method_handle_entry(G3_method_handle, O1_scratch);
      }
    }
    break;

  case _adapter_retype_only:
  case _adapter_retype_raw:
    // Immediately jump to the next MH layer:
626
    __ load_heap_oop(G3_mh_vmtarget, G3_method_handle);
T
twisti 已提交
627 628 629 630 631 632 633 634 635 636 637 638 639 640 641
    __ jump_to_method_handle_entry(G3_method_handle, O1_scratch);
    // This is OK when all parameter types widen.
    // It is also OK when a return type narrows.
    break;

  case _adapter_check_cast:
    {
      // Temps:
      Register G5_klass = G5_index;  // Interesting AMH data.

      // Check a reference argument before jumping to the next layer of MH:
      __ ldsw(G3_amh_vmargslot, O0_argslot);
      Address vmarg = __ argument_address(O0_argslot);

      // What class are we casting to?
642 643
      __ load_heap_oop(G3_amh_argument, G5_klass);  // This is a Class object!
      __ load_heap_oop(Address(G5_klass, java_lang_Class::klass_offset_in_bytes()), G5_klass);
T
twisti 已提交
644 645 646 647 648 649 650 651 652 653 654 655 656 657 658

      Label done;
      __ ld_ptr(vmarg, O1_scratch);
      __ tst(O1_scratch);
      __ brx(Assembler::zero, false, Assembler::pn, done);  // No cast if null.
      __ delayed()->nop();
      __ load_klass(O1_scratch, O1_scratch);

      // Live at this point:
      // - G5_klass        :  klass required by the target method
      // - O1_scratch      :  argument klass to test
      // - G3_method_handle:  adapter method handle
      __ check_klass_subtype(O1_scratch, G5_klass, O0_argslot, O2_scratch, done);

      // If we get here, the type check failed!
659 660 661 662
      __ load_heap_oop(G3_amh_argument,        O2_required);  // required class
      __ ld_ptr(       vmarg,                  O1_actual);    // bad object
      __ jump_to(AddressLiteral(from_interpreted_entry(_raise_exception)), O3_scratch);
      __ delayed()->mov(Bytecodes::_checkcast, O0_code);      // who is complaining?
T
twisti 已提交
663 664 665

      __ bind(done);
      // Get the new MH:
666
      __ load_heap_oop(G3_mh_vmtarget, G3_method_handle);
T
twisti 已提交
667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684
      __ jump_to_method_handle_entry(G3_method_handle, O1_scratch);
    }
    break;

  case _adapter_prim_to_prim:
  case _adapter_ref_to_prim:
    // Handled completely by optimized cases.
    __ stop("init_AdapterMethodHandle should not issue this");
    break;

  case _adapter_opt_i2i:        // optimized subcase of adapt_prim_to_prim
//case _adapter_opt_f2i:        // optimized subcase of adapt_prim_to_prim
  case _adapter_opt_l2i:        // optimized subcase of adapt_prim_to_prim
  case _adapter_opt_unboxi:     // optimized subcase of adapt_ref_to_prim
    {
      // Perform an in-place conversion to int or an int subword.
      __ ldsw(G3_amh_vmargslot, O0_argslot);
      Address value;
685
      Address vmarg = __ argument_address(O0_argslot);
T
twisti 已提交
686 687 688 689 690 691
      bool value_left_justified = false;

      switch (ek) {
      case _adapter_opt_i2i:
        value = vmarg;
        break;
692 693 694
      case _adapter_opt_l2i:
        {
          // just delete the extra slot
695 696 697 698 699 700 701 702 703 704
#ifdef _LP64
          // In V9, longs are given 2 64-bit slots in the interpreter, but the
          // data is passed in only 1 slot.
          // Keep the second slot.
          __ add(Gargs, __ argument_offset(O0_argslot, -1), O0_argslot);
          remove_arg_slots(_masm, -stack_move_unit(), O0_argslot, O1_scratch, O2_scratch, O3_scratch);
          value = Address(O0_argslot, 4);  // Get least-significant 32-bit of 64-bit value.
          vmarg = Address(O0_argslot, Interpreter::stackElementSize);
#else
          // Keep the first slot.
705 706
          __ add(Gargs, __ argument_offset(O0_argslot), O0_argslot);
          remove_arg_slots(_masm, -stack_move_unit(), O0_argslot, O1_scratch, O2_scratch, O3_scratch);
707 708 709
          value = Address(O0_argslot, 0);
          vmarg = value;
#endif
710 711
        }
        break;
T
twisti 已提交
712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762
      case _adapter_opt_unboxi:
        {
          // Load the value up from the heap.
          __ ld_ptr(vmarg, O1_scratch);
          int value_offset = java_lang_boxing_object::value_offset_in_bytes(T_INT);
#ifdef ASSERT
          for (int bt = T_BOOLEAN; bt < T_INT; bt++) {
            if (is_subword_type(BasicType(bt)))
              assert(value_offset == java_lang_boxing_object::value_offset_in_bytes(BasicType(bt)), "");
          }
#endif
          __ null_check(O1_scratch, value_offset);
          value = Address(O1_scratch, value_offset);
#ifdef _BIG_ENDIAN
          // Values stored in objects are packed.
          value_left_justified = true;
#endif
        }
        break;
      default:
        ShouldNotReachHere();
      }

      // This check is required on _BIG_ENDIAN
      Register G5_vminfo = G5_index;
      __ ldsw(G3_amh_conversion, G5_vminfo);
      assert(CONV_VMINFO_SHIFT == 0, "preshifted");

      // Original 32-bit vmdata word must be of this form:
      // | MBZ:6 | signBitCount:8 | srcDstTypes:8 | conversionOp:8 |
      __ lduw(value, O1_scratch);
      if (!value_left_justified)
        __ sll(O1_scratch, G5_vminfo, O1_scratch);
      Label zero_extend, done;
      __ btst(CONV_VMINFO_SIGN_FLAG, G5_vminfo);
      __ br(Assembler::zero, false, Assembler::pn, zero_extend);
      __ delayed()->nop();

      // this path is taken for int->byte, int->short
      __ sra(O1_scratch, G5_vminfo, O1_scratch);
      __ ba(false, done);
      __ delayed()->nop();

      __ bind(zero_extend);
      // this is taken for int->char
      __ srl(O1_scratch, G5_vminfo, O1_scratch);

      __ bind(done);
      __ st(O1_scratch, vmarg);

      // Get the new MH:
763
      __ load_heap_oop(G3_mh_vmtarget, G3_method_handle);
T
twisti 已提交
764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780
      __ jump_to_method_handle_entry(G3_method_handle, O1_scratch);
    }
    break;

  case _adapter_opt_i2l:        // optimized subcase of adapt_prim_to_prim
  case _adapter_opt_unboxl:     // optimized subcase of adapt_ref_to_prim
    {
      // Perform an in-place int-to-long or ref-to-long conversion.
      __ ldsw(G3_amh_vmargslot, O0_argslot);

      // On big-endian machine we duplicate the slot and store the MSW
      // in the first slot.
      __ add(Gargs, __ argument_offset(O0_argslot, 1), O0_argslot);

      insert_arg_slots(_masm, stack_move_unit(), _INSERT_INT_MASK, O0_argslot, O1_scratch, O2_scratch, G5_index);

      Address arg_lsw(O0_argslot, 0);
781
      Address arg_msw(O0_argslot, -Interpreter::stackElementSize);
T
twisti 已提交
782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807

      switch (ek) {
      case _adapter_opt_i2l:
        {
          __ ldsw(arg_lsw, O2_scratch);      // Load LSW
#ifndef _LP64
          __ signx(O2_scratch, O3_scratch);  // Sign extend
#endif
          __ st_long(O2_scratch, arg_msw);   // Uses O2/O3 on !_LP64
        }
        break;
      case _adapter_opt_unboxl:
        {
          // Load the value up from the heap.
          __ ld_ptr(arg_lsw, O1_scratch);
          int value_offset = java_lang_boxing_object::value_offset_in_bytes(T_LONG);
          assert(value_offset == java_lang_boxing_object::value_offset_in_bytes(T_DOUBLE), "");
          __ null_check(O1_scratch, value_offset);
          __ ld_long(Address(O1_scratch, value_offset), O2_scratch);  // Uses O2/O3 on !_LP64
          __ st_long(O2_scratch, arg_msw);
        }
        break;
      default:
        ShouldNotReachHere();
      }

808
      __ load_heap_oop(G3_mh_vmtarget, G3_method_handle);
T
twisti 已提交
809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937
      __ jump_to_method_handle_entry(G3_method_handle, O1_scratch);
    }
    break;

  case _adapter_opt_f2d:        // optimized subcase of adapt_prim_to_prim
  case _adapter_opt_d2f:        // optimized subcase of adapt_prim_to_prim
    {
      // perform an in-place floating primitive conversion
      __ unimplemented(entry_name(ek));
    }
    break;

  case _adapter_prim_to_ref:
    __ unimplemented(entry_name(ek)); // %%% FIXME: NYI
    break;

  case _adapter_swap_args:
  case _adapter_rot_args:
    // handled completely by optimized cases
    __ stop("init_AdapterMethodHandle should not issue this");
    break;

  case _adapter_opt_swap_1:
  case _adapter_opt_swap_2:
  case _adapter_opt_rot_1_up:
  case _adapter_opt_rot_1_down:
  case _adapter_opt_rot_2_up:
  case _adapter_opt_rot_2_down:
    {
      int swap_bytes = 0, rotate = 0;
      get_ek_adapter_opt_swap_rot_info(ek, swap_bytes, rotate);

      // 'argslot' is the position of the first argument to swap.
      __ ldsw(G3_amh_vmargslot, O0_argslot);
      __ add(Gargs, __ argument_offset(O0_argslot), O0_argslot);

      // 'vminfo' is the second.
      Register O1_destslot = O1_scratch;
      __ ldsw(G3_amh_conversion, O1_destslot);
      assert(CONV_VMINFO_SHIFT == 0, "preshifted");
      __ and3(O1_destslot, CONV_VMINFO_MASK, O1_destslot);
      __ add(Gargs, __ argument_offset(O1_destslot), O1_destslot);

      if (!rotate) {
        for (int i = 0; i < swap_bytes; i += wordSize) {
          __ ld_ptr(Address(O0_argslot,  i), O2_scratch);
          __ ld_ptr(Address(O1_destslot, i), O3_scratch);
          __ st_ptr(O3_scratch, Address(O0_argslot,  i));
          __ st_ptr(O2_scratch, Address(O1_destslot, i));
        }
      } else {
        // Save the first chunk, which is going to get overwritten.
        switch (swap_bytes) {
        case 4 : __ lduw(Address(O0_argslot, 0), O2_scratch); break;
        case 16: __ ldx( Address(O0_argslot, 8), O3_scratch); //fall-thru
        case 8 : __ ldx( Address(O0_argslot, 0), O2_scratch); break;
        default: ShouldNotReachHere();
        }

        if (rotate > 0) {
          // Rorate upward.
          __ sub(O0_argslot, swap_bytes, O0_argslot);
#if ASSERT
          {
            // Verify that argslot > destslot, by at least swap_bytes.
            Label L_ok;
            __ cmp(O0_argslot, O1_destslot);
            __ brx(Assembler::greaterEqualUnsigned, false, Assembler::pt, L_ok);
            __ delayed()->nop();
            __ stop("source must be above destination (upward rotation)");
            __ bind(L_ok);
          }
#endif
          // Work argslot down to destslot, copying contiguous data upwards.
          // Pseudo-code:
          //   argslot  = src_addr - swap_bytes
          //   destslot = dest_addr
          //   while (argslot >= destslot) {
          //     *(argslot + swap_bytes) = *(argslot + 0);
          //     argslot--;
          //   }
          Label loop;
          __ bind(loop);
          __ ld_ptr(Address(O0_argslot, 0), G5_index);
          __ st_ptr(G5_index, Address(O0_argslot, swap_bytes));
          __ sub(O0_argslot, wordSize, O0_argslot);
          __ cmp(O0_argslot, O1_destslot);
          __ brx(Assembler::greaterEqualUnsigned, false, Assembler::pt, loop);
          __ delayed()->nop();  // FILLME
        } else {
          __ add(O0_argslot, swap_bytes, O0_argslot);
#if ASSERT
          {
            // Verify that argslot < destslot, by at least swap_bytes.
            Label L_ok;
            __ cmp(O0_argslot, O1_destslot);
            __ brx(Assembler::lessEqualUnsigned, false, Assembler::pt, L_ok);
            __ delayed()->nop();
            __ stop("source must be above destination (upward rotation)");
            __ bind(L_ok);
          }
#endif
          // Work argslot up to destslot, copying contiguous data downwards.
          // Pseudo-code:
          //   argslot  = src_addr + swap_bytes
          //   destslot = dest_addr
          //   while (argslot >= destslot) {
          //     *(argslot - swap_bytes) = *(argslot + 0);
          //     argslot++;
          //   }
          Label loop;
          __ bind(loop);
          __ ld_ptr(Address(O0_argslot, 0), G5_index);
          __ st_ptr(G5_index, Address(O0_argslot, -swap_bytes));
          __ add(O0_argslot, wordSize, O0_argslot);
          __ cmp(O0_argslot, O1_destslot);
          __ brx(Assembler::lessEqualUnsigned, false, Assembler::pt, loop);
          __ delayed()->nop();  // FILLME
        }

        // Store the original first chunk into the destination slot, now free.
        switch (swap_bytes) {
        case 4 : __ stw(O2_scratch, Address(O1_destslot, 0)); break;
        case 16: __ stx(O3_scratch, Address(O1_destslot, 8)); // fall-thru
        case 8 : __ stx(O2_scratch, Address(O1_destslot, 0)); break;
        default: ShouldNotReachHere();
        }
      }

938
      __ load_heap_oop(G3_mh_vmtarget, G3_method_handle);
T
twisti 已提交
939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981
      __ jump_to_method_handle_entry(G3_method_handle, O1_scratch);
    }
    break;

  case _adapter_dup_args:
    {
      // 'argslot' is the position of the first argument to duplicate.
      __ ldsw(G3_amh_vmargslot, O0_argslot);
      __ add(Gargs, __ argument_offset(O0_argslot), O0_argslot);

      // 'stack_move' is negative number of words to duplicate.
      Register G5_stack_move = G5_index;
      __ ldsw(G3_amh_conversion, G5_stack_move);
      __ sra(G5_stack_move, CONV_STACK_MOVE_SHIFT, G5_stack_move);

      // Remember the old Gargs (argslot[0]).
      Register O1_oldarg = O1_scratch;
      __ mov(Gargs, O1_oldarg);

      // Move Gargs down to make room for dups.
      __ sll_ptr(G5_stack_move, LogBytesPerWord, G5_stack_move);
      __ add(Gargs, G5_stack_move, Gargs);

      // Compute the new Gargs (argslot[0]).
      Register O2_newarg = O2_scratch;
      __ mov(Gargs, O2_newarg);

      // Copy from oldarg[0...] down to newarg[0...]
      // Pseude-code:
      //   O1_oldarg  = old-Gargs
      //   O2_newarg  = new-Gargs
      //   O0_argslot = argslot
      //   while (O2_newarg < O1_oldarg) *O2_newarg = *O0_argslot++
      Label loop;
      __ bind(loop);
      __ ld_ptr(Address(O0_argslot, 0), O3_scratch);
      __ st_ptr(O3_scratch, Address(O2_newarg, 0));
      __ add(O0_argslot, wordSize, O0_argslot);
      __ add(O2_newarg,  wordSize, O2_newarg);
      __ cmp(O2_newarg, O1_oldarg);
      __ brx(Assembler::less, false, Assembler::pt, loop);
      __ delayed()->nop();  // FILLME

982
      __ load_heap_oop(G3_mh_vmtarget, G3_method_handle);
T
twisti 已提交
983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999
      __ jump_to_method_handle_entry(G3_method_handle, O1_scratch);
    }
    break;

  case _adapter_drop_args:
    {
      // 'argslot' is the position of the first argument to nuke.
      __ ldsw(G3_amh_vmargslot, O0_argslot);
      __ add(Gargs, __ argument_offset(O0_argslot), O0_argslot);

      // 'stack_move' is number of words to drop.
      Register G5_stack_move = G5_index;
      __ ldsw(G3_amh_conversion, G5_stack_move);
      __ sra(G5_stack_move, CONV_STACK_MOVE_SHIFT, G5_stack_move);

      remove_arg_slots(_masm, G5_stack_move, O0_argslot, O1_scratch, O2_scratch, O3_scratch);

1000
      __ load_heap_oop(G3_mh_vmtarget, G3_method_handle);
T
twisti 已提交
1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035
      __ jump_to_method_handle_entry(G3_method_handle, O1_scratch);
    }
    break;

  case _adapter_collect_args:
    __ unimplemented(entry_name(ek)); // %%% FIXME: NYI
    break;

  case _adapter_spread_args:
    // Handled completely by optimized cases.
    __ stop("init_AdapterMethodHandle should not issue this");
    break;

  case _adapter_opt_spread_0:
  case _adapter_opt_spread_1:
  case _adapter_opt_spread_more:
    {
      // spread an array out into a group of arguments
      __ unimplemented(entry_name(ek));
    }
    break;

  case _adapter_flyby:
  case _adapter_ricochet:
    __ unimplemented(entry_name(ek)); // %%% FIXME: NYI
    break;

  default:
    ShouldNotReachHere();
  }

  address me_cookie = MethodHandleEntry::start_compiled_entry(_masm, interp_entry);
  __ unimplemented(entry_name(ek)); // %%% FIXME: NYI

  init_entry(ek, MethodHandleEntry::finish_compiled_entry(_masm, me_cookie));
1036
}