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