annotate src/cpu/x86/vm/stubGenerator_x86_64.cpp @ 16:f8236e79048a

6664627: Merge changes made only in hotspot 11 forward to jdk 7 Reviewed-by: jcoomes
author dcubed
date Wed, 05 Dec 2007 09:00:00 -0800
parents a61af66fc99e
children ba764ed4b6f2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 #include "incls/_precompiled.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
26 #include "incls/_stubGenerator_x86_64.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 // Declaration and definition of StubGenerator (no .hpp file).
a61af66fc99e Initial load
duke
parents:
diff changeset
29 // For a more detailed description of the stub routine structure
a61af66fc99e Initial load
duke
parents:
diff changeset
30 // see the comment in stubRoutines.hpp
a61af66fc99e Initial load
duke
parents:
diff changeset
31
a61af66fc99e Initial load
duke
parents:
diff changeset
32 #define __ _masm->
a61af66fc99e Initial load
duke
parents:
diff changeset
33
a61af66fc99e Initial load
duke
parents:
diff changeset
34 #ifdef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
35 #define BLOCK_COMMENT(str) /* nothing */
a61af66fc99e Initial load
duke
parents:
diff changeset
36 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
37 #define BLOCK_COMMENT(str) __ block_comment(str)
a61af66fc99e Initial load
duke
parents:
diff changeset
38 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40 #define BIND(label) bind(label); BLOCK_COMMENT(#label ":")
a61af66fc99e Initial load
duke
parents:
diff changeset
41 const int MXCSR_MASK = 0xFFC0; // Mask out any pending exceptions
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 // Stub Code definitions
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 static address handle_unsafe_access() {
a61af66fc99e Initial load
duke
parents:
diff changeset
46 JavaThread* thread = JavaThread::current();
a61af66fc99e Initial load
duke
parents:
diff changeset
47 address pc = thread->saved_exception_pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
48 // pc is the instruction which we must emulate
a61af66fc99e Initial load
duke
parents:
diff changeset
49 // doing a no-op is fine: return garbage from the load
a61af66fc99e Initial load
duke
parents:
diff changeset
50 // therefore, compute npc
a61af66fc99e Initial load
duke
parents:
diff changeset
51 address npc = Assembler::locate_next_instruction(pc);
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // request an async exception
a61af66fc99e Initial load
duke
parents:
diff changeset
54 thread->set_pending_unsafe_access_error();
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 // return address of next instruction to execute
a61af66fc99e Initial load
duke
parents:
diff changeset
57 return npc;
a61af66fc99e Initial load
duke
parents:
diff changeset
58 }
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 class StubGenerator: public StubCodeGenerator {
a61af66fc99e Initial load
duke
parents:
diff changeset
61 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63 #ifdef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
64 #define inc_counter_np(counter) (0)
a61af66fc99e Initial load
duke
parents:
diff changeset
65 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
66 void inc_counter_np_(int& counter) {
a61af66fc99e Initial load
duke
parents:
diff changeset
67 __ incrementl(ExternalAddress((address)&counter));
a61af66fc99e Initial load
duke
parents:
diff changeset
68 }
a61af66fc99e Initial load
duke
parents:
diff changeset
69 #define inc_counter_np(counter) \
a61af66fc99e Initial load
duke
parents:
diff changeset
70 BLOCK_COMMENT("inc_counter " #counter); \
a61af66fc99e Initial load
duke
parents:
diff changeset
71 inc_counter_np_(counter);
a61af66fc99e Initial load
duke
parents:
diff changeset
72 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
73
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // Call stubs are used to call Java from C
a61af66fc99e Initial load
duke
parents:
diff changeset
75 //
a61af66fc99e Initial load
duke
parents:
diff changeset
76 // Linux Arguments:
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // c_rarg0: call wrapper address address
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // c_rarg1: result address
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // c_rarg2: result type BasicType
a61af66fc99e Initial load
duke
parents:
diff changeset
80 // c_rarg3: method methodOop
a61af66fc99e Initial load
duke
parents:
diff changeset
81 // c_rarg4: (interpreter) entry point address
a61af66fc99e Initial load
duke
parents:
diff changeset
82 // c_rarg5: parameters intptr_t*
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // 16(rbp): parameter size (in words) int
a61af66fc99e Initial load
duke
parents:
diff changeset
84 // 24(rbp): thread Thread*
a61af66fc99e Initial load
duke
parents:
diff changeset
85 //
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // [ return_from_Java ] <--- rsp
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // [ argument word n ]
a61af66fc99e Initial load
duke
parents:
diff changeset
88 // ...
a61af66fc99e Initial load
duke
parents:
diff changeset
89 // -12 [ argument word 1 ]
a61af66fc99e Initial load
duke
parents:
diff changeset
90 // -11 [ saved r15 ] <--- rsp_after_call
a61af66fc99e Initial load
duke
parents:
diff changeset
91 // -10 [ saved r14 ]
a61af66fc99e Initial load
duke
parents:
diff changeset
92 // -9 [ saved r13 ]
a61af66fc99e Initial load
duke
parents:
diff changeset
93 // -8 [ saved r12 ]
a61af66fc99e Initial load
duke
parents:
diff changeset
94 // -7 [ saved rbx ]
a61af66fc99e Initial load
duke
parents:
diff changeset
95 // -6 [ call wrapper ]
a61af66fc99e Initial load
duke
parents:
diff changeset
96 // -5 [ result ]
a61af66fc99e Initial load
duke
parents:
diff changeset
97 // -4 [ result type ]
a61af66fc99e Initial load
duke
parents:
diff changeset
98 // -3 [ method ]
a61af66fc99e Initial load
duke
parents:
diff changeset
99 // -2 [ entry point ]
a61af66fc99e Initial load
duke
parents:
diff changeset
100 // -1 [ parameters ]
a61af66fc99e Initial load
duke
parents:
diff changeset
101 // 0 [ saved rbp ] <--- rbp
a61af66fc99e Initial load
duke
parents:
diff changeset
102 // 1 [ return address ]
a61af66fc99e Initial load
duke
parents:
diff changeset
103 // 2 [ parameter size ]
a61af66fc99e Initial load
duke
parents:
diff changeset
104 // 3 [ thread ]
a61af66fc99e Initial load
duke
parents:
diff changeset
105 //
a61af66fc99e Initial load
duke
parents:
diff changeset
106 // Windows Arguments:
a61af66fc99e Initial load
duke
parents:
diff changeset
107 // c_rarg0: call wrapper address address
a61af66fc99e Initial load
duke
parents:
diff changeset
108 // c_rarg1: result address
a61af66fc99e Initial load
duke
parents:
diff changeset
109 // c_rarg2: result type BasicType
a61af66fc99e Initial load
duke
parents:
diff changeset
110 // c_rarg3: method methodOop
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // 48(rbp): (interpreter) entry point address
a61af66fc99e Initial load
duke
parents:
diff changeset
112 // 56(rbp): parameters intptr_t*
a61af66fc99e Initial load
duke
parents:
diff changeset
113 // 64(rbp): parameter size (in words) int
a61af66fc99e Initial load
duke
parents:
diff changeset
114 // 72(rbp): thread Thread*
a61af66fc99e Initial load
duke
parents:
diff changeset
115 //
a61af66fc99e Initial load
duke
parents:
diff changeset
116 // [ return_from_Java ] <--- rsp
a61af66fc99e Initial load
duke
parents:
diff changeset
117 // [ argument word n ]
a61af66fc99e Initial load
duke
parents:
diff changeset
118 // ...
a61af66fc99e Initial load
duke
parents:
diff changeset
119 // -8 [ argument word 1 ]
a61af66fc99e Initial load
duke
parents:
diff changeset
120 // -7 [ saved r15 ] <--- rsp_after_call
a61af66fc99e Initial load
duke
parents:
diff changeset
121 // -6 [ saved r14 ]
a61af66fc99e Initial load
duke
parents:
diff changeset
122 // -5 [ saved r13 ]
a61af66fc99e Initial load
duke
parents:
diff changeset
123 // -4 [ saved r12 ]
a61af66fc99e Initial load
duke
parents:
diff changeset
124 // -3 [ saved rdi ]
a61af66fc99e Initial load
duke
parents:
diff changeset
125 // -2 [ saved rsi ]
a61af66fc99e Initial load
duke
parents:
diff changeset
126 // -1 [ saved rbx ]
a61af66fc99e Initial load
duke
parents:
diff changeset
127 // 0 [ saved rbp ] <--- rbp
a61af66fc99e Initial load
duke
parents:
diff changeset
128 // 1 [ return address ]
a61af66fc99e Initial load
duke
parents:
diff changeset
129 // 2 [ call wrapper ]
a61af66fc99e Initial load
duke
parents:
diff changeset
130 // 3 [ result ]
a61af66fc99e Initial load
duke
parents:
diff changeset
131 // 4 [ result type ]
a61af66fc99e Initial load
duke
parents:
diff changeset
132 // 5 [ method ]
a61af66fc99e Initial load
duke
parents:
diff changeset
133 // 6 [ entry point ]
a61af66fc99e Initial load
duke
parents:
diff changeset
134 // 7 [ parameters ]
a61af66fc99e Initial load
duke
parents:
diff changeset
135 // 8 [ parameter size ]
a61af66fc99e Initial load
duke
parents:
diff changeset
136 // 9 [ thread ]
a61af66fc99e Initial load
duke
parents:
diff changeset
137 //
a61af66fc99e Initial load
duke
parents:
diff changeset
138 // Windows reserves the callers stack space for arguments 1-4.
a61af66fc99e Initial load
duke
parents:
diff changeset
139 // We spill c_rarg0-c_rarg3 to this space.
a61af66fc99e Initial load
duke
parents:
diff changeset
140
a61af66fc99e Initial load
duke
parents:
diff changeset
141 // Call stub stack layout word offsets from rbp
a61af66fc99e Initial load
duke
parents:
diff changeset
142 enum call_stub_layout {
a61af66fc99e Initial load
duke
parents:
diff changeset
143 #ifdef _WIN64
a61af66fc99e Initial load
duke
parents:
diff changeset
144 rsp_after_call_off = -7,
a61af66fc99e Initial load
duke
parents:
diff changeset
145 r15_off = rsp_after_call_off,
a61af66fc99e Initial load
duke
parents:
diff changeset
146 r14_off = -6,
a61af66fc99e Initial load
duke
parents:
diff changeset
147 r13_off = -5,
a61af66fc99e Initial load
duke
parents:
diff changeset
148 r12_off = -4,
a61af66fc99e Initial load
duke
parents:
diff changeset
149 rdi_off = -3,
a61af66fc99e Initial load
duke
parents:
diff changeset
150 rsi_off = -2,
a61af66fc99e Initial load
duke
parents:
diff changeset
151 rbx_off = -1,
a61af66fc99e Initial load
duke
parents:
diff changeset
152 rbp_off = 0,
a61af66fc99e Initial load
duke
parents:
diff changeset
153 retaddr_off = 1,
a61af66fc99e Initial load
duke
parents:
diff changeset
154 call_wrapper_off = 2,
a61af66fc99e Initial load
duke
parents:
diff changeset
155 result_off = 3,
a61af66fc99e Initial load
duke
parents:
diff changeset
156 result_type_off = 4,
a61af66fc99e Initial load
duke
parents:
diff changeset
157 method_off = 5,
a61af66fc99e Initial load
duke
parents:
diff changeset
158 entry_point_off = 6,
a61af66fc99e Initial load
duke
parents:
diff changeset
159 parameters_off = 7,
a61af66fc99e Initial load
duke
parents:
diff changeset
160 parameter_size_off = 8,
a61af66fc99e Initial load
duke
parents:
diff changeset
161 thread_off = 9
a61af66fc99e Initial load
duke
parents:
diff changeset
162 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
163 rsp_after_call_off = -12,
a61af66fc99e Initial load
duke
parents:
diff changeset
164 mxcsr_off = rsp_after_call_off,
a61af66fc99e Initial load
duke
parents:
diff changeset
165 r15_off = -11,
a61af66fc99e Initial load
duke
parents:
diff changeset
166 r14_off = -10,
a61af66fc99e Initial load
duke
parents:
diff changeset
167 r13_off = -9,
a61af66fc99e Initial load
duke
parents:
diff changeset
168 r12_off = -8,
a61af66fc99e Initial load
duke
parents:
diff changeset
169 rbx_off = -7,
a61af66fc99e Initial load
duke
parents:
diff changeset
170 call_wrapper_off = -6,
a61af66fc99e Initial load
duke
parents:
diff changeset
171 result_off = -5,
a61af66fc99e Initial load
duke
parents:
diff changeset
172 result_type_off = -4,
a61af66fc99e Initial load
duke
parents:
diff changeset
173 method_off = -3,
a61af66fc99e Initial load
duke
parents:
diff changeset
174 entry_point_off = -2,
a61af66fc99e Initial load
duke
parents:
diff changeset
175 parameters_off = -1,
a61af66fc99e Initial load
duke
parents:
diff changeset
176 rbp_off = 0,
a61af66fc99e Initial load
duke
parents:
diff changeset
177 retaddr_off = 1,
a61af66fc99e Initial load
duke
parents:
diff changeset
178 parameter_size_off = 2,
a61af66fc99e Initial load
duke
parents:
diff changeset
179 thread_off = 3
a61af66fc99e Initial load
duke
parents:
diff changeset
180 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
181 };
a61af66fc99e Initial load
duke
parents:
diff changeset
182
a61af66fc99e Initial load
duke
parents:
diff changeset
183 address generate_call_stub(address& return_address) {
a61af66fc99e Initial load
duke
parents:
diff changeset
184 assert((int)frame::entry_frame_after_call_words == -(int)rsp_after_call_off + 1 &&
a61af66fc99e Initial load
duke
parents:
diff changeset
185 (int)frame::entry_frame_call_wrapper_offset == (int)call_wrapper_off,
a61af66fc99e Initial load
duke
parents:
diff changeset
186 "adjust this code");
a61af66fc99e Initial load
duke
parents:
diff changeset
187 StubCodeMark mark(this, "StubRoutines", "call_stub");
a61af66fc99e Initial load
duke
parents:
diff changeset
188 address start = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
189
a61af66fc99e Initial load
duke
parents:
diff changeset
190 // same as in generate_catch_exception()!
a61af66fc99e Initial load
duke
parents:
diff changeset
191 const Address rsp_after_call(rbp, rsp_after_call_off * wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
192
a61af66fc99e Initial load
duke
parents:
diff changeset
193 const Address call_wrapper (rbp, call_wrapper_off * wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
194 const Address result (rbp, result_off * wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
195 const Address result_type (rbp, result_type_off * wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
196 const Address method (rbp, method_off * wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
197 const Address entry_point (rbp, entry_point_off * wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
198 const Address parameters (rbp, parameters_off * wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
199 const Address parameter_size(rbp, parameter_size_off * wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
200
a61af66fc99e Initial load
duke
parents:
diff changeset
201 // same as in generate_catch_exception()!
a61af66fc99e Initial load
duke
parents:
diff changeset
202 const Address thread (rbp, thread_off * wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
203
a61af66fc99e Initial load
duke
parents:
diff changeset
204 const Address r15_save(rbp, r15_off * wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
205 const Address r14_save(rbp, r14_off * wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
206 const Address r13_save(rbp, r13_off * wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
207 const Address r12_save(rbp, r12_off * wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
208 const Address rbx_save(rbp, rbx_off * wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
209
a61af66fc99e Initial load
duke
parents:
diff changeset
210 // stub code
a61af66fc99e Initial load
duke
parents:
diff changeset
211 __ enter();
a61af66fc99e Initial load
duke
parents:
diff changeset
212 __ subq(rsp, -rsp_after_call_off * wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
213
a61af66fc99e Initial load
duke
parents:
diff changeset
214 // save register parameters
a61af66fc99e Initial load
duke
parents:
diff changeset
215 #ifndef _WIN64
a61af66fc99e Initial load
duke
parents:
diff changeset
216 __ movq(parameters, c_rarg5); // parameters
a61af66fc99e Initial load
duke
parents:
diff changeset
217 __ movq(entry_point, c_rarg4); // entry_point
a61af66fc99e Initial load
duke
parents:
diff changeset
218 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
219
a61af66fc99e Initial load
duke
parents:
diff changeset
220 __ movq(method, c_rarg3); // method
a61af66fc99e Initial load
duke
parents:
diff changeset
221 __ movl(result_type, c_rarg2); // result type
a61af66fc99e Initial load
duke
parents:
diff changeset
222 __ movq(result, c_rarg1); // result
a61af66fc99e Initial load
duke
parents:
diff changeset
223 __ movq(call_wrapper, c_rarg0); // call wrapper
a61af66fc99e Initial load
duke
parents:
diff changeset
224
a61af66fc99e Initial load
duke
parents:
diff changeset
225 // save regs belonging to calling function
a61af66fc99e Initial load
duke
parents:
diff changeset
226 __ movq(rbx_save, rbx);
a61af66fc99e Initial load
duke
parents:
diff changeset
227 __ movq(r12_save, r12);
a61af66fc99e Initial load
duke
parents:
diff changeset
228 __ movq(r13_save, r13);
a61af66fc99e Initial load
duke
parents:
diff changeset
229 __ movq(r14_save, r14);
a61af66fc99e Initial load
duke
parents:
diff changeset
230 __ movq(r15_save, r15);
a61af66fc99e Initial load
duke
parents:
diff changeset
231
a61af66fc99e Initial load
duke
parents:
diff changeset
232 #ifdef _WIN64
a61af66fc99e Initial load
duke
parents:
diff changeset
233 const Address rdi_save(rbp, rdi_off * wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
234 const Address rsi_save(rbp, rsi_off * wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
235
a61af66fc99e Initial load
duke
parents:
diff changeset
236 __ movq(rsi_save, rsi);
a61af66fc99e Initial load
duke
parents:
diff changeset
237 __ movq(rdi_save, rdi);
a61af66fc99e Initial load
duke
parents:
diff changeset
238 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
239 const Address mxcsr_save(rbp, mxcsr_off * wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
240 {
a61af66fc99e Initial load
duke
parents:
diff changeset
241 Label skip_ldmx;
a61af66fc99e Initial load
duke
parents:
diff changeset
242 __ stmxcsr(mxcsr_save);
a61af66fc99e Initial load
duke
parents:
diff changeset
243 __ movl(rax, mxcsr_save);
a61af66fc99e Initial load
duke
parents:
diff changeset
244 __ andl(rax, MXCSR_MASK); // Only check control and mask bits
a61af66fc99e Initial load
duke
parents:
diff changeset
245 ExternalAddress mxcsr_std(StubRoutines::amd64::mxcsr_std());
a61af66fc99e Initial load
duke
parents:
diff changeset
246 __ cmp32(rax, mxcsr_std);
a61af66fc99e Initial load
duke
parents:
diff changeset
247 __ jcc(Assembler::equal, skip_ldmx);
a61af66fc99e Initial load
duke
parents:
diff changeset
248 __ ldmxcsr(mxcsr_std);
a61af66fc99e Initial load
duke
parents:
diff changeset
249 __ bind(skip_ldmx);
a61af66fc99e Initial load
duke
parents:
diff changeset
250 }
a61af66fc99e Initial load
duke
parents:
diff changeset
251 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
252
a61af66fc99e Initial load
duke
parents:
diff changeset
253 // Load up thread register
a61af66fc99e Initial load
duke
parents:
diff changeset
254 __ movq(r15_thread, thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
255
a61af66fc99e Initial load
duke
parents:
diff changeset
256 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
257 // make sure we have no pending exceptions
a61af66fc99e Initial load
duke
parents:
diff changeset
258 {
a61af66fc99e Initial load
duke
parents:
diff changeset
259 Label L;
a61af66fc99e Initial load
duke
parents:
diff changeset
260 __ cmpq(Address(r15_thread, Thread::pending_exception_offset()), (int)NULL_WORD);
a61af66fc99e Initial load
duke
parents:
diff changeset
261 __ jcc(Assembler::equal, L);
a61af66fc99e Initial load
duke
parents:
diff changeset
262 __ stop("StubRoutines::call_stub: entered with pending exception");
a61af66fc99e Initial load
duke
parents:
diff changeset
263 __ bind(L);
a61af66fc99e Initial load
duke
parents:
diff changeset
264 }
a61af66fc99e Initial load
duke
parents:
diff changeset
265 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
266
a61af66fc99e Initial load
duke
parents:
diff changeset
267 // pass parameters if any
a61af66fc99e Initial load
duke
parents:
diff changeset
268 BLOCK_COMMENT("pass parameters if any");
a61af66fc99e Initial load
duke
parents:
diff changeset
269 Label parameters_done;
a61af66fc99e Initial load
duke
parents:
diff changeset
270 __ movl(c_rarg3, parameter_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
271 __ testl(c_rarg3, c_rarg3);
a61af66fc99e Initial load
duke
parents:
diff changeset
272 __ jcc(Assembler::zero, parameters_done);
a61af66fc99e Initial load
duke
parents:
diff changeset
273
a61af66fc99e Initial load
duke
parents:
diff changeset
274 Label loop;
a61af66fc99e Initial load
duke
parents:
diff changeset
275 __ movq(c_rarg2, parameters); // parameter pointer
a61af66fc99e Initial load
duke
parents:
diff changeset
276 __ movl(c_rarg1, c_rarg3); // parameter counter is in c_rarg1
a61af66fc99e Initial load
duke
parents:
diff changeset
277 __ BIND(loop);
a61af66fc99e Initial load
duke
parents:
diff changeset
278 if (TaggedStackInterpreter) {
a61af66fc99e Initial load
duke
parents:
diff changeset
279 __ movq(rax, Address(c_rarg2, 0)); // get tag
a61af66fc99e Initial load
duke
parents:
diff changeset
280 __ addq(c_rarg2, wordSize); // advance to next tag
a61af66fc99e Initial load
duke
parents:
diff changeset
281 __ pushq(rax); // pass tag
a61af66fc99e Initial load
duke
parents:
diff changeset
282 }
a61af66fc99e Initial load
duke
parents:
diff changeset
283 __ movq(rax, Address(c_rarg2, 0)); // get parameter
a61af66fc99e Initial load
duke
parents:
diff changeset
284 __ addq(c_rarg2, wordSize); // advance to next parameter
a61af66fc99e Initial load
duke
parents:
diff changeset
285 __ decrementl(c_rarg1); // decrement counter
a61af66fc99e Initial load
duke
parents:
diff changeset
286 __ pushq(rax); // pass parameter
a61af66fc99e Initial load
duke
parents:
diff changeset
287 __ jcc(Assembler::notZero, loop);
a61af66fc99e Initial load
duke
parents:
diff changeset
288
a61af66fc99e Initial load
duke
parents:
diff changeset
289 // call Java function
a61af66fc99e Initial load
duke
parents:
diff changeset
290 __ BIND(parameters_done);
a61af66fc99e Initial load
duke
parents:
diff changeset
291 __ movq(rbx, method); // get methodOop
a61af66fc99e Initial load
duke
parents:
diff changeset
292 __ movq(c_rarg1, entry_point); // get entry_point
a61af66fc99e Initial load
duke
parents:
diff changeset
293 __ movq(r13, rsp); // set sender sp
a61af66fc99e Initial load
duke
parents:
diff changeset
294 BLOCK_COMMENT("call Java function");
a61af66fc99e Initial load
duke
parents:
diff changeset
295 __ call(c_rarg1);
a61af66fc99e Initial load
duke
parents:
diff changeset
296
a61af66fc99e Initial load
duke
parents:
diff changeset
297 BLOCK_COMMENT("call_stub_return_address:");
a61af66fc99e Initial load
duke
parents:
diff changeset
298 return_address = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
299
a61af66fc99e Initial load
duke
parents:
diff changeset
300 // store result depending on type (everything that is not
a61af66fc99e Initial load
duke
parents:
diff changeset
301 // T_OBJECT, T_LONG, T_FLOAT or T_DOUBLE is treated as T_INT)
a61af66fc99e Initial load
duke
parents:
diff changeset
302 __ movq(c_rarg0, result);
a61af66fc99e Initial load
duke
parents:
diff changeset
303 Label is_long, is_float, is_double, exit;
a61af66fc99e Initial load
duke
parents:
diff changeset
304 __ movl(c_rarg1, result_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
305 __ cmpl(c_rarg1, T_OBJECT);
a61af66fc99e Initial load
duke
parents:
diff changeset
306 __ jcc(Assembler::equal, is_long);
a61af66fc99e Initial load
duke
parents:
diff changeset
307 __ cmpl(c_rarg1, T_LONG);
a61af66fc99e Initial load
duke
parents:
diff changeset
308 __ jcc(Assembler::equal, is_long);
a61af66fc99e Initial load
duke
parents:
diff changeset
309 __ cmpl(c_rarg1, T_FLOAT);
a61af66fc99e Initial load
duke
parents:
diff changeset
310 __ jcc(Assembler::equal, is_float);
a61af66fc99e Initial load
duke
parents:
diff changeset
311 __ cmpl(c_rarg1, T_DOUBLE);
a61af66fc99e Initial load
duke
parents:
diff changeset
312 __ jcc(Assembler::equal, is_double);
a61af66fc99e Initial load
duke
parents:
diff changeset
313
a61af66fc99e Initial load
duke
parents:
diff changeset
314 // handle T_INT case
a61af66fc99e Initial load
duke
parents:
diff changeset
315 __ movl(Address(c_rarg0, 0), rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
316
a61af66fc99e Initial load
duke
parents:
diff changeset
317 __ BIND(exit);
a61af66fc99e Initial load
duke
parents:
diff changeset
318
a61af66fc99e Initial load
duke
parents:
diff changeset
319 // pop parameters
a61af66fc99e Initial load
duke
parents:
diff changeset
320 __ leaq(rsp, rsp_after_call);
a61af66fc99e Initial load
duke
parents:
diff changeset
321
a61af66fc99e Initial load
duke
parents:
diff changeset
322 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
323 // verify that threads correspond
a61af66fc99e Initial load
duke
parents:
diff changeset
324 {
a61af66fc99e Initial load
duke
parents:
diff changeset
325 Label L, S;
a61af66fc99e Initial load
duke
parents:
diff changeset
326 __ cmpq(r15_thread, thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
327 __ jcc(Assembler::notEqual, S);
a61af66fc99e Initial load
duke
parents:
diff changeset
328 __ get_thread(rbx);
a61af66fc99e Initial load
duke
parents:
diff changeset
329 __ cmpq(r15_thread, rbx);
a61af66fc99e Initial load
duke
parents:
diff changeset
330 __ jcc(Assembler::equal, L);
a61af66fc99e Initial load
duke
parents:
diff changeset
331 __ bind(S);
a61af66fc99e Initial load
duke
parents:
diff changeset
332 __ jcc(Assembler::equal, L);
a61af66fc99e Initial load
duke
parents:
diff changeset
333 __ stop("StubRoutines::call_stub: threads must correspond");
a61af66fc99e Initial load
duke
parents:
diff changeset
334 __ bind(L);
a61af66fc99e Initial load
duke
parents:
diff changeset
335 }
a61af66fc99e Initial load
duke
parents:
diff changeset
336 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
337
a61af66fc99e Initial load
duke
parents:
diff changeset
338 // restore regs belonging to calling function
a61af66fc99e Initial load
duke
parents:
diff changeset
339 __ movq(r15, r15_save);
a61af66fc99e Initial load
duke
parents:
diff changeset
340 __ movq(r14, r14_save);
a61af66fc99e Initial load
duke
parents:
diff changeset
341 __ movq(r13, r13_save);
a61af66fc99e Initial load
duke
parents:
diff changeset
342 __ movq(r12, r12_save);
a61af66fc99e Initial load
duke
parents:
diff changeset
343 __ movq(rbx, rbx_save);
a61af66fc99e Initial load
duke
parents:
diff changeset
344
a61af66fc99e Initial load
duke
parents:
diff changeset
345 #ifdef _WIN64
a61af66fc99e Initial load
duke
parents:
diff changeset
346 __ movq(rdi, rdi_save);
a61af66fc99e Initial load
duke
parents:
diff changeset
347 __ movq(rsi, rsi_save);
a61af66fc99e Initial load
duke
parents:
diff changeset
348 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
349 __ ldmxcsr(mxcsr_save);
a61af66fc99e Initial load
duke
parents:
diff changeset
350 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
351
a61af66fc99e Initial load
duke
parents:
diff changeset
352 // restore rsp
a61af66fc99e Initial load
duke
parents:
diff changeset
353 __ addq(rsp, -rsp_after_call_off * wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
354
a61af66fc99e Initial load
duke
parents:
diff changeset
355 // return
a61af66fc99e Initial load
duke
parents:
diff changeset
356 __ popq(rbp);
a61af66fc99e Initial load
duke
parents:
diff changeset
357 __ ret(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
358
a61af66fc99e Initial load
duke
parents:
diff changeset
359 // handle return types different from T_INT
a61af66fc99e Initial load
duke
parents:
diff changeset
360 __ BIND(is_long);
a61af66fc99e Initial load
duke
parents:
diff changeset
361 __ movq(Address(c_rarg0, 0), rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
362 __ jmp(exit);
a61af66fc99e Initial load
duke
parents:
diff changeset
363
a61af66fc99e Initial load
duke
parents:
diff changeset
364 __ BIND(is_float);
a61af66fc99e Initial load
duke
parents:
diff changeset
365 __ movflt(Address(c_rarg0, 0), xmm0);
a61af66fc99e Initial load
duke
parents:
diff changeset
366 __ jmp(exit);
a61af66fc99e Initial load
duke
parents:
diff changeset
367
a61af66fc99e Initial load
duke
parents:
diff changeset
368 __ BIND(is_double);
a61af66fc99e Initial load
duke
parents:
diff changeset
369 __ movdbl(Address(c_rarg0, 0), xmm0);
a61af66fc99e Initial load
duke
parents:
diff changeset
370 __ jmp(exit);
a61af66fc99e Initial load
duke
parents:
diff changeset
371
a61af66fc99e Initial load
duke
parents:
diff changeset
372 return start;
a61af66fc99e Initial load
duke
parents:
diff changeset
373 }
a61af66fc99e Initial load
duke
parents:
diff changeset
374
a61af66fc99e Initial load
duke
parents:
diff changeset
375 // Return point for a Java call if there's an exception thrown in
a61af66fc99e Initial load
duke
parents:
diff changeset
376 // Java code. The exception is caught and transformed into a
a61af66fc99e Initial load
duke
parents:
diff changeset
377 // pending exception stored in JavaThread that can be tested from
a61af66fc99e Initial load
duke
parents:
diff changeset
378 // within the VM.
a61af66fc99e Initial load
duke
parents:
diff changeset
379 //
a61af66fc99e Initial load
duke
parents:
diff changeset
380 // Note: Usually the parameters are removed by the callee. In case
a61af66fc99e Initial load
duke
parents:
diff changeset
381 // of an exception crossing an activation frame boundary, that is
a61af66fc99e Initial load
duke
parents:
diff changeset
382 // not the case if the callee is compiled code => need to setup the
a61af66fc99e Initial load
duke
parents:
diff changeset
383 // rsp.
a61af66fc99e Initial load
duke
parents:
diff changeset
384 //
a61af66fc99e Initial load
duke
parents:
diff changeset
385 // rax: exception oop
a61af66fc99e Initial load
duke
parents:
diff changeset
386
a61af66fc99e Initial load
duke
parents:
diff changeset
387 address generate_catch_exception() {
a61af66fc99e Initial load
duke
parents:
diff changeset
388 StubCodeMark mark(this, "StubRoutines", "catch_exception");
a61af66fc99e Initial load
duke
parents:
diff changeset
389 address start = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
390
a61af66fc99e Initial load
duke
parents:
diff changeset
391 // same as in generate_call_stub():
a61af66fc99e Initial load
duke
parents:
diff changeset
392 const Address rsp_after_call(rbp, rsp_after_call_off * wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
393 const Address thread (rbp, thread_off * wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
394
a61af66fc99e Initial load
duke
parents:
diff changeset
395 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
396 // verify that threads correspond
a61af66fc99e Initial load
duke
parents:
diff changeset
397 {
a61af66fc99e Initial load
duke
parents:
diff changeset
398 Label L, S;
a61af66fc99e Initial load
duke
parents:
diff changeset
399 __ cmpq(r15_thread, thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
400 __ jcc(Assembler::notEqual, S);
a61af66fc99e Initial load
duke
parents:
diff changeset
401 __ get_thread(rbx);
a61af66fc99e Initial load
duke
parents:
diff changeset
402 __ cmpq(r15_thread, rbx);
a61af66fc99e Initial load
duke
parents:
diff changeset
403 __ jcc(Assembler::equal, L);
a61af66fc99e Initial load
duke
parents:
diff changeset
404 __ bind(S);
a61af66fc99e Initial load
duke
parents:
diff changeset
405 __ stop("StubRoutines::catch_exception: threads must correspond");
a61af66fc99e Initial load
duke
parents:
diff changeset
406 __ bind(L);
a61af66fc99e Initial load
duke
parents:
diff changeset
407 }
a61af66fc99e Initial load
duke
parents:
diff changeset
408 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
409
a61af66fc99e Initial load
duke
parents:
diff changeset
410 // set pending exception
a61af66fc99e Initial load
duke
parents:
diff changeset
411 __ verify_oop(rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
412
a61af66fc99e Initial load
duke
parents:
diff changeset
413 __ movq(Address(r15_thread, Thread::pending_exception_offset()), rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
414 __ lea(rscratch1, ExternalAddress((address)__FILE__));
a61af66fc99e Initial load
duke
parents:
diff changeset
415 __ movq(Address(r15_thread, Thread::exception_file_offset()), rscratch1);
a61af66fc99e Initial load
duke
parents:
diff changeset
416 __ movl(Address(r15_thread, Thread::exception_line_offset()), (int) __LINE__);
a61af66fc99e Initial load
duke
parents:
diff changeset
417
a61af66fc99e Initial load
duke
parents:
diff changeset
418 // complete return to VM
a61af66fc99e Initial load
duke
parents:
diff changeset
419 assert(StubRoutines::_call_stub_return_address != NULL,
a61af66fc99e Initial load
duke
parents:
diff changeset
420 "_call_stub_return_address must have been generated before");
a61af66fc99e Initial load
duke
parents:
diff changeset
421 __ jump(RuntimeAddress(StubRoutines::_call_stub_return_address));
a61af66fc99e Initial load
duke
parents:
diff changeset
422
a61af66fc99e Initial load
duke
parents:
diff changeset
423 return start;
a61af66fc99e Initial load
duke
parents:
diff changeset
424 }
a61af66fc99e Initial load
duke
parents:
diff changeset
425
a61af66fc99e Initial load
duke
parents:
diff changeset
426 // Continuation point for runtime calls returning with a pending
a61af66fc99e Initial load
duke
parents:
diff changeset
427 // exception. The pending exception check happened in the runtime
a61af66fc99e Initial load
duke
parents:
diff changeset
428 // or native call stub. The pending exception in Thread is
a61af66fc99e Initial load
duke
parents:
diff changeset
429 // converted into a Java-level exception.
a61af66fc99e Initial load
duke
parents:
diff changeset
430 //
a61af66fc99e Initial load
duke
parents:
diff changeset
431 // Contract with Java-level exception handlers:
a61af66fc99e Initial load
duke
parents:
diff changeset
432 // rax: exception
a61af66fc99e Initial load
duke
parents:
diff changeset
433 // rdx: throwing pc
a61af66fc99e Initial load
duke
parents:
diff changeset
434 //
a61af66fc99e Initial load
duke
parents:
diff changeset
435 // NOTE: At entry of this stub, exception-pc must be on stack !!
a61af66fc99e Initial load
duke
parents:
diff changeset
436
a61af66fc99e Initial load
duke
parents:
diff changeset
437 address generate_forward_exception() {
a61af66fc99e Initial load
duke
parents:
diff changeset
438 StubCodeMark mark(this, "StubRoutines", "forward exception");
a61af66fc99e Initial load
duke
parents:
diff changeset
439 address start = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
440
a61af66fc99e Initial load
duke
parents:
diff changeset
441 // Upon entry, the sp points to the return address returning into
a61af66fc99e Initial load
duke
parents:
diff changeset
442 // Java (interpreted or compiled) code; i.e., the return address
a61af66fc99e Initial load
duke
parents:
diff changeset
443 // becomes the throwing pc.
a61af66fc99e Initial load
duke
parents:
diff changeset
444 //
a61af66fc99e Initial load
duke
parents:
diff changeset
445 // Arguments pushed before the runtime call are still on the stack
a61af66fc99e Initial load
duke
parents:
diff changeset
446 // but the exception handler will reset the stack pointer ->
a61af66fc99e Initial load
duke
parents:
diff changeset
447 // ignore them. A potential result in registers can be ignored as
a61af66fc99e Initial load
duke
parents:
diff changeset
448 // well.
a61af66fc99e Initial load
duke
parents:
diff changeset
449
a61af66fc99e Initial load
duke
parents:
diff changeset
450 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
451 // make sure this code is only executed if there is a pending exception
a61af66fc99e Initial load
duke
parents:
diff changeset
452 {
a61af66fc99e Initial load
duke
parents:
diff changeset
453 Label L;
a61af66fc99e Initial load
duke
parents:
diff changeset
454 __ cmpq(Address(r15_thread, Thread::pending_exception_offset()), (int) NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
455 __ jcc(Assembler::notEqual, L);
a61af66fc99e Initial load
duke
parents:
diff changeset
456 __ stop("StubRoutines::forward exception: no pending exception (1)");
a61af66fc99e Initial load
duke
parents:
diff changeset
457 __ bind(L);
a61af66fc99e Initial load
duke
parents:
diff changeset
458 }
a61af66fc99e Initial load
duke
parents:
diff changeset
459 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
460
a61af66fc99e Initial load
duke
parents:
diff changeset
461 // compute exception handler into rbx
a61af66fc99e Initial load
duke
parents:
diff changeset
462 __ movq(c_rarg0, Address(rsp, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
463 BLOCK_COMMENT("call exception_handler_for_return_address");
a61af66fc99e Initial load
duke
parents:
diff changeset
464 __ call_VM_leaf(CAST_FROM_FN_PTR(address,
a61af66fc99e Initial load
duke
parents:
diff changeset
465 SharedRuntime::exception_handler_for_return_address),
a61af66fc99e Initial load
duke
parents:
diff changeset
466 c_rarg0);
a61af66fc99e Initial load
duke
parents:
diff changeset
467 __ movq(rbx, rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
468
a61af66fc99e Initial load
duke
parents:
diff changeset
469 // setup rax & rdx, remove return address & clear pending exception
a61af66fc99e Initial load
duke
parents:
diff changeset
470 __ popq(rdx);
a61af66fc99e Initial load
duke
parents:
diff changeset
471 __ movq(rax, Address(r15_thread, Thread::pending_exception_offset()));
a61af66fc99e Initial load
duke
parents:
diff changeset
472 __ movptr(Address(r15_thread, Thread::pending_exception_offset()), (int)NULL_WORD);
a61af66fc99e Initial load
duke
parents:
diff changeset
473
a61af66fc99e Initial load
duke
parents:
diff changeset
474 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
475 // make sure exception is set
a61af66fc99e Initial load
duke
parents:
diff changeset
476 {
a61af66fc99e Initial load
duke
parents:
diff changeset
477 Label L;
a61af66fc99e Initial load
duke
parents:
diff changeset
478 __ testq(rax, rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
479 __ jcc(Assembler::notEqual, L);
a61af66fc99e Initial load
duke
parents:
diff changeset
480 __ stop("StubRoutines::forward exception: no pending exception (2)");
a61af66fc99e Initial load
duke
parents:
diff changeset
481 __ bind(L);
a61af66fc99e Initial load
duke
parents:
diff changeset
482 }
a61af66fc99e Initial load
duke
parents:
diff changeset
483 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
484
a61af66fc99e Initial load
duke
parents:
diff changeset
485 // continue at exception handler (return address removed)
a61af66fc99e Initial load
duke
parents:
diff changeset
486 // rax: exception
a61af66fc99e Initial load
duke
parents:
diff changeset
487 // rbx: exception handler
a61af66fc99e Initial load
duke
parents:
diff changeset
488 // rdx: throwing pc
a61af66fc99e Initial load
duke
parents:
diff changeset
489 __ verify_oop(rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
490 __ jmp(rbx);
a61af66fc99e Initial load
duke
parents:
diff changeset
491
a61af66fc99e Initial load
duke
parents:
diff changeset
492 return start;
a61af66fc99e Initial load
duke
parents:
diff changeset
493 }
a61af66fc99e Initial load
duke
parents:
diff changeset
494
a61af66fc99e Initial load
duke
parents:
diff changeset
495 // Support for jint atomic::xchg(jint exchange_value, volatile jint* dest)
a61af66fc99e Initial load
duke
parents:
diff changeset
496 //
a61af66fc99e Initial load
duke
parents:
diff changeset
497 // Arguments :
a61af66fc99e Initial load
duke
parents:
diff changeset
498 // c_rarg0: exchange_value
a61af66fc99e Initial load
duke
parents:
diff changeset
499 // c_rarg0: dest
a61af66fc99e Initial load
duke
parents:
diff changeset
500 //
a61af66fc99e Initial load
duke
parents:
diff changeset
501 // Result:
a61af66fc99e Initial load
duke
parents:
diff changeset
502 // *dest <- ex, return (orig *dest)
a61af66fc99e Initial load
duke
parents:
diff changeset
503 address generate_atomic_xchg() {
a61af66fc99e Initial load
duke
parents:
diff changeset
504 StubCodeMark mark(this, "StubRoutines", "atomic_xchg");
a61af66fc99e Initial load
duke
parents:
diff changeset
505 address start = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
506
a61af66fc99e Initial load
duke
parents:
diff changeset
507 __ movl(rax, c_rarg0); // Copy to eax we need a return value anyhow
a61af66fc99e Initial load
duke
parents:
diff changeset
508 __ xchgl(rax, Address(c_rarg1, 0)); // automatic LOCK
a61af66fc99e Initial load
duke
parents:
diff changeset
509 __ ret(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
510
a61af66fc99e Initial load
duke
parents:
diff changeset
511 return start;
a61af66fc99e Initial load
duke
parents:
diff changeset
512 }
a61af66fc99e Initial load
duke
parents:
diff changeset
513
a61af66fc99e Initial load
duke
parents:
diff changeset
514 // Support for intptr_t atomic::xchg_ptr(intptr_t exchange_value, volatile intptr_t* dest)
a61af66fc99e Initial load
duke
parents:
diff changeset
515 //
a61af66fc99e Initial load
duke
parents:
diff changeset
516 // Arguments :
a61af66fc99e Initial load
duke
parents:
diff changeset
517 // c_rarg0: exchange_value
a61af66fc99e Initial load
duke
parents:
diff changeset
518 // c_rarg1: dest
a61af66fc99e Initial load
duke
parents:
diff changeset
519 //
a61af66fc99e Initial load
duke
parents:
diff changeset
520 // Result:
a61af66fc99e Initial load
duke
parents:
diff changeset
521 // *dest <- ex, return (orig *dest)
a61af66fc99e Initial load
duke
parents:
diff changeset
522 address generate_atomic_xchg_ptr() {
a61af66fc99e Initial load
duke
parents:
diff changeset
523 StubCodeMark mark(this, "StubRoutines", "atomic_xchg_ptr");
a61af66fc99e Initial load
duke
parents:
diff changeset
524 address start = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
525
a61af66fc99e Initial load
duke
parents:
diff changeset
526 __ movq(rax, c_rarg0); // Copy to eax we need a return value anyhow
a61af66fc99e Initial load
duke
parents:
diff changeset
527 __ xchgq(rax, Address(c_rarg1, 0)); // automatic LOCK
a61af66fc99e Initial load
duke
parents:
diff changeset
528 __ ret(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
529
a61af66fc99e Initial load
duke
parents:
diff changeset
530 return start;
a61af66fc99e Initial load
duke
parents:
diff changeset
531 }
a61af66fc99e Initial load
duke
parents:
diff changeset
532
a61af66fc99e Initial load
duke
parents:
diff changeset
533 // Support for jint atomic::atomic_cmpxchg(jint exchange_value, volatile jint* dest,
a61af66fc99e Initial load
duke
parents:
diff changeset
534 // jint compare_value)
a61af66fc99e Initial load
duke
parents:
diff changeset
535 //
a61af66fc99e Initial load
duke
parents:
diff changeset
536 // Arguments :
a61af66fc99e Initial load
duke
parents:
diff changeset
537 // c_rarg0: exchange_value
a61af66fc99e Initial load
duke
parents:
diff changeset
538 // c_rarg1: dest
a61af66fc99e Initial load
duke
parents:
diff changeset
539 // c_rarg2: compare_value
a61af66fc99e Initial load
duke
parents:
diff changeset
540 //
a61af66fc99e Initial load
duke
parents:
diff changeset
541 // Result:
a61af66fc99e Initial load
duke
parents:
diff changeset
542 // if ( compare_value == *dest ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
543 // *dest = exchange_value
a61af66fc99e Initial load
duke
parents:
diff changeset
544 // return compare_value;
a61af66fc99e Initial load
duke
parents:
diff changeset
545 // else
a61af66fc99e Initial load
duke
parents:
diff changeset
546 // return *dest;
a61af66fc99e Initial load
duke
parents:
diff changeset
547 address generate_atomic_cmpxchg() {
a61af66fc99e Initial load
duke
parents:
diff changeset
548 StubCodeMark mark(this, "StubRoutines", "atomic_cmpxchg");
a61af66fc99e Initial load
duke
parents:
diff changeset
549 address start = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
550
a61af66fc99e Initial load
duke
parents:
diff changeset
551 __ movl(rax, c_rarg2);
a61af66fc99e Initial load
duke
parents:
diff changeset
552 if ( os::is_MP() ) __ lock();
a61af66fc99e Initial load
duke
parents:
diff changeset
553 __ cmpxchgl(c_rarg0, Address(c_rarg1, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
554 __ ret(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
555
a61af66fc99e Initial load
duke
parents:
diff changeset
556 return start;
a61af66fc99e Initial load
duke
parents:
diff changeset
557 }
a61af66fc99e Initial load
duke
parents:
diff changeset
558
a61af66fc99e Initial load
duke
parents:
diff changeset
559 // Support for jint atomic::atomic_cmpxchg_long(jlong exchange_value,
a61af66fc99e Initial load
duke
parents:
diff changeset
560 // volatile jlong* dest,
a61af66fc99e Initial load
duke
parents:
diff changeset
561 // jlong compare_value)
a61af66fc99e Initial load
duke
parents:
diff changeset
562 // Arguments :
a61af66fc99e Initial load
duke
parents:
diff changeset
563 // c_rarg0: exchange_value
a61af66fc99e Initial load
duke
parents:
diff changeset
564 // c_rarg1: dest
a61af66fc99e Initial load
duke
parents:
diff changeset
565 // c_rarg2: compare_value
a61af66fc99e Initial load
duke
parents:
diff changeset
566 //
a61af66fc99e Initial load
duke
parents:
diff changeset
567 // Result:
a61af66fc99e Initial load
duke
parents:
diff changeset
568 // if ( compare_value == *dest ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
569 // *dest = exchange_value
a61af66fc99e Initial load
duke
parents:
diff changeset
570 // return compare_value;
a61af66fc99e Initial load
duke
parents:
diff changeset
571 // else
a61af66fc99e Initial load
duke
parents:
diff changeset
572 // return *dest;
a61af66fc99e Initial load
duke
parents:
diff changeset
573 address generate_atomic_cmpxchg_long() {
a61af66fc99e Initial load
duke
parents:
diff changeset
574 StubCodeMark mark(this, "StubRoutines", "atomic_cmpxchg_long");
a61af66fc99e Initial load
duke
parents:
diff changeset
575 address start = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
576
a61af66fc99e Initial load
duke
parents:
diff changeset
577 __ movq(rax, c_rarg2);
a61af66fc99e Initial load
duke
parents:
diff changeset
578 if ( os::is_MP() ) __ lock();
a61af66fc99e Initial load
duke
parents:
diff changeset
579 __ cmpxchgq(c_rarg0, Address(c_rarg1, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
580 __ ret(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
581
a61af66fc99e Initial load
duke
parents:
diff changeset
582 return start;
a61af66fc99e Initial load
duke
parents:
diff changeset
583 }
a61af66fc99e Initial load
duke
parents:
diff changeset
584
a61af66fc99e Initial load
duke
parents:
diff changeset
585 // Support for jint atomic::add(jint add_value, volatile jint* dest)
a61af66fc99e Initial load
duke
parents:
diff changeset
586 //
a61af66fc99e Initial load
duke
parents:
diff changeset
587 // Arguments :
a61af66fc99e Initial load
duke
parents:
diff changeset
588 // c_rarg0: add_value
a61af66fc99e Initial load
duke
parents:
diff changeset
589 // c_rarg1: dest
a61af66fc99e Initial load
duke
parents:
diff changeset
590 //
a61af66fc99e Initial load
duke
parents:
diff changeset
591 // Result:
a61af66fc99e Initial load
duke
parents:
diff changeset
592 // *dest += add_value
a61af66fc99e Initial load
duke
parents:
diff changeset
593 // return *dest;
a61af66fc99e Initial load
duke
parents:
diff changeset
594 address generate_atomic_add() {
a61af66fc99e Initial load
duke
parents:
diff changeset
595 StubCodeMark mark(this, "StubRoutines", "atomic_add");
a61af66fc99e Initial load
duke
parents:
diff changeset
596 address start = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
597
a61af66fc99e Initial load
duke
parents:
diff changeset
598 __ movl(rax, c_rarg0);
a61af66fc99e Initial load
duke
parents:
diff changeset
599 if ( os::is_MP() ) __ lock();
a61af66fc99e Initial load
duke
parents:
diff changeset
600 __ xaddl(Address(c_rarg1, 0), c_rarg0);
a61af66fc99e Initial load
duke
parents:
diff changeset
601 __ addl(rax, c_rarg0);
a61af66fc99e Initial load
duke
parents:
diff changeset
602 __ ret(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
603
a61af66fc99e Initial load
duke
parents:
diff changeset
604 return start;
a61af66fc99e Initial load
duke
parents:
diff changeset
605 }
a61af66fc99e Initial load
duke
parents:
diff changeset
606
a61af66fc99e Initial load
duke
parents:
diff changeset
607 // Support for intptr_t atomic::add_ptr(intptr_t add_value, volatile intptr_t* dest)
a61af66fc99e Initial load
duke
parents:
diff changeset
608 //
a61af66fc99e Initial load
duke
parents:
diff changeset
609 // Arguments :
a61af66fc99e Initial load
duke
parents:
diff changeset
610 // c_rarg0: add_value
a61af66fc99e Initial load
duke
parents:
diff changeset
611 // c_rarg1: dest
a61af66fc99e Initial load
duke
parents:
diff changeset
612 //
a61af66fc99e Initial load
duke
parents:
diff changeset
613 // Result:
a61af66fc99e Initial load
duke
parents:
diff changeset
614 // *dest += add_value
a61af66fc99e Initial load
duke
parents:
diff changeset
615 // return *dest;
a61af66fc99e Initial load
duke
parents:
diff changeset
616 address generate_atomic_add_ptr() {
a61af66fc99e Initial load
duke
parents:
diff changeset
617 StubCodeMark mark(this, "StubRoutines", "atomic_add_ptr");
a61af66fc99e Initial load
duke
parents:
diff changeset
618 address start = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
619
a61af66fc99e Initial load
duke
parents:
diff changeset
620 __ movq(rax, c_rarg0); // Copy to eax we need a return value anyhow
a61af66fc99e Initial load
duke
parents:
diff changeset
621 if ( os::is_MP() ) __ lock();
a61af66fc99e Initial load
duke
parents:
diff changeset
622 __ xaddl(Address(c_rarg1, 0), c_rarg0);
a61af66fc99e Initial load
duke
parents:
diff changeset
623 __ addl(rax, c_rarg0);
a61af66fc99e Initial load
duke
parents:
diff changeset
624 __ ret(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
625
a61af66fc99e Initial load
duke
parents:
diff changeset
626 return start;
a61af66fc99e Initial load
duke
parents:
diff changeset
627 }
a61af66fc99e Initial load
duke
parents:
diff changeset
628
a61af66fc99e Initial load
duke
parents:
diff changeset
629 // Support for intptr_t OrderAccess::fence()
a61af66fc99e Initial load
duke
parents:
diff changeset
630 //
a61af66fc99e Initial load
duke
parents:
diff changeset
631 // Arguments :
a61af66fc99e Initial load
duke
parents:
diff changeset
632 //
a61af66fc99e Initial load
duke
parents:
diff changeset
633 // Result:
a61af66fc99e Initial load
duke
parents:
diff changeset
634 address generate_orderaccess_fence() {
a61af66fc99e Initial load
duke
parents:
diff changeset
635 StubCodeMark mark(this, "StubRoutines", "orderaccess_fence");
a61af66fc99e Initial load
duke
parents:
diff changeset
636 address start = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
637 __ mfence();
a61af66fc99e Initial load
duke
parents:
diff changeset
638 __ ret(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
639
a61af66fc99e Initial load
duke
parents:
diff changeset
640 return start;
a61af66fc99e Initial load
duke
parents:
diff changeset
641 }
a61af66fc99e Initial load
duke
parents:
diff changeset
642
a61af66fc99e Initial load
duke
parents:
diff changeset
643 // Support for intptr_t get_previous_fp()
a61af66fc99e Initial load
duke
parents:
diff changeset
644 //
a61af66fc99e Initial load
duke
parents:
diff changeset
645 // This routine is used to find the previous frame pointer for the
a61af66fc99e Initial load
duke
parents:
diff changeset
646 // caller (current_frame_guess). This is used as part of debugging
a61af66fc99e Initial load
duke
parents:
diff changeset
647 // ps() is seemingly lost trying to find frames.
a61af66fc99e Initial load
duke
parents:
diff changeset
648 // This code assumes that caller current_frame_guess) has a frame.
a61af66fc99e Initial load
duke
parents:
diff changeset
649 address generate_get_previous_fp() {
a61af66fc99e Initial load
duke
parents:
diff changeset
650 StubCodeMark mark(this, "StubRoutines", "get_previous_fp");
a61af66fc99e Initial load
duke
parents:
diff changeset
651 const Address old_fp(rbp, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
652 const Address older_fp(rax, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
653 address start = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
654
a61af66fc99e Initial load
duke
parents:
diff changeset
655 __ enter();
a61af66fc99e Initial load
duke
parents:
diff changeset
656 __ movq(rax, old_fp); // callers fp
a61af66fc99e Initial load
duke
parents:
diff changeset
657 __ movq(rax, older_fp); // the frame for ps()
a61af66fc99e Initial load
duke
parents:
diff changeset
658 __ popq(rbp);
a61af66fc99e Initial load
duke
parents:
diff changeset
659 __ ret(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
660
a61af66fc99e Initial load
duke
parents:
diff changeset
661 return start;
a61af66fc99e Initial load
duke
parents:
diff changeset
662 }
a61af66fc99e Initial load
duke
parents:
diff changeset
663
a61af66fc99e Initial load
duke
parents:
diff changeset
664 //----------------------------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
665 // Support for void verify_mxcsr()
a61af66fc99e Initial load
duke
parents:
diff changeset
666 //
a61af66fc99e Initial load
duke
parents:
diff changeset
667 // This routine is used with -Xcheck:jni to verify that native
a61af66fc99e Initial load
duke
parents:
diff changeset
668 // JNI code does not return to Java code without restoring the
a61af66fc99e Initial load
duke
parents:
diff changeset
669 // MXCSR register to our expected state.
a61af66fc99e Initial load
duke
parents:
diff changeset
670
a61af66fc99e Initial load
duke
parents:
diff changeset
671 address generate_verify_mxcsr() {
a61af66fc99e Initial load
duke
parents:
diff changeset
672 StubCodeMark mark(this, "StubRoutines", "verify_mxcsr");
a61af66fc99e Initial load
duke
parents:
diff changeset
673 address start = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
674
a61af66fc99e Initial load
duke
parents:
diff changeset
675 const Address mxcsr_save(rsp, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
676
a61af66fc99e Initial load
duke
parents:
diff changeset
677 if (CheckJNICalls) {
a61af66fc99e Initial load
duke
parents:
diff changeset
678 Label ok_ret;
a61af66fc99e Initial load
duke
parents:
diff changeset
679 __ pushq(rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
680 __ subq(rsp, wordSize); // allocate a temp location
a61af66fc99e Initial load
duke
parents:
diff changeset
681 __ stmxcsr(mxcsr_save);
a61af66fc99e Initial load
duke
parents:
diff changeset
682 __ movl(rax, mxcsr_save);
a61af66fc99e Initial load
duke
parents:
diff changeset
683 __ andl(rax, MXCSR_MASK); // Only check control and mask bits
a61af66fc99e Initial load
duke
parents:
diff changeset
684 __ cmpl(rax, *(int *)(StubRoutines::amd64::mxcsr_std()));
a61af66fc99e Initial load
duke
parents:
diff changeset
685 __ jcc(Assembler::equal, ok_ret);
a61af66fc99e Initial load
duke
parents:
diff changeset
686
a61af66fc99e Initial load
duke
parents:
diff changeset
687 __ warn("MXCSR changed by native JNI code, use -XX:+RestoreMXCSROnJNICall");
a61af66fc99e Initial load
duke
parents:
diff changeset
688
a61af66fc99e Initial load
duke
parents:
diff changeset
689 __ ldmxcsr(ExternalAddress(StubRoutines::amd64::mxcsr_std()));
a61af66fc99e Initial load
duke
parents:
diff changeset
690
a61af66fc99e Initial load
duke
parents:
diff changeset
691 __ bind(ok_ret);
a61af66fc99e Initial load
duke
parents:
diff changeset
692 __ addq(rsp, wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
693 __ popq(rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
694 }
a61af66fc99e Initial load
duke
parents:
diff changeset
695
a61af66fc99e Initial load
duke
parents:
diff changeset
696 __ ret(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
697
a61af66fc99e Initial load
duke
parents:
diff changeset
698 return start;
a61af66fc99e Initial load
duke
parents:
diff changeset
699 }
a61af66fc99e Initial load
duke
parents:
diff changeset
700
a61af66fc99e Initial load
duke
parents:
diff changeset
701 address generate_f2i_fixup() {
a61af66fc99e Initial load
duke
parents:
diff changeset
702 StubCodeMark mark(this, "StubRoutines", "f2i_fixup");
a61af66fc99e Initial load
duke
parents:
diff changeset
703 Address inout(rsp, 5 * wordSize); // return address + 4 saves
a61af66fc99e Initial load
duke
parents:
diff changeset
704
a61af66fc99e Initial load
duke
parents:
diff changeset
705 address start = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
706
a61af66fc99e Initial load
duke
parents:
diff changeset
707 Label L;
a61af66fc99e Initial load
duke
parents:
diff changeset
708
a61af66fc99e Initial load
duke
parents:
diff changeset
709 __ pushq(rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
710 __ pushq(c_rarg3);
a61af66fc99e Initial load
duke
parents:
diff changeset
711 __ pushq(c_rarg2);
a61af66fc99e Initial load
duke
parents:
diff changeset
712 __ pushq(c_rarg1);
a61af66fc99e Initial load
duke
parents:
diff changeset
713
a61af66fc99e Initial load
duke
parents:
diff changeset
714 __ movl(rax, 0x7f800000);
a61af66fc99e Initial load
duke
parents:
diff changeset
715 __ xorl(c_rarg3, c_rarg3);
a61af66fc99e Initial load
duke
parents:
diff changeset
716 __ movl(c_rarg2, inout);
a61af66fc99e Initial load
duke
parents:
diff changeset
717 __ movl(c_rarg1, c_rarg2);
a61af66fc99e Initial load
duke
parents:
diff changeset
718 __ andl(c_rarg1, 0x7fffffff);
a61af66fc99e Initial load
duke
parents:
diff changeset
719 __ cmpl(rax, c_rarg1); // NaN? -> 0
a61af66fc99e Initial load
duke
parents:
diff changeset
720 __ jcc(Assembler::negative, L);
a61af66fc99e Initial load
duke
parents:
diff changeset
721 __ testl(c_rarg2, c_rarg2); // signed ? min_jint : max_jint
a61af66fc99e Initial load
duke
parents:
diff changeset
722 __ movl(c_rarg3, 0x80000000);
a61af66fc99e Initial load
duke
parents:
diff changeset
723 __ movl(rax, 0x7fffffff);
a61af66fc99e Initial load
duke
parents:
diff changeset
724 __ cmovl(Assembler::positive, c_rarg3, rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
725
a61af66fc99e Initial load
duke
parents:
diff changeset
726 __ bind(L);
a61af66fc99e Initial load
duke
parents:
diff changeset
727 __ movq(inout, c_rarg3);
a61af66fc99e Initial load
duke
parents:
diff changeset
728
a61af66fc99e Initial load
duke
parents:
diff changeset
729 __ popq(c_rarg1);
a61af66fc99e Initial load
duke
parents:
diff changeset
730 __ popq(c_rarg2);
a61af66fc99e Initial load
duke
parents:
diff changeset
731 __ popq(c_rarg3);
a61af66fc99e Initial load
duke
parents:
diff changeset
732 __ popq(rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
733
a61af66fc99e Initial load
duke
parents:
diff changeset
734 __ ret(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
735
a61af66fc99e Initial load
duke
parents:
diff changeset
736 return start;
a61af66fc99e Initial load
duke
parents:
diff changeset
737 }
a61af66fc99e Initial load
duke
parents:
diff changeset
738
a61af66fc99e Initial load
duke
parents:
diff changeset
739 address generate_f2l_fixup() {
a61af66fc99e Initial load
duke
parents:
diff changeset
740 StubCodeMark mark(this, "StubRoutines", "f2l_fixup");
a61af66fc99e Initial load
duke
parents:
diff changeset
741 Address inout(rsp, 5 * wordSize); // return address + 4 saves
a61af66fc99e Initial load
duke
parents:
diff changeset
742 address start = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
743
a61af66fc99e Initial load
duke
parents:
diff changeset
744 Label L;
a61af66fc99e Initial load
duke
parents:
diff changeset
745
a61af66fc99e Initial load
duke
parents:
diff changeset
746 __ pushq(rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
747 __ pushq(c_rarg3);
a61af66fc99e Initial load
duke
parents:
diff changeset
748 __ pushq(c_rarg2);
a61af66fc99e Initial load
duke
parents:
diff changeset
749 __ pushq(c_rarg1);
a61af66fc99e Initial load
duke
parents:
diff changeset
750
a61af66fc99e Initial load
duke
parents:
diff changeset
751 __ movl(rax, 0x7f800000);
a61af66fc99e Initial load
duke
parents:
diff changeset
752 __ xorl(c_rarg3, c_rarg3);
a61af66fc99e Initial load
duke
parents:
diff changeset
753 __ movl(c_rarg2, inout);
a61af66fc99e Initial load
duke
parents:
diff changeset
754 __ movl(c_rarg1, c_rarg2);
a61af66fc99e Initial load
duke
parents:
diff changeset
755 __ andl(c_rarg1, 0x7fffffff);
a61af66fc99e Initial load
duke
parents:
diff changeset
756 __ cmpl(rax, c_rarg1); // NaN? -> 0
a61af66fc99e Initial load
duke
parents:
diff changeset
757 __ jcc(Assembler::negative, L);
a61af66fc99e Initial load
duke
parents:
diff changeset
758 __ testl(c_rarg2, c_rarg2); // signed ? min_jlong : max_jlong
a61af66fc99e Initial load
duke
parents:
diff changeset
759 __ mov64(c_rarg3, 0x8000000000000000);
a61af66fc99e Initial load
duke
parents:
diff changeset
760 __ mov64(rax, 0x7fffffffffffffff);
a61af66fc99e Initial load
duke
parents:
diff changeset
761 __ cmovq(Assembler::positive, c_rarg3, rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
762
a61af66fc99e Initial load
duke
parents:
diff changeset
763 __ bind(L);
a61af66fc99e Initial load
duke
parents:
diff changeset
764 __ movq(inout, c_rarg3);
a61af66fc99e Initial load
duke
parents:
diff changeset
765
a61af66fc99e Initial load
duke
parents:
diff changeset
766 __ popq(c_rarg1);
a61af66fc99e Initial load
duke
parents:
diff changeset
767 __ popq(c_rarg2);
a61af66fc99e Initial load
duke
parents:
diff changeset
768 __ popq(c_rarg3);
a61af66fc99e Initial load
duke
parents:
diff changeset
769 __ popq(rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
770
a61af66fc99e Initial load
duke
parents:
diff changeset
771 __ ret(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
772
a61af66fc99e Initial load
duke
parents:
diff changeset
773 return start;
a61af66fc99e Initial load
duke
parents:
diff changeset
774 }
a61af66fc99e Initial load
duke
parents:
diff changeset
775
a61af66fc99e Initial load
duke
parents:
diff changeset
776 address generate_d2i_fixup() {
a61af66fc99e Initial load
duke
parents:
diff changeset
777 StubCodeMark mark(this, "StubRoutines", "d2i_fixup");
a61af66fc99e Initial load
duke
parents:
diff changeset
778 Address inout(rsp, 6 * wordSize); // return address + 5 saves
a61af66fc99e Initial load
duke
parents:
diff changeset
779
a61af66fc99e Initial load
duke
parents:
diff changeset
780 address start = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
781
a61af66fc99e Initial load
duke
parents:
diff changeset
782 Label L;
a61af66fc99e Initial load
duke
parents:
diff changeset
783
a61af66fc99e Initial load
duke
parents:
diff changeset
784 __ pushq(rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
785 __ pushq(c_rarg3);
a61af66fc99e Initial load
duke
parents:
diff changeset
786 __ pushq(c_rarg2);
a61af66fc99e Initial load
duke
parents:
diff changeset
787 __ pushq(c_rarg1);
a61af66fc99e Initial load
duke
parents:
diff changeset
788 __ pushq(c_rarg0);
a61af66fc99e Initial load
duke
parents:
diff changeset
789
a61af66fc99e Initial load
duke
parents:
diff changeset
790 __ movl(rax, 0x7ff00000);
a61af66fc99e Initial load
duke
parents:
diff changeset
791 __ movq(c_rarg2, inout);
a61af66fc99e Initial load
duke
parents:
diff changeset
792 __ movl(c_rarg3, c_rarg2);
a61af66fc99e Initial load
duke
parents:
diff changeset
793 __ movq(c_rarg1, c_rarg2);
a61af66fc99e Initial load
duke
parents:
diff changeset
794 __ movq(c_rarg0, c_rarg2);
a61af66fc99e Initial load
duke
parents:
diff changeset
795 __ negl(c_rarg3);
a61af66fc99e Initial load
duke
parents:
diff changeset
796 __ shrq(c_rarg1, 0x20);
a61af66fc99e Initial load
duke
parents:
diff changeset
797 __ orl(c_rarg3, c_rarg2);
a61af66fc99e Initial load
duke
parents:
diff changeset
798 __ andl(c_rarg1, 0x7fffffff);
a61af66fc99e Initial load
duke
parents:
diff changeset
799 __ xorl(c_rarg2, c_rarg2);
a61af66fc99e Initial load
duke
parents:
diff changeset
800 __ shrl(c_rarg3, 0x1f);
a61af66fc99e Initial load
duke
parents:
diff changeset
801 __ orl(c_rarg1, c_rarg3);
a61af66fc99e Initial load
duke
parents:
diff changeset
802 __ cmpl(rax, c_rarg1);
a61af66fc99e Initial load
duke
parents:
diff changeset
803 __ jcc(Assembler::negative, L); // NaN -> 0
a61af66fc99e Initial load
duke
parents:
diff changeset
804 __ testq(c_rarg0, c_rarg0); // signed ? min_jint : max_jint
a61af66fc99e Initial load
duke
parents:
diff changeset
805 __ movl(c_rarg2, 0x80000000);
a61af66fc99e Initial load
duke
parents:
diff changeset
806 __ movl(rax, 0x7fffffff);
a61af66fc99e Initial load
duke
parents:
diff changeset
807 __ cmovl(Assembler::positive, c_rarg2, rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
808
a61af66fc99e Initial load
duke
parents:
diff changeset
809 __ bind(L);
a61af66fc99e Initial load
duke
parents:
diff changeset
810 __ movq(inout, c_rarg2);
a61af66fc99e Initial load
duke
parents:
diff changeset
811
a61af66fc99e Initial load
duke
parents:
diff changeset
812 __ popq(c_rarg0);
a61af66fc99e Initial load
duke
parents:
diff changeset
813 __ popq(c_rarg1);
a61af66fc99e Initial load
duke
parents:
diff changeset
814 __ popq(c_rarg2);
a61af66fc99e Initial load
duke
parents:
diff changeset
815 __ popq(c_rarg3);
a61af66fc99e Initial load
duke
parents:
diff changeset
816 __ popq(rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
817
a61af66fc99e Initial load
duke
parents:
diff changeset
818 __ ret(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
819
a61af66fc99e Initial load
duke
parents:
diff changeset
820 return start;
a61af66fc99e Initial load
duke
parents:
diff changeset
821 }
a61af66fc99e Initial load
duke
parents:
diff changeset
822
a61af66fc99e Initial load
duke
parents:
diff changeset
823 address generate_d2l_fixup() {
a61af66fc99e Initial load
duke
parents:
diff changeset
824 StubCodeMark mark(this, "StubRoutines", "d2l_fixup");
a61af66fc99e Initial load
duke
parents:
diff changeset
825 Address inout(rsp, 6 * wordSize); // return address + 5 saves
a61af66fc99e Initial load
duke
parents:
diff changeset
826
a61af66fc99e Initial load
duke
parents:
diff changeset
827 address start = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
828
a61af66fc99e Initial load
duke
parents:
diff changeset
829 Label L;
a61af66fc99e Initial load
duke
parents:
diff changeset
830
a61af66fc99e Initial load
duke
parents:
diff changeset
831 __ pushq(rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
832 __ pushq(c_rarg3);
a61af66fc99e Initial load
duke
parents:
diff changeset
833 __ pushq(c_rarg2);
a61af66fc99e Initial load
duke
parents:
diff changeset
834 __ pushq(c_rarg1);
a61af66fc99e Initial load
duke
parents:
diff changeset
835 __ pushq(c_rarg0);
a61af66fc99e Initial load
duke
parents:
diff changeset
836
a61af66fc99e Initial load
duke
parents:
diff changeset
837 __ movl(rax, 0x7ff00000);
a61af66fc99e Initial load
duke
parents:
diff changeset
838 __ movq(c_rarg2, inout);
a61af66fc99e Initial load
duke
parents:
diff changeset
839 __ movl(c_rarg3, c_rarg2);
a61af66fc99e Initial load
duke
parents:
diff changeset
840 __ movq(c_rarg1, c_rarg2);
a61af66fc99e Initial load
duke
parents:
diff changeset
841 __ movq(c_rarg0, c_rarg2);
a61af66fc99e Initial load
duke
parents:
diff changeset
842 __ negl(c_rarg3);
a61af66fc99e Initial load
duke
parents:
diff changeset
843 __ shrq(c_rarg1, 0x20);
a61af66fc99e Initial load
duke
parents:
diff changeset
844 __ orl(c_rarg3, c_rarg2);
a61af66fc99e Initial load
duke
parents:
diff changeset
845 __ andl(c_rarg1, 0x7fffffff);
a61af66fc99e Initial load
duke
parents:
diff changeset
846 __ xorl(c_rarg2, c_rarg2);
a61af66fc99e Initial load
duke
parents:
diff changeset
847 __ shrl(c_rarg3, 0x1f);
a61af66fc99e Initial load
duke
parents:
diff changeset
848 __ orl(c_rarg1, c_rarg3);
a61af66fc99e Initial load
duke
parents:
diff changeset
849 __ cmpl(rax, c_rarg1);
a61af66fc99e Initial load
duke
parents:
diff changeset
850 __ jcc(Assembler::negative, L); // NaN -> 0
a61af66fc99e Initial load
duke
parents:
diff changeset
851 __ testq(c_rarg0, c_rarg0); // signed ? min_jlong : max_jlong
a61af66fc99e Initial load
duke
parents:
diff changeset
852 __ mov64(c_rarg2, 0x8000000000000000);
a61af66fc99e Initial load
duke
parents:
diff changeset
853 __ mov64(rax, 0x7fffffffffffffff);
a61af66fc99e Initial load
duke
parents:
diff changeset
854 __ cmovq(Assembler::positive, c_rarg2, rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
855
a61af66fc99e Initial load
duke
parents:
diff changeset
856 __ bind(L);
a61af66fc99e Initial load
duke
parents:
diff changeset
857 __ movq(inout, c_rarg2);
a61af66fc99e Initial load
duke
parents:
diff changeset
858
a61af66fc99e Initial load
duke
parents:
diff changeset
859 __ popq(c_rarg0);
a61af66fc99e Initial load
duke
parents:
diff changeset
860 __ popq(c_rarg1);
a61af66fc99e Initial load
duke
parents:
diff changeset
861 __ popq(c_rarg2);
a61af66fc99e Initial load
duke
parents:
diff changeset
862 __ popq(c_rarg3);
a61af66fc99e Initial load
duke
parents:
diff changeset
863 __ popq(rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
864
a61af66fc99e Initial load
duke
parents:
diff changeset
865 __ ret(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
866
a61af66fc99e Initial load
duke
parents:
diff changeset
867 return start;
a61af66fc99e Initial load
duke
parents:
diff changeset
868 }
a61af66fc99e Initial load
duke
parents:
diff changeset
869
a61af66fc99e Initial load
duke
parents:
diff changeset
870 address generate_fp_mask(const char *stub_name, int64_t mask) {
a61af66fc99e Initial load
duke
parents:
diff changeset
871 StubCodeMark mark(this, "StubRoutines", stub_name);
a61af66fc99e Initial load
duke
parents:
diff changeset
872
a61af66fc99e Initial load
duke
parents:
diff changeset
873 __ align(16);
a61af66fc99e Initial load
duke
parents:
diff changeset
874 address start = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
875
a61af66fc99e Initial load
duke
parents:
diff changeset
876 __ emit_data64( mask, relocInfo::none );
a61af66fc99e Initial load
duke
parents:
diff changeset
877 __ emit_data64( mask, relocInfo::none );
a61af66fc99e Initial load
duke
parents:
diff changeset
878
a61af66fc99e Initial load
duke
parents:
diff changeset
879 return start;
a61af66fc99e Initial load
duke
parents:
diff changeset
880 }
a61af66fc99e Initial load
duke
parents:
diff changeset
881
a61af66fc99e Initial load
duke
parents:
diff changeset
882 // The following routine generates a subroutine to throw an
a61af66fc99e Initial load
duke
parents:
diff changeset
883 // asynchronous UnknownError when an unsafe access gets a fault that
a61af66fc99e Initial load
duke
parents:
diff changeset
884 // could not be reasonably prevented by the programmer. (Example:
a61af66fc99e Initial load
duke
parents:
diff changeset
885 // SIGBUS/OBJERR.)
a61af66fc99e Initial load
duke
parents:
diff changeset
886 address generate_handler_for_unsafe_access() {
a61af66fc99e Initial load
duke
parents:
diff changeset
887 StubCodeMark mark(this, "StubRoutines", "handler_for_unsafe_access");
a61af66fc99e Initial load
duke
parents:
diff changeset
888 address start = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
889
a61af66fc99e Initial load
duke
parents:
diff changeset
890 __ pushq(0); // hole for return address-to-be
a61af66fc99e Initial load
duke
parents:
diff changeset
891 __ pushaq(); // push registers
a61af66fc99e Initial load
duke
parents:
diff changeset
892 Address next_pc(rsp, RegisterImpl::number_of_registers * BytesPerWord);
a61af66fc99e Initial load
duke
parents:
diff changeset
893
a61af66fc99e Initial load
duke
parents:
diff changeset
894 __ subq(rsp, frame::arg_reg_save_area_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
895 BLOCK_COMMENT("call handle_unsafe_access");
a61af66fc99e Initial load
duke
parents:
diff changeset
896 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, handle_unsafe_access)));
a61af66fc99e Initial load
duke
parents:
diff changeset
897 __ addq(rsp, frame::arg_reg_save_area_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
898
a61af66fc99e Initial load
duke
parents:
diff changeset
899 __ movq(next_pc, rax); // stuff next address
a61af66fc99e Initial load
duke
parents:
diff changeset
900 __ popaq();
a61af66fc99e Initial load
duke
parents:
diff changeset
901 __ ret(0); // jump to next address
a61af66fc99e Initial load
duke
parents:
diff changeset
902
a61af66fc99e Initial load
duke
parents:
diff changeset
903 return start;
a61af66fc99e Initial load
duke
parents:
diff changeset
904 }
a61af66fc99e Initial load
duke
parents:
diff changeset
905
a61af66fc99e Initial load
duke
parents:
diff changeset
906 // Non-destructive plausibility checks for oops
a61af66fc99e Initial load
duke
parents:
diff changeset
907 //
a61af66fc99e Initial load
duke
parents:
diff changeset
908 // Arguments:
a61af66fc99e Initial load
duke
parents:
diff changeset
909 // all args on stack!
a61af66fc99e Initial load
duke
parents:
diff changeset
910 //
a61af66fc99e Initial load
duke
parents:
diff changeset
911 // Stack after saving c_rarg3:
a61af66fc99e Initial load
duke
parents:
diff changeset
912 // [tos + 0]: saved c_rarg3
a61af66fc99e Initial load
duke
parents:
diff changeset
913 // [tos + 1]: saved c_rarg2
a61af66fc99e Initial load
duke
parents:
diff changeset
914 // [tos + 2]: saved flags
a61af66fc99e Initial load
duke
parents:
diff changeset
915 // [tos + 3]: return address
a61af66fc99e Initial load
duke
parents:
diff changeset
916 // * [tos + 4]: error message (char*)
a61af66fc99e Initial load
duke
parents:
diff changeset
917 // * [tos + 5]: object to verify (oop)
a61af66fc99e Initial load
duke
parents:
diff changeset
918 // * [tos + 6]: saved rax - saved by caller and bashed
a61af66fc99e Initial load
duke
parents:
diff changeset
919 // * = popped on exit
a61af66fc99e Initial load
duke
parents:
diff changeset
920 address generate_verify_oop() {
a61af66fc99e Initial load
duke
parents:
diff changeset
921 StubCodeMark mark(this, "StubRoutines", "verify_oop");
a61af66fc99e Initial load
duke
parents:
diff changeset
922 address start = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
923
a61af66fc99e Initial load
duke
parents:
diff changeset
924 Label exit, error;
a61af66fc99e Initial load
duke
parents:
diff changeset
925
a61af66fc99e Initial load
duke
parents:
diff changeset
926 __ pushfq();
a61af66fc99e Initial load
duke
parents:
diff changeset
927 __ incrementl(ExternalAddress((address) StubRoutines::verify_oop_count_addr()));
a61af66fc99e Initial load
duke
parents:
diff changeset
928
a61af66fc99e Initial load
duke
parents:
diff changeset
929 // save c_rarg2 and c_rarg3
a61af66fc99e Initial load
duke
parents:
diff changeset
930 __ pushq(c_rarg2);
a61af66fc99e Initial load
duke
parents:
diff changeset
931 __ pushq(c_rarg3);
a61af66fc99e Initial load
duke
parents:
diff changeset
932
a61af66fc99e Initial load
duke
parents:
diff changeset
933 // get object
a61af66fc99e Initial load
duke
parents:
diff changeset
934 __ movq(rax, Address(rsp, 5 * wordSize));
a61af66fc99e Initial load
duke
parents:
diff changeset
935
a61af66fc99e Initial load
duke
parents:
diff changeset
936 // make sure object is 'reasonable'
a61af66fc99e Initial load
duke
parents:
diff changeset
937 __ testq(rax, rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
938 __ jcc(Assembler::zero, exit); // if obj is NULL it is OK
a61af66fc99e Initial load
duke
parents:
diff changeset
939 // Check if the oop is in the right area of memory
a61af66fc99e Initial load
duke
parents:
diff changeset
940 __ movq(c_rarg2, rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
941 __ movptr(c_rarg3, (int64_t) Universe::verify_oop_mask());
a61af66fc99e Initial load
duke
parents:
diff changeset
942 __ andq(c_rarg2, c_rarg3);
a61af66fc99e Initial load
duke
parents:
diff changeset
943 __ movptr(c_rarg3, (int64_t) Universe::verify_oop_bits());
a61af66fc99e Initial load
duke
parents:
diff changeset
944 __ cmpq(c_rarg2, c_rarg3);
a61af66fc99e Initial load
duke
parents:
diff changeset
945 __ jcc(Assembler::notZero, error);
a61af66fc99e Initial load
duke
parents:
diff changeset
946
a61af66fc99e Initial load
duke
parents:
diff changeset
947 // make sure klass is 'reasonable'
a61af66fc99e Initial load
duke
parents:
diff changeset
948 __ movq(rax, Address(rax, oopDesc::klass_offset_in_bytes())); // get klass
a61af66fc99e Initial load
duke
parents:
diff changeset
949 __ testq(rax, rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
950 __ jcc(Assembler::zero, error); // if klass is NULL it is broken
a61af66fc99e Initial load
duke
parents:
diff changeset
951 // Check if the klass is in the right area of memory
a61af66fc99e Initial load
duke
parents:
diff changeset
952 __ movq(c_rarg2, rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
953 __ movptr(c_rarg3, (int64_t) Universe::verify_klass_mask());
a61af66fc99e Initial load
duke
parents:
diff changeset
954 __ andq(c_rarg2, c_rarg3);
a61af66fc99e Initial load
duke
parents:
diff changeset
955 __ movptr(c_rarg3, (int64_t) Universe::verify_klass_bits());
a61af66fc99e Initial load
duke
parents:
diff changeset
956 __ cmpq(c_rarg2, c_rarg3);
a61af66fc99e Initial load
duke
parents:
diff changeset
957 __ jcc(Assembler::notZero, error);
a61af66fc99e Initial load
duke
parents:
diff changeset
958
a61af66fc99e Initial load
duke
parents:
diff changeset
959 // make sure klass' klass is 'reasonable'
a61af66fc99e Initial load
duke
parents:
diff changeset
960 __ movq(rax, Address(rax, oopDesc::klass_offset_in_bytes()));
a61af66fc99e Initial load
duke
parents:
diff changeset
961 __ testq(rax, rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
962 __ jcc(Assembler::zero, error); // if klass' klass is NULL it is broken
a61af66fc99e Initial load
duke
parents:
diff changeset
963 // Check if the klass' klass is in the right area of memory
a61af66fc99e Initial load
duke
parents:
diff changeset
964 __ movptr(c_rarg3, (int64_t) Universe::verify_klass_mask());
a61af66fc99e Initial load
duke
parents:
diff changeset
965 __ andq(rax, c_rarg3);
a61af66fc99e Initial load
duke
parents:
diff changeset
966 __ movptr(c_rarg3, (int64_t) Universe::verify_klass_bits());
a61af66fc99e Initial load
duke
parents:
diff changeset
967 __ cmpq(rax, c_rarg3);
a61af66fc99e Initial load
duke
parents:
diff changeset
968 __ jcc(Assembler::notZero, error);
a61af66fc99e Initial load
duke
parents:
diff changeset
969
a61af66fc99e Initial load
duke
parents:
diff changeset
970 // return if everything seems ok
a61af66fc99e Initial load
duke
parents:
diff changeset
971 __ bind(exit);
a61af66fc99e Initial load
duke
parents:
diff changeset
972 __ movq(rax, Address(rsp, 6 * wordSize)); // get saved rax back
a61af66fc99e Initial load
duke
parents:
diff changeset
973 __ popq(c_rarg3); // restore c_rarg3
a61af66fc99e Initial load
duke
parents:
diff changeset
974 __ popq(c_rarg2); // restore c_rarg2
a61af66fc99e Initial load
duke
parents:
diff changeset
975 __ popfq(); // restore flags
a61af66fc99e Initial load
duke
parents:
diff changeset
976 __ ret(3 * wordSize); // pop caller saved stuff
a61af66fc99e Initial load
duke
parents:
diff changeset
977
a61af66fc99e Initial load
duke
parents:
diff changeset
978 // handle errors
a61af66fc99e Initial load
duke
parents:
diff changeset
979 __ bind(error);
a61af66fc99e Initial load
duke
parents:
diff changeset
980 __ movq(rax, Address(rsp, 6 * wordSize)); // get saved rax back
a61af66fc99e Initial load
duke
parents:
diff changeset
981 __ popq(c_rarg3); // get saved c_rarg3 back
a61af66fc99e Initial load
duke
parents:
diff changeset
982 __ popq(c_rarg2); // get saved c_rarg2 back
a61af66fc99e Initial load
duke
parents:
diff changeset
983 __ popfq(); // get saved flags off stack --
a61af66fc99e Initial load
duke
parents:
diff changeset
984 // will be ignored
a61af66fc99e Initial load
duke
parents:
diff changeset
985
a61af66fc99e Initial load
duke
parents:
diff changeset
986 __ pushaq(); // push registers
a61af66fc99e Initial load
duke
parents:
diff changeset
987 // (rip is already
a61af66fc99e Initial load
duke
parents:
diff changeset
988 // already pushed)
a61af66fc99e Initial load
duke
parents:
diff changeset
989 // debug(char* msg, int64_t regs[])
a61af66fc99e Initial load
duke
parents:
diff changeset
990 // We've popped the registers we'd saved (c_rarg3, c_rarg2 and flags), and
a61af66fc99e Initial load
duke
parents:
diff changeset
991 // pushed all the registers, so now the stack looks like:
a61af66fc99e Initial load
duke
parents:
diff changeset
992 // [tos + 0] 16 saved registers
a61af66fc99e Initial load
duke
parents:
diff changeset
993 // [tos + 16] return address
a61af66fc99e Initial load
duke
parents:
diff changeset
994 // [tos + 17] error message (char*)
a61af66fc99e Initial load
duke
parents:
diff changeset
995
a61af66fc99e Initial load
duke
parents:
diff changeset
996 __ movq(c_rarg0, Address(rsp, 17 * wordSize)); // pass address of error message
a61af66fc99e Initial load
duke
parents:
diff changeset
997 __ movq(c_rarg1, rsp); // pass address of regs on stack
a61af66fc99e Initial load
duke
parents:
diff changeset
998 __ movq(r12, rsp); // remember rsp
a61af66fc99e Initial load
duke
parents:
diff changeset
999 __ subq(rsp, frame::arg_reg_save_area_bytes);// windows
a61af66fc99e Initial load
duke
parents:
diff changeset
1000 __ andq(rsp, -16); // align stack as required by ABI
a61af66fc99e Initial load
duke
parents:
diff changeset
1001 BLOCK_COMMENT("call MacroAssembler::debug");
a61af66fc99e Initial load
duke
parents:
diff changeset
1002 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, MacroAssembler::debug)));
a61af66fc99e Initial load
duke
parents:
diff changeset
1003 __ movq(rsp, r12); // restore rsp
a61af66fc99e Initial load
duke
parents:
diff changeset
1004 __ popaq(); // pop registers
a61af66fc99e Initial load
duke
parents:
diff changeset
1005 __ ret(3 * wordSize); // pop caller saved stuff
a61af66fc99e Initial load
duke
parents:
diff changeset
1006
a61af66fc99e Initial load
duke
parents:
diff changeset
1007 return start;
a61af66fc99e Initial load
duke
parents:
diff changeset
1008 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1009
a61af66fc99e Initial load
duke
parents:
diff changeset
1010 static address disjoint_byte_copy_entry;
a61af66fc99e Initial load
duke
parents:
diff changeset
1011 static address disjoint_short_copy_entry;
a61af66fc99e Initial load
duke
parents:
diff changeset
1012 static address disjoint_int_copy_entry;
a61af66fc99e Initial load
duke
parents:
diff changeset
1013 static address disjoint_long_copy_entry;
a61af66fc99e Initial load
duke
parents:
diff changeset
1014 static address disjoint_oop_copy_entry;
a61af66fc99e Initial load
duke
parents:
diff changeset
1015
a61af66fc99e Initial load
duke
parents:
diff changeset
1016 static address byte_copy_entry;
a61af66fc99e Initial load
duke
parents:
diff changeset
1017 static address short_copy_entry;
a61af66fc99e Initial load
duke
parents:
diff changeset
1018 static address int_copy_entry;
a61af66fc99e Initial load
duke
parents:
diff changeset
1019 static address long_copy_entry;
a61af66fc99e Initial load
duke
parents:
diff changeset
1020 static address oop_copy_entry;
a61af66fc99e Initial load
duke
parents:
diff changeset
1021
a61af66fc99e Initial load
duke
parents:
diff changeset
1022 static address checkcast_copy_entry;
a61af66fc99e Initial load
duke
parents:
diff changeset
1023
a61af66fc99e Initial load
duke
parents:
diff changeset
1024 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1025 // Verify that a register contains clean 32-bits positive value
a61af66fc99e Initial load
duke
parents:
diff changeset
1026 // (high 32-bits are 0) so it could be used in 64-bits shifts.
a61af66fc99e Initial load
duke
parents:
diff changeset
1027 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1028 // Input:
a61af66fc99e Initial load
duke
parents:
diff changeset
1029 // Rint - 32-bits value
a61af66fc99e Initial load
duke
parents:
diff changeset
1030 // Rtmp - scratch
a61af66fc99e Initial load
duke
parents:
diff changeset
1031 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1032 void assert_clean_int(Register Rint, Register Rtmp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1033 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
1034 Label L;
a61af66fc99e Initial load
duke
parents:
diff changeset
1035 assert_different_registers(Rtmp, Rint);
a61af66fc99e Initial load
duke
parents:
diff changeset
1036 __ movslq(Rtmp, Rint);
a61af66fc99e Initial load
duke
parents:
diff changeset
1037 __ cmpq(Rtmp, Rint);
a61af66fc99e Initial load
duke
parents:
diff changeset
1038 __ jccb(Assembler::equal, L);
a61af66fc99e Initial load
duke
parents:
diff changeset
1039 __ stop("high 32-bits of int value are not 0");
a61af66fc99e Initial load
duke
parents:
diff changeset
1040 __ bind(L);
a61af66fc99e Initial load
duke
parents:
diff changeset
1041 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
1042 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1043
a61af66fc99e Initial load
duke
parents:
diff changeset
1044 // Generate overlap test for array copy stubs
a61af66fc99e Initial load
duke
parents:
diff changeset
1045 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1046 // Input:
a61af66fc99e Initial load
duke
parents:
diff changeset
1047 // c_rarg0 - from
a61af66fc99e Initial load
duke
parents:
diff changeset
1048 // c_rarg1 - to
a61af66fc99e Initial load
duke
parents:
diff changeset
1049 // c_rarg2 - element count
a61af66fc99e Initial load
duke
parents:
diff changeset
1050 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1051 // Output:
a61af66fc99e Initial load
duke
parents:
diff changeset
1052 // rax - &from[element count - 1]
a61af66fc99e Initial load
duke
parents:
diff changeset
1053 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1054 void array_overlap_test(address no_overlap_target, Address::ScaleFactor sf) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1055 assert(no_overlap_target != NULL, "must be generated");
a61af66fc99e Initial load
duke
parents:
diff changeset
1056 array_overlap_test(no_overlap_target, NULL, sf);
a61af66fc99e Initial load
duke
parents:
diff changeset
1057 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1058 void array_overlap_test(Label& L_no_overlap, Address::ScaleFactor sf) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1059 array_overlap_test(NULL, &L_no_overlap, sf);
a61af66fc99e Initial load
duke
parents:
diff changeset
1060 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1061 void array_overlap_test(address no_overlap_target, Label* NOLp, Address::ScaleFactor sf) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1062 const Register from = c_rarg0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1063 const Register to = c_rarg1;
a61af66fc99e Initial load
duke
parents:
diff changeset
1064 const Register count = c_rarg2;
a61af66fc99e Initial load
duke
parents:
diff changeset
1065 const Register end_from = rax;
a61af66fc99e Initial load
duke
parents:
diff changeset
1066
a61af66fc99e Initial load
duke
parents:
diff changeset
1067 __ cmpq(to, from);
a61af66fc99e Initial load
duke
parents:
diff changeset
1068 __ leaq(end_from, Address(from, count, sf, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
1069 if (NOLp == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1070 ExternalAddress no_overlap(no_overlap_target);
a61af66fc99e Initial load
duke
parents:
diff changeset
1071 __ jump_cc(Assembler::belowEqual, no_overlap);
a61af66fc99e Initial load
duke
parents:
diff changeset
1072 __ cmpq(to, end_from);
a61af66fc99e Initial load
duke
parents:
diff changeset
1073 __ jump_cc(Assembler::aboveEqual, no_overlap);
a61af66fc99e Initial load
duke
parents:
diff changeset
1074 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1075 __ jcc(Assembler::belowEqual, (*NOLp));
a61af66fc99e Initial load
duke
parents:
diff changeset
1076 __ cmpq(to, end_from);
a61af66fc99e Initial load
duke
parents:
diff changeset
1077 __ jcc(Assembler::aboveEqual, (*NOLp));
a61af66fc99e Initial load
duke
parents:
diff changeset
1078 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1079 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1080
a61af66fc99e Initial load
duke
parents:
diff changeset
1081 // Shuffle first three arg regs on Windows into Linux/Solaris locations.
a61af66fc99e Initial load
duke
parents:
diff changeset
1082 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1083 // Outputs:
a61af66fc99e Initial load
duke
parents:
diff changeset
1084 // rdi - rcx
a61af66fc99e Initial load
duke
parents:
diff changeset
1085 // rsi - rdx
a61af66fc99e Initial load
duke
parents:
diff changeset
1086 // rdx - r8
a61af66fc99e Initial load
duke
parents:
diff changeset
1087 // rcx - r9
a61af66fc99e Initial load
duke
parents:
diff changeset
1088 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1089 // Registers r9 and r10 are used to save rdi and rsi on Windows, which latter
a61af66fc99e Initial load
duke
parents:
diff changeset
1090 // are non-volatile. r9 and r10 should not be used by the caller.
a61af66fc99e Initial load
duke
parents:
diff changeset
1091 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1092 void setup_arg_regs(int nargs = 3) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1093 const Register saved_rdi = r9;
a61af66fc99e Initial load
duke
parents:
diff changeset
1094 const Register saved_rsi = r10;
a61af66fc99e Initial load
duke
parents:
diff changeset
1095 assert(nargs == 3 || nargs == 4, "else fix");
a61af66fc99e Initial load
duke
parents:
diff changeset
1096 #ifdef _WIN64
a61af66fc99e Initial load
duke
parents:
diff changeset
1097 assert(c_rarg0 == rcx && c_rarg1 == rdx && c_rarg2 == r8 && c_rarg3 == r9,
a61af66fc99e Initial load
duke
parents:
diff changeset
1098 "unexpected argument registers");
a61af66fc99e Initial load
duke
parents:
diff changeset
1099 if (nargs >= 4)
a61af66fc99e Initial load
duke
parents:
diff changeset
1100 __ movq(rax, r9); // r9 is also saved_rdi
a61af66fc99e Initial load
duke
parents:
diff changeset
1101 __ movq(saved_rdi, rdi);
a61af66fc99e Initial load
duke
parents:
diff changeset
1102 __ movq(saved_rsi, rsi);
a61af66fc99e Initial load
duke
parents:
diff changeset
1103 __ movq(rdi, rcx); // c_rarg0
a61af66fc99e Initial load
duke
parents:
diff changeset
1104 __ movq(rsi, rdx); // c_rarg1
a61af66fc99e Initial load
duke
parents:
diff changeset
1105 __ movq(rdx, r8); // c_rarg2
a61af66fc99e Initial load
duke
parents:
diff changeset
1106 if (nargs >= 4)
a61af66fc99e Initial load
duke
parents:
diff changeset
1107 __ movq(rcx, rax); // c_rarg3 (via rax)
a61af66fc99e Initial load
duke
parents:
diff changeset
1108 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
1109 assert(c_rarg0 == rdi && c_rarg1 == rsi && c_rarg2 == rdx && c_rarg3 == rcx,
a61af66fc99e Initial load
duke
parents:
diff changeset
1110 "unexpected argument registers");
a61af66fc99e Initial load
duke
parents:
diff changeset
1111 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
1112 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1113
a61af66fc99e Initial load
duke
parents:
diff changeset
1114 void restore_arg_regs() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1115 const Register saved_rdi = r9;
a61af66fc99e Initial load
duke
parents:
diff changeset
1116 const Register saved_rsi = r10;
a61af66fc99e Initial load
duke
parents:
diff changeset
1117 #ifdef _WIN64
a61af66fc99e Initial load
duke
parents:
diff changeset
1118 __ movq(rdi, saved_rdi);
a61af66fc99e Initial load
duke
parents:
diff changeset
1119 __ movq(rsi, saved_rsi);
a61af66fc99e Initial load
duke
parents:
diff changeset
1120 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
1121 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1122
a61af66fc99e Initial load
duke
parents:
diff changeset
1123 // Generate code for an array write pre barrier
a61af66fc99e Initial load
duke
parents:
diff changeset
1124 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1125 // addr - starting address
a61af66fc99e Initial load
duke
parents:
diff changeset
1126 // count - element count
a61af66fc99e Initial load
duke
parents:
diff changeset
1127 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1128 // Destroy no registers!
a61af66fc99e Initial load
duke
parents:
diff changeset
1129 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1130 void gen_write_ref_array_pre_barrier(Register addr, Register count) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1131 #if 0 // G1 - only
a61af66fc99e Initial load
duke
parents:
diff changeset
1132 assert_different_registers(addr, c_rarg1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1133 assert_different_registers(count, c_rarg0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1134 BarrierSet* bs = Universe::heap()->barrier_set();
a61af66fc99e Initial load
duke
parents:
diff changeset
1135 switch (bs->kind()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1136 case BarrierSet::G1SATBCT:
a61af66fc99e Initial load
duke
parents:
diff changeset
1137 case BarrierSet::G1SATBCTLogging:
a61af66fc99e Initial load
duke
parents:
diff changeset
1138 {
a61af66fc99e Initial load
duke
parents:
diff changeset
1139 __ pushaq(); // push registers
a61af66fc99e Initial load
duke
parents:
diff changeset
1140 __ movq(c_rarg0, addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1141 __ movq(c_rarg1, count);
a61af66fc99e Initial load
duke
parents:
diff changeset
1142 __ call(RuntimeAddress(BarrierSet::static_write_ref_array_pre));
a61af66fc99e Initial load
duke
parents:
diff changeset
1143 __ popaq();
a61af66fc99e Initial load
duke
parents:
diff changeset
1144 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1145 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1146 case BarrierSet::CardTableModRef:
a61af66fc99e Initial load
duke
parents:
diff changeset
1147 case BarrierSet::CardTableExtension:
a61af66fc99e Initial load
duke
parents:
diff changeset
1148 case BarrierSet::ModRef:
a61af66fc99e Initial load
duke
parents:
diff changeset
1149 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1150 default :
a61af66fc99e Initial load
duke
parents:
diff changeset
1151 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1152
a61af66fc99e Initial load
duke
parents:
diff changeset
1153 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1154 #endif // 0 G1 - only
a61af66fc99e Initial load
duke
parents:
diff changeset
1155 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1156
a61af66fc99e Initial load
duke
parents:
diff changeset
1157 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1158 // Generate code for an array write post barrier
a61af66fc99e Initial load
duke
parents:
diff changeset
1159 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1160 // Input:
a61af66fc99e Initial load
duke
parents:
diff changeset
1161 // start - register containing starting address of destination array
a61af66fc99e Initial load
duke
parents:
diff changeset
1162 // end - register containing ending address of destination array
a61af66fc99e Initial load
duke
parents:
diff changeset
1163 // scratch - scratch register
a61af66fc99e Initial load
duke
parents:
diff changeset
1164 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1165 // The input registers are overwritten.
a61af66fc99e Initial load
duke
parents:
diff changeset
1166 // The ending address is inclusive.
a61af66fc99e Initial load
duke
parents:
diff changeset
1167 void gen_write_ref_array_post_barrier(Register start, Register end, Register scratch) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1168 assert_different_registers(start, end, scratch);
a61af66fc99e Initial load
duke
parents:
diff changeset
1169 BarrierSet* bs = Universe::heap()->barrier_set();
a61af66fc99e Initial load
duke
parents:
diff changeset
1170 switch (bs->kind()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1171 #if 0 // G1 - only
a61af66fc99e Initial load
duke
parents:
diff changeset
1172 case BarrierSet::G1SATBCT:
a61af66fc99e Initial load
duke
parents:
diff changeset
1173 case BarrierSet::G1SATBCTLogging:
a61af66fc99e Initial load
duke
parents:
diff changeset
1174
a61af66fc99e Initial load
duke
parents:
diff changeset
1175 {
a61af66fc99e Initial load
duke
parents:
diff changeset
1176 __ pushaq(); // push registers (overkill)
a61af66fc99e Initial load
duke
parents:
diff changeset
1177 // must compute element count unless barrier set interface is changed (other platforms supply count)
a61af66fc99e Initial load
duke
parents:
diff changeset
1178 assert_different_registers(start, end, scratch);
a61af66fc99e Initial load
duke
parents:
diff changeset
1179 __ leaq(scratch, Address(end, wordSize));
a61af66fc99e Initial load
duke
parents:
diff changeset
1180 __ subq(scratch, start);
a61af66fc99e Initial load
duke
parents:
diff changeset
1181 __ shrq(scratch, LogBytesPerWord);
a61af66fc99e Initial load
duke
parents:
diff changeset
1182 __ movq(c_rarg0, start);
a61af66fc99e Initial load
duke
parents:
diff changeset
1183 __ movq(c_rarg1, scratch);
a61af66fc99e Initial load
duke
parents:
diff changeset
1184 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, BarrierSet::static_write_ref_array_post));
a61af66fc99e Initial load
duke
parents:
diff changeset
1185 __ popaq();
a61af66fc99e Initial load
duke
parents:
diff changeset
1186 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1187 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1188 #endif // 0 G1 - only
a61af66fc99e Initial load
duke
parents:
diff changeset
1189 case BarrierSet::CardTableModRef:
a61af66fc99e Initial load
duke
parents:
diff changeset
1190 case BarrierSet::CardTableExtension:
a61af66fc99e Initial load
duke
parents:
diff changeset
1191 {
a61af66fc99e Initial load
duke
parents:
diff changeset
1192 CardTableModRefBS* ct = (CardTableModRefBS*)bs;
a61af66fc99e Initial load
duke
parents:
diff changeset
1193 assert(sizeof(*ct->byte_map_base) == sizeof(jbyte), "adjust this code");
a61af66fc99e Initial load
duke
parents:
diff changeset
1194
a61af66fc99e Initial load
duke
parents:
diff changeset
1195 Label L_loop;
a61af66fc99e Initial load
duke
parents:
diff changeset
1196
a61af66fc99e Initial load
duke
parents:
diff changeset
1197 __ shrq(start, CardTableModRefBS::card_shift);
a61af66fc99e Initial load
duke
parents:
diff changeset
1198 __ shrq(end, CardTableModRefBS::card_shift);
a61af66fc99e Initial load
duke
parents:
diff changeset
1199 __ subq(end, start); // number of bytes to copy
a61af66fc99e Initial load
duke
parents:
diff changeset
1200
a61af66fc99e Initial load
duke
parents:
diff changeset
1201 const Register count = end; // 'end' register contains bytes count now
a61af66fc99e Initial load
duke
parents:
diff changeset
1202 __ lea(scratch, ExternalAddress((address)ct->byte_map_base));
a61af66fc99e Initial load
duke
parents:
diff changeset
1203 __ addq(start, scratch);
a61af66fc99e Initial load
duke
parents:
diff changeset
1204 __ BIND(L_loop);
a61af66fc99e Initial load
duke
parents:
diff changeset
1205 __ movb(Address(start, count, Address::times_1), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1206 __ decrementq(count);
a61af66fc99e Initial load
duke
parents:
diff changeset
1207 __ jcc(Assembler::greaterEqual, L_loop);
a61af66fc99e Initial load
duke
parents:
diff changeset
1208 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1209 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1210 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1211
a61af66fc99e Initial load
duke
parents:
diff changeset
1212 // Copy big chunks forward
a61af66fc99e Initial load
duke
parents:
diff changeset
1213 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1214 // Inputs:
a61af66fc99e Initial load
duke
parents:
diff changeset
1215 // end_from - source arrays end address
a61af66fc99e Initial load
duke
parents:
diff changeset
1216 // end_to - destination array end address
a61af66fc99e Initial load
duke
parents:
diff changeset
1217 // qword_count - 64-bits element count, negative
a61af66fc99e Initial load
duke
parents:
diff changeset
1218 // to - scratch
a61af66fc99e Initial load
duke
parents:
diff changeset
1219 // L_copy_32_bytes - entry label
a61af66fc99e Initial load
duke
parents:
diff changeset
1220 // L_copy_8_bytes - exit label
a61af66fc99e Initial load
duke
parents:
diff changeset
1221 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1222 void copy_32_bytes_forward(Register end_from, Register end_to,
a61af66fc99e Initial load
duke
parents:
diff changeset
1223 Register qword_count, Register to,
a61af66fc99e Initial load
duke
parents:
diff changeset
1224 Label& L_copy_32_bytes, Label& L_copy_8_bytes) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1225 DEBUG_ONLY(__ stop("enter at entry label, not here"));
a61af66fc99e Initial load
duke
parents:
diff changeset
1226 Label L_loop;
a61af66fc99e Initial load
duke
parents:
diff changeset
1227 __ align(16);
a61af66fc99e Initial load
duke
parents:
diff changeset
1228 __ BIND(L_loop);
a61af66fc99e Initial load
duke
parents:
diff changeset
1229 __ movq(to, Address(end_from, qword_count, Address::times_8, -24));
a61af66fc99e Initial load
duke
parents:
diff changeset
1230 __ movq(Address(end_to, qword_count, Address::times_8, -24), to);
a61af66fc99e Initial load
duke
parents:
diff changeset
1231 __ movq(to, Address(end_from, qword_count, Address::times_8, -16));
a61af66fc99e Initial load
duke
parents:
diff changeset
1232 __ movq(Address(end_to, qword_count, Address::times_8, -16), to);
a61af66fc99e Initial load
duke
parents:
diff changeset
1233 __ movq(to, Address(end_from, qword_count, Address::times_8, - 8));
a61af66fc99e Initial load
duke
parents:
diff changeset
1234 __ movq(Address(end_to, qword_count, Address::times_8, - 8), to);
a61af66fc99e Initial load
duke
parents:
diff changeset
1235 __ movq(to, Address(end_from, qword_count, Address::times_8, - 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
1236 __ movq(Address(end_to, qword_count, Address::times_8, - 0), to);
a61af66fc99e Initial load
duke
parents:
diff changeset
1237 __ BIND(L_copy_32_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1238 __ addq(qword_count, 4);
a61af66fc99e Initial load
duke
parents:
diff changeset
1239 __ jcc(Assembler::lessEqual, L_loop);
a61af66fc99e Initial load
duke
parents:
diff changeset
1240 __ subq(qword_count, 4);
a61af66fc99e Initial load
duke
parents:
diff changeset
1241 __ jcc(Assembler::less, L_copy_8_bytes); // Copy trailing qwords
a61af66fc99e Initial load
duke
parents:
diff changeset
1242 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1243
a61af66fc99e Initial load
duke
parents:
diff changeset
1244
a61af66fc99e Initial load
duke
parents:
diff changeset
1245 // Copy big chunks backward
a61af66fc99e Initial load
duke
parents:
diff changeset
1246 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1247 // Inputs:
a61af66fc99e Initial load
duke
parents:
diff changeset
1248 // from - source arrays address
a61af66fc99e Initial load
duke
parents:
diff changeset
1249 // dest - destination array address
a61af66fc99e Initial load
duke
parents:
diff changeset
1250 // qword_count - 64-bits element count
a61af66fc99e Initial load
duke
parents:
diff changeset
1251 // to - scratch
a61af66fc99e Initial load
duke
parents:
diff changeset
1252 // L_copy_32_bytes - entry label
a61af66fc99e Initial load
duke
parents:
diff changeset
1253 // L_copy_8_bytes - exit label
a61af66fc99e Initial load
duke
parents:
diff changeset
1254 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1255 void copy_32_bytes_backward(Register from, Register dest,
a61af66fc99e Initial load
duke
parents:
diff changeset
1256 Register qword_count, Register to,
a61af66fc99e Initial load
duke
parents:
diff changeset
1257 Label& L_copy_32_bytes, Label& L_copy_8_bytes) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1258 DEBUG_ONLY(__ stop("enter at entry label, not here"));
a61af66fc99e Initial load
duke
parents:
diff changeset
1259 Label L_loop;
a61af66fc99e Initial load
duke
parents:
diff changeset
1260 __ align(16);
a61af66fc99e Initial load
duke
parents:
diff changeset
1261 __ BIND(L_loop);
a61af66fc99e Initial load
duke
parents:
diff changeset
1262 __ movq(to, Address(from, qword_count, Address::times_8, 24));
a61af66fc99e Initial load
duke
parents:
diff changeset
1263 __ movq(Address(dest, qword_count, Address::times_8, 24), to);
a61af66fc99e Initial load
duke
parents:
diff changeset
1264 __ movq(to, Address(from, qword_count, Address::times_8, 16));
a61af66fc99e Initial load
duke
parents:
diff changeset
1265 __ movq(Address(dest, qword_count, Address::times_8, 16), to);
a61af66fc99e Initial load
duke
parents:
diff changeset
1266 __ movq(to, Address(from, qword_count, Address::times_8, 8));
a61af66fc99e Initial load
duke
parents:
diff changeset
1267 __ movq(Address(dest, qword_count, Address::times_8, 8), to);
a61af66fc99e Initial load
duke
parents:
diff changeset
1268 __ movq(to, Address(from, qword_count, Address::times_8, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
1269 __ movq(Address(dest, qword_count, Address::times_8, 0), to);
a61af66fc99e Initial load
duke
parents:
diff changeset
1270 __ BIND(L_copy_32_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1271 __ subq(qword_count, 4);
a61af66fc99e Initial load
duke
parents:
diff changeset
1272 __ jcc(Assembler::greaterEqual, L_loop);
a61af66fc99e Initial load
duke
parents:
diff changeset
1273 __ addq(qword_count, 4);
a61af66fc99e Initial load
duke
parents:
diff changeset
1274 __ jcc(Assembler::greater, L_copy_8_bytes); // Copy trailing qwords
a61af66fc99e Initial load
duke
parents:
diff changeset
1275 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1276
a61af66fc99e Initial load
duke
parents:
diff changeset
1277
a61af66fc99e Initial load
duke
parents:
diff changeset
1278 // Arguments:
a61af66fc99e Initial load
duke
parents:
diff changeset
1279 // aligned - true => Input and output aligned on a HeapWord == 8-byte boundary
a61af66fc99e Initial load
duke
parents:
diff changeset
1280 // ignored
a61af66fc99e Initial load
duke
parents:
diff changeset
1281 // name - stub name string
a61af66fc99e Initial load
duke
parents:
diff changeset
1282 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1283 // Inputs:
a61af66fc99e Initial load
duke
parents:
diff changeset
1284 // c_rarg0 - source array address
a61af66fc99e Initial load
duke
parents:
diff changeset
1285 // c_rarg1 - destination array address
a61af66fc99e Initial load
duke
parents:
diff changeset
1286 // c_rarg2 - element count, treated as ssize_t, can be zero
a61af66fc99e Initial load
duke
parents:
diff changeset
1287 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1288 // If 'from' and/or 'to' are aligned on 4-, 2-, or 1-byte boundaries,
a61af66fc99e Initial load
duke
parents:
diff changeset
1289 // we let the hardware handle it. The one to eight bytes within words,
a61af66fc99e Initial load
duke
parents:
diff changeset
1290 // dwords or qwords that span cache line boundaries will still be loaded
a61af66fc99e Initial load
duke
parents:
diff changeset
1291 // and stored atomically.
a61af66fc99e Initial load
duke
parents:
diff changeset
1292 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1293 // Side Effects:
a61af66fc99e Initial load
duke
parents:
diff changeset
1294 // disjoint_byte_copy_entry is set to the no-overlap entry point
a61af66fc99e Initial load
duke
parents:
diff changeset
1295 // used by generate_conjoint_byte_copy().
a61af66fc99e Initial load
duke
parents:
diff changeset
1296 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1297 address generate_disjoint_byte_copy(bool aligned, const char *name) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1298 __ align(CodeEntryAlignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
1299 StubCodeMark mark(this, "StubRoutines", name);
a61af66fc99e Initial load
duke
parents:
diff changeset
1300 address start = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
1301
a61af66fc99e Initial load
duke
parents:
diff changeset
1302 Label L_copy_32_bytes, L_copy_8_bytes, L_copy_4_bytes, L_copy_2_bytes;
a61af66fc99e Initial load
duke
parents:
diff changeset
1303 Label L_copy_byte, L_exit;
a61af66fc99e Initial load
duke
parents:
diff changeset
1304 const Register from = rdi; // source array address
a61af66fc99e Initial load
duke
parents:
diff changeset
1305 const Register to = rsi; // destination array address
a61af66fc99e Initial load
duke
parents:
diff changeset
1306 const Register count = rdx; // elements count
a61af66fc99e Initial load
duke
parents:
diff changeset
1307 const Register byte_count = rcx;
a61af66fc99e Initial load
duke
parents:
diff changeset
1308 const Register qword_count = count;
a61af66fc99e Initial load
duke
parents:
diff changeset
1309 const Register end_from = from; // source array end address
a61af66fc99e Initial load
duke
parents:
diff changeset
1310 const Register end_to = to; // destination array end address
a61af66fc99e Initial load
duke
parents:
diff changeset
1311 // End pointers are inclusive, and if count is not zero they point
a61af66fc99e Initial load
duke
parents:
diff changeset
1312 // to the last unit copied: end_to[0] := end_from[0]
a61af66fc99e Initial load
duke
parents:
diff changeset
1313
a61af66fc99e Initial load
duke
parents:
diff changeset
1314 __ enter(); // required for proper stackwalking of RuntimeStub frame
a61af66fc99e Initial load
duke
parents:
diff changeset
1315 assert_clean_int(c_rarg2, rax); // Make sure 'count' is clean int.
a61af66fc99e Initial load
duke
parents:
diff changeset
1316
a61af66fc99e Initial load
duke
parents:
diff changeset
1317 disjoint_byte_copy_entry = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
1318 BLOCK_COMMENT("Entry:");
a61af66fc99e Initial load
duke
parents:
diff changeset
1319 // caller can pass a 64-bit byte count here (from Unsafe.copyMemory)
a61af66fc99e Initial load
duke
parents:
diff changeset
1320
a61af66fc99e Initial load
duke
parents:
diff changeset
1321 setup_arg_regs(); // from => rdi, to => rsi, count => rdx
a61af66fc99e Initial load
duke
parents:
diff changeset
1322 // r9 and r10 may be used to save non-volatile registers
a61af66fc99e Initial load
duke
parents:
diff changeset
1323
a61af66fc99e Initial load
duke
parents:
diff changeset
1324 // 'from', 'to' and 'count' are now valid
a61af66fc99e Initial load
duke
parents:
diff changeset
1325 __ movq(byte_count, count);
a61af66fc99e Initial load
duke
parents:
diff changeset
1326 __ shrq(count, 3); // count => qword_count
a61af66fc99e Initial load
duke
parents:
diff changeset
1327
a61af66fc99e Initial load
duke
parents:
diff changeset
1328 // Copy from low to high addresses. Use 'to' as scratch.
a61af66fc99e Initial load
duke
parents:
diff changeset
1329 __ leaq(end_from, Address(from, qword_count, Address::times_8, -8));
a61af66fc99e Initial load
duke
parents:
diff changeset
1330 __ leaq(end_to, Address(to, qword_count, Address::times_8, -8));
a61af66fc99e Initial load
duke
parents:
diff changeset
1331 __ negq(qword_count); // make the count negative
a61af66fc99e Initial load
duke
parents:
diff changeset
1332 __ jmp(L_copy_32_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1333
a61af66fc99e Initial load
duke
parents:
diff changeset
1334 // Copy trailing qwords
a61af66fc99e Initial load
duke
parents:
diff changeset
1335 __ BIND(L_copy_8_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1336 __ movq(rax, Address(end_from, qword_count, Address::times_8, 8));
a61af66fc99e Initial load
duke
parents:
diff changeset
1337 __ movq(Address(end_to, qword_count, Address::times_8, 8), rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
1338 __ incrementq(qword_count);
a61af66fc99e Initial load
duke
parents:
diff changeset
1339 __ jcc(Assembler::notZero, L_copy_8_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1340
a61af66fc99e Initial load
duke
parents:
diff changeset
1341 // Check for and copy trailing dword
a61af66fc99e Initial load
duke
parents:
diff changeset
1342 __ BIND(L_copy_4_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1343 __ testq(byte_count, 4);
a61af66fc99e Initial load
duke
parents:
diff changeset
1344 __ jccb(Assembler::zero, L_copy_2_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1345 __ movl(rax, Address(end_from, 8));
a61af66fc99e Initial load
duke
parents:
diff changeset
1346 __ movl(Address(end_to, 8), rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
1347
a61af66fc99e Initial load
duke
parents:
diff changeset
1348 __ addq(end_from, 4);
a61af66fc99e Initial load
duke
parents:
diff changeset
1349 __ addq(end_to, 4);
a61af66fc99e Initial load
duke
parents:
diff changeset
1350
a61af66fc99e Initial load
duke
parents:
diff changeset
1351 // Check for and copy trailing word
a61af66fc99e Initial load
duke
parents:
diff changeset
1352 __ BIND(L_copy_2_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1353 __ testq(byte_count, 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
1354 __ jccb(Assembler::zero, L_copy_byte);
a61af66fc99e Initial load
duke
parents:
diff changeset
1355 __ movw(rax, Address(end_from, 8));
a61af66fc99e Initial load
duke
parents:
diff changeset
1356 __ movw(Address(end_to, 8), rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
1357
a61af66fc99e Initial load
duke
parents:
diff changeset
1358 __ addq(end_from, 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
1359 __ addq(end_to, 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
1360
a61af66fc99e Initial load
duke
parents:
diff changeset
1361 // Check for and copy trailing byte
a61af66fc99e Initial load
duke
parents:
diff changeset
1362 __ BIND(L_copy_byte);
a61af66fc99e Initial load
duke
parents:
diff changeset
1363 __ testq(byte_count, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1364 __ jccb(Assembler::zero, L_exit);
a61af66fc99e Initial load
duke
parents:
diff changeset
1365 __ movb(rax, Address(end_from, 8));
a61af66fc99e Initial load
duke
parents:
diff changeset
1366 __ movb(Address(end_to, 8), rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
1367
a61af66fc99e Initial load
duke
parents:
diff changeset
1368 __ BIND(L_exit);
a61af66fc99e Initial load
duke
parents:
diff changeset
1369 inc_counter_np(SharedRuntime::_jbyte_array_copy_ctr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1370 restore_arg_regs();
a61af66fc99e Initial load
duke
parents:
diff changeset
1371 __ xorq(rax, rax); // return 0
a61af66fc99e Initial load
duke
parents:
diff changeset
1372 __ leave(); // required for proper stackwalking of RuntimeStub frame
a61af66fc99e Initial load
duke
parents:
diff changeset
1373 __ ret(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1374
a61af66fc99e Initial load
duke
parents:
diff changeset
1375 // Copy in 32-bytes chunks
a61af66fc99e Initial load
duke
parents:
diff changeset
1376 copy_32_bytes_forward(end_from, end_to, qword_count, rax, L_copy_32_bytes, L_copy_8_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1377 __ jmp(L_copy_4_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1378
a61af66fc99e Initial load
duke
parents:
diff changeset
1379 return start;
a61af66fc99e Initial load
duke
parents:
diff changeset
1380 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1381
a61af66fc99e Initial load
duke
parents:
diff changeset
1382 // Arguments:
a61af66fc99e Initial load
duke
parents:
diff changeset
1383 // aligned - true => Input and output aligned on a HeapWord == 8-byte boundary
a61af66fc99e Initial load
duke
parents:
diff changeset
1384 // ignored
a61af66fc99e Initial load
duke
parents:
diff changeset
1385 // name - stub name string
a61af66fc99e Initial load
duke
parents:
diff changeset
1386 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1387 // Inputs:
a61af66fc99e Initial load
duke
parents:
diff changeset
1388 // c_rarg0 - source array address
a61af66fc99e Initial load
duke
parents:
diff changeset
1389 // c_rarg1 - destination array address
a61af66fc99e Initial load
duke
parents:
diff changeset
1390 // c_rarg2 - element count, treated as ssize_t, can be zero
a61af66fc99e Initial load
duke
parents:
diff changeset
1391 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1392 // If 'from' and/or 'to' are aligned on 4-, 2-, or 1-byte boundaries,
a61af66fc99e Initial load
duke
parents:
diff changeset
1393 // we let the hardware handle it. The one to eight bytes within words,
a61af66fc99e Initial load
duke
parents:
diff changeset
1394 // dwords or qwords that span cache line boundaries will still be loaded
a61af66fc99e Initial load
duke
parents:
diff changeset
1395 // and stored atomically.
a61af66fc99e Initial load
duke
parents:
diff changeset
1396 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1397 address generate_conjoint_byte_copy(bool aligned, const char *name) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1398 __ align(CodeEntryAlignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
1399 StubCodeMark mark(this, "StubRoutines", name);
a61af66fc99e Initial load
duke
parents:
diff changeset
1400 address start = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
1401
a61af66fc99e Initial load
duke
parents:
diff changeset
1402 Label L_copy_32_bytes, L_copy_8_bytes, L_copy_4_bytes, L_copy_2_bytes;
a61af66fc99e Initial load
duke
parents:
diff changeset
1403 const Register from = rdi; // source array address
a61af66fc99e Initial load
duke
parents:
diff changeset
1404 const Register to = rsi; // destination array address
a61af66fc99e Initial load
duke
parents:
diff changeset
1405 const Register count = rdx; // elements count
a61af66fc99e Initial load
duke
parents:
diff changeset
1406 const Register byte_count = rcx;
a61af66fc99e Initial load
duke
parents:
diff changeset
1407 const Register qword_count = count;
a61af66fc99e Initial load
duke
parents:
diff changeset
1408
a61af66fc99e Initial load
duke
parents:
diff changeset
1409 __ enter(); // required for proper stackwalking of RuntimeStub frame
a61af66fc99e Initial load
duke
parents:
diff changeset
1410 assert_clean_int(c_rarg2, rax); // Make sure 'count' is clean int.
a61af66fc99e Initial load
duke
parents:
diff changeset
1411
a61af66fc99e Initial load
duke
parents:
diff changeset
1412 byte_copy_entry = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
1413 BLOCK_COMMENT("Entry:");
a61af66fc99e Initial load
duke
parents:
diff changeset
1414 // caller can pass a 64-bit byte count here (from Unsafe.copyMemory)
a61af66fc99e Initial load
duke
parents:
diff changeset
1415
a61af66fc99e Initial load
duke
parents:
diff changeset
1416 array_overlap_test(disjoint_byte_copy_entry, Address::times_1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1417 setup_arg_regs(); // from => rdi, to => rsi, count => rdx
a61af66fc99e Initial load
duke
parents:
diff changeset
1418 // r9 and r10 may be used to save non-volatile registers
a61af66fc99e Initial load
duke
parents:
diff changeset
1419
a61af66fc99e Initial load
duke
parents:
diff changeset
1420 // 'from', 'to' and 'count' are now valid
a61af66fc99e Initial load
duke
parents:
diff changeset
1421 __ movq(byte_count, count);
a61af66fc99e Initial load
duke
parents:
diff changeset
1422 __ shrq(count, 3); // count => qword_count
a61af66fc99e Initial load
duke
parents:
diff changeset
1423
a61af66fc99e Initial load
duke
parents:
diff changeset
1424 // Copy from high to low addresses.
a61af66fc99e Initial load
duke
parents:
diff changeset
1425
a61af66fc99e Initial load
duke
parents:
diff changeset
1426 // Check for and copy trailing byte
a61af66fc99e Initial load
duke
parents:
diff changeset
1427 __ testq(byte_count, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1428 __ jcc(Assembler::zero, L_copy_2_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1429 __ movb(rax, Address(from, byte_count, Address::times_1, -1));
a61af66fc99e Initial load
duke
parents:
diff changeset
1430 __ movb(Address(to, byte_count, Address::times_1, -1), rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
1431 __ decrementq(byte_count); // Adjust for possible trailing word
a61af66fc99e Initial load
duke
parents:
diff changeset
1432
a61af66fc99e Initial load
duke
parents:
diff changeset
1433 // Check for and copy trailing word
a61af66fc99e Initial load
duke
parents:
diff changeset
1434 __ BIND(L_copy_2_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1435 __ testq(byte_count, 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
1436 __ jcc(Assembler::zero, L_copy_4_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1437 __ movw(rax, Address(from, byte_count, Address::times_1, -2));
a61af66fc99e Initial load
duke
parents:
diff changeset
1438 __ movw(Address(to, byte_count, Address::times_1, -2), rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
1439
a61af66fc99e Initial load
duke
parents:
diff changeset
1440 // Check for and copy trailing dword
a61af66fc99e Initial load
duke
parents:
diff changeset
1441 __ BIND(L_copy_4_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1442 __ testq(byte_count, 4);
a61af66fc99e Initial load
duke
parents:
diff changeset
1443 __ jcc(Assembler::zero, L_copy_32_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1444 __ movl(rax, Address(from, qword_count, Address::times_8));
a61af66fc99e Initial load
duke
parents:
diff changeset
1445 __ movl(Address(to, qword_count, Address::times_8), rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
1446 __ jmp(L_copy_32_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1447
a61af66fc99e Initial load
duke
parents:
diff changeset
1448 // Copy trailing qwords
a61af66fc99e Initial load
duke
parents:
diff changeset
1449 __ BIND(L_copy_8_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1450 __ movq(rax, Address(from, qword_count, Address::times_8, -8));
a61af66fc99e Initial load
duke
parents:
diff changeset
1451 __ movq(Address(to, qword_count, Address::times_8, -8), rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
1452 __ decrementq(qword_count);
a61af66fc99e Initial load
duke
parents:
diff changeset
1453 __ jcc(Assembler::notZero, L_copy_8_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1454
a61af66fc99e Initial load
duke
parents:
diff changeset
1455 inc_counter_np(SharedRuntime::_jbyte_array_copy_ctr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1456 restore_arg_regs();
a61af66fc99e Initial load
duke
parents:
diff changeset
1457 __ xorq(rax, rax); // return 0
a61af66fc99e Initial load
duke
parents:
diff changeset
1458 __ leave(); // required for proper stackwalking of RuntimeStub frame
a61af66fc99e Initial load
duke
parents:
diff changeset
1459 __ ret(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1460
a61af66fc99e Initial load
duke
parents:
diff changeset
1461 // Copy in 32-bytes chunks
a61af66fc99e Initial load
duke
parents:
diff changeset
1462 copy_32_bytes_backward(from, to, qword_count, rax, L_copy_32_bytes, L_copy_8_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1463
a61af66fc99e Initial load
duke
parents:
diff changeset
1464 inc_counter_np(SharedRuntime::_jbyte_array_copy_ctr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1465 restore_arg_regs();
a61af66fc99e Initial load
duke
parents:
diff changeset
1466 __ xorq(rax, rax); // return 0
a61af66fc99e Initial load
duke
parents:
diff changeset
1467 __ leave(); // required for proper stackwalking of RuntimeStub frame
a61af66fc99e Initial load
duke
parents:
diff changeset
1468 __ ret(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1469
a61af66fc99e Initial load
duke
parents:
diff changeset
1470 return start;
a61af66fc99e Initial load
duke
parents:
diff changeset
1471 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1472
a61af66fc99e Initial load
duke
parents:
diff changeset
1473 // Arguments:
a61af66fc99e Initial load
duke
parents:
diff changeset
1474 // aligned - true => Input and output aligned on a HeapWord == 8-byte boundary
a61af66fc99e Initial load
duke
parents:
diff changeset
1475 // ignored
a61af66fc99e Initial load
duke
parents:
diff changeset
1476 // name - stub name string
a61af66fc99e Initial load
duke
parents:
diff changeset
1477 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1478 // Inputs:
a61af66fc99e Initial load
duke
parents:
diff changeset
1479 // c_rarg0 - source array address
a61af66fc99e Initial load
duke
parents:
diff changeset
1480 // c_rarg1 - destination array address
a61af66fc99e Initial load
duke
parents:
diff changeset
1481 // c_rarg2 - element count, treated as ssize_t, can be zero
a61af66fc99e Initial load
duke
parents:
diff changeset
1482 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1483 // If 'from' and/or 'to' are aligned on 4- or 2-byte boundaries, we
a61af66fc99e Initial load
duke
parents:
diff changeset
1484 // let the hardware handle it. The two or four words within dwords
a61af66fc99e Initial load
duke
parents:
diff changeset
1485 // or qwords that span cache line boundaries will still be loaded
a61af66fc99e Initial load
duke
parents:
diff changeset
1486 // and stored atomically.
a61af66fc99e Initial load
duke
parents:
diff changeset
1487 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1488 // Side Effects:
a61af66fc99e Initial load
duke
parents:
diff changeset
1489 // disjoint_short_copy_entry is set to the no-overlap entry point
a61af66fc99e Initial load
duke
parents:
diff changeset
1490 // used by generate_conjoint_short_copy().
a61af66fc99e Initial load
duke
parents:
diff changeset
1491 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1492 address generate_disjoint_short_copy(bool aligned, const char *name) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1493 __ align(CodeEntryAlignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
1494 StubCodeMark mark(this, "StubRoutines", name);
a61af66fc99e Initial load
duke
parents:
diff changeset
1495 address start = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
1496
a61af66fc99e Initial load
duke
parents:
diff changeset
1497 Label L_copy_32_bytes, L_copy_8_bytes, L_copy_4_bytes,L_copy_2_bytes,L_exit;
a61af66fc99e Initial load
duke
parents:
diff changeset
1498 const Register from = rdi; // source array address
a61af66fc99e Initial load
duke
parents:
diff changeset
1499 const Register to = rsi; // destination array address
a61af66fc99e Initial load
duke
parents:
diff changeset
1500 const Register count = rdx; // elements count
a61af66fc99e Initial load
duke
parents:
diff changeset
1501 const Register word_count = rcx;
a61af66fc99e Initial load
duke
parents:
diff changeset
1502 const Register qword_count = count;
a61af66fc99e Initial load
duke
parents:
diff changeset
1503 const Register end_from = from; // source array end address
a61af66fc99e Initial load
duke
parents:
diff changeset
1504 const Register end_to = to; // destination array end address
a61af66fc99e Initial load
duke
parents:
diff changeset
1505 // End pointers are inclusive, and if count is not zero they point
a61af66fc99e Initial load
duke
parents:
diff changeset
1506 // to the last unit copied: end_to[0] := end_from[0]
a61af66fc99e Initial load
duke
parents:
diff changeset
1507
a61af66fc99e Initial load
duke
parents:
diff changeset
1508 __ enter(); // required for proper stackwalking of RuntimeStub frame
a61af66fc99e Initial load
duke
parents:
diff changeset
1509 assert_clean_int(c_rarg2, rax); // Make sure 'count' is clean int.
a61af66fc99e Initial load
duke
parents:
diff changeset
1510
a61af66fc99e Initial load
duke
parents:
diff changeset
1511 disjoint_short_copy_entry = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
1512 BLOCK_COMMENT("Entry:");
a61af66fc99e Initial load
duke
parents:
diff changeset
1513 // caller can pass a 64-bit byte count here (from Unsafe.copyMemory)
a61af66fc99e Initial load
duke
parents:
diff changeset
1514
a61af66fc99e Initial load
duke
parents:
diff changeset
1515 setup_arg_regs(); // from => rdi, to => rsi, count => rdx
a61af66fc99e Initial load
duke
parents:
diff changeset
1516 // r9 and r10 may be used to save non-volatile registers
a61af66fc99e Initial load
duke
parents:
diff changeset
1517
a61af66fc99e Initial load
duke
parents:
diff changeset
1518 // 'from', 'to' and 'count' are now valid
a61af66fc99e Initial load
duke
parents:
diff changeset
1519 __ movq(word_count, count);
a61af66fc99e Initial load
duke
parents:
diff changeset
1520 __ shrq(count, 2); // count => qword_count
a61af66fc99e Initial load
duke
parents:
diff changeset
1521
a61af66fc99e Initial load
duke
parents:
diff changeset
1522 // Copy from low to high addresses. Use 'to' as scratch.
a61af66fc99e Initial load
duke
parents:
diff changeset
1523 __ leaq(end_from, Address(from, qword_count, Address::times_8, -8));
a61af66fc99e Initial load
duke
parents:
diff changeset
1524 __ leaq(end_to, Address(to, qword_count, Address::times_8, -8));
a61af66fc99e Initial load
duke
parents:
diff changeset
1525 __ negq(qword_count);
a61af66fc99e Initial load
duke
parents:
diff changeset
1526 __ jmp(L_copy_32_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1527
a61af66fc99e Initial load
duke
parents:
diff changeset
1528 // Copy trailing qwords
a61af66fc99e Initial load
duke
parents:
diff changeset
1529 __ BIND(L_copy_8_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1530 __ movq(rax, Address(end_from, qword_count, Address::times_8, 8));
a61af66fc99e Initial load
duke
parents:
diff changeset
1531 __ movq(Address(end_to, qword_count, Address::times_8, 8), rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
1532 __ incrementq(qword_count);
a61af66fc99e Initial load
duke
parents:
diff changeset
1533 __ jcc(Assembler::notZero, L_copy_8_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1534
a61af66fc99e Initial load
duke
parents:
diff changeset
1535 // Original 'dest' is trashed, so we can't use it as a
a61af66fc99e Initial load
duke
parents:
diff changeset
1536 // base register for a possible trailing word copy
a61af66fc99e Initial load
duke
parents:
diff changeset
1537
a61af66fc99e Initial load
duke
parents:
diff changeset
1538 // Check for and copy trailing dword
a61af66fc99e Initial load
duke
parents:
diff changeset
1539 __ BIND(L_copy_4_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1540 __ testq(word_count, 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
1541 __ jccb(Assembler::zero, L_copy_2_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1542 __ movl(rax, Address(end_from, 8));
a61af66fc99e Initial load
duke
parents:
diff changeset
1543 __ movl(Address(end_to, 8), rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
1544
a61af66fc99e Initial load
duke
parents:
diff changeset
1545 __ addq(end_from, 4);
a61af66fc99e Initial load
duke
parents:
diff changeset
1546 __ addq(end_to, 4);
a61af66fc99e Initial load
duke
parents:
diff changeset
1547
a61af66fc99e Initial load
duke
parents:
diff changeset
1548 // Check for and copy trailing word
a61af66fc99e Initial load
duke
parents:
diff changeset
1549 __ BIND(L_copy_2_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1550 __ testq(word_count, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1551 __ jccb(Assembler::zero, L_exit);
a61af66fc99e Initial load
duke
parents:
diff changeset
1552 __ movw(rax, Address(end_from, 8));
a61af66fc99e Initial load
duke
parents:
diff changeset
1553 __ movw(Address(end_to, 8), rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
1554
a61af66fc99e Initial load
duke
parents:
diff changeset
1555 __ BIND(L_exit);
a61af66fc99e Initial load
duke
parents:
diff changeset
1556 inc_counter_np(SharedRuntime::_jshort_array_copy_ctr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1557 restore_arg_regs();
a61af66fc99e Initial load
duke
parents:
diff changeset
1558 __ xorq(rax, rax); // return 0
a61af66fc99e Initial load
duke
parents:
diff changeset
1559 __ leave(); // required for proper stackwalking of RuntimeStub frame
a61af66fc99e Initial load
duke
parents:
diff changeset
1560 __ ret(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1561
a61af66fc99e Initial load
duke
parents:
diff changeset
1562 // Copy in 32-bytes chunks
a61af66fc99e Initial load
duke
parents:
diff changeset
1563 copy_32_bytes_forward(end_from, end_to, qword_count, rax, L_copy_32_bytes, L_copy_8_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1564 __ jmp(L_copy_4_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1565
a61af66fc99e Initial load
duke
parents:
diff changeset
1566 return start;
a61af66fc99e Initial load
duke
parents:
diff changeset
1567 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1568
a61af66fc99e Initial load
duke
parents:
diff changeset
1569 // Arguments:
a61af66fc99e Initial load
duke
parents:
diff changeset
1570 // aligned - true => Input and output aligned on a HeapWord == 8-byte boundary
a61af66fc99e Initial load
duke
parents:
diff changeset
1571 // ignored
a61af66fc99e Initial load
duke
parents:
diff changeset
1572 // name - stub name string
a61af66fc99e Initial load
duke
parents:
diff changeset
1573 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1574 // Inputs:
a61af66fc99e Initial load
duke
parents:
diff changeset
1575 // c_rarg0 - source array address
a61af66fc99e Initial load
duke
parents:
diff changeset
1576 // c_rarg1 - destination array address
a61af66fc99e Initial load
duke
parents:
diff changeset
1577 // c_rarg2 - element count, treated as ssize_t, can be zero
a61af66fc99e Initial load
duke
parents:
diff changeset
1578 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1579 // If 'from' and/or 'to' are aligned on 4- or 2-byte boundaries, we
a61af66fc99e Initial load
duke
parents:
diff changeset
1580 // let the hardware handle it. The two or four words within dwords
a61af66fc99e Initial load
duke
parents:
diff changeset
1581 // or qwords that span cache line boundaries will still be loaded
a61af66fc99e Initial load
duke
parents:
diff changeset
1582 // and stored atomically.
a61af66fc99e Initial load
duke
parents:
diff changeset
1583 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1584 address generate_conjoint_short_copy(bool aligned, const char *name) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1585 __ align(CodeEntryAlignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
1586 StubCodeMark mark(this, "StubRoutines", name);
a61af66fc99e Initial load
duke
parents:
diff changeset
1587 address start = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
1588
a61af66fc99e Initial load
duke
parents:
diff changeset
1589 Label L_copy_32_bytes, L_copy_8_bytes, L_copy_4_bytes;
a61af66fc99e Initial load
duke
parents:
diff changeset
1590 const Register from = rdi; // source array address
a61af66fc99e Initial load
duke
parents:
diff changeset
1591 const Register to = rsi; // destination array address
a61af66fc99e Initial load
duke
parents:
diff changeset
1592 const Register count = rdx; // elements count
a61af66fc99e Initial load
duke
parents:
diff changeset
1593 const Register word_count = rcx;
a61af66fc99e Initial load
duke
parents:
diff changeset
1594 const Register qword_count = count;
a61af66fc99e Initial load
duke
parents:
diff changeset
1595
a61af66fc99e Initial load
duke
parents:
diff changeset
1596 __ enter(); // required for proper stackwalking of RuntimeStub frame
a61af66fc99e Initial load
duke
parents:
diff changeset
1597 assert_clean_int(c_rarg2, rax); // Make sure 'count' is clean int.
a61af66fc99e Initial load
duke
parents:
diff changeset
1598
a61af66fc99e Initial load
duke
parents:
diff changeset
1599 short_copy_entry = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
1600 BLOCK_COMMENT("Entry:");
a61af66fc99e Initial load
duke
parents:
diff changeset
1601 // caller can pass a 64-bit byte count here (from Unsafe.copyMemory)
a61af66fc99e Initial load
duke
parents:
diff changeset
1602
a61af66fc99e Initial load
duke
parents:
diff changeset
1603 array_overlap_test(disjoint_short_copy_entry, Address::times_2);
a61af66fc99e Initial load
duke
parents:
diff changeset
1604 setup_arg_regs(); // from => rdi, to => rsi, count => rdx
a61af66fc99e Initial load
duke
parents:
diff changeset
1605 // r9 and r10 may be used to save non-volatile registers
a61af66fc99e Initial load
duke
parents:
diff changeset
1606
a61af66fc99e Initial load
duke
parents:
diff changeset
1607 // 'from', 'to' and 'count' are now valid
a61af66fc99e Initial load
duke
parents:
diff changeset
1608 __ movq(word_count, count);
a61af66fc99e Initial load
duke
parents:
diff changeset
1609 __ shrq(count, 2); // count => qword_count
a61af66fc99e Initial load
duke
parents:
diff changeset
1610
a61af66fc99e Initial load
duke
parents:
diff changeset
1611 // Copy from high to low addresses. Use 'to' as scratch.
a61af66fc99e Initial load
duke
parents:
diff changeset
1612
a61af66fc99e Initial load
duke
parents:
diff changeset
1613 // Check for and copy trailing word
a61af66fc99e Initial load
duke
parents:
diff changeset
1614 __ testq(word_count, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1615 __ jccb(Assembler::zero, L_copy_4_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1616 __ movw(rax, Address(from, word_count, Address::times_2, -2));
a61af66fc99e Initial load
duke
parents:
diff changeset
1617 __ movw(Address(to, word_count, Address::times_2, -2), rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
1618
a61af66fc99e Initial load
duke
parents:
diff changeset
1619 // Check for and copy trailing dword
a61af66fc99e Initial load
duke
parents:
diff changeset
1620 __ BIND(L_copy_4_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1621 __ testq(word_count, 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
1622 __ jcc(Assembler::zero, L_copy_32_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1623 __ movl(rax, Address(from, qword_count, Address::times_8));
a61af66fc99e Initial load
duke
parents:
diff changeset
1624 __ movl(Address(to, qword_count, Address::times_8), rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
1625 __ jmp(L_copy_32_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1626
a61af66fc99e Initial load
duke
parents:
diff changeset
1627 // Copy trailing qwords
a61af66fc99e Initial load
duke
parents:
diff changeset
1628 __ BIND(L_copy_8_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1629 __ movq(rax, Address(from, qword_count, Address::times_8, -8));
a61af66fc99e Initial load
duke
parents:
diff changeset
1630 __ movq(Address(to, qword_count, Address::times_8, -8), rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
1631 __ decrementq(qword_count);
a61af66fc99e Initial load
duke
parents:
diff changeset
1632 __ jcc(Assembler::notZero, L_copy_8_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1633
a61af66fc99e Initial load
duke
parents:
diff changeset
1634 inc_counter_np(SharedRuntime::_jshort_array_copy_ctr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1635 restore_arg_regs();
a61af66fc99e Initial load
duke
parents:
diff changeset
1636 __ xorq(rax, rax); // return 0
a61af66fc99e Initial load
duke
parents:
diff changeset
1637 __ leave(); // required for proper stackwalking of RuntimeStub frame
a61af66fc99e Initial load
duke
parents:
diff changeset
1638 __ ret(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1639
a61af66fc99e Initial load
duke
parents:
diff changeset
1640 // Copy in 32-bytes chunks
a61af66fc99e Initial load
duke
parents:
diff changeset
1641 copy_32_bytes_backward(from, to, qword_count, rax, L_copy_32_bytes, L_copy_8_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1642
a61af66fc99e Initial load
duke
parents:
diff changeset
1643 inc_counter_np(SharedRuntime::_jshort_array_copy_ctr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1644 restore_arg_regs();
a61af66fc99e Initial load
duke
parents:
diff changeset
1645 __ xorq(rax, rax); // return 0
a61af66fc99e Initial load
duke
parents:
diff changeset
1646 __ leave(); // required for proper stackwalking of RuntimeStub frame
a61af66fc99e Initial load
duke
parents:
diff changeset
1647 __ ret(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1648
a61af66fc99e Initial load
duke
parents:
diff changeset
1649 return start;
a61af66fc99e Initial load
duke
parents:
diff changeset
1650 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1651
a61af66fc99e Initial load
duke
parents:
diff changeset
1652 // Arguments:
a61af66fc99e Initial load
duke
parents:
diff changeset
1653 // aligned - true => Input and output aligned on a HeapWord == 8-byte boundary
a61af66fc99e Initial load
duke
parents:
diff changeset
1654 // ignored
a61af66fc99e Initial load
duke
parents:
diff changeset
1655 // name - stub name string
a61af66fc99e Initial load
duke
parents:
diff changeset
1656 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1657 // Inputs:
a61af66fc99e Initial load
duke
parents:
diff changeset
1658 // c_rarg0 - source array address
a61af66fc99e Initial load
duke
parents:
diff changeset
1659 // c_rarg1 - destination array address
a61af66fc99e Initial load
duke
parents:
diff changeset
1660 // c_rarg2 - element count, treated as ssize_t, can be zero
a61af66fc99e Initial load
duke
parents:
diff changeset
1661 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1662 // If 'from' and/or 'to' are aligned on 4-byte boundaries, we let
a61af66fc99e Initial load
duke
parents:
diff changeset
1663 // the hardware handle it. The two dwords within qwords that span
a61af66fc99e Initial load
duke
parents:
diff changeset
1664 // cache line boundaries will still be loaded and stored atomicly.
a61af66fc99e Initial load
duke
parents:
diff changeset
1665 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1666 // Side Effects:
a61af66fc99e Initial load
duke
parents:
diff changeset
1667 // disjoint_int_copy_entry is set to the no-overlap entry point
a61af66fc99e Initial load
duke
parents:
diff changeset
1668 // used by generate_conjoint_int_copy().
a61af66fc99e Initial load
duke
parents:
diff changeset
1669 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1670 address generate_disjoint_int_copy(bool aligned, const char *name) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1671 __ align(CodeEntryAlignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
1672 StubCodeMark mark(this, "StubRoutines", name);
a61af66fc99e Initial load
duke
parents:
diff changeset
1673 address start = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
1674
a61af66fc99e Initial load
duke
parents:
diff changeset
1675 Label L_copy_32_bytes, L_copy_8_bytes, L_copy_4_bytes, L_exit;
a61af66fc99e Initial load
duke
parents:
diff changeset
1676 const Register from = rdi; // source array address
a61af66fc99e Initial load
duke
parents:
diff changeset
1677 const Register to = rsi; // destination array address
a61af66fc99e Initial load
duke
parents:
diff changeset
1678 const Register count = rdx; // elements count
a61af66fc99e Initial load
duke
parents:
diff changeset
1679 const Register dword_count = rcx;
a61af66fc99e Initial load
duke
parents:
diff changeset
1680 const Register qword_count = count;
a61af66fc99e Initial load
duke
parents:
diff changeset
1681 const Register end_from = from; // source array end address
a61af66fc99e Initial load
duke
parents:
diff changeset
1682 const Register end_to = to; // destination array end address
a61af66fc99e Initial load
duke
parents:
diff changeset
1683 // End pointers are inclusive, and if count is not zero they point
a61af66fc99e Initial load
duke
parents:
diff changeset
1684 // to the last unit copied: end_to[0] := end_from[0]
a61af66fc99e Initial load
duke
parents:
diff changeset
1685
a61af66fc99e Initial load
duke
parents:
diff changeset
1686 __ enter(); // required for proper stackwalking of RuntimeStub frame
a61af66fc99e Initial load
duke
parents:
diff changeset
1687 assert_clean_int(c_rarg2, rax); // Make sure 'count' is clean int.
a61af66fc99e Initial load
duke
parents:
diff changeset
1688
a61af66fc99e Initial load
duke
parents:
diff changeset
1689 disjoint_int_copy_entry = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
1690 BLOCK_COMMENT("Entry:");
a61af66fc99e Initial load
duke
parents:
diff changeset
1691 // caller can pass a 64-bit byte count here (from Unsafe.copyMemory)
a61af66fc99e Initial load
duke
parents:
diff changeset
1692
a61af66fc99e Initial load
duke
parents:
diff changeset
1693 setup_arg_regs(); // from => rdi, to => rsi, count => rdx
a61af66fc99e Initial load
duke
parents:
diff changeset
1694 // r9 and r10 may be used to save non-volatile registers
a61af66fc99e Initial load
duke
parents:
diff changeset
1695
a61af66fc99e Initial load
duke
parents:
diff changeset
1696 // 'from', 'to' and 'count' are now valid
a61af66fc99e Initial load
duke
parents:
diff changeset
1697 __ movq(dword_count, count);
a61af66fc99e Initial load
duke
parents:
diff changeset
1698 __ shrq(count, 1); // count => qword_count
a61af66fc99e Initial load
duke
parents:
diff changeset
1699
a61af66fc99e Initial load
duke
parents:
diff changeset
1700 // Copy from low to high addresses. Use 'to' as scratch.
a61af66fc99e Initial load
duke
parents:
diff changeset
1701 __ leaq(end_from, Address(from, qword_count, Address::times_8, -8));
a61af66fc99e Initial load
duke
parents:
diff changeset
1702 __ leaq(end_to, Address(to, qword_count, Address::times_8, -8));
a61af66fc99e Initial load
duke
parents:
diff changeset
1703 __ negq(qword_count);
a61af66fc99e Initial load
duke
parents:
diff changeset
1704 __ jmp(L_copy_32_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1705
a61af66fc99e Initial load
duke
parents:
diff changeset
1706 // Copy trailing qwords
a61af66fc99e Initial load
duke
parents:
diff changeset
1707 __ BIND(L_copy_8_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1708 __ movq(rax, Address(end_from, qword_count, Address::times_8, 8));
a61af66fc99e Initial load
duke
parents:
diff changeset
1709 __ movq(Address(end_to, qword_count, Address::times_8, 8), rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
1710 __ incrementq(qword_count);
a61af66fc99e Initial load
duke
parents:
diff changeset
1711 __ jcc(Assembler::notZero, L_copy_8_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1712
a61af66fc99e Initial load
duke
parents:
diff changeset
1713 // Check for and copy trailing dword
a61af66fc99e Initial load
duke
parents:
diff changeset
1714 __ BIND(L_copy_4_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1715 __ testq(dword_count, 1); // Only byte test since the value is 0 or 1
a61af66fc99e Initial load
duke
parents:
diff changeset
1716 __ jccb(Assembler::zero, L_exit);
a61af66fc99e Initial load
duke
parents:
diff changeset
1717 __ movl(rax, Address(end_from, 8));
a61af66fc99e Initial load
duke
parents:
diff changeset
1718 __ movl(Address(end_to, 8), rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
1719
a61af66fc99e Initial load
duke
parents:
diff changeset
1720 __ BIND(L_exit);
a61af66fc99e Initial load
duke
parents:
diff changeset
1721 inc_counter_np(SharedRuntime::_jint_array_copy_ctr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1722 restore_arg_regs();
a61af66fc99e Initial load
duke
parents:
diff changeset
1723 __ xorq(rax, rax); // return 0
a61af66fc99e Initial load
duke
parents:
diff changeset
1724 __ leave(); // required for proper stackwalking of RuntimeStub frame
a61af66fc99e Initial load
duke
parents:
diff changeset
1725 __ ret(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1726
a61af66fc99e Initial load
duke
parents:
diff changeset
1727 // Copy 32-bytes chunks
a61af66fc99e Initial load
duke
parents:
diff changeset
1728 copy_32_bytes_forward(end_from, end_to, qword_count, rax, L_copy_32_bytes, L_copy_8_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1729 __ jmp(L_copy_4_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1730
a61af66fc99e Initial load
duke
parents:
diff changeset
1731 return start;
a61af66fc99e Initial load
duke
parents:
diff changeset
1732 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1733
a61af66fc99e Initial load
duke
parents:
diff changeset
1734 // Arguments:
a61af66fc99e Initial load
duke
parents:
diff changeset
1735 // aligned - true => Input and output aligned on a HeapWord == 8-byte boundary
a61af66fc99e Initial load
duke
parents:
diff changeset
1736 // ignored
a61af66fc99e Initial load
duke
parents:
diff changeset
1737 // name - stub name string
a61af66fc99e Initial load
duke
parents:
diff changeset
1738 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1739 // Inputs:
a61af66fc99e Initial load
duke
parents:
diff changeset
1740 // c_rarg0 - source array address
a61af66fc99e Initial load
duke
parents:
diff changeset
1741 // c_rarg1 - destination array address
a61af66fc99e Initial load
duke
parents:
diff changeset
1742 // c_rarg2 - element count, treated as ssize_t, can be zero
a61af66fc99e Initial load
duke
parents:
diff changeset
1743 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1744 // If 'from' and/or 'to' are aligned on 4-byte boundaries, we let
a61af66fc99e Initial load
duke
parents:
diff changeset
1745 // the hardware handle it. The two dwords within qwords that span
a61af66fc99e Initial load
duke
parents:
diff changeset
1746 // cache line boundaries will still be loaded and stored atomicly.
a61af66fc99e Initial load
duke
parents:
diff changeset
1747 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1748 address generate_conjoint_int_copy(bool aligned, const char *name) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1749 __ align(CodeEntryAlignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
1750 StubCodeMark mark(this, "StubRoutines", name);
a61af66fc99e Initial load
duke
parents:
diff changeset
1751 address start = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
1752
a61af66fc99e Initial load
duke
parents:
diff changeset
1753 Label L_copy_32_bytes, L_copy_8_bytes, L_copy_2_bytes;
a61af66fc99e Initial load
duke
parents:
diff changeset
1754 const Register from = rdi; // source array address
a61af66fc99e Initial load
duke
parents:
diff changeset
1755 const Register to = rsi; // destination array address
a61af66fc99e Initial load
duke
parents:
diff changeset
1756 const Register count = rdx; // elements count
a61af66fc99e Initial load
duke
parents:
diff changeset
1757 const Register dword_count = rcx;
a61af66fc99e Initial load
duke
parents:
diff changeset
1758 const Register qword_count = count;
a61af66fc99e Initial load
duke
parents:
diff changeset
1759
a61af66fc99e Initial load
duke
parents:
diff changeset
1760 __ enter(); // required for proper stackwalking of RuntimeStub frame
a61af66fc99e Initial load
duke
parents:
diff changeset
1761 assert_clean_int(c_rarg2, rax); // Make sure 'count' is clean int.
a61af66fc99e Initial load
duke
parents:
diff changeset
1762
a61af66fc99e Initial load
duke
parents:
diff changeset
1763 int_copy_entry = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
1764 BLOCK_COMMENT("Entry:");
a61af66fc99e Initial load
duke
parents:
diff changeset
1765 // caller can pass a 64-bit byte count here (from Unsafe.copyMemory)
a61af66fc99e Initial load
duke
parents:
diff changeset
1766
a61af66fc99e Initial load
duke
parents:
diff changeset
1767 array_overlap_test(disjoint_int_copy_entry, Address::times_4);
a61af66fc99e Initial load
duke
parents:
diff changeset
1768 setup_arg_regs(); // from => rdi, to => rsi, count => rdx
a61af66fc99e Initial load
duke
parents:
diff changeset
1769 // r9 and r10 may be used to save non-volatile registers
a61af66fc99e Initial load
duke
parents:
diff changeset
1770
a61af66fc99e Initial load
duke
parents:
diff changeset
1771 // 'from', 'to' and 'count' are now valid
a61af66fc99e Initial load
duke
parents:
diff changeset
1772 __ movq(dword_count, count);
a61af66fc99e Initial load
duke
parents:
diff changeset
1773 __ shrq(count, 1); // count => qword_count
a61af66fc99e Initial load
duke
parents:
diff changeset
1774
a61af66fc99e Initial load
duke
parents:
diff changeset
1775 // Copy from high to low addresses. Use 'to' as scratch.
a61af66fc99e Initial load
duke
parents:
diff changeset
1776
a61af66fc99e Initial load
duke
parents:
diff changeset
1777 // Check for and copy trailing dword
a61af66fc99e Initial load
duke
parents:
diff changeset
1778 __ testq(dword_count, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1779 __ jcc(Assembler::zero, L_copy_32_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1780 __ movl(rax, Address(from, dword_count, Address::times_4, -4));
a61af66fc99e Initial load
duke
parents:
diff changeset
1781 __ movl(Address(to, dword_count, Address::times_4, -4), rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
1782 __ jmp(L_copy_32_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1783
a61af66fc99e Initial load
duke
parents:
diff changeset
1784 // Copy trailing qwords
a61af66fc99e Initial load
duke
parents:
diff changeset
1785 __ BIND(L_copy_8_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1786 __ movq(rax, Address(from, qword_count, Address::times_8, -8));
a61af66fc99e Initial load
duke
parents:
diff changeset
1787 __ movq(Address(to, qword_count, Address::times_8, -8), rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
1788 __ decrementq(qword_count);
a61af66fc99e Initial load
duke
parents:
diff changeset
1789 __ jcc(Assembler::notZero, L_copy_8_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1790
a61af66fc99e Initial load
duke
parents:
diff changeset
1791 inc_counter_np(SharedRuntime::_jint_array_copy_ctr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1792 restore_arg_regs();
a61af66fc99e Initial load
duke
parents:
diff changeset
1793 __ xorq(rax, rax); // return 0
a61af66fc99e Initial load
duke
parents:
diff changeset
1794 __ leave(); // required for proper stackwalking of RuntimeStub frame
a61af66fc99e Initial load
duke
parents:
diff changeset
1795 __ ret(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1796
a61af66fc99e Initial load
duke
parents:
diff changeset
1797 // Copy in 32-bytes chunks
a61af66fc99e Initial load
duke
parents:
diff changeset
1798 copy_32_bytes_backward(from, to, qword_count, rax, L_copy_32_bytes, L_copy_8_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1799
a61af66fc99e Initial load
duke
parents:
diff changeset
1800 inc_counter_np(SharedRuntime::_jint_array_copy_ctr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1801 restore_arg_regs();
a61af66fc99e Initial load
duke
parents:
diff changeset
1802 __ xorq(rax, rax); // return 0
a61af66fc99e Initial load
duke
parents:
diff changeset
1803 __ leave(); // required for proper stackwalking of RuntimeStub frame
a61af66fc99e Initial load
duke
parents:
diff changeset
1804 __ ret(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1805
a61af66fc99e Initial load
duke
parents:
diff changeset
1806 return start;
a61af66fc99e Initial load
duke
parents:
diff changeset
1807 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1808
a61af66fc99e Initial load
duke
parents:
diff changeset
1809 // Arguments:
a61af66fc99e Initial load
duke
parents:
diff changeset
1810 // aligned - true => Input and output aligned on a HeapWord boundary == 8 bytes
a61af66fc99e Initial load
duke
parents:
diff changeset
1811 // ignored
a61af66fc99e Initial load
duke
parents:
diff changeset
1812 // is_oop - true => oop array, so generate store check code
a61af66fc99e Initial load
duke
parents:
diff changeset
1813 // name - stub name string
a61af66fc99e Initial load
duke
parents:
diff changeset
1814 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1815 // Inputs:
a61af66fc99e Initial load
duke
parents:
diff changeset
1816 // c_rarg0 - source array address
a61af66fc99e Initial load
duke
parents:
diff changeset
1817 // c_rarg1 - destination array address
a61af66fc99e Initial load
duke
parents:
diff changeset
1818 // c_rarg2 - element count, treated as ssize_t, can be zero
a61af66fc99e Initial load
duke
parents:
diff changeset
1819 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1820 // Side Effects:
a61af66fc99e Initial load
duke
parents:
diff changeset
1821 // disjoint_oop_copy_entry or disjoint_long_copy_entry is set to the
a61af66fc99e Initial load
duke
parents:
diff changeset
1822 // no-overlap entry point used by generate_conjoint_long_oop_copy().
a61af66fc99e Initial load
duke
parents:
diff changeset
1823 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1824 address generate_disjoint_long_oop_copy(bool aligned, bool is_oop, const char *name) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1825 __ align(CodeEntryAlignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
1826 StubCodeMark mark(this, "StubRoutines", name);
a61af66fc99e Initial load
duke
parents:
diff changeset
1827 address start = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
1828
a61af66fc99e Initial load
duke
parents:
diff changeset
1829 Label L_copy_32_bytes, L_copy_8_bytes, L_exit;
a61af66fc99e Initial load
duke
parents:
diff changeset
1830 const Register from = rdi; // source array address
a61af66fc99e Initial load
duke
parents:
diff changeset
1831 const Register to = rsi; // destination array address
a61af66fc99e Initial load
duke
parents:
diff changeset
1832 const Register qword_count = rdx; // elements count
a61af66fc99e Initial load
duke
parents:
diff changeset
1833 const Register end_from = from; // source array end address
a61af66fc99e Initial load
duke
parents:
diff changeset
1834 const Register end_to = rcx; // destination array end address
a61af66fc99e Initial load
duke
parents:
diff changeset
1835 const Register saved_to = to;
a61af66fc99e Initial load
duke
parents:
diff changeset
1836 // End pointers are inclusive, and if count is not zero they point
a61af66fc99e Initial load
duke
parents:
diff changeset
1837 // to the last unit copied: end_to[0] := end_from[0]
a61af66fc99e Initial load
duke
parents:
diff changeset
1838
a61af66fc99e Initial load
duke
parents:
diff changeset
1839 __ enter(); // required for proper stackwalking of RuntimeStub frame
a61af66fc99e Initial load
duke
parents:
diff changeset
1840 // Save no-overlap entry point for generate_conjoint_long_oop_copy()
a61af66fc99e Initial load
duke
parents:
diff changeset
1841 assert_clean_int(c_rarg2, rax); // Make sure 'count' is clean int.
a61af66fc99e Initial load
duke
parents:
diff changeset
1842
a61af66fc99e Initial load
duke
parents:
diff changeset
1843 if (is_oop) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1844 disjoint_oop_copy_entry = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
1845 // no registers are destroyed by this call
a61af66fc99e Initial load
duke
parents:
diff changeset
1846 gen_write_ref_array_pre_barrier(/* dest */ c_rarg1, /* count */ c_rarg2);
a61af66fc99e Initial load
duke
parents:
diff changeset
1847 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1848 disjoint_long_copy_entry = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
1849 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1850 BLOCK_COMMENT("Entry:");
a61af66fc99e Initial load
duke
parents:
diff changeset
1851 // caller can pass a 64-bit byte count here (from Unsafe.copyMemory)
a61af66fc99e Initial load
duke
parents:
diff changeset
1852
a61af66fc99e Initial load
duke
parents:
diff changeset
1853 setup_arg_regs(); // from => rdi, to => rsi, count => rdx
a61af66fc99e Initial load
duke
parents:
diff changeset
1854 // r9 and r10 may be used to save non-volatile registers
a61af66fc99e Initial load
duke
parents:
diff changeset
1855
a61af66fc99e Initial load
duke
parents:
diff changeset
1856 // 'from', 'to' and 'qword_count' are now valid
a61af66fc99e Initial load
duke
parents:
diff changeset
1857
a61af66fc99e Initial load
duke
parents:
diff changeset
1858 // Copy from low to high addresses. Use 'to' as scratch.
a61af66fc99e Initial load
duke
parents:
diff changeset
1859 __ leaq(end_from, Address(from, qword_count, Address::times_8, -8));
a61af66fc99e Initial load
duke
parents:
diff changeset
1860 __ leaq(end_to, Address(to, qword_count, Address::times_8, -8));
a61af66fc99e Initial load
duke
parents:
diff changeset
1861 __ negq(qword_count);
a61af66fc99e Initial load
duke
parents:
diff changeset
1862 __ jmp(L_copy_32_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1863
a61af66fc99e Initial load
duke
parents:
diff changeset
1864 // Copy trailing qwords
a61af66fc99e Initial load
duke
parents:
diff changeset
1865 __ BIND(L_copy_8_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1866 __ movq(rax, Address(end_from, qword_count, Address::times_8, 8));
a61af66fc99e Initial load
duke
parents:
diff changeset
1867 __ movq(Address(end_to, qword_count, Address::times_8, 8), rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
1868 __ incrementq(qword_count);
a61af66fc99e Initial load
duke
parents:
diff changeset
1869 __ jcc(Assembler::notZero, L_copy_8_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1870
a61af66fc99e Initial load
duke
parents:
diff changeset
1871 if (is_oop) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1872 __ jmp(L_exit);
a61af66fc99e Initial load
duke
parents:
diff changeset
1873 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1874 inc_counter_np(SharedRuntime::_jlong_array_copy_ctr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1875 restore_arg_regs();
a61af66fc99e Initial load
duke
parents:
diff changeset
1876 __ xorq(rax, rax); // return 0
a61af66fc99e Initial load
duke
parents:
diff changeset
1877 __ leave(); // required for proper stackwalking of RuntimeStub frame
a61af66fc99e Initial load
duke
parents:
diff changeset
1878 __ ret(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1879 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1880
a61af66fc99e Initial load
duke
parents:
diff changeset
1881 // Copy 64-byte chunks
a61af66fc99e Initial load
duke
parents:
diff changeset
1882 copy_32_bytes_forward(end_from, end_to, qword_count, rax, L_copy_32_bytes, L_copy_8_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1883
a61af66fc99e Initial load
duke
parents:
diff changeset
1884 if (is_oop) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1885 __ BIND(L_exit);
a61af66fc99e Initial load
duke
parents:
diff changeset
1886 gen_write_ref_array_post_barrier(saved_to, end_to, rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
1887 inc_counter_np(SharedRuntime::_oop_array_copy_ctr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1888 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1889 inc_counter_np(SharedRuntime::_jlong_array_copy_ctr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1890 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1891 restore_arg_regs();
a61af66fc99e Initial load
duke
parents:
diff changeset
1892 __ xorq(rax, rax); // return 0
a61af66fc99e Initial load
duke
parents:
diff changeset
1893 __ leave(); // required for proper stackwalking of RuntimeStub frame
a61af66fc99e Initial load
duke
parents:
diff changeset
1894 __ ret(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1895
a61af66fc99e Initial load
duke
parents:
diff changeset
1896 return start;
a61af66fc99e Initial load
duke
parents:
diff changeset
1897 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1898
a61af66fc99e Initial load
duke
parents:
diff changeset
1899 // Arguments:
a61af66fc99e Initial load
duke
parents:
diff changeset
1900 // aligned - true => Input and output aligned on a HeapWord boundary == 8 bytes
a61af66fc99e Initial load
duke
parents:
diff changeset
1901 // ignored
a61af66fc99e Initial load
duke
parents:
diff changeset
1902 // is_oop - true => oop array, so generate store check code
a61af66fc99e Initial load
duke
parents:
diff changeset
1903 // name - stub name string
a61af66fc99e Initial load
duke
parents:
diff changeset
1904 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1905 // Inputs:
a61af66fc99e Initial load
duke
parents:
diff changeset
1906 // c_rarg0 - source array address
a61af66fc99e Initial load
duke
parents:
diff changeset
1907 // c_rarg1 - destination array address
a61af66fc99e Initial load
duke
parents:
diff changeset
1908 // c_rarg2 - element count, treated as ssize_t, can be zero
a61af66fc99e Initial load
duke
parents:
diff changeset
1909 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1910 address generate_conjoint_long_oop_copy(bool aligned, bool is_oop, const char *name) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1911 __ align(CodeEntryAlignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
1912 StubCodeMark mark(this, "StubRoutines", name);
a61af66fc99e Initial load
duke
parents:
diff changeset
1913 address start = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
1914
a61af66fc99e Initial load
duke
parents:
diff changeset
1915 Label L_copy_32_bytes, L_copy_8_bytes, L_exit;
a61af66fc99e Initial load
duke
parents:
diff changeset
1916 const Register from = rdi; // source array address
a61af66fc99e Initial load
duke
parents:
diff changeset
1917 const Register to = rsi; // destination array address
a61af66fc99e Initial load
duke
parents:
diff changeset
1918 const Register qword_count = rdx; // elements count
a61af66fc99e Initial load
duke
parents:
diff changeset
1919 const Register saved_count = rcx;
a61af66fc99e Initial load
duke
parents:
diff changeset
1920
a61af66fc99e Initial load
duke
parents:
diff changeset
1921 __ enter(); // required for proper stackwalking of RuntimeStub frame
a61af66fc99e Initial load
duke
parents:
diff changeset
1922 assert_clean_int(c_rarg2, rax); // Make sure 'count' is clean int.
a61af66fc99e Initial load
duke
parents:
diff changeset
1923
a61af66fc99e Initial load
duke
parents:
diff changeset
1924 address disjoint_copy_entry = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
1925 if (is_oop) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1926 disjoint_copy_entry = disjoint_oop_copy_entry;
a61af66fc99e Initial load
duke
parents:
diff changeset
1927 oop_copy_entry = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
1928 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1929 disjoint_copy_entry = disjoint_long_copy_entry;
a61af66fc99e Initial load
duke
parents:
diff changeset
1930 long_copy_entry = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
1931 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1932 BLOCK_COMMENT("Entry:");
a61af66fc99e Initial load
duke
parents:
diff changeset
1933 // caller can pass a 64-bit byte count here (from Unsafe.copyMemory)
a61af66fc99e Initial load
duke
parents:
diff changeset
1934
a61af66fc99e Initial load
duke
parents:
diff changeset
1935 array_overlap_test(disjoint_copy_entry, Address::times_8);
a61af66fc99e Initial load
duke
parents:
diff changeset
1936 setup_arg_regs(); // from => rdi, to => rsi, count => rdx
a61af66fc99e Initial load
duke
parents:
diff changeset
1937 // r9 and r10 may be used to save non-volatile registers
a61af66fc99e Initial load
duke
parents:
diff changeset
1938
a61af66fc99e Initial load
duke
parents:
diff changeset
1939 // 'from', 'to' and 'qword_count' are now valid
a61af66fc99e Initial load
duke
parents:
diff changeset
1940
a61af66fc99e Initial load
duke
parents:
diff changeset
1941 if (is_oop) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1942 // Save to and count for store barrier
a61af66fc99e Initial load
duke
parents:
diff changeset
1943 __ movq(saved_count, qword_count);
a61af66fc99e Initial load
duke
parents:
diff changeset
1944 // No registers are destroyed by this call
a61af66fc99e Initial load
duke
parents:
diff changeset
1945 gen_write_ref_array_pre_barrier(to, saved_count);
a61af66fc99e Initial load
duke
parents:
diff changeset
1946 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1947
a61af66fc99e Initial load
duke
parents:
diff changeset
1948 // Copy from high to low addresses. Use rcx as scratch.
a61af66fc99e Initial load
duke
parents:
diff changeset
1949
a61af66fc99e Initial load
duke
parents:
diff changeset
1950 __ jmp(L_copy_32_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1951
a61af66fc99e Initial load
duke
parents:
diff changeset
1952 // Copy trailing qwords
a61af66fc99e Initial load
duke
parents:
diff changeset
1953 __ BIND(L_copy_8_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1954 __ movq(rax, Address(from, qword_count, Address::times_8, -8));
a61af66fc99e Initial load
duke
parents:
diff changeset
1955 __ movq(Address(to, qword_count, Address::times_8, -8), rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
1956 __ decrementq(qword_count);
a61af66fc99e Initial load
duke
parents:
diff changeset
1957 __ jcc(Assembler::notZero, L_copy_8_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1958
a61af66fc99e Initial load
duke
parents:
diff changeset
1959 if (is_oop) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1960 __ jmp(L_exit);
a61af66fc99e Initial load
duke
parents:
diff changeset
1961 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1962 inc_counter_np(SharedRuntime::_jlong_array_copy_ctr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1963 restore_arg_regs();
a61af66fc99e Initial load
duke
parents:
diff changeset
1964 __ xorq(rax, rax); // return 0
a61af66fc99e Initial load
duke
parents:
diff changeset
1965 __ leave(); // required for proper stackwalking of RuntimeStub frame
a61af66fc99e Initial load
duke
parents:
diff changeset
1966 __ ret(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1967 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1968
a61af66fc99e Initial load
duke
parents:
diff changeset
1969 // Copy in 32-bytes chunks
a61af66fc99e Initial load
duke
parents:
diff changeset
1970 copy_32_bytes_backward(from, to, qword_count, rax, L_copy_32_bytes, L_copy_8_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1971
a61af66fc99e Initial load
duke
parents:
diff changeset
1972 if (is_oop) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1973 __ BIND(L_exit);
a61af66fc99e Initial load
duke
parents:
diff changeset
1974 __ leaq(rcx, Address(to, saved_count, Address::times_8, -8));
a61af66fc99e Initial load
duke
parents:
diff changeset
1975 gen_write_ref_array_post_barrier(to, rcx, rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
1976 inc_counter_np(SharedRuntime::_oop_array_copy_ctr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1977 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1978 inc_counter_np(SharedRuntime::_jlong_array_copy_ctr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1979 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1980 restore_arg_regs();
a61af66fc99e Initial load
duke
parents:
diff changeset
1981 __ xorq(rax, rax); // return 0
a61af66fc99e Initial load
duke
parents:
diff changeset
1982 __ leave(); // required for proper stackwalking of RuntimeStub frame
a61af66fc99e Initial load
duke
parents:
diff changeset
1983 __ ret(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1984
a61af66fc99e Initial load
duke
parents:
diff changeset
1985 return start;
a61af66fc99e Initial load
duke
parents:
diff changeset
1986 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1987
a61af66fc99e Initial load
duke
parents:
diff changeset
1988
a61af66fc99e Initial load
duke
parents:
diff changeset
1989 // Helper for generating a dynamic type check.
a61af66fc99e Initial load
duke
parents:
diff changeset
1990 // Smashes no registers.
a61af66fc99e Initial load
duke
parents:
diff changeset
1991 void generate_type_check(Register sub_klass,
a61af66fc99e Initial load
duke
parents:
diff changeset
1992 Register super_check_offset,
a61af66fc99e Initial load
duke
parents:
diff changeset
1993 Register super_klass,
a61af66fc99e Initial load
duke
parents:
diff changeset
1994 Label& L_success) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1995 assert_different_registers(sub_klass, super_check_offset, super_klass);
a61af66fc99e Initial load
duke
parents:
diff changeset
1996
a61af66fc99e Initial load
duke
parents:
diff changeset
1997 BLOCK_COMMENT("type_check:");
a61af66fc99e Initial load
duke
parents:
diff changeset
1998
a61af66fc99e Initial load
duke
parents:
diff changeset
1999 Label L_miss;
a61af66fc99e Initial load
duke
parents:
diff changeset
2000
a61af66fc99e Initial load
duke
parents:
diff changeset
2001 // a couple of useful fields in sub_klass:
a61af66fc99e Initial load
duke
parents:
diff changeset
2002 int ss_offset = (klassOopDesc::header_size() * HeapWordSize +
a61af66fc99e Initial load
duke
parents:
diff changeset
2003 Klass::secondary_supers_offset_in_bytes());
a61af66fc99e Initial load
duke
parents:
diff changeset
2004 int sc_offset = (klassOopDesc::header_size() * HeapWordSize +
a61af66fc99e Initial load
duke
parents:
diff changeset
2005 Klass::secondary_super_cache_offset_in_bytes());
a61af66fc99e Initial load
duke
parents:
diff changeset
2006 Address secondary_supers_addr(sub_klass, ss_offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
2007 Address super_cache_addr( sub_klass, sc_offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
2008
a61af66fc99e Initial load
duke
parents:
diff changeset
2009 // if the pointers are equal, we are done (e.g., String[] elements)
a61af66fc99e Initial load
duke
parents:
diff changeset
2010 __ cmpq(super_klass, sub_klass);
a61af66fc99e Initial load
duke
parents:
diff changeset
2011 __ jcc(Assembler::equal, L_success);
a61af66fc99e Initial load
duke
parents:
diff changeset
2012
a61af66fc99e Initial load
duke
parents:
diff changeset
2013 // check the supertype display:
a61af66fc99e Initial load
duke
parents:
diff changeset
2014 Address super_check_addr(sub_klass, super_check_offset, Address::times_1, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2015 __ cmpq(super_klass, super_check_addr); // test the super type
a61af66fc99e Initial load
duke
parents:
diff changeset
2016 __ jcc(Assembler::equal, L_success);
a61af66fc99e Initial load
duke
parents:
diff changeset
2017
a61af66fc99e Initial load
duke
parents:
diff changeset
2018 // if it was a primary super, we can just fail immediately
a61af66fc99e Initial load
duke
parents:
diff changeset
2019 __ cmpl(super_check_offset, sc_offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
2020 __ jcc(Assembler::notEqual, L_miss);
a61af66fc99e Initial load
duke
parents:
diff changeset
2021
a61af66fc99e Initial load
duke
parents:
diff changeset
2022 // Now do a linear scan of the secondary super-klass chain.
a61af66fc99e Initial load
duke
parents:
diff changeset
2023 // The repne_scan instruction uses fixed registers, which we must spill.
a61af66fc99e Initial load
duke
parents:
diff changeset
2024 // (We need a couple more temps in any case.)
a61af66fc99e Initial load
duke
parents:
diff changeset
2025 // This code is rarely used, so simplicity is a virtue here.
a61af66fc99e Initial load
duke
parents:
diff changeset
2026 inc_counter_np(SharedRuntime::_partial_subtype_ctr);
a61af66fc99e Initial load
duke
parents:
diff changeset
2027 {
a61af66fc99e Initial load
duke
parents:
diff changeset
2028 __ pushq(rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
2029 __ pushq(rcx);
a61af66fc99e Initial load
duke
parents:
diff changeset
2030 __ pushq(rdi);
a61af66fc99e Initial load
duke
parents:
diff changeset
2031 assert_different_registers(sub_klass, super_klass, rax, rcx, rdi);
a61af66fc99e Initial load
duke
parents:
diff changeset
2032
a61af66fc99e Initial load
duke
parents:
diff changeset
2033 __ movq(rdi, secondary_supers_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
2034 // Load the array length.
a61af66fc99e Initial load
duke
parents:
diff changeset
2035 __ movl(rcx, Address(rdi, arrayOopDesc::length_offset_in_bytes()));
a61af66fc99e Initial load
duke
parents:
diff changeset
2036 // Skip to start of data.
a61af66fc99e Initial load
duke
parents:
diff changeset
2037 __ addq(rdi, arrayOopDesc::base_offset_in_bytes(T_OBJECT));
a61af66fc99e Initial load
duke
parents:
diff changeset
2038 // Scan rcx words at [rdi] for occurance of rax
a61af66fc99e Initial load
duke
parents:
diff changeset
2039 // Set NZ/Z based on last compare
a61af66fc99e Initial load
duke
parents:
diff changeset
2040 __ movq(rax, super_klass);
a61af66fc99e Initial load
duke
parents:
diff changeset
2041 __ repne_scan();
a61af66fc99e Initial load
duke
parents:
diff changeset
2042
a61af66fc99e Initial load
duke
parents:
diff changeset
2043 // Unspill the temp. registers:
a61af66fc99e Initial load
duke
parents:
diff changeset
2044 __ popq(rdi);
a61af66fc99e Initial load
duke
parents:
diff changeset
2045 __ popq(rcx);
a61af66fc99e Initial load
duke
parents:
diff changeset
2046 __ popq(rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
2047
a61af66fc99e Initial load
duke
parents:
diff changeset
2048 __ jcc(Assembler::notEqual, L_miss);
a61af66fc99e Initial load
duke
parents:
diff changeset
2049 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2050
a61af66fc99e Initial load
duke
parents:
diff changeset
2051 // Success. Cache the super we found and proceed in triumph.
a61af66fc99e Initial load
duke
parents:
diff changeset
2052 __ movq(super_cache_addr, super_klass); // note: rax is dead
a61af66fc99e Initial load
duke
parents:
diff changeset
2053 __ jmp(L_success);
a61af66fc99e Initial load
duke
parents:
diff changeset
2054
a61af66fc99e Initial load
duke
parents:
diff changeset
2055 // Fall through on failure!
a61af66fc99e Initial load
duke
parents:
diff changeset
2056 __ BIND(L_miss);
a61af66fc99e Initial load
duke
parents:
diff changeset
2057 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2058
a61af66fc99e Initial load
duke
parents:
diff changeset
2059 //
a61af66fc99e Initial load
duke
parents:
diff changeset
2060 // Generate checkcasting array copy stub
a61af66fc99e Initial load
duke
parents:
diff changeset
2061 //
a61af66fc99e Initial load
duke
parents:
diff changeset
2062 // Input:
a61af66fc99e Initial load
duke
parents:
diff changeset
2063 // c_rarg0 - source array address
a61af66fc99e Initial load
duke
parents:
diff changeset
2064 // c_rarg1 - destination array address
a61af66fc99e Initial load
duke
parents:
diff changeset
2065 // c_rarg2 - element count, treated as ssize_t, can be zero
a61af66fc99e Initial load
duke
parents:
diff changeset
2066 // c_rarg3 - size_t ckoff (super_check_offset)
a61af66fc99e Initial load
duke
parents:
diff changeset
2067 // not Win64
a61af66fc99e Initial load
duke
parents:
diff changeset
2068 // c_rarg4 - oop ckval (super_klass)
a61af66fc99e Initial load
duke
parents:
diff changeset
2069 // Win64
a61af66fc99e Initial load
duke
parents:
diff changeset
2070 // rsp+40 - oop ckval (super_klass)
a61af66fc99e Initial load
duke
parents:
diff changeset
2071 //
a61af66fc99e Initial load
duke
parents:
diff changeset
2072 // Output:
a61af66fc99e Initial load
duke
parents:
diff changeset
2073 // rax == 0 - success
a61af66fc99e Initial load
duke
parents:
diff changeset
2074 // rax == -1^K - failure, where K is partial transfer count
a61af66fc99e Initial load
duke
parents:
diff changeset
2075 //
a61af66fc99e Initial load
duke
parents:
diff changeset
2076 address generate_checkcast_copy(const char *name) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2077
a61af66fc99e Initial load
duke
parents:
diff changeset
2078 Label L_load_element, L_store_element, L_do_card_marks, L_done;
a61af66fc99e Initial load
duke
parents:
diff changeset
2079
a61af66fc99e Initial load
duke
parents:
diff changeset
2080 // Input registers (after setup_arg_regs)
a61af66fc99e Initial load
duke
parents:
diff changeset
2081 const Register from = rdi; // source array address
a61af66fc99e Initial load
duke
parents:
diff changeset
2082 const Register to = rsi; // destination array address
a61af66fc99e Initial load
duke
parents:
diff changeset
2083 const Register length = rdx; // elements count
a61af66fc99e Initial load
duke
parents:
diff changeset
2084 const Register ckoff = rcx; // super_check_offset
a61af66fc99e Initial load
duke
parents:
diff changeset
2085 const Register ckval = r8; // super_klass
a61af66fc99e Initial load
duke
parents:
diff changeset
2086
a61af66fc99e Initial load
duke
parents:
diff changeset
2087 // Registers used as temps (r13, r14 are save-on-entry)
a61af66fc99e Initial load
duke
parents:
diff changeset
2088 const Register end_from = from; // source array end address
a61af66fc99e Initial load
duke
parents:
diff changeset
2089 const Register end_to = r13; // destination array end address
a61af66fc99e Initial load
duke
parents:
diff changeset
2090 const Register count = rdx; // -(count_remaining)
a61af66fc99e Initial load
duke
parents:
diff changeset
2091 const Register r14_length = r14; // saved copy of length
a61af66fc99e Initial load
duke
parents:
diff changeset
2092 // End pointers are inclusive, and if length is not zero they point
a61af66fc99e Initial load
duke
parents:
diff changeset
2093 // to the last unit copied: end_to[0] := end_from[0]
a61af66fc99e Initial load
duke
parents:
diff changeset
2094
a61af66fc99e Initial load
duke
parents:
diff changeset
2095 const Register rax_oop = rax; // actual oop copied
a61af66fc99e Initial load
duke
parents:
diff changeset
2096 const Register r11_klass = r11; // oop._klass
a61af66fc99e Initial load
duke
parents:
diff changeset
2097
a61af66fc99e Initial load
duke
parents:
diff changeset
2098 //---------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
2099 // Assembler stub will be used for this call to arraycopy
a61af66fc99e Initial load
duke
parents:
diff changeset
2100 // if the two arrays are subtypes of Object[] but the
a61af66fc99e Initial load
duke
parents:
diff changeset
2101 // destination array type is not equal to or a supertype
a61af66fc99e Initial load
duke
parents:
diff changeset
2102 // of the source type. Each element must be separately
a61af66fc99e Initial load
duke
parents:
diff changeset
2103 // checked.
a61af66fc99e Initial load
duke
parents:
diff changeset
2104
a61af66fc99e Initial load
duke
parents:
diff changeset
2105 __ align(CodeEntryAlignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
2106 StubCodeMark mark(this, "StubRoutines", name);
a61af66fc99e Initial load
duke
parents:
diff changeset
2107 address start = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
2108
a61af66fc99e Initial load
duke
parents:
diff changeset
2109 __ enter(); // required for proper stackwalking of RuntimeStub frame
a61af66fc99e Initial load
duke
parents:
diff changeset
2110
a61af66fc99e Initial load
duke
parents:
diff changeset
2111 checkcast_copy_entry = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
2112 BLOCK_COMMENT("Entry:");
a61af66fc99e Initial load
duke
parents:
diff changeset
2113
a61af66fc99e Initial load
duke
parents:
diff changeset
2114 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
2115 // caller guarantees that the arrays really are different
a61af66fc99e Initial load
duke
parents:
diff changeset
2116 // otherwise, we would have to make conjoint checks
a61af66fc99e Initial load
duke
parents:
diff changeset
2117 { Label L;
a61af66fc99e Initial load
duke
parents:
diff changeset
2118 array_overlap_test(L, Address::times_8);
a61af66fc99e Initial load
duke
parents:
diff changeset
2119 __ stop("checkcast_copy within a single array");
a61af66fc99e Initial load
duke
parents:
diff changeset
2120 __ bind(L);
a61af66fc99e Initial load
duke
parents:
diff changeset
2121 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2122 #endif //ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
2123
a61af66fc99e Initial load
duke
parents:
diff changeset
2124 // allocate spill slots for r13, r14
a61af66fc99e Initial load
duke
parents:
diff changeset
2125 enum {
a61af66fc99e Initial load
duke
parents:
diff changeset
2126 saved_r13_offset,
a61af66fc99e Initial load
duke
parents:
diff changeset
2127 saved_r14_offset,
a61af66fc99e Initial load
duke
parents:
diff changeset
2128 saved_rbp_offset,
a61af66fc99e Initial load
duke
parents:
diff changeset
2129 saved_rip_offset,
a61af66fc99e Initial load
duke
parents:
diff changeset
2130 saved_rarg0_offset
a61af66fc99e Initial load
duke
parents:
diff changeset
2131 };
a61af66fc99e Initial load
duke
parents:
diff changeset
2132 __ subq(rsp, saved_rbp_offset * wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
2133 __ movq(Address(rsp, saved_r13_offset * wordSize), r13);
a61af66fc99e Initial load
duke
parents:
diff changeset
2134 __ movq(Address(rsp, saved_r14_offset * wordSize), r14);
a61af66fc99e Initial load
duke
parents:
diff changeset
2135 setup_arg_regs(4); // from => rdi, to => rsi, length => rdx
a61af66fc99e Initial load
duke
parents:
diff changeset
2136 // ckoff => rcx, ckval => r8
a61af66fc99e Initial load
duke
parents:
diff changeset
2137 // r9 and r10 may be used to save non-volatile registers
a61af66fc99e Initial load
duke
parents:
diff changeset
2138 #ifdef _WIN64
a61af66fc99e Initial load
duke
parents:
diff changeset
2139 // last argument (#4) is on stack on Win64
a61af66fc99e Initial load
duke
parents:
diff changeset
2140 const int ckval_offset = saved_rarg0_offset + 4;
a61af66fc99e Initial load
duke
parents:
diff changeset
2141 __ movq(ckval, Address(rsp, ckval_offset * wordSize));
a61af66fc99e Initial load
duke
parents:
diff changeset
2142 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
2143
a61af66fc99e Initial load
duke
parents:
diff changeset
2144 // check that int operands are properly extended to size_t
a61af66fc99e Initial load
duke
parents:
diff changeset
2145 assert_clean_int(length, rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
2146 assert_clean_int(ckoff, rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
2147
a61af66fc99e Initial load
duke
parents:
diff changeset
2148 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
2149 BLOCK_COMMENT("assert consistent ckoff/ckval");
a61af66fc99e Initial load
duke
parents:
diff changeset
2150 // The ckoff and ckval must be mutually consistent,
a61af66fc99e Initial load
duke
parents:
diff changeset
2151 // even though caller generates both.
a61af66fc99e Initial load
duke
parents:
diff changeset
2152 { Label L;
a61af66fc99e Initial load
duke
parents:
diff changeset
2153 int sco_offset = (klassOopDesc::header_size() * HeapWordSize +
a61af66fc99e Initial load
duke
parents:
diff changeset
2154 Klass::super_check_offset_offset_in_bytes());
a61af66fc99e Initial load
duke
parents:
diff changeset
2155 __ cmpl(ckoff, Address(ckval, sco_offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
2156 __ jcc(Assembler::equal, L);
a61af66fc99e Initial load
duke
parents:
diff changeset
2157 __ stop("super_check_offset inconsistent");
a61af66fc99e Initial load
duke
parents:
diff changeset
2158 __ bind(L);
a61af66fc99e Initial load
duke
parents:
diff changeset
2159 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2160 #endif //ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
2161
a61af66fc99e Initial load
duke
parents:
diff changeset
2162 // Loop-invariant addresses. They are exclusive end pointers.
a61af66fc99e Initial load
duke
parents:
diff changeset
2163 Address end_from_addr(from, length, Address::times_8, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2164 Address end_to_addr(to, length, Address::times_8, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2165 // Loop-variant addresses. They assume post-incremented count < 0.
a61af66fc99e Initial load
duke
parents:
diff changeset
2166 Address from_element_addr(end_from, count, Address::times_8, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2167 Address to_element_addr(end_to, count, Address::times_8, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2168 Address oop_klass_addr(rax_oop, oopDesc::klass_offset_in_bytes());
a61af66fc99e Initial load
duke
parents:
diff changeset
2169
a61af66fc99e Initial load
duke
parents:
diff changeset
2170 gen_write_ref_array_pre_barrier(to, count);
a61af66fc99e Initial load
duke
parents:
diff changeset
2171
a61af66fc99e Initial load
duke
parents:
diff changeset
2172 // Copy from low to high addresses, indexed from the end of each array.
a61af66fc99e Initial load
duke
parents:
diff changeset
2173 __ leaq(end_from, end_from_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
2174 __ leaq(end_to, end_to_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
2175 __ movq(r14_length, length); // save a copy of the length
a61af66fc99e Initial load
duke
parents:
diff changeset
2176 assert(length == count, ""); // else fix next line:
a61af66fc99e Initial load
duke
parents:
diff changeset
2177 __ negq(count); // negate and test the length
a61af66fc99e Initial load
duke
parents:
diff changeset
2178 __ jcc(Assembler::notZero, L_load_element);
a61af66fc99e Initial load
duke
parents:
diff changeset
2179
a61af66fc99e Initial load
duke
parents:
diff changeset
2180 // Empty array: Nothing to do.
a61af66fc99e Initial load
duke
parents:
diff changeset
2181 __ xorq(rax, rax); // return 0 on (trivial) success
a61af66fc99e Initial load
duke
parents:
diff changeset
2182 __ jmp(L_done);
a61af66fc99e Initial load
duke
parents:
diff changeset
2183
a61af66fc99e Initial load
duke
parents:
diff changeset
2184 // ======== begin loop ========
a61af66fc99e Initial load
duke
parents:
diff changeset
2185 // (Loop is rotated; its entry is L_load_element.)
a61af66fc99e Initial load
duke
parents:
diff changeset
2186 // Loop control:
a61af66fc99e Initial load
duke
parents:
diff changeset
2187 // for (count = -count; count != 0; count++)
a61af66fc99e Initial load
duke
parents:
diff changeset
2188 // Base pointers src, dst are biased by 8*(count-1),to last element.
a61af66fc99e Initial load
duke
parents:
diff changeset
2189 __ align(16);
a61af66fc99e Initial load
duke
parents:
diff changeset
2190
a61af66fc99e Initial load
duke
parents:
diff changeset
2191 __ BIND(L_store_element);
a61af66fc99e Initial load
duke
parents:
diff changeset
2192 __ movq(to_element_addr, rax_oop); // store the oop
a61af66fc99e Initial load
duke
parents:
diff changeset
2193 __ incrementq(count); // increment the count toward zero
a61af66fc99e Initial load
duke
parents:
diff changeset
2194 __ jcc(Assembler::zero, L_do_card_marks);
a61af66fc99e Initial load
duke
parents:
diff changeset
2195
a61af66fc99e Initial load
duke
parents:
diff changeset
2196 // ======== loop entry is here ========
a61af66fc99e Initial load
duke
parents:
diff changeset
2197 __ BIND(L_load_element);
a61af66fc99e Initial load
duke
parents:
diff changeset
2198 __ movq(rax_oop, from_element_addr); // load the oop
a61af66fc99e Initial load
duke
parents:
diff changeset
2199 __ testq(rax_oop, rax_oop);
a61af66fc99e Initial load
duke
parents:
diff changeset
2200 __ jcc(Assembler::zero, L_store_element);
a61af66fc99e Initial load
duke
parents:
diff changeset
2201
a61af66fc99e Initial load
duke
parents:
diff changeset
2202 __ movq(r11_klass, oop_klass_addr); // query the object klass
a61af66fc99e Initial load
duke
parents:
diff changeset
2203 generate_type_check(r11_klass, ckoff, ckval, L_store_element);
a61af66fc99e Initial load
duke
parents:
diff changeset
2204 // ======== end loop ========
a61af66fc99e Initial load
duke
parents:
diff changeset
2205
a61af66fc99e Initial load
duke
parents:
diff changeset
2206 // It was a real error; we must depend on the caller to finish the job.
a61af66fc99e Initial load
duke
parents:
diff changeset
2207 // Register rdx = -1 * number of *remaining* oops, r14 = *total* oops.
a61af66fc99e Initial load
duke
parents:
diff changeset
2208 // Emit GC store barriers for the oops we have copied (r14 + rdx),
a61af66fc99e Initial load
duke
parents:
diff changeset
2209 // and report their number to the caller.
a61af66fc99e Initial load
duke
parents:
diff changeset
2210 assert_different_registers(rax, r14_length, count, to, end_to, rcx);
a61af66fc99e Initial load
duke
parents:
diff changeset
2211 __ leaq(end_to, to_element_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
2212 gen_write_ref_array_post_barrier(to, end_to, rcx);
a61af66fc99e Initial load
duke
parents:
diff changeset
2213 __ movq(rax, r14_length); // original oops
a61af66fc99e Initial load
duke
parents:
diff changeset
2214 __ addq(rax, count); // K = (original - remaining) oops
a61af66fc99e Initial load
duke
parents:
diff changeset
2215 __ notq(rax); // report (-1^K) to caller
a61af66fc99e Initial load
duke
parents:
diff changeset
2216 __ jmp(L_done);
a61af66fc99e Initial load
duke
parents:
diff changeset
2217
a61af66fc99e Initial load
duke
parents:
diff changeset
2218 // Come here on success only.
a61af66fc99e Initial load
duke
parents:
diff changeset
2219 __ BIND(L_do_card_marks);
a61af66fc99e Initial load
duke
parents:
diff changeset
2220 __ addq(end_to, -wordSize); // make an inclusive end pointer
a61af66fc99e Initial load
duke
parents:
diff changeset
2221 gen_write_ref_array_post_barrier(to, end_to, rcx);
a61af66fc99e Initial load
duke
parents:
diff changeset
2222 __ xorq(rax, rax); // return 0 on success
a61af66fc99e Initial load
duke
parents:
diff changeset
2223
a61af66fc99e Initial load
duke
parents:
diff changeset
2224 // Common exit point (success or failure).
a61af66fc99e Initial load
duke
parents:
diff changeset
2225 __ BIND(L_done);
a61af66fc99e Initial load
duke
parents:
diff changeset
2226 __ movq(r13, Address(rsp, saved_r13_offset * wordSize));
a61af66fc99e Initial load
duke
parents:
diff changeset
2227 __ movq(r14, Address(rsp, saved_r14_offset * wordSize));
a61af66fc99e Initial load
duke
parents:
diff changeset
2228 inc_counter_np(SharedRuntime::_checkcast_array_copy_ctr);
a61af66fc99e Initial load
duke
parents:
diff changeset
2229 restore_arg_regs();
a61af66fc99e Initial load
duke
parents:
diff changeset
2230 __ leave(); // required for proper stackwalking of RuntimeStub frame
a61af66fc99e Initial load
duke
parents:
diff changeset
2231 __ ret(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2232
a61af66fc99e Initial load
duke
parents:
diff changeset
2233 return start;
a61af66fc99e Initial load
duke
parents:
diff changeset
2234 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2235
a61af66fc99e Initial load
duke
parents:
diff changeset
2236 //
a61af66fc99e Initial load
duke
parents:
diff changeset
2237 // Generate 'unsafe' array copy stub
a61af66fc99e Initial load
duke
parents:
diff changeset
2238 // Though just as safe as the other stubs, it takes an unscaled
a61af66fc99e Initial load
duke
parents:
diff changeset
2239 // size_t argument instead of an element count.
a61af66fc99e Initial load
duke
parents:
diff changeset
2240 //
a61af66fc99e Initial load
duke
parents:
diff changeset
2241 // Input:
a61af66fc99e Initial load
duke
parents:
diff changeset
2242 // c_rarg0 - source array address
a61af66fc99e Initial load
duke
parents:
diff changeset
2243 // c_rarg1 - destination array address
a61af66fc99e Initial load
duke
parents:
diff changeset
2244 // c_rarg2 - byte count, treated as ssize_t, can be zero
a61af66fc99e Initial load
duke
parents:
diff changeset
2245 //
a61af66fc99e Initial load
duke
parents:
diff changeset
2246 // Examines the alignment of the operands and dispatches
a61af66fc99e Initial load
duke
parents:
diff changeset
2247 // to a long, int, short, or byte copy loop.
a61af66fc99e Initial load
duke
parents:
diff changeset
2248 //
a61af66fc99e Initial load
duke
parents:
diff changeset
2249 address generate_unsafe_copy(const char *name) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2250
a61af66fc99e Initial load
duke
parents:
diff changeset
2251 Label L_long_aligned, L_int_aligned, L_short_aligned;
a61af66fc99e Initial load
duke
parents:
diff changeset
2252
a61af66fc99e Initial load
duke
parents:
diff changeset
2253 // Input registers (before setup_arg_regs)
a61af66fc99e Initial load
duke
parents:
diff changeset
2254 const Register from = c_rarg0; // source array address
a61af66fc99e Initial load
duke
parents:
diff changeset
2255 const Register to = c_rarg1; // destination array address
a61af66fc99e Initial load
duke
parents:
diff changeset
2256 const Register size = c_rarg2; // byte count (size_t)
a61af66fc99e Initial load
duke
parents:
diff changeset
2257
a61af66fc99e Initial load
duke
parents:
diff changeset
2258 // Register used as a temp
a61af66fc99e Initial load
duke
parents:
diff changeset
2259 const Register bits = rax; // test copy of low bits
a61af66fc99e Initial load
duke
parents:
diff changeset
2260
a61af66fc99e Initial load
duke
parents:
diff changeset
2261 __ align(CodeEntryAlignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
2262 StubCodeMark mark(this, "StubRoutines", name);
a61af66fc99e Initial load
duke
parents:
diff changeset
2263 address start = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
2264
a61af66fc99e Initial load
duke
parents:
diff changeset
2265 __ enter(); // required for proper stackwalking of RuntimeStub frame
a61af66fc99e Initial load
duke
parents:
diff changeset
2266
a61af66fc99e Initial load
duke
parents:
diff changeset
2267 // bump this on entry, not on exit:
a61af66fc99e Initial load
duke
parents:
diff changeset
2268 inc_counter_np(SharedRuntime::_unsafe_array_copy_ctr);
a61af66fc99e Initial load
duke
parents:
diff changeset
2269
a61af66fc99e Initial load
duke
parents:
diff changeset
2270 __ movq(bits, from);
a61af66fc99e Initial load
duke
parents:
diff changeset
2271 __ orq(bits, to);
a61af66fc99e Initial load
duke
parents:
diff changeset
2272 __ orq(bits, size);
a61af66fc99e Initial load
duke
parents:
diff changeset
2273
a61af66fc99e Initial load
duke
parents:
diff changeset
2274 __ testb(bits, BytesPerLong-1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2275 __ jccb(Assembler::zero, L_long_aligned);
a61af66fc99e Initial load
duke
parents:
diff changeset
2276
a61af66fc99e Initial load
duke
parents:
diff changeset
2277 __ testb(bits, BytesPerInt-1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2278 __ jccb(Assembler::zero, L_int_aligned);
a61af66fc99e Initial load
duke
parents:
diff changeset
2279
a61af66fc99e Initial load
duke
parents:
diff changeset
2280 __ testb(bits, BytesPerShort-1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2281 __ jump_cc(Assembler::notZero, RuntimeAddress(byte_copy_entry));
a61af66fc99e Initial load
duke
parents:
diff changeset
2282
a61af66fc99e Initial load
duke
parents:
diff changeset
2283 __ BIND(L_short_aligned);
a61af66fc99e Initial load
duke
parents:
diff changeset
2284 __ shrq(size, LogBytesPerShort); // size => short_count
a61af66fc99e Initial load
duke
parents:
diff changeset
2285 __ jump(RuntimeAddress(short_copy_entry));
a61af66fc99e Initial load
duke
parents:
diff changeset
2286
a61af66fc99e Initial load
duke
parents:
diff changeset
2287 __ BIND(L_int_aligned);
a61af66fc99e Initial load
duke
parents:
diff changeset
2288 __ shrq(size, LogBytesPerInt); // size => int_count
a61af66fc99e Initial load
duke
parents:
diff changeset
2289 __ jump(RuntimeAddress(int_copy_entry));
a61af66fc99e Initial load
duke
parents:
diff changeset
2290
a61af66fc99e Initial load
duke
parents:
diff changeset
2291 __ BIND(L_long_aligned);
a61af66fc99e Initial load
duke
parents:
diff changeset
2292 __ shrq(size, LogBytesPerLong); // size => qword_count
a61af66fc99e Initial load
duke
parents:
diff changeset
2293 __ jump(RuntimeAddress(long_copy_entry));
a61af66fc99e Initial load
duke
parents:
diff changeset
2294
a61af66fc99e Initial load
duke
parents:
diff changeset
2295 return start;
a61af66fc99e Initial load
duke
parents:
diff changeset
2296 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2297
a61af66fc99e Initial load
duke
parents:
diff changeset
2298 // Perform range checks on the proposed arraycopy.
a61af66fc99e Initial load
duke
parents:
diff changeset
2299 // Kills temp, but nothing else.
a61af66fc99e Initial load
duke
parents:
diff changeset
2300 // Also, clean the sign bits of src_pos and dst_pos.
a61af66fc99e Initial load
duke
parents:
diff changeset
2301 void arraycopy_range_checks(Register src, // source array oop (c_rarg0)
a61af66fc99e Initial load
duke
parents:
diff changeset
2302 Register src_pos, // source position (c_rarg1)
a61af66fc99e Initial load
duke
parents:
diff changeset
2303 Register dst, // destination array oo (c_rarg2)
a61af66fc99e Initial load
duke
parents:
diff changeset
2304 Register dst_pos, // destination position (c_rarg3)
a61af66fc99e Initial load
duke
parents:
diff changeset
2305 Register length,
a61af66fc99e Initial load
duke
parents:
diff changeset
2306 Register temp,
a61af66fc99e Initial load
duke
parents:
diff changeset
2307 Label& L_failed) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2308 BLOCK_COMMENT("arraycopy_range_checks:");
a61af66fc99e Initial load
duke
parents:
diff changeset
2309
a61af66fc99e Initial load
duke
parents:
diff changeset
2310 // if (src_pos + length > arrayOop(src)->length()) FAIL;
a61af66fc99e Initial load
duke
parents:
diff changeset
2311 __ movl(temp, length);
a61af66fc99e Initial load
duke
parents:
diff changeset
2312 __ addl(temp, src_pos); // src_pos + length
a61af66fc99e Initial load
duke
parents:
diff changeset
2313 __ cmpl(temp, Address(src, arrayOopDesc::length_offset_in_bytes()));
a61af66fc99e Initial load
duke
parents:
diff changeset
2314 __ jcc(Assembler::above, L_failed);
a61af66fc99e Initial load
duke
parents:
diff changeset
2315
a61af66fc99e Initial load
duke
parents:
diff changeset
2316 // if (dst_pos + length > arrayOop(dst)->length()) FAIL;
a61af66fc99e Initial load
duke
parents:
diff changeset
2317 __ movl(temp, length);
a61af66fc99e Initial load
duke
parents:
diff changeset
2318 __ addl(temp, dst_pos); // dst_pos + length
a61af66fc99e Initial load
duke
parents:
diff changeset
2319 __ cmpl(temp, Address(dst, arrayOopDesc::length_offset_in_bytes()));
a61af66fc99e Initial load
duke
parents:
diff changeset
2320 __ jcc(Assembler::above, L_failed);
a61af66fc99e Initial load
duke
parents:
diff changeset
2321
a61af66fc99e Initial load
duke
parents:
diff changeset
2322 // Have to clean up high 32-bits of 'src_pos' and 'dst_pos'.
a61af66fc99e Initial load
duke
parents:
diff changeset
2323 // Move with sign extension can be used since they are positive.
a61af66fc99e Initial load
duke
parents:
diff changeset
2324 __ movslq(src_pos, src_pos);
a61af66fc99e Initial load
duke
parents:
diff changeset
2325 __ movslq(dst_pos, dst_pos);
a61af66fc99e Initial load
duke
parents:
diff changeset
2326
a61af66fc99e Initial load
duke
parents:
diff changeset
2327 BLOCK_COMMENT("arraycopy_range_checks done");
a61af66fc99e Initial load
duke
parents:
diff changeset
2328 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2329
a61af66fc99e Initial load
duke
parents:
diff changeset
2330 //
a61af66fc99e Initial load
duke
parents:
diff changeset
2331 // Generate generic array copy stubs
a61af66fc99e Initial load
duke
parents:
diff changeset
2332 //
a61af66fc99e Initial load
duke
parents:
diff changeset
2333 // Input:
a61af66fc99e Initial load
duke
parents:
diff changeset
2334 // c_rarg0 - src oop
a61af66fc99e Initial load
duke
parents:
diff changeset
2335 // c_rarg1 - src_pos (32-bits)
a61af66fc99e Initial load
duke
parents:
diff changeset
2336 // c_rarg2 - dst oop
a61af66fc99e Initial load
duke
parents:
diff changeset
2337 // c_rarg3 - dst_pos (32-bits)
a61af66fc99e Initial load
duke
parents:
diff changeset
2338 // not Win64
a61af66fc99e Initial load
duke
parents:
diff changeset
2339 // c_rarg4 - element count (32-bits)
a61af66fc99e Initial load
duke
parents:
diff changeset
2340 // Win64
a61af66fc99e Initial load
duke
parents:
diff changeset
2341 // rsp+40 - element count (32-bits)
a61af66fc99e Initial load
duke
parents:
diff changeset
2342 //
a61af66fc99e Initial load
duke
parents:
diff changeset
2343 // Output:
a61af66fc99e Initial load
duke
parents:
diff changeset
2344 // rax == 0 - success
a61af66fc99e Initial load
duke
parents:
diff changeset
2345 // rax == -1^K - failure, where K is partial transfer count
a61af66fc99e Initial load
duke
parents:
diff changeset
2346 //
a61af66fc99e Initial load
duke
parents:
diff changeset
2347 address generate_generic_copy(const char *name) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2348
a61af66fc99e Initial load
duke
parents:
diff changeset
2349 Label L_failed, L_failed_0, L_objArray;
a61af66fc99e Initial load
duke
parents:
diff changeset
2350 Label L_copy_bytes, L_copy_shorts, L_copy_ints, L_copy_longs;
a61af66fc99e Initial load
duke
parents:
diff changeset
2351
a61af66fc99e Initial load
duke
parents:
diff changeset
2352 // Input registers
a61af66fc99e Initial load
duke
parents:
diff changeset
2353 const Register src = c_rarg0; // source array oop
a61af66fc99e Initial load
duke
parents:
diff changeset
2354 const Register src_pos = c_rarg1; // source position
a61af66fc99e Initial load
duke
parents:
diff changeset
2355 const Register dst = c_rarg2; // destination array oop
a61af66fc99e Initial load
duke
parents:
diff changeset
2356 const Register dst_pos = c_rarg3; // destination position
a61af66fc99e Initial load
duke
parents:
diff changeset
2357 // elements count is on stack on Win64
a61af66fc99e Initial load
duke
parents:
diff changeset
2358 #ifdef _WIN64
a61af66fc99e Initial load
duke
parents:
diff changeset
2359 #define C_RARG4 Address(rsp, 6 * wordSize)
a61af66fc99e Initial load
duke
parents:
diff changeset
2360 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
2361 #define C_RARG4 c_rarg4
a61af66fc99e Initial load
duke
parents:
diff changeset
2362 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
2363
a61af66fc99e Initial load
duke
parents:
diff changeset
2364 { int modulus = CodeEntryAlignment;
a61af66fc99e Initial load
duke
parents:
diff changeset
2365 int target = modulus - 5; // 5 = sizeof jmp(L_failed)
a61af66fc99e Initial load
duke
parents:
diff changeset
2366 int advance = target - (__ offset() % modulus);
a61af66fc99e Initial load
duke
parents:
diff changeset
2367 if (advance < 0) advance += modulus;
a61af66fc99e Initial load
duke
parents:
diff changeset
2368 if (advance > 0) __ nop(advance);
a61af66fc99e Initial load
duke
parents:
diff changeset
2369 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2370 StubCodeMark mark(this, "StubRoutines", name);
a61af66fc99e Initial load
duke
parents:
diff changeset
2371
a61af66fc99e Initial load
duke
parents:
diff changeset
2372 // Short-hop target to L_failed. Makes for denser prologue code.
a61af66fc99e Initial load
duke
parents:
diff changeset
2373 __ BIND(L_failed_0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2374 __ jmp(L_failed);
a61af66fc99e Initial load
duke
parents:
diff changeset
2375 assert(__ offset() % CodeEntryAlignment == 0, "no further alignment needed");
a61af66fc99e Initial load
duke
parents:
diff changeset
2376
a61af66fc99e Initial load
duke
parents:
diff changeset
2377 __ align(CodeEntryAlignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
2378 address start = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
2379
a61af66fc99e Initial load
duke
parents:
diff changeset
2380 __ enter(); // required for proper stackwalking of RuntimeStub frame
a61af66fc99e Initial load
duke
parents:
diff changeset
2381
a61af66fc99e Initial load
duke
parents:
diff changeset
2382 // bump this on entry, not on exit:
a61af66fc99e Initial load
duke
parents:
diff changeset
2383 inc_counter_np(SharedRuntime::_generic_array_copy_ctr);
a61af66fc99e Initial load
duke
parents:
diff changeset
2384
a61af66fc99e Initial load
duke
parents:
diff changeset
2385 //-----------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
2386 // Assembler stub will be used for this call to arraycopy
a61af66fc99e Initial load
duke
parents:
diff changeset
2387 // if the following conditions are met:
a61af66fc99e Initial load
duke
parents:
diff changeset
2388 //
a61af66fc99e Initial load
duke
parents:
diff changeset
2389 // (1) src and dst must not be null.
a61af66fc99e Initial load
duke
parents:
diff changeset
2390 // (2) src_pos must not be negative.
a61af66fc99e Initial load
duke
parents:
diff changeset
2391 // (3) dst_pos must not be negative.
a61af66fc99e Initial load
duke
parents:
diff changeset
2392 // (4) length must not be negative.
a61af66fc99e Initial load
duke
parents:
diff changeset
2393 // (5) src klass and dst klass should be the same and not NULL.
a61af66fc99e Initial load
duke
parents:
diff changeset
2394 // (6) src and dst should be arrays.
a61af66fc99e Initial load
duke
parents:
diff changeset
2395 // (7) src_pos + length must not exceed length of src.
a61af66fc99e Initial load
duke
parents:
diff changeset
2396 // (8) dst_pos + length must not exceed length of dst.
a61af66fc99e Initial load
duke
parents:
diff changeset
2397 //
a61af66fc99e Initial load
duke
parents:
diff changeset
2398
a61af66fc99e Initial load
duke
parents:
diff changeset
2399 // if (src == NULL) return -1;
a61af66fc99e Initial load
duke
parents:
diff changeset
2400 __ testq(src, src); // src oop
a61af66fc99e Initial load
duke
parents:
diff changeset
2401 size_t j1off = __ offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
2402 __ jccb(Assembler::zero, L_failed_0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2403
a61af66fc99e Initial load
duke
parents:
diff changeset
2404 // if (src_pos < 0) return -1;
a61af66fc99e Initial load
duke
parents:
diff changeset
2405 __ testl(src_pos, src_pos); // src_pos (32-bits)
a61af66fc99e Initial load
duke
parents:
diff changeset
2406 __ jccb(Assembler::negative, L_failed_0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2407
a61af66fc99e Initial load
duke
parents:
diff changeset
2408 // if (dst == NULL) return -1;
a61af66fc99e Initial load
duke
parents:
diff changeset
2409 __ testq(dst, dst); // dst oop
a61af66fc99e Initial load
duke
parents:
diff changeset
2410 __ jccb(Assembler::zero, L_failed_0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2411
a61af66fc99e Initial load
duke
parents:
diff changeset
2412 // if (dst_pos < 0) return -1;
a61af66fc99e Initial load
duke
parents:
diff changeset
2413 __ testl(dst_pos, dst_pos); // dst_pos (32-bits)
a61af66fc99e Initial load
duke
parents:
diff changeset
2414 size_t j4off = __ offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
2415 __ jccb(Assembler::negative, L_failed_0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2416
a61af66fc99e Initial load
duke
parents:
diff changeset
2417 // The first four tests are very dense code,
a61af66fc99e Initial load
duke
parents:
diff changeset
2418 // but not quite dense enough to put four
a61af66fc99e Initial load
duke
parents:
diff changeset
2419 // jumps in a 16-byte instruction fetch buffer.
a61af66fc99e Initial load
duke
parents:
diff changeset
2420 // That's good, because some branch predicters
a61af66fc99e Initial load
duke
parents:
diff changeset
2421 // do not like jumps so close together.
a61af66fc99e Initial load
duke
parents:
diff changeset
2422 // Make sure of this.
a61af66fc99e Initial load
duke
parents:
diff changeset
2423 guarantee(((j1off ^ j4off) & ~15) != 0, "I$ line of 1st & 4th jumps");
a61af66fc99e Initial load
duke
parents:
diff changeset
2424
a61af66fc99e Initial load
duke
parents:
diff changeset
2425 // registers used as temp
a61af66fc99e Initial load
duke
parents:
diff changeset
2426 const Register r11_length = r11; // elements count to copy
a61af66fc99e Initial load
duke
parents:
diff changeset
2427 const Register r10_src_klass = r10; // array klass
a61af66fc99e Initial load
duke
parents:
diff changeset
2428
a61af66fc99e Initial load
duke
parents:
diff changeset
2429 // if (length < 0) return -1;
a61af66fc99e Initial load
duke
parents:
diff changeset
2430 __ movl(r11_length, C_RARG4); // length (elements count, 32-bits value)
a61af66fc99e Initial load
duke
parents:
diff changeset
2431 __ testl(r11_length, r11_length);
a61af66fc99e Initial load
duke
parents:
diff changeset
2432 __ jccb(Assembler::negative, L_failed_0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2433
a61af66fc99e Initial load
duke
parents:
diff changeset
2434 Address src_klass_addr(src, oopDesc::klass_offset_in_bytes());
a61af66fc99e Initial load
duke
parents:
diff changeset
2435 Address dst_klass_addr(dst, oopDesc::klass_offset_in_bytes());
a61af66fc99e Initial load
duke
parents:
diff changeset
2436 __ movq(r10_src_klass, src_klass_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
2437 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
2438 // assert(src->klass() != NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
2439 BLOCK_COMMENT("assert klasses not null");
a61af66fc99e Initial load
duke
parents:
diff changeset
2440 { Label L1, L2;
a61af66fc99e Initial load
duke
parents:
diff changeset
2441 __ testq(r10_src_klass, r10_src_klass);
a61af66fc99e Initial load
duke
parents:
diff changeset
2442 __ jcc(Assembler::notZero, L2); // it is broken if klass is NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
2443 __ bind(L1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2444 __ stop("broken null klass");
a61af66fc99e Initial load
duke
parents:
diff changeset
2445 __ bind(L2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2446 __ cmpq(dst_klass_addr, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2447 __ jcc(Assembler::equal, L1); // this would be broken also
a61af66fc99e Initial load
duke
parents:
diff changeset
2448 BLOCK_COMMENT("assert done");
a61af66fc99e Initial load
duke
parents:
diff changeset
2449 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2450 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
2451
a61af66fc99e Initial load
duke
parents:
diff changeset
2452 // Load layout helper (32-bits)
a61af66fc99e Initial load
duke
parents:
diff changeset
2453 //
a61af66fc99e Initial load
duke
parents:
diff changeset
2454 // |array_tag| | header_size | element_type | |log2_element_size|
a61af66fc99e Initial load
duke
parents:
diff changeset
2455 // 32 30 24 16 8 2 0
a61af66fc99e Initial load
duke
parents:
diff changeset
2456 //
a61af66fc99e Initial load
duke
parents:
diff changeset
2457 // array_tag: typeArray = 0x3, objArray = 0x2, non-array = 0x0
a61af66fc99e Initial load
duke
parents:
diff changeset
2458 //
a61af66fc99e Initial load
duke
parents:
diff changeset
2459
a61af66fc99e Initial load
duke
parents:
diff changeset
2460 int lh_offset = klassOopDesc::header_size() * HeapWordSize +
a61af66fc99e Initial load
duke
parents:
diff changeset
2461 Klass::layout_helper_offset_in_bytes();
a61af66fc99e Initial load
duke
parents:
diff changeset
2462
a61af66fc99e Initial load
duke
parents:
diff changeset
2463 const Register rax_lh = rax; // layout helper
a61af66fc99e Initial load
duke
parents:
diff changeset
2464
a61af66fc99e Initial load
duke
parents:
diff changeset
2465 __ movl(rax_lh, Address(r10_src_klass, lh_offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
2466
a61af66fc99e Initial load
duke
parents:
diff changeset
2467 // Handle objArrays completely differently...
a61af66fc99e Initial load
duke
parents:
diff changeset
2468 jint objArray_lh = Klass::array_layout_helper(T_OBJECT);
a61af66fc99e Initial load
duke
parents:
diff changeset
2469 __ cmpl(rax_lh, objArray_lh);
a61af66fc99e Initial load
duke
parents:
diff changeset
2470 __ jcc(Assembler::equal, L_objArray);
a61af66fc99e Initial load
duke
parents:
diff changeset
2471
a61af66fc99e Initial load
duke
parents:
diff changeset
2472 // if (src->klass() != dst->klass()) return -1;
a61af66fc99e Initial load
duke
parents:
diff changeset
2473 __ cmpq(r10_src_klass, dst_klass_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
2474 __ jcc(Assembler::notEqual, L_failed);
a61af66fc99e Initial load
duke
parents:
diff changeset
2475
a61af66fc99e Initial load
duke
parents:
diff changeset
2476 // if (!src->is_Array()) return -1;
a61af66fc99e Initial load
duke
parents:
diff changeset
2477 __ cmpl(rax_lh, Klass::_lh_neutral_value);
a61af66fc99e Initial load
duke
parents:
diff changeset
2478 __ jcc(Assembler::greaterEqual, L_failed);
a61af66fc99e Initial load
duke
parents:
diff changeset
2479
a61af66fc99e Initial load
duke
parents:
diff changeset
2480 // At this point, it is known to be a typeArray (array_tag 0x3).
a61af66fc99e Initial load
duke
parents:
diff changeset
2481 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
2482 { Label L;
a61af66fc99e Initial load
duke
parents:
diff changeset
2483 __ cmpl(rax_lh, (Klass::_lh_array_tag_type_value << Klass::_lh_array_tag_shift));
a61af66fc99e Initial load
duke
parents:
diff changeset
2484 __ jcc(Assembler::greaterEqual, L);
a61af66fc99e Initial load
duke
parents:
diff changeset
2485 __ stop("must be a primitive array");
a61af66fc99e Initial load
duke
parents:
diff changeset
2486 __ bind(L);
a61af66fc99e Initial load
duke
parents:
diff changeset
2487 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2488 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
2489
a61af66fc99e Initial load
duke
parents:
diff changeset
2490 arraycopy_range_checks(src, src_pos, dst, dst_pos, r11_length,
a61af66fc99e Initial load
duke
parents:
diff changeset
2491 r10, L_failed);
a61af66fc99e Initial load
duke
parents:
diff changeset
2492
a61af66fc99e Initial load
duke
parents:
diff changeset
2493 // typeArrayKlass
a61af66fc99e Initial load
duke
parents:
diff changeset
2494 //
a61af66fc99e Initial load
duke
parents:
diff changeset
2495 // src_addr = (src + array_header_in_bytes()) + (src_pos << log2elemsize);
a61af66fc99e Initial load
duke
parents:
diff changeset
2496 // dst_addr = (dst + array_header_in_bytes()) + (dst_pos << log2elemsize);
a61af66fc99e Initial load
duke
parents:
diff changeset
2497 //
a61af66fc99e Initial load
duke
parents:
diff changeset
2498
a61af66fc99e Initial load
duke
parents:
diff changeset
2499 const Register r10_offset = r10; // array offset
a61af66fc99e Initial load
duke
parents:
diff changeset
2500 const Register rax_elsize = rax_lh; // element size
a61af66fc99e Initial load
duke
parents:
diff changeset
2501
a61af66fc99e Initial load
duke
parents:
diff changeset
2502 __ movl(r10_offset, rax_lh);
a61af66fc99e Initial load
duke
parents:
diff changeset
2503 __ shrl(r10_offset, Klass::_lh_header_size_shift);
a61af66fc99e Initial load
duke
parents:
diff changeset
2504 __ andq(r10_offset, Klass::_lh_header_size_mask); // array_offset
a61af66fc99e Initial load
duke
parents:
diff changeset
2505 __ addq(src, r10_offset); // src array offset
a61af66fc99e Initial load
duke
parents:
diff changeset
2506 __ addq(dst, r10_offset); // dst array offset
a61af66fc99e Initial load
duke
parents:
diff changeset
2507 BLOCK_COMMENT("choose copy loop based on element size");
a61af66fc99e Initial load
duke
parents:
diff changeset
2508 __ andl(rax_lh, Klass::_lh_log2_element_size_mask); // rax_lh -> rax_elsize
a61af66fc99e Initial load
duke
parents:
diff changeset
2509
a61af66fc99e Initial load
duke
parents:
diff changeset
2510 // next registers should be set before the jump to corresponding stub
a61af66fc99e Initial load
duke
parents:
diff changeset
2511 const Register from = c_rarg0; // source array address
a61af66fc99e Initial load
duke
parents:
diff changeset
2512 const Register to = c_rarg1; // destination array address
a61af66fc99e Initial load
duke
parents:
diff changeset
2513 const Register count = c_rarg2; // elements count
a61af66fc99e Initial load
duke
parents:
diff changeset
2514
a61af66fc99e Initial load
duke
parents:
diff changeset
2515 // 'from', 'to', 'count' registers should be set in such order
a61af66fc99e Initial load
duke
parents:
diff changeset
2516 // since they are the same as 'src', 'src_pos', 'dst'.
a61af66fc99e Initial load
duke
parents:
diff changeset
2517
a61af66fc99e Initial load
duke
parents:
diff changeset
2518 __ BIND(L_copy_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
2519 __ cmpl(rax_elsize, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2520 __ jccb(Assembler::notEqual, L_copy_shorts);
a61af66fc99e Initial load
duke
parents:
diff changeset
2521 __ leaq(from, Address(src, src_pos, Address::times_1, 0));// src_addr
a61af66fc99e Initial load
duke
parents:
diff changeset
2522 __ leaq(to, Address(dst, dst_pos, Address::times_1, 0));// dst_addr
a61af66fc99e Initial load
duke
parents:
diff changeset
2523 __ movslq(count, r11_length); // length
a61af66fc99e Initial load
duke
parents:
diff changeset
2524 __ jump(RuntimeAddress(byte_copy_entry));
a61af66fc99e Initial load
duke
parents:
diff changeset
2525
a61af66fc99e Initial load
duke
parents:
diff changeset
2526 __ BIND(L_copy_shorts);
a61af66fc99e Initial load
duke
parents:
diff changeset
2527 __ cmpl(rax_elsize, LogBytesPerShort);
a61af66fc99e Initial load
duke
parents:
diff changeset
2528 __ jccb(Assembler::notEqual, L_copy_ints);
a61af66fc99e Initial load
duke
parents:
diff changeset
2529 __ leaq(from, Address(src, src_pos, Address::times_2, 0));// src_addr
a61af66fc99e Initial load
duke
parents:
diff changeset
2530 __ leaq(to, Address(dst, dst_pos, Address::times_2, 0));// dst_addr
a61af66fc99e Initial load
duke
parents:
diff changeset
2531 __ movslq(count, r11_length); // length
a61af66fc99e Initial load
duke
parents:
diff changeset
2532 __ jump(RuntimeAddress(short_copy_entry));
a61af66fc99e Initial load
duke
parents:
diff changeset
2533
a61af66fc99e Initial load
duke
parents:
diff changeset
2534 __ BIND(L_copy_ints);
a61af66fc99e Initial load
duke
parents:
diff changeset
2535 __ cmpl(rax_elsize, LogBytesPerInt);
a61af66fc99e Initial load
duke
parents:
diff changeset
2536 __ jccb(Assembler::notEqual, L_copy_longs);
a61af66fc99e Initial load
duke
parents:
diff changeset
2537 __ leaq(from, Address(src, src_pos, Address::times_4, 0));// src_addr
a61af66fc99e Initial load
duke
parents:
diff changeset
2538 __ leaq(to, Address(dst, dst_pos, Address::times_4, 0));// dst_addr
a61af66fc99e Initial load
duke
parents:
diff changeset
2539 __ movslq(count, r11_length); // length
a61af66fc99e Initial load
duke
parents:
diff changeset
2540 __ jump(RuntimeAddress(int_copy_entry));
a61af66fc99e Initial load
duke
parents:
diff changeset
2541
a61af66fc99e Initial load
duke
parents:
diff changeset
2542 __ BIND(L_copy_longs);
a61af66fc99e Initial load
duke
parents:
diff changeset
2543 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
2544 { Label L;
a61af66fc99e Initial load
duke
parents:
diff changeset
2545 __ cmpl(rax_elsize, LogBytesPerLong);
a61af66fc99e Initial load
duke
parents:
diff changeset
2546 __ jcc(Assembler::equal, L);
a61af66fc99e Initial load
duke
parents:
diff changeset
2547 __ stop("must be long copy, but elsize is wrong");
a61af66fc99e Initial load
duke
parents:
diff changeset
2548 __ bind(L);
a61af66fc99e Initial load
duke
parents:
diff changeset
2549 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2550 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
2551 __ leaq(from, Address(src, src_pos, Address::times_8, 0));// src_addr
a61af66fc99e Initial load
duke
parents:
diff changeset
2552 __ leaq(to, Address(dst, dst_pos, Address::times_8, 0));// dst_addr
a61af66fc99e Initial load
duke
parents:
diff changeset
2553 __ movslq(count, r11_length); // length
a61af66fc99e Initial load
duke
parents:
diff changeset
2554 __ jump(RuntimeAddress(long_copy_entry));
a61af66fc99e Initial load
duke
parents:
diff changeset
2555
a61af66fc99e Initial load
duke
parents:
diff changeset
2556 // objArrayKlass
a61af66fc99e Initial load
duke
parents:
diff changeset
2557 __ BIND(L_objArray);
a61af66fc99e Initial load
duke
parents:
diff changeset
2558 // live at this point: r10_src_klass, src[_pos], dst[_pos]
a61af66fc99e Initial load
duke
parents:
diff changeset
2559
a61af66fc99e Initial load
duke
parents:
diff changeset
2560 Label L_plain_copy, L_checkcast_copy;
a61af66fc99e Initial load
duke
parents:
diff changeset
2561 // test array classes for subtyping
a61af66fc99e Initial load
duke
parents:
diff changeset
2562 __ cmpq(r10_src_klass, dst_klass_addr); // usual case is exact equality
a61af66fc99e Initial load
duke
parents:
diff changeset
2563 __ jcc(Assembler::notEqual, L_checkcast_copy);
a61af66fc99e Initial load
duke
parents:
diff changeset
2564
a61af66fc99e Initial load
duke
parents:
diff changeset
2565 // Identically typed arrays can be copied without element-wise checks.
a61af66fc99e Initial load
duke
parents:
diff changeset
2566 arraycopy_range_checks(src, src_pos, dst, dst_pos, r11_length,
a61af66fc99e Initial load
duke
parents:
diff changeset
2567 r10, L_failed);
a61af66fc99e Initial load
duke
parents:
diff changeset
2568
a61af66fc99e Initial load
duke
parents:
diff changeset
2569 __ leaq(from, Address(src, src_pos, Address::times_8,
a61af66fc99e Initial load
duke
parents:
diff changeset
2570 arrayOopDesc::base_offset_in_bytes(T_OBJECT))); // src_addr
a61af66fc99e Initial load
duke
parents:
diff changeset
2571 __ leaq(to, Address(dst, dst_pos, Address::times_8,
a61af66fc99e Initial load
duke
parents:
diff changeset
2572 arrayOopDesc::base_offset_in_bytes(T_OBJECT))); // dst_addr
a61af66fc99e Initial load
duke
parents:
diff changeset
2573 __ movslq(count, r11_length); // length
a61af66fc99e Initial load
duke
parents:
diff changeset
2574 __ BIND(L_plain_copy);
a61af66fc99e Initial load
duke
parents:
diff changeset
2575 __ jump(RuntimeAddress(oop_copy_entry));
a61af66fc99e Initial load
duke
parents:
diff changeset
2576
a61af66fc99e Initial load
duke
parents:
diff changeset
2577 __ BIND(L_checkcast_copy);
a61af66fc99e Initial load
duke
parents:
diff changeset
2578 // live at this point: r10_src_klass, !r11_length
a61af66fc99e Initial load
duke
parents:
diff changeset
2579 {
a61af66fc99e Initial load
duke
parents:
diff changeset
2580 // assert(r11_length == C_RARG4); // will reload from here
a61af66fc99e Initial load
duke
parents:
diff changeset
2581 Register r11_dst_klass = r11;
a61af66fc99e Initial load
duke
parents:
diff changeset
2582 __ movq(r11_dst_klass, dst_klass_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
2583
a61af66fc99e Initial load
duke
parents:
diff changeset
2584 // Before looking at dst.length, make sure dst is also an objArray.
a61af66fc99e Initial load
duke
parents:
diff changeset
2585 __ cmpl(Address(r11_dst_klass, lh_offset), objArray_lh);
a61af66fc99e Initial load
duke
parents:
diff changeset
2586 __ jcc(Assembler::notEqual, L_failed);
a61af66fc99e Initial load
duke
parents:
diff changeset
2587
a61af66fc99e Initial load
duke
parents:
diff changeset
2588 // It is safe to examine both src.length and dst.length.
a61af66fc99e Initial load
duke
parents:
diff changeset
2589 #ifndef _WIN64
a61af66fc99e Initial load
duke
parents:
diff changeset
2590 arraycopy_range_checks(src, src_pos, dst, dst_pos, C_RARG4,
a61af66fc99e Initial load
duke
parents:
diff changeset
2591 rax, L_failed);
a61af66fc99e Initial load
duke
parents:
diff changeset
2592 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
2593 __ movl(r11_length, C_RARG4); // reload
a61af66fc99e Initial load
duke
parents:
diff changeset
2594 arraycopy_range_checks(src, src_pos, dst, dst_pos, r11_length,
a61af66fc99e Initial load
duke
parents:
diff changeset
2595 rax, L_failed);
a61af66fc99e Initial load
duke
parents:
diff changeset
2596 __ movl(r11_dst_klass, dst_klass_addr); // reload
a61af66fc99e Initial load
duke
parents:
diff changeset
2597 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
2598
a61af66fc99e Initial load
duke
parents:
diff changeset
2599 // Marshal the base address arguments now, freeing registers.
a61af66fc99e Initial load
duke
parents:
diff changeset
2600 __ leaq(from, Address(src, src_pos, Address::times_8,
a61af66fc99e Initial load
duke
parents:
diff changeset
2601 arrayOopDesc::base_offset_in_bytes(T_OBJECT)));
a61af66fc99e Initial load
duke
parents:
diff changeset
2602 __ leaq(to, Address(dst, dst_pos, Address::times_8,
a61af66fc99e Initial load
duke
parents:
diff changeset
2603 arrayOopDesc::base_offset_in_bytes(T_OBJECT)));
a61af66fc99e Initial load
duke
parents:
diff changeset
2604 __ movl(count, C_RARG4); // length (reloaded)
a61af66fc99e Initial load
duke
parents:
diff changeset
2605 Register sco_temp = c_rarg3; // this register is free now
a61af66fc99e Initial load
duke
parents:
diff changeset
2606 assert_different_registers(from, to, count, sco_temp,
a61af66fc99e Initial load
duke
parents:
diff changeset
2607 r11_dst_klass, r10_src_klass);
a61af66fc99e Initial load
duke
parents:
diff changeset
2608 assert_clean_int(count, sco_temp);
a61af66fc99e Initial load
duke
parents:
diff changeset
2609
a61af66fc99e Initial load
duke
parents:
diff changeset
2610 // Generate the type check.
a61af66fc99e Initial load
duke
parents:
diff changeset
2611 int sco_offset = (klassOopDesc::header_size() * HeapWordSize +
a61af66fc99e Initial load
duke
parents:
diff changeset
2612 Klass::super_check_offset_offset_in_bytes());
a61af66fc99e Initial load
duke
parents:
diff changeset
2613 __ movl(sco_temp, Address(r11_dst_klass, sco_offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
2614 assert_clean_int(sco_temp, rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
2615 generate_type_check(r10_src_klass, sco_temp, r11_dst_klass, L_plain_copy);
a61af66fc99e Initial load
duke
parents:
diff changeset
2616
a61af66fc99e Initial load
duke
parents:
diff changeset
2617 // Fetch destination element klass from the objArrayKlass header.
a61af66fc99e Initial load
duke
parents:
diff changeset
2618 int ek_offset = (klassOopDesc::header_size() * HeapWordSize +
a61af66fc99e Initial load
duke
parents:
diff changeset
2619 objArrayKlass::element_klass_offset_in_bytes());
a61af66fc99e Initial load
duke
parents:
diff changeset
2620 __ movq(r11_dst_klass, Address(r11_dst_klass, ek_offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
2621 __ movl(sco_temp, Address(r11_dst_klass, sco_offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
2622 assert_clean_int(sco_temp, rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
2623
a61af66fc99e Initial load
duke
parents:
diff changeset
2624 // the checkcast_copy loop needs two extra arguments:
a61af66fc99e Initial load
duke
parents:
diff changeset
2625 assert(c_rarg3 == sco_temp, "#3 already in place");
a61af66fc99e Initial load
duke
parents:
diff changeset
2626 __ movq(C_RARG4, r11_dst_klass); // dst.klass.element_klass
a61af66fc99e Initial load
duke
parents:
diff changeset
2627 __ jump(RuntimeAddress(checkcast_copy_entry));
a61af66fc99e Initial load
duke
parents:
diff changeset
2628 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2629
a61af66fc99e Initial load
duke
parents:
diff changeset
2630 __ BIND(L_failed);
a61af66fc99e Initial load
duke
parents:
diff changeset
2631 __ xorq(rax, rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
2632 __ notq(rax); // return -1
a61af66fc99e Initial load
duke
parents:
diff changeset
2633 __ leave(); // required for proper stackwalking of RuntimeStub frame
a61af66fc99e Initial load
duke
parents:
diff changeset
2634 __ ret(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2635
a61af66fc99e Initial load
duke
parents:
diff changeset
2636 return start;
a61af66fc99e Initial load
duke
parents:
diff changeset
2637 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2638
a61af66fc99e Initial load
duke
parents:
diff changeset
2639 #undef length_arg
a61af66fc99e Initial load
duke
parents:
diff changeset
2640
a61af66fc99e Initial load
duke
parents:
diff changeset
2641 void generate_arraycopy_stubs() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2642 // Call the conjoint generation methods immediately after
a61af66fc99e Initial load
duke
parents:
diff changeset
2643 // the disjoint ones so that short branches from the former
a61af66fc99e Initial load
duke
parents:
diff changeset
2644 // to the latter can be generated.
a61af66fc99e Initial load
duke
parents:
diff changeset
2645 StubRoutines::_jbyte_disjoint_arraycopy = generate_disjoint_byte_copy(false, "jbyte_disjoint_arraycopy");
a61af66fc99e Initial load
duke
parents:
diff changeset
2646 StubRoutines::_jbyte_arraycopy = generate_conjoint_byte_copy(false, "jbyte_arraycopy");
a61af66fc99e Initial load
duke
parents:
diff changeset
2647
a61af66fc99e Initial load
duke
parents:
diff changeset
2648 StubRoutines::_jshort_disjoint_arraycopy = generate_disjoint_short_copy(false, "jshort_disjoint_arraycopy");
a61af66fc99e Initial load
duke
parents:
diff changeset
2649 StubRoutines::_jshort_arraycopy = generate_conjoint_short_copy(false, "jshort_arraycopy");
a61af66fc99e Initial load
duke
parents:
diff changeset
2650
a61af66fc99e Initial load
duke
parents:
diff changeset
2651 StubRoutines::_jint_disjoint_arraycopy = generate_disjoint_int_copy(false, "jint_disjoint_arraycopy");
a61af66fc99e Initial load
duke
parents:
diff changeset
2652 StubRoutines::_jint_arraycopy = generate_conjoint_int_copy(false, "jint_arraycopy");
a61af66fc99e Initial load
duke
parents:
diff changeset
2653
a61af66fc99e Initial load
duke
parents:
diff changeset
2654 StubRoutines::_jlong_disjoint_arraycopy = generate_disjoint_long_oop_copy(false, false, "jlong_disjoint_arraycopy");
a61af66fc99e Initial load
duke
parents:
diff changeset
2655 StubRoutines::_jlong_arraycopy = generate_conjoint_long_oop_copy(false, false, "jlong_arraycopy");
a61af66fc99e Initial load
duke
parents:
diff changeset
2656
a61af66fc99e Initial load
duke
parents:
diff changeset
2657 StubRoutines::_oop_disjoint_arraycopy = generate_disjoint_long_oop_copy(false, true, "oop_disjoint_arraycopy");
a61af66fc99e Initial load
duke
parents:
diff changeset
2658 StubRoutines::_oop_arraycopy = generate_conjoint_long_oop_copy(false, true, "oop_arraycopy");
a61af66fc99e Initial load
duke
parents:
diff changeset
2659
a61af66fc99e Initial load
duke
parents:
diff changeset
2660 StubRoutines::_checkcast_arraycopy = generate_checkcast_copy("checkcast_arraycopy");
a61af66fc99e Initial load
duke
parents:
diff changeset
2661 StubRoutines::_unsafe_arraycopy = generate_unsafe_copy("unsafe_arraycopy");
a61af66fc99e Initial load
duke
parents:
diff changeset
2662 StubRoutines::_generic_arraycopy = generate_generic_copy("generic_arraycopy");
a61af66fc99e Initial load
duke
parents:
diff changeset
2663
a61af66fc99e Initial load
duke
parents:
diff changeset
2664 // We don't generate specialized code for HeapWord-aligned source
a61af66fc99e Initial load
duke
parents:
diff changeset
2665 // arrays, so just use the code we've already generated
a61af66fc99e Initial load
duke
parents:
diff changeset
2666 StubRoutines::_arrayof_jbyte_disjoint_arraycopy = StubRoutines::_jbyte_disjoint_arraycopy;
a61af66fc99e Initial load
duke
parents:
diff changeset
2667 StubRoutines::_arrayof_jbyte_arraycopy = StubRoutines::_jbyte_arraycopy;
a61af66fc99e Initial load
duke
parents:
diff changeset
2668
a61af66fc99e Initial load
duke
parents:
diff changeset
2669 StubRoutines::_arrayof_jshort_disjoint_arraycopy = StubRoutines::_jshort_disjoint_arraycopy;
a61af66fc99e Initial load
duke
parents:
diff changeset
2670 StubRoutines::_arrayof_jshort_arraycopy = StubRoutines::_jshort_arraycopy;
a61af66fc99e Initial load
duke
parents:
diff changeset
2671
a61af66fc99e Initial load
duke
parents:
diff changeset
2672 StubRoutines::_arrayof_jint_disjoint_arraycopy = StubRoutines::_jint_disjoint_arraycopy;
a61af66fc99e Initial load
duke
parents:
diff changeset
2673 StubRoutines::_arrayof_jint_arraycopy = StubRoutines::_jint_arraycopy;
a61af66fc99e Initial load
duke
parents:
diff changeset
2674
a61af66fc99e Initial load
duke
parents:
diff changeset
2675 StubRoutines::_arrayof_jlong_disjoint_arraycopy = StubRoutines::_jlong_disjoint_arraycopy;
a61af66fc99e Initial load
duke
parents:
diff changeset
2676 StubRoutines::_arrayof_jlong_arraycopy = StubRoutines::_jlong_arraycopy;
a61af66fc99e Initial load
duke
parents:
diff changeset
2677
a61af66fc99e Initial load
duke
parents:
diff changeset
2678 StubRoutines::_arrayof_oop_disjoint_arraycopy = StubRoutines::_oop_disjoint_arraycopy;
a61af66fc99e Initial load
duke
parents:
diff changeset
2679 StubRoutines::_arrayof_oop_arraycopy = StubRoutines::_oop_arraycopy;
a61af66fc99e Initial load
duke
parents:
diff changeset
2680 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2681
a61af66fc99e Initial load
duke
parents:
diff changeset
2682 #undef __
a61af66fc99e Initial load
duke
parents:
diff changeset
2683 #define __ masm->
a61af66fc99e Initial load
duke
parents:
diff changeset
2684
a61af66fc99e Initial load
duke
parents:
diff changeset
2685 // Continuation point for throwing of implicit exceptions that are
a61af66fc99e Initial load
duke
parents:
diff changeset
2686 // not handled in the current activation. Fabricates an exception
a61af66fc99e Initial load
duke
parents:
diff changeset
2687 // oop and initiates normal exception dispatching in this
a61af66fc99e Initial load
duke
parents:
diff changeset
2688 // frame. Since we need to preserve callee-saved values (currently
a61af66fc99e Initial load
duke
parents:
diff changeset
2689 // only for C2, but done for C1 as well) we need a callee-saved oop
a61af66fc99e Initial load
duke
parents:
diff changeset
2690 // map and therefore have to make these stubs into RuntimeStubs
a61af66fc99e Initial load
duke
parents:
diff changeset
2691 // rather than BufferBlobs. If the compiler needs all registers to
a61af66fc99e Initial load
duke
parents:
diff changeset
2692 // be preserved between the fault point and the exception handler
a61af66fc99e Initial load
duke
parents:
diff changeset
2693 // then it must assume responsibility for that in
a61af66fc99e Initial load
duke
parents:
diff changeset
2694 // AbstractCompiler::continuation_for_implicit_null_exception or
a61af66fc99e Initial load
duke
parents:
diff changeset
2695 // continuation_for_implicit_division_by_zero_exception. All other
a61af66fc99e Initial load
duke
parents:
diff changeset
2696 // implicit exceptions (e.g., NullPointerException or
a61af66fc99e Initial load
duke
parents:
diff changeset
2697 // AbstractMethodError on entry) are either at call sites or
a61af66fc99e Initial load
duke
parents:
diff changeset
2698 // otherwise assume that stack unwinding will be initiated, so
a61af66fc99e Initial load
duke
parents:
diff changeset
2699 // caller saved registers were assumed volatile in the compiler.
a61af66fc99e Initial load
duke
parents:
diff changeset
2700 address generate_throw_exception(const char* name,
a61af66fc99e Initial load
duke
parents:
diff changeset
2701 address runtime_entry,
a61af66fc99e Initial load
duke
parents:
diff changeset
2702 bool restore_saved_exception_pc) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2703 // Information about frame layout at time of blocking runtime call.
a61af66fc99e Initial load
duke
parents:
diff changeset
2704 // Note that we only have to preserve callee-saved registers since
a61af66fc99e Initial load
duke
parents:
diff changeset
2705 // the compilers are responsible for supplying a continuation point
a61af66fc99e Initial load
duke
parents:
diff changeset
2706 // if they expect all registers to be preserved.
a61af66fc99e Initial load
duke
parents:
diff changeset
2707 enum layout {
a61af66fc99e Initial load
duke
parents:
diff changeset
2708 rbp_off = frame::arg_reg_save_area_bytes/BytesPerInt,
a61af66fc99e Initial load
duke
parents:
diff changeset
2709 rbp_off2,
a61af66fc99e Initial load
duke
parents:
diff changeset
2710 return_off,
a61af66fc99e Initial load
duke
parents:
diff changeset
2711 return_off2,
a61af66fc99e Initial load
duke
parents:
diff changeset
2712 framesize // inclusive of return address
a61af66fc99e Initial load
duke
parents:
diff changeset
2713 };
a61af66fc99e Initial load
duke
parents:
diff changeset
2714
a61af66fc99e Initial load
duke
parents:
diff changeset
2715 int insts_size = 512;
a61af66fc99e Initial load
duke
parents:
diff changeset
2716 int locs_size = 64;
a61af66fc99e Initial load
duke
parents:
diff changeset
2717
a61af66fc99e Initial load
duke
parents:
diff changeset
2718 CodeBuffer code(name, insts_size, locs_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
2719 OopMapSet* oop_maps = new OopMapSet();
a61af66fc99e Initial load
duke
parents:
diff changeset
2720 MacroAssembler* masm = new MacroAssembler(&code);
a61af66fc99e Initial load
duke
parents:
diff changeset
2721
a61af66fc99e Initial load
duke
parents:
diff changeset
2722 address start = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
2723
a61af66fc99e Initial load
duke
parents:
diff changeset
2724 // This is an inlined and slightly modified version of call_VM
a61af66fc99e Initial load
duke
parents:
diff changeset
2725 // which has the ability to fetch the return PC out of
a61af66fc99e Initial load
duke
parents:
diff changeset
2726 // thread-local storage and also sets up last_Java_sp slightly
a61af66fc99e Initial load
duke
parents:
diff changeset
2727 // differently than the real call_VM
a61af66fc99e Initial load
duke
parents:
diff changeset
2728 if (restore_saved_exception_pc) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2729 __ movq(rax,
a61af66fc99e Initial load
duke
parents:
diff changeset
2730 Address(r15_thread,
a61af66fc99e Initial load
duke
parents:
diff changeset
2731 in_bytes(JavaThread::saved_exception_pc_offset())));
a61af66fc99e Initial load
duke
parents:
diff changeset
2732 __ pushq(rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
2733 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2734
a61af66fc99e Initial load
duke
parents:
diff changeset
2735 __ enter(); // required for proper stackwalking of RuntimeStub frame
a61af66fc99e Initial load
duke
parents:
diff changeset
2736
a61af66fc99e Initial load
duke
parents:
diff changeset
2737 assert(is_even(framesize/2), "sp not 16-byte aligned");
a61af66fc99e Initial load
duke
parents:
diff changeset
2738
a61af66fc99e Initial load
duke
parents:
diff changeset
2739 // return address and rbp are already in place
a61af66fc99e Initial load
duke
parents:
diff changeset
2740 __ subq(rsp, (framesize-4) << LogBytesPerInt); // prolog
a61af66fc99e Initial load
duke
parents:
diff changeset
2741
a61af66fc99e Initial load
duke
parents:
diff changeset
2742 int frame_complete = __ pc() - start;
a61af66fc99e Initial load
duke
parents:
diff changeset
2743
a61af66fc99e Initial load
duke
parents:
diff changeset
2744 // Set up last_Java_sp and last_Java_fp
a61af66fc99e Initial load
duke
parents:
diff changeset
2745 __ set_last_Java_frame(rsp, rbp, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
2746
a61af66fc99e Initial load
duke
parents:
diff changeset
2747 // Call runtime
a61af66fc99e Initial load
duke
parents:
diff changeset
2748 __ movq(c_rarg0, r15_thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
2749 BLOCK_COMMENT("call runtime_entry");
a61af66fc99e Initial load
duke
parents:
diff changeset
2750 __ call(RuntimeAddress(runtime_entry));
a61af66fc99e Initial load
duke
parents:
diff changeset
2751
a61af66fc99e Initial load
duke
parents:
diff changeset
2752 // Generate oop map
a61af66fc99e Initial load
duke
parents:
diff changeset
2753 OopMap* map = new OopMap(framesize, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2754
a61af66fc99e Initial load
duke
parents:
diff changeset
2755 oop_maps->add_gc_map(__ pc() - start, map);
a61af66fc99e Initial load
duke
parents:
diff changeset
2756
a61af66fc99e Initial load
duke
parents:
diff changeset
2757 __ reset_last_Java_frame(true, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
2758
a61af66fc99e Initial load
duke
parents:
diff changeset
2759 __ leave(); // required for proper stackwalking of RuntimeStub frame
a61af66fc99e Initial load
duke
parents:
diff changeset
2760
a61af66fc99e Initial load
duke
parents:
diff changeset
2761 // check for pending exceptions
a61af66fc99e Initial load
duke
parents:
diff changeset
2762 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
2763 Label L;
a61af66fc99e Initial load
duke
parents:
diff changeset
2764 __ cmpq(Address(r15_thread, Thread::pending_exception_offset()),
a61af66fc99e Initial load
duke
parents:
diff changeset
2765 (int) NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
2766 __ jcc(Assembler::notEqual, L);
a61af66fc99e Initial load
duke
parents:
diff changeset
2767 __ should_not_reach_here();
a61af66fc99e Initial load
duke
parents:
diff changeset
2768 __ bind(L);
a61af66fc99e Initial load
duke
parents:
diff changeset
2769 #endif // ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
2770 __ jump(RuntimeAddress(StubRoutines::forward_exception_entry()));
a61af66fc99e Initial load
duke
parents:
diff changeset
2771
a61af66fc99e Initial load
duke
parents:
diff changeset
2772
a61af66fc99e Initial load
duke
parents:
diff changeset
2773 // codeBlob framesize is in words (not VMRegImpl::slot_size)
a61af66fc99e Initial load
duke
parents:
diff changeset
2774 RuntimeStub* stub =
a61af66fc99e Initial load
duke
parents:
diff changeset
2775 RuntimeStub::new_runtime_stub(name,
a61af66fc99e Initial load
duke
parents:
diff changeset
2776 &code,
a61af66fc99e Initial load
duke
parents:
diff changeset
2777 frame_complete,
a61af66fc99e Initial load
duke
parents:
diff changeset
2778 (framesize >> (LogBytesPerWord - LogBytesPerInt)),
a61af66fc99e Initial load
duke
parents:
diff changeset
2779 oop_maps, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
2780 return stub->entry_point();
a61af66fc99e Initial load
duke
parents:
diff changeset
2781 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2782
a61af66fc99e Initial load
duke
parents:
diff changeset
2783 // Initialization
a61af66fc99e Initial load
duke
parents:
diff changeset
2784 void generate_initial() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2785 // Generates all stubs and initializes the entry points
a61af66fc99e Initial load
duke
parents:
diff changeset
2786
a61af66fc99e Initial load
duke
parents:
diff changeset
2787 // This platform-specific stub is needed by generate_call_stub()
a61af66fc99e Initial load
duke
parents:
diff changeset
2788 StubRoutines::amd64::_mxcsr_std = generate_fp_mask("mxcsr_std", 0x0000000000001F80);
a61af66fc99e Initial load
duke
parents:
diff changeset
2789
a61af66fc99e Initial load
duke
parents:
diff changeset
2790 // entry points that exist in all platforms Note: This is code
a61af66fc99e Initial load
duke
parents:
diff changeset
2791 // that could be shared among different platforms - however the
a61af66fc99e Initial load
duke
parents:
diff changeset
2792 // benefit seems to be smaller than the disadvantage of having a
a61af66fc99e Initial load
duke
parents:
diff changeset
2793 // much more complicated generator structure. See also comment in
a61af66fc99e Initial load
duke
parents:
diff changeset
2794 // stubRoutines.hpp.
a61af66fc99e Initial load
duke
parents:
diff changeset
2795
a61af66fc99e Initial load
duke
parents:
diff changeset
2796 StubRoutines::_forward_exception_entry = generate_forward_exception();
a61af66fc99e Initial load
duke
parents:
diff changeset
2797
a61af66fc99e Initial load
duke
parents:
diff changeset
2798 StubRoutines::_call_stub_entry =
a61af66fc99e Initial load
duke
parents:
diff changeset
2799 generate_call_stub(StubRoutines::_call_stub_return_address);
a61af66fc99e Initial load
duke
parents:
diff changeset
2800
a61af66fc99e Initial load
duke
parents:
diff changeset
2801 // is referenced by megamorphic call
a61af66fc99e Initial load
duke
parents:
diff changeset
2802 StubRoutines::_catch_exception_entry = generate_catch_exception();
a61af66fc99e Initial load
duke
parents:
diff changeset
2803
a61af66fc99e Initial load
duke
parents:
diff changeset
2804 // atomic calls
a61af66fc99e Initial load
duke
parents:
diff changeset
2805 StubRoutines::_atomic_xchg_entry = generate_atomic_xchg();
a61af66fc99e Initial load
duke
parents:
diff changeset
2806 StubRoutines::_atomic_xchg_ptr_entry = generate_atomic_xchg_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
2807 StubRoutines::_atomic_cmpxchg_entry = generate_atomic_cmpxchg();
a61af66fc99e Initial load
duke
parents:
diff changeset
2808 StubRoutines::_atomic_cmpxchg_long_entry = generate_atomic_cmpxchg_long();
a61af66fc99e Initial load
duke
parents:
diff changeset
2809 StubRoutines::_atomic_add_entry = generate_atomic_add();
a61af66fc99e Initial load
duke
parents:
diff changeset
2810 StubRoutines::_atomic_add_ptr_entry = generate_atomic_add_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
2811 StubRoutines::_fence_entry = generate_orderaccess_fence();
a61af66fc99e Initial load
duke
parents:
diff changeset
2812
a61af66fc99e Initial load
duke
parents:
diff changeset
2813 StubRoutines::_handler_for_unsafe_access_entry =
a61af66fc99e Initial load
duke
parents:
diff changeset
2814 generate_handler_for_unsafe_access();
a61af66fc99e Initial load
duke
parents:
diff changeset
2815
a61af66fc99e Initial load
duke
parents:
diff changeset
2816 // platform dependent
a61af66fc99e Initial load
duke
parents:
diff changeset
2817 StubRoutines::amd64::_get_previous_fp_entry = generate_get_previous_fp();
a61af66fc99e Initial load
duke
parents:
diff changeset
2818
a61af66fc99e Initial load
duke
parents:
diff changeset
2819 StubRoutines::amd64::_verify_mxcsr_entry = generate_verify_mxcsr();
a61af66fc99e Initial load
duke
parents:
diff changeset
2820 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2821
a61af66fc99e Initial load
duke
parents:
diff changeset
2822 void generate_all() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2823 // Generates all stubs and initializes the entry points
a61af66fc99e Initial load
duke
parents:
diff changeset
2824
a61af66fc99e Initial load
duke
parents:
diff changeset
2825 // These entry points require SharedInfo::stack0 to be set up in
a61af66fc99e Initial load
duke
parents:
diff changeset
2826 // non-core builds and need to be relocatable, so they each
a61af66fc99e Initial load
duke
parents:
diff changeset
2827 // fabricate a RuntimeStub internally.
a61af66fc99e Initial load
duke
parents:
diff changeset
2828 StubRoutines::_throw_AbstractMethodError_entry =
a61af66fc99e Initial load
duke
parents:
diff changeset
2829 generate_throw_exception("AbstractMethodError throw_exception",
a61af66fc99e Initial load
duke
parents:
diff changeset
2830 CAST_FROM_FN_PTR(address,
a61af66fc99e Initial load
duke
parents:
diff changeset
2831 SharedRuntime::
a61af66fc99e Initial load
duke
parents:
diff changeset
2832 throw_AbstractMethodError),
a61af66fc99e Initial load
duke
parents:
diff changeset
2833 false);
a61af66fc99e Initial load
duke
parents:
diff changeset
2834
16
f8236e79048a 6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents: 0
diff changeset
2835 StubRoutines::_throw_IncompatibleClassChangeError_entry =
f8236e79048a 6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents: 0
diff changeset
2836 generate_throw_exception("IncompatibleClassChangeError throw_exception",
f8236e79048a 6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents: 0
diff changeset
2837 CAST_FROM_FN_PTR(address,
f8236e79048a 6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents: 0
diff changeset
2838 SharedRuntime::
f8236e79048a 6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents: 0
diff changeset
2839 throw_IncompatibleClassChangeError),
f8236e79048a 6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents: 0
diff changeset
2840 false);
f8236e79048a 6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents: 0
diff changeset
2841
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2842 StubRoutines::_throw_ArithmeticException_entry =
a61af66fc99e Initial load
duke
parents:
diff changeset
2843 generate_throw_exception("ArithmeticException throw_exception",
a61af66fc99e Initial load
duke
parents:
diff changeset
2844 CAST_FROM_FN_PTR(address,
a61af66fc99e Initial load
duke
parents:
diff changeset
2845 SharedRuntime::
a61af66fc99e Initial load
duke
parents:
diff changeset
2846 throw_ArithmeticException),
a61af66fc99e Initial load
duke
parents:
diff changeset
2847 true);
a61af66fc99e Initial load
duke
parents:
diff changeset
2848
a61af66fc99e Initial load
duke
parents:
diff changeset
2849 StubRoutines::_throw_NullPointerException_entry =
a61af66fc99e Initial load
duke
parents:
diff changeset
2850 generate_throw_exception("NullPointerException throw_exception",
a61af66fc99e Initial load
duke
parents:
diff changeset
2851 CAST_FROM_FN_PTR(address,
a61af66fc99e Initial load
duke
parents:
diff changeset
2852 SharedRuntime::
a61af66fc99e Initial load
duke
parents:
diff changeset
2853 throw_NullPointerException),
a61af66fc99e Initial load
duke
parents:
diff changeset
2854 true);
a61af66fc99e Initial load
duke
parents:
diff changeset
2855
a61af66fc99e Initial load
duke
parents:
diff changeset
2856 StubRoutines::_throw_NullPointerException_at_call_entry =
a61af66fc99e Initial load
duke
parents:
diff changeset
2857 generate_throw_exception("NullPointerException at call throw_exception",
a61af66fc99e Initial load
duke
parents:
diff changeset
2858 CAST_FROM_FN_PTR(address,
a61af66fc99e Initial load
duke
parents:
diff changeset
2859 SharedRuntime::
a61af66fc99e Initial load
duke
parents:
diff changeset
2860 throw_NullPointerException_at_call),
a61af66fc99e Initial load
duke
parents:
diff changeset
2861 false);
a61af66fc99e Initial load
duke
parents:
diff changeset
2862
a61af66fc99e Initial load
duke
parents:
diff changeset
2863 StubRoutines::_throw_StackOverflowError_entry =
a61af66fc99e Initial load
duke
parents:
diff changeset
2864 generate_throw_exception("StackOverflowError throw_exception",
a61af66fc99e Initial load
duke
parents:
diff changeset
2865 CAST_FROM_FN_PTR(address,
a61af66fc99e Initial load
duke
parents:
diff changeset
2866 SharedRuntime::
a61af66fc99e Initial load
duke
parents:
diff changeset
2867 throw_StackOverflowError),
a61af66fc99e Initial load
duke
parents:
diff changeset
2868 false);
a61af66fc99e Initial load
duke
parents:
diff changeset
2869
a61af66fc99e Initial load
duke
parents:
diff changeset
2870 // entry points that are platform specific
a61af66fc99e Initial load
duke
parents:
diff changeset
2871 StubRoutines::amd64::_f2i_fixup = generate_f2i_fixup();
a61af66fc99e Initial load
duke
parents:
diff changeset
2872 StubRoutines::amd64::_f2l_fixup = generate_f2l_fixup();
a61af66fc99e Initial load
duke
parents:
diff changeset
2873 StubRoutines::amd64::_d2i_fixup = generate_d2i_fixup();
a61af66fc99e Initial load
duke
parents:
diff changeset
2874 StubRoutines::amd64::_d2l_fixup = generate_d2l_fixup();
a61af66fc99e Initial load
duke
parents:
diff changeset
2875
a61af66fc99e Initial load
duke
parents:
diff changeset
2876 StubRoutines::amd64::_float_sign_mask = generate_fp_mask("float_sign_mask", 0x7FFFFFFF7FFFFFFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
2877 StubRoutines::amd64::_float_sign_flip = generate_fp_mask("float_sign_flip", 0x8000000080000000);
a61af66fc99e Initial load
duke
parents:
diff changeset
2878 StubRoutines::amd64::_double_sign_mask = generate_fp_mask("double_sign_mask", 0x7FFFFFFFFFFFFFFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
2879 StubRoutines::amd64::_double_sign_flip = generate_fp_mask("double_sign_flip", 0x8000000000000000);
a61af66fc99e Initial load
duke
parents:
diff changeset
2880
a61af66fc99e Initial load
duke
parents:
diff changeset
2881 // support for verify_oop (must happen after universe_init)
a61af66fc99e Initial load
duke
parents:
diff changeset
2882 StubRoutines::_verify_oop_subroutine_entry = generate_verify_oop();
a61af66fc99e Initial load
duke
parents:
diff changeset
2883
a61af66fc99e Initial load
duke
parents:
diff changeset
2884 // arraycopy stubs used by compilers
a61af66fc99e Initial load
duke
parents:
diff changeset
2885 generate_arraycopy_stubs();
a61af66fc99e Initial load
duke
parents:
diff changeset
2886 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2887
a61af66fc99e Initial load
duke
parents:
diff changeset
2888 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
2889 StubGenerator(CodeBuffer* code, bool all) : StubCodeGenerator(code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2890 if (all) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2891 generate_all();
a61af66fc99e Initial load
duke
parents:
diff changeset
2892 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2893 generate_initial();
a61af66fc99e Initial load
duke
parents:
diff changeset
2894 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2895 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2896 }; // end class declaration
a61af66fc99e Initial load
duke
parents:
diff changeset
2897
a61af66fc99e Initial load
duke
parents:
diff changeset
2898 address StubGenerator::disjoint_byte_copy_entry = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
2899 address StubGenerator::disjoint_short_copy_entry = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
2900 address StubGenerator::disjoint_int_copy_entry = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
2901 address StubGenerator::disjoint_long_copy_entry = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
2902 address StubGenerator::disjoint_oop_copy_entry = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
2903
a61af66fc99e Initial load
duke
parents:
diff changeset
2904 address StubGenerator::byte_copy_entry = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
2905 address StubGenerator::short_copy_entry = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
2906 address StubGenerator::int_copy_entry = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
2907 address StubGenerator::long_copy_entry = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
2908 address StubGenerator::oop_copy_entry = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
2909
a61af66fc99e Initial load
duke
parents:
diff changeset
2910 address StubGenerator::checkcast_copy_entry = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
2911
a61af66fc99e Initial load
duke
parents:
diff changeset
2912 void StubGenerator_generate(CodeBuffer* code, bool all) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2913 StubGenerator g(code, all);
a61af66fc99e Initial load
duke
parents:
diff changeset
2914 }