hotspot/src/cpu/sparc/vm/methodHandles_sparc.cpp
author twisti
Wed, 13 Oct 2010 01:19:43 -0700
changeset 6775 633e4ce534ac
parent 6772 2563324665d5
child 7102 a20be5bfcbee
permissions -rw-r--r--
6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC Reviewed-by: never, jrose
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
     1
/*
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5420
diff changeset
     2
 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
2534
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
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5420
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5420
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5420
diff changeset
    21
 * questions.
2534
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_sparc.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
6775
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6772
diff changeset
    30
#ifdef PRODUCT
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6772
diff changeset
    31
#define BLOCK_COMMENT(str) /* nothing */
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6772
diff changeset
    32
#else
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6772
diff changeset
    33
#define BLOCK_COMMENT(str) __ block_comment(str)
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6772
diff changeset
    34
#endif
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6772
diff changeset
    35
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6772
diff changeset
    36
#define BIND(label) bind(label); BLOCK_COMMENT(#label ":")
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6772
diff changeset
    37
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    38
address MethodHandleEntry::start_compiled_entry(MacroAssembler* _masm,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    39
                                                address interpreted_entry) {
5416
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
    40
  // Just before the actual machine code entry point, allocate space
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
    41
  // for a MethodHandleEntry::Data record, so that we can manage everything
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
    42
  // from one base pointer.
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    43
  __ align(wordSize);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    44
  address target = __ pc() + sizeof(Data);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    45
  while (__ pc() < target) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    46
    __ nop();
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    47
    __ align(wordSize);
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* me = (MethodHandleEntry*) __ pc();
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    51
  me->set_end_address(__ pc());         // set a temporary end_address
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    52
  me->set_from_interpreted_entry(interpreted_entry);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    53
  me->set_type_checking_entry(NULL);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    54
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    55
  return (address) me;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    56
}
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    57
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    58
MethodHandleEntry* MethodHandleEntry::finish_compiled_entry(MacroAssembler* _masm,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    59
                                                address start_addr) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    60
  MethodHandleEntry* me = (MethodHandleEntry*) start_addr;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    61
  assert(me->end_address() == start_addr, "valid ME");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    62
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    63
  // Fill in the real end_address:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    64
  __ align(wordSize);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    65
  me->set_end_address(__ pc());
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    66
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    67
  return me;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    68
}
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    69
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    70
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    71
// Code generation
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    72
address MethodHandles::generate_method_handle_interpreter_entry(MacroAssembler* _masm) {
5416
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
    73
  // I5_savedSP: sender SP (must preserve)
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
    74
  // G4 (Gargs): incoming argument list (must preserve)
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
    75
  // G5_method:  invoke methodOop; becomes method type.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
    76
  // G3_method_handle: receiver method handle (must load from sp[MethodTypeForm.vmslots])
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
    77
  // O0, O1: garbage temps, blown away
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
    78
  Register O0_argslot = O0;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
    79
  Register O1_scratch = O1;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
    80
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
    81
  // emit WrongMethodType path first, to enable back-branch from main path
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
    82
  Label wrong_method_type;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
    83
  __ bind(wrong_method_type);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
    84
  __ jump_to(AddressLiteral(Interpreter::throw_WrongMethodType_entry()), O1_scratch);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
    85
  __ delayed()->nop();
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
    86
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
    87
  // here's where control starts out:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
    88
  __ align(CodeEntryAlignment);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
    89
  address entry_point = __ pc();
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
    90
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
    91
  // fetch the MethodType from the method handle into G5_method_type
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
    92
  {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
    93
    Register tem = G5_method;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
    94
    assert(tem == G5_method_type, "yes, it's the same register");
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
    95
    for (jint* pchase = methodOopDesc::method_type_offsets_chain(); (*pchase) != -1; pchase++) {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
    96
      __ ld_ptr(Address(tem, *pchase), G5_method_type);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
    97
    }
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
    98
  }
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
    99
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   100
  // given the MethodType, find out where the MH argument is buried
6772
2563324665d5 6829194: JSR 292 needs to support compressed oops
twisti
parents: 5702
diff changeset
   101
  __ load_heap_oop(Address(G5_method_type, __ delayed_value(java_dyn_MethodType::form_offset_in_bytes, O1_scratch)),        O0_argslot);
2563324665d5 6829194: JSR 292 needs to support compressed oops
twisti
parents: 5702
diff changeset
   102
  __ ldsw(         Address(O0_argslot,     __ delayed_value(java_dyn_MethodTypeForm::vmslots_offset_in_bytes, O1_scratch)), O0_argslot);
5416
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   103
  __ ld_ptr(__ argument_address(O0_argslot), G3_method_handle);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   104
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   105
  __ check_method_handle_type(G5_method_type, G3_method_handle, O1_scratch, wrong_method_type);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   106
  __ jump_to_method_handle_entry(G3_method_handle, O1_scratch);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   107
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   108
  return entry_point;
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   109
}
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   110
5416
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   111
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   112
#ifdef ASSERT
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   113
static void verify_argslot(MacroAssembler* _masm, Register argslot_reg, Register temp_reg, const char* error_message) {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   114
  // Verify that argslot lies within (Gargs, FP].
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   115
  Label L_ok, L_bad;
6775
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6772
diff changeset
   116
  BLOCK_COMMENT("{ verify_argslot");
5416
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   117
#ifdef _LP64
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   118
  __ add(FP, STACK_BIAS, temp_reg);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   119
  __ cmp(argslot_reg, temp_reg);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   120
#else
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   121
  __ cmp(argslot_reg, FP);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   122
#endif
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   123
  __ brx(Assembler::greaterUnsigned, false, Assembler::pn, L_bad);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   124
  __ delayed()->nop();
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   125
  __ cmp(Gargs, argslot_reg);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   126
  __ brx(Assembler::lessEqualUnsigned, false, Assembler::pt, L_ok);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   127
  __ delayed()->nop();
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   128
  __ bind(L_bad);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   129
  __ stop(error_message);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   130
  __ bind(L_ok);
6775
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6772
diff changeset
   131
  BLOCK_COMMENT("} verify_argslot");
5416
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   132
}
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   133
#endif
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   134
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   135
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   136
// Helper to insert argument slots into the stack.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   137
// arg_slots must be a multiple of stack_move_unit() and <= 0
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   138
void MethodHandles::insert_arg_slots(MacroAssembler* _masm,
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   139
                                     RegisterOrConstant arg_slots,
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   140
                                     int arg_mask,
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   141
                                     Register argslot_reg,
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   142
                                     Register temp_reg, Register temp2_reg, Register temp3_reg) {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   143
  assert(temp3_reg != noreg, "temp3 required");
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   144
  assert_different_registers(argslot_reg, temp_reg, temp2_reg, temp3_reg,
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   145
                             (!arg_slots.is_register() ? Gargs : arg_slots.as_register()));
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   146
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   147
#ifdef ASSERT
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   148
  verify_argslot(_masm, argslot_reg, temp_reg, "insertion point must fall within current frame");
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   149
  if (arg_slots.is_register()) {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   150
    Label L_ok, L_bad;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   151
    __ cmp(arg_slots.as_register(), (int32_t) NULL_WORD);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   152
    __ br(Assembler::greater, false, Assembler::pn, L_bad);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   153
    __ delayed()->nop();
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   154
    __ btst(-stack_move_unit() - 1, arg_slots.as_register());
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   155
    __ br(Assembler::zero, false, Assembler::pt, L_ok);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   156
    __ delayed()->nop();
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   157
    __ bind(L_bad);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   158
    __ stop("assert arg_slots <= 0 and clear low bits");
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   159
    __ bind(L_ok);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   160
  } else {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   161
    assert(arg_slots.as_constant() <= 0, "");
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   162
    assert(arg_slots.as_constant() % -stack_move_unit() == 0, "");
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   163
  }
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   164
#endif // ASSERT
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   165
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   166
#ifdef _LP64
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   167
  if (arg_slots.is_register()) {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   168
    // Was arg_slots register loaded as signed int?
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   169
    Label L_ok;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   170
    __ sll(arg_slots.as_register(), BitsPerInt, temp_reg);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   171
    __ sra(temp_reg, BitsPerInt, temp_reg);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   172
    __ cmp(arg_slots.as_register(), temp_reg);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   173
    __ br(Assembler::equal, false, Assembler::pt, L_ok);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   174
    __ delayed()->nop();
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   175
    __ stop("arg_slots register not loaded as signed int");
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   176
    __ bind(L_ok);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   177
  }
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   178
#endif
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   179
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   180
  // Make space on the stack for the inserted argument(s).
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   181
  // Then pull down everything shallower than argslot_reg.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   182
  // The stacked return address gets pulled down with everything else.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   183
  // That is, copy [sp, argslot) downward by -size words.  In pseudo-code:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   184
  //   sp -= size;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   185
  //   for (temp = sp + size; temp < argslot; temp++)
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   186
  //     temp[-size] = temp[0]
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   187
  //   argslot -= size;
6775
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6772
diff changeset
   188
  BLOCK_COMMENT("insert_arg_slots {");
5416
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   189
  RegisterOrConstant offset = __ regcon_sll_ptr(arg_slots, LogBytesPerWord, temp3_reg);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   190
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   191
  // Keep the stack pointer 2*wordSize aligned.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   192
  const int TwoWordAlignmentMask = right_n_bits(LogBytesPerWord + 1);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   193
  RegisterOrConstant masked_offset = __ regcon_andn_ptr(offset, TwoWordAlignmentMask, temp_reg);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   194
  __ add(SP, masked_offset, SP);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   195
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   196
  __ mov(Gargs, temp_reg);  // source pointer for copy
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   197
  __ add(Gargs, offset, Gargs);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   198
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   199
  {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   200
    Label loop;
6775
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6772
diff changeset
   201
    __ BIND(loop);
5416
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   202
    // pull one word down each time through the loop
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   203
    __ ld_ptr(Address(temp_reg, 0), temp2_reg);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   204
    __ st_ptr(temp2_reg, Address(temp_reg, offset));
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   205
    __ add(temp_reg, wordSize, temp_reg);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   206
    __ cmp(temp_reg, argslot_reg);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   207
    __ brx(Assembler::less, false, Assembler::pt, loop);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   208
    __ delayed()->nop();  // FILLME
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   209
  }
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   210
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   211
  // Now move the argslot down, to point to the opened-up space.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   212
  __ add(argslot_reg, offset, argslot_reg);
6775
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6772
diff changeset
   213
  BLOCK_COMMENT("} insert_arg_slots");
5416
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   214
}
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   215
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   216
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   217
// Helper to remove argument slots from the stack.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   218
// arg_slots must be a multiple of stack_move_unit() and >= 0
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   219
void MethodHandles::remove_arg_slots(MacroAssembler* _masm,
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   220
                                     RegisterOrConstant arg_slots,
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   221
                                     Register argslot_reg,
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   222
                                     Register temp_reg, Register temp2_reg, Register temp3_reg) {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   223
  assert(temp3_reg != noreg, "temp3 required");
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   224
  assert_different_registers(argslot_reg, temp_reg, temp2_reg, temp3_reg,
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   225
                             (!arg_slots.is_register() ? Gargs : arg_slots.as_register()));
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   226
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   227
  RegisterOrConstant offset = __ regcon_sll_ptr(arg_slots, LogBytesPerWord, temp3_reg);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   228
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   229
#ifdef ASSERT
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   230
  // Verify that [argslot..argslot+size) lies within (Gargs, FP).
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   231
  __ add(argslot_reg, offset, temp2_reg);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   232
  verify_argslot(_masm, temp2_reg, temp_reg, "deleted argument(s) must fall within current frame");
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   233
  if (arg_slots.is_register()) {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   234
    Label L_ok, L_bad;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   235
    __ cmp(arg_slots.as_register(), (int32_t) NULL_WORD);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   236
    __ br(Assembler::less, false, Assembler::pn, L_bad);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   237
    __ delayed()->nop();
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   238
    __ btst(-stack_move_unit() - 1, arg_slots.as_register());
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   239
    __ br(Assembler::zero, false, Assembler::pt, L_ok);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   240
    __ delayed()->nop();
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   241
    __ bind(L_bad);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   242
    __ stop("assert arg_slots >= 0 and clear low bits");
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   243
    __ bind(L_ok);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   244
  } else {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   245
    assert(arg_slots.as_constant() >= 0, "");
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   246
    assert(arg_slots.as_constant() % -stack_move_unit() == 0, "");
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   247
  }
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   248
#endif // ASSERT
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   249
6775
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6772
diff changeset
   250
  BLOCK_COMMENT("remove_arg_slots {");
5416
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   251
  // Pull up everything shallower than argslot.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   252
  // Then remove the excess space on the stack.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   253
  // The stacked return address gets pulled up with everything else.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   254
  // That is, copy [sp, argslot) upward by size words.  In pseudo-code:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   255
  //   for (temp = argslot-1; temp >= sp; --temp)
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   256
  //     temp[size] = temp[0]
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   257
  //   argslot += size;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   258
  //   sp += size;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   259
  __ sub(argslot_reg, wordSize, temp_reg);  // source pointer for copy
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   260
  {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   261
    Label loop;
6775
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6772
diff changeset
   262
    __ BIND(loop);
5416
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   263
    // pull one word up each time through the loop
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   264
    __ ld_ptr(Address(temp_reg, 0), temp2_reg);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   265
    __ st_ptr(temp2_reg, Address(temp_reg, offset));
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   266
    __ sub(temp_reg, wordSize, temp_reg);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   267
    __ cmp(temp_reg, Gargs);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   268
    __ brx(Assembler::greaterEqual, false, Assembler::pt, loop);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   269
    __ delayed()->nop();  // FILLME
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   270
  }
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   271
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   272
  // Now move the argslot up, to point to the just-copied block.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   273
  __ add(Gargs, offset, Gargs);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   274
  // And adjust the argslot address to point at the deletion point.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   275
  __ add(argslot_reg, offset, argslot_reg);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   276
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   277
  // Keep the stack pointer 2*wordSize aligned.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   278
  const int TwoWordAlignmentMask = right_n_bits(LogBytesPerWord + 1);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   279
  RegisterOrConstant masked_offset = __ regcon_andn_ptr(offset, TwoWordAlignmentMask, temp_reg);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   280
  __ add(SP, masked_offset, SP);
6775
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6772
diff changeset
   281
  BLOCK_COMMENT("} remove_arg_slots");
5416
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   282
}
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   283
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   284
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   285
#ifndef PRODUCT
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   286
extern "C" void print_method_handle(oop mh);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   287
void trace_method_handle_stub(const char* adaptername,
6775
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6772
diff changeset
   288
                              oopDesc* mh) {
5416
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   289
  printf("MH %s mh="INTPTR_FORMAT"\n", adaptername, (intptr_t) mh);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   290
  print_method_handle(mh);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   291
}
6775
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6772
diff changeset
   292
void MethodHandles::trace_method_handle(MacroAssembler* _masm, const char* adaptername) {
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6772
diff changeset
   293
  if (!TraceMethodHandles)  return;
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6772
diff changeset
   294
  BLOCK_COMMENT("trace_method_handle {");
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6772
diff changeset
   295
  // save: Gargs, O5_savedSP
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6772
diff changeset
   296
  __ save_frame(16);
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6772
diff changeset
   297
  __ set((intptr_t) adaptername, O0);
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6772
diff changeset
   298
  __ mov(G3_method_handle, O1);
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6772
diff changeset
   299
  __ mov(G3_method_handle, L3);
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6772
diff changeset
   300
  __ mov(Gargs, L4);
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6772
diff changeset
   301
  __ mov(G5_method_type, L5);
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6772
diff changeset
   302
  __ call_VM_leaf(L7, CAST_FROM_FN_PTR(address, trace_method_handle_stub));
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6772
diff changeset
   303
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6772
diff changeset
   304
  __ mov(L3, G3_method_handle);
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6772
diff changeset
   305
  __ mov(L4, Gargs);
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6772
diff changeset
   306
  __ mov(L5, G5_method_type);
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6772
diff changeset
   307
  __ restore();
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6772
diff changeset
   308
  BLOCK_COMMENT("} trace_method_handle");
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6772
diff changeset
   309
}
5416
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   310
#endif // PRODUCT
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   311
5420
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 5419
diff changeset
   312
// which conversion op types are implemented here?
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 5419
diff changeset
   313
int MethodHandles::adapter_conversion_ops_supported_mask() {
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 5419
diff changeset
   314
  return ((1<<sun_dyn_AdapterMethodHandle::OP_RETYPE_ONLY)
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 5419
diff changeset
   315
         |(1<<sun_dyn_AdapterMethodHandle::OP_RETYPE_RAW)
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 5419
diff changeset
   316
         |(1<<sun_dyn_AdapterMethodHandle::OP_CHECK_CAST)
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 5419
diff changeset
   317
         |(1<<sun_dyn_AdapterMethodHandle::OP_PRIM_TO_PRIM)
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 5419
diff changeset
   318
         |(1<<sun_dyn_AdapterMethodHandle::OP_REF_TO_PRIM)
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 5419
diff changeset
   319
         |(1<<sun_dyn_AdapterMethodHandle::OP_SWAP_ARGS)
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 5419
diff changeset
   320
         |(1<<sun_dyn_AdapterMethodHandle::OP_ROT_ARGS)
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 5419
diff changeset
   321
         |(1<<sun_dyn_AdapterMethodHandle::OP_DUP_ARGS)
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 5419
diff changeset
   322
         |(1<<sun_dyn_AdapterMethodHandle::OP_DROP_ARGS)
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 5419
diff changeset
   323
         //|(1<<sun_dyn_AdapterMethodHandle::OP_SPREAD_ARGS) //BUG!
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 5419
diff changeset
   324
         );
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 5419
diff changeset
   325
  // FIXME: MethodHandlesTest gets a crash if we enable OP_SPREAD_ARGS.
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 5419
diff changeset
   326
}
5416
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   327
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   328
//------------------------------------------------------------------------------
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   329
// MethodHandles::generate_method_handle_stub
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   330
//
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   331
// Generate an "entry" field for a method handle.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   332
// This determines how the method handle will respond to calls.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   333
void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHandles::EntryKind ek) {
5416
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   334
  // Here is the register state during an interpreted call,
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   335
  // as set up by generate_method_handle_interpreter_entry():
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   336
  // - G5: garbage temp (was MethodHandle.invoke methodOop, unused)
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   337
  // - G3: receiver method handle
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   338
  // - O5_savedSP: sender SP (must preserve)
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   339
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   340
  Register O0_argslot = O0;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   341
  Register O1_scratch = O1;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   342
  Register O2_scratch = O2;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   343
  Register O3_scratch = O3;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   344
  Register G5_index   = G5;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   345
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   346
  guarantee(java_dyn_MethodHandle::vmentry_offset_in_bytes() != 0, "must have offsets");
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   347
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   348
  // Some handy addresses:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   349
  Address G5_method_fie(    G5_method,        in_bytes(methodOopDesc::from_interpreted_offset()));
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   350
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   351
  Address G3_mh_vmtarget(   G3_method_handle, java_dyn_MethodHandle::vmtarget_offset_in_bytes());
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   352
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   353
  Address G3_dmh_vmindex(   G3_method_handle, sun_dyn_DirectMethodHandle::vmindex_offset_in_bytes());
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   354
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   355
  Address G3_bmh_vmargslot( G3_method_handle, sun_dyn_BoundMethodHandle::vmargslot_offset_in_bytes());
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   356
  Address G3_bmh_argument(  G3_method_handle, sun_dyn_BoundMethodHandle::argument_offset_in_bytes());
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   357
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   358
  Address G3_amh_vmargslot( G3_method_handle, sun_dyn_AdapterMethodHandle::vmargslot_offset_in_bytes());
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   359
  Address G3_amh_argument ( G3_method_handle, sun_dyn_AdapterMethodHandle::argument_offset_in_bytes());
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   360
  Address G3_amh_conversion(G3_method_handle, sun_dyn_AdapterMethodHandle::conversion_offset_in_bytes());
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   361
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   362
  const int java_mirror_offset = klassOopDesc::klass_part_offset_in_bytes() + Klass::java_mirror_offset_in_bytes();
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   363
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   364
  if (have_entry(ek)) {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   365
    __ nop();  // empty stubs make SG sick
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   366
    return;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   367
  }
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   368
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   369
  address interp_entry = __ pc();
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   370
6775
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6772
diff changeset
   371
  trace_method_handle(_masm, entry_name(ek));
5416
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   372
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   373
  switch ((int) ek) {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   374
  case _raise_exception:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   375
    {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   376
      // Not a real MH entry, but rather shared code for raising an
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   377
      // exception.  Extra local arguments are passed in scratch
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   378
      // registers, as required type in O3, failing object (or NULL)
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   379
      // in O2, failing bytecode type in O1.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   380
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   381
      __ mov(O5_savedSP, SP);  // Cut the stack back to where the caller started.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   382
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   383
      // Push arguments as if coming from the interpreter.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   384
      Register O0_scratch = O0_argslot;
5419
f2e8cc8c12ea 6943304: remove tagged stack interpreter
twisti
parents: 5416
diff changeset
   385
      int stackElementSize = Interpreter::stackElementSize;
5416
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   386
5687
b862d1f189bd 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 5420
diff changeset
   387
      // Make space on the stack for the arguments and set Gargs
b862d1f189bd 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 5420
diff changeset
   388
      // correctly.
b862d1f189bd 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 5420
diff changeset
   389
      __ sub(SP, 4*stackElementSize, SP);  // Keep stack aligned.
b862d1f189bd 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 5420
diff changeset
   390
      __ add(SP, (frame::varargs_offset)*wordSize - 1*Interpreter::stackElementSize + STACK_BIAS + BytesPerWord, Gargs);
5416
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   391
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   392
      // void raiseException(int code, Object actual, Object required)
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   393
      __ st(    O1_scratch, Address(Gargs, 2*stackElementSize));  // code
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   394
      __ st_ptr(O2_scratch, Address(Gargs, 1*stackElementSize));  // actual
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   395
      __ st_ptr(O3_scratch, Address(Gargs, 0*stackElementSize));  // required
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   396
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   397
      Label no_method;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   398
      // FIXME: fill in _raise_exception_method with a suitable sun.dyn method
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   399
      __ set(AddressLiteral((address) &_raise_exception_method), G5_method);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   400
      __ ld_ptr(Address(G5_method, 0), G5_method);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   401
      __ tst(G5_method);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   402
      __ brx(Assembler::zero, false, Assembler::pn, no_method);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   403
      __ delayed()->nop();
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   404
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   405
      int jobject_oop_offset = 0;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   406
      __ ld_ptr(Address(G5_method, jobject_oop_offset), G5_method);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   407
      __ tst(G5_method);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   408
      __ brx(Assembler::zero, false, Assembler::pn, no_method);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   409
      __ delayed()->nop();
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   410
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   411
      __ verify_oop(G5_method);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   412
      __ jump_indirect_to(G5_method_fie, O1_scratch);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   413
      __ delayed()->nop();
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   414
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   415
      // If we get here, the Java runtime did not do its job of creating the exception.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   416
      // Do something that is at least causes a valid throw from the interpreter.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   417
      __ bind(no_method);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   418
      __ unimplemented("_raise_exception no method");
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   419
    }
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   420
    break;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   421
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   422
  case _invokestatic_mh:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   423
  case _invokespecial_mh:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   424
    {
6772
2563324665d5 6829194: JSR 292 needs to support compressed oops
twisti
parents: 5702
diff changeset
   425
      __ load_heap_oop(G3_mh_vmtarget, G5_method);  // target is a methodOop
5416
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   426
      __ verify_oop(G5_method);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   427
      // Same as TemplateTable::invokestatic or invokespecial,
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   428
      // minus the CP setup and profiling:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   429
      if (ek == _invokespecial_mh) {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   430
        // Must load & check the first argument before entering the target method.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   431
        __ load_method_handle_vmslots(O0_argslot, G3_method_handle, O1_scratch);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   432
        __ ld_ptr(__ argument_address(O0_argslot), G3_method_handle);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   433
        __ null_check(G3_method_handle);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   434
        __ verify_oop(G3_method_handle);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   435
      }
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   436
      __ jump_indirect_to(G5_method_fie, O1_scratch);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   437
      __ delayed()->nop();
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   438
    }
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   439
    break;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   440
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   441
  case _invokevirtual_mh:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   442
    {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   443
      // Same as TemplateTable::invokevirtual,
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   444
      // minus the CP setup and profiling:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   445
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   446
      // Pick out the vtable index and receiver offset from the MH,
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   447
      // and then we can discard it:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   448
      __ load_method_handle_vmslots(O0_argslot, G3_method_handle, O1_scratch);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   449
      __ ldsw(G3_dmh_vmindex, G5_index);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   450
      // Note:  The verifier allows us to ignore G3_mh_vmtarget.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   451
      __ ld_ptr(__ argument_address(O0_argslot, -1), G3_method_handle);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   452
      __ null_check(G3_method_handle, oopDesc::klass_offset_in_bytes());
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   453
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   454
      // Get receiver klass:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   455
      Register O0_klass = O0_argslot;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   456
      __ load_klass(G3_method_handle, O0_klass);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   457
      __ verify_oop(O0_klass);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   458
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   459
      // Get target methodOop & entry point:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   460
      const int base = instanceKlass::vtable_start_offset() * wordSize;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   461
      assert(vtableEntry::size() * wordSize == wordSize, "adjust the scaling in the code below");
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   462
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   463
      __ sll_ptr(G5_index, LogBytesPerWord, G5_index);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   464
      __ add(O0_klass, G5_index, O0_klass);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   465
      Address vtable_entry_addr(O0_klass, base + vtableEntry::method_offset_in_bytes());
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   466
      __ ld_ptr(vtable_entry_addr, G5_method);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   467
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   468
      __ verify_oop(G5_method);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   469
      __ jump_indirect_to(G5_method_fie, O1_scratch);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   470
      __ delayed()->nop();
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   471
    }
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   472
    break;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   473
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   474
  case _invokeinterface_mh:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   475
    {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   476
      // Same as TemplateTable::invokeinterface,
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   477
      // minus the CP setup and profiling:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   478
      __ load_method_handle_vmslots(O0_argslot, G3_method_handle, O1_scratch);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   479
      Register O1_intf  = O1_scratch;
6772
2563324665d5 6829194: JSR 292 needs to support compressed oops
twisti
parents: 5702
diff changeset
   480
      __ load_heap_oop(G3_mh_vmtarget, O1_intf);
5416
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   481
      __ ldsw(G3_dmh_vmindex, G5_index);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   482
      __ ld_ptr(__ argument_address(O0_argslot, -1), G3_method_handle);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   483
      __ null_check(G3_method_handle, oopDesc::klass_offset_in_bytes());
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   484
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   485
      // Get receiver klass:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   486
      Register O0_klass = O0_argslot;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   487
      __ load_klass(G3_method_handle, O0_klass);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   488
      __ verify_oop(O0_klass);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   489
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   490
      // Get interface:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   491
      Label no_such_interface;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   492
      __ verify_oop(O1_intf);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   493
      __ lookup_interface_method(O0_klass, O1_intf,
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   494
                                 // Note: next two args must be the same:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   495
                                 G5_index, G5_method,
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   496
                                 O2_scratch,
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   497
                                 O3_scratch,
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   498
                                 no_such_interface);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   499
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   500
      __ verify_oop(G5_method);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   501
      __ jump_indirect_to(G5_method_fie, O1_scratch);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   502
      __ delayed()->nop();
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   503
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   504
      __ bind(no_such_interface);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   505
      // Throw an exception.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   506
      // For historical reasons, it will be IncompatibleClassChangeError.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   507
      __ unimplemented("not tested yet");
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   508
      __ ld_ptr(Address(O1_intf, java_mirror_offset), O3_scratch);  // required interface
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   509
      __ mov(O0_klass, O2_scratch);  // bad receiver
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   510
      __ jump_to(AddressLiteral(from_interpreted_entry(_raise_exception)), O0_argslot);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   511
      __ delayed()->mov(Bytecodes::_invokeinterface, O1_scratch);  // who is complaining?
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   512
    }
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   513
    break;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   514
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   515
  case _bound_ref_mh:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   516
  case _bound_int_mh:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   517
  case _bound_long_mh:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   518
  case _bound_ref_direct_mh:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   519
  case _bound_int_direct_mh:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   520
  case _bound_long_direct_mh:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   521
    {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   522
      const bool direct_to_method = (ek >= _bound_ref_direct_mh);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   523
      BasicType arg_type  = T_ILLEGAL;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   524
      int       arg_mask  = _INSERT_NO_MASK;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   525
      int       arg_slots = -1;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   526
      get_ek_bound_mh_info(ek, arg_type, arg_mask, arg_slots);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   527
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   528
      // Make room for the new argument:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   529
      __ ldsw(G3_bmh_vmargslot, O0_argslot);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   530
      __ add(Gargs, __ argument_offset(O0_argslot), O0_argslot);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   531
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   532
      insert_arg_slots(_masm, arg_slots * stack_move_unit(), arg_mask, O0_argslot, O1_scratch, O2_scratch, G5_index);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   533
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   534
      // Store bound argument into the new stack slot:
6772
2563324665d5 6829194: JSR 292 needs to support compressed oops
twisti
parents: 5702
diff changeset
   535
      __ load_heap_oop(G3_bmh_argument, O1_scratch);
5416
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   536
      if (arg_type == T_OBJECT) {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   537
        __ st_ptr(O1_scratch, Address(O0_argslot, 0));
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   538
      } else {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   539
        Address prim_value_addr(O1_scratch, java_lang_boxing_object::value_offset_in_bytes(arg_type));
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   540
        __ load_sized_value(prim_value_addr, O2_scratch, type2aelembytes(arg_type), is_signed_subword_type(arg_type));
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   541
        if (arg_slots == 2) {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   542
          __ unimplemented("not yet tested");
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   543
#ifndef _LP64
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   544
          __ signx(O2_scratch, O3_scratch);  // Sign extend
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   545
#endif
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   546
          __ st_long(O2_scratch, Address(O0_argslot, 0));  // Uses O2/O3 on !_LP64
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   547
        } else {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   548
          __ st_ptr( O2_scratch, Address(O0_argslot, 0));
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   549
        }
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   550
      }
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   551
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   552
      if (direct_to_method) {
6772
2563324665d5 6829194: JSR 292 needs to support compressed oops
twisti
parents: 5702
diff changeset
   553
        __ load_heap_oop(G3_mh_vmtarget, G5_method);  // target is a methodOop
5416
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   554
        __ verify_oop(G5_method);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   555
        __ jump_indirect_to(G5_method_fie, O1_scratch);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   556
        __ delayed()->nop();
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   557
      } else {
6772
2563324665d5 6829194: JSR 292 needs to support compressed oops
twisti
parents: 5702
diff changeset
   558
        __ load_heap_oop(G3_mh_vmtarget, G3_method_handle);  // target is a methodOop
5416
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   559
        __ verify_oop(G3_method_handle);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   560
        __ jump_to_method_handle_entry(G3_method_handle, O1_scratch);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   561
      }
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   562
    }
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   563
    break;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   564
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   565
  case _adapter_retype_only:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   566
  case _adapter_retype_raw:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   567
    // Immediately jump to the next MH layer:
6772
2563324665d5 6829194: JSR 292 needs to support compressed oops
twisti
parents: 5702
diff changeset
   568
    __ load_heap_oop(G3_mh_vmtarget, G3_method_handle);
5416
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   569
    __ jump_to_method_handle_entry(G3_method_handle, O1_scratch);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   570
    // This is OK when all parameter types widen.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   571
    // It is also OK when a return type narrows.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   572
    break;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   573
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   574
  case _adapter_check_cast:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   575
    {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   576
      // Temps:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   577
      Register G5_klass = G5_index;  // Interesting AMH data.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   578
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   579
      // Check a reference argument before jumping to the next layer of MH:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   580
      __ ldsw(G3_amh_vmargslot, O0_argslot);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   581
      Address vmarg = __ argument_address(O0_argslot);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   582
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   583
      // What class are we casting to?
6772
2563324665d5 6829194: JSR 292 needs to support compressed oops
twisti
parents: 5702
diff changeset
   584
      __ load_heap_oop(G3_amh_argument, G5_klass);  // This is a Class object!
2563324665d5 6829194: JSR 292 needs to support compressed oops
twisti
parents: 5702
diff changeset
   585
      __ load_heap_oop(Address(G5_klass, java_lang_Class::klass_offset_in_bytes()), G5_klass);
5416
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   586
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   587
      Label done;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   588
      __ ld_ptr(vmarg, O1_scratch);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   589
      __ tst(O1_scratch);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   590
      __ brx(Assembler::zero, false, Assembler::pn, done);  // No cast if null.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   591
      __ delayed()->nop();
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   592
      __ load_klass(O1_scratch, O1_scratch);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   593
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   594
      // Live at this point:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   595
      // - G5_klass        :  klass required by the target method
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   596
      // - O1_scratch      :  argument klass to test
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   597
      // - G3_method_handle:  adapter method handle
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   598
      __ check_klass_subtype(O1_scratch, G5_klass, O0_argslot, O2_scratch, done);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   599
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   600
      // If we get here, the type check failed!
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   601
      __ ldsw(G3_amh_vmargslot, O0_argslot);  // reload argslot field
6772
2563324665d5 6829194: JSR 292 needs to support compressed oops
twisti
parents: 5702
diff changeset
   602
      __ load_heap_oop(G3_amh_argument, O3_scratch);  // required class
5416
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   603
      __ ld_ptr(vmarg, O2_scratch);  // bad object
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   604
      __ jump_to(AddressLiteral(from_interpreted_entry(_raise_exception)), O0_argslot);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   605
      __ delayed()->mov(Bytecodes::_checkcast, O1_scratch);  // who is complaining?
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   606
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   607
      __ bind(done);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   608
      // Get the new MH:
6772
2563324665d5 6829194: JSR 292 needs to support compressed oops
twisti
parents: 5702
diff changeset
   609
      __ load_heap_oop(G3_mh_vmtarget, G3_method_handle);
5416
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   610
      __ jump_to_method_handle_entry(G3_method_handle, O1_scratch);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   611
    }
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   612
    break;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   613
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   614
  case _adapter_prim_to_prim:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   615
  case _adapter_ref_to_prim:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   616
    // Handled completely by optimized cases.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   617
    __ stop("init_AdapterMethodHandle should not issue this");
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   618
    break;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   619
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   620
  case _adapter_opt_i2i:        // optimized subcase of adapt_prim_to_prim
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   621
//case _adapter_opt_f2i:        // optimized subcase of adapt_prim_to_prim
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   622
  case _adapter_opt_l2i:        // optimized subcase of adapt_prim_to_prim
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   623
  case _adapter_opt_unboxi:     // optimized subcase of adapt_ref_to_prim
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   624
    {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   625
      // Perform an in-place conversion to int or an int subword.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   626
      __ ldsw(G3_amh_vmargslot, O0_argslot);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   627
      Address vmarg = __ argument_address(O0_argslot);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   628
      Address value;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   629
      bool value_left_justified = false;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   630
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   631
      switch (ek) {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   632
      case _adapter_opt_i2i:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   633
      case _adapter_opt_l2i:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   634
        __ unimplemented(entry_name(ek));
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   635
        value = vmarg;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   636
        break;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   637
      case _adapter_opt_unboxi:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   638
        {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   639
          // Load the value up from the heap.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   640
          __ ld_ptr(vmarg, O1_scratch);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   641
          int value_offset = java_lang_boxing_object::value_offset_in_bytes(T_INT);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   642
#ifdef ASSERT
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   643
          for (int bt = T_BOOLEAN; bt < T_INT; bt++) {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   644
            if (is_subword_type(BasicType(bt)))
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   645
              assert(value_offset == java_lang_boxing_object::value_offset_in_bytes(BasicType(bt)), "");
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   646
          }
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   647
#endif
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   648
          __ null_check(O1_scratch, value_offset);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   649
          value = Address(O1_scratch, value_offset);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   650
#ifdef _BIG_ENDIAN
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   651
          // Values stored in objects are packed.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   652
          value_left_justified = true;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   653
#endif
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   654
        }
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   655
        break;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   656
      default:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   657
        ShouldNotReachHere();
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   658
      }
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   659
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   660
      // This check is required on _BIG_ENDIAN
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   661
      Register G5_vminfo = G5_index;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   662
      __ ldsw(G3_amh_conversion, G5_vminfo);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   663
      assert(CONV_VMINFO_SHIFT == 0, "preshifted");
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   664
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   665
      // Original 32-bit vmdata word must be of this form:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   666
      // | MBZ:6 | signBitCount:8 | srcDstTypes:8 | conversionOp:8 |
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   667
      __ lduw(value, O1_scratch);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   668
      if (!value_left_justified)
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   669
        __ sll(O1_scratch, G5_vminfo, O1_scratch);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   670
      Label zero_extend, done;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   671
      __ btst(CONV_VMINFO_SIGN_FLAG, G5_vminfo);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   672
      __ br(Assembler::zero, false, Assembler::pn, zero_extend);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   673
      __ delayed()->nop();
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   674
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   675
      // this path is taken for int->byte, int->short
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   676
      __ sra(O1_scratch, G5_vminfo, O1_scratch);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   677
      __ ba(false, done);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   678
      __ delayed()->nop();
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   679
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   680
      __ bind(zero_extend);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   681
      // this is taken for int->char
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   682
      __ srl(O1_scratch, G5_vminfo, O1_scratch);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   683
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   684
      __ bind(done);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   685
      __ st(O1_scratch, vmarg);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   686
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   687
      // Get the new MH:
6772
2563324665d5 6829194: JSR 292 needs to support compressed oops
twisti
parents: 5702
diff changeset
   688
      __ load_heap_oop(G3_mh_vmtarget, G3_method_handle);
5416
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   689
      __ jump_to_method_handle_entry(G3_method_handle, O1_scratch);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   690
    }
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   691
    break;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   692
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   693
  case _adapter_opt_i2l:        // optimized subcase of adapt_prim_to_prim
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   694
  case _adapter_opt_unboxl:     // optimized subcase of adapt_ref_to_prim
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   695
    {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   696
      // Perform an in-place int-to-long or ref-to-long conversion.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   697
      __ ldsw(G3_amh_vmargslot, O0_argslot);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   698
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   699
      // On big-endian machine we duplicate the slot and store the MSW
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   700
      // in the first slot.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   701
      __ add(Gargs, __ argument_offset(O0_argslot, 1), O0_argslot);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   702
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   703
      insert_arg_slots(_masm, stack_move_unit(), _INSERT_INT_MASK, O0_argslot, O1_scratch, O2_scratch, G5_index);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   704
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   705
      Address arg_lsw(O0_argslot, 0);
5419
f2e8cc8c12ea 6943304: remove tagged stack interpreter
twisti
parents: 5416
diff changeset
   706
      Address arg_msw(O0_argslot, -Interpreter::stackElementSize);
5416
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   707
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   708
      switch (ek) {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   709
      case _adapter_opt_i2l:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   710
        {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   711
          __ ldsw(arg_lsw, O2_scratch);      // Load LSW
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   712
#ifndef _LP64
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   713
          __ signx(O2_scratch, O3_scratch);  // Sign extend
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   714
#endif
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   715
          __ st_long(O2_scratch, arg_msw);   // Uses O2/O3 on !_LP64
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   716
        }
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   717
        break;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   718
      case _adapter_opt_unboxl:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   719
        {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   720
          // Load the value up from the heap.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   721
          __ ld_ptr(arg_lsw, O1_scratch);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   722
          int value_offset = java_lang_boxing_object::value_offset_in_bytes(T_LONG);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   723
          assert(value_offset == java_lang_boxing_object::value_offset_in_bytes(T_DOUBLE), "");
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   724
          __ null_check(O1_scratch, value_offset);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   725
          __ ld_long(Address(O1_scratch, value_offset), O2_scratch);  // Uses O2/O3 on !_LP64
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   726
          __ st_long(O2_scratch, arg_msw);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   727
        }
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   728
        break;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   729
      default:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   730
        ShouldNotReachHere();
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   731
      }
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   732
6772
2563324665d5 6829194: JSR 292 needs to support compressed oops
twisti
parents: 5702
diff changeset
   733
      __ load_heap_oop(G3_mh_vmtarget, G3_method_handle);
5416
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   734
      __ jump_to_method_handle_entry(G3_method_handle, O1_scratch);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   735
    }
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   736
    break;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   737
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   738
  case _adapter_opt_f2d:        // optimized subcase of adapt_prim_to_prim
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   739
  case _adapter_opt_d2f:        // optimized subcase of adapt_prim_to_prim
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   740
    {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   741
      // perform an in-place floating primitive conversion
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   742
      __ unimplemented(entry_name(ek));
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   743
    }
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   744
    break;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   745
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   746
  case _adapter_prim_to_ref:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   747
    __ unimplemented(entry_name(ek)); // %%% FIXME: NYI
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   748
    break;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   749
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   750
  case _adapter_swap_args:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   751
  case _adapter_rot_args:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   752
    // handled completely by optimized cases
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   753
    __ stop("init_AdapterMethodHandle should not issue this");
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   754
    break;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   755
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   756
  case _adapter_opt_swap_1:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   757
  case _adapter_opt_swap_2:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   758
  case _adapter_opt_rot_1_up:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   759
  case _adapter_opt_rot_1_down:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   760
  case _adapter_opt_rot_2_up:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   761
  case _adapter_opt_rot_2_down:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   762
    {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   763
      int swap_bytes = 0, rotate = 0;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   764
      get_ek_adapter_opt_swap_rot_info(ek, swap_bytes, rotate);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   765
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   766
      // 'argslot' is the position of the first argument to swap.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   767
      __ ldsw(G3_amh_vmargslot, O0_argslot);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   768
      __ add(Gargs, __ argument_offset(O0_argslot), O0_argslot);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   769
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   770
      // 'vminfo' is the second.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   771
      Register O1_destslot = O1_scratch;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   772
      __ ldsw(G3_amh_conversion, O1_destslot);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   773
      assert(CONV_VMINFO_SHIFT == 0, "preshifted");
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   774
      __ and3(O1_destslot, CONV_VMINFO_MASK, O1_destslot);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   775
      __ add(Gargs, __ argument_offset(O1_destslot), O1_destslot);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   776
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   777
      if (!rotate) {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   778
        for (int i = 0; i < swap_bytes; i += wordSize) {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   779
          __ ld_ptr(Address(O0_argslot,  i), O2_scratch);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   780
          __ ld_ptr(Address(O1_destslot, i), O3_scratch);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   781
          __ st_ptr(O3_scratch, Address(O0_argslot,  i));
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   782
          __ st_ptr(O2_scratch, Address(O1_destslot, i));
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   783
        }
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   784
      } else {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   785
        // Save the first chunk, which is going to get overwritten.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   786
        switch (swap_bytes) {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   787
        case 4 : __ lduw(Address(O0_argslot, 0), O2_scratch); break;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   788
        case 16: __ ldx( Address(O0_argslot, 8), O3_scratch); //fall-thru
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   789
        case 8 : __ ldx( Address(O0_argslot, 0), O2_scratch); break;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   790
        default: ShouldNotReachHere();
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   791
        }
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   792
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   793
        if (rotate > 0) {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   794
          // Rorate upward.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   795
          __ sub(O0_argslot, swap_bytes, O0_argslot);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   796
#if ASSERT
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   797
          {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   798
            // Verify that argslot > destslot, by at least swap_bytes.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   799
            Label L_ok;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   800
            __ cmp(O0_argslot, O1_destslot);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   801
            __ brx(Assembler::greaterEqualUnsigned, false, Assembler::pt, L_ok);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   802
            __ delayed()->nop();
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   803
            __ stop("source must be above destination (upward rotation)");
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   804
            __ bind(L_ok);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   805
          }
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   806
#endif
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   807
          // Work argslot down to destslot, copying contiguous data upwards.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   808
          // Pseudo-code:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   809
          //   argslot  = src_addr - swap_bytes
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   810
          //   destslot = dest_addr
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   811
          //   while (argslot >= destslot) {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   812
          //     *(argslot + swap_bytes) = *(argslot + 0);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   813
          //     argslot--;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   814
          //   }
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   815
          Label loop;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   816
          __ bind(loop);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   817
          __ ld_ptr(Address(O0_argslot, 0), G5_index);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   818
          __ st_ptr(G5_index, Address(O0_argslot, swap_bytes));
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   819
          __ sub(O0_argslot, wordSize, O0_argslot);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   820
          __ cmp(O0_argslot, O1_destslot);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   821
          __ brx(Assembler::greaterEqualUnsigned, false, Assembler::pt, loop);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   822
          __ delayed()->nop();  // FILLME
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   823
        } else {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   824
          __ add(O0_argslot, swap_bytes, O0_argslot);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   825
#if ASSERT
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   826
          {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   827
            // Verify that argslot < destslot, by at least swap_bytes.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   828
            Label L_ok;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   829
            __ cmp(O0_argslot, O1_destslot);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   830
            __ brx(Assembler::lessEqualUnsigned, false, Assembler::pt, L_ok);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   831
            __ delayed()->nop();
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   832
            __ stop("source must be above destination (upward rotation)");
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   833
            __ bind(L_ok);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   834
          }
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   835
#endif
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   836
          // Work argslot up to destslot, copying contiguous data downwards.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   837
          // Pseudo-code:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   838
          //   argslot  = src_addr + swap_bytes
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   839
          //   destslot = dest_addr
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   840
          //   while (argslot >= destslot) {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   841
          //     *(argslot - swap_bytes) = *(argslot + 0);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   842
          //     argslot++;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   843
          //   }
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   844
          Label loop;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   845
          __ bind(loop);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   846
          __ ld_ptr(Address(O0_argslot, 0), G5_index);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   847
          __ st_ptr(G5_index, Address(O0_argslot, -swap_bytes));
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   848
          __ add(O0_argslot, wordSize, O0_argslot);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   849
          __ cmp(O0_argslot, O1_destslot);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   850
          __ brx(Assembler::lessEqualUnsigned, false, Assembler::pt, loop);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   851
          __ delayed()->nop();  // FILLME
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   852
        }
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   853
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   854
        // Store the original first chunk into the destination slot, now free.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   855
        switch (swap_bytes) {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   856
        case 4 : __ stw(O2_scratch, Address(O1_destslot, 0)); break;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   857
        case 16: __ stx(O3_scratch, Address(O1_destslot, 8)); // fall-thru
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   858
        case 8 : __ stx(O2_scratch, Address(O1_destslot, 0)); break;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   859
        default: ShouldNotReachHere();
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   860
        }
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   861
      }
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   862
6772
2563324665d5 6829194: JSR 292 needs to support compressed oops
twisti
parents: 5702
diff changeset
   863
      __ load_heap_oop(G3_mh_vmtarget, G3_method_handle);
5416
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   864
      __ jump_to_method_handle_entry(G3_method_handle, O1_scratch);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   865
    }
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   866
    break;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   867
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   868
  case _adapter_dup_args:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   869
    {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   870
      // 'argslot' is the position of the first argument to duplicate.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   871
      __ ldsw(G3_amh_vmargslot, O0_argslot);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   872
      __ add(Gargs, __ argument_offset(O0_argslot), O0_argslot);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   873
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   874
      // 'stack_move' is negative number of words to duplicate.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   875
      Register G5_stack_move = G5_index;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   876
      __ ldsw(G3_amh_conversion, G5_stack_move);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   877
      __ sra(G5_stack_move, CONV_STACK_MOVE_SHIFT, G5_stack_move);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   878
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   879
      // Remember the old Gargs (argslot[0]).
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   880
      Register O1_oldarg = O1_scratch;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   881
      __ mov(Gargs, O1_oldarg);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   882
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   883
      // Move Gargs down to make room for dups.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   884
      __ sll_ptr(G5_stack_move, LogBytesPerWord, G5_stack_move);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   885
      __ add(Gargs, G5_stack_move, Gargs);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   886
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   887
      // Compute the new Gargs (argslot[0]).
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   888
      Register O2_newarg = O2_scratch;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   889
      __ mov(Gargs, O2_newarg);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   890
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   891
      // Copy from oldarg[0...] down to newarg[0...]
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   892
      // Pseude-code:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   893
      //   O1_oldarg  = old-Gargs
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   894
      //   O2_newarg  = new-Gargs
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   895
      //   O0_argslot = argslot
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   896
      //   while (O2_newarg < O1_oldarg) *O2_newarg = *O0_argslot++
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   897
      Label loop;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   898
      __ bind(loop);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   899
      __ ld_ptr(Address(O0_argslot, 0), O3_scratch);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   900
      __ st_ptr(O3_scratch, Address(O2_newarg, 0));
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   901
      __ add(O0_argslot, wordSize, O0_argslot);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   902
      __ add(O2_newarg,  wordSize, O2_newarg);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   903
      __ cmp(O2_newarg, O1_oldarg);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   904
      __ brx(Assembler::less, false, Assembler::pt, loop);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   905
      __ delayed()->nop();  // FILLME
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   906
6772
2563324665d5 6829194: JSR 292 needs to support compressed oops
twisti
parents: 5702
diff changeset
   907
      __ load_heap_oop(G3_mh_vmtarget, G3_method_handle);
5416
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   908
      __ jump_to_method_handle_entry(G3_method_handle, O1_scratch);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   909
    }
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   910
    break;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   911
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   912
  case _adapter_drop_args:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   913
    {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   914
      // 'argslot' is the position of the first argument to nuke.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   915
      __ ldsw(G3_amh_vmargslot, O0_argslot);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   916
      __ add(Gargs, __ argument_offset(O0_argslot), O0_argslot);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   917
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   918
      // 'stack_move' is number of words to drop.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   919
      Register G5_stack_move = G5_index;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   920
      __ ldsw(G3_amh_conversion, G5_stack_move);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   921
      __ sra(G5_stack_move, CONV_STACK_MOVE_SHIFT, G5_stack_move);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   922
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   923
      remove_arg_slots(_masm, G5_stack_move, O0_argslot, O1_scratch, O2_scratch, O3_scratch);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   924
6772
2563324665d5 6829194: JSR 292 needs to support compressed oops
twisti
parents: 5702
diff changeset
   925
      __ load_heap_oop(G3_mh_vmtarget, G3_method_handle);
5416
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   926
      __ jump_to_method_handle_entry(G3_method_handle, O1_scratch);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   927
    }
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   928
    break;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   929
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   930
  case _adapter_collect_args:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   931
    __ unimplemented(entry_name(ek)); // %%% FIXME: NYI
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   932
    break;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   933
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   934
  case _adapter_spread_args:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   935
    // Handled completely by optimized cases.
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   936
    __ stop("init_AdapterMethodHandle should not issue this");
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   937
    break;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   938
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   939
  case _adapter_opt_spread_0:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   940
  case _adapter_opt_spread_1:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   941
  case _adapter_opt_spread_more:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   942
    {
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   943
      // spread an array out into a group of arguments
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   944
      __ unimplemented(entry_name(ek));
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   945
    }
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   946
    break;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   947
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   948
  case _adapter_flyby:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   949
  case _adapter_ricochet:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   950
    __ unimplemented(entry_name(ek)); // %%% FIXME: NYI
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   951
    break;
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   952
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   953
  default:
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   954
    ShouldNotReachHere();
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   955
  }
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   956
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   957
  address me_cookie = MethodHandleEntry::start_compiled_entry(_masm, interp_entry);
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   958
  __ unimplemented(entry_name(ek)); // %%% FIXME: NYI
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   959
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 2534
diff changeset
   960
  init_entry(ek, MethodHandleEntry::finish_compiled_entry(_masm, me_cookie));
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   961
}