author | twisti |
Thu, 29 Apr 2010 06:30:25 -0700 | |
changeset 5416 | 5f6377fcfd3e |
parent 5095 | 06b1faf0df9c |
child 5419 | f2e8cc8c12ea |
permissions | -rw-r--r-- |
2534 | 1 |
/* |
5044
7e40acdf2163
6932536: JSR 292 modified JDK MethodHandlesTest fails on x86_64
twisti
parents:
5028
diff
changeset
|
2 |
* Copyright 1997-2010 Sun Microsystems, Inc. All Rights Reserved. |
2534 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
|
21 |
* have any questions. |
|
22 |
* |
|
23 |
*/ |
|
24 |
||
25 |
#include "incls/_precompiled.incl" |
|
26 |
#include "incls/_methodHandles_x86.cpp.incl" |
|
27 |
||
28 |
#define __ _masm-> |
|
29 |
||
30 |
address MethodHandleEntry::start_compiled_entry(MacroAssembler* _masm, |
|
31 |
address interpreted_entry) { |
|
32 |
// Just before the actual machine code entry point, allocate space |
|
33 |
// for a MethodHandleEntry::Data record, so that we can manage everything |
|
34 |
// from one base pointer. |
|
35 |
__ align(wordSize); |
|
36 |
address target = __ pc() + sizeof(Data); |
|
37 |
while (__ pc() < target) { |
|
38 |
__ nop(); |
|
39 |
__ align(wordSize); |
|
40 |
} |
|
41 |
||
42 |
MethodHandleEntry* me = (MethodHandleEntry*) __ pc(); |
|
43 |
me->set_end_address(__ pc()); // set a temporary end_address |
|
44 |
me->set_from_interpreted_entry(interpreted_entry); |
|
45 |
me->set_type_checking_entry(NULL); |
|
46 |
||
47 |
return (address) me; |
|
48 |
} |
|
49 |
||
50 |
MethodHandleEntry* MethodHandleEntry::finish_compiled_entry(MacroAssembler* _masm, |
|
51 |
address start_addr) { |
|
52 |
MethodHandleEntry* me = (MethodHandleEntry*) start_addr; |
|
53 |
assert(me->end_address() == start_addr, "valid ME"); |
|
54 |
||
55 |
// Fill in the real end_address: |
|
56 |
__ align(wordSize); |
|
57 |
me->set_end_address(__ pc()); |
|
58 |
||
59 |
return me; |
|
60 |
} |
|
61 |
||
62 |
#ifdef ASSERT |
|
5055 | 63 |
static void verify_argslot(MacroAssembler* _masm, Register argslot_reg, |
2534 | 64 |
const char* error_message) { |
65 |
// Verify that argslot lies within (rsp, rbp]. |
|
66 |
Label L_ok, L_bad; |
|
5055 | 67 |
__ cmpptr(argslot_reg, rbp); |
4564
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4562
diff
changeset
|
68 |
__ jccb(Assembler::above, L_bad); |
5055 | 69 |
__ cmpptr(rsp, argslot_reg); |
4564
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4562
diff
changeset
|
70 |
__ jccb(Assembler::below, L_ok); |
2534 | 71 |
__ bind(L_bad); |
72 |
__ stop(error_message); |
|
73 |
__ bind(L_ok); |
|
74 |
} |
|
75 |
#endif |
|
76 |
||
77 |
||
78 |
// Code generation |
|
79 |
address MethodHandles::generate_method_handle_interpreter_entry(MacroAssembler* _masm) { |
|
80 |
// rbx: methodOop |
|
81 |
// rcx: receiver method handle (must load from sp[MethodTypeForm.vmslots]) |
|
82 |
// rsi/r13: sender SP (must preserve; see prepare_to_jump_from_interpreted) |
|
83 |
// rdx: garbage temp, blown away |
|
84 |
||
85 |
Register rbx_method = rbx; |
|
86 |
Register rcx_recv = rcx; |
|
87 |
Register rax_mtype = rax; |
|
88 |
Register rdx_temp = rdx; |
|
89 |
||
90 |
// emit WrongMethodType path first, to enable jccb back-branch from main path |
|
91 |
Label wrong_method_type; |
|
92 |
__ bind(wrong_method_type); |
|
93 |
__ push(rax_mtype); // required mtype |
|
94 |
__ push(rcx_recv); // bad mh (1st stacked argument) |
|
95 |
__ jump(ExternalAddress(Interpreter::throw_WrongMethodType_entry())); |
|
96 |
||
97 |
// here's where control starts out: |
|
98 |
__ align(CodeEntryAlignment); |
|
99 |
address entry_point = __ pc(); |
|
100 |
||
101 |
// fetch the MethodType from the method handle into rax (the 'check' register) |
|
102 |
{ |
|
103 |
Register tem = rbx_method; |
|
104 |
for (jint* pchase = methodOopDesc::method_type_offsets_chain(); (*pchase) != -1; pchase++) { |
|
105 |
__ movptr(rax_mtype, Address(tem, *pchase)); |
|
106 |
tem = rax_mtype; // in case there is another indirection |
|
107 |
} |
|
108 |
} |
|
109 |
Register rbx_temp = rbx_method; // done with incoming methodOop |
|
110 |
||
111 |
// given the MethodType, find out where the MH argument is buried |
|
112 |
__ movptr(rdx_temp, Address(rax_mtype, |
|
113 |
__ delayed_value(java_dyn_MethodType::form_offset_in_bytes, rbx_temp))); |
|
114 |
__ movl(rdx_temp, Address(rdx_temp, |
|
115 |
__ delayed_value(java_dyn_MethodTypeForm::vmslots_offset_in_bytes, rbx_temp))); |
|
116 |
__ movptr(rcx_recv, __ argument_address(rdx_temp)); |
|
117 |
||
118 |
__ check_method_handle_type(rax_mtype, rcx_recv, rdx_temp, wrong_method_type); |
|
119 |
__ jump_to_method_handle_entry(rcx_recv, rdx_temp); |
|
120 |
||
121 |
return entry_point; |
|
122 |
} |
|
123 |
||
124 |
// Helper to insert argument slots into the stack. |
|
125 |
// arg_slots must be a multiple of stack_move_unit() and <= 0 |
|
126 |
void MethodHandles::insert_arg_slots(MacroAssembler* _masm, |
|
127 |
RegisterOrConstant arg_slots, |
|
128 |
int arg_mask, |
|
129 |
Register rax_argslot, |
|
5416 | 130 |
Register rbx_temp, Register rdx_temp, Register temp3_reg) { |
131 |
assert(temp3_reg == noreg, "temp3 not required"); |
|
2534 | 132 |
assert_different_registers(rax_argslot, rbx_temp, rdx_temp, |
133 |
(!arg_slots.is_register() ? rsp : arg_slots.as_register())); |
|
134 |
||
135 |
#ifdef ASSERT |
|
136 |
verify_argslot(_masm, rax_argslot, "insertion point must fall within current frame"); |
|
137 |
if (arg_slots.is_register()) { |
|
138 |
Label L_ok, L_bad; |
|
139 |
__ cmpptr(arg_slots.as_register(), (int32_t) NULL_WORD); |
|
4564
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4562
diff
changeset
|
140 |
__ jccb(Assembler::greater, L_bad); |
2534 | 141 |
__ testl(arg_slots.as_register(), -stack_move_unit() - 1); |
4564
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4562
diff
changeset
|
142 |
__ jccb(Assembler::zero, L_ok); |
2534 | 143 |
__ bind(L_bad); |
144 |
__ stop("assert arg_slots <= 0 and clear low bits"); |
|
145 |
__ bind(L_ok); |
|
146 |
} else { |
|
147 |
assert(arg_slots.as_constant() <= 0, ""); |
|
148 |
assert(arg_slots.as_constant() % -stack_move_unit() == 0, ""); |
|
149 |
} |
|
150 |
#endif //ASSERT |
|
151 |
||
152 |
#ifdef _LP64 |
|
153 |
if (arg_slots.is_register()) { |
|
154 |
// clean high bits of stack motion register (was loaded as an int) |
|
155 |
__ movslq(arg_slots.as_register(), arg_slots.as_register()); |
|
156 |
} |
|
157 |
#endif |
|
158 |
||
159 |
// Make space on the stack for the inserted argument(s). |
|
160 |
// Then pull down everything shallower than rax_argslot. |
|
161 |
// The stacked return address gets pulled down with everything else. |
|
162 |
// That is, copy [rsp, argslot) downward by -size words. In pseudo-code: |
|
163 |
// rsp -= size; |
|
164 |
// for (rdx = rsp + size; rdx < argslot; rdx++) |
|
165 |
// rdx[-size] = rdx[0] |
|
166 |
// argslot -= size; |
|
167 |
__ mov(rdx_temp, rsp); // source pointer for copy |
|
168 |
__ lea(rsp, Address(rsp, arg_slots, Address::times_ptr)); |
|
169 |
{ |
|
170 |
Label loop; |
|
171 |
__ bind(loop); |
|
172 |
// pull one word down each time through the loop |
|
173 |
__ movptr(rbx_temp, Address(rdx_temp, 0)); |
|
174 |
__ movptr(Address(rdx_temp, arg_slots, Address::times_ptr), rbx_temp); |
|
175 |
__ addptr(rdx_temp, wordSize); |
|
176 |
__ cmpptr(rdx_temp, rax_argslot); |
|
4564
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4562
diff
changeset
|
177 |
__ jccb(Assembler::less, loop); |
2534 | 178 |
} |
179 |
||
180 |
// Now move the argslot down, to point to the opened-up space. |
|
181 |
__ lea(rax_argslot, Address(rax_argslot, arg_slots, Address::times_ptr)); |
|
182 |
} |
|
183 |
||
184 |
// Helper to remove argument slots from the stack. |
|
185 |
// arg_slots must be a multiple of stack_move_unit() and >= 0 |
|
186 |
void MethodHandles::remove_arg_slots(MacroAssembler* _masm, |
|
187 |
RegisterOrConstant arg_slots, |
|
188 |
Register rax_argslot, |
|
5416 | 189 |
Register rbx_temp, Register rdx_temp, Register temp3_reg) { |
190 |
assert(temp3_reg == noreg, "temp3 not required"); |
|
2534 | 191 |
assert_different_registers(rax_argslot, rbx_temp, rdx_temp, |
192 |
(!arg_slots.is_register() ? rsp : arg_slots.as_register())); |
|
193 |
||
194 |
#ifdef ASSERT |
|
5055 | 195 |
// Verify that [argslot..argslot+size) lies within (rsp, rbp). |
196 |
__ lea(rbx_temp, Address(rax_argslot, arg_slots, Address::times_ptr)); |
|
197 |
verify_argslot(_masm, rbx_temp, "deleted argument(s) must fall within current frame"); |
|
2534 | 198 |
if (arg_slots.is_register()) { |
199 |
Label L_ok, L_bad; |
|
200 |
__ cmpptr(arg_slots.as_register(), (int32_t) NULL_WORD); |
|
4564
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4562
diff
changeset
|
201 |
__ jccb(Assembler::less, L_bad); |
2534 | 202 |
__ testl(arg_slots.as_register(), -stack_move_unit() - 1); |
4564
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4562
diff
changeset
|
203 |
__ jccb(Assembler::zero, L_ok); |
2534 | 204 |
__ bind(L_bad); |
205 |
__ stop("assert arg_slots >= 0 and clear low bits"); |
|
206 |
__ bind(L_ok); |
|
207 |
} else { |
|
208 |
assert(arg_slots.as_constant() >= 0, ""); |
|
209 |
assert(arg_slots.as_constant() % -stack_move_unit() == 0, ""); |
|
210 |
} |
|
211 |
#endif //ASSERT |
|
212 |
||
213 |
#ifdef _LP64 |
|
214 |
if (false) { // not needed, since register is positive |
|
215 |
// clean high bits of stack motion register (was loaded as an int) |
|
216 |
if (arg_slots.is_register()) |
|
217 |
__ movslq(arg_slots.as_register(), arg_slots.as_register()); |
|
218 |
} |
|
219 |
#endif |
|
220 |
||
221 |
// Pull up everything shallower than rax_argslot. |
|
222 |
// Then remove the excess space on the stack. |
|
223 |
// The stacked return address gets pulled up with everything else. |
|
224 |
// That is, copy [rsp, argslot) upward by size words. In pseudo-code: |
|
225 |
// for (rdx = argslot-1; rdx >= rsp; --rdx) |
|
226 |
// rdx[size] = rdx[0] |
|
227 |
// argslot += size; |
|
228 |
// rsp += size; |
|
229 |
__ lea(rdx_temp, Address(rax_argslot, -wordSize)); // source pointer for copy |
|
230 |
{ |
|
231 |
Label loop; |
|
232 |
__ bind(loop); |
|
233 |
// pull one word up each time through the loop |
|
234 |
__ movptr(rbx_temp, Address(rdx_temp, 0)); |
|
235 |
__ movptr(Address(rdx_temp, arg_slots, Address::times_ptr), rbx_temp); |
|
236 |
__ addptr(rdx_temp, -wordSize); |
|
237 |
__ cmpptr(rdx_temp, rsp); |
|
4564
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4562
diff
changeset
|
238 |
__ jccb(Assembler::greaterEqual, loop); |
2534 | 239 |
} |
240 |
||
241 |
// Now move the argslot up, to point to the just-copied block. |
|
242 |
__ lea(rsp, Address(rsp, arg_slots, Address::times_ptr)); |
|
243 |
// And adjust the argslot address to point at the deletion point. |
|
244 |
__ lea(rax_argslot, Address(rax_argslot, arg_slots, Address::times_ptr)); |
|
245 |
} |
|
246 |
||
247 |
#ifndef PRODUCT |
|
4562
5d93cb2d2090
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
4478
diff
changeset
|
248 |
extern "C" void print_method_handle(oop mh); |
2534 | 249 |
void trace_method_handle_stub(const char* adaptername, |
4562
5d93cb2d2090
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
4478
diff
changeset
|
250 |
oop mh, |
2534 | 251 |
intptr_t* entry_sp, |
4094
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
252 |
intptr_t* saved_sp, |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
253 |
intptr_t* saved_bp) { |
2534 | 254 |
// called as a leaf from native code: do not block the JVM! |
4094
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
255 |
intptr_t* last_sp = (intptr_t*) saved_bp[frame::interpreter_frame_last_sp_offset]; |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
256 |
intptr_t* base_sp = (intptr_t*) saved_bp[frame::interpreter_frame_monitor_block_top_offset]; |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
257 |
printf("MH %s mh="INTPTR_FORMAT" sp=("INTPTR_FORMAT"+"INTX_FORMAT") stack_size="INTX_FORMAT" bp="INTPTR_FORMAT"\n", |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
258 |
adaptername, (intptr_t)mh, (intptr_t)entry_sp, (intptr_t)(saved_sp - entry_sp), (intptr_t)(base_sp - last_sp), (intptr_t)saved_bp); |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
259 |
if (last_sp != saved_sp) |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
260 |
printf("*** last_sp="INTPTR_FORMAT"\n", (intptr_t)last_sp); |
4562
5d93cb2d2090
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
4478
diff
changeset
|
261 |
if (Verbose) print_method_handle(mh); |
2534 | 262 |
} |
263 |
#endif //PRODUCT |
|
264 |
||
265 |
// Generate an "entry" field for a method handle. |
|
266 |
// This determines how the method handle will respond to calls. |
|
267 |
void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHandles::EntryKind ek) { |
|
268 |
// Here is the register state during an interpreted call, |
|
269 |
// as set up by generate_method_handle_interpreter_entry(): |
|
270 |
// - rbx: garbage temp (was MethodHandle.invoke methodOop, unused) |
|
271 |
// - rcx: receiver method handle |
|
272 |
// - rax: method handle type (only used by the check_mtype entry point) |
|
273 |
// - rsi/r13: sender SP (must preserve; see prepare_to_jump_from_interpreted) |
|
274 |
// - rdx: garbage temp, can blow away |
|
275 |
||
276 |
Register rcx_recv = rcx; |
|
277 |
Register rax_argslot = rax; |
|
278 |
Register rbx_temp = rbx; |
|
279 |
Register rdx_temp = rdx; |
|
280 |
||
4094
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
281 |
// This guy is set up by prepare_to_jump_from_interpreted (from interpreted calls) |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
282 |
// and gen_c2i_adapter (from compiled calls): |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
283 |
Register saved_last_sp = LP64_ONLY(r13) NOT_LP64(rsi); |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
284 |
|
2534 | 285 |
guarantee(java_dyn_MethodHandle::vmentry_offset_in_bytes() != 0, "must have offsets"); |
286 |
||
287 |
// some handy addresses |
|
288 |
Address rbx_method_fie( rbx, methodOopDesc::from_interpreted_offset() ); |
|
289 |
||
290 |
Address rcx_mh_vmtarget( rcx_recv, java_dyn_MethodHandle::vmtarget_offset_in_bytes() ); |
|
291 |
Address rcx_dmh_vmindex( rcx_recv, sun_dyn_DirectMethodHandle::vmindex_offset_in_bytes() ); |
|
292 |
||
293 |
Address rcx_bmh_vmargslot( rcx_recv, sun_dyn_BoundMethodHandle::vmargslot_offset_in_bytes() ); |
|
294 |
Address rcx_bmh_argument( rcx_recv, sun_dyn_BoundMethodHandle::argument_offset_in_bytes() ); |
|
295 |
||
296 |
Address rcx_amh_vmargslot( rcx_recv, sun_dyn_AdapterMethodHandle::vmargslot_offset_in_bytes() ); |
|
297 |
Address rcx_amh_argument( rcx_recv, sun_dyn_AdapterMethodHandle::argument_offset_in_bytes() ); |
|
298 |
Address rcx_amh_conversion( rcx_recv, sun_dyn_AdapterMethodHandle::conversion_offset_in_bytes() ); |
|
299 |
Address vmarg; // __ argument_address(vmargslot) |
|
300 |
||
4094
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
301 |
const int java_mirror_offset = klassOopDesc::klass_part_offset_in_bytes() + Klass::java_mirror_offset_in_bytes(); |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
302 |
|
2534 | 303 |
if (have_entry(ek)) { |
304 |
__ nop(); // empty stubs make SG sick |
|
305 |
return; |
|
306 |
} |
|
307 |
||
308 |
address interp_entry = __ pc(); |
|
309 |
if (UseCompressedOops) __ unimplemented("UseCompressedOops"); |
|
310 |
||
311 |
#ifndef PRODUCT |
|
312 |
if (TraceMethodHandles) { |
|
313 |
__ push(rax); __ push(rbx); __ push(rcx); __ push(rdx); __ push(rsi); __ push(rdi); |
|
314 |
__ lea(rax, Address(rsp, wordSize*6)); // entry_sp |
|
315 |
// arguments: |
|
4094
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
316 |
__ push(rbp); // interpreter frame pointer |
2534 | 317 |
__ push(rsi); // saved_sp |
318 |
__ push(rax); // entry_sp |
|
319 |
__ push(rcx); // mh |
|
320 |
__ push(rcx); |
|
321 |
__ movptr(Address(rsp, 0), (intptr_t)entry_name(ek)); |
|
4094
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
322 |
__ call_VM_leaf(CAST_FROM_FN_PTR(address, trace_method_handle_stub), 5); |
2534 | 323 |
__ pop(rdi); __ pop(rsi); __ pop(rdx); __ pop(rcx); __ pop(rbx); __ pop(rax); |
324 |
} |
|
325 |
#endif //PRODUCT |
|
326 |
||
327 |
switch ((int) ek) { |
|
4094
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
328 |
case _raise_exception: |
2534 | 329 |
{ |
4094
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
330 |
// Not a real MH entry, but rather shared code for raising an exception. |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
331 |
// Extra local arguments are pushed on stack, as required type at TOS+8, |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
332 |
// failing object (or NULL) at TOS+4, failing bytecode type at TOS. |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
333 |
// Beyond those local arguments are the PC, of course. |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
334 |
Register rdx_code = rdx_temp; |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
335 |
Register rcx_fail = rcx_recv; |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
336 |
Register rax_want = rax_argslot; |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
337 |
Register rdi_pc = rdi; |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
338 |
__ pop(rdx_code); // TOS+0 |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
339 |
__ pop(rcx_fail); // TOS+4 |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
340 |
__ pop(rax_want); // TOS+8 |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
341 |
__ pop(rdi_pc); // caller PC |
2534 | 342 |
|
4094
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
343 |
__ mov(rsp, rsi); // cut the stack back to where the caller started |
2534 | 344 |
|
4094
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
345 |
// Repush the arguments as if coming from the interpreter. |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
346 |
__ push(rdx_code); |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
347 |
__ push(rcx_fail); |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
348 |
__ push(rax_want); |
2534 | 349 |
|
4094
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
350 |
Register rbx_method = rbx_temp; |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
351 |
Label no_method; |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
352 |
// FIXME: fill in _raise_exception_method with a suitable sun.dyn method |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
353 |
__ movptr(rbx_method, ExternalAddress((address) &_raise_exception_method)); |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
354 |
__ testptr(rbx_method, rbx_method); |
4564
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4562
diff
changeset
|
355 |
__ jccb(Assembler::zero, no_method); |
4094
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
356 |
int jobject_oop_offset = 0; |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
357 |
__ movptr(rbx_method, Address(rbx_method, jobject_oop_offset)); // dereference the jobject |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
358 |
__ testptr(rbx_method, rbx_method); |
4564
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4562
diff
changeset
|
359 |
__ jccb(Assembler::zero, no_method); |
4094
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
360 |
__ verify_oop(rbx_method); |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
361 |
__ push(rdi_pc); // and restore caller PC |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
362 |
__ jmp(rbx_method_fie); |
2534 | 363 |
|
4094
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
364 |
// If we get here, the Java runtime did not do its job of creating the exception. |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
365 |
// Do something that is at least causes a valid throw from the interpreter. |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
366 |
__ bind(no_method); |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
367 |
__ pop(rax_want); |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
368 |
__ pop(rcx_fail); |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
369 |
__ push(rax_want); |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
370 |
__ push(rcx_fail); |
2534 | 371 |
__ jump(ExternalAddress(Interpreter::throw_WrongMethodType_entry())); |
372 |
} |
|
373 |
break; |
|
374 |
||
375 |
case _invokestatic_mh: |
|
376 |
case _invokespecial_mh: |
|
377 |
{ |
|
378 |
Register rbx_method = rbx_temp; |
|
379 |
__ movptr(rbx_method, rcx_mh_vmtarget); // target is a methodOop |
|
380 |
__ verify_oop(rbx_method); |
|
381 |
// same as TemplateTable::invokestatic or invokespecial, |
|
382 |
// minus the CP setup and profiling: |
|
383 |
if (ek == _invokespecial_mh) { |
|
384 |
// Must load & check the first argument before entering the target method. |
|
385 |
__ load_method_handle_vmslots(rax_argslot, rcx_recv, rdx_temp); |
|
386 |
__ movptr(rcx_recv, __ argument_address(rax_argslot, -1)); |
|
387 |
__ null_check(rcx_recv); |
|
388 |
__ verify_oop(rcx_recv); |
|
389 |
} |
|
390 |
__ jmp(rbx_method_fie); |
|
391 |
} |
|
392 |
break; |
|
393 |
||
394 |
case _invokevirtual_mh: |
|
395 |
{ |
|
396 |
// same as TemplateTable::invokevirtual, |
|
397 |
// minus the CP setup and profiling: |
|
398 |
||
399 |
// pick out the vtable index and receiver offset from the MH, |
|
400 |
// and then we can discard it: |
|
401 |
__ load_method_handle_vmslots(rax_argslot, rcx_recv, rdx_temp); |
|
402 |
Register rbx_index = rbx_temp; |
|
403 |
__ movl(rbx_index, rcx_dmh_vmindex); |
|
404 |
// Note: The verifier allows us to ignore rcx_mh_vmtarget. |
|
405 |
__ movptr(rcx_recv, __ argument_address(rax_argslot, -1)); |
|
406 |
__ null_check(rcx_recv, oopDesc::klass_offset_in_bytes()); |
|
407 |
||
408 |
// get receiver klass |
|
409 |
Register rax_klass = rax_argslot; |
|
410 |
__ load_klass(rax_klass, rcx_recv); |
|
411 |
__ verify_oop(rax_klass); |
|
412 |
||
413 |
// get target methodOop & entry point |
|
414 |
const int base = instanceKlass::vtable_start_offset() * wordSize; |
|
415 |
assert(vtableEntry::size() * wordSize == wordSize, "adjust the scaling in the code below"); |
|
416 |
Address vtable_entry_addr(rax_klass, |
|
417 |
rbx_index, Address::times_ptr, |
|
418 |
base + vtableEntry::method_offset_in_bytes()); |
|
419 |
Register rbx_method = rbx_temp; |
|
4478 | 420 |
__ movptr(rbx_method, vtable_entry_addr); |
2534 | 421 |
|
422 |
__ verify_oop(rbx_method); |
|
423 |
__ jmp(rbx_method_fie); |
|
424 |
} |
|
425 |
break; |
|
426 |
||
427 |
case _invokeinterface_mh: |
|
428 |
{ |
|
429 |
// same as TemplateTable::invokeinterface, |
|
430 |
// minus the CP setup and profiling: |
|
431 |
||
432 |
// pick out the interface and itable index from the MH. |
|
433 |
__ load_method_handle_vmslots(rax_argslot, rcx_recv, rdx_temp); |
|
434 |
Register rdx_intf = rdx_temp; |
|
435 |
Register rbx_index = rbx_temp; |
|
436 |
__ movptr(rdx_intf, rcx_mh_vmtarget); |
|
437 |
__ movl(rbx_index, rcx_dmh_vmindex); |
|
438 |
__ movptr(rcx_recv, __ argument_address(rax_argslot, -1)); |
|
439 |
__ null_check(rcx_recv, oopDesc::klass_offset_in_bytes()); |
|
440 |
||
441 |
// get receiver klass |
|
442 |
Register rax_klass = rax_argslot; |
|
443 |
__ load_klass(rax_klass, rcx_recv); |
|
444 |
__ verify_oop(rax_klass); |
|
445 |
||
4094
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
446 |
Register rdi_temp = rdi; |
2534 | 447 |
Register rbx_method = rbx_index; |
448 |
||
449 |
// get interface klass |
|
450 |
Label no_such_interface; |
|
451 |
__ verify_oop(rdx_intf); |
|
452 |
__ lookup_interface_method(rax_klass, rdx_intf, |
|
453 |
// note: next two args must be the same: |
|
454 |
rbx_index, rbx_method, |
|
4094
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
455 |
rdi_temp, |
2534 | 456 |
no_such_interface); |
457 |
||
458 |
__ verify_oop(rbx_method); |
|
459 |
__ jmp(rbx_method_fie); |
|
460 |
__ hlt(); |
|
461 |
||
462 |
__ bind(no_such_interface); |
|
463 |
// Throw an exception. |
|
464 |
// For historical reasons, it will be IncompatibleClassChangeError. |
|
4094
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
465 |
__ pushptr(Address(rdx_intf, java_mirror_offset)); // required interface |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
466 |
__ push(rcx_recv); // bad receiver |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
467 |
__ push((int)Bytecodes::_invokeinterface); // who is complaining? |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
468 |
__ jump(ExternalAddress(from_interpreted_entry(_raise_exception))); |
2534 | 469 |
} |
470 |
break; |
|
471 |
||
472 |
case _bound_ref_mh: |
|
473 |
case _bound_int_mh: |
|
474 |
case _bound_long_mh: |
|
475 |
case _bound_ref_direct_mh: |
|
476 |
case _bound_int_direct_mh: |
|
477 |
case _bound_long_direct_mh: |
|
478 |
{ |
|
479 |
bool direct_to_method = (ek >= _bound_ref_direct_mh); |
|
5055 | 480 |
BasicType arg_type = T_ILLEGAL; |
481 |
int arg_mask = _INSERT_NO_MASK; |
|
482 |
int arg_slots = -1; |
|
483 |
get_ek_bound_mh_info(ek, arg_type, arg_mask, arg_slots); |
|
2534 | 484 |
|
485 |
// make room for the new argument: |
|
486 |
__ movl(rax_argslot, rcx_bmh_vmargslot); |
|
487 |
__ lea(rax_argslot, __ argument_address(rax_argslot)); |
|
488 |
insert_arg_slots(_masm, arg_slots * stack_move_unit(), arg_mask, |
|
489 |
rax_argslot, rbx_temp, rdx_temp); |
|
490 |
||
491 |
// store bound argument into the new stack slot: |
|
492 |
__ movptr(rbx_temp, rcx_bmh_argument); |
|
493 |
Address prim_value_addr(rbx_temp, java_lang_boxing_object::value_offset_in_bytes(arg_type)); |
|
494 |
if (arg_type == T_OBJECT) { |
|
495 |
__ movptr(Address(rax_argslot, 0), rbx_temp); |
|
496 |
} else { |
|
4564
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4562
diff
changeset
|
497 |
__ load_sized_value(rdx_temp, prim_value_addr, |
2534 | 498 |
type2aelembytes(arg_type), is_signed_subword_type(arg_type)); |
4564
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4562
diff
changeset
|
499 |
__ movptr(Address(rax_argslot, 0), rdx_temp); |
2534 | 500 |
#ifndef _LP64 |
501 |
if (arg_slots == 2) { |
|
4564
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4562
diff
changeset
|
502 |
__ movl(rdx_temp, prim_value_addr.plus_disp(wordSize)); |
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4562
diff
changeset
|
503 |
__ movl(Address(rax_argslot, Interpreter::stackElementSize()), rdx_temp); |
2534 | 504 |
} |
505 |
#endif //_LP64 |
|
506 |
} |
|
507 |
||
508 |
if (direct_to_method) { |
|
509 |
Register rbx_method = rbx_temp; |
|
510 |
__ movptr(rbx_method, rcx_mh_vmtarget); |
|
511 |
__ verify_oop(rbx_method); |
|
512 |
__ jmp(rbx_method_fie); |
|
513 |
} else { |
|
514 |
__ movptr(rcx_recv, rcx_mh_vmtarget); |
|
515 |
__ verify_oop(rcx_recv); |
|
516 |
__ jump_to_method_handle_entry(rcx_recv, rdx_temp); |
|
517 |
} |
|
518 |
} |
|
519 |
break; |
|
520 |
||
521 |
case _adapter_retype_only: |
|
4094
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
522 |
case _adapter_retype_raw: |
2534 | 523 |
// immediately jump to the next MH layer: |
524 |
__ movptr(rcx_recv, rcx_mh_vmtarget); |
|
525 |
__ verify_oop(rcx_recv); |
|
526 |
__ jump_to_method_handle_entry(rcx_recv, rdx_temp); |
|
527 |
// This is OK when all parameter types widen. |
|
528 |
// It is also OK when a return type narrows. |
|
529 |
break; |
|
530 |
||
531 |
case _adapter_check_cast: |
|
532 |
{ |
|
533 |
// temps: |
|
534 |
Register rbx_klass = rbx_temp; // interesting AMH data |
|
535 |
||
536 |
// check a reference argument before jumping to the next layer of MH: |
|
537 |
__ movl(rax_argslot, rcx_amh_vmargslot); |
|
538 |
vmarg = __ argument_address(rax_argslot); |
|
539 |
||
540 |
// What class are we casting to? |
|
541 |
__ movptr(rbx_klass, rcx_amh_argument); // this is a Class object! |
|
542 |
__ movptr(rbx_klass, Address(rbx_klass, java_lang_Class::klass_offset_in_bytes())); |
|
543 |
||
544 |
Label done; |
|
545 |
__ movptr(rdx_temp, vmarg); |
|
5028 | 546 |
__ testptr(rdx_temp, rdx_temp); |
4564
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4562
diff
changeset
|
547 |
__ jccb(Assembler::zero, done); // no cast if null |
2534 | 548 |
__ load_klass(rdx_temp, rdx_temp); |
549 |
||
550 |
// live at this point: |
|
551 |
// - rbx_klass: klass required by the target method |
|
552 |
// - rdx_temp: argument klass to test |
|
4094
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
553 |
// - rcx_recv: adapter method handle |
2534 | 554 |
__ check_klass_subtype(rdx_temp, rbx_klass, rax_argslot, done); |
555 |
||
556 |
// If we get here, the type check failed! |
|
557 |
// Call the wrong_method_type stub, passing the failing argument type in rax. |
|
558 |
Register rax_mtype = rax_argslot; |
|
4094
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
559 |
__ movl(rax_argslot, rcx_amh_vmargslot); // reload argslot field |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
560 |
__ movptr(rdx_temp, vmarg); |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
561 |
|
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
562 |
__ pushptr(rcx_amh_argument); // required class |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
563 |
__ push(rdx_temp); // bad object |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
564 |
__ push((int)Bytecodes::_checkcast); // who is complaining? |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
565 |
__ jump(ExternalAddress(from_interpreted_entry(_raise_exception))); |
2534 | 566 |
|
567 |
__ bind(done); |
|
4094
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
568 |
// get the new MH: |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
569 |
__ movptr(rcx_recv, rcx_mh_vmtarget); |
2534 | 570 |
__ jump_to_method_handle_entry(rcx_recv, rdx_temp); |
571 |
} |
|
572 |
break; |
|
573 |
||
574 |
case _adapter_prim_to_prim: |
|
575 |
case _adapter_ref_to_prim: |
|
576 |
// handled completely by optimized cases |
|
577 |
__ stop("init_AdapterMethodHandle should not issue this"); |
|
578 |
break; |
|
579 |
||
580 |
case _adapter_opt_i2i: // optimized subcase of adapt_prim_to_prim |
|
581 |
//case _adapter_opt_f2i: // optimized subcase of adapt_prim_to_prim |
|
582 |
case _adapter_opt_l2i: // optimized subcase of adapt_prim_to_prim |
|
583 |
case _adapter_opt_unboxi: // optimized subcase of adapt_ref_to_prim |
|
584 |
{ |
|
585 |
// perform an in-place conversion to int or an int subword |
|
586 |
__ movl(rax_argslot, rcx_amh_vmargslot); |
|
587 |
vmarg = __ argument_address(rax_argslot); |
|
588 |
||
589 |
switch (ek) { |
|
590 |
case _adapter_opt_i2i: |
|
591 |
__ movl(rdx_temp, vmarg); |
|
592 |
break; |
|
593 |
case _adapter_opt_l2i: |
|
594 |
{ |
|
595 |
// just delete the extra slot; on a little-endian machine we keep the first |
|
596 |
__ lea(rax_argslot, __ argument_address(rax_argslot, 1)); |
|
597 |
remove_arg_slots(_masm, -stack_move_unit(), |
|
598 |
rax_argslot, rbx_temp, rdx_temp); |
|
599 |
vmarg = Address(rax_argslot, -Interpreter::stackElementSize()); |
|
600 |
__ movl(rdx_temp, vmarg); |
|
601 |
} |
|
602 |
break; |
|
603 |
case _adapter_opt_unboxi: |
|
604 |
{ |
|
605 |
// Load the value up from the heap. |
|
606 |
__ movptr(rdx_temp, vmarg); |
|
607 |
int value_offset = java_lang_boxing_object::value_offset_in_bytes(T_INT); |
|
608 |
#ifdef ASSERT |
|
609 |
for (int bt = T_BOOLEAN; bt < T_INT; bt++) { |
|
610 |
if (is_subword_type(BasicType(bt))) |
|
611 |
assert(value_offset == java_lang_boxing_object::value_offset_in_bytes(BasicType(bt)), ""); |
|
612 |
} |
|
613 |
#endif |
|
614 |
__ null_check(rdx_temp, value_offset); |
|
615 |
__ movl(rdx_temp, Address(rdx_temp, value_offset)); |
|
616 |
// We load this as a word. Because we are little-endian, |
|
617 |
// the low bits will be correct, but the high bits may need cleaning. |
|
618 |
// The vminfo will guide us to clean those bits. |
|
619 |
} |
|
620 |
break; |
|
621 |
default: |
|
5055 | 622 |
ShouldNotReachHere(); |
2534 | 623 |
} |
624 |
||
5055 | 625 |
// Do the requested conversion and store the value. |
2534 | 626 |
Register rbx_vminfo = rbx_temp; |
627 |
__ movl(rbx_vminfo, rcx_amh_conversion); |
|
628 |
assert(CONV_VMINFO_SHIFT == 0, "preshifted"); |
|
629 |
||
630 |
// get the new MH: |
|
631 |
__ movptr(rcx_recv, rcx_mh_vmtarget); |
|
632 |
// (now we are done with the old MH) |
|
633 |
||
634 |
// original 32-bit vmdata word must be of this form: |
|
4564
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4562
diff
changeset
|
635 |
// | MBZ:6 | signBitCount:8 | srcDstTypes:8 | conversionOp:8 | |
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4562
diff
changeset
|
636 |
__ xchgptr(rcx, rbx_vminfo); // free rcx for shifts |
2534 | 637 |
__ shll(rdx_temp /*, rcx*/); |
638 |
Label zero_extend, done; |
|
639 |
__ testl(rcx, CONV_VMINFO_SIGN_FLAG); |
|
4564
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4562
diff
changeset
|
640 |
__ jccb(Assembler::zero, zero_extend); |
2534 | 641 |
|
642 |
// this path is taken for int->byte, int->short |
|
643 |
__ sarl(rdx_temp /*, rcx*/); |
|
4564
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4562
diff
changeset
|
644 |
__ jmpb(done); |
2534 | 645 |
|
646 |
__ bind(zero_extend); |
|
647 |
// this is taken for int->char |
|
648 |
__ shrl(rdx_temp /*, rcx*/); |
|
649 |
||
650 |
__ bind(done); |
|
5055 | 651 |
__ movl(vmarg, rdx_temp); // Store the value. |
4564
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4562
diff
changeset
|
652 |
__ xchgptr(rcx, rbx_vminfo); // restore rcx_recv |
2534 | 653 |
|
654 |
__ jump_to_method_handle_entry(rcx_recv, rdx_temp); |
|
655 |
} |
|
656 |
break; |
|
657 |
||
658 |
case _adapter_opt_i2l: // optimized subcase of adapt_prim_to_prim |
|
659 |
case _adapter_opt_unboxl: // optimized subcase of adapt_ref_to_prim |
|
660 |
{ |
|
661 |
// perform an in-place int-to-long or ref-to-long conversion |
|
662 |
__ movl(rax_argslot, rcx_amh_vmargslot); |
|
663 |
||
664 |
// on a little-endian machine we keep the first slot and add another after |
|
665 |
__ lea(rax_argslot, __ argument_address(rax_argslot, 1)); |
|
666 |
insert_arg_slots(_masm, stack_move_unit(), _INSERT_INT_MASK, |
|
667 |
rax_argslot, rbx_temp, rdx_temp); |
|
668 |
Address vmarg1(rax_argslot, -Interpreter::stackElementSize()); |
|
669 |
Address vmarg2 = vmarg1.plus_disp(Interpreter::stackElementSize()); |
|
670 |
||
671 |
switch (ek) { |
|
672 |
case _adapter_opt_i2l: |
|
673 |
{ |
|
5044
7e40acdf2163
6932536: JSR 292 modified JDK MethodHandlesTest fails on x86_64
twisti
parents:
5028
diff
changeset
|
674 |
#ifdef _LP64 |
7e40acdf2163
6932536: JSR 292 modified JDK MethodHandlesTest fails on x86_64
twisti
parents:
5028
diff
changeset
|
675 |
__ movslq(rdx_temp, vmarg1); // Load sign-extended |
7e40acdf2163
6932536: JSR 292 modified JDK MethodHandlesTest fails on x86_64
twisti
parents:
5028
diff
changeset
|
676 |
__ movq(vmarg1, rdx_temp); // Store into first slot |
7e40acdf2163
6932536: JSR 292 modified JDK MethodHandlesTest fails on x86_64
twisti
parents:
5028
diff
changeset
|
677 |
#else |
2534 | 678 |
__ movl(rdx_temp, vmarg1); |
5044
7e40acdf2163
6932536: JSR 292 modified JDK MethodHandlesTest fails on x86_64
twisti
parents:
5028
diff
changeset
|
679 |
__ sarl(rdx_temp, BitsPerInt - 1); // __ extend_sign() |
2534 | 680 |
__ movl(vmarg2, rdx_temp); // store second word |
5044
7e40acdf2163
6932536: JSR 292 modified JDK MethodHandlesTest fails on x86_64
twisti
parents:
5028
diff
changeset
|
681 |
#endif |
2534 | 682 |
} |
683 |
break; |
|
684 |
case _adapter_opt_unboxl: |
|
685 |
{ |
|
686 |
// Load the value up from the heap. |
|
687 |
__ movptr(rdx_temp, vmarg1); |
|
688 |
int value_offset = java_lang_boxing_object::value_offset_in_bytes(T_LONG); |
|
689 |
assert(value_offset == java_lang_boxing_object::value_offset_in_bytes(T_DOUBLE), ""); |
|
690 |
__ null_check(rdx_temp, value_offset); |
|
5044
7e40acdf2163
6932536: JSR 292 modified JDK MethodHandlesTest fails on x86_64
twisti
parents:
5028
diff
changeset
|
691 |
#ifdef _LP64 |
7e40acdf2163
6932536: JSR 292 modified JDK MethodHandlesTest fails on x86_64
twisti
parents:
5028
diff
changeset
|
692 |
__ movq(rbx_temp, Address(rdx_temp, value_offset)); |
7e40acdf2163
6932536: JSR 292 modified JDK MethodHandlesTest fails on x86_64
twisti
parents:
5028
diff
changeset
|
693 |
__ movq(vmarg1, rbx_temp); |
7e40acdf2163
6932536: JSR 292 modified JDK MethodHandlesTest fails on x86_64
twisti
parents:
5028
diff
changeset
|
694 |
#else |
2534 | 695 |
__ movl(rbx_temp, Address(rdx_temp, value_offset + 0*BytesPerInt)); |
696 |
__ movl(rdx_temp, Address(rdx_temp, value_offset + 1*BytesPerInt)); |
|
697 |
__ movl(vmarg1, rbx_temp); |
|
698 |
__ movl(vmarg2, rdx_temp); |
|
5044
7e40acdf2163
6932536: JSR 292 modified JDK MethodHandlesTest fails on x86_64
twisti
parents:
5028
diff
changeset
|
699 |
#endif |
2534 | 700 |
} |
701 |
break; |
|
702 |
default: |
|
5055 | 703 |
ShouldNotReachHere(); |
2534 | 704 |
} |
705 |
||
706 |
__ movptr(rcx_recv, rcx_mh_vmtarget); |
|
707 |
__ jump_to_method_handle_entry(rcx_recv, rdx_temp); |
|
708 |
} |
|
709 |
break; |
|
710 |
||
711 |
case _adapter_opt_f2d: // optimized subcase of adapt_prim_to_prim |
|
712 |
case _adapter_opt_d2f: // optimized subcase of adapt_prim_to_prim |
|
713 |
{ |
|
714 |
// perform an in-place floating primitive conversion |
|
715 |
__ movl(rax_argslot, rcx_amh_vmargslot); |
|
716 |
__ lea(rax_argslot, __ argument_address(rax_argslot, 1)); |
|
717 |
if (ek == _adapter_opt_f2d) { |
|
718 |
insert_arg_slots(_masm, stack_move_unit(), _INSERT_INT_MASK, |
|
719 |
rax_argslot, rbx_temp, rdx_temp); |
|
720 |
} |
|
721 |
Address vmarg(rax_argslot, -Interpreter::stackElementSize()); |
|
722 |
||
723 |
#ifdef _LP64 |
|
724 |
if (ek == _adapter_opt_f2d) { |
|
725 |
__ movflt(xmm0, vmarg); |
|
726 |
__ cvtss2sd(xmm0, xmm0); |
|
727 |
__ movdbl(vmarg, xmm0); |
|
728 |
} else { |
|
729 |
__ movdbl(xmm0, vmarg); |
|
730 |
__ cvtsd2ss(xmm0, xmm0); |
|
731 |
__ movflt(vmarg, xmm0); |
|
732 |
} |
|
733 |
#else //_LP64 |
|
734 |
if (ek == _adapter_opt_f2d) { |
|
735 |
__ fld_s(vmarg); // load float to ST0 |
|
736 |
__ fstp_s(vmarg); // store single |
|
5055 | 737 |
} else { |
2534 | 738 |
__ fld_d(vmarg); // load double to ST0 |
739 |
__ fstp_s(vmarg); // store single |
|
740 |
} |
|
741 |
#endif //_LP64 |
|
742 |
||
743 |
if (ek == _adapter_opt_d2f) { |
|
744 |
remove_arg_slots(_masm, -stack_move_unit(), |
|
745 |
rax_argslot, rbx_temp, rdx_temp); |
|
746 |
} |
|
747 |
||
748 |
__ movptr(rcx_recv, rcx_mh_vmtarget); |
|
749 |
__ jump_to_method_handle_entry(rcx_recv, rdx_temp); |
|
750 |
} |
|
751 |
break; |
|
752 |
||
753 |
case _adapter_prim_to_ref: |
|
754 |
__ unimplemented(entry_name(ek)); // %%% FIXME: NYI |
|
755 |
break; |
|
756 |
||
757 |
case _adapter_swap_args: |
|
758 |
case _adapter_rot_args: |
|
759 |
// handled completely by optimized cases |
|
760 |
__ stop("init_AdapterMethodHandle should not issue this"); |
|
761 |
break; |
|
762 |
||
763 |
case _adapter_opt_swap_1: |
|
764 |
case _adapter_opt_swap_2: |
|
765 |
case _adapter_opt_rot_1_up: |
|
766 |
case _adapter_opt_rot_1_down: |
|
767 |
case _adapter_opt_rot_2_up: |
|
768 |
case _adapter_opt_rot_2_down: |
|
769 |
{ |
|
5055 | 770 |
int swap_bytes = 0, rotate = 0; |
771 |
get_ek_adapter_opt_swap_rot_info(ek, swap_bytes, rotate); |
|
2534 | 772 |
|
773 |
// 'argslot' is the position of the first argument to swap |
|
774 |
__ movl(rax_argslot, rcx_amh_vmargslot); |
|
775 |
__ lea(rax_argslot, __ argument_address(rax_argslot)); |
|
776 |
||
777 |
// 'vminfo' is the second |
|
778 |
Register rbx_destslot = rbx_temp; |
|
779 |
__ movl(rbx_destslot, rcx_amh_conversion); |
|
780 |
assert(CONV_VMINFO_SHIFT == 0, "preshifted"); |
|
781 |
__ andl(rbx_destslot, CONV_VMINFO_MASK); |
|
782 |
__ lea(rbx_destslot, __ argument_address(rbx_destslot)); |
|
783 |
DEBUG_ONLY(verify_argslot(_masm, rbx_destslot, "swap point must fall within current frame")); |
|
784 |
||
785 |
if (!rotate) { |
|
786 |
for (int i = 0; i < swap_bytes; i += wordSize) { |
|
787 |
__ movptr(rdx_temp, Address(rax_argslot , i)); |
|
788 |
__ push(rdx_temp); |
|
789 |
__ movptr(rdx_temp, Address(rbx_destslot, i)); |
|
790 |
__ movptr(Address(rax_argslot, i), rdx_temp); |
|
791 |
__ pop(rdx_temp); |
|
792 |
__ movptr(Address(rbx_destslot, i), rdx_temp); |
|
793 |
} |
|
794 |
} else { |
|
795 |
// push the first chunk, which is going to get overwritten |
|
796 |
for (int i = swap_bytes; (i -= wordSize) >= 0; ) { |
|
797 |
__ movptr(rdx_temp, Address(rax_argslot, i)); |
|
798 |
__ push(rdx_temp); |
|
799 |
} |
|
800 |
||
801 |
if (rotate > 0) { |
|
802 |
// rotate upward |
|
803 |
__ subptr(rax_argslot, swap_bytes); |
|
804 |
#ifdef ASSERT |
|
805 |
{ |
|
806 |
// Verify that argslot > destslot, by at least swap_bytes. |
|
807 |
Label L_ok; |
|
808 |
__ cmpptr(rax_argslot, rbx_destslot); |
|
4564
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4562
diff
changeset
|
809 |
__ jccb(Assembler::aboveEqual, L_ok); |
2534 | 810 |
__ stop("source must be above destination (upward rotation)"); |
811 |
__ bind(L_ok); |
|
812 |
} |
|
813 |
#endif |
|
814 |
// work argslot down to destslot, copying contiguous data upwards |
|
815 |
// pseudo-code: |
|
816 |
// rax = src_addr - swap_bytes |
|
817 |
// rbx = dest_addr |
|
818 |
// while (rax >= rbx) *(rax + swap_bytes) = *(rax + 0), rax--; |
|
819 |
Label loop; |
|
820 |
__ bind(loop); |
|
821 |
__ movptr(rdx_temp, Address(rax_argslot, 0)); |
|
822 |
__ movptr(Address(rax_argslot, swap_bytes), rdx_temp); |
|
823 |
__ addptr(rax_argslot, -wordSize); |
|
824 |
__ cmpptr(rax_argslot, rbx_destslot); |
|
4564
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4562
diff
changeset
|
825 |
__ jccb(Assembler::aboveEqual, loop); |
2534 | 826 |
} else { |
827 |
__ addptr(rax_argslot, swap_bytes); |
|
828 |
#ifdef ASSERT |
|
829 |
{ |
|
830 |
// Verify that argslot < destslot, by at least swap_bytes. |
|
831 |
Label L_ok; |
|
832 |
__ cmpptr(rax_argslot, rbx_destslot); |
|
4564
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4562
diff
changeset
|
833 |
__ jccb(Assembler::belowEqual, L_ok); |
2534 | 834 |
__ stop("source must be below destination (downward rotation)"); |
835 |
__ bind(L_ok); |
|
836 |
} |
|
837 |
#endif |
|
838 |
// work argslot up to destslot, copying contiguous data downwards |
|
839 |
// pseudo-code: |
|
840 |
// rax = src_addr + swap_bytes |
|
841 |
// rbx = dest_addr |
|
842 |
// while (rax <= rbx) *(rax - swap_bytes) = *(rax + 0), rax++; |
|
843 |
Label loop; |
|
844 |
__ bind(loop); |
|
845 |
__ movptr(rdx_temp, Address(rax_argslot, 0)); |
|
846 |
__ movptr(Address(rax_argslot, -swap_bytes), rdx_temp); |
|
847 |
__ addptr(rax_argslot, wordSize); |
|
848 |
__ cmpptr(rax_argslot, rbx_destslot); |
|
4564
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4562
diff
changeset
|
849 |
__ jccb(Assembler::belowEqual, loop); |
2534 | 850 |
} |
851 |
||
852 |
// pop the original first chunk into the destination slot, now free |
|
853 |
for (int i = 0; i < swap_bytes; i += wordSize) { |
|
854 |
__ pop(rdx_temp); |
|
855 |
__ movptr(Address(rbx_destslot, i), rdx_temp); |
|
856 |
} |
|
857 |
} |
|
858 |
||
859 |
__ movptr(rcx_recv, rcx_mh_vmtarget); |
|
860 |
__ jump_to_method_handle_entry(rcx_recv, rdx_temp); |
|
861 |
} |
|
862 |
break; |
|
863 |
||
864 |
case _adapter_dup_args: |
|
865 |
{ |
|
866 |
// 'argslot' is the position of the first argument to duplicate |
|
867 |
__ movl(rax_argslot, rcx_amh_vmargslot); |
|
868 |
__ lea(rax_argslot, __ argument_address(rax_argslot)); |
|
869 |
||
870 |
// 'stack_move' is negative number of words to duplicate |
|
871 |
Register rdx_stack_move = rdx_temp; |
|
5044
7e40acdf2163
6932536: JSR 292 modified JDK MethodHandlesTest fails on x86_64
twisti
parents:
5028
diff
changeset
|
872 |
__ movl2ptr(rdx_stack_move, rcx_amh_conversion); |
7e40acdf2163
6932536: JSR 292 modified JDK MethodHandlesTest fails on x86_64
twisti
parents:
5028
diff
changeset
|
873 |
__ sarptr(rdx_stack_move, CONV_STACK_MOVE_SHIFT); |
2534 | 874 |
|
875 |
int argslot0_num = 0; |
|
876 |
Address argslot0 = __ argument_address(RegisterOrConstant(argslot0_num)); |
|
877 |
assert(argslot0.base() == rsp, ""); |
|
878 |
int pre_arg_size = argslot0.disp(); |
|
879 |
assert(pre_arg_size % wordSize == 0, ""); |
|
880 |
assert(pre_arg_size > 0, "must include PC"); |
|
881 |
||
882 |
// remember the old rsp+1 (argslot[0]) |
|
883 |
Register rbx_oldarg = rbx_temp; |
|
884 |
__ lea(rbx_oldarg, argslot0); |
|
885 |
||
886 |
// move rsp down to make room for dups |
|
887 |
__ lea(rsp, Address(rsp, rdx_stack_move, Address::times_ptr)); |
|
888 |
||
889 |
// compute the new rsp+1 (argslot[0]) |
|
890 |
Register rdx_newarg = rdx_temp; |
|
891 |
__ lea(rdx_newarg, argslot0); |
|
892 |
||
893 |
__ push(rdi); // need a temp |
|
894 |
// (preceding push must be done after arg addresses are taken!) |
|
895 |
||
896 |
// pull down the pre_arg_size data (PC) |
|
897 |
for (int i = -pre_arg_size; i < 0; i += wordSize) { |
|
898 |
__ movptr(rdi, Address(rbx_oldarg, i)); |
|
899 |
__ movptr(Address(rdx_newarg, i), rdi); |
|
900 |
} |
|
901 |
||
902 |
// copy from rax_argslot[0...] down to new_rsp[1...] |
|
903 |
// pseudo-code: |
|
904 |
// rbx = old_rsp+1 |
|
905 |
// rdx = new_rsp+1 |
|
906 |
// rax = argslot |
|
907 |
// while (rdx < rbx) *rdx++ = *rax++ |
|
908 |
Label loop; |
|
909 |
__ bind(loop); |
|
910 |
__ movptr(rdi, Address(rax_argslot, 0)); |
|
911 |
__ movptr(Address(rdx_newarg, 0), rdi); |
|
912 |
__ addptr(rax_argslot, wordSize); |
|
913 |
__ addptr(rdx_newarg, wordSize); |
|
914 |
__ cmpptr(rdx_newarg, rbx_oldarg); |
|
4564
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4562
diff
changeset
|
915 |
__ jccb(Assembler::less, loop); |
2534 | 916 |
|
917 |
__ pop(rdi); // restore temp |
|
918 |
||
919 |
__ movptr(rcx_recv, rcx_mh_vmtarget); |
|
920 |
__ jump_to_method_handle_entry(rcx_recv, rdx_temp); |
|
921 |
} |
|
922 |
break; |
|
923 |
||
924 |
case _adapter_drop_args: |
|
925 |
{ |
|
926 |
// 'argslot' is the position of the first argument to nuke |
|
927 |
__ movl(rax_argslot, rcx_amh_vmargslot); |
|
928 |
__ lea(rax_argslot, __ argument_address(rax_argslot)); |
|
929 |
||
930 |
__ push(rdi); // need a temp |
|
931 |
// (must do previous push after argslot address is taken) |
|
932 |
||
933 |
// 'stack_move' is number of words to drop |
|
934 |
Register rdi_stack_move = rdi; |
|
5044
7e40acdf2163
6932536: JSR 292 modified JDK MethodHandlesTest fails on x86_64
twisti
parents:
5028
diff
changeset
|
935 |
__ movl2ptr(rdi_stack_move, rcx_amh_conversion); |
7e40acdf2163
6932536: JSR 292 modified JDK MethodHandlesTest fails on x86_64
twisti
parents:
5028
diff
changeset
|
936 |
__ sarptr(rdi_stack_move, CONV_STACK_MOVE_SHIFT); |
2534 | 937 |
remove_arg_slots(_masm, rdi_stack_move, |
938 |
rax_argslot, rbx_temp, rdx_temp); |
|
939 |
||
940 |
__ pop(rdi); // restore temp |
|
941 |
||
942 |
__ movptr(rcx_recv, rcx_mh_vmtarget); |
|
943 |
__ jump_to_method_handle_entry(rcx_recv, rdx_temp); |
|
944 |
} |
|
945 |
break; |
|
946 |
||
947 |
case _adapter_collect_args: |
|
948 |
__ unimplemented(entry_name(ek)); // %%% FIXME: NYI |
|
949 |
break; |
|
950 |
||
951 |
case _adapter_spread_args: |
|
952 |
// handled completely by optimized cases |
|
953 |
__ stop("init_AdapterMethodHandle should not issue this"); |
|
954 |
break; |
|
955 |
||
956 |
case _adapter_opt_spread_0: |
|
957 |
case _adapter_opt_spread_1: |
|
958 |
case _adapter_opt_spread_more: |
|
959 |
{ |
|
960 |
// spread an array out into a group of arguments |
|
5055 | 961 |
int length_constant = get_ek_adapter_opt_spread_info(ek); |
2534 | 962 |
|
963 |
// find the address of the array argument |
|
964 |
__ movl(rax_argslot, rcx_amh_vmargslot); |
|
965 |
__ lea(rax_argslot, __ argument_address(rax_argslot)); |
|
966 |
||
967 |
// grab some temps |
|
968 |
{ __ push(rsi); __ push(rdi); } |
|
969 |
// (preceding pushes must be done after argslot address is taken!) |
|
970 |
#define UNPUSH_RSI_RDI \ |
|
971 |
{ __ pop(rdi); __ pop(rsi); } |
|
972 |
||
973 |
// arx_argslot points both to the array and to the first output arg |
|
974 |
vmarg = Address(rax_argslot, 0); |
|
975 |
||
976 |
// Get the array value. |
|
977 |
Register rsi_array = rsi; |
|
978 |
Register rdx_array_klass = rdx_temp; |
|
979 |
BasicType elem_type = T_OBJECT; |
|
980 |
int length_offset = arrayOopDesc::length_offset_in_bytes(); |
|
981 |
int elem0_offset = arrayOopDesc::base_offset_in_bytes(elem_type); |
|
982 |
__ movptr(rsi_array, vmarg); |
|
983 |
Label skip_array_check; |
|
984 |
if (length_constant == 0) { |
|
985 |
__ testptr(rsi_array, rsi_array); |
|
986 |
__ jcc(Assembler::zero, skip_array_check); |
|
987 |
} |
|
988 |
__ null_check(rsi_array, oopDesc::klass_offset_in_bytes()); |
|
989 |
__ load_klass(rdx_array_klass, rsi_array); |
|
990 |
||
991 |
// Check the array type. |
|
992 |
Register rbx_klass = rbx_temp; |
|
993 |
__ movptr(rbx_klass, rcx_amh_argument); // this is a Class object! |
|
994 |
__ movptr(rbx_klass, Address(rbx_klass, java_lang_Class::klass_offset_in_bytes())); |
|
995 |
||
996 |
Label ok_array_klass, bad_array_klass, bad_array_length; |
|
997 |
__ check_klass_subtype(rdx_array_klass, rbx_klass, rdi, ok_array_klass); |
|
998 |
// If we get here, the type check failed! |
|
999 |
__ jmp(bad_array_klass); |
|
1000 |
__ bind(ok_array_klass); |
|
1001 |
||
1002 |
// Check length. |
|
1003 |
if (length_constant >= 0) { |
|
1004 |
__ cmpl(Address(rsi_array, length_offset), length_constant); |
|
1005 |
} else { |
|
1006 |
Register rbx_vminfo = rbx_temp; |
|
1007 |
__ movl(rbx_vminfo, rcx_amh_conversion); |
|
1008 |
assert(CONV_VMINFO_SHIFT == 0, "preshifted"); |
|
1009 |
__ andl(rbx_vminfo, CONV_VMINFO_MASK); |
|
1010 |
__ cmpl(rbx_vminfo, Address(rsi_array, length_offset)); |
|
1011 |
} |
|
1012 |
__ jcc(Assembler::notEqual, bad_array_length); |
|
1013 |
||
1014 |
Register rdx_argslot_limit = rdx_temp; |
|
1015 |
||
1016 |
// Array length checks out. Now insert any required stack slots. |
|
1017 |
if (length_constant == -1) { |
|
1018 |
// Form a pointer to the end of the affected region. |
|
1019 |
__ lea(rdx_argslot_limit, Address(rax_argslot, Interpreter::stackElementSize())); |
|
1020 |
// 'stack_move' is negative number of words to insert |
|
1021 |
Register rdi_stack_move = rdi; |
|
5044
7e40acdf2163
6932536: JSR 292 modified JDK MethodHandlesTest fails on x86_64
twisti
parents:
5028
diff
changeset
|
1022 |
__ movl2ptr(rdi_stack_move, rcx_amh_conversion); |
7e40acdf2163
6932536: JSR 292 modified JDK MethodHandlesTest fails on x86_64
twisti
parents:
5028
diff
changeset
|
1023 |
__ sarptr(rdi_stack_move, CONV_STACK_MOVE_SHIFT); |
2534 | 1024 |
Register rsi_temp = rsi_array; // spill this |
1025 |
insert_arg_slots(_masm, rdi_stack_move, -1, |
|
1026 |
rax_argslot, rbx_temp, rsi_temp); |
|
1027 |
// reload the array (since rsi was killed) |
|
1028 |
__ movptr(rsi_array, vmarg); |
|
1029 |
} else if (length_constant > 1) { |
|
1030 |
int arg_mask = 0; |
|
1031 |
int new_slots = (length_constant - 1); |
|
1032 |
for (int i = 0; i < new_slots; i++) { |
|
1033 |
arg_mask <<= 1; |
|
1034 |
arg_mask |= _INSERT_REF_MASK; |
|
1035 |
} |
|
1036 |
insert_arg_slots(_masm, new_slots * stack_move_unit(), arg_mask, |
|
1037 |
rax_argslot, rbx_temp, rdx_temp); |
|
1038 |
} else if (length_constant == 1) { |
|
1039 |
// no stack resizing required |
|
1040 |
} else if (length_constant == 0) { |
|
1041 |
remove_arg_slots(_masm, -stack_move_unit(), |
|
1042 |
rax_argslot, rbx_temp, rdx_temp); |
|
1043 |
} |
|
1044 |
||
1045 |
// Copy from the array to the new slots. |
|
1046 |
// Note: Stack change code preserves integrity of rax_argslot pointer. |
|
1047 |
// So even after slot insertions, rax_argslot still points to first argument. |
|
1048 |
if (length_constant == -1) { |
|
1049 |
// [rax_argslot, rdx_argslot_limit) is the area we are inserting into. |
|
1050 |
Register rsi_source = rsi_array; |
|
1051 |
__ lea(rsi_source, Address(rsi_array, elem0_offset)); |
|
1052 |
Label loop; |
|
1053 |
__ bind(loop); |
|
1054 |
__ movptr(rbx_temp, Address(rsi_source, 0)); |
|
1055 |
__ movptr(Address(rax_argslot, 0), rbx_temp); |
|
1056 |
__ addptr(rsi_source, type2aelembytes(elem_type)); |
|
1057 |
__ addptr(rax_argslot, Interpreter::stackElementSize()); |
|
1058 |
__ cmpptr(rax_argslot, rdx_argslot_limit); |
|
4564
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4562
diff
changeset
|
1059 |
__ jccb(Assembler::less, loop); |
2534 | 1060 |
} else if (length_constant == 0) { |
1061 |
__ bind(skip_array_check); |
|
1062 |
// nothing to copy |
|
1063 |
} else { |
|
1064 |
int elem_offset = elem0_offset; |
|
1065 |
int slot_offset = 0; |
|
1066 |
for (int index = 0; index < length_constant; index++) { |
|
1067 |
__ movptr(rbx_temp, Address(rsi_array, elem_offset)); |
|
1068 |
__ movptr(Address(rax_argslot, slot_offset), rbx_temp); |
|
1069 |
elem_offset += type2aelembytes(elem_type); |
|
5095 | 1070 |
slot_offset += Interpreter::stackElementSize(); |
2534 | 1071 |
} |
1072 |
} |
|
1073 |
||
1074 |
// Arguments are spread. Move to next method handle. |
|
1075 |
UNPUSH_RSI_RDI; |
|
1076 |
__ movptr(rcx_recv, rcx_mh_vmtarget); |
|
1077 |
__ jump_to_method_handle_entry(rcx_recv, rdx_temp); |
|
1078 |
||
1079 |
__ bind(bad_array_klass); |
|
1080 |
UNPUSH_RSI_RDI; |
|
4094
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
1081 |
__ pushptr(Address(rdx_array_klass, java_mirror_offset)); // required type |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
1082 |
__ pushptr(vmarg); // bad array |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
1083 |
__ push((int)Bytecodes::_aaload); // who is complaining? |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
1084 |
__ jump(ExternalAddress(from_interpreted_entry(_raise_exception))); |
2534 | 1085 |
|
1086 |
__ bind(bad_array_length); |
|
1087 |
UNPUSH_RSI_RDI; |
|
4094
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
1088 |
__ push(rcx_recv); // AMH requiring a certain length |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
1089 |
__ pushptr(vmarg); // bad array |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
1090 |
__ push((int)Bytecodes::_arraylength); // who is complaining? |
1f424b2b2171
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
3262
diff
changeset
|
1091 |
__ jump(ExternalAddress(from_interpreted_entry(_raise_exception))); |
2534 | 1092 |
|
1093 |
#undef UNPUSH_RSI_RDI |
|
1094 |
} |
|
1095 |
break; |
|
1096 |
||
1097 |
case _adapter_flyby: |
|
1098 |
case _adapter_ricochet: |
|
1099 |
__ unimplemented(entry_name(ek)); // %%% FIXME: NYI |
|
1100 |
break; |
|
1101 |
||
1102 |
default: ShouldNotReachHere(); |
|
1103 |
} |
|
1104 |
__ hlt(); |
|
1105 |
||
1106 |
address me_cookie = MethodHandleEntry::start_compiled_entry(_masm, interp_entry); |
|
1107 |
__ unimplemented(entry_name(ek)); // %%% FIXME: NYI |
|
1108 |
||
1109 |
init_entry(ek, MethodHandleEntry::finish_compiled_entry(_masm, me_cookie)); |
|
1110 |
} |