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