Mercurial > hg > graal-compiler
annotate src/cpu/x86/vm/methodHandles_x86.cpp @ 3371:fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
Reviewed-by: jrose, kvn, never
author | twisti |
---|---|
date | Thu, 12 May 2011 14:04:48 -0700 |
parents | 167b70ff3abc |
children | a80577f854f9 |
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 | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
72 // stack walking support |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
73 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
74 frame MethodHandles::ricochet_frame_sender(const frame& fr, RegisterMap *map) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
75 RicochetFrame* f = RicochetFrame::from_frame(fr); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
76 if (map->update_map()) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
77 frame::update_map_with_saved_link(map, &f->_sender_link); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
78 return frame(f->extended_sender_sp(), f->exact_sender_sp(), f->sender_link(), f->sender_pc()); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
79 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
80 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
81 void MethodHandles::ricochet_frame_oops_do(const frame& fr, OopClosure* blk, const RegisterMap* reg_map) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
82 RicochetFrame* f = RicochetFrame::from_frame(fr); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
83 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
84 // pick up the argument type descriptor: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
85 Thread* thread = Thread::current(); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
86 Handle cookie(thread, f->compute_saved_args_layout(true, true)); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
87 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
88 // process fixed part |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
89 blk->do_oop((oop*)f->saved_target_addr()); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
90 blk->do_oop((oop*)f->saved_args_layout_addr()); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
91 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
92 // process variable arguments: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
93 if (cookie.is_null()) return; // no arguments to describe |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
94 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
95 // the cookie is actually the invokeExact method for my target |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
96 // his argument signature is what I'm interested in |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
97 assert(cookie->is_method(), ""); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
98 methodHandle invoker(thread, methodOop(cookie())); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
99 assert(invoker->name() == vmSymbols::invokeExact_name(), "must be this kind of method"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
100 assert(!invoker->is_static(), "must have MH argument"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
101 int slot_count = invoker->size_of_parameters(); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
102 assert(slot_count >= 1, "must include 'this'"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
103 intptr_t* base = f->saved_args_base(); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
104 intptr_t* retval = NULL; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
105 if (f->has_return_value_slot()) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
106 retval = f->return_value_slot_addr(); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
107 int slot_num = slot_count; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
108 intptr_t* loc = &base[slot_num -= 1]; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
109 //blk->do_oop((oop*) loc); // original target, which is irrelevant |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
110 int arg_num = 0; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
111 for (SignatureStream ss(invoker->signature()); !ss.is_done(); ss.next()) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
112 if (ss.at_return_type()) continue; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
113 BasicType ptype = ss.type(); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
114 if (ptype == T_ARRAY) ptype = T_OBJECT; // fold all refs to T_OBJECT |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
115 assert(ptype >= T_BOOLEAN && ptype <= T_OBJECT, "not array or void"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
116 loc = &base[slot_num -= type2size[ptype]]; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
117 bool is_oop = (ptype == T_OBJECT && loc != retval); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
118 if (is_oop) blk->do_oop((oop*)loc); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
119 arg_num += 1; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
120 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
121 assert(slot_num == 0, "must have processed all the arguments"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
122 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
123 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
124 oop MethodHandles::RicochetFrame::compute_saved_args_layout(bool read_cache, bool write_cache) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
125 oop cookie = NULL; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
126 if (read_cache) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
127 cookie = saved_args_layout(); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
128 if (cookie != NULL) return cookie; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
129 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
130 oop target = saved_target(); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
131 oop mtype = java_lang_invoke_MethodHandle::type(target); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
132 oop mtform = java_lang_invoke_MethodType::form(mtype); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
133 cookie = java_lang_invoke_MethodTypeForm::vmlayout(mtform); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
134 if (write_cache) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
135 (*saved_args_layout_addr()) = cookie; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
136 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
137 return cookie; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
138 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
139 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
140 void MethodHandles::RicochetFrame::generate_ricochet_blob(MacroAssembler* _masm, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
141 // output params: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
142 int* frame_size_in_words, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
143 int* bounce_offset, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
144 int* exception_offset) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
145 (*frame_size_in_words) = RicochetFrame::frame_size_in_bytes() / wordSize; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
146 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
147 address start = __ pc(); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
148 |
710 | 149 #ifdef ASSERT |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
150 __ hlt(); __ hlt(); __ hlt(); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
151 // here's a hint of something special: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
152 __ push(MAGIC_NUMBER_1); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
153 __ push(MAGIC_NUMBER_2); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
154 #endif //ASSERT |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
155 __ hlt(); // not reached |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
156 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
157 // A return PC has just been popped from the stack. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
158 // Return values are in registers. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
159 // The ebp points into the RicochetFrame, which contains |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
160 // a cleanup continuation we must return to. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
161 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
162 (*bounce_offset) = __ pc() - start; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
163 BLOCK_COMMENT("ricochet_blob.bounce"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
164 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
165 if (VerifyMethodHandles) RicochetFrame::verify_clean(_masm); |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3363
diff
changeset
|
166 trace_method_handle(_masm, "return/ricochet_blob.bounce"); |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
167 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
168 __ jmp(frame_address(continuation_offset_in_bytes())); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
169 __ hlt(); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
170 DEBUG_ONLY(__ push(MAGIC_NUMBER_2)); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
171 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
172 (*exception_offset) = __ pc() - start; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
173 BLOCK_COMMENT("ricochet_blob.exception"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
174 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
175 // compare this to Interpreter::rethrow_exception_entry, which is parallel code |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
176 // for example, see TemplateInterpreterGenerator::generate_throw_exception |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
177 // Live registers in: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
178 // rax: exception |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
179 // rdx: return address/pc that threw exception (ignored, always equal to bounce addr) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
180 __ verify_oop(rax); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
181 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
182 // no need to empty_FPU_stack or reinit_heapbase, since caller frame will do the same if needed |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
183 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
184 // Take down the frame. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
185 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
186 // Cf. InterpreterMacroAssembler::remove_activation. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
187 leave_ricochet_frame(_masm, /*rcx_recv=*/ noreg, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
188 saved_last_sp_register(), |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
189 /*sender_pc_reg=*/ rdx); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
190 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
191 // In between activations - previous activation type unknown yet |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
192 // compute continuation point - the continuation point expects the |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
193 // following registers set up: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
194 // |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
195 // rax: exception |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
196 // rdx: return address/pc that threw exception |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
197 // rsp: expression stack of caller |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
198 // rbp: ebp of caller |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
199 __ push(rax); // save exception |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
200 __ push(rdx); // save return address |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
201 Register thread_reg = LP64_ONLY(r15_thread) NOT_LP64(rdi); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
202 NOT_LP64(__ get_thread(thread_reg)); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
203 __ call_VM_leaf(CAST_FROM_FN_PTR(address, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
204 SharedRuntime::exception_handler_for_return_address), |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
205 thread_reg, rdx); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
206 __ mov(rbx, rax); // save exception handler |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
207 __ pop(rdx); // restore return address |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
208 __ pop(rax); // restore exception |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
209 __ jmp(rbx); // jump to exception |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
210 // handler of caller |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
211 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
212 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
213 void MethodHandles::RicochetFrame::enter_ricochet_frame(MacroAssembler* _masm, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
214 Register rcx_recv, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
215 Register rax_argv, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
216 address return_handler, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
217 Register rbx_temp) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
218 const Register saved_last_sp = saved_last_sp_register(); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
219 Address rcx_mh_vmtarget( rcx_recv, java_lang_invoke_MethodHandle::vmtarget_offset_in_bytes() ); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
220 Address rcx_amh_conversion( rcx_recv, java_lang_invoke_AdapterMethodHandle::conversion_offset_in_bytes() ); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
221 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
222 // Push the RicochetFrame a word at a time. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
223 // This creates something similar to an interpreter frame. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
224 // Cf. TemplateInterpreterGenerator::generate_fixed_frame. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
225 BLOCK_COMMENT("push RicochetFrame {"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
226 DEBUG_ONLY(int rfo = (int) sizeof(RicochetFrame)); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
227 assert((rfo -= wordSize) == RicochetFrame::sender_pc_offset_in_bytes(), ""); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
228 #define RF_FIELD(push_value, name) \ |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
229 { push_value; \ |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
230 assert((rfo -= wordSize) == RicochetFrame::name##_offset_in_bytes(), ""); } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
231 RF_FIELD(__ push(rbp), sender_link); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
232 RF_FIELD(__ push(saved_last_sp), exact_sender_sp); // rsi/r13 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
233 RF_FIELD(__ pushptr(rcx_amh_conversion), conversion); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
234 RF_FIELD(__ push(rax_argv), saved_args_base); // can be updated if args are shifted |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
235 RF_FIELD(__ push((int32_t) NULL_WORD), saved_args_layout); // cache for GC layout cookie |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
236 if (UseCompressedOops) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
237 __ load_heap_oop(rbx_temp, rcx_mh_vmtarget); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
238 RF_FIELD(__ push(rbx_temp), saved_target); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
239 } else { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
240 RF_FIELD(__ pushptr(rcx_mh_vmtarget), saved_target); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
241 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
242 __ lea(rbx_temp, ExternalAddress(return_handler)); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
243 RF_FIELD(__ push(rbx_temp), continuation); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
244 #undef RF_FIELD |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
245 assert(rfo == 0, "fully initialized the RicochetFrame"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
246 // compute new frame pointer: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
247 __ lea(rbp, Address(rsp, RicochetFrame::sender_link_offset_in_bytes())); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
248 // Push guard word #1 in debug mode. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
249 DEBUG_ONLY(__ push((int32_t) RicochetFrame::MAGIC_NUMBER_1)); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
250 // For debugging, leave behind an indication of which stub built this frame. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
251 DEBUG_ONLY({ Label L; __ call(L, relocInfo::none); __ bind(L); }); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
252 BLOCK_COMMENT("} RicochetFrame"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
253 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
254 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
255 void MethodHandles::RicochetFrame::leave_ricochet_frame(MacroAssembler* _masm, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
256 Register rcx_recv, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
257 Register new_sp_reg, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
258 Register sender_pc_reg) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
259 assert_different_registers(rcx_recv, new_sp_reg, sender_pc_reg); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
260 const Register saved_last_sp = saved_last_sp_register(); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
261 // Take down the frame. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
262 // Cf. InterpreterMacroAssembler::remove_activation. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
263 BLOCK_COMMENT("end_ricochet_frame {"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
264 // TO DO: If (exact_sender_sp - extended_sender_sp) > THRESH, compact the frame down. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
265 // This will keep stack in bounds even with unlimited tailcalls, each with an adapter. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
266 if (rcx_recv->is_valid()) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
267 __ movptr(rcx_recv, RicochetFrame::frame_address(RicochetFrame::saved_target_offset_in_bytes())); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
268 __ movptr(sender_pc_reg, RicochetFrame::frame_address(RicochetFrame::sender_pc_offset_in_bytes())); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
269 __ movptr(saved_last_sp, RicochetFrame::frame_address(RicochetFrame::exact_sender_sp_offset_in_bytes())); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
270 __ movptr(rbp, RicochetFrame::frame_address(RicochetFrame::sender_link_offset_in_bytes())); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
271 __ mov(rsp, new_sp_reg); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
272 BLOCK_COMMENT("} end_ricochet_frame"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
273 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
274 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
275 // Emit code to verify that RBP is pointing at a valid ricochet frame. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
276 #ifdef ASSERT |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
277 enum { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
278 ARG_LIMIT = 255, SLOP = 4, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
279 // use this parameter for checking for garbage stack movements: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
280 UNREASONABLE_STACK_MOVE = (ARG_LIMIT + SLOP) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
281 // the slop defends against false alarms due to fencepost errors |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
282 }; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
283 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
284 void MethodHandles::RicochetFrame::verify_clean(MacroAssembler* _masm) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
285 // The stack should look like this: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
286 // ... keep1 | dest=42 | keep2 | RF | magic | handler | magic | recursive args | |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
287 // Check various invariants. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
288 verify_offsets(); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
289 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
290 Register rdi_temp = rdi; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
291 Register rcx_temp = rcx; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
292 { __ push(rdi_temp); __ push(rcx_temp); } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
293 #define UNPUSH_TEMPS \ |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
294 { __ pop(rcx_temp); __ pop(rdi_temp); } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
295 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
296 Address magic_number_1_addr = RicochetFrame::frame_address(RicochetFrame::magic_number_1_offset_in_bytes()); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
297 Address magic_number_2_addr = RicochetFrame::frame_address(RicochetFrame::magic_number_2_offset_in_bytes()); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
298 Address continuation_addr = RicochetFrame::frame_address(RicochetFrame::continuation_offset_in_bytes()); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
299 Address conversion_addr = RicochetFrame::frame_address(RicochetFrame::conversion_offset_in_bytes()); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
300 Address saved_args_base_addr = RicochetFrame::frame_address(RicochetFrame::saved_args_base_offset_in_bytes()); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
301 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
302 Label L_bad, L_ok; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
303 BLOCK_COMMENT("verify_clean {"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
304 // Magic numbers must check out: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
305 __ cmpptr(magic_number_1_addr, (int32_t) MAGIC_NUMBER_1); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
306 __ jcc(Assembler::notEqual, L_bad); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
307 __ cmpptr(magic_number_2_addr, (int32_t) MAGIC_NUMBER_2); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
308 __ jcc(Assembler::notEqual, L_bad); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
309 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
310 // Arguments pointer must look reasonable: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
311 __ movptr(rcx_temp, saved_args_base_addr); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
312 __ cmpptr(rcx_temp, rbp); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
313 __ jcc(Assembler::below, L_bad); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
314 __ subptr(rcx_temp, UNREASONABLE_STACK_MOVE * Interpreter::stackElementSize); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
315 __ cmpptr(rcx_temp, rbp); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
316 __ jcc(Assembler::above, L_bad); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
317 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
318 load_conversion_dest_type(_masm, rdi_temp, conversion_addr); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
319 __ cmpl(rdi_temp, T_VOID); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
320 __ jcc(Assembler::equal, L_ok); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
321 __ movptr(rcx_temp, saved_args_base_addr); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
322 load_conversion_vminfo(_masm, rdi_temp, conversion_addr); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
323 __ cmpptr(Address(rcx_temp, rdi_temp, Interpreter::stackElementScale()), |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
324 (int32_t) RETURN_VALUE_PLACEHOLDER); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
325 __ jcc(Assembler::equal, L_ok); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
326 __ BIND(L_bad); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
327 UNPUSH_TEMPS; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
328 __ stop("damaged ricochet frame"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
329 __ BIND(L_ok); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
330 UNPUSH_TEMPS; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
331 BLOCK_COMMENT("} verify_clean"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
332 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
333 #undef UNPUSH_TEMPS |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
334 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
335 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
336 #endif //ASSERT |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
337 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
338 void MethodHandles::load_klass_from_Class(MacroAssembler* _masm, Register klass_reg) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
339 if (VerifyMethodHandles) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
340 verify_klass(_masm, klass_reg, SystemDictionaryHandles::Class_klass(), |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
341 "AMH argument is a Class"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
342 __ load_heap_oop(klass_reg, Address(klass_reg, java_lang_Class::klass_offset_in_bytes())); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
343 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
344 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
345 void MethodHandles::load_conversion_vminfo(MacroAssembler* _masm, Register reg, Address conversion_field_addr) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
346 int bits = BitsPerByte; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
347 int offset = (CONV_VMINFO_SHIFT / bits); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
348 int shift = (CONV_VMINFO_SHIFT % bits); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
349 __ load_unsigned_byte(reg, conversion_field_addr.plus_disp(offset)); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
350 assert(CONV_VMINFO_MASK == right_n_bits(bits - shift), "else change type of previous load"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
351 assert(shift == 0, "no shift needed"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
352 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
353 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
354 void MethodHandles::load_conversion_dest_type(MacroAssembler* _masm, Register reg, Address conversion_field_addr) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
355 int bits = BitsPerByte; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
356 int offset = (CONV_DEST_TYPE_SHIFT / bits); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
357 int shift = (CONV_DEST_TYPE_SHIFT % bits); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
358 __ load_unsigned_byte(reg, conversion_field_addr.plus_disp(offset)); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
359 assert(CONV_TYPE_MASK == right_n_bits(bits - shift), "else change type of previous load"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
360 __ shrl(reg, shift); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
361 DEBUG_ONLY(int conv_type_bits = (int) exact_log2(CONV_TYPE_MASK+1)); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
362 assert((shift + conv_type_bits) == bits, "left justified in byte"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
363 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
364 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
365 void MethodHandles::load_stack_move(MacroAssembler* _masm, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
366 Register rdi_stack_move, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
367 Register rcx_amh, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
368 bool might_be_negative) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
369 BLOCK_COMMENT("load_stack_move"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
370 Address rcx_amh_conversion(rcx_amh, java_lang_invoke_AdapterMethodHandle::conversion_offset_in_bytes()); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
371 __ movl(rdi_stack_move, rcx_amh_conversion); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
372 __ sarl(rdi_stack_move, CONV_STACK_MOVE_SHIFT); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
373 #ifdef _LP64 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
374 if (might_be_negative) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
375 // clean high bits of stack motion register (was loaded as an int) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
376 __ movslq(rdi_stack_move, rdi_stack_move); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
377 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
378 #endif //_LP64 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
379 if (VerifyMethodHandles) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
380 Label L_ok, L_bad; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
381 int32_t stack_move_limit = 0x4000; // extra-large |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
382 __ cmpptr(rdi_stack_move, stack_move_limit); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
383 __ jcc(Assembler::greaterEqual, L_bad); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
384 __ cmpptr(rdi_stack_move, -stack_move_limit); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
385 __ jcc(Assembler::greater, L_ok); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
386 __ bind(L_bad); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
387 __ stop("load_stack_move of garbage value"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
388 __ BIND(L_ok); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
389 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
390 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
391 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
392 #ifndef PRODUCT |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
393 void MethodHandles::RicochetFrame::verify_offsets() { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
394 // Check compatibility of this struct with the more generally used offsets of class frame: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
395 int ebp_off = sender_link_offset_in_bytes(); // offset from struct base to local rbp value |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
396 assert(ebp_off + wordSize*frame::interpreter_frame_method_offset == saved_args_base_offset_in_bytes(), ""); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
397 assert(ebp_off + wordSize*frame::interpreter_frame_last_sp_offset == conversion_offset_in_bytes(), ""); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
398 assert(ebp_off + wordSize*frame::interpreter_frame_sender_sp_offset == exact_sender_sp_offset_in_bytes(), ""); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
399 // These last two have to be exact: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
400 assert(ebp_off + wordSize*frame::link_offset == sender_link_offset_in_bytes(), ""); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
401 assert(ebp_off + wordSize*frame::return_addr_offset == sender_pc_offset_in_bytes(), ""); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
402 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
403 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
404 void MethodHandles::RicochetFrame::verify() const { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
405 verify_offsets(); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
406 assert(magic_number_1() == MAGIC_NUMBER_1, ""); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
407 assert(magic_number_2() == MAGIC_NUMBER_2, ""); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
408 if (!Universe::heap()->is_gc_active()) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
409 if (saved_args_layout() != NULL) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
410 assert(saved_args_layout()->is_method(), "must be valid oop"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
411 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
412 if (saved_target() != NULL) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
413 assert(java_lang_invoke_MethodHandle::is_instance(saved_target()), "checking frame value"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
414 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
415 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
416 int conv_op = adapter_conversion_op(conversion()); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
417 assert(conv_op == java_lang_invoke_AdapterMethodHandle::OP_COLLECT_ARGS || |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
418 conv_op == java_lang_invoke_AdapterMethodHandle::OP_FOLD_ARGS || |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
419 conv_op == java_lang_invoke_AdapterMethodHandle::OP_PRIM_TO_REF, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
420 "must be a sane conversion"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
421 if (has_return_value_slot()) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
422 assert(*return_value_slot_addr() == RETURN_VALUE_PLACEHOLDER, ""); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
423 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
424 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
425 #endif //PRODUCT |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
426 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
427 #ifdef ASSERT |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
428 void MethodHandles::verify_argslot(MacroAssembler* _masm, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
429 Register argslot_reg, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
430 const char* error_message) { |
710 | 431 // Verify that argslot lies within (rsp, rbp]. |
432 Label L_ok, L_bad; | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
433 BLOCK_COMMENT("verify_argslot {"); |
1304 | 434 __ cmpptr(argslot_reg, rbp); |
1135
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1133
diff
changeset
|
435 __ jccb(Assembler::above, L_bad); |
1304 | 436 __ cmpptr(rsp, argslot_reg); |
1135
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1133
diff
changeset
|
437 __ jccb(Assembler::below, L_ok); |
710 | 438 __ bind(L_bad); |
439 __ stop(error_message); | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
440 __ BIND(L_ok); |
1793
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
441 BLOCK_COMMENT("} verify_argslot"); |
710 | 442 } |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
443 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
444 void MethodHandles::verify_argslots(MacroAssembler* _masm, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
445 RegisterOrConstant arg_slots, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
446 Register arg_slot_base_reg, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
447 bool negate_argslots, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
448 const char* error_message) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
449 // Verify that [argslot..argslot+size) lies within (rsp, rbp). |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
450 Label L_ok, L_bad; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
451 Register rdi_temp = rdi; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
452 BLOCK_COMMENT("verify_argslots {"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
453 __ push(rdi_temp); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
454 if (negate_argslots) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
455 if (arg_slots.is_constant()) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
456 arg_slots = -1 * arg_slots.as_constant(); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
457 } else { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
458 __ movptr(rdi_temp, arg_slots); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
459 __ negptr(rdi_temp); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
460 arg_slots = rdi_temp; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
461 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
462 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
463 __ lea(rdi_temp, Address(arg_slot_base_reg, arg_slots, Interpreter::stackElementScale())); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
464 __ cmpptr(rdi_temp, rbp); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
465 __ pop(rdi_temp); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
466 __ jcc(Assembler::above, L_bad); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
467 __ cmpptr(rsp, arg_slot_base_reg); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
468 __ jcc(Assembler::below, L_ok); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
469 __ bind(L_bad); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
470 __ stop(error_message); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
471 __ BIND(L_ok); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
472 BLOCK_COMMENT("} verify_argslots"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
473 } |
710 | 474 |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
475 // Make sure that arg_slots has the same sign as the given direction. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
476 // If (and only if) arg_slots is a assembly-time constant, also allow it to be zero. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
477 void MethodHandles::verify_stack_move(MacroAssembler* _masm, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
478 RegisterOrConstant arg_slots, int direction) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
479 bool allow_zero = arg_slots.is_constant(); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
480 if (direction == 0) { direction = +1; allow_zero = true; } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
481 assert(stack_move_unit() == -1, "else add extra checks here"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
482 if (arg_slots.is_register()) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
483 Label L_ok, L_bad; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
484 BLOCK_COMMENT("verify_stack_move {"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
485 // testl(arg_slots.as_register(), -stack_move_unit() - 1); // no need |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
486 // jcc(Assembler::notZero, L_bad); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
487 __ cmpptr(arg_slots.as_register(), (int32_t) NULL_WORD); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
488 if (direction > 0) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
489 __ jcc(allow_zero ? Assembler::less : Assembler::lessEqual, L_bad); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
490 __ cmpptr(arg_slots.as_register(), (int32_t) UNREASONABLE_STACK_MOVE); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
491 __ jcc(Assembler::less, L_ok); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
492 } else { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
493 __ jcc(allow_zero ? Assembler::greater : Assembler::greaterEqual, L_bad); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
494 __ cmpptr(arg_slots.as_register(), (int32_t) -UNREASONABLE_STACK_MOVE); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
495 __ jcc(Assembler::greater, L_ok); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
496 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
497 __ bind(L_bad); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
498 if (direction > 0) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
499 __ stop("assert arg_slots > 0"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
500 else |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
501 __ stop("assert arg_slots < 0"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
502 __ BIND(L_ok); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
503 BLOCK_COMMENT("} verify_stack_move"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
504 } else { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
505 intptr_t size = arg_slots.as_constant(); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
506 if (direction < 0) size = -size; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
507 assert(size >= 0, "correct direction of constant move"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
508 assert(size < UNREASONABLE_STACK_MOVE, "reasonable size of constant move"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
509 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
510 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
511 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
512 void MethodHandles::verify_klass(MacroAssembler* _masm, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
513 Register obj, KlassHandle klass, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
514 const char* error_message) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
515 oop* klass_addr = klass.raw_value(); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
516 assert(klass_addr >= SystemDictionaryHandles::Object_klass().raw_value() && |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
517 klass_addr <= SystemDictionaryHandles::Long_klass().raw_value(), |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
518 "must be one of the SystemDictionaryHandles"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
519 Register temp = rdi; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
520 Label L_ok, L_bad; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
521 BLOCK_COMMENT("verify_klass {"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
522 __ verify_oop(obj); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
523 __ testptr(obj, obj); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
524 __ jcc(Assembler::zero, L_bad); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
525 __ push(temp); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
526 __ load_klass(temp, obj); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
527 __ cmpptr(temp, ExternalAddress((address) klass_addr)); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
528 __ jcc(Assembler::equal, L_ok); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
529 intptr_t super_check_offset = klass->super_check_offset(); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
530 __ movptr(temp, Address(temp, super_check_offset)); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
531 __ cmpptr(temp, ExternalAddress((address) klass_addr)); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
532 __ jcc(Assembler::equal, L_ok); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
533 __ pop(temp); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
534 __ bind(L_bad); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
535 __ stop(error_message); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
536 __ BIND(L_ok); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
537 __ pop(temp); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
538 BLOCK_COMMENT("} verify_klass"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
539 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
540 #endif //ASSERT |
710 | 541 |
542 // Code generation | |
543 address MethodHandles::generate_method_handle_interpreter_entry(MacroAssembler* _masm) { | |
544 // rbx: methodOop | |
545 // rcx: receiver method handle (must load from sp[MethodTypeForm.vmslots]) | |
546 // 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
|
547 // rdx, rdi: garbage temp, blown away |
710 | 548 |
549 Register rbx_method = rbx; | |
550 Register rcx_recv = rcx; | |
551 Register rax_mtype = rax; | |
552 Register rdx_temp = rdx; | |
1793
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
553 Register rdi_temp = rdi; |
710 | 554 |
555 // emit WrongMethodType path first, to enable jccb back-branch from main path | |
556 Label wrong_method_type; | |
557 __ bind(wrong_method_type); | |
1793
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
558 Label invoke_generic_slow_path; |
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
559 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
|
560 __ 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
|
561 __ jcc(Assembler::notEqual, invoke_generic_slow_path); |
710 | 562 __ push(rax_mtype); // required mtype |
563 __ push(rcx_recv); // bad mh (1st stacked argument) | |
564 __ jump(ExternalAddress(Interpreter::throw_WrongMethodType_entry())); | |
565 | |
566 // here's where control starts out: | |
567 __ align(CodeEntryAlignment); | |
568 address entry_point = __ pc(); | |
569 | |
570 // fetch the MethodType from the method handle into rax (the 'check' register) | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
571 // FIXME: Interpreter should transmit pre-popped stack pointer, to locate base of arg list. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
572 // This would simplify several touchy bits of code. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
573 // See 6984712: JSR 292 method handle calls need a clean argument base pointer |
710 | 574 { |
575 Register tem = rbx_method; | |
576 for (jint* pchase = methodOopDesc::method_type_offsets_chain(); (*pchase) != -1; pchase++) { | |
577 __ movptr(rax_mtype, Address(tem, *pchase)); | |
578 tem = rax_mtype; // in case there is another indirection | |
579 } | |
580 } | |
581 | |
582 // 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
|
583 __ 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
|
584 Register rdx_vmslots = rdx_temp; |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2321
diff
changeset
|
585 __ movl(rdx_vmslots, Address(rdx_temp, __ delayed_value(java_lang_invoke_MethodTypeForm::vmslots_offset_in_bytes, rdi_temp))); |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
586 Address mh_receiver_slot_addr = __ argument_address(rdx_vmslots); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
587 __ movptr(rcx_recv, mh_receiver_slot_addr); |
1793
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
588 |
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
589 trace_method_handle(_masm, "invokeExact"); |
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
590 |
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
591 __ check_method_handle_type(rax_mtype, rcx_recv, rdi_temp, wrong_method_type); |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
592 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
593 // Nobody uses the MH receiver slot after this. Make sure. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
594 DEBUG_ONLY(__ movptr(mh_receiver_slot_addr, (int32_t)0x999999)); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
595 |
1793
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
596 __ 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
|
597 |
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
598 // 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
|
599 __ bind(invoke_generic_slow_path); |
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
600 #ifdef ASSERT |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
601 if (VerifyMethodHandles) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
602 Label L; |
1793
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
603 __ 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
|
604 __ jcc(Assembler::equal, L); |
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
605 __ stop("bad methodOop::intrinsic_id"); |
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
606 __ bind(L); |
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
607 } |
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
608 #endif //ASSERT |
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
609 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
|
610 |
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
611 // 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
|
612 Register rcx_argslot = rcx_recv; |
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
613 __ lea(rcx_argslot, __ argument_address(rdx_vmslots, 1)); |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
614 insert_arg_slots(_masm, 2 * stack_move_unit(), |
1793
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
615 rcx_argslot, rbx_temp, rdx_temp); |
710 | 616 |
1793
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
617 // load up an adapter from the calling type (Java weaves this) |
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
618 Register rdx_adapter = rdx_temp; |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3363
diff
changeset
|
619 __ load_heap_oop(rdx_temp, Address(rax_mtype, __ delayed_value(java_lang_invoke_MethodType::form_offset_in_bytes, rdi_temp))); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3363
diff
changeset
|
620 __ load_heap_oop(rdx_adapter, Address(rdx_temp, __ delayed_value(java_lang_invoke_MethodTypeForm::genericInvoker_offset_in_bytes, rdi_temp))); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3363
diff
changeset
|
621 __ verify_oop(rdx_adapter); |
1793
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
622 __ 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
|
623 // 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
|
624 // 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
|
625 // (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
|
626 __ 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
|
627 // 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
|
628 __ mov(rcx, rdx_adapter); |
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
629 trace_method_handle(_masm, "invokeGeneric"); |
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
630 __ 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
|
631 |
710 | 632 return entry_point; |
633 } | |
634 | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
635 // Workaround for C++ overloading nastiness on '0' for RegisterOrConstant. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
636 static RegisterOrConstant constant(int value) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
637 return RegisterOrConstant(value); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
638 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
639 |
710 | 640 // Helper to insert argument slots into the stack. |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
641 // arg_slots must be a multiple of stack_move_unit() and < 0 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
642 // rax_argslot is decremented to point to the new (shifted) location of the argslot |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
643 // But, rdx_temp ends up holding the original value of rax_argslot. |
710 | 644 void MethodHandles::insert_arg_slots(MacroAssembler* _masm, |
645 RegisterOrConstant arg_slots, | |
646 Register rax_argslot, | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
647 Register rbx_temp, Register rdx_temp) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
648 // allow constant zero |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
649 if (arg_slots.is_constant() && arg_slots.as_constant() == 0) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
650 return; |
710 | 651 assert_different_registers(rax_argslot, rbx_temp, rdx_temp, |
652 (!arg_slots.is_register() ? rsp : arg_slots.as_register())); | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
653 if (VerifyMethodHandles) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
654 verify_argslot(_masm, rax_argslot, "insertion point must fall within current frame"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
655 if (VerifyMethodHandles) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
656 verify_stack_move(_masm, arg_slots, -1); |
710 | 657 |
658 // Make space on the stack for the inserted argument(s). | |
659 // Then pull down everything shallower than rax_argslot. | |
660 // The stacked return address gets pulled down with everything else. | |
661 // That is, copy [rsp, argslot) downward by -size words. In pseudo-code: | |
662 // rsp -= size; | |
663 // for (rdx = rsp + size; rdx < argslot; rdx++) | |
664 // rdx[-size] = rdx[0] | |
665 // argslot -= size; | |
1793
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
666 BLOCK_COMMENT("insert_arg_slots {"); |
710 | 667 __ mov(rdx_temp, rsp); // source pointer for copy |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
668 __ lea(rsp, Address(rsp, arg_slots, Interpreter::stackElementScale())); |
710 | 669 { |
670 Label loop; | |
1793
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
671 __ BIND(loop); |
710 | 672 // pull one word down each time through the loop |
673 __ movptr(rbx_temp, Address(rdx_temp, 0)); | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
674 __ movptr(Address(rdx_temp, arg_slots, Interpreter::stackElementScale()), rbx_temp); |
710 | 675 __ addptr(rdx_temp, wordSize); |
676 __ cmpptr(rdx_temp, rax_argslot); | |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3363
diff
changeset
|
677 __ jcc(Assembler::below, loop); |
710 | 678 } |
679 | |
680 // Now move the argslot down, to point to the opened-up space. | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
681 __ lea(rax_argslot, Address(rax_argslot, arg_slots, Interpreter::stackElementScale())); |
1793
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
682 BLOCK_COMMENT("} insert_arg_slots"); |
710 | 683 } |
684 | |
685 // Helper to remove argument slots from the stack. | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
686 // arg_slots must be a multiple of stack_move_unit() and > 0 |
710 | 687 void MethodHandles::remove_arg_slots(MacroAssembler* _masm, |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
688 RegisterOrConstant arg_slots, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
689 Register rax_argslot, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
690 Register rbx_temp, Register rdx_temp) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
691 // allow constant zero |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
692 if (arg_slots.is_constant() && arg_slots.as_constant() == 0) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
693 return; |
710 | 694 assert_different_registers(rax_argslot, rbx_temp, rdx_temp, |
695 (!arg_slots.is_register() ? rsp : arg_slots.as_register())); | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
696 if (VerifyMethodHandles) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
697 verify_argslots(_masm, arg_slots, rax_argslot, false, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
698 "deleted argument(s) must fall within current frame"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
699 if (VerifyMethodHandles) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
700 verify_stack_move(_masm, arg_slots, +1); |
710 | 701 |
1793
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
702 BLOCK_COMMENT("remove_arg_slots {"); |
710 | 703 // Pull up everything shallower than rax_argslot. |
704 // Then remove the excess space on the stack. | |
705 // The stacked return address gets pulled up with everything else. | |
706 // That is, copy [rsp, argslot) upward by size words. In pseudo-code: | |
707 // for (rdx = argslot-1; rdx >= rsp; --rdx) | |
708 // rdx[size] = rdx[0] | |
709 // argslot += size; | |
710 // rsp += size; | |
711 __ lea(rdx_temp, Address(rax_argslot, -wordSize)); // source pointer for copy | |
712 { | |
713 Label loop; | |
1793
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
714 __ BIND(loop); |
710 | 715 // pull one word up each time through the loop |
716 __ movptr(rbx_temp, Address(rdx_temp, 0)); | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
717 __ movptr(Address(rdx_temp, arg_slots, Interpreter::stackElementScale()), rbx_temp); |
710 | 718 __ addptr(rdx_temp, -wordSize); |
719 __ cmpptr(rdx_temp, rsp); | |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3363
diff
changeset
|
720 __ jcc(Assembler::aboveEqual, loop); |
710 | 721 } |
722 | |
723 // Now move the argslot up, to point to the just-copied block. | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
724 __ lea(rsp, Address(rsp, arg_slots, Interpreter::stackElementScale())); |
710 | 725 // And adjust the argslot address to point at the deletion point. |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
726 __ lea(rax_argslot, Address(rax_argslot, arg_slots, Interpreter::stackElementScale())); |
1793
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
727 BLOCK_COMMENT("} remove_arg_slots"); |
710 | 728 } |
729 | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
730 // Helper to copy argument slots to the top of the stack. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
731 // The sequence starts with rax_argslot and is counted by slot_count |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
732 // slot_count must be a multiple of stack_move_unit() and >= 0 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
733 // This function blows the temps but does not change rax_argslot. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
734 void MethodHandles::push_arg_slots(MacroAssembler* _masm, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
735 Register rax_argslot, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
736 RegisterOrConstant slot_count, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
737 int skip_words_count, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
738 Register rbx_temp, Register rdx_temp) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
739 assert_different_registers(rax_argslot, rbx_temp, rdx_temp, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
740 (!slot_count.is_register() ? rbp : slot_count.as_register()), |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
741 rsp); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
742 assert(Interpreter::stackElementSize == wordSize, "else change this code"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
743 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
744 if (VerifyMethodHandles) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
745 verify_stack_move(_masm, slot_count, 0); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
746 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
747 // allow constant zero |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
748 if (slot_count.is_constant() && slot_count.as_constant() == 0) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
749 return; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
750 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
751 BLOCK_COMMENT("push_arg_slots {"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
752 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
753 Register rbx_top = rbx_temp; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
754 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
755 // There is at most 1 word to carry down with the TOS. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
756 switch (skip_words_count) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
757 case 1: __ pop(rdx_temp); break; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
758 case 0: break; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
759 default: ShouldNotReachHere(); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
760 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
761 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
762 if (slot_count.is_constant()) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
763 for (int i = slot_count.as_constant() - 1; i >= 0; i--) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
764 __ pushptr(Address(rax_argslot, i * wordSize)); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
765 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
766 } else { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
767 Label L_plural, L_loop, L_break; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
768 // Emit code to dynamically check for the common cases, zero and one slot. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
769 __ cmpl(slot_count.as_register(), (int32_t) 1); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
770 __ jccb(Assembler::greater, L_plural); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
771 __ jccb(Assembler::less, L_break); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
772 __ pushptr(Address(rax_argslot, 0)); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
773 __ jmpb(L_break); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
774 __ BIND(L_plural); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
775 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
776 // Loop for 2 or more: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
777 // rbx = &rax[slot_count] |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
778 // while (rbx > rax) *(--rsp) = *(--rbx) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
779 __ lea(rbx_top, Address(rax_argslot, slot_count, Address::times_ptr)); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
780 __ BIND(L_loop); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
781 __ subptr(rbx_top, wordSize); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
782 __ pushptr(Address(rbx_top, 0)); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
783 __ cmpptr(rbx_top, rax_argslot); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
784 __ jcc(Assembler::above, L_loop); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
785 __ bind(L_break); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
786 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
787 switch (skip_words_count) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
788 case 1: __ push(rdx_temp); break; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
789 case 0: break; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
790 default: ShouldNotReachHere(); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
791 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
792 BLOCK_COMMENT("} push_arg_slots"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
793 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
794 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
795 // in-place movement; no change to rsp |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
796 // blows rax_temp, rdx_temp |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
797 void MethodHandles::move_arg_slots_up(MacroAssembler* _masm, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
798 Register rbx_bottom, // invariant |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
799 Address top_addr, // can use rax_temp |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
800 RegisterOrConstant positive_distance_in_slots, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
801 Register rax_temp, Register rdx_temp) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
802 BLOCK_COMMENT("move_arg_slots_up {"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
803 assert_different_registers(rbx_bottom, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
804 rax_temp, rdx_temp, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
805 positive_distance_in_slots.register_or_noreg()); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
806 Label L_loop, L_break; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
807 Register rax_top = rax_temp; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
808 if (!top_addr.is_same_address(Address(rax_top, 0))) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
809 __ lea(rax_top, top_addr); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
810 // Detect empty (or broken) loop: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
811 #ifdef ASSERT |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
812 if (VerifyMethodHandles) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
813 // Verify that &bottom < &top (non-empty interval) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
814 Label L_ok, L_bad; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
815 if (positive_distance_in_slots.is_register()) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
816 __ cmpptr(positive_distance_in_slots.as_register(), (int32_t) 0); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
817 __ jcc(Assembler::lessEqual, L_bad); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
818 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
819 __ cmpptr(rbx_bottom, rax_top); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
820 __ jcc(Assembler::below, L_ok); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
821 __ bind(L_bad); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
822 __ stop("valid bounds (copy up)"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
823 __ BIND(L_ok); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
824 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
825 #endif |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
826 __ cmpptr(rbx_bottom, rax_top); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
827 __ jccb(Assembler::aboveEqual, L_break); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
828 // work rax down to rbx, copying contiguous data upwards |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
829 // In pseudo-code: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
830 // [rbx, rax) = &[bottom, top) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
831 // while (--rax >= rbx) *(rax + distance) = *(rax + 0), rax--; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
832 __ BIND(L_loop); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
833 __ subptr(rax_top, wordSize); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
834 __ movptr(rdx_temp, Address(rax_top, 0)); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
835 __ movptr( Address(rax_top, positive_distance_in_slots, Address::times_ptr), rdx_temp); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
836 __ cmpptr(rax_top, rbx_bottom); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
837 __ jcc(Assembler::above, L_loop); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
838 assert(Interpreter::stackElementSize == wordSize, "else change loop"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
839 __ bind(L_break); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
840 BLOCK_COMMENT("} move_arg_slots_up"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
841 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
842 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
843 // in-place movement; no change to rsp |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
844 // blows rax_temp, rdx_temp |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
845 void MethodHandles::move_arg_slots_down(MacroAssembler* _masm, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
846 Address bottom_addr, // can use rax_temp |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
847 Register rbx_top, // invariant |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
848 RegisterOrConstant negative_distance_in_slots, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
849 Register rax_temp, Register rdx_temp) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
850 BLOCK_COMMENT("move_arg_slots_down {"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
851 assert_different_registers(rbx_top, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
852 negative_distance_in_slots.register_or_noreg(), |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
853 rax_temp, rdx_temp); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
854 Label L_loop, L_break; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
855 Register rax_bottom = rax_temp; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
856 if (!bottom_addr.is_same_address(Address(rax_bottom, 0))) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
857 __ lea(rax_bottom, bottom_addr); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
858 // Detect empty (or broken) loop: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
859 #ifdef ASSERT |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
860 assert(!negative_distance_in_slots.is_constant() || negative_distance_in_slots.as_constant() < 0, ""); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
861 if (VerifyMethodHandles) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
862 // Verify that &bottom < &top (non-empty interval) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
863 Label L_ok, L_bad; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
864 if (negative_distance_in_slots.is_register()) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
865 __ cmpptr(negative_distance_in_slots.as_register(), (int32_t) 0); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
866 __ jcc(Assembler::greaterEqual, L_bad); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
867 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
868 __ cmpptr(rax_bottom, rbx_top); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
869 __ jcc(Assembler::below, L_ok); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
870 __ bind(L_bad); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
871 __ stop("valid bounds (copy down)"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
872 __ BIND(L_ok); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
873 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
874 #endif |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
875 __ cmpptr(rax_bottom, rbx_top); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
876 __ jccb(Assembler::aboveEqual, L_break); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
877 // work rax up to rbx, copying contiguous data downwards |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
878 // In pseudo-code: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
879 // [rax, rbx) = &[bottom, top) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
880 // while (rax < rbx) *(rax - distance) = *(rax + 0), rax++; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
881 __ BIND(L_loop); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
882 __ movptr(rdx_temp, Address(rax_bottom, 0)); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
883 __ movptr( Address(rax_bottom, negative_distance_in_slots, Address::times_ptr), rdx_temp); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
884 __ addptr(rax_bottom, wordSize); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
885 __ cmpptr(rax_bottom, rbx_top); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
886 __ jcc(Assembler::below, L_loop); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
887 assert(Interpreter::stackElementSize == wordSize, "else change loop"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
888 __ bind(L_break); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
889 BLOCK_COMMENT("} move_arg_slots_down"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
890 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
891 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
892 // Copy from a field or array element to a stacked argument slot. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
893 // is_element (ignored) says whether caller is loading an array element instead of an instance field. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
894 void MethodHandles::move_typed_arg(MacroAssembler* _masm, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
895 BasicType type, bool is_element, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
896 Address slot_dest, Address value_src, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
897 Register rbx_temp, Register rdx_temp) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
898 BLOCK_COMMENT(!is_element ? "move_typed_arg {" : "move_typed_arg { (array element)"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
899 if (type == T_OBJECT || type == T_ARRAY) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
900 __ load_heap_oop(rbx_temp, value_src); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
901 __ movptr(slot_dest, rbx_temp); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
902 } else if (type != T_VOID) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
903 int arg_size = type2aelembytes(type); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
904 bool arg_is_signed = is_signed_subword_type(type); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
905 int slot_size = (arg_size > wordSize) ? arg_size : wordSize; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
906 __ load_sized_value( rdx_temp, value_src, arg_size, arg_is_signed, rbx_temp); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
907 __ store_sized_value( slot_dest, rdx_temp, slot_size, rbx_temp); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
908 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
909 BLOCK_COMMENT("} move_typed_arg"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
910 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
911 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
912 void MethodHandles::move_return_value(MacroAssembler* _masm, BasicType type, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
913 Address return_slot) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
914 BLOCK_COMMENT("move_return_value {"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
915 // Old versions of the JVM must clean the FPU stack after every return. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
916 #ifndef _LP64 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
917 #ifdef COMPILER2 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
918 // The FPU stack is clean if UseSSE >= 2 but must be cleaned in other cases |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
919 if ((type == T_FLOAT && UseSSE < 1) || (type == T_DOUBLE && UseSSE < 2)) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
920 for (int i = 1; i < 8; i++) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
921 __ ffree(i); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
922 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
923 } else if (UseSSE < 2) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
924 __ empty_FPU_stack(); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
925 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
926 #endif //COMPILER2 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
927 #endif //!_LP64 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
928 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
929 // Look at the type and pull the value out of the corresponding register. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
930 if (type == T_VOID) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
931 // nothing to do |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
932 } else if (type == T_OBJECT) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
933 __ movptr(return_slot, rax); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
934 } else if (type == T_INT || is_subword_type(type)) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
935 // write the whole word, even if only 32 bits is significant |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
936 __ movptr(return_slot, rax); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
937 } else if (type == T_LONG) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
938 // store the value by parts |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
939 // Note: We assume longs are continguous (if misaligned) on the interpreter stack. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
940 __ store_sized_value(return_slot, rax, BytesPerLong, rdx); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
941 } else if (NOT_LP64((type == T_FLOAT && UseSSE < 1) || |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
942 (type == T_DOUBLE && UseSSE < 2) ||) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
943 false) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
944 // Use old x86 FPU registers: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
945 if (type == T_FLOAT) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
946 __ fstp_s(return_slot); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
947 else |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
948 __ fstp_d(return_slot); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
949 } else if (type == T_FLOAT) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
950 __ movflt(return_slot, xmm0); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
951 } else if (type == T_DOUBLE) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
952 __ movdbl(return_slot, xmm0); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
953 } else { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
954 ShouldNotReachHere(); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
955 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
956 BLOCK_COMMENT("} move_return_value"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
957 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
958 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
959 |
710 | 960 #ifndef PRODUCT |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
1108
diff
changeset
|
961 extern "C" void print_method_handle(oop mh); |
710 | 962 void trace_method_handle_stub(const char* adaptername, |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
963 oop mh, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
964 intptr_t* saved_regs, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
965 intptr_t* entry_sp, |
3336
2e038ad0c1d0
7009361: JSR 292 Invalid value on stack on solaris-sparc with -Xcomp
never
parents:
2357
diff
changeset
|
966 intptr_t* saved_sp, |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
967 intptr_t* saved_bp) { |
710 | 968 // called as a leaf from native code: do not block the JVM! |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3363
diff
changeset
|
969 bool has_mh = (strstr(adaptername, "return/") == NULL); // return adapters don't have rcx_mh |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
970 intptr_t* last_sp = (intptr_t*) saved_bp[frame::interpreter_frame_last_sp_offset]; |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3363
diff
changeset
|
971 intptr_t* base_sp = last_sp; |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3363
diff
changeset
|
972 typedef MethodHandles::RicochetFrame RicochetFrame; |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3363
diff
changeset
|
973 RicochetFrame* rfp = (RicochetFrame*)((address)saved_bp - RicochetFrame::sender_link_offset_in_bytes()); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3363
diff
changeset
|
974 if (!UseRicochetFrames || Universe::heap()->is_in((address) rfp->saved_args_base())) { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3363
diff
changeset
|
975 // Probably an interpreter frame. |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3363
diff
changeset
|
976 base_sp = (intptr_t*) saved_bp[frame::interpreter_frame_monitor_block_top_offset]; |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3363
diff
changeset
|
977 } |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3363
diff
changeset
|
978 intptr_t mh_reg = (intptr_t)mh; |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3363
diff
changeset
|
979 const char* mh_reg_name = "rcx_mh"; |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3363
diff
changeset
|
980 if (!has_mh) mh_reg_name = "rcx"; |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3363
diff
changeset
|
981 tty->print_cr("MH %s %s="PTR_FORMAT" sp=("PTR_FORMAT"+"INTX_FORMAT") stack_size="INTX_FORMAT" bp="PTR_FORMAT, |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3363
diff
changeset
|
982 adaptername, mh_reg_name, mh_reg, |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3363
diff
changeset
|
983 (intptr_t)entry_sp, (intptr_t)(saved_sp - entry_sp), (intptr_t)(base_sp - last_sp), (intptr_t)saved_bp); |
1793
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
984 if (Verbose) { |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
985 tty->print(" reg dump: "); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
986 int saved_regs_count = (entry_sp-1) - saved_regs; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
987 // 32 bit: rdi rsi rbp rsp; rbx rdx rcx (*) rax |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
988 int i; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
989 for (i = 0; i <= saved_regs_count; i++) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
990 if (i > 0 && i % 4 == 0 && i != saved_regs_count) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
991 tty->cr(); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
992 tty->print(" + dump: "); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
993 } |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3363
diff
changeset
|
994 tty->print(" %d: "PTR_FORMAT, i, saved_regs[i]); |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
995 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
996 tty->cr(); |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3363
diff
changeset
|
997 if (last_sp != saved_sp && last_sp != NULL) |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3363
diff
changeset
|
998 tty->print_cr("*** last_sp="PTR_FORMAT, (intptr_t)last_sp); |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
999 int stack_dump_count = 16; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1000 if (stack_dump_count < (int)(saved_bp + 2 - saved_sp)) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1001 stack_dump_count = (int)(saved_bp + 2 - saved_sp); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1002 if (stack_dump_count > 64) stack_dump_count = 48; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1003 for (i = 0; i < stack_dump_count; i += 4) { |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3363
diff
changeset
|
1004 tty->print_cr(" dump at SP[%d] "PTR_FORMAT": "PTR_FORMAT" "PTR_FORMAT" "PTR_FORMAT" "PTR_FORMAT, |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1005 i, (intptr_t) &entry_sp[i+0], entry_sp[i+0], entry_sp[i+1], entry_sp[i+2], entry_sp[i+3]); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1006 } |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3363
diff
changeset
|
1007 if (has_mh) |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3363
diff
changeset
|
1008 print_method_handle(mh); |
1793
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
1009 } |
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
1010 } |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1011 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1012 // The stub wraps the arguments in a struct on the stack to avoid |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1013 // dealing with the different calling conventions for passing 6 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1014 // arguments. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1015 struct MethodHandleStubArguments { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1016 const char* adaptername; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1017 oopDesc* mh; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1018 intptr_t* saved_regs; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1019 intptr_t* entry_sp; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1020 intptr_t* saved_sp; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1021 intptr_t* saved_bp; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1022 }; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1023 void trace_method_handle_stub_wrapper(MethodHandleStubArguments* args) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1024 trace_method_handle_stub(args->adaptername, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1025 args->mh, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1026 args->saved_regs, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1027 args->entry_sp, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1028 args->saved_sp, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1029 args->saved_bp); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1030 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1031 |
1793
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
1032 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
|
1033 if (!TraceMethodHandles) return; |
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
1034 BLOCK_COMMENT("trace_method_handle {"); |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1035 __ push(rax); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1036 __ lea(rax, Address(rsp, wordSize * NOT_LP64(6) LP64_ONLY(14))); // entry_sp __ pusha(); |
1793
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
1037 __ pusha(); |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1038 __ mov(rbx, rsp); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1039 __ enter(); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1040 // incoming state: |
3336
2e038ad0c1d0
7009361: JSR 292 Invalid value on stack on solaris-sparc with -Xcomp
never
parents:
2357
diff
changeset
|
1041 // rcx: method handle |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1042 // r13 or rsi: saved sp |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1043 // To avoid calling convention issues, build a record on the stack and pass the pointer to that instead. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1044 __ push(rbp); // saved_bp |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1045 __ push(rsi); // saved_sp |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1046 __ push(rax); // entry_sp |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1047 __ push(rbx); // pusha saved_regs |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1048 __ push(rcx); // mh |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1049 __ push(rcx); // adaptername |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1050 __ movptr(Address(rsp, 0), (intptr_t) adaptername); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1051 __ super_call_VM_leaf(CAST_FROM_FN_PTR(address, trace_method_handle_stub_wrapper), rsp); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1052 __ leave(); |
1793
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
1053 __ popa(); |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1054 __ pop(rax); |
1793
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
1055 BLOCK_COMMENT("} trace_method_handle"); |
710 | 1056 } |
1057 #endif //PRODUCT | |
1058 | |
1507
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1506
diff
changeset
|
1059 // which conversion op types are implemented here? |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1506
diff
changeset
|
1060 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
|
1061 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
|
1062 |(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
|
1063 |(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
|
1064 |(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
|
1065 |(1<<java_lang_invoke_AdapterMethodHandle::OP_REF_TO_PRIM) |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1066 //OP_PRIM_TO_REF is below... |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2321
diff
changeset
|
1067 |(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
|
1068 |(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
|
1069 |(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
|
1070 |(1<<java_lang_invoke_AdapterMethodHandle::OP_DROP_ARGS) |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1071 //OP_COLLECT_ARGS is below... |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1072 |(1<<java_lang_invoke_AdapterMethodHandle::OP_SPREAD_ARGS) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1073 |(!UseRicochetFrames ? 0 : |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1074 java_lang_invoke_MethodTypeForm::vmlayout_offset_in_bytes() <= 0 ? 0 : |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1075 ((1<<java_lang_invoke_AdapterMethodHandle::OP_PRIM_TO_REF) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1076 |(1<<java_lang_invoke_AdapterMethodHandle::OP_COLLECT_ARGS) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1077 |(1<<java_lang_invoke_AdapterMethodHandle::OP_FOLD_ARGS) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1078 )) |
1507
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1506
diff
changeset
|
1079 ); |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1506
diff
changeset
|
1080 } |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1506
diff
changeset
|
1081 |
2088
8d0b933dda2d
7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents:
1972
diff
changeset
|
1082 //------------------------------------------------------------------------------ |
8d0b933dda2d
7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents:
1972
diff
changeset
|
1083 // MethodHandles::generate_method_handle_stub |
8d0b933dda2d
7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents:
1972
diff
changeset
|
1084 // |
710 | 1085 // Generate an "entry" field for a method handle. |
1086 // 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
|
1087 void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHandles::EntryKind ek) { |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1088 MethodHandles::EntryKind ek_orig = ek_original_kind(ek); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1089 |
710 | 1090 // Here is the register state during an interpreted call, |
1091 // as set up by generate_method_handle_interpreter_entry(): | |
1092 // - rbx: garbage temp (was MethodHandle.invoke methodOop, unused) | |
1093 // - rcx: receiver method handle | |
1094 // - rax: method handle type (only used by the check_mtype entry point) | |
1095 // - rsi/r13: sender SP (must preserve; see prepare_to_jump_from_interpreted) | |
1096 // - rdx: garbage temp, can blow away | |
1097 | |
2088
8d0b933dda2d
7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents:
1972
diff
changeset
|
1098 const Register rcx_recv = rcx; |
8d0b933dda2d
7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents:
1972
diff
changeset
|
1099 const Register rax_argslot = rax; |
8d0b933dda2d
7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents:
1972
diff
changeset
|
1100 const Register rbx_temp = rbx; |
8d0b933dda2d
7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents:
1972
diff
changeset
|
1101 const Register rdx_temp = rdx; |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1102 const Register rdi_temp = rdi; |
710 | 1103 |
1039
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
845
diff
changeset
|
1104 // 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
|
1105 // and gen_c2i_adapter (from compiled calls): |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1106 const Register saved_last_sp = saved_last_sp_register(); |
2088
8d0b933dda2d
7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents:
1972
diff
changeset
|
1107 |
8d0b933dda2d
7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents:
1972
diff
changeset
|
1108 // Argument registers for _raise_exception. |
8d0b933dda2d
7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents:
1972
diff
changeset
|
1109 // 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
|
1110 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
|
1111 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
|
1112 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
|
1113 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
|
1114 |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2321
diff
changeset
|
1115 guarantee(java_lang_invoke_MethodHandle::vmentry_offset_in_bytes() != 0, "must have offsets"); |
710 | 1116 |
1117 // some handy addresses | |
1118 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
|
1119 Address rbx_method_fce( rbx, methodOopDesc::from_compiled_offset() ); |
710 | 1120 |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2321
diff
changeset
|
1121 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
|
1122 Address rcx_dmh_vmindex( rcx_recv, java_lang_invoke_DirectMethodHandle::vmindex_offset_in_bytes() ); |
710 | 1123 |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2321
diff
changeset
|
1124 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
|
1125 Address rcx_bmh_argument( rcx_recv, java_lang_invoke_BoundMethodHandle::argument_offset_in_bytes() ); |
710 | 1126 |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2321
diff
changeset
|
1127 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
|
1128 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
|
1129 Address rcx_amh_conversion( rcx_recv, java_lang_invoke_AdapterMethodHandle::conversion_offset_in_bytes() ); |
710 | 1130 Address vmarg; // __ argument_address(vmargslot) |
1131 | |
1039
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
845
diff
changeset
|
1132 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
|
1133 |
710 | 1134 if (have_entry(ek)) { |
1135 __ nop(); // empty stubs make SG sick | |
1136 return; | |
1137 } | |
1138 | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1139 #ifdef ASSERT |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1140 __ push((int32_t) 0xEEEEEEEE); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1141 __ push((int32_t) (intptr_t) entry_name(ek)); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1142 LP64_ONLY(__ push((int32_t) high((intptr_t) entry_name(ek)))); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1143 __ push((int32_t) 0x33333333); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1144 #endif //ASSERT |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1145 |
710 | 1146 address interp_entry = __ pc(); |
1147 | |
1793
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
1148 trace_method_handle(_masm, entry_name(ek)); |
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
1149 |
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
1150 BLOCK_COMMENT(entry_name(ek)); |
710 | 1151 |
1152 switch ((int) ek) { | |
1039
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
845
diff
changeset
|
1153 case _raise_exception: |
710 | 1154 { |
2088
8d0b933dda2d
7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents:
1972
diff
changeset
|
1155 // 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
|
1156 // 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
|
1157 // 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
|
1158 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
|
1159 assert(raise_exception_method()->from_compiled_entry(), "method must be linked"); |
710 | 1160 |
2088
8d0b933dda2d
7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents:
1972
diff
changeset
|
1161 const Register rdi_pc = rax; |
8d0b933dda2d
7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents:
1972
diff
changeset
|
1162 __ pop(rdi_pc); // caller PC |
8d0b933dda2d
7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents:
1972
diff
changeset
|
1163 __ mov(rsp, saved_last_sp); // cut the stack back to where the caller started |
710 | 1164 |
1039
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
845
diff
changeset
|
1165 Register rbx_method = rbx_temp; |
2088
8d0b933dda2d
7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents:
1972
diff
changeset
|
1166 Label L_no_method; |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2321
diff
changeset
|
1167 // 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
|
1168 __ movptr(rbx_method, ExternalAddress((address) &_raise_exception_method)); |
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
845
diff
changeset
|
1169 __ testptr(rbx_method, rbx_method); |
2088
8d0b933dda2d
7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents:
1972
diff
changeset
|
1170 __ jccb(Assembler::zero, L_no_method); |
8d0b933dda2d
7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents:
1972
diff
changeset
|
1171 |
8d0b933dda2d
7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents:
1972
diff
changeset
|
1172 const int jobject_oop_offset = 0; |
1039
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
845
diff
changeset
|
1173 __ 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
|
1174 __ testptr(rbx_method, rbx_method); |
2088
8d0b933dda2d
7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents:
1972
diff
changeset
|
1175 __ jccb(Assembler::zero, L_no_method); |
1039
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
845
diff
changeset
|
1176 __ verify_oop(rbx_method); |
2088
8d0b933dda2d
7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents:
1972
diff
changeset
|
1177 |
8d0b933dda2d
7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents:
1972
diff
changeset
|
1178 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
|
1179 __ 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
|
1180 __ 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
|
1181 |
1039
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
845
diff
changeset
|
1182 // 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
|
1183 __ bind(L_no_method); |
8d0b933dda2d
7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents:
1972
diff
changeset
|
1184 __ push(rarg2_required); |
8d0b933dda2d
7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents:
1972
diff
changeset
|
1185 __ push(rarg1_actual); |
710 | 1186 __ jump(ExternalAddress(Interpreter::throw_WrongMethodType_entry())); |
1187 } | |
1188 break; | |
1189 | |
1190 case _invokestatic_mh: | |
1191 case _invokespecial_mh: | |
1192 { | |
1193 Register rbx_method = rbx_temp; | |
1846 | 1194 __ load_heap_oop(rbx_method, rcx_mh_vmtarget); // target is a methodOop |
710 | 1195 __ verify_oop(rbx_method); |
1196 // same as TemplateTable::invokestatic or invokespecial, | |
1197 // minus the CP setup and profiling: | |
1198 if (ek == _invokespecial_mh) { | |
1199 // Must load & check the first argument before entering the target method. | |
1200 __ load_method_handle_vmslots(rax_argslot, rcx_recv, rdx_temp); | |
1201 __ movptr(rcx_recv, __ argument_address(rax_argslot, -1)); | |
1202 __ null_check(rcx_recv); | |
1203 __ verify_oop(rcx_recv); | |
1204 } | |
1205 __ jmp(rbx_method_fie); | |
1206 } | |
1207 break; | |
1208 | |
1209 case _invokevirtual_mh: | |
1210 { | |
1211 // same as TemplateTable::invokevirtual, | |
1212 // minus the CP setup and profiling: | |
1213 | |
1214 // pick out the vtable index and receiver offset from the MH, | |
1215 // and then we can discard it: | |
1216 __ load_method_handle_vmslots(rax_argslot, rcx_recv, rdx_temp); | |
1217 Register rbx_index = rbx_temp; | |
1218 __ movl(rbx_index, rcx_dmh_vmindex); | |
1219 // Note: The verifier allows us to ignore rcx_mh_vmtarget. | |
1220 __ movptr(rcx_recv, __ argument_address(rax_argslot, -1)); | |
1221 __ null_check(rcx_recv, oopDesc::klass_offset_in_bytes()); | |
1222 | |
1223 // get receiver klass | |
1224 Register rax_klass = rax_argslot; | |
1225 __ load_klass(rax_klass, rcx_recv); | |
1226 __ verify_oop(rax_klass); | |
1227 | |
1228 // get target methodOop & entry point | |
1229 const int base = instanceKlass::vtable_start_offset() * wordSize; | |
1230 assert(vtableEntry::size() * wordSize == wordSize, "adjust the scaling in the code below"); | |
1231 Address vtable_entry_addr(rax_klass, | |
1232 rbx_index, Address::times_ptr, | |
1233 base + vtableEntry::method_offset_in_bytes()); | |
1234 Register rbx_method = rbx_temp; | |
1108 | 1235 __ movptr(rbx_method, vtable_entry_addr); |
710 | 1236 |
1237 __ verify_oop(rbx_method); | |
1238 __ jmp(rbx_method_fie); | |
1239 } | |
1240 break; | |
1241 | |
1242 case _invokeinterface_mh: | |
1243 { | |
1244 // same as TemplateTable::invokeinterface, | |
1245 // minus the CP setup and profiling: | |
1246 | |
1247 // pick out the interface and itable index from the MH. | |
1248 __ load_method_handle_vmslots(rax_argslot, rcx_recv, rdx_temp); | |
1249 Register rdx_intf = rdx_temp; | |
1250 Register rbx_index = rbx_temp; | |
1846 | 1251 __ load_heap_oop(rdx_intf, rcx_mh_vmtarget); |
1252 __ movl(rbx_index, rcx_dmh_vmindex); | |
710 | 1253 __ movptr(rcx_recv, __ argument_address(rax_argslot, -1)); |
1254 __ null_check(rcx_recv, oopDesc::klass_offset_in_bytes()); | |
1255 | |
1256 // get receiver klass | |
1257 Register rax_klass = rax_argslot; | |
1258 __ load_klass(rax_klass, rcx_recv); | |
1259 __ verify_oop(rax_klass); | |
1260 | |
1261 Register rbx_method = rbx_index; | |
1262 | |
1263 // get interface klass | |
1264 Label no_such_interface; | |
1265 __ verify_oop(rdx_intf); | |
1266 __ lookup_interface_method(rax_klass, rdx_intf, | |
1267 // note: next two args must be the same: | |
1268 rbx_index, rbx_method, | |
1039
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
845
diff
changeset
|
1269 rdi_temp, |
710 | 1270 no_such_interface); |
1271 | |
1272 __ verify_oop(rbx_method); | |
1273 __ jmp(rbx_method_fie); | |
1274 __ hlt(); | |
1275 | |
1276 __ bind(no_such_interface); | |
1277 // Throw an exception. | |
1278 // 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
|
1279 __ 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
|
1280 assert_different_registers(rarg2_required, rbx_temp); |
8d0b933dda2d
7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents:
1972
diff
changeset
|
1281 __ 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
|
1282 __ mov( rarg1_actual, rbx_temp); // bad receiver |
8d0b933dda2d
7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents:
1972
diff
changeset
|
1283 __ 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
|
1284 __ jump(ExternalAddress(from_interpreted_entry(_raise_exception))); |
710 | 1285 } |
1286 break; | |
1287 | |
1288 case _bound_ref_mh: | |
1289 case _bound_int_mh: | |
1290 case _bound_long_mh: | |
1291 case _bound_ref_direct_mh: | |
1292 case _bound_int_direct_mh: | |
1293 case _bound_long_direct_mh: | |
1294 { | |
1295 bool direct_to_method = (ek >= _bound_ref_direct_mh); | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1296 BasicType arg_type = ek_bound_mh_arg_type(ek); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1297 int arg_slots = type2size[arg_type]; |
710 | 1298 |
1299 // make room for the new argument: | |
1300 __ movl(rax_argslot, rcx_bmh_vmargslot); | |
1301 __ 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
|
1302 |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1303 insert_arg_slots(_masm, arg_slots * stack_move_unit(), rax_argslot, rbx_temp, rdx_temp); |
710 | 1304 |
1305 // store bound argument into the new stack slot: | |
1846 | 1306 __ load_heap_oop(rbx_temp, rcx_bmh_argument); |
710 | 1307 if (arg_type == T_OBJECT) { |
1308 __ movptr(Address(rax_argslot, 0), rbx_temp); | |
1309 } else { | |
2258
28bf941f445e
7018378: JSR 292: _bound_int_mh produces wrong result on 64-bit SPARC
twisti
parents:
2116
diff
changeset
|
1310 Address prim_value_addr(rbx_temp, java_lang_boxing_object::value_offset_in_bytes(arg_type)); |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1311 move_typed_arg(_masm, arg_type, false, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1312 Address(rax_argslot, 0), |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1313 prim_value_addr, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1314 rbx_temp, rdx_temp); |
710 | 1315 } |
1316 | |
1317 if (direct_to_method) { | |
1318 Register rbx_method = rbx_temp; | |
1846 | 1319 __ load_heap_oop(rbx_method, rcx_mh_vmtarget); |
710 | 1320 __ verify_oop(rbx_method); |
1321 __ jmp(rbx_method_fie); | |
1322 } else { | |
1846 | 1323 __ load_heap_oop(rcx_recv, rcx_mh_vmtarget); |
710 | 1324 __ verify_oop(rcx_recv); |
1325 __ jump_to_method_handle_entry(rcx_recv, rdx_temp); | |
1326 } | |
1327 } | |
1328 break; | |
1329 | |
1330 case _adapter_retype_only: | |
1039
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
845
diff
changeset
|
1331 case _adapter_retype_raw: |
710 | 1332 // immediately jump to the next MH layer: |
1846 | 1333 __ load_heap_oop(rcx_recv, rcx_mh_vmtarget); |
710 | 1334 __ verify_oop(rcx_recv); |
1335 __ jump_to_method_handle_entry(rcx_recv, rdx_temp); | |
1336 // This is OK when all parameter types widen. | |
1337 // It is also OK when a return type narrows. | |
1338 break; | |
1339 | |
1340 case _adapter_check_cast: | |
1341 { | |
1342 // temps: | |
1343 Register rbx_klass = rbx_temp; // interesting AMH data | |
1344 | |
1345 // check a reference argument before jumping to the next layer of MH: | |
1346 __ movl(rax_argslot, rcx_amh_vmargslot); | |
1347 vmarg = __ argument_address(rax_argslot); | |
1348 | |
1349 // What class are we casting to? | |
1846 | 1350 __ load_heap_oop(rbx_klass, rcx_amh_argument); // this is a Class object! |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1351 load_klass_from_Class(_masm, rbx_klass); |
710 | 1352 |
1353 Label done; | |
1354 __ movptr(rdx_temp, vmarg); | |
1277 | 1355 __ testptr(rdx_temp, rdx_temp); |
1846 | 1356 __ jcc(Assembler::zero, done); // no cast if null |
710 | 1357 __ load_klass(rdx_temp, rdx_temp); |
1358 | |
1359 // live at this point: | |
1360 // - rbx_klass: klass required by the target method | |
1361 // - rdx_temp: argument klass to test | |
1039
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
845
diff
changeset
|
1362 // - rcx_recv: adapter method handle |
710 | 1363 __ check_klass_subtype(rdx_temp, rbx_klass, rax_argslot, done); |
1364 | |
1365 // If we get here, the type check failed! | |
1366 // Call the wrong_method_type stub, passing the failing argument type in rax. | |
1367 Register rax_mtype = rax_argslot; | |
1039
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
845
diff
changeset
|
1368 __ movl(rax_argslot, rcx_amh_vmargslot); // reload argslot field |
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
845
diff
changeset
|
1369 __ movptr(rdx_temp, vmarg); |
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
845
diff
changeset
|
1370 |
2088
8d0b933dda2d
7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents:
1972
diff
changeset
|
1371 assert_different_registers(rarg2_required, rdx_temp); |
8d0b933dda2d
7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents:
1972
diff
changeset
|
1372 __ 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
|
1373 __ mov( rarg1_actual, rdx_temp); // bad object |
8d0b933dda2d
7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents:
1972
diff
changeset
|
1374 __ 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
|
1375 __ jump(ExternalAddress(from_interpreted_entry(_raise_exception))); |
710 | 1376 |
1377 __ bind(done); | |
1039
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
845
diff
changeset
|
1378 // get the new MH: |
1846 | 1379 __ load_heap_oop(rcx_recv, rcx_mh_vmtarget); |
710 | 1380 __ jump_to_method_handle_entry(rcx_recv, rdx_temp); |
1381 } | |
1382 break; | |
1383 | |
1384 case _adapter_prim_to_prim: | |
1385 case _adapter_ref_to_prim: | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1386 case _adapter_prim_to_ref: |
710 | 1387 // handled completely by optimized cases |
1388 __ stop("init_AdapterMethodHandle should not issue this"); | |
1389 break; | |
1390 | |
1391 case _adapter_opt_i2i: // optimized subcase of adapt_prim_to_prim | |
1392 //case _adapter_opt_f2i: // optimized subcase of adapt_prim_to_prim | |
1393 case _adapter_opt_l2i: // optimized subcase of adapt_prim_to_prim | |
1394 case _adapter_opt_unboxi: // optimized subcase of adapt_ref_to_prim | |
1395 { | |
1396 // perform an in-place conversion to int or an int subword | |
1397 __ movl(rax_argslot, rcx_amh_vmargslot); | |
1398 vmarg = __ argument_address(rax_argslot); | |
1399 | |
1400 switch (ek) { | |
1401 case _adapter_opt_i2i: | |
1402 __ movl(rdx_temp, vmarg); | |
1403 break; | |
1404 case _adapter_opt_l2i: | |
1405 { | |
1406 // just delete the extra slot; on a little-endian machine we keep the first | |
1407 __ lea(rax_argslot, __ argument_address(rax_argslot, 1)); | |
1408 remove_arg_slots(_masm, -stack_move_unit(), | |
1409 rax_argslot, rbx_temp, rdx_temp); | |
1506 | 1410 vmarg = Address(rax_argslot, -Interpreter::stackElementSize); |
710 | 1411 __ movl(rdx_temp, vmarg); |
1412 } | |
1413 break; | |
1414 case _adapter_opt_unboxi: | |
1415 { | |
1416 // Load the value up from the heap. | |
1417 __ movptr(rdx_temp, vmarg); | |
1418 int value_offset = java_lang_boxing_object::value_offset_in_bytes(T_INT); | |
1419 #ifdef ASSERT | |
1420 for (int bt = T_BOOLEAN; bt < T_INT; bt++) { | |
1421 if (is_subword_type(BasicType(bt))) | |
1422 assert(value_offset == java_lang_boxing_object::value_offset_in_bytes(BasicType(bt)), ""); | |
1423 } | |
1424 #endif | |
1425 __ null_check(rdx_temp, value_offset); | |
1426 __ movl(rdx_temp, Address(rdx_temp, value_offset)); | |
1427 // We load this as a word. Because we are little-endian, | |
1428 // the low bits will be correct, but the high bits may need cleaning. | |
1429 // The vminfo will guide us to clean those bits. | |
1430 } | |
1431 break; | |
1432 default: | |
1304 | 1433 ShouldNotReachHere(); |
710 | 1434 } |
1435 | |
1304 | 1436 // Do the requested conversion and store the value. |
710 | 1437 Register rbx_vminfo = rbx_temp; |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1438 load_conversion_vminfo(_masm, rbx_vminfo, rcx_amh_conversion); |
710 | 1439 |
1440 // get the new MH: | |
1846 | 1441 __ load_heap_oop(rcx_recv, rcx_mh_vmtarget); |
710 | 1442 // (now we are done with the old MH) |
1443 | |
1444 // 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
|
1445 // | 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
|
1446 __ xchgptr(rcx, rbx_vminfo); // free rcx for shifts |
710 | 1447 __ shll(rdx_temp /*, rcx*/); |
1448 Label zero_extend, done; | |
1449 __ testl(rcx, CONV_VMINFO_SIGN_FLAG); | |
1135
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1133
diff
changeset
|
1450 __ jccb(Assembler::zero, zero_extend); |
710 | 1451 |
1452 // this path is taken for int->byte, int->short | |
1453 __ sarl(rdx_temp /*, rcx*/); | |
1135
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1133
diff
changeset
|
1454 __ jmpb(done); |
710 | 1455 |
1456 __ bind(zero_extend); | |
1457 // this is taken for int->char | |
1458 __ shrl(rdx_temp /*, rcx*/); | |
1459 | |
1460 __ bind(done); | |
1304 | 1461 __ 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
|
1462 __ xchgptr(rcx, rbx_vminfo); // restore rcx_recv |
710 | 1463 |
1464 __ jump_to_method_handle_entry(rcx_recv, rdx_temp); | |
1465 } | |
1466 break; | |
1467 | |
1468 case _adapter_opt_i2l: // optimized subcase of adapt_prim_to_prim | |
1469 case _adapter_opt_unboxl: // optimized subcase of adapt_ref_to_prim | |
1470 { | |
1471 // perform an in-place int-to-long or ref-to-long conversion | |
1472 __ movl(rax_argslot, rcx_amh_vmargslot); | |
1473 | |
1474 // on a little-endian machine we keep the first slot and add another after | |
1475 __ lea(rax_argslot, __ argument_address(rax_argslot, 1)); | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1476 insert_arg_slots(_masm, stack_move_unit(), |
710 | 1477 rax_argslot, rbx_temp, rdx_temp); |
1506 | 1478 Address vmarg1(rax_argslot, -Interpreter::stackElementSize); |
1479 Address vmarg2 = vmarg1.plus_disp(Interpreter::stackElementSize); | |
710 | 1480 |
1481 switch (ek) { | |
1482 case _adapter_opt_i2l: | |
1483 { | |
1293
51db1e4b379d
6932536: JSR 292 modified JDK MethodHandlesTest fails on x86_64
twisti
parents:
1277
diff
changeset
|
1484 #ifdef _LP64 |
51db1e4b379d
6932536: JSR 292 modified JDK MethodHandlesTest fails on x86_64
twisti
parents:
1277
diff
changeset
|
1485 __ movslq(rdx_temp, vmarg1); // Load sign-extended |
51db1e4b379d
6932536: JSR 292 modified JDK MethodHandlesTest fails on x86_64
twisti
parents:
1277
diff
changeset
|
1486 __ movq(vmarg1, rdx_temp); // Store into first slot |
51db1e4b379d
6932536: JSR 292 modified JDK MethodHandlesTest fails on x86_64
twisti
parents:
1277
diff
changeset
|
1487 #else |
710 | 1488 __ movl(rdx_temp, vmarg1); |
1293
51db1e4b379d
6932536: JSR 292 modified JDK MethodHandlesTest fails on x86_64
twisti
parents:
1277
diff
changeset
|
1489 __ sarl(rdx_temp, BitsPerInt - 1); // __ extend_sign() |
710 | 1490 __ movl(vmarg2, rdx_temp); // store second word |
1293
51db1e4b379d
6932536: JSR 292 modified JDK MethodHandlesTest fails on x86_64
twisti
parents:
1277
diff
changeset
|
1491 #endif |
710 | 1492 } |
1493 break; | |
1494 case _adapter_opt_unboxl: | |
1495 { | |
1496 // Load the value up from the heap. | |
1497 __ movptr(rdx_temp, vmarg1); | |
1498 int value_offset = java_lang_boxing_object::value_offset_in_bytes(T_LONG); | |
1499 assert(value_offset == java_lang_boxing_object::value_offset_in_bytes(T_DOUBLE), ""); | |
1500 __ null_check(rdx_temp, value_offset); | |
1293
51db1e4b379d
6932536: JSR 292 modified JDK MethodHandlesTest fails on x86_64
twisti
parents:
1277
diff
changeset
|
1501 #ifdef _LP64 |
51db1e4b379d
6932536: JSR 292 modified JDK MethodHandlesTest fails on x86_64
twisti
parents:
1277
diff
changeset
|
1502 __ movq(rbx_temp, Address(rdx_temp, value_offset)); |
51db1e4b379d
6932536: JSR 292 modified JDK MethodHandlesTest fails on x86_64
twisti
parents:
1277
diff
changeset
|
1503 __ movq(vmarg1, rbx_temp); |
51db1e4b379d
6932536: JSR 292 modified JDK MethodHandlesTest fails on x86_64
twisti
parents:
1277
diff
changeset
|
1504 #else |
710 | 1505 __ movl(rbx_temp, Address(rdx_temp, value_offset + 0*BytesPerInt)); |
1506 __ movl(rdx_temp, Address(rdx_temp, value_offset + 1*BytesPerInt)); | |
1507 __ movl(vmarg1, rbx_temp); | |
1508 __ movl(vmarg2, rdx_temp); | |
1293
51db1e4b379d
6932536: JSR 292 modified JDK MethodHandlesTest fails on x86_64
twisti
parents:
1277
diff
changeset
|
1509 #endif |
710 | 1510 } |
1511 break; | |
1512 default: | |
1304 | 1513 ShouldNotReachHere(); |
710 | 1514 } |
1515 | |
1846 | 1516 __ load_heap_oop(rcx_recv, rcx_mh_vmtarget); |
710 | 1517 __ jump_to_method_handle_entry(rcx_recv, rdx_temp); |
1518 } | |
1519 break; | |
1520 | |
1521 case _adapter_opt_f2d: // optimized subcase of adapt_prim_to_prim | |
1522 case _adapter_opt_d2f: // optimized subcase of adapt_prim_to_prim | |
1523 { | |
1524 // perform an in-place floating primitive conversion | |
1525 __ movl(rax_argslot, rcx_amh_vmargslot); | |
1526 __ lea(rax_argslot, __ argument_address(rax_argslot, 1)); | |
1527 if (ek == _adapter_opt_f2d) { | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1528 insert_arg_slots(_masm, stack_move_unit(), |
710 | 1529 rax_argslot, rbx_temp, rdx_temp); |
1530 } | |
1506 | 1531 Address vmarg(rax_argslot, -Interpreter::stackElementSize); |
710 | 1532 |
1533 #ifdef _LP64 | |
1534 if (ek == _adapter_opt_f2d) { | |
1535 __ movflt(xmm0, vmarg); | |
1536 __ cvtss2sd(xmm0, xmm0); | |
1537 __ movdbl(vmarg, xmm0); | |
1538 } else { | |
1539 __ movdbl(xmm0, vmarg); | |
1540 __ cvtsd2ss(xmm0, xmm0); | |
1541 __ movflt(vmarg, xmm0); | |
1542 } | |
1543 #else //_LP64 | |
1544 if (ek == _adapter_opt_f2d) { | |
1545 __ fld_s(vmarg); // load float to ST0 | |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3363
diff
changeset
|
1546 __ fstp_d(vmarg); // store double |
1304 | 1547 } else { |
710 | 1548 __ fld_d(vmarg); // load double to ST0 |
1549 __ fstp_s(vmarg); // store single | |
1550 } | |
1551 #endif //_LP64 | |
1552 | |
1553 if (ek == _adapter_opt_d2f) { | |
1554 remove_arg_slots(_masm, -stack_move_unit(), | |
1555 rax_argslot, rbx_temp, rdx_temp); | |
1556 } | |
1557 | |
1846 | 1558 __ load_heap_oop(rcx_recv, rcx_mh_vmtarget); |
710 | 1559 __ jump_to_method_handle_entry(rcx_recv, rdx_temp); |
1560 } | |
1561 break; | |
1562 | |
1563 case _adapter_swap_args: | |
1564 case _adapter_rot_args: | |
1565 // handled completely by optimized cases | |
1566 __ stop("init_AdapterMethodHandle should not issue this"); | |
1567 break; | |
1568 | |
1569 case _adapter_opt_swap_1: | |
1570 case _adapter_opt_swap_2: | |
1571 case _adapter_opt_rot_1_up: | |
1572 case _adapter_opt_rot_1_down: | |
1573 case _adapter_opt_rot_2_up: | |
1574 case _adapter_opt_rot_2_down: | |
1575 { | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1576 int swap_slots = ek_adapter_opt_swap_slots(ek); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1577 int rotate = ek_adapter_opt_swap_mode(ek); |
710 | 1578 |
1579 // 'argslot' is the position of the first argument to swap | |
1580 __ movl(rax_argslot, rcx_amh_vmargslot); | |
1581 __ lea(rax_argslot, __ argument_address(rax_argslot)); | |
1582 | |
1583 // 'vminfo' is the second | |
1584 Register rbx_destslot = rbx_temp; | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1585 load_conversion_vminfo(_masm, rbx_destslot, rcx_amh_conversion); |
710 | 1586 __ lea(rbx_destslot, __ argument_address(rbx_destslot)); |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1587 if (VerifyMethodHandles) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1588 verify_argslot(_masm, rbx_destslot, "swap point must fall within current frame"); |
710 | 1589 |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1590 assert(Interpreter::stackElementSize == wordSize, "else rethink use of wordSize here"); |
710 | 1591 if (!rotate) { |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1592 // simple swap |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1593 for (int i = 0; i < swap_slots; i++) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1594 __ movptr(rdi_temp, Address(rax_argslot, i * wordSize)); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1595 __ movptr(rdx_temp, Address(rbx_destslot, i * wordSize)); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1596 __ movptr(Address(rax_argslot, i * wordSize), rdx_temp); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1597 __ movptr(Address(rbx_destslot, i * wordSize), rdi_temp); |
710 | 1598 } |
1599 } else { | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1600 // A rotate is actually pair of moves, with an "odd slot" (or pair) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1601 // changing place with a series of other slots. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1602 // First, push the "odd slot", which is going to get overwritten |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1603 for (int i = swap_slots - 1; i >= 0; i--) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1604 // handle one with rdi_temp instead of a push: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1605 if (i == 0) __ movptr(rdi_temp, Address(rax_argslot, i * wordSize)); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1606 else __ pushptr( Address(rax_argslot, i * wordSize)); |
710 | 1607 } |
1608 if (rotate > 0) { | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1609 // Here is rotate > 0: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1610 // (low mem) (high mem) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1611 // | dest: more_slots... | arg: odd_slot :arg+1 | |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1612 // => |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1613 // | dest: odd_slot | dest+1: more_slots... :arg+1 | |
710 | 1614 // work argslot down to destslot, copying contiguous data upwards |
1615 // pseudo-code: | |
1616 // rax = src_addr - swap_bytes | |
1617 // rbx = dest_addr | |
1618 // while (rax >= rbx) *(rax + swap_bytes) = *(rax + 0), rax--; | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1619 move_arg_slots_up(_masm, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1620 rbx_destslot, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1621 Address(rax_argslot, 0), |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1622 swap_slots, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1623 rax_argslot, rdx_temp); |
710 | 1624 } else { |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1625 // Here is the other direction, rotate < 0: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1626 // (low mem) (high mem) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1627 // | arg: odd_slot | arg+1: more_slots... :dest+1 | |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1628 // => |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1629 // | arg: more_slots... | dest: odd_slot :dest+1 | |
710 | 1630 // work argslot up to destslot, copying contiguous data downwards |
1631 // pseudo-code: | |
1632 // rax = src_addr + swap_bytes | |
1633 // rbx = dest_addr | |
1634 // while (rax <= rbx) *(rax - swap_bytes) = *(rax + 0), rax++; | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1635 __ addptr(rbx_destslot, wordSize); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1636 move_arg_slots_down(_masm, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1637 Address(rax_argslot, swap_slots * wordSize), |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1638 rbx_destslot, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1639 -swap_slots, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1640 rax_argslot, rdx_temp); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1641 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1642 __ subptr(rbx_destslot, wordSize); |
710 | 1643 } |
1644 // pop the original first chunk into the destination slot, now free | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1645 for (int i = 0; i < swap_slots; i++) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1646 if (i == 0) __ movptr(Address(rbx_destslot, i * wordSize), rdi_temp); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1647 else __ popptr(Address(rbx_destslot, i * wordSize)); |
710 | 1648 } |
1649 } | |
1650 | |
1846 | 1651 __ load_heap_oop(rcx_recv, rcx_mh_vmtarget); |
710 | 1652 __ jump_to_method_handle_entry(rcx_recv, rdx_temp); |
1653 } | |
1654 break; | |
1655 | |
1656 case _adapter_dup_args: | |
1657 { | |
1658 // 'argslot' is the position of the first argument to duplicate | |
1659 __ movl(rax_argslot, rcx_amh_vmargslot); | |
1660 __ lea(rax_argslot, __ argument_address(rax_argslot)); | |
1661 | |
1662 // 'stack_move' is negative number of words to duplicate | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1663 Register rdi_stack_move = rdi_temp; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1664 load_stack_move(_masm, rdi_stack_move, rcx_recv, true); |
710 | 1665 |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1666 if (VerifyMethodHandles) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1667 verify_argslots(_masm, rdi_stack_move, rax_argslot, true, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1668 "copied argument(s) must fall within current frame"); |
710 | 1669 } |
1670 | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1671 // insert location is always the bottom of the argument list: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1672 Address insert_location = __ argument_address(constant(0)); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1673 int pre_arg_words = insert_location.disp() / wordSize; // return PC is pushed |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1674 assert(insert_location.base() == rsp, ""); |
710 | 1675 |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1676 __ negl(rdi_stack_move); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1677 push_arg_slots(_masm, rax_argslot, rdi_stack_move, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1678 pre_arg_words, rbx_temp, rdx_temp); |
710 | 1679 |
1846 | 1680 __ load_heap_oop(rcx_recv, rcx_mh_vmtarget); |
710 | 1681 __ jump_to_method_handle_entry(rcx_recv, rdx_temp); |
1682 } | |
1683 break; | |
1684 | |
1685 case _adapter_drop_args: | |
1686 { | |
1687 // 'argslot' is the position of the first argument to nuke | |
1688 __ movl(rax_argslot, rcx_amh_vmargslot); | |
1689 __ lea(rax_argslot, __ argument_address(rax_argslot)); | |
1690 | |
1691 // (must do previous push after argslot address is taken) | |
1692 | |
1693 // 'stack_move' is number of words to drop | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1694 Register rdi_stack_move = rdi_temp; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1695 load_stack_move(_masm, rdi_stack_move, rcx_recv, false); |
710 | 1696 remove_arg_slots(_masm, rdi_stack_move, |
1697 rax_argslot, rbx_temp, rdx_temp); | |
1698 | |
1846 | 1699 __ load_heap_oop(rcx_recv, rcx_mh_vmtarget); |
710 | 1700 __ jump_to_method_handle_entry(rcx_recv, rdx_temp); |
1701 } | |
1702 break; | |
1703 | |
1704 case _adapter_collect_args: | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1705 case _adapter_fold_args: |
710 | 1706 case _adapter_spread_args: |
1707 // handled completely by optimized cases | |
1708 __ stop("init_AdapterMethodHandle should not issue this"); | |
1709 break; | |
1710 | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1711 case _adapter_opt_collect_ref: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1712 case _adapter_opt_collect_int: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1713 case _adapter_opt_collect_long: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1714 case _adapter_opt_collect_float: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1715 case _adapter_opt_collect_double: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1716 case _adapter_opt_collect_void: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1717 case _adapter_opt_collect_0_ref: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1718 case _adapter_opt_collect_1_ref: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1719 case _adapter_opt_collect_2_ref: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1720 case _adapter_opt_collect_3_ref: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1721 case _adapter_opt_collect_4_ref: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1722 case _adapter_opt_collect_5_ref: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1723 case _adapter_opt_filter_S0_ref: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1724 case _adapter_opt_filter_S1_ref: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1725 case _adapter_opt_filter_S2_ref: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1726 case _adapter_opt_filter_S3_ref: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1727 case _adapter_opt_filter_S4_ref: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1728 case _adapter_opt_filter_S5_ref: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1729 case _adapter_opt_collect_2_S0_ref: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1730 case _adapter_opt_collect_2_S1_ref: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1731 case _adapter_opt_collect_2_S2_ref: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1732 case _adapter_opt_collect_2_S3_ref: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1733 case _adapter_opt_collect_2_S4_ref: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1734 case _adapter_opt_collect_2_S5_ref: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1735 case _adapter_opt_fold_ref: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1736 case _adapter_opt_fold_int: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1737 case _adapter_opt_fold_long: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1738 case _adapter_opt_fold_float: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1739 case _adapter_opt_fold_double: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1740 case _adapter_opt_fold_void: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1741 case _adapter_opt_fold_1_ref: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1742 case _adapter_opt_fold_2_ref: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1743 case _adapter_opt_fold_3_ref: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1744 case _adapter_opt_fold_4_ref: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1745 case _adapter_opt_fold_5_ref: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1746 { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1747 // Given a fresh incoming stack frame, build a new ricochet frame. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1748 // On entry, TOS points at a return PC, and RBP is the callers frame ptr. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1749 // RSI/R13 has the caller's exact stack pointer, which we must also preserve. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1750 // RCX contains an AdapterMethodHandle of the indicated kind. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1751 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1752 // Relevant AMH fields: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1753 // amh.vmargslot: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1754 // points to the trailing edge of the arguments |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1755 // to filter, collect, or fold. For a boxing operation, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1756 // it points just after the single primitive value. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1757 // amh.argument: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1758 // recursively called MH, on |collect| arguments |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1759 // amh.vmtarget: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1760 // final destination MH, on return value, etc. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1761 // amh.conversion.dest: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1762 // tells what is the type of the return value |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1763 // (not needed here, since dest is also derived from ek) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1764 // amh.conversion.vminfo: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1765 // points to the trailing edge of the return value |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1766 // when the vmtarget is to be called; this is |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1767 // equal to vmargslot + (retained ? |collect| : 0) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1768 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1769 // Pass 0 or more argument slots to the recursive target. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1770 int collect_count_constant = ek_adapter_opt_collect_count(ek); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1771 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1772 // The collected arguments are copied from the saved argument list: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1773 int collect_slot_constant = ek_adapter_opt_collect_slot(ek); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1774 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1775 assert(ek_orig == _adapter_collect_args || |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1776 ek_orig == _adapter_fold_args, ""); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1777 bool retain_original_args = (ek_orig == _adapter_fold_args); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1778 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1779 // The return value is replaced (or inserted) at the 'vminfo' argslot. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1780 // Sometimes we can compute this statically. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1781 int dest_slot_constant = -1; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1782 if (!retain_original_args) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1783 dest_slot_constant = collect_slot_constant; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1784 else if (collect_slot_constant >= 0 && collect_count_constant >= 0) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1785 // We are preserving all the arguments, and the return value is prepended, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1786 // so the return slot is to the left (above) the |collect| sequence. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1787 dest_slot_constant = collect_slot_constant + collect_count_constant; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1788 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1789 // Replace all those slots by the result of the recursive call. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1790 // The result type can be one of ref, int, long, float, double, void. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1791 // In the case of void, nothing is pushed on the stack after return. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1792 BasicType dest = ek_adapter_opt_collect_type(ek); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1793 assert(dest == type2wfield[dest], "dest is a stack slot type"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1794 int dest_count = type2size[dest]; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1795 assert(dest_count == 1 || dest_count == 2 || (dest_count == 0 && dest == T_VOID), "dest has a size"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1796 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1797 // Choose a return continuation. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1798 EntryKind ek_ret = _adapter_opt_return_any; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1799 if (dest != T_CONFLICT && OptimizeMethodHandles) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1800 switch (dest) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1801 case T_INT : ek_ret = _adapter_opt_return_int; break; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1802 case T_LONG : ek_ret = _adapter_opt_return_long; break; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1803 case T_FLOAT : ek_ret = _adapter_opt_return_float; break; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1804 case T_DOUBLE : ek_ret = _adapter_opt_return_double; break; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1805 case T_OBJECT : ek_ret = _adapter_opt_return_ref; break; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1806 case T_VOID : ek_ret = _adapter_opt_return_void; break; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1807 default : ShouldNotReachHere(); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1808 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1809 if (dest == T_OBJECT && dest_slot_constant >= 0) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1810 EntryKind ek_try = EntryKind(_adapter_opt_return_S0_ref + dest_slot_constant); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1811 if (ek_try <= _adapter_opt_return_LAST && |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1812 ek_adapter_opt_return_slot(ek_try) == dest_slot_constant) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1813 ek_ret = ek_try; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1814 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1815 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1816 assert(ek_adapter_opt_return_type(ek_ret) == dest, ""); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1817 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1818 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1819 // Already pushed: ... keep1 | collect | keep2 | sender_pc | |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1820 // push(sender_pc); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1821 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1822 // Compute argument base: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1823 Register rax_argv = rax_argslot; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1824 __ lea(rax_argv, __ argument_address(constant(0))); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1825 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1826 // Push a few extra argument words, if we need them to store the return value. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1827 { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1828 int extra_slots = 0; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1829 if (retain_original_args) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1830 extra_slots = dest_count; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1831 } else if (collect_count_constant == -1) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1832 extra_slots = dest_count; // collect_count might be zero; be generous |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1833 } else if (dest_count > collect_count_constant) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1834 extra_slots = (dest_count - collect_count_constant); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1835 } else { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1836 // else we know we have enough dead space in |collect| to repurpose for return values |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1837 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1838 DEBUG_ONLY(extra_slots += 1); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1839 if (extra_slots > 0) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1840 __ pop(rbx_temp); // return value |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1841 __ subptr(rsp, (extra_slots * Interpreter::stackElementSize)); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1842 // Push guard word #2 in debug mode. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1843 DEBUG_ONLY(__ movptr(Address(rsp, 0), (int32_t) RicochetFrame::MAGIC_NUMBER_2)); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1844 __ push(rbx_temp); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1845 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1846 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1847 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1848 RicochetFrame::enter_ricochet_frame(_masm, rcx_recv, rax_argv, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1849 entry(ek_ret)->from_interpreted_entry(), rbx_temp); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1850 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1851 // Now pushed: ... keep1 | collect | keep2 | RF | |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1852 // some handy frame slots: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1853 Address exact_sender_sp_addr = RicochetFrame::frame_address(RicochetFrame::exact_sender_sp_offset_in_bytes()); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1854 Address conversion_addr = RicochetFrame::frame_address(RicochetFrame::conversion_offset_in_bytes()); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1855 Address saved_args_base_addr = RicochetFrame::frame_address(RicochetFrame::saved_args_base_offset_in_bytes()); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1856 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1857 #ifdef ASSERT |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1858 if (VerifyMethodHandles && dest != T_CONFLICT) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1859 BLOCK_COMMENT("verify AMH.conv.dest"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1860 load_conversion_dest_type(_masm, rbx_temp, conversion_addr); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1861 Label L_dest_ok; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1862 __ cmpl(rbx_temp, (int) dest); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1863 __ jcc(Assembler::equal, L_dest_ok); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1864 if (dest == T_INT) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1865 for (int bt = T_BOOLEAN; bt < T_INT; bt++) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1866 if (is_subword_type(BasicType(bt))) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1867 __ cmpl(rbx_temp, (int) bt); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1868 __ jcc(Assembler::equal, L_dest_ok); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1869 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1870 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1871 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1872 __ stop("bad dest in AMH.conv"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1873 __ BIND(L_dest_ok); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1874 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1875 #endif //ASSERT |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1876 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1877 // Find out where the original copy of the recursive argument sequence begins. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1878 Register rax_coll = rax_argv; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1879 { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1880 RegisterOrConstant collect_slot = collect_slot_constant; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1881 if (collect_slot_constant == -1) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1882 __ movl(rdi_temp, rcx_amh_vmargslot); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1883 collect_slot = rdi_temp; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1884 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1885 if (collect_slot_constant != 0) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1886 __ lea(rax_coll, Address(rax_argv, collect_slot, Interpreter::stackElementScale())); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1887 // rax_coll now points at the trailing edge of |collect| and leading edge of |keep2| |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1888 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1889 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1890 // Replace the old AMH with the recursive MH. (No going back now.) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1891 // In the case of a boxing call, the recursive call is to a 'boxer' method, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1892 // such as Integer.valueOf or Long.valueOf. In the case of a filter |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1893 // or collect call, it will take one or more arguments, transform them, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1894 // and return some result, to store back into argument_base[vminfo]. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1895 __ load_heap_oop(rcx_recv, rcx_amh_argument); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1896 if (VerifyMethodHandles) verify_method_handle(_masm, rcx_recv); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1897 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1898 // Push a space for the recursively called MH first: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1899 __ push((int32_t)NULL_WORD); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1900 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1901 // Calculate |collect|, the number of arguments we are collecting. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1902 Register rdi_collect_count = rdi_temp; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1903 RegisterOrConstant collect_count; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1904 if (collect_count_constant >= 0) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1905 collect_count = collect_count_constant; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1906 } else { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1907 __ load_method_handle_vmslots(rdi_collect_count, rcx_recv, rdx_temp); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1908 collect_count = rdi_collect_count; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1909 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1910 #ifdef ASSERT |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1911 if (VerifyMethodHandles && collect_count_constant >= 0) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1912 __ load_method_handle_vmslots(rbx_temp, rcx_recv, rdx_temp); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1913 Label L_count_ok; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1914 __ cmpl(rbx_temp, collect_count_constant); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1915 __ jcc(Assembler::equal, L_count_ok); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1916 __ stop("bad vminfo in AMH.conv"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1917 __ BIND(L_count_ok); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1918 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1919 #endif //ASSERT |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1920 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1921 // copy |collect| slots directly to TOS: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1922 push_arg_slots(_masm, rax_coll, collect_count, 0, rbx_temp, rdx_temp); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1923 // Now pushed: ... keep1 | collect | keep2 | RF... | collect | |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1924 // rax_coll still points at the trailing edge of |collect| and leading edge of |keep2| |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1925 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1926 // If necessary, adjust the saved arguments to make room for the eventual return value. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1927 // Normal adjustment: ... keep1 | +dest+ | -collect- | keep2 | RF... | collect | |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1928 // If retaining args: ... keep1 | +dest+ | collect | keep2 | RF... | collect | |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1929 // In the non-retaining case, this might move keep2 either up or down. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1930 // We don't have to copy the whole | RF... collect | complex, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1931 // but we must adjust RF.saved_args_base. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1932 // Also, from now on, we will forget about the origial copy of |collect|. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1933 // If we are retaining it, we will treat it as part of |keep2|. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1934 // For clarity we will define |keep3| = |collect|keep2| or |keep2|. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1935 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1936 BLOCK_COMMENT("adjust trailing arguments {"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1937 // Compare the sizes of |+dest+| and |-collect-|, which are opposed opening and closing movements. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1938 int open_count = dest_count; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1939 RegisterOrConstant close_count = collect_count_constant; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1940 Register rdi_close_count = rdi_collect_count; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1941 if (retain_original_args) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1942 close_count = constant(0); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1943 } else if (collect_count_constant == -1) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1944 close_count = rdi_collect_count; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1945 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1946 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1947 // How many slots need moving? This is simply dest_slot (0 => no |keep3|). |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1948 RegisterOrConstant keep3_count; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1949 Register rsi_keep3_count = rsi; // can repair from RF.exact_sender_sp |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1950 if (dest_slot_constant >= 0) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1951 keep3_count = dest_slot_constant; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1952 } else { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1953 load_conversion_vminfo(_masm, rsi_keep3_count, conversion_addr); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1954 keep3_count = rsi_keep3_count; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1955 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1956 #ifdef ASSERT |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1957 if (VerifyMethodHandles && dest_slot_constant >= 0) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1958 load_conversion_vminfo(_masm, rbx_temp, conversion_addr); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1959 Label L_vminfo_ok; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1960 __ cmpl(rbx_temp, dest_slot_constant); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1961 __ jcc(Assembler::equal, L_vminfo_ok); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1962 __ stop("bad vminfo in AMH.conv"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1963 __ BIND(L_vminfo_ok); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1964 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1965 #endif //ASSERT |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1966 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1967 // tasks remaining: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1968 bool move_keep3 = (!keep3_count.is_constant() || keep3_count.as_constant() != 0); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1969 bool stomp_dest = (NOT_DEBUG(dest == T_OBJECT) DEBUG_ONLY(dest_count != 0)); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1970 bool fix_arg_base = (!close_count.is_constant() || open_count != close_count.as_constant()); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1971 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1972 if (stomp_dest | fix_arg_base) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1973 // we will probably need an updated rax_argv value |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1974 if (collect_slot_constant >= 0) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1975 // rax_coll already holds the leading edge of |keep2|, so tweak it |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1976 assert(rax_coll == rax_argv, "elided a move"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1977 if (collect_slot_constant != 0) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1978 __ subptr(rax_argv, collect_slot_constant * Interpreter::stackElementSize); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1979 } else { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1980 // Just reload from RF.saved_args_base. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1981 __ movptr(rax_argv, saved_args_base_addr); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1982 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1983 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1984 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1985 // Old and new argument locations (based at slot 0). |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1986 // Net shift (&new_argv - &old_argv) is (close_count - open_count). |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1987 bool zero_open_count = (open_count == 0); // remember this bit of info |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1988 if (move_keep3 && fix_arg_base) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1989 // It will be easier t have everything in one register: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1990 if (close_count.is_register()) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1991 // Deduct open_count from close_count register to get a clean +/- value. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1992 __ subptr(close_count.as_register(), open_count); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1993 } else { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1994 close_count = close_count.as_constant() - open_count; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1995 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1996 open_count = 0; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1997 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1998 Address old_argv(rax_argv, 0); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
1999 Address new_argv(rax_argv, close_count, Interpreter::stackElementScale(), |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2000 - open_count * Interpreter::stackElementSize); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2001 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2002 // First decide if any actual data are to be moved. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2003 // We can skip if (a) |keep3| is empty, or (b) the argument list size didn't change. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2004 // (As it happens, all movements involve an argument list size change.) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2005 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2006 // If there are variable parameters, use dynamic checks to skip around the whole mess. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2007 Label L_done; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2008 if (!keep3_count.is_constant()) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2009 __ testl(keep3_count.as_register(), keep3_count.as_register()); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2010 __ jcc(Assembler::zero, L_done); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2011 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2012 if (!close_count.is_constant()) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2013 __ cmpl(close_count.as_register(), open_count); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2014 __ jcc(Assembler::equal, L_done); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2015 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2016 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2017 if (move_keep3 && fix_arg_base) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2018 bool emit_move_down = false, emit_move_up = false, emit_guard = false; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2019 if (!close_count.is_constant()) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2020 emit_move_down = emit_guard = !zero_open_count; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2021 emit_move_up = true; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2022 } else if (open_count != close_count.as_constant()) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2023 emit_move_down = (open_count > close_count.as_constant()); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2024 emit_move_up = !emit_move_down; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2025 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2026 Label L_move_up; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2027 if (emit_guard) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2028 __ cmpl(close_count.as_register(), open_count); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2029 __ jcc(Assembler::greater, L_move_up); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2030 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2031 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2032 if (emit_move_down) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2033 // Move arguments down if |+dest+| > |-collect-| |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2034 // (This is rare, except when arguments are retained.) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2035 // This opens space for the return value. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2036 if (keep3_count.is_constant()) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2037 for (int i = 0; i < keep3_count.as_constant(); i++) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2038 __ movptr(rdx_temp, old_argv.plus_disp(i * Interpreter::stackElementSize)); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2039 __ movptr( new_argv.plus_disp(i * Interpreter::stackElementSize), rdx_temp); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2040 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2041 } else { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2042 Register rbx_argv_top = rbx_temp; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2043 __ lea(rbx_argv_top, old_argv.plus_disp(keep3_count, Interpreter::stackElementScale())); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2044 move_arg_slots_down(_masm, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2045 old_argv, // beginning of old argv |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2046 rbx_argv_top, // end of old argv |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2047 close_count, // distance to move down (must be negative) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2048 rax_argv, rdx_temp); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2049 // Used argv as an iteration variable; reload from RF.saved_args_base. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2050 __ movptr(rax_argv, saved_args_base_addr); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2051 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2052 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2053 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2054 if (emit_guard) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2055 __ jmp(L_done); // assumes emit_move_up is true also |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2056 __ BIND(L_move_up); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2057 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2058 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2059 if (emit_move_up) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2060 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2061 // Move arguments up if |+dest+| < |-collect-| |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2062 // (This is usual, except when |keep3| is empty.) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2063 // This closes up the space occupied by the now-deleted collect values. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2064 if (keep3_count.is_constant()) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2065 for (int i = keep3_count.as_constant() - 1; i >= 0; i--) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2066 __ movptr(rdx_temp, old_argv.plus_disp(i * Interpreter::stackElementSize)); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2067 __ movptr( new_argv.plus_disp(i * Interpreter::stackElementSize), rdx_temp); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2068 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2069 } else { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2070 Address argv_top = old_argv.plus_disp(keep3_count, Interpreter::stackElementScale()); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2071 move_arg_slots_up(_masm, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2072 rax_argv, // beginning of old argv |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2073 argv_top, // end of old argv |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2074 close_count, // distance to move up (must be positive) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2075 rbx_temp, rdx_temp); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2076 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2077 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2078 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2079 __ BIND(L_done); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2080 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2081 if (fix_arg_base) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2082 // adjust RF.saved_args_base by adding (close_count - open_count) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2083 if (!new_argv.is_same_address(Address(rax_argv, 0))) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2084 __ lea(rax_argv, new_argv); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2085 __ movptr(saved_args_base_addr, rax_argv); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2086 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2087 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2088 if (stomp_dest) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2089 // Stomp the return slot, so it doesn't hold garbage. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2090 // This isn't strictly necessary, but it may help detect bugs. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2091 int forty_two = RicochetFrame::RETURN_VALUE_PLACEHOLDER; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2092 __ movptr(Address(rax_argv, keep3_count, Address::times_ptr), |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2093 (int32_t) forty_two); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2094 // uses rsi_keep3_count |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2095 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2096 BLOCK_COMMENT("} adjust trailing arguments"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2097 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2098 BLOCK_COMMENT("do_recursive_call"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2099 __ mov(saved_last_sp, rsp); // set rsi/r13 for callee |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2100 __ pushptr(ExternalAddress(SharedRuntime::ricochet_blob()->bounce_addr()).addr()); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2101 // The globally unique bounce address has two purposes: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2102 // 1. It helps the JVM recognize this frame (frame::is_ricochet_frame). |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2103 // 2. When returned to, it cuts back the stack and redirects control flow |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2104 // to the return handler. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2105 // The return handler will further cut back the stack when it takes |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2106 // down the RF. Perhaps there is a way to streamline this further. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2107 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2108 // State during recursive call: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2109 // ... keep1 | dest | dest=42 | keep3 | RF... | collect | bounce_pc | |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2110 __ jump_to_method_handle_entry(rcx_recv, rdx_temp); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2111 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2112 break; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2113 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2114 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2115 case _adapter_opt_return_ref: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2116 case _adapter_opt_return_int: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2117 case _adapter_opt_return_long: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2118 case _adapter_opt_return_float: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2119 case _adapter_opt_return_double: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2120 case _adapter_opt_return_void: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2121 case _adapter_opt_return_S0_ref: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2122 case _adapter_opt_return_S1_ref: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2123 case _adapter_opt_return_S2_ref: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2124 case _adapter_opt_return_S3_ref: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2125 case _adapter_opt_return_S4_ref: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2126 case _adapter_opt_return_S5_ref: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2127 { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2128 BasicType dest_type_constant = ek_adapter_opt_return_type(ek); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2129 int dest_slot_constant = ek_adapter_opt_return_slot(ek); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2130 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2131 if (VerifyMethodHandles) RicochetFrame::verify_clean(_masm); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2132 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2133 if (dest_slot_constant == -1) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2134 // The current stub is a general handler for this dest_type. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2135 // It can be called from _adapter_opt_return_any below. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2136 // Stash the address in a little table. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2137 assert((dest_type_constant & CONV_TYPE_MASK) == dest_type_constant, "oob"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2138 address return_handler = __ pc(); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2139 _adapter_return_handlers[dest_type_constant] = return_handler; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2140 if (dest_type_constant == T_INT) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2141 // do the subword types too |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2142 for (int bt = T_BOOLEAN; bt < T_INT; bt++) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2143 if (is_subword_type(BasicType(bt)) && |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2144 _adapter_return_handlers[bt] == NULL) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2145 _adapter_return_handlers[bt] = return_handler; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2146 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2147 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2148 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2149 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2150 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2151 Register rbx_arg_base = rbx_temp; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2152 assert_different_registers(rax, rdx, // possibly live return value registers |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2153 rdi_temp, rbx_arg_base); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2154 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2155 Address conversion_addr = RicochetFrame::frame_address(RicochetFrame::conversion_offset_in_bytes()); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2156 Address saved_args_base_addr = RicochetFrame::frame_address(RicochetFrame::saved_args_base_offset_in_bytes()); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2157 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2158 __ movptr(rbx_arg_base, saved_args_base_addr); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2159 RegisterOrConstant dest_slot = dest_slot_constant; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2160 if (dest_slot_constant == -1) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2161 load_conversion_vminfo(_masm, rdi_temp, conversion_addr); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2162 dest_slot = rdi_temp; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2163 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2164 // Store the result back into the argslot. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2165 // This code uses the interpreter calling sequence, in which the return value |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2166 // is usually left in the TOS register, as defined by InterpreterMacroAssembler::pop. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2167 // There are certain irregularities with floating point values, which can be seen |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2168 // in TemplateInterpreterGenerator::generate_return_entry_for. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2169 move_return_value(_masm, dest_type_constant, Address(rbx_arg_base, dest_slot, Interpreter::stackElementScale())); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2170 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2171 RicochetFrame::leave_ricochet_frame(_masm, rcx_recv, rbx_arg_base, rdx_temp); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2172 __ push(rdx_temp); // repush the return PC |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2173 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2174 // Load the final target and go. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2175 if (VerifyMethodHandles) verify_method_handle(_masm, rcx_recv); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2176 __ jump_to_method_handle_entry(rcx_recv, rdx_temp); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2177 __ hlt(); // -------------------- |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2178 break; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2179 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2180 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2181 case _adapter_opt_return_any: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2182 { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2183 if (VerifyMethodHandles) RicochetFrame::verify_clean(_masm); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2184 Register rdi_conv = rdi_temp; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2185 assert_different_registers(rax, rdx, // possibly live return value registers |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2186 rdi_conv, rbx_temp); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2187 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2188 Address conversion_addr = RicochetFrame::frame_address(RicochetFrame::conversion_offset_in_bytes()); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2189 load_conversion_dest_type(_masm, rdi_conv, conversion_addr); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2190 __ lea(rbx_temp, ExternalAddress((address) &_adapter_return_handlers[0])); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2191 __ movptr(rbx_temp, Address(rbx_temp, rdi_conv, Address::times_ptr)); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2192 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2193 #ifdef ASSERT |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2194 { Label L_badconv; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2195 __ testptr(rbx_temp, rbx_temp); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2196 __ jccb(Assembler::zero, L_badconv); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2197 __ jmp(rbx_temp); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2198 __ bind(L_badconv); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2199 __ stop("bad method handle return"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2200 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2201 #else //ASSERT |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2202 __ jmp(rbx_temp); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2203 #endif //ASSERT |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2204 break; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2205 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2206 |
710 | 2207 case _adapter_opt_spread_0: |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2208 case _adapter_opt_spread_1_ref: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2209 case _adapter_opt_spread_2_ref: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2210 case _adapter_opt_spread_3_ref: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2211 case _adapter_opt_spread_4_ref: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2212 case _adapter_opt_spread_5_ref: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2213 case _adapter_opt_spread_ref: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2214 case _adapter_opt_spread_byte: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2215 case _adapter_opt_spread_char: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2216 case _adapter_opt_spread_short: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2217 case _adapter_opt_spread_int: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2218 case _adapter_opt_spread_long: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2219 case _adapter_opt_spread_float: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2220 case _adapter_opt_spread_double: |
710 | 2221 { |
2222 // spread an array out into a group of arguments | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2223 int length_constant = ek_adapter_opt_spread_count(ek); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2224 bool length_can_be_zero = (length_constant == 0); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2225 if (length_constant < 0) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2226 // some adapters with variable length must handle the zero case |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2227 if (!OptimizeMethodHandles || |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2228 ek_adapter_opt_spread_type(ek) != T_OBJECT) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2229 length_can_be_zero = true; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2230 } |
710 | 2231 |
2232 // find the address of the array argument | |
2233 __ movl(rax_argslot, rcx_amh_vmargslot); | |
2234 __ lea(rax_argslot, __ argument_address(rax_argslot)); | |
2235 | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2236 // grab another temp |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2237 Register rsi_temp = rsi; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2238 { if (rsi_temp == saved_last_sp) __ push(saved_last_sp); } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2239 // (preceding push must be done after argslot address is taken!) |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2240 #define UNPUSH_RSI \ |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2241 { if (rsi_temp == saved_last_sp) __ pop(saved_last_sp); } |
710 | 2242 |
2243 // arx_argslot points both to the array and to the first output arg | |
2244 vmarg = Address(rax_argslot, 0); | |
2245 | |
2246 // Get the array value. | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2247 Register rsi_array = rsi_temp; |
710 | 2248 Register rdx_array_klass = rdx_temp; |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2249 BasicType elem_type = ek_adapter_opt_spread_type(ek); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2250 int elem_slots = type2size[elem_type]; // 1 or 2 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2251 int array_slots = 1; // array is always a T_OBJECT |
710 | 2252 int length_offset = arrayOopDesc::length_offset_in_bytes(); |
2253 int elem0_offset = arrayOopDesc::base_offset_in_bytes(elem_type); | |
2254 __ movptr(rsi_array, vmarg); | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2255 |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2256 Label L_array_is_empty, L_insert_arg_space, L_copy_args, L_args_done; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2257 if (length_can_be_zero) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2258 // handle the null pointer case, if zero is allowed |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2259 Label L_skip; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2260 if (length_constant < 0) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2261 load_conversion_vminfo(_masm, rbx_temp, rcx_amh_conversion); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2262 __ testl(rbx_temp, rbx_temp); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2263 __ jcc(Assembler::notZero, L_skip); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2264 } |
710 | 2265 __ testptr(rsi_array, rsi_array); |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2266 __ jcc(Assembler::zero, L_array_is_empty); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2267 __ bind(L_skip); |
710 | 2268 } |
2269 __ null_check(rsi_array, oopDesc::klass_offset_in_bytes()); | |
2270 __ load_klass(rdx_array_klass, rsi_array); | |
2271 | |
2272 // Check the array type. | |
2273 Register rbx_klass = rbx_temp; | |
1846 | 2274 __ load_heap_oop(rbx_klass, rcx_amh_argument); // this is a Class object! |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2275 load_klass_from_Class(_masm, rbx_klass); |
710 | 2276 |
2277 Label ok_array_klass, bad_array_klass, bad_array_length; | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2278 __ check_klass_subtype(rdx_array_klass, rbx_klass, rdi_temp, ok_array_klass); |
710 | 2279 // If we get here, the type check failed! |
2280 __ jmp(bad_array_klass); | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2281 __ BIND(ok_array_klass); |
710 | 2282 |
2283 // Check length. | |
2284 if (length_constant >= 0) { | |
2285 __ cmpl(Address(rsi_array, length_offset), length_constant); | |
2286 } else { | |
2287 Register rbx_vminfo = rbx_temp; | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2288 load_conversion_vminfo(_masm, rbx_vminfo, rcx_amh_conversion); |
710 | 2289 __ cmpl(rbx_vminfo, Address(rsi_array, length_offset)); |
2290 } | |
2291 __ jcc(Assembler::notEqual, bad_array_length); | |
2292 | |
2293 Register rdx_argslot_limit = rdx_temp; | |
2294 | |
2295 // Array length checks out. Now insert any required stack slots. | |
2296 if (length_constant == -1) { | |
2297 // Form a pointer to the end of the affected region. | |
1506 | 2298 __ lea(rdx_argslot_limit, Address(rax_argslot, Interpreter::stackElementSize)); |
710 | 2299 // 'stack_move' is negative number of words to insert |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2300 // This number already accounts for elem_slots. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2301 Register rdi_stack_move = rdi_temp; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2302 load_stack_move(_masm, rdi_stack_move, rcx_recv, true); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2303 __ cmpptr(rdi_stack_move, 0); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2304 assert(stack_move_unit() < 0, "else change this comparison"); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2305 __ jcc(Assembler::less, L_insert_arg_space); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2306 __ jcc(Assembler::equal, L_copy_args); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2307 // single argument case, with no array movement |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2308 __ BIND(L_array_is_empty); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2309 remove_arg_slots(_masm, -stack_move_unit() * array_slots, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2310 rax_argslot, rbx_temp, rdx_temp); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2311 __ jmp(L_args_done); // no spreading to do |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2312 __ BIND(L_insert_arg_space); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2313 // come here in the usual case, stack_move < 0 (2 or more spread arguments) |
710 | 2314 Register rsi_temp = rsi_array; // spill this |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2315 insert_arg_slots(_masm, rdi_stack_move, |
710 | 2316 rax_argslot, rbx_temp, rsi_temp); |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2317 // reload the array since rsi was killed |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2318 // reload from rdx_argslot_limit since rax_argslot is now decremented |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2319 __ movptr(rsi_array, Address(rdx_argslot_limit, -Interpreter::stackElementSize)); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2320 } else if (length_constant >= 1) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2321 int new_slots = (length_constant * elem_slots) - array_slots; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2322 insert_arg_slots(_masm, new_slots * stack_move_unit(), |
710 | 2323 rax_argslot, rbx_temp, rdx_temp); |
2324 } else if (length_constant == 0) { | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2325 __ BIND(L_array_is_empty); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2326 remove_arg_slots(_masm, -stack_move_unit() * array_slots, |
710 | 2327 rax_argslot, rbx_temp, rdx_temp); |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2328 } else { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2329 ShouldNotReachHere(); |
710 | 2330 } |
2331 | |
2332 // Copy from the array to the new slots. | |
2333 // Note: Stack change code preserves integrity of rax_argslot pointer. | |
2334 // So even after slot insertions, rax_argslot still points to first argument. | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2335 // Beware: Arguments that are shallow on the stack are deep in the array, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2336 // and vice versa. So a downward-growing stack (the usual) has to be copied |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2337 // elementwise in reverse order from the source array. |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2338 __ BIND(L_copy_args); |
710 | 2339 if (length_constant == -1) { |
2340 // [rax_argslot, rdx_argslot_limit) is the area we are inserting into. | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2341 // Array element [0] goes at rdx_argslot_limit[-wordSize]. |
710 | 2342 Register rsi_source = rsi_array; |
2343 __ lea(rsi_source, Address(rsi_array, elem0_offset)); | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2344 Register rdx_fill_ptr = rdx_argslot_limit; |
710 | 2345 Label loop; |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2346 __ BIND(loop); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2347 __ addptr(rdx_fill_ptr, -Interpreter::stackElementSize * elem_slots); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2348 move_typed_arg(_masm, elem_type, true, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2349 Address(rdx_fill_ptr, 0), Address(rsi_source, 0), |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2350 rbx_temp, rdi_temp); |
710 | 2351 __ addptr(rsi_source, type2aelembytes(elem_type)); |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2352 __ cmpptr(rdx_fill_ptr, rax_argslot); |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3363
diff
changeset
|
2353 __ jcc(Assembler::above, loop); |
710 | 2354 } else if (length_constant == 0) { |
2355 // nothing to copy | |
2356 } else { | |
2357 int elem_offset = elem0_offset; | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2358 int slot_offset = length_constant * Interpreter::stackElementSize; |
710 | 2359 for (int index = 0; index < length_constant; index++) { |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2360 slot_offset -= Interpreter::stackElementSize * elem_slots; // fill backward |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2361 move_typed_arg(_masm, elem_type, true, |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2362 Address(rax_argslot, slot_offset), Address(rsi_array, elem_offset), |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2363 rbx_temp, rdi_temp); |
710 | 2364 elem_offset += type2aelembytes(elem_type); |
2365 } | |
2366 } | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2367 __ BIND(L_args_done); |
710 | 2368 |
2369 // Arguments are spread. Move to next method handle. | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2370 UNPUSH_RSI; |
1846 | 2371 __ load_heap_oop(rcx_recv, rcx_mh_vmtarget); |
710 | 2372 __ jump_to_method_handle_entry(rcx_recv, rdx_temp); |
2373 | |
2374 __ bind(bad_array_klass); | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2375 UNPUSH_RSI; |
2088
8d0b933dda2d
7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents:
1972
diff
changeset
|
2376 assert(!vmarg.uses(rarg2_required), "must be different registers"); |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2377 __ load_heap_oop( rarg2_required, Address(rdx_array_klass, java_mirror_offset)); // required type |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2378 __ movptr( rarg1_actual, vmarg); // bad array |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2379 __ 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
|
2380 __ jump(ExternalAddress(from_interpreted_entry(_raise_exception))); |
710 | 2381 |
2382 __ bind(bad_array_length); | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2383 UNPUSH_RSI; |
2088
8d0b933dda2d
7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents:
1972
diff
changeset
|
2384 assert(!vmarg.uses(rarg2_required), "must be different registers"); |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2385 __ mov( rarg2_required, rcx_recv); // AMH requiring a certain length |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2386 __ movptr( rarg1_actual, vmarg); // bad array |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2387 __ 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
|
2388 __ jump(ExternalAddress(from_interpreted_entry(_raise_exception))); |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2389 #undef UNPUSH_RSI |
710 | 2390 |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2391 break; |
710 | 2392 } |
2393 | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2394 default: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2395 // do not require all platforms to recognize all adapter types |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2396 __ nop(); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3336
diff
changeset
|
2397 return; |
710 | 2398 } |
2399 __ hlt(); | |
2400 | |
2401 address me_cookie = MethodHandleEntry::start_compiled_entry(_masm, interp_entry); | |
2402 __ unimplemented(entry_name(ek)); // %%% FIXME: NYI | |
2403 | |
2404 init_entry(ek, MethodHandleEntry::finish_compiled_entry(_masm, me_cookie)); | |
2405 } |