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