src/cpu/sparc/vm/methodHandles_sparc.cpp

Thu, 07 Oct 2010 15:12:57 -0400

author
bobv
date
Thu, 07 Oct 2010 15:12:57 -0400
changeset 2223
3dc12ef8735e
parent 1934
e9ff18c4ace7
child 2201
d55217dc206f
permissions
-rw-r--r--

6989297: Integrate additional portability improvements
Reviewed-by: vladidan, dholmes

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

mercurial