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