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