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