Mercurial > hg > truffle
comparison src/cpu/x86/vm/stubGenerator_x86_32.cpp @ 304:dc7f315e41f7
5108146: Merge i486 and amd64 cpu directories
6459804: Want client (c1) compiler for x86_64 (amd64) for faster start-up
Reviewed-by: kvn
author | never |
---|---|
date | Wed, 27 Aug 2008 00:21:55 -0700 |
parents | 910a4cb98e9e |
children | 9ee9cf798b59 f8199438385b |
comparison
equal
deleted
inserted
replaced
303:fa4d1d240383 | 304:dc7f315e41f7 |
---|---|
28 // Declaration and definition of StubGenerator (no .hpp file). | 28 // Declaration and definition of StubGenerator (no .hpp file). |
29 // For a more detailed description of the stub routine structure | 29 // For a more detailed description of the stub routine structure |
30 // see the comment in stubRoutines.hpp | 30 // see the comment in stubRoutines.hpp |
31 | 31 |
32 #define __ _masm-> | 32 #define __ _masm-> |
33 #define a__ ((Assembler*)_masm)-> | |
33 | 34 |
34 #ifdef PRODUCT | 35 #ifdef PRODUCT |
35 #define BLOCK_COMMENT(str) /* nothing */ | 36 #define BLOCK_COMMENT(str) /* nothing */ |
36 #else | 37 #else |
37 #define BLOCK_COMMENT(str) __ block_comment(str) | 38 #define BLOCK_COMMENT(str) __ block_comment(str) |
65 | 66 |
66 #ifdef PRODUCT | 67 #ifdef PRODUCT |
67 #define inc_counter_np(counter) (0) | 68 #define inc_counter_np(counter) (0) |
68 #else | 69 #else |
69 void inc_counter_np_(int& counter) { | 70 void inc_counter_np_(int& counter) { |
70 __ increment(ExternalAddress((address)&counter)); | 71 __ incrementl(ExternalAddress((address)&counter)); |
71 } | 72 } |
72 #define inc_counter_np(counter) \ | 73 #define inc_counter_np(counter) \ |
73 BLOCK_COMMENT("inc_counter " #counter); \ | 74 BLOCK_COMMENT("inc_counter " #counter); \ |
74 inc_counter_np_(counter); | 75 inc_counter_np_(counter); |
75 #endif //PRODUCT | 76 #endif //PRODUCT |
135 const Address thread (rbp, 9 * wordSize); // same as in generate_catch_exception()! | 136 const Address thread (rbp, 9 * wordSize); // same as in generate_catch_exception()! |
136 sse_save = UseSSE > 0; | 137 sse_save = UseSSE > 0; |
137 | 138 |
138 // stub code | 139 // stub code |
139 __ enter(); | 140 __ enter(); |
140 __ movl(rcx, parameter_size); // parameter counter | 141 __ movptr(rcx, parameter_size); // parameter counter |
141 __ shll(rcx, Interpreter::logStackElementSize()); // convert parameter count to bytes | 142 __ shlptr(rcx, Interpreter::logStackElementSize()); // convert parameter count to bytes |
142 __ addl(rcx, locals_count_in_bytes); // reserve space for register saves | 143 __ addptr(rcx, locals_count_in_bytes); // reserve space for register saves |
143 __ subl(rsp, rcx); | 144 __ subptr(rsp, rcx); |
144 __ andl(rsp, -(StackAlignmentInBytes)); // Align stack | 145 __ andptr(rsp, -(StackAlignmentInBytes)); // Align stack |
145 | 146 |
146 // save rdi, rsi, & rbx, according to C calling conventions | 147 // save rdi, rsi, & rbx, according to C calling conventions |
147 __ movl(saved_rdi, rdi); | 148 __ movptr(saved_rdi, rdi); |
148 __ movl(saved_rsi, rsi); | 149 __ movptr(saved_rsi, rsi); |
149 __ movl(saved_rbx, rbx); | 150 __ movptr(saved_rbx, rbx); |
150 // save and initialize %mxcsr | 151 // save and initialize %mxcsr |
151 if (sse_save) { | 152 if (sse_save) { |
152 Label skip_ldmx; | 153 Label skip_ldmx; |
153 __ stmxcsr(mxcsr_save); | 154 __ stmxcsr(mxcsr_save); |
154 __ movl(rax, mxcsr_save); | 155 __ movl(rax, mxcsr_save); |
164 __ fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_std())); | 165 __ fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_std())); |
165 | 166 |
166 #ifdef ASSERT | 167 #ifdef ASSERT |
167 // make sure we have no pending exceptions | 168 // make sure we have no pending exceptions |
168 { Label L; | 169 { Label L; |
169 __ movl(rcx, thread); | 170 __ movptr(rcx, thread); |
170 __ cmpl(Address(rcx, Thread::pending_exception_offset()), NULL_WORD); | 171 __ cmpptr(Address(rcx, Thread::pending_exception_offset()), (int32_t)NULL_WORD); |
171 __ jcc(Assembler::equal, L); | 172 __ jcc(Assembler::equal, L); |
172 __ stop("StubRoutines::call_stub: entered with pending exception"); | 173 __ stop("StubRoutines::call_stub: entered with pending exception"); |
173 __ bind(L); | 174 __ bind(L); |
174 } | 175 } |
175 #endif | 176 #endif |
187 // Copy Java parameters in reverse order (receiver last) | 188 // Copy Java parameters in reverse order (receiver last) |
188 // Note that the argument order is inverted in the process | 189 // Note that the argument order is inverted in the process |
189 // source is rdx[rcx: N-1..0] | 190 // source is rdx[rcx: N-1..0] |
190 // dest is rsp[rbx: 0..N-1] | 191 // dest is rsp[rbx: 0..N-1] |
191 | 192 |
192 __ movl(rdx, parameters); // parameter pointer | 193 __ movptr(rdx, parameters); // parameter pointer |
193 __ xorl(rbx, rbx); | 194 __ xorptr(rbx, rbx); |
194 | 195 |
195 __ BIND(loop); | 196 __ BIND(loop); |
196 if (TaggedStackInterpreter) { | 197 if (TaggedStackInterpreter) { |
197 __ movl(rax, Address(rdx, rcx, Interpreter::stackElementScale(), | 198 __ movptr(rax, Address(rdx, rcx, Interpreter::stackElementScale(), |
198 -2*wordSize)); // get tag | 199 -2*wordSize)); // get tag |
199 __ movl(Address(rsp, rbx, Interpreter::stackElementScale(), | 200 __ movptr(Address(rsp, rbx, Interpreter::stackElementScale(), |
200 Interpreter::expr_tag_offset_in_bytes(0)), rax); // store tag | 201 Interpreter::expr_tag_offset_in_bytes(0)), rax); // store tag |
201 } | 202 } |
202 | 203 |
203 // get parameter | 204 // get parameter |
204 __ movl(rax, Address(rdx, rcx, Interpreter::stackElementScale(), -wordSize)); | 205 __ movptr(rax, Address(rdx, rcx, Interpreter::stackElementScale(), -wordSize)); |
205 __ movl(Address(rsp, rbx, Interpreter::stackElementScale(), | 206 __ movptr(Address(rsp, rbx, Interpreter::stackElementScale(), |
206 Interpreter::expr_offset_in_bytes(0)), rax); // store parameter | 207 Interpreter::expr_offset_in_bytes(0)), rax); // store parameter |
207 __ increment(rbx); | 208 __ increment(rbx); |
208 __ decrement(rcx); | 209 __ decrement(rcx); |
209 __ jcc(Assembler::notZero, loop); | 210 __ jcc(Assembler::notZero, loop); |
210 | 211 |
211 // call Java function | 212 // call Java function |
212 __ BIND(parameters_done); | 213 __ BIND(parameters_done); |
213 __ movl(rbx, method); // get methodOop | 214 __ movptr(rbx, method); // get methodOop |
214 __ movl(rax, entry_point); // get entry_point | 215 __ movptr(rax, entry_point); // get entry_point |
215 __ movl(rsi, rsp); // set sender sp | 216 __ mov(rsi, rsp); // set sender sp |
216 BLOCK_COMMENT("call Java function"); | 217 BLOCK_COMMENT("call Java function"); |
217 __ call(rax); | 218 __ call(rax); |
218 | 219 |
219 BLOCK_COMMENT("call_stub_return_address:"); | 220 BLOCK_COMMENT("call_stub_return_address:"); |
220 return_address = __ pc(); | 221 return_address = __ pc(); |
223 | 224 |
224 __ BIND(common_return); | 225 __ BIND(common_return); |
225 | 226 |
226 // store result depending on type | 227 // store result depending on type |
227 // (everything that is not T_LONG, T_FLOAT or T_DOUBLE is treated as T_INT) | 228 // (everything that is not T_LONG, T_FLOAT or T_DOUBLE is treated as T_INT) |
228 __ movl(rdi, result); | 229 __ movptr(rdi, result); |
229 Label is_long, is_float, is_double, exit; | 230 Label is_long, is_float, is_double, exit; |
230 __ movl(rsi, result_type); | 231 __ movl(rsi, result_type); |
231 __ cmpl(rsi, T_LONG); | 232 __ cmpl(rsi, T_LONG); |
232 __ jcc(Assembler::equal, is_long); | 233 __ jcc(Assembler::equal, is_long); |
233 __ cmpl(rsi, T_FLOAT); | 234 __ cmpl(rsi, T_FLOAT); |
241 | 242 |
242 // check that FPU stack is empty | 243 // check that FPU stack is empty |
243 __ verify_FPU(0, "generate_call_stub"); | 244 __ verify_FPU(0, "generate_call_stub"); |
244 | 245 |
245 // pop parameters | 246 // pop parameters |
246 __ leal(rsp, rsp_after_call); | 247 __ lea(rsp, rsp_after_call); |
247 | 248 |
248 // restore %mxcsr | 249 // restore %mxcsr |
249 if (sse_save) { | 250 if (sse_save) { |
250 __ ldmxcsr(mxcsr_save); | 251 __ ldmxcsr(mxcsr_save); |
251 } | 252 } |
252 | 253 |
253 // restore rdi, rsi and rbx, | 254 // restore rdi, rsi and rbx, |
254 __ movl(rbx, saved_rbx); | 255 __ movptr(rbx, saved_rbx); |
255 __ movl(rsi, saved_rsi); | 256 __ movptr(rsi, saved_rsi); |
256 __ movl(rdi, saved_rdi); | 257 __ movptr(rdi, saved_rdi); |
257 __ addl(rsp, 4*wordSize); | 258 __ addptr(rsp, 4*wordSize); |
258 | 259 |
259 // return | 260 // return |
260 __ popl(rbp); | 261 __ pop(rbp); |
261 __ ret(0); | 262 __ ret(0); |
262 | 263 |
263 // handle return types different from T_INT | 264 // handle return types different from T_INT |
264 __ BIND(is_long); | 265 __ BIND(is_long); |
265 __ movl(Address(rdi, 0 * wordSize), rax); | 266 __ movl(Address(rdi, 0 * wordSize), rax); |
289 // piece of code that can handle compiled results and cleaning the fpu | 290 // piece of code that can handle compiled results and cleaning the fpu |
290 // stack. compiled code will be set to return here instead of the | 291 // stack. compiled code will be set to return here instead of the |
291 // return above that handles interpreter returns. | 292 // return above that handles interpreter returns. |
292 | 293 |
293 BLOCK_COMMENT("call_stub_compiled_return:"); | 294 BLOCK_COMMENT("call_stub_compiled_return:"); |
294 StubRoutines::i486::set_call_stub_compiled_return( __ pc()); | 295 StubRoutines::x86::set_call_stub_compiled_return( __ pc()); |
295 | 296 |
296 #ifdef COMPILER2 | 297 #ifdef COMPILER2 |
297 if (UseSSE >= 2) { | 298 if (UseSSE >= 2) { |
298 __ verify_FPU(0, "call_stub_compiled_return"); | 299 __ verify_FPU(0, "call_stub_compiled_return"); |
299 } else { | 300 } else { |
335 const Address rsp_after_call(rbp, -4 * wordSize); // same as in generate_call_stub()! | 336 const Address rsp_after_call(rbp, -4 * wordSize); // same as in generate_call_stub()! |
336 const Address thread (rbp, 9 * wordSize); // same as in generate_call_stub()! | 337 const Address thread (rbp, 9 * wordSize); // same as in generate_call_stub()! |
337 address start = __ pc(); | 338 address start = __ pc(); |
338 | 339 |
339 // get thread directly | 340 // get thread directly |
340 __ movl(rcx, thread); | 341 __ movptr(rcx, thread); |
341 #ifdef ASSERT | 342 #ifdef ASSERT |
342 // verify that threads correspond | 343 // verify that threads correspond |
343 { Label L; | 344 { Label L; |
344 __ get_thread(rbx); | 345 __ get_thread(rbx); |
345 __ cmpl(rbx, rcx); | 346 __ cmpptr(rbx, rcx); |
346 __ jcc(Assembler::equal, L); | 347 __ jcc(Assembler::equal, L); |
347 __ stop("StubRoutines::catch_exception: threads must correspond"); | 348 __ stop("StubRoutines::catch_exception: threads must correspond"); |
348 __ bind(L); | 349 __ bind(L); |
349 } | 350 } |
350 #endif | 351 #endif |
351 // set pending exception | 352 // set pending exception |
352 __ verify_oop(rax); | 353 __ verify_oop(rax); |
353 __ movl(Address(rcx, Thread::pending_exception_offset()), rax ); | 354 __ movptr(Address(rcx, Thread::pending_exception_offset()), rax ); |
354 __ lea(Address(rcx, Thread::exception_file_offset ()), | 355 __ lea(Address(rcx, Thread::exception_file_offset ()), |
355 ExternalAddress((address)__FILE__)); | 356 ExternalAddress((address)__FILE__)); |
356 __ movl(Address(rcx, Thread::exception_line_offset ()), __LINE__ ); | 357 __ movl(Address(rcx, Thread::exception_line_offset ()), __LINE__ ); |
357 // complete return to VM | 358 // complete return to VM |
358 assert(StubRoutines::_call_stub_return_address != NULL, "_call_stub_return_address must have been generated before"); | 359 assert(StubRoutines::_call_stub_return_address != NULL, "_call_stub_return_address must have been generated before"); |
387 | 388 |
388 #ifdef ASSERT | 389 #ifdef ASSERT |
389 // make sure this code is only executed if there is a pending exception | 390 // make sure this code is only executed if there is a pending exception |
390 { Label L; | 391 { Label L; |
391 __ get_thread(rcx); | 392 __ get_thread(rcx); |
392 __ cmpl(Address(rcx, Thread::pending_exception_offset()), NULL_WORD); | 393 __ cmpptr(Address(rcx, Thread::pending_exception_offset()), (int32_t)NULL_WORD); |
393 __ jcc(Assembler::notEqual, L); | 394 __ jcc(Assembler::notEqual, L); |
394 __ stop("StubRoutines::forward exception: no pending exception (1)"); | 395 __ stop("StubRoutines::forward exception: no pending exception (1)"); |
395 __ bind(L); | 396 __ bind(L); |
396 } | 397 } |
397 #endif | 398 #endif |
398 | 399 |
399 // compute exception handler into rbx, | 400 // compute exception handler into rbx, |
400 __ movl(rax, Address(rsp, 0)); | 401 __ movptr(rax, Address(rsp, 0)); |
401 BLOCK_COMMENT("call exception_handler_for_return_address"); | 402 BLOCK_COMMENT("call exception_handler_for_return_address"); |
402 __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::exception_handler_for_return_address), rax); | 403 __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::exception_handler_for_return_address), rax); |
403 __ movl(rbx, rax); | 404 __ mov(rbx, rax); |
404 | 405 |
405 // setup rax, & rdx, remove return address & clear pending exception | 406 // setup rax, & rdx, remove return address & clear pending exception |
406 __ get_thread(rcx); | 407 __ get_thread(rcx); |
407 __ popl(rdx); | 408 __ pop(rdx); |
408 __ movl(rax, Address(rcx, Thread::pending_exception_offset())); | 409 __ movptr(rax, Address(rcx, Thread::pending_exception_offset())); |
409 __ movl(Address(rcx, Thread::pending_exception_offset()), NULL_WORD); | 410 __ movptr(Address(rcx, Thread::pending_exception_offset()), (int32_t)NULL_WORD); |
410 | 411 |
411 #ifdef ASSERT | 412 #ifdef ASSERT |
412 // make sure exception is set | 413 // make sure exception is set |
413 { Label L; | 414 { Label L; |
414 __ testl(rax, rax); | 415 __ testptr(rax, rax); |
415 __ jcc(Assembler::notEqual, L); | 416 __ jcc(Assembler::notEqual, L); |
416 __ stop("StubRoutines::forward exception: no pending exception (2)"); | 417 __ stop("StubRoutines::forward exception: no pending exception (2)"); |
417 __ bind(L); | 418 __ bind(L); |
418 } | 419 } |
419 #endif | 420 #endif |
445 | 446 |
446 address generate_atomic_xchg() { | 447 address generate_atomic_xchg() { |
447 StubCodeMark mark(this, "StubRoutines", "atomic_xchg"); | 448 StubCodeMark mark(this, "StubRoutines", "atomic_xchg"); |
448 address start = __ pc(); | 449 address start = __ pc(); |
449 | 450 |
450 __ pushl(rdx); | 451 __ push(rdx); |
451 Address exchange(rsp, 2 * wordSize); | 452 Address exchange(rsp, 2 * wordSize); |
452 Address dest_addr(rsp, 3 * wordSize); | 453 Address dest_addr(rsp, 3 * wordSize); |
453 __ movl(rax, exchange); | 454 __ movl(rax, exchange); |
454 __ movl(rdx, dest_addr); | 455 __ movptr(rdx, dest_addr); |
455 __ xchg(rax, Address(rdx, 0)); | 456 __ xchgl(rax, Address(rdx, 0)); |
456 __ popl(rdx); | 457 __ pop(rdx); |
457 __ ret(0); | 458 __ ret(0); |
458 | 459 |
459 return start; | 460 return start; |
460 } | 461 } |
461 | 462 |
474 const Address mxcsr_save(rsp, 0); | 475 const Address mxcsr_save(rsp, 0); |
475 | 476 |
476 if (CheckJNICalls && UseSSE > 0 ) { | 477 if (CheckJNICalls && UseSSE > 0 ) { |
477 Label ok_ret; | 478 Label ok_ret; |
478 ExternalAddress mxcsr_std(StubRoutines::addr_mxcsr_std()); | 479 ExternalAddress mxcsr_std(StubRoutines::addr_mxcsr_std()); |
479 __ pushl(rax); | 480 __ push(rax); |
480 __ subl(rsp, wordSize); // allocate a temp location | 481 __ subptr(rsp, wordSize); // allocate a temp location |
481 __ stmxcsr(mxcsr_save); | 482 __ stmxcsr(mxcsr_save); |
482 __ movl(rax, mxcsr_save); | 483 __ movl(rax, mxcsr_save); |
483 __ andl(rax, MXCSR_MASK); | 484 __ andl(rax, MXCSR_MASK); |
484 __ cmp32(rax, mxcsr_std); | 485 __ cmp32(rax, mxcsr_std); |
485 __ jcc(Assembler::equal, ok_ret); | 486 __ jcc(Assembler::equal, ok_ret); |
487 __ warn("MXCSR changed by native JNI code."); | 488 __ warn("MXCSR changed by native JNI code."); |
488 | 489 |
489 __ ldmxcsr(mxcsr_std); | 490 __ ldmxcsr(mxcsr_std); |
490 | 491 |
491 __ bind(ok_ret); | 492 __ bind(ok_ret); |
492 __ addl(rsp, wordSize); | 493 __ addptr(rsp, wordSize); |
493 __ popl(rax); | 494 __ pop(rax); |
494 } | 495 } |
495 | 496 |
496 __ ret(0); | 497 __ ret(0); |
497 | 498 |
498 return start; | 499 return start; |
512 | 513 |
513 const Address fpu_cntrl_wrd_save(rsp, 0); | 514 const Address fpu_cntrl_wrd_save(rsp, 0); |
514 | 515 |
515 if (CheckJNICalls) { | 516 if (CheckJNICalls) { |
516 Label ok_ret; | 517 Label ok_ret; |
517 __ pushl(rax); | 518 __ push(rax); |
518 __ subl(rsp, wordSize); // allocate a temp location | 519 __ subptr(rsp, wordSize); // allocate a temp location |
519 __ fnstcw(fpu_cntrl_wrd_save); | 520 __ fnstcw(fpu_cntrl_wrd_save); |
520 __ movl(rax, fpu_cntrl_wrd_save); | 521 __ movl(rax, fpu_cntrl_wrd_save); |
521 __ andl(rax, FPU_CNTRL_WRD_MASK); | 522 __ andl(rax, FPU_CNTRL_WRD_MASK); |
522 ExternalAddress fpu_std(StubRoutines::addr_fpu_cntrl_wrd_std()); | 523 ExternalAddress fpu_std(StubRoutines::addr_fpu_cntrl_wrd_std()); |
523 __ cmp32(rax, fpu_std); | 524 __ cmp32(rax, fpu_std); |
526 __ warn("Floating point control word changed by native JNI code."); | 527 __ warn("Floating point control word changed by native JNI code."); |
527 | 528 |
528 __ fldcw(fpu_std); | 529 __ fldcw(fpu_std); |
529 | 530 |
530 __ bind(ok_ret); | 531 __ bind(ok_ret); |
531 __ addl(rsp, wordSize); | 532 __ addptr(rsp, wordSize); |
532 __ popl(rax); | 533 __ pop(rax); |
533 } | 534 } |
534 | 535 |
535 __ ret(0); | 536 __ ret(0); |
536 | 537 |
537 return start; | 538 return start; |
561 }; | 562 }; |
562 | 563 |
563 assert(FPUStateSizeInWords == 27, "update stack layout"); | 564 assert(FPUStateSizeInWords == 27, "update stack layout"); |
564 | 565 |
565 // Save outgoing argument to stack across push_FPU_state() | 566 // Save outgoing argument to stack across push_FPU_state() |
566 __ subl(rsp, wordSize * 2); | 567 __ subptr(rsp, wordSize * 2); |
567 __ fstp_d(Address(rsp, 0)); | 568 __ fstp_d(Address(rsp, 0)); |
568 | 569 |
569 // Save CPU & FPU state | 570 // Save CPU & FPU state |
570 __ pushl(rbx); | 571 __ push(rbx); |
571 __ pushl(rcx); | 572 __ push(rcx); |
572 __ pushl(rsi); | 573 __ push(rsi); |
573 __ pushl(rdi); | 574 __ push(rdi); |
574 __ pushl(rbp); | 575 __ push(rbp); |
575 __ push_FPU_state(); | 576 __ push_FPU_state(); |
576 | 577 |
577 // push_FPU_state() resets the FP top of stack | 578 // push_FPU_state() resets the FP top of stack |
578 // Load original double into FP top of stack | 579 // Load original double into FP top of stack |
579 __ fld_d(Address(rsp, saved_argument_off * wordSize)); | 580 __ fld_d(Address(rsp, saved_argument_off * wordSize)); |
580 // Store double into stack as outgoing argument | 581 // Store double into stack as outgoing argument |
581 __ subl(rsp, wordSize*2); | 582 __ subptr(rsp, wordSize*2); |
582 __ fst_d(Address(rsp, 0)); | 583 __ fst_d(Address(rsp, 0)); |
583 | 584 |
584 // Prepare FPU for doing math in C-land | 585 // Prepare FPU for doing math in C-land |
585 __ empty_FPU_stack(); | 586 __ empty_FPU_stack(); |
586 // Call the C code to massage the double. Result in EAX | 587 // Call the C code to massage the double. Result in EAX |
590 { BLOCK_COMMENT("SharedRuntime::d2l"); } | 591 { BLOCK_COMMENT("SharedRuntime::d2l"); } |
591 __ call_VM_leaf( fcn, 2 ); | 592 __ call_VM_leaf( fcn, 2 ); |
592 | 593 |
593 // Restore CPU & FPU state | 594 // Restore CPU & FPU state |
594 __ pop_FPU_state(); | 595 __ pop_FPU_state(); |
595 __ popl(rbp); | 596 __ pop(rbp); |
596 __ popl(rdi); | 597 __ pop(rdi); |
597 __ popl(rsi); | 598 __ pop(rsi); |
598 __ popl(rcx); | 599 __ pop(rcx); |
599 __ popl(rbx); | 600 __ pop(rbx); |
600 __ addl(rsp, wordSize * 2); | 601 __ addptr(rsp, wordSize * 2); |
601 | 602 |
602 __ ret(0); | 603 __ ret(0); |
603 | 604 |
604 return start; | 605 return start; |
605 } | 606 } |
611 // reasonably prevented by the programmer. (Example: SIGBUS/OBJERR.) | 612 // reasonably prevented by the programmer. (Example: SIGBUS/OBJERR.) |
612 address generate_handler_for_unsafe_access() { | 613 address generate_handler_for_unsafe_access() { |
613 StubCodeMark mark(this, "StubRoutines", "handler_for_unsafe_access"); | 614 StubCodeMark mark(this, "StubRoutines", "handler_for_unsafe_access"); |
614 address start = __ pc(); | 615 address start = __ pc(); |
615 | 616 |
616 __ pushl(0); // hole for return address-to-be | 617 __ push(0); // hole for return address-to-be |
617 __ pushad(); // push registers | 618 __ pusha(); // push registers |
618 Address next_pc(rsp, RegisterImpl::number_of_registers * BytesPerWord); | 619 Address next_pc(rsp, RegisterImpl::number_of_registers * BytesPerWord); |
619 BLOCK_COMMENT("call handle_unsafe_access"); | 620 BLOCK_COMMENT("call handle_unsafe_access"); |
620 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, handle_unsafe_access))); | 621 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, handle_unsafe_access))); |
621 __ movl(next_pc, rax); // stuff next address | 622 __ movptr(next_pc, rax); // stuff next address |
622 __ popad(); | 623 __ popa(); |
623 __ ret(0); // jump to next address | 624 __ ret(0); // jump to next address |
624 | 625 |
625 return start; | 626 return start; |
626 } | 627 } |
627 | 628 |
641 // [tos + 3]: char* error message | 642 // [tos + 3]: char* error message |
642 // [tos + 4]: oop object to verify | 643 // [tos + 4]: oop object to verify |
643 // [tos + 5]: saved rax, - saved by caller and bashed | 644 // [tos + 5]: saved rax, - saved by caller and bashed |
644 | 645 |
645 Label exit, error; | 646 Label exit, error; |
646 __ pushfd(); | 647 __ pushf(); |
647 __ increment(ExternalAddress((address) StubRoutines::verify_oop_count_addr())); | 648 __ incrementl(ExternalAddress((address) StubRoutines::verify_oop_count_addr())); |
648 __ pushl(rdx); // save rdx | 649 __ push(rdx); // save rdx |
649 // make sure object is 'reasonable' | 650 // make sure object is 'reasonable' |
650 __ movl(rax, Address(rsp, 4 * wordSize)); // get object | 651 __ movptr(rax, Address(rsp, 4 * wordSize)); // get object |
651 __ testl(rax, rax); | 652 __ testptr(rax, rax); |
652 __ jcc(Assembler::zero, exit); // if obj is NULL it is ok | 653 __ jcc(Assembler::zero, exit); // if obj is NULL it is ok |
653 | 654 |
654 // Check if the oop is in the right area of memory | 655 // Check if the oop is in the right area of memory |
655 const int oop_mask = Universe::verify_oop_mask(); | 656 const int oop_mask = Universe::verify_oop_mask(); |
656 const int oop_bits = Universe::verify_oop_bits(); | 657 const int oop_bits = Universe::verify_oop_bits(); |
657 __ movl(rdx, rax); | 658 __ mov(rdx, rax); |
658 __ andl(rdx, oop_mask); | 659 __ andptr(rdx, oop_mask); |
659 __ cmpl(rdx, oop_bits); | 660 __ cmpptr(rdx, oop_bits); |
660 __ jcc(Assembler::notZero, error); | 661 __ jcc(Assembler::notZero, error); |
661 | 662 |
662 // make sure klass is 'reasonable' | 663 // make sure klass is 'reasonable' |
663 __ movl(rax, Address(rax, oopDesc::klass_offset_in_bytes())); // get klass | 664 __ movptr(rax, Address(rax, oopDesc::klass_offset_in_bytes())); // get klass |
664 __ testl(rax, rax); | 665 __ testptr(rax, rax); |
665 __ jcc(Assembler::zero, error); // if klass is NULL it is broken | 666 __ jcc(Assembler::zero, error); // if klass is NULL it is broken |
666 | 667 |
667 // Check if the klass is in the right area of memory | 668 // Check if the klass is in the right area of memory |
668 const int klass_mask = Universe::verify_klass_mask(); | 669 const int klass_mask = Universe::verify_klass_mask(); |
669 const int klass_bits = Universe::verify_klass_bits(); | 670 const int klass_bits = Universe::verify_klass_bits(); |
670 __ movl(rdx, rax); | 671 __ mov(rdx, rax); |
671 __ andl(rdx, klass_mask); | 672 __ andptr(rdx, klass_mask); |
672 __ cmpl(rdx, klass_bits); | 673 __ cmpptr(rdx, klass_bits); |
673 __ jcc(Assembler::notZero, error); | 674 __ jcc(Assembler::notZero, error); |
674 | 675 |
675 // make sure klass' klass is 'reasonable' | 676 // make sure klass' klass is 'reasonable' |
676 __ movl(rax, Address(rax, oopDesc::klass_offset_in_bytes())); // get klass' klass | 677 __ movptr(rax, Address(rax, oopDesc::klass_offset_in_bytes())); // get klass' klass |
677 __ testl(rax, rax); | 678 __ testptr(rax, rax); |
678 __ jcc(Assembler::zero, error); // if klass' klass is NULL it is broken | 679 __ jcc(Assembler::zero, error); // if klass' klass is NULL it is broken |
679 | 680 |
680 __ movl(rdx, rax); | 681 __ mov(rdx, rax); |
681 __ andl(rdx, klass_mask); | 682 __ andptr(rdx, klass_mask); |
682 __ cmpl(rdx, klass_bits); | 683 __ cmpptr(rdx, klass_bits); |
683 __ jcc(Assembler::notZero, error); // if klass not in right area | 684 __ jcc(Assembler::notZero, error); // if klass not in right area |
684 // of memory it is broken too. | 685 // of memory it is broken too. |
685 | 686 |
686 // return if everything seems ok | 687 // return if everything seems ok |
687 __ bind(exit); | 688 __ bind(exit); |
688 __ movl(rax, Address(rsp, 5 * wordSize)); // get saved rax, back | 689 __ movptr(rax, Address(rsp, 5 * wordSize)); // get saved rax, back |
689 __ popl(rdx); // restore rdx | 690 __ pop(rdx); // restore rdx |
690 __ popfd(); // restore EFLAGS | 691 __ popf(); // restore EFLAGS |
691 __ ret(3 * wordSize); // pop arguments | 692 __ ret(3 * wordSize); // pop arguments |
692 | 693 |
693 // handle errors | 694 // handle errors |
694 __ bind(error); | 695 __ bind(error); |
695 __ movl(rax, Address(rsp, 5 * wordSize)); // get saved rax, back | 696 __ movptr(rax, Address(rsp, 5 * wordSize)); // get saved rax, back |
696 __ popl(rdx); // get saved rdx back | 697 __ pop(rdx); // get saved rdx back |
697 __ popfd(); // get saved EFLAGS off stack -- will be ignored | 698 __ popf(); // get saved EFLAGS off stack -- will be ignored |
698 __ pushad(); // push registers (eip = return address & msg are already pushed) | 699 __ pusha(); // push registers (eip = return address & msg are already pushed) |
699 BLOCK_COMMENT("call MacroAssembler::debug"); | 700 BLOCK_COMMENT("call MacroAssembler::debug"); |
700 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, MacroAssembler::debug))); | 701 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, MacroAssembler::debug32))); |
701 __ popad(); | 702 __ popa(); |
702 __ ret(3 * wordSize); // pop arguments | 703 __ ret(3 * wordSize); // pop arguments |
703 return start; | 704 return start; |
704 } | 705 } |
705 | 706 |
706 // | 707 // |
715 BarrierSet* bs = Universe::heap()->barrier_set(); | 716 BarrierSet* bs = Universe::heap()->barrier_set(); |
716 switch (bs->kind()) { | 717 switch (bs->kind()) { |
717 case BarrierSet::G1SATBCT: | 718 case BarrierSet::G1SATBCT: |
718 case BarrierSet::G1SATBCTLogging: | 719 case BarrierSet::G1SATBCTLogging: |
719 { | 720 { |
720 __ pushad(); // push registers | 721 __ pusha(); // push registers |
721 __ pushl(count); | 722 __ push(count); |
722 __ pushl(start); | 723 __ push(start); |
723 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, BarrierSet::static_write_ref_array_pre)); | 724 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, BarrierSet::static_write_ref_array_pre)); |
724 __ addl(esp, wordSize * 2); | 725 __ addl(esp, wordSize * 2); |
725 __ popad(); | 726 __ popa(); |
726 } | 727 } |
727 break; | 728 break; |
728 case BarrierSet::CardTableModRef: | 729 case BarrierSet::CardTableModRef: |
729 case BarrierSet::CardTableExtension: | 730 case BarrierSet::CardTableExtension: |
730 case BarrierSet::ModRef: | 731 case BarrierSet::ModRef: |
751 switch (bs->kind()) { | 752 switch (bs->kind()) { |
752 #if 0 // G1 only | 753 #if 0 // G1 only |
753 case BarrierSet::G1SATBCT: | 754 case BarrierSet::G1SATBCT: |
754 case BarrierSet::G1SATBCTLogging: | 755 case BarrierSet::G1SATBCTLogging: |
755 { | 756 { |
756 __ pushad(); // push registers | 757 __ pusha(); // push registers |
757 __ pushl(count); | 758 __ push(count); |
758 __ pushl(start); | 759 __ push(start); |
759 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, BarrierSet::static_write_ref_array_post)); | 760 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, BarrierSet::static_write_ref_array_post)); |
760 __ addl(esp, wordSize * 2); | 761 __ addl(esp, wordSize * 2); |
761 __ popad(); | 762 __ popa(); |
762 | 763 |
763 } | 764 } |
764 break; | 765 break; |
765 #endif // 0 G1 only | 766 #endif // 0 G1 only |
766 | 767 |
772 | 773 |
773 Label L_loop; | 774 Label L_loop; |
774 const Register end = count; // elements count; end == start+count-1 | 775 const Register end = count; // elements count; end == start+count-1 |
775 assert_different_registers(start, end); | 776 assert_different_registers(start, end); |
776 | 777 |
777 __ leal(end, Address(start, count, Address::times_4, -4)); | 778 __ lea(end, Address(start, count, Address::times_ptr, -wordSize)); |
778 __ shrl(start, CardTableModRefBS::card_shift); | 779 __ shrptr(start, CardTableModRefBS::card_shift); |
779 __ shrl(end, CardTableModRefBS::card_shift); | 780 __ shrptr(end, CardTableModRefBS::card_shift); |
780 __ subl(end, start); // end --> count | 781 __ subptr(end, start); // end --> count |
781 __ BIND(L_loop); | 782 __ BIND(L_loop); |
782 intptr_t disp = (intptr_t) ct->byte_map_base; | 783 intptr_t disp = (intptr_t) ct->byte_map_base; |
783 Address cardtable(start, count, Address::times_1, disp); | 784 Address cardtable(start, count, Address::times_1, disp); |
784 __ movb(cardtable, 0); | 785 __ movb(cardtable, 0); |
785 __ decrement(count); | 786 __ decrement(count); |
821 __ movq(Address(from, to_from, Address::times_1, 32), mmx4); | 822 __ movq(Address(from, to_from, Address::times_1, 32), mmx4); |
822 __ movq(mmx7, Address(from, 56)); | 823 __ movq(mmx7, Address(from, 56)); |
823 __ movq(Address(from, to_from, Address::times_1, 40), mmx5); | 824 __ movq(Address(from, to_from, Address::times_1, 40), mmx5); |
824 __ movq(Address(from, to_from, Address::times_1, 48), mmx6); | 825 __ movq(Address(from, to_from, Address::times_1, 48), mmx6); |
825 __ movq(Address(from, to_from, Address::times_1, 56), mmx7); | 826 __ movq(Address(from, to_from, Address::times_1, 56), mmx7); |
826 __ addl(from, 64); | 827 __ addptr(from, 64); |
827 __ BIND(L_copy_64_bytes); | 828 __ BIND(L_copy_64_bytes); |
828 __ subl(qword_count, 8); | 829 __ subl(qword_count, 8); |
829 __ jcc(Assembler::greaterEqual, L_copy_64_bytes_loop); | 830 __ jcc(Assembler::greaterEqual, L_copy_64_bytes_loop); |
830 __ addl(qword_count, 8); | 831 __ addl(qword_count, 8); |
831 __ jccb(Assembler::zero, L_exit); | 832 __ jccb(Assembler::zero, L_exit); |
833 // length is too short, just copy qwords | 834 // length is too short, just copy qwords |
834 // | 835 // |
835 __ BIND(L_copy_8_bytes); | 836 __ BIND(L_copy_8_bytes); |
836 __ movq(mmx0, Address(from, 0)); | 837 __ movq(mmx0, Address(from, 0)); |
837 __ movq(Address(from, to_from, Address::times_1), mmx0); | 838 __ movq(Address(from, to_from, Address::times_1), mmx0); |
838 __ addl(from, 8); | 839 __ addptr(from, 8); |
839 __ decrement(qword_count); | 840 __ decrement(qword_count); |
840 __ jcc(Assembler::greater, L_copy_8_bytes); | 841 __ jcc(Assembler::greater, L_copy_8_bytes); |
841 __ BIND(L_exit); | 842 __ BIND(L_exit); |
842 __ emms(); | 843 __ emms(); |
843 } | 844 } |
850 address start = __ pc(); | 851 address start = __ pc(); |
851 | 852 |
852 Label L_0_count, L_exit, L_skip_align1, L_skip_align2, L_copy_byte; | 853 Label L_0_count, L_exit, L_skip_align1, L_skip_align2, L_copy_byte; |
853 Label L_copy_2_bytes, L_copy_4_bytes, L_copy_64_bytes; | 854 Label L_copy_2_bytes, L_copy_4_bytes, L_copy_64_bytes; |
854 | 855 |
855 int shift = Address::times_4 - sf; | 856 int shift = Address::times_ptr - sf; |
856 | 857 |
857 const Register from = rsi; // source array address | 858 const Register from = rsi; // source array address |
858 const Register to = rdi; // destination array address | 859 const Register to = rdi; // destination array address |
859 const Register count = rcx; // elements count | 860 const Register count = rcx; // elements count |
860 const Register to_from = to; // (to - from) | 861 const Register to_from = to; // (to - from) |
861 const Register saved_to = rdx; // saved destination array address | 862 const Register saved_to = rdx; // saved destination array address |
862 | 863 |
863 __ enter(); // required for proper stackwalking of RuntimeStub frame | 864 __ enter(); // required for proper stackwalking of RuntimeStub frame |
864 __ pushl(rsi); | 865 __ push(rsi); |
865 __ pushl(rdi); | 866 __ push(rdi); |
866 __ movl(from , Address(rsp, 12+ 4)); | 867 __ movptr(from , Address(rsp, 12+ 4)); |
867 __ movl(to , Address(rsp, 12+ 8)); | 868 __ movptr(to , Address(rsp, 12+ 8)); |
868 __ movl(count, Address(rsp, 12+ 12)); | 869 __ movl(count, Address(rsp, 12+ 12)); |
869 if (t == T_OBJECT) { | 870 if (t == T_OBJECT) { |
870 __ testl(count, count); | 871 __ testl(count, count); |
871 __ jcc(Assembler::zero, L_0_count); | 872 __ jcc(Assembler::zero, L_0_count); |
872 gen_write_ref_array_pre_barrier(to, count); | 873 gen_write_ref_array_pre_barrier(to, count); |
873 __ movl(saved_to, to); // save 'to' | 874 __ mov(saved_to, to); // save 'to' |
874 } | 875 } |
875 | 876 |
876 *entry = __ pc(); // Entry point from conjoint arraycopy stub. | 877 *entry = __ pc(); // Entry point from conjoint arraycopy stub. |
877 BLOCK_COMMENT("Entry:"); | 878 BLOCK_COMMENT("Entry:"); |
878 | 879 |
879 __ subl(to, from); // to --> to_from | 880 __ subptr(to, from); // to --> to_from |
880 __ cmpl(count, 2<<shift); // Short arrays (< 8 bytes) copy by element | 881 __ cmpl(count, 2<<shift); // Short arrays (< 8 bytes) copy by element |
881 __ jcc(Assembler::below, L_copy_4_bytes); // use unsigned cmp | 882 __ jcc(Assembler::below, L_copy_4_bytes); // use unsigned cmp |
882 if (!aligned && (t == T_BYTE || t == T_SHORT)) { | 883 if (!aligned && (t == T_BYTE || t == T_SHORT)) { |
883 // align source address at 4 bytes address boundary | 884 // align source address at 4 bytes address boundary |
884 if (t == T_BYTE) { | 885 if (t == T_BYTE) { |
894 // Two bytes misalignment happens only for byte and short (char) arrays | 895 // Two bytes misalignment happens only for byte and short (char) arrays |
895 __ testl(from, 2); | 896 __ testl(from, 2); |
896 __ jccb(Assembler::zero, L_skip_align2); | 897 __ jccb(Assembler::zero, L_skip_align2); |
897 __ movw(rax, Address(from, 0)); | 898 __ movw(rax, Address(from, 0)); |
898 __ movw(Address(from, to_from, Address::times_1, 0), rax); | 899 __ movw(Address(from, to_from, Address::times_1, 0), rax); |
899 __ addl(from, 2); | 900 __ addptr(from, 2); |
900 __ subl(count, 1<<(shift-1)); | 901 __ subl(count, 1<<(shift-1)); |
901 __ BIND(L_skip_align2); | 902 __ BIND(L_skip_align2); |
902 } | 903 } |
903 if (!VM_Version::supports_mmx()) { | 904 if (!VM_Version::supports_mmx()) { |
904 __ movl(rax, count); // save 'count' | 905 __ mov(rax, count); // save 'count' |
905 __ shrl(count, shift); // bytes count | 906 __ shrl(count, shift); // bytes count |
906 __ addl(to_from, from); // restore 'to' | 907 __ addptr(to_from, from);// restore 'to' |
907 __ rep_movl(); | 908 __ rep_mov(); |
908 __ subl(to_from, from); // restore 'to_from' | 909 __ subptr(to_from, from);// restore 'to_from' |
909 __ movl(count, rax); // restore 'count' | 910 __ mov(count, rax); // restore 'count' |
910 __ jmpb(L_copy_2_bytes); // all dwords were copied | 911 __ jmpb(L_copy_2_bytes); // all dwords were copied |
911 } else { | 912 } else { |
912 // align to 8 bytes, we know we are 4 byte aligned to start | 913 // align to 8 bytes, we know we are 4 byte aligned to start |
913 __ testl(from, 4); | 914 __ testptr(from, 4); |
914 __ jccb(Assembler::zero, L_copy_64_bytes); | 915 __ jccb(Assembler::zero, L_copy_64_bytes); |
915 __ movl(rax, Address(from, 0)); | 916 __ movl(rax, Address(from, 0)); |
916 __ movl(Address(from, to_from, Address::times_1, 0), rax); | 917 __ movl(Address(from, to_from, Address::times_1, 0), rax); |
917 __ addl(from, 4); | 918 __ addptr(from, 4); |
918 __ subl(count, 1<<shift); | 919 __ subl(count, 1<<shift); |
919 __ BIND(L_copy_64_bytes); | 920 __ BIND(L_copy_64_bytes); |
920 __ movl(rax, count); | 921 __ mov(rax, count); |
921 __ shrl(rax, shift+1); // 8 bytes chunk count | 922 __ shrl(rax, shift+1); // 8 bytes chunk count |
922 // | 923 // |
923 // Copy 8-byte chunks through MMX registers, 8 per iteration of the loop | 924 // Copy 8-byte chunks through MMX registers, 8 per iteration of the loop |
924 // | 925 // |
925 mmx_copy_forward(from, to_from, rax); | 926 mmx_copy_forward(from, to_from, rax); |
929 __ testl(count, 1<<shift); | 930 __ testl(count, 1<<shift); |
930 __ jccb(Assembler::zero, L_copy_2_bytes); | 931 __ jccb(Assembler::zero, L_copy_2_bytes); |
931 __ movl(rax, Address(from, 0)); | 932 __ movl(rax, Address(from, 0)); |
932 __ movl(Address(from, to_from, Address::times_1, 0), rax); | 933 __ movl(Address(from, to_from, Address::times_1, 0), rax); |
933 if (t == T_BYTE || t == T_SHORT) { | 934 if (t == T_BYTE || t == T_SHORT) { |
934 __ addl(from, 4); | 935 __ addptr(from, 4); |
935 __ BIND(L_copy_2_bytes); | 936 __ BIND(L_copy_2_bytes); |
936 // copy tailing word | 937 // copy tailing word |
937 __ testl(count, 1<<(shift-1)); | 938 __ testl(count, 1<<(shift-1)); |
938 __ jccb(Assembler::zero, L_copy_byte); | 939 __ jccb(Assembler::zero, L_copy_byte); |
939 __ movw(rax, Address(from, 0)); | 940 __ movw(rax, Address(from, 0)); |
940 __ movw(Address(from, to_from, Address::times_1, 0), rax); | 941 __ movw(Address(from, to_from, Address::times_1, 0), rax); |
941 if (t == T_BYTE) { | 942 if (t == T_BYTE) { |
942 __ addl(from, 2); | 943 __ addptr(from, 2); |
943 __ BIND(L_copy_byte); | 944 __ BIND(L_copy_byte); |
944 // copy tailing byte | 945 // copy tailing byte |
945 __ testl(count, 1); | 946 __ testl(count, 1); |
946 __ jccb(Assembler::zero, L_exit); | 947 __ jccb(Assembler::zero, L_exit); |
947 __ movb(rax, Address(from, 0)); | 948 __ movb(rax, Address(from, 0)); |
954 __ BIND(L_copy_2_bytes); | 955 __ BIND(L_copy_2_bytes); |
955 } | 956 } |
956 | 957 |
957 if (t == T_OBJECT) { | 958 if (t == T_OBJECT) { |
958 __ movl(count, Address(rsp, 12+12)); // reread 'count' | 959 __ movl(count, Address(rsp, 12+12)); // reread 'count' |
959 __ movl(to, saved_to); // restore 'to' | 960 __ mov(to, saved_to); // restore 'to' |
960 gen_write_ref_array_post_barrier(to, count); | 961 gen_write_ref_array_post_barrier(to, count); |
961 __ BIND(L_0_count); | 962 __ BIND(L_0_count); |
962 } | 963 } |
963 inc_copy_counter_np(t); | 964 inc_copy_counter_np(t); |
964 __ popl(rdi); | 965 __ pop(rdi); |
965 __ popl(rsi); | 966 __ pop(rsi); |
966 __ leave(); // required for proper stackwalking of RuntimeStub frame | 967 __ leave(); // required for proper stackwalking of RuntimeStub frame |
967 __ xorl(rax, rax); // return 0 | 968 __ xorptr(rax, rax); // return 0 |
968 __ ret(0); | 969 __ ret(0); |
969 return start; | 970 return start; |
970 } | 971 } |
971 | 972 |
972 | 973 |
979 address start = __ pc(); | 980 address start = __ pc(); |
980 | 981 |
981 Label L_0_count, L_exit, L_skip_align1, L_skip_align2, L_copy_byte; | 982 Label L_0_count, L_exit, L_skip_align1, L_skip_align2, L_copy_byte; |
982 Label L_copy_2_bytes, L_copy_4_bytes, L_copy_8_bytes, L_copy_8_bytes_loop; | 983 Label L_copy_2_bytes, L_copy_4_bytes, L_copy_8_bytes, L_copy_8_bytes_loop; |
983 | 984 |
984 int shift = Address::times_4 - sf; | 985 int shift = Address::times_ptr - sf; |
985 | 986 |
986 const Register src = rax; // source array address | 987 const Register src = rax; // source array address |
987 const Register dst = rdx; // destination array address | 988 const Register dst = rdx; // destination array address |
988 const Register from = rsi; // source array address | 989 const Register from = rsi; // source array address |
989 const Register to = rdi; // destination array address | 990 const Register to = rdi; // destination array address |
990 const Register count = rcx; // elements count | 991 const Register count = rcx; // elements count |
991 const Register end = rax; // array end address | 992 const Register end = rax; // array end address |
992 | 993 |
993 __ enter(); // required for proper stackwalking of RuntimeStub frame | 994 __ enter(); // required for proper stackwalking of RuntimeStub frame |
994 __ pushl(rsi); | 995 __ push(rsi); |
995 __ pushl(rdi); | 996 __ push(rdi); |
996 __ movl(src , Address(rsp, 12+ 4)); // from | 997 __ movptr(src , Address(rsp, 12+ 4)); // from |
997 __ movl(dst , Address(rsp, 12+ 8)); // to | 998 __ movptr(dst , Address(rsp, 12+ 8)); // to |
998 __ movl(count, Address(rsp, 12+12)); // count | 999 __ movl2ptr(count, Address(rsp, 12+12)); // count |
999 if (t == T_OBJECT) { | 1000 if (t == T_OBJECT) { |
1000 gen_write_ref_array_pre_barrier(dst, count); | 1001 gen_write_ref_array_pre_barrier(dst, count); |
1001 } | 1002 } |
1002 | 1003 |
1003 if (entry != NULL) { | 1004 if (entry != NULL) { |
1007 | 1008 |
1008 if (t == T_OBJECT) { | 1009 if (t == T_OBJECT) { |
1009 __ testl(count, count); | 1010 __ testl(count, count); |
1010 __ jcc(Assembler::zero, L_0_count); | 1011 __ jcc(Assembler::zero, L_0_count); |
1011 } | 1012 } |
1012 __ movl(from, src); | 1013 __ mov(from, src); |
1013 __ movl(to , dst); | 1014 __ mov(to , dst); |
1014 | 1015 |
1015 // arrays overlap test | 1016 // arrays overlap test |
1016 RuntimeAddress nooverlap(nooverlap_target); | 1017 RuntimeAddress nooverlap(nooverlap_target); |
1017 __ cmpl(dst, src); | 1018 __ cmpptr(dst, src); |
1018 __ leal(end, Address(src, count, sf, 0)); // src + count * elem_size | 1019 __ lea(end, Address(src, count, sf, 0)); // src + count * elem_size |
1019 __ jump_cc(Assembler::belowEqual, nooverlap); | 1020 __ jump_cc(Assembler::belowEqual, nooverlap); |
1020 __ cmpl(dst, end); | 1021 __ cmpptr(dst, end); |
1021 __ jump_cc(Assembler::aboveEqual, nooverlap); | 1022 __ jump_cc(Assembler::aboveEqual, nooverlap); |
1022 | 1023 |
1023 // copy from high to low | 1024 // copy from high to low |
1024 __ cmpl(count, 2<<shift); // Short arrays (< 8 bytes) copy by element | 1025 __ cmpl(count, 2<<shift); // Short arrays (< 8 bytes) copy by element |
1025 __ jcc(Assembler::below, L_copy_4_bytes); // use unsigned cmp | 1026 __ jcc(Assembler::below, L_copy_4_bytes); // use unsigned cmp |
1026 if (t == T_BYTE || t == T_SHORT) { | 1027 if (t == T_BYTE || t == T_SHORT) { |
1027 // Align the end of destination array at 4 bytes address boundary | 1028 // Align the end of destination array at 4 bytes address boundary |
1028 __ leal(end, Address(dst, count, sf, 0)); | 1029 __ lea(end, Address(dst, count, sf, 0)); |
1029 if (t == T_BYTE) { | 1030 if (t == T_BYTE) { |
1030 // One byte misalignment happens only for byte arrays | 1031 // One byte misalignment happens only for byte arrays |
1031 __ testl(end, 1); | 1032 __ testl(end, 1); |
1032 __ jccb(Assembler::zero, L_skip_align1); | 1033 __ jccb(Assembler::zero, L_skip_align1); |
1033 __ decrement(count); | 1034 __ decrement(count); |
1036 __ BIND(L_skip_align1); | 1037 __ BIND(L_skip_align1); |
1037 } | 1038 } |
1038 // Two bytes misalignment happens only for byte and short (char) arrays | 1039 // Two bytes misalignment happens only for byte and short (char) arrays |
1039 __ testl(end, 2); | 1040 __ testl(end, 2); |
1040 __ jccb(Assembler::zero, L_skip_align2); | 1041 __ jccb(Assembler::zero, L_skip_align2); |
1041 __ subl(count, 1<<(shift-1)); | 1042 __ subptr(count, 1<<(shift-1)); |
1042 __ movw(rdx, Address(from, count, sf, 0)); | 1043 __ movw(rdx, Address(from, count, sf, 0)); |
1043 __ movw(Address(to, count, sf, 0), rdx); | 1044 __ movw(Address(to, count, sf, 0), rdx); |
1044 __ BIND(L_skip_align2); | 1045 __ BIND(L_skip_align2); |
1045 __ cmpl(count, 2<<shift); // Short arrays (< 8 bytes) copy by element | 1046 __ cmpl(count, 2<<shift); // Short arrays (< 8 bytes) copy by element |
1046 __ jcc(Assembler::below, L_copy_4_bytes); | 1047 __ jcc(Assembler::below, L_copy_4_bytes); |
1047 } | 1048 } |
1048 | 1049 |
1049 if (!VM_Version::supports_mmx()) { | 1050 if (!VM_Version::supports_mmx()) { |
1050 __ std(); | 1051 __ std(); |
1051 __ movl(rax, count); // Save 'count' | 1052 __ mov(rax, count); // Save 'count' |
1052 __ movl(rdx, to); // Save 'to' | 1053 __ mov(rdx, to); // Save 'to' |
1053 __ leal(rsi, Address(from, count, sf, -4)); | 1054 __ lea(rsi, Address(from, count, sf, -4)); |
1054 __ leal(rdi, Address(to , count, sf, -4)); | 1055 __ lea(rdi, Address(to , count, sf, -4)); |
1055 __ shrl(count, shift); // bytes count | 1056 __ shrptr(count, shift); // bytes count |
1056 __ rep_movl(); | 1057 __ rep_mov(); |
1057 __ cld(); | 1058 __ cld(); |
1058 __ movl(count, rax); // restore 'count' | 1059 __ mov(count, rax); // restore 'count' |
1059 __ andl(count, (1<<shift)-1); // mask the number of rest elements | 1060 __ andl(count, (1<<shift)-1); // mask the number of rest elements |
1060 __ movl(from, Address(rsp, 12+4)); // reread 'from' | 1061 __ movptr(from, Address(rsp, 12+4)); // reread 'from' |
1061 __ movl(to, rdx); // restore 'to' | 1062 __ mov(to, rdx); // restore 'to' |
1062 __ jmpb(L_copy_2_bytes); // all dword were copied | 1063 __ jmpb(L_copy_2_bytes); // all dword were copied |
1063 } else { | 1064 } else { |
1064 // Align to 8 bytes the end of array. It is aligned to 4 bytes already. | 1065 // Align to 8 bytes the end of array. It is aligned to 4 bytes already. |
1065 __ testl(end, 4); | 1066 __ testptr(end, 4); |
1066 __ jccb(Assembler::zero, L_copy_8_bytes); | 1067 __ jccb(Assembler::zero, L_copy_8_bytes); |
1067 __ subl(count, 1<<shift); | 1068 __ subl(count, 1<<shift); |
1068 __ movl(rdx, Address(from, count, sf, 0)); | 1069 __ movl(rdx, Address(from, count, sf, 0)); |
1069 __ movl(Address(to, count, sf, 0), rdx); | 1070 __ movl(Address(to, count, sf, 0), rdx); |
1070 __ jmpb(L_copy_8_bytes); | 1071 __ jmpb(L_copy_8_bytes); |
1109 } | 1110 } |
1110 } else { | 1111 } else { |
1111 __ BIND(L_copy_2_bytes); | 1112 __ BIND(L_copy_2_bytes); |
1112 } | 1113 } |
1113 if (t == T_OBJECT) { | 1114 if (t == T_OBJECT) { |
1114 __ movl(count, Address(rsp, 12+12)); // reread count | 1115 __ movl2ptr(count, Address(rsp, 12+12)); // reread count |
1115 gen_write_ref_array_post_barrier(to, count); | 1116 gen_write_ref_array_post_barrier(to, count); |
1116 __ BIND(L_0_count); | 1117 __ BIND(L_0_count); |
1117 } | 1118 } |
1118 inc_copy_counter_np(t); | 1119 inc_copy_counter_np(t); |
1119 __ popl(rdi); | 1120 __ pop(rdi); |
1120 __ popl(rsi); | 1121 __ pop(rsi); |
1121 __ leave(); // required for proper stackwalking of RuntimeStub frame | 1122 __ leave(); // required for proper stackwalking of RuntimeStub frame |
1122 __ xorl(rax, rax); // return 0 | 1123 __ xorptr(rax, rax); // return 0 |
1123 __ ret(0); | 1124 __ ret(0); |
1124 return start; | 1125 return start; |
1125 } | 1126 } |
1126 | 1127 |
1127 | 1128 |
1135 const Register to = rdx; // destination array address | 1136 const Register to = rdx; // destination array address |
1136 const Register count = rcx; // elements count | 1137 const Register count = rcx; // elements count |
1137 const Register to_from = rdx; // (to - from) | 1138 const Register to_from = rdx; // (to - from) |
1138 | 1139 |
1139 __ enter(); // required for proper stackwalking of RuntimeStub frame | 1140 __ enter(); // required for proper stackwalking of RuntimeStub frame |
1140 __ movl(from , Address(rsp, 8+0)); // from | 1141 __ movptr(from , Address(rsp, 8+0)); // from |
1141 __ movl(to , Address(rsp, 8+4)); // to | 1142 __ movptr(to , Address(rsp, 8+4)); // to |
1142 __ movl(count, Address(rsp, 8+8)); // count | 1143 __ movl2ptr(count, Address(rsp, 8+8)); // count |
1143 | 1144 |
1144 *entry = __ pc(); // Entry point from conjoint arraycopy stub. | 1145 *entry = __ pc(); // Entry point from conjoint arraycopy stub. |
1145 BLOCK_COMMENT("Entry:"); | 1146 BLOCK_COMMENT("Entry:"); |
1146 | 1147 |
1147 __ subl(to, from); // to --> to_from | 1148 __ subptr(to, from); // to --> to_from |
1148 if (VM_Version::supports_mmx()) { | 1149 if (VM_Version::supports_mmx()) { |
1149 mmx_copy_forward(from, to_from, count); | 1150 mmx_copy_forward(from, to_from, count); |
1150 } else { | 1151 } else { |
1151 __ jmpb(L_copy_8_bytes); | 1152 __ jmpb(L_copy_8_bytes); |
1152 __ align(16); | 1153 __ align(16); |
1153 __ BIND(L_copy_8_bytes_loop); | 1154 __ BIND(L_copy_8_bytes_loop); |
1154 __ fild_d(Address(from, 0)); | 1155 __ fild_d(Address(from, 0)); |
1155 __ fistp_d(Address(from, to_from, Address::times_1)); | 1156 __ fistp_d(Address(from, to_from, Address::times_1)); |
1156 __ addl(from, 8); | 1157 __ addptr(from, 8); |
1157 __ BIND(L_copy_8_bytes); | 1158 __ BIND(L_copy_8_bytes); |
1158 __ decrement(count); | 1159 __ decrement(count); |
1159 __ jcc(Assembler::greaterEqual, L_copy_8_bytes_loop); | 1160 __ jcc(Assembler::greaterEqual, L_copy_8_bytes_loop); |
1160 } | 1161 } |
1161 inc_copy_counter_np(T_LONG); | 1162 inc_copy_counter_np(T_LONG); |
1162 __ leave(); // required for proper stackwalking of RuntimeStub frame | 1163 __ leave(); // required for proper stackwalking of RuntimeStub frame |
1163 __ xorl(rax, rax); // return 0 | 1164 __ xorptr(rax, rax); // return 0 |
1164 __ ret(0); | 1165 __ ret(0); |
1165 return start; | 1166 return start; |
1166 } | 1167 } |
1167 | 1168 |
1168 address generate_conjoint_long_copy(address nooverlap_target, | 1169 address generate_conjoint_long_copy(address nooverlap_target, |
1176 const Register to = rdx; // destination array address | 1177 const Register to = rdx; // destination array address |
1177 const Register count = rcx; // elements count | 1178 const Register count = rcx; // elements count |
1178 const Register end_from = rax; // source array end address | 1179 const Register end_from = rax; // source array end address |
1179 | 1180 |
1180 __ enter(); // required for proper stackwalking of RuntimeStub frame | 1181 __ enter(); // required for proper stackwalking of RuntimeStub frame |
1181 __ movl(from , Address(rsp, 8+0)); // from | 1182 __ movptr(from , Address(rsp, 8+0)); // from |
1182 __ movl(to , Address(rsp, 8+4)); // to | 1183 __ movptr(to , Address(rsp, 8+4)); // to |
1183 __ movl(count, Address(rsp, 8+8)); // count | 1184 __ movl2ptr(count, Address(rsp, 8+8)); // count |
1184 | 1185 |
1185 *entry = __ pc(); // Entry point from generic arraycopy stub. | 1186 *entry = __ pc(); // Entry point from generic arraycopy stub. |
1186 BLOCK_COMMENT("Entry:"); | 1187 BLOCK_COMMENT("Entry:"); |
1187 | 1188 |
1188 // arrays overlap test | 1189 // arrays overlap test |
1189 __ cmpl(to, from); | 1190 __ cmpptr(to, from); |
1190 RuntimeAddress nooverlap(nooverlap_target); | 1191 RuntimeAddress nooverlap(nooverlap_target); |
1191 __ jump_cc(Assembler::belowEqual, nooverlap); | 1192 __ jump_cc(Assembler::belowEqual, nooverlap); |
1192 __ leal(end_from, Address(from, count, Address::times_8, 0)); | 1193 __ lea(end_from, Address(from, count, Address::times_8, 0)); |
1193 __ cmpl(to, end_from); | 1194 __ cmpptr(to, end_from); |
1194 __ movl(from, Address(rsp, 8)); // from | 1195 __ movptr(from, Address(rsp, 8)); // from |
1195 __ jump_cc(Assembler::aboveEqual, nooverlap); | 1196 __ jump_cc(Assembler::aboveEqual, nooverlap); |
1196 | 1197 |
1197 __ jmpb(L_copy_8_bytes); | 1198 __ jmpb(L_copy_8_bytes); |
1198 | 1199 |
1199 __ align(16); | 1200 __ align(16); |
1212 if (VM_Version::supports_mmx()) { | 1213 if (VM_Version::supports_mmx()) { |
1213 __ emms(); | 1214 __ emms(); |
1214 } | 1215 } |
1215 inc_copy_counter_np(T_LONG); | 1216 inc_copy_counter_np(T_LONG); |
1216 __ leave(); // required for proper stackwalking of RuntimeStub frame | 1217 __ leave(); // required for proper stackwalking of RuntimeStub frame |
1217 __ xorl(rax, rax); // return 0 | 1218 __ xorptr(rax, rax); // return 0 |
1218 __ ret(0); | 1219 __ ret(0); |
1219 return start; | 1220 return start; |
1220 } | 1221 } |
1221 | 1222 |
1222 | 1223 |
1249 Klass::secondary_super_cache_offset_in_bytes()); | 1250 Klass::secondary_super_cache_offset_in_bytes()); |
1250 Address secondary_supers_addr(sub_klass, ss_offset); | 1251 Address secondary_supers_addr(sub_klass, ss_offset); |
1251 Address super_cache_addr( sub_klass, sc_offset); | 1252 Address super_cache_addr( sub_klass, sc_offset); |
1252 | 1253 |
1253 // if the pointers are equal, we are done (e.g., String[] elements) | 1254 // if the pointers are equal, we are done (e.g., String[] elements) |
1254 __ cmpl(sub_klass, super_klass_addr); | 1255 __ cmpptr(sub_klass, super_klass_addr); |
1255 __ jcc(Assembler::equal, L_success); | 1256 __ jcc(Assembler::equal, L_success); |
1256 | 1257 |
1257 // check the supertype display: | 1258 // check the supertype display: |
1258 __ movl(temp, super_check_offset_addr); | 1259 __ movl2ptr(temp, super_check_offset_addr); |
1259 Address super_check_addr(sub_klass, temp, Address::times_1, 0); | 1260 Address super_check_addr(sub_klass, temp, Address::times_1, 0); |
1260 __ movl(temp, super_check_addr); // load displayed supertype | 1261 __ movptr(temp, super_check_addr); // load displayed supertype |
1261 __ cmpl(temp, super_klass_addr); // test the super type | 1262 __ cmpptr(temp, super_klass_addr); // test the super type |
1262 __ jcc(Assembler::equal, L_success); | 1263 __ jcc(Assembler::equal, L_success); |
1263 | 1264 |
1264 // if it was a primary super, we can just fail immediately | 1265 // if it was a primary super, we can just fail immediately |
1265 __ cmpl(super_check_offset_addr, sc_offset); | 1266 __ cmpl(super_check_offset_addr, sc_offset); |
1266 __ jcc(Assembler::notEqual, L_failure); | 1267 __ jcc(Assembler::notEqual, L_failure); |
1269 // This code is rarely used, so simplicity is a virtue here. | 1270 // This code is rarely used, so simplicity is a virtue here. |
1270 inc_counter_np(SharedRuntime::_partial_subtype_ctr); | 1271 inc_counter_np(SharedRuntime::_partial_subtype_ctr); |
1271 { | 1272 { |
1272 // The repne_scan instruction uses fixed registers, which we must spill. | 1273 // The repne_scan instruction uses fixed registers, which we must spill. |
1273 // (We need a couple more temps in any case.) | 1274 // (We need a couple more temps in any case.) |
1274 __ pushl(rax); | 1275 __ push(rax); |
1275 __ pushl(rcx); | 1276 __ push(rcx); |
1276 __ pushl(rdi); | 1277 __ push(rdi); |
1277 assert_different_registers(sub_klass, rax, rcx, rdi); | 1278 assert_different_registers(sub_klass, rax, rcx, rdi); |
1278 | 1279 |
1279 __ movl(rdi, secondary_supers_addr); | 1280 __ movptr(rdi, secondary_supers_addr); |
1280 // Load the array length. | 1281 // Load the array length. |
1281 __ movl(rcx, Address(rdi, arrayOopDesc::length_offset_in_bytes())); | 1282 __ movl(rcx, Address(rdi, arrayOopDesc::length_offset_in_bytes())); |
1282 // Skip to start of data. | 1283 // Skip to start of data. |
1283 __ addl(rdi, arrayOopDesc::base_offset_in_bytes(T_OBJECT)); | 1284 __ addptr(rdi, arrayOopDesc::base_offset_in_bytes(T_OBJECT)); |
1284 // Scan rcx words at [edi] for occurance of rax, | 1285 // Scan rcx words at [edi] for occurance of rax, |
1285 // Set NZ/Z based on last compare | 1286 // Set NZ/Z based on last compare |
1286 __ movl(rax, super_klass_addr); | 1287 __ movptr(rax, super_klass_addr); |
1287 __ repne_scan(); | 1288 __ repne_scan(); |
1288 | 1289 |
1289 // Unspill the temp. registers: | 1290 // Unspill the temp. registers: |
1290 __ popl(rdi); | 1291 __ pop(rdi); |
1291 __ popl(rcx); | 1292 __ pop(rcx); |
1292 __ popl(rax); | 1293 __ pop(rax); |
1293 } | 1294 } |
1294 __ jcc(Assembler::notEqual, L_failure); | 1295 __ jcc(Assembler::notEqual, L_failure); |
1295 | 1296 |
1296 // Success. Cache the super we found and proceed in triumph. | 1297 // Success. Cache the super we found and proceed in triumph. |
1297 __ movl(temp, super_klass_addr); // note: rax, is dead | 1298 __ movptr(temp, super_klass_addr); // note: rax, is dead |
1298 __ movl(super_cache_addr, temp); | 1299 __ movptr(super_cache_addr, temp); |
1299 | 1300 |
1300 if (!fall_through_on_success) | 1301 if (!fall_through_on_success) |
1301 __ jmp(L_success); | 1302 __ jmp(L_success); |
1302 | 1303 |
1303 // Fall through on failure! | 1304 // Fall through on failure! |
1336 const Register elem_klass = rsi; // each elem._klass (sub_klass) | 1337 const Register elem_klass = rsi; // each elem._klass (sub_klass) |
1337 const Register temp = rbx; // lone remaining temp | 1338 const Register temp = rbx; // lone remaining temp |
1338 | 1339 |
1339 __ enter(); // required for proper stackwalking of RuntimeStub frame | 1340 __ enter(); // required for proper stackwalking of RuntimeStub frame |
1340 | 1341 |
1341 __ pushl(rsi); | 1342 __ push(rsi); |
1342 __ pushl(rdi); | 1343 __ push(rdi); |
1343 __ pushl(rbx); | 1344 __ push(rbx); |
1344 | 1345 |
1345 Address from_arg(rsp, 16+ 4); // from | 1346 Address from_arg(rsp, 16+ 4); // from |
1346 Address to_arg(rsp, 16+ 8); // to | 1347 Address to_arg(rsp, 16+ 8); // to |
1347 Address length_arg(rsp, 16+12); // elements count | 1348 Address length_arg(rsp, 16+12); // elements count |
1348 Address ckoff_arg(rsp, 16+16); // super_check_offset | 1349 Address ckoff_arg(rsp, 16+16); // super_check_offset |
1349 Address ckval_arg(rsp, 16+20); // super_klass | 1350 Address ckval_arg(rsp, 16+20); // super_klass |
1350 | 1351 |
1351 // Load up: | 1352 // Load up: |
1352 __ movl(from, from_arg); | 1353 __ movptr(from, from_arg); |
1353 __ movl(to, to_arg); | 1354 __ movptr(to, to_arg); |
1354 __ movl(length, length_arg); | 1355 __ movl2ptr(length, length_arg); |
1355 | 1356 |
1356 *entry = __ pc(); // Entry point from generic arraycopy stub. | 1357 *entry = __ pc(); // Entry point from generic arraycopy stub. |
1357 BLOCK_COMMENT("Entry:"); | 1358 BLOCK_COMMENT("Entry:"); |
1358 | 1359 |
1359 //--------------------------------------------------------------- | 1360 //--------------------------------------------------------------- |
1362 // destination array type is not equal to or a supertype | 1363 // destination array type is not equal to or a supertype |
1363 // of the source type. Each element must be separately | 1364 // of the source type. Each element must be separately |
1364 // checked. | 1365 // checked. |
1365 | 1366 |
1366 // Loop-invariant addresses. They are exclusive end pointers. | 1367 // Loop-invariant addresses. They are exclusive end pointers. |
1367 Address end_from_addr(from, length, Address::times_4, 0); | 1368 Address end_from_addr(from, length, Address::times_ptr, 0); |
1368 Address end_to_addr(to, length, Address::times_4, 0); | 1369 Address end_to_addr(to, length, Address::times_ptr, 0); |
1369 | 1370 |
1370 Register end_from = from; // re-use | 1371 Register end_from = from; // re-use |
1371 Register end_to = to; // re-use | 1372 Register end_to = to; // re-use |
1372 Register count = length; // re-use | 1373 Register count = length; // re-use |
1373 | 1374 |
1374 // Loop-variant addresses. They assume post-incremented count < 0. | 1375 // Loop-variant addresses. They assume post-incremented count < 0. |
1375 Address from_element_addr(end_from, count, Address::times_4, 0); | 1376 Address from_element_addr(end_from, count, Address::times_ptr, 0); |
1376 Address to_element_addr(end_to, count, Address::times_4, 0); | 1377 Address to_element_addr(end_to, count, Address::times_ptr, 0); |
1377 Address elem_klass_addr(elem, oopDesc::klass_offset_in_bytes()); | 1378 Address elem_klass_addr(elem, oopDesc::klass_offset_in_bytes()); |
1378 | 1379 |
1379 // Copy from low to high addresses, indexed from the end of each array. | 1380 // Copy from low to high addresses, indexed from the end of each array. |
1380 __ leal(end_from, end_from_addr); | 1381 __ lea(end_from, end_from_addr); |
1381 __ leal(end_to, end_to_addr); | 1382 __ lea(end_to, end_to_addr); |
1382 gen_write_ref_array_pre_barrier(to, count); | 1383 gen_write_ref_array_pre_barrier(to, count); |
1383 assert(length == count, ""); // else fix next line: | 1384 assert(length == count, ""); // else fix next line: |
1384 __ negl(count); // negate and test the length | 1385 __ negptr(count); // negate and test the length |
1385 __ jccb(Assembler::notZero, L_load_element); | 1386 __ jccb(Assembler::notZero, L_load_element); |
1386 | 1387 |
1387 // Empty array: Nothing to do. | 1388 // Empty array: Nothing to do. |
1388 __ xorl(rax, rax); // return 0 on (trivial) success | 1389 __ xorptr(rax, rax); // return 0 on (trivial) success |
1389 __ jmp(L_done); | 1390 __ jmp(L_done); |
1390 | 1391 |
1391 // ======== begin loop ======== | 1392 // ======== begin loop ======== |
1392 // (Loop is rotated; its entry is L_load_element.) | 1393 // (Loop is rotated; its entry is L_load_element.) |
1393 // Loop control: | 1394 // Loop control: |
1394 // for (count = -count; count != 0; count++) | 1395 // for (count = -count; count != 0; count++) |
1395 // Base pointers src, dst are biased by 8*count,to last element. | 1396 // Base pointers src, dst are biased by 8*count,to last element. |
1396 __ align(16); | 1397 __ align(16); |
1397 | 1398 |
1398 __ BIND(L_store_element); | 1399 __ BIND(L_store_element); |
1399 __ movl(to_element_addr, elem); // store the oop | 1400 __ movptr(to_element_addr, elem); // store the oop |
1400 __ increment(count); // increment the count toward zero | 1401 __ increment(count); // increment the count toward zero |
1401 __ jccb(Assembler::zero, L_do_card_marks); | 1402 __ jccb(Assembler::zero, L_do_card_marks); |
1402 | 1403 |
1403 // ======== loop entry is here ======== | 1404 // ======== loop entry is here ======== |
1404 __ BIND(L_load_element); | 1405 __ BIND(L_load_element); |
1405 __ movl(elem, from_element_addr); // load the oop | 1406 __ movptr(elem, from_element_addr); // load the oop |
1406 __ testl(elem, elem); | 1407 __ testptr(elem, elem); |
1407 __ jccb(Assembler::zero, L_store_element); | 1408 __ jccb(Assembler::zero, L_store_element); |
1408 | 1409 |
1409 // (Could do a trick here: Remember last successful non-null | 1410 // (Could do a trick here: Remember last successful non-null |
1410 // element stored and make a quick oop equality check on it.) | 1411 // element stored and make a quick oop equality check on it.) |
1411 | 1412 |
1412 __ movl(elem_klass, elem_klass_addr); // query the object klass | 1413 __ movptr(elem_klass, elem_klass_addr); // query the object klass |
1413 generate_type_check(elem_klass, ckoff_arg, ckval_arg, temp, | 1414 generate_type_check(elem_klass, ckoff_arg, ckval_arg, temp, |
1414 &L_store_element, NULL); | 1415 &L_store_element, NULL); |
1415 // (On fall-through, we have failed the element type check.) | 1416 // (On fall-through, we have failed the element type check.) |
1416 // ======== end loop ======== | 1417 // ======== end loop ======== |
1417 | 1418 |
1418 // It was a real error; we must depend on the caller to finish the job. | 1419 // It was a real error; we must depend on the caller to finish the job. |
1419 // Register "count" = -1 * number of *remaining* oops, length_arg = *total* oops. | 1420 // Register "count" = -1 * number of *remaining* oops, length_arg = *total* oops. |
1420 // Emit GC store barriers for the oops we have copied (length_arg + count), | 1421 // Emit GC store barriers for the oops we have copied (length_arg + count), |
1421 // and report their number to the caller. | 1422 // and report their number to the caller. |
1422 __ addl(count, length_arg); // transfers = (length - remaining) | 1423 __ addl(count, length_arg); // transfers = (length - remaining) |
1423 __ movl(rax, count); // save the value | 1424 __ movl2ptr(rax, count); // save the value |
1424 __ notl(rax); // report (-1^K) to caller | 1425 __ notptr(rax); // report (-1^K) to caller |
1425 __ movl(to, to_arg); // reload | 1426 __ movptr(to, to_arg); // reload |
1426 assert_different_registers(to, count, rax); | 1427 assert_different_registers(to, count, rax); |
1427 gen_write_ref_array_post_barrier(to, count); | 1428 gen_write_ref_array_post_barrier(to, count); |
1428 __ jmpb(L_done); | 1429 __ jmpb(L_done); |
1429 | 1430 |
1430 // Come here on success only. | 1431 // Come here on success only. |
1431 __ BIND(L_do_card_marks); | 1432 __ BIND(L_do_card_marks); |
1432 __ movl(count, length_arg); | 1433 __ movl2ptr(count, length_arg); |
1433 __ movl(to, to_arg); // reload | 1434 __ movptr(to, to_arg); // reload |
1434 gen_write_ref_array_post_barrier(to, count); | 1435 gen_write_ref_array_post_barrier(to, count); |
1435 __ xorl(rax, rax); // return 0 on success | 1436 __ xorptr(rax, rax); // return 0 on success |
1436 | 1437 |
1437 // Common exit point (success or failure). | 1438 // Common exit point (success or failure). |
1438 __ BIND(L_done); | 1439 __ BIND(L_done); |
1439 __ popl(rbx); | 1440 __ pop(rbx); |
1440 __ popl(rdi); | 1441 __ pop(rdi); |
1441 __ popl(rsi); | 1442 __ pop(rsi); |
1442 inc_counter_np(SharedRuntime::_checkcast_array_copy_ctr); | 1443 inc_counter_np(SharedRuntime::_checkcast_array_copy_ctr); |
1443 __ leave(); // required for proper stackwalking of RuntimeStub frame | 1444 __ leave(); // required for proper stackwalking of RuntimeStub frame |
1444 __ ret(0); | 1445 __ ret(0); |
1445 | 1446 |
1446 return start; | 1447 return start; |
1478 const Register from = rax; // source array address | 1479 const Register from = rax; // source array address |
1479 const Register to = rdx; // destination array address | 1480 const Register to = rdx; // destination array address |
1480 const Register count = rcx; // elements count | 1481 const Register count = rcx; // elements count |
1481 | 1482 |
1482 __ enter(); // required for proper stackwalking of RuntimeStub frame | 1483 __ enter(); // required for proper stackwalking of RuntimeStub frame |
1483 __ pushl(rsi); | 1484 __ push(rsi); |
1484 __ pushl(rdi); | 1485 __ push(rdi); |
1485 Address from_arg(rsp, 12+ 4); // from | 1486 Address from_arg(rsp, 12+ 4); // from |
1486 Address to_arg(rsp, 12+ 8); // to | 1487 Address to_arg(rsp, 12+ 8); // to |
1487 Address count_arg(rsp, 12+12); // byte count | 1488 Address count_arg(rsp, 12+12); // byte count |
1488 | 1489 |
1489 // Load up: | 1490 // Load up: |
1490 __ movl(from , from_arg); | 1491 __ movptr(from , from_arg); |
1491 __ movl(to , to_arg); | 1492 __ movptr(to , to_arg); |
1492 __ movl(count, count_arg); | 1493 __ movl2ptr(count, count_arg); |
1493 | 1494 |
1494 // bump this on entry, not on exit: | 1495 // bump this on entry, not on exit: |
1495 inc_counter_np(SharedRuntime::_unsafe_array_copy_ctr); | 1496 inc_counter_np(SharedRuntime::_unsafe_array_copy_ctr); |
1496 | 1497 |
1497 const Register bits = rsi; | 1498 const Register bits = rsi; |
1498 __ movl(bits, from); | 1499 __ mov(bits, from); |
1499 __ orl(bits, to); | 1500 __ orptr(bits, to); |
1500 __ orl(bits, count); | 1501 __ orptr(bits, count); |
1501 | 1502 |
1502 __ testl(bits, BytesPerLong-1); | 1503 __ testl(bits, BytesPerLong-1); |
1503 __ jccb(Assembler::zero, L_long_aligned); | 1504 __ jccb(Assembler::zero, L_long_aligned); |
1504 | 1505 |
1505 __ testl(bits, BytesPerInt-1); | 1506 __ testl(bits, BytesPerInt-1); |
1507 | 1508 |
1508 __ testl(bits, BytesPerShort-1); | 1509 __ testl(bits, BytesPerShort-1); |
1509 __ jump_cc(Assembler::notZero, RuntimeAddress(byte_copy_entry)); | 1510 __ jump_cc(Assembler::notZero, RuntimeAddress(byte_copy_entry)); |
1510 | 1511 |
1511 __ BIND(L_short_aligned); | 1512 __ BIND(L_short_aligned); |
1512 __ shrl(count, LogBytesPerShort); // size => short_count | 1513 __ shrptr(count, LogBytesPerShort); // size => short_count |
1513 __ movl(count_arg, count); // update 'count' | 1514 __ movl(count_arg, count); // update 'count' |
1514 __ jump(RuntimeAddress(short_copy_entry)); | 1515 __ jump(RuntimeAddress(short_copy_entry)); |
1515 | 1516 |
1516 __ BIND(L_int_aligned); | 1517 __ BIND(L_int_aligned); |
1517 __ shrl(count, LogBytesPerInt); // size => int_count | 1518 __ shrptr(count, LogBytesPerInt); // size => int_count |
1518 __ movl(count_arg, count); // update 'count' | 1519 __ movl(count_arg, count); // update 'count' |
1519 __ jump(RuntimeAddress(int_copy_entry)); | 1520 __ jump(RuntimeAddress(int_copy_entry)); |
1520 | 1521 |
1521 __ BIND(L_long_aligned); | 1522 __ BIND(L_long_aligned); |
1522 __ shrl(count, LogBytesPerLong); // size => qword_count | 1523 __ shrptr(count, LogBytesPerLong); // size => qword_count |
1523 __ movl(count_arg, count); // update 'count' | 1524 __ movl(count_arg, count); // update 'count' |
1524 __ popl(rdi); // Do pops here since jlong_arraycopy stub does not do it. | 1525 __ pop(rdi); // Do pops here since jlong_arraycopy stub does not do it. |
1525 __ popl(rsi); | 1526 __ pop(rsi); |
1526 __ jump(RuntimeAddress(long_copy_entry)); | 1527 __ jump(RuntimeAddress(long_copy_entry)); |
1527 | 1528 |
1528 return start; | 1529 return start; |
1529 } | 1530 } |
1530 | 1531 |
1593 | 1594 |
1594 __ align(CodeEntryAlignment); | 1595 __ align(CodeEntryAlignment); |
1595 address start = __ pc(); | 1596 address start = __ pc(); |
1596 | 1597 |
1597 __ enter(); // required for proper stackwalking of RuntimeStub frame | 1598 __ enter(); // required for proper stackwalking of RuntimeStub frame |
1598 __ pushl(rsi); | 1599 __ push(rsi); |
1599 __ pushl(rdi); | 1600 __ push(rdi); |
1600 | 1601 |
1601 // bump this on entry, not on exit: | 1602 // bump this on entry, not on exit: |
1602 inc_counter_np(SharedRuntime::_generic_array_copy_ctr); | 1603 inc_counter_np(SharedRuntime::_generic_array_copy_ctr); |
1603 | 1604 |
1604 // Input values | 1605 // Input values |
1627 const Register dst = rdx; // destination array oop | 1628 const Register dst = rdx; // destination array oop |
1628 const Register dst_pos = rdi; | 1629 const Register dst_pos = rdi; |
1629 const Register length = rcx; // transfer count | 1630 const Register length = rcx; // transfer count |
1630 | 1631 |
1631 // if (src == NULL) return -1; | 1632 // if (src == NULL) return -1; |
1632 __ movl(src, SRC); // src oop | 1633 __ movptr(src, SRC); // src oop |
1633 __ testl(src, src); | 1634 __ testptr(src, src); |
1634 __ jccb(Assembler::zero, L_failed_0); | 1635 __ jccb(Assembler::zero, L_failed_0); |
1635 | 1636 |
1636 // if (src_pos < 0) return -1; | 1637 // if (src_pos < 0) return -1; |
1637 __ movl(src_pos, SRC_POS); // src_pos | 1638 __ movl2ptr(src_pos, SRC_POS); // src_pos |
1638 __ testl(src_pos, src_pos); | 1639 __ testl(src_pos, src_pos); |
1639 __ jccb(Assembler::negative, L_failed_0); | 1640 __ jccb(Assembler::negative, L_failed_0); |
1640 | 1641 |
1641 // if (dst == NULL) return -1; | 1642 // if (dst == NULL) return -1; |
1642 __ movl(dst, DST); // dst oop | 1643 __ movptr(dst, DST); // dst oop |
1643 __ testl(dst, dst); | 1644 __ testptr(dst, dst); |
1644 __ jccb(Assembler::zero, L_failed_0); | 1645 __ jccb(Assembler::zero, L_failed_0); |
1645 | 1646 |
1646 // if (dst_pos < 0) return -1; | 1647 // if (dst_pos < 0) return -1; |
1647 __ movl(dst_pos, DST_POS); // dst_pos | 1648 __ movl2ptr(dst_pos, DST_POS); // dst_pos |
1648 __ testl(dst_pos, dst_pos); | 1649 __ testl(dst_pos, dst_pos); |
1649 __ jccb(Assembler::negative, L_failed_0); | 1650 __ jccb(Assembler::negative, L_failed_0); |
1650 | 1651 |
1651 // if (length < 0) return -1; | 1652 // if (length < 0) return -1; |
1652 __ movl(length, LENGTH); // length | 1653 __ movl2ptr(length, LENGTH); // length |
1653 __ testl(length, length); | 1654 __ testl(length, length); |
1654 __ jccb(Assembler::negative, L_failed_0); | 1655 __ jccb(Assembler::negative, L_failed_0); |
1655 | 1656 |
1656 // if (src->klass() == NULL) return -1; | 1657 // if (src->klass() == NULL) return -1; |
1657 Address src_klass_addr(src, oopDesc::klass_offset_in_bytes()); | 1658 Address src_klass_addr(src, oopDesc::klass_offset_in_bytes()); |
1658 Address dst_klass_addr(dst, oopDesc::klass_offset_in_bytes()); | 1659 Address dst_klass_addr(dst, oopDesc::klass_offset_in_bytes()); |
1659 const Register rcx_src_klass = rcx; // array klass | 1660 const Register rcx_src_klass = rcx; // array klass |
1660 __ movl(rcx_src_klass, Address(src, oopDesc::klass_offset_in_bytes())); | 1661 __ movptr(rcx_src_klass, Address(src, oopDesc::klass_offset_in_bytes())); |
1661 | 1662 |
1662 #ifdef ASSERT | 1663 #ifdef ASSERT |
1663 // assert(src->klass() != NULL); | 1664 // assert(src->klass() != NULL); |
1664 BLOCK_COMMENT("assert klasses not null"); | 1665 BLOCK_COMMENT("assert klasses not null"); |
1665 { Label L1, L2; | 1666 { Label L1, L2; |
1666 __ testl(rcx_src_klass, rcx_src_klass); | 1667 __ testptr(rcx_src_klass, rcx_src_klass); |
1667 __ jccb(Assembler::notZero, L2); // it is broken if klass is NULL | 1668 __ jccb(Assembler::notZero, L2); // it is broken if klass is NULL |
1668 __ bind(L1); | 1669 __ bind(L1); |
1669 __ stop("broken null klass"); | 1670 __ stop("broken null klass"); |
1670 __ bind(L2); | 1671 __ bind(L2); |
1671 __ cmpl(dst_klass_addr, 0); | 1672 __ cmpptr(dst_klass_addr, (int32_t)NULL_WORD); |
1672 __ jccb(Assembler::equal, L1); // this would be broken also | 1673 __ jccb(Assembler::equal, L1); // this would be broken also |
1673 BLOCK_COMMENT("assert done"); | 1674 BLOCK_COMMENT("assert done"); |
1674 } | 1675 } |
1675 #endif //ASSERT | 1676 #endif //ASSERT |
1676 | 1677 |
1690 jint objArray_lh = Klass::array_layout_helper(T_OBJECT); | 1691 jint objArray_lh = Klass::array_layout_helper(T_OBJECT); |
1691 __ cmpl(src_klass_lh_addr, objArray_lh); | 1692 __ cmpl(src_klass_lh_addr, objArray_lh); |
1692 __ jcc(Assembler::equal, L_objArray); | 1693 __ jcc(Assembler::equal, L_objArray); |
1693 | 1694 |
1694 // if (src->klass() != dst->klass()) return -1; | 1695 // if (src->klass() != dst->klass()) return -1; |
1695 __ cmpl(rcx_src_klass, dst_klass_addr); | 1696 __ cmpptr(rcx_src_klass, dst_klass_addr); |
1696 __ jccb(Assembler::notEqual, L_failed_0); | 1697 __ jccb(Assembler::notEqual, L_failed_0); |
1697 | 1698 |
1698 const Register rcx_lh = rcx; // layout helper | 1699 const Register rcx_lh = rcx; // layout helper |
1699 assert(rcx_lh == rcx_src_klass, "known alias"); | 1700 assert(rcx_lh == rcx_src_klass, "known alias"); |
1700 __ movl(rcx_lh, src_klass_lh_addr); | 1701 __ movl(rcx_lh, src_klass_lh_addr); |
1724 const Register rsi_offset = rsi; // array offset | 1725 const Register rsi_offset = rsi; // array offset |
1725 const Register src_array = src; // src array offset | 1726 const Register src_array = src; // src array offset |
1726 const Register dst_array = dst; // dst array offset | 1727 const Register dst_array = dst; // dst array offset |
1727 const Register rdi_elsize = rdi; // log2 element size | 1728 const Register rdi_elsize = rdi; // log2 element size |
1728 | 1729 |
1729 __ movl(rsi_offset, rcx_lh); | 1730 __ mov(rsi_offset, rcx_lh); |
1730 __ shrl(rsi_offset, Klass::_lh_header_size_shift); | 1731 __ shrptr(rsi_offset, Klass::_lh_header_size_shift); |
1731 __ andl(rsi_offset, Klass::_lh_header_size_mask); // array_offset | 1732 __ andptr(rsi_offset, Klass::_lh_header_size_mask); // array_offset |
1732 __ addl(src_array, rsi_offset); // src array offset | 1733 __ addptr(src_array, rsi_offset); // src array offset |
1733 __ addl(dst_array, rsi_offset); // dst array offset | 1734 __ addptr(dst_array, rsi_offset); // dst array offset |
1734 __ andl(rcx_lh, Klass::_lh_log2_element_size_mask); // log2 elsize | 1735 __ andptr(rcx_lh, Klass::_lh_log2_element_size_mask); // log2 elsize |
1735 | 1736 |
1736 // next registers should be set before the jump to corresponding stub | 1737 // next registers should be set before the jump to corresponding stub |
1737 const Register from = src; // source array address | 1738 const Register from = src; // source array address |
1738 const Register to = dst; // destination array address | 1739 const Register to = dst; // destination array address |
1739 const Register count = rcx; // elements count | 1740 const Register count = rcx; // elements count |
1741 #define FROM Address(rsp, 12+ 4) | 1742 #define FROM Address(rsp, 12+ 4) |
1742 #define TO Address(rsp, 12+ 8) // Not used now | 1743 #define TO Address(rsp, 12+ 8) // Not used now |
1743 #define COUNT Address(rsp, 12+12) // Only for oop arraycopy | 1744 #define COUNT Address(rsp, 12+12) // Only for oop arraycopy |
1744 | 1745 |
1745 BLOCK_COMMENT("scale indexes to element size"); | 1746 BLOCK_COMMENT("scale indexes to element size"); |
1746 __ movl(rsi, SRC_POS); // src_pos | 1747 __ movl2ptr(rsi, SRC_POS); // src_pos |
1747 __ shll(rsi); // src_pos << rcx (log2 elsize) | 1748 __ shlptr(rsi); // src_pos << rcx (log2 elsize) |
1748 assert(src_array == from, ""); | 1749 assert(src_array == from, ""); |
1749 __ addl(from, rsi); // from = src_array + SRC_POS << log2 elsize | 1750 __ addptr(from, rsi); // from = src_array + SRC_POS << log2 elsize |
1750 __ movl(rdi, DST_POS); // dst_pos | 1751 __ movl2ptr(rdi, DST_POS); // dst_pos |
1751 __ shll(rdi); // dst_pos << rcx (log2 elsize) | 1752 __ shlptr(rdi); // dst_pos << rcx (log2 elsize) |
1752 assert(dst_array == to, ""); | 1753 assert(dst_array == to, ""); |
1753 __ addl(to, rdi); // to = dst_array + DST_POS << log2 elsize | 1754 __ addptr(to, rdi); // to = dst_array + DST_POS << log2 elsize |
1754 __ movl(FROM, from); // src_addr | 1755 __ movptr(FROM, from); // src_addr |
1755 __ movl(rdi_elsize, rcx_lh); // log2 elsize | 1756 __ mov(rdi_elsize, rcx_lh); // log2 elsize |
1756 __ movl(count, LENGTH); // elements count | 1757 __ movl2ptr(count, LENGTH); // elements count |
1757 | 1758 |
1758 BLOCK_COMMENT("choose copy loop based on element size"); | 1759 BLOCK_COMMENT("choose copy loop based on element size"); |
1759 __ cmpl(rdi_elsize, 0); | 1760 __ cmpl(rdi_elsize, 0); |
1760 | 1761 |
1761 __ jump_cc(Assembler::equal, RuntimeAddress(entry_jbyte_arraycopy)); | 1762 __ jump_cc(Assembler::equal, RuntimeAddress(entry_jbyte_arraycopy)); |
1765 __ jump_cc(Assembler::equal, RuntimeAddress(entry_jint_arraycopy)); | 1766 __ jump_cc(Assembler::equal, RuntimeAddress(entry_jint_arraycopy)); |
1766 #ifdef ASSERT | 1767 #ifdef ASSERT |
1767 __ cmpl(rdi_elsize, LogBytesPerLong); | 1768 __ cmpl(rdi_elsize, LogBytesPerLong); |
1768 __ jccb(Assembler::notEqual, L_failed); | 1769 __ jccb(Assembler::notEqual, L_failed); |
1769 #endif | 1770 #endif |
1770 __ popl(rdi); // Do pops here since jlong_arraycopy stub does not do it. | 1771 __ pop(rdi); // Do pops here since jlong_arraycopy stub does not do it. |
1771 __ popl(rsi); | 1772 __ pop(rsi); |
1772 __ jump(RuntimeAddress(entry_jlong_arraycopy)); | 1773 __ jump(RuntimeAddress(entry_jlong_arraycopy)); |
1773 | 1774 |
1774 __ BIND(L_failed); | 1775 __ BIND(L_failed); |
1775 __ xorl(rax, rax); | 1776 __ xorptr(rax, rax); |
1776 __ notl(rax); // return -1 | 1777 __ notptr(rax); // return -1 |
1777 __ popl(rdi); | 1778 __ pop(rdi); |
1778 __ popl(rsi); | 1779 __ pop(rsi); |
1779 __ leave(); // required for proper stackwalking of RuntimeStub frame | 1780 __ leave(); // required for proper stackwalking of RuntimeStub frame |
1780 __ ret(0); | 1781 __ ret(0); |
1781 | 1782 |
1782 // objArrayKlass | 1783 // objArrayKlass |
1783 __ BIND(L_objArray); | 1784 __ BIND(L_objArray); |
1784 // live at this point: rcx_src_klass, src[_pos], dst[_pos] | 1785 // live at this point: rcx_src_klass, src[_pos], dst[_pos] |
1785 | 1786 |
1786 Label L_plain_copy, L_checkcast_copy; | 1787 Label L_plain_copy, L_checkcast_copy; |
1787 // test array classes for subtyping | 1788 // test array classes for subtyping |
1788 __ cmpl(rcx_src_klass, dst_klass_addr); // usual case is exact equality | 1789 __ cmpptr(rcx_src_klass, dst_klass_addr); // usual case is exact equality |
1789 __ jccb(Assembler::notEqual, L_checkcast_copy); | 1790 __ jccb(Assembler::notEqual, L_checkcast_copy); |
1790 | 1791 |
1791 // Identically typed arrays can be copied without element-wise checks. | 1792 // Identically typed arrays can be copied without element-wise checks. |
1792 assert_different_registers(src, src_pos, dst, dst_pos, rcx_src_klass); | 1793 assert_different_registers(src, src_pos, dst, dst_pos, rcx_src_klass); |
1793 arraycopy_range_checks(src, src_pos, dst, dst_pos, LENGTH, L_failed); | 1794 arraycopy_range_checks(src, src_pos, dst, dst_pos, LENGTH, L_failed); |
1794 | 1795 |
1795 __ BIND(L_plain_copy); | 1796 __ BIND(L_plain_copy); |
1796 __ movl(count, LENGTH); // elements count | 1797 __ movl2ptr(count, LENGTH); // elements count |
1797 __ movl(src_pos, SRC_POS); // reload src_pos | 1798 __ movl2ptr(src_pos, SRC_POS); // reload src_pos |
1798 __ leal(from, Address(src, src_pos, Address::times_4, | 1799 __ lea(from, Address(src, src_pos, Address::times_ptr, |
1799 arrayOopDesc::base_offset_in_bytes(T_OBJECT))); // src_addr | 1800 arrayOopDesc::base_offset_in_bytes(T_OBJECT))); // src_addr |
1800 __ movl(dst_pos, DST_POS); // reload dst_pos | 1801 __ movl2ptr(dst_pos, DST_POS); // reload dst_pos |
1801 __ leal(to, Address(dst, dst_pos, Address::times_4, | 1802 __ lea(to, Address(dst, dst_pos, Address::times_ptr, |
1802 arrayOopDesc::base_offset_in_bytes(T_OBJECT))); // dst_addr | 1803 arrayOopDesc::base_offset_in_bytes(T_OBJECT))); // dst_addr |
1803 __ movl(FROM, from); // src_addr | 1804 __ movptr(FROM, from); // src_addr |
1804 __ movl(TO, to); // dst_addr | 1805 __ movptr(TO, to); // dst_addr |
1805 __ movl(COUNT, count); // count | 1806 __ movl(COUNT, count); // count |
1806 __ jump(RuntimeAddress(entry_oop_arraycopy)); | 1807 __ jump(RuntimeAddress(entry_oop_arraycopy)); |
1807 | 1808 |
1808 __ BIND(L_checkcast_copy); | 1809 __ BIND(L_checkcast_copy); |
1809 // live at this point: rcx_src_klass, dst[_pos], src[_pos] | 1810 // live at this point: rcx_src_klass, dst[_pos], src[_pos] |
1819 assert(rsi_dst_klass == src_pos, "expected alias w/ src_pos"); | 1820 assert(rsi_dst_klass == src_pos, "expected alias w/ src_pos"); |
1820 assert(rdi_temp == dst_pos, "expected alias w/ dst_pos"); | 1821 assert(rdi_temp == dst_pos, "expected alias w/ dst_pos"); |
1821 Address dst_klass_lh_addr(rsi_dst_klass, lh_offset); | 1822 Address dst_klass_lh_addr(rsi_dst_klass, lh_offset); |
1822 | 1823 |
1823 // Before looking at dst.length, make sure dst is also an objArray. | 1824 // Before looking at dst.length, make sure dst is also an objArray. |
1824 __ movl(rsi_dst_klass, dst_klass_addr); | 1825 __ movptr(rsi_dst_klass, dst_klass_addr); |
1825 __ cmpl(dst_klass_lh_addr, objArray_lh); | 1826 __ cmpl(dst_klass_lh_addr, objArray_lh); |
1826 __ jccb(Assembler::notEqual, L_failed); | 1827 __ jccb(Assembler::notEqual, L_failed); |
1827 | 1828 |
1828 // It is safe to examine both src.length and dst.length. | 1829 // It is safe to examine both src.length and dst.length. |
1829 __ movl(src_pos, SRC_POS); // reload rsi | 1830 __ movl2ptr(src_pos, SRC_POS); // reload rsi |
1830 arraycopy_range_checks(src, src_pos, dst, dst_pos, LENGTH, L_failed); | 1831 arraycopy_range_checks(src, src_pos, dst, dst_pos, LENGTH, L_failed); |
1831 // (Now src_pos and dst_pos are killed, but not src and dst.) | 1832 // (Now src_pos and dst_pos are killed, but not src and dst.) |
1832 | 1833 |
1833 // We'll need this temp (don't forget to pop it after the type check). | 1834 // We'll need this temp (don't forget to pop it after the type check). |
1834 __ pushl(rbx); | 1835 __ push(rbx); |
1835 Register rbx_src_klass = rbx; | 1836 Register rbx_src_klass = rbx; |
1836 | 1837 |
1837 __ movl(rbx_src_klass, rcx_src_klass); // spill away from rcx | 1838 __ mov(rbx_src_klass, rcx_src_klass); // spill away from rcx |
1838 __ movl(rsi_dst_klass, dst_klass_addr); | 1839 __ movptr(rsi_dst_klass, dst_klass_addr); |
1839 Address super_check_offset_addr(rsi_dst_klass, sco_offset); | 1840 Address super_check_offset_addr(rsi_dst_klass, sco_offset); |
1840 Label L_fail_array_check; | 1841 Label L_fail_array_check; |
1841 generate_type_check(rbx_src_klass, | 1842 generate_type_check(rbx_src_klass, |
1842 super_check_offset_addr, dst_klass_addr, | 1843 super_check_offset_addr, dst_klass_addr, |
1843 rdi_temp, NULL, &L_fail_array_check); | 1844 rdi_temp, NULL, &L_fail_array_check); |
1844 // (On fall-through, we have passed the array type check.) | 1845 // (On fall-through, we have passed the array type check.) |
1845 __ popl(rbx); | 1846 __ pop(rbx); |
1846 __ jmp(L_plain_copy); | 1847 __ jmp(L_plain_copy); |
1847 | 1848 |
1848 __ BIND(L_fail_array_check); | 1849 __ BIND(L_fail_array_check); |
1849 // Reshuffle arguments so we can call checkcast_arraycopy: | 1850 // Reshuffle arguments so we can call checkcast_arraycopy: |
1850 | 1851 |
1851 // match initial saves for checkcast_arraycopy | 1852 // match initial saves for checkcast_arraycopy |
1852 // pushl(rsi); // already done; see above | 1853 // push(rsi); // already done; see above |
1853 // pushl(rdi); // already done; see above | 1854 // push(rdi); // already done; see above |
1854 // pushl(rbx); // already done; see above | 1855 // push(rbx); // already done; see above |
1855 | 1856 |
1856 // Marshal outgoing arguments now, freeing registers. | 1857 // Marshal outgoing arguments now, freeing registers. |
1857 Address from_arg(rsp, 16+ 4); // from | 1858 Address from_arg(rsp, 16+ 4); // from |
1858 Address to_arg(rsp, 16+ 8); // to | 1859 Address to_arg(rsp, 16+ 8); // to |
1859 Address length_arg(rsp, 16+12); // elements count | 1860 Address length_arg(rsp, 16+12); // elements count |
1864 Address DST_POS_arg(rsp, 16+16); | 1865 Address DST_POS_arg(rsp, 16+16); |
1865 Address LENGTH_arg(rsp, 16+20); | 1866 Address LENGTH_arg(rsp, 16+20); |
1866 // push rbx, changed the incoming offsets (why not just use rbp,??) | 1867 // push rbx, changed the incoming offsets (why not just use rbp,??) |
1867 // assert(SRC_POS_arg.disp() == SRC_POS.disp() + 4, ""); | 1868 // assert(SRC_POS_arg.disp() == SRC_POS.disp() + 4, ""); |
1868 | 1869 |
1869 __ movl(rbx, Address(rsi_dst_klass, ek_offset)); | 1870 __ movptr(rbx, Address(rsi_dst_klass, ek_offset)); |
1870 __ movl(length, LENGTH_arg); // reload elements count | 1871 __ movl2ptr(length, LENGTH_arg); // reload elements count |
1871 __ movl(src_pos, SRC_POS_arg); // reload src_pos | 1872 __ movl2ptr(src_pos, SRC_POS_arg); // reload src_pos |
1872 __ movl(dst_pos, DST_POS_arg); // reload dst_pos | 1873 __ movl2ptr(dst_pos, DST_POS_arg); // reload dst_pos |
1873 | 1874 |
1874 __ movl(ckval_arg, rbx); // destination element type | 1875 __ movptr(ckval_arg, rbx); // destination element type |
1875 __ movl(rbx, Address(rbx, sco_offset)); | 1876 __ movl(rbx, Address(rbx, sco_offset)); |
1876 __ movl(ckoff_arg, rbx); // corresponding class check offset | 1877 __ movl(ckoff_arg, rbx); // corresponding class check offset |
1877 | 1878 |
1878 __ movl(length_arg, length); // outgoing length argument | 1879 __ movl(length_arg, length); // outgoing length argument |
1879 | 1880 |
1880 __ leal(from, Address(src, src_pos, Address::times_4, | 1881 __ lea(from, Address(src, src_pos, Address::times_ptr, |
1881 arrayOopDesc::base_offset_in_bytes(T_OBJECT))); | 1882 arrayOopDesc::base_offset_in_bytes(T_OBJECT))); |
1882 __ movl(from_arg, from); | 1883 __ movptr(from_arg, from); |
1883 | 1884 |
1884 __ leal(to, Address(dst, dst_pos, Address::times_4, | 1885 __ lea(to, Address(dst, dst_pos, Address::times_ptr, |
1885 arrayOopDesc::base_offset_in_bytes(T_OBJECT))); | 1886 arrayOopDesc::base_offset_in_bytes(T_OBJECT))); |
1886 __ movl(to_arg, to); | 1887 __ movptr(to_arg, to); |
1887 __ jump(RuntimeAddress(entry_checkcast_arraycopy)); | 1888 __ jump(RuntimeAddress(entry_checkcast_arraycopy)); |
1888 } | 1889 } |
1889 | 1890 |
1890 return start; | 1891 return start; |
1891 } | 1892 } |
1932 StubRoutines::_jint_arraycopy = | 1933 StubRoutines::_jint_arraycopy = |
1933 generate_conjoint_copy(T_INT, true, Address::times_4, entry, | 1934 generate_conjoint_copy(T_INT, true, Address::times_4, entry, |
1934 &entry_jint_arraycopy, "jint_arraycopy"); | 1935 &entry_jint_arraycopy, "jint_arraycopy"); |
1935 | 1936 |
1936 StubRoutines::_oop_disjoint_arraycopy = | 1937 StubRoutines::_oop_disjoint_arraycopy = |
1937 generate_disjoint_copy(T_OBJECT, true, Address::times_4, &entry, | 1938 generate_disjoint_copy(T_OBJECT, true, Address::times_ptr, &entry, |
1938 "oop_disjoint_arraycopy"); | 1939 "oop_disjoint_arraycopy"); |
1939 StubRoutines::_oop_arraycopy = | 1940 StubRoutines::_oop_arraycopy = |
1940 generate_conjoint_copy(T_OBJECT, true, Address::times_4, entry, | 1941 generate_conjoint_copy(T_OBJECT, true, Address::times_ptr, entry, |
1941 &entry_oop_arraycopy, "oop_arraycopy"); | 1942 &entry_oop_arraycopy, "oop_arraycopy"); |
1942 | 1943 |
1943 StubRoutines::_jlong_disjoint_arraycopy = | 1944 StubRoutines::_jlong_disjoint_arraycopy = |
1944 generate_disjoint_long_copy(&entry, "jlong_disjoint_arraycopy"); | 1945 generate_disjoint_long_copy(&entry, "jlong_disjoint_arraycopy"); |
1945 StubRoutines::_jlong_arraycopy = | 1946 StubRoutines::_jlong_arraycopy = |
2035 // thread-local storage and also sets up last_Java_sp slightly | 2036 // thread-local storage and also sets up last_Java_sp slightly |
2036 // differently than the real call_VM | 2037 // differently than the real call_VM |
2037 Register java_thread = rbx; | 2038 Register java_thread = rbx; |
2038 __ get_thread(java_thread); | 2039 __ get_thread(java_thread); |
2039 if (restore_saved_exception_pc) { | 2040 if (restore_saved_exception_pc) { |
2040 __ movl(rax, Address(java_thread, in_bytes(JavaThread::saved_exception_pc_offset()))); | 2041 __ movptr(rax, Address(java_thread, in_bytes(JavaThread::saved_exception_pc_offset()))); |
2041 __ pushl(rax); | 2042 __ push(rax); |
2042 } | 2043 } |
2043 | 2044 |
2044 __ enter(); // required for proper stackwalking of RuntimeStub frame | 2045 __ enter(); // required for proper stackwalking of RuntimeStub frame |
2045 | 2046 |
2046 // pc and rbp, already pushed | 2047 // pc and rbp, already pushed |
2047 __ subl(rsp, (framesize-2) * wordSize); // prolog | 2048 __ subptr(rsp, (framesize-2) * wordSize); // prolog |
2048 | 2049 |
2049 // Frame is now completed as far as size and linkage. | 2050 // Frame is now completed as far as size and linkage. |
2050 | 2051 |
2051 int frame_complete = __ pc() - start; | 2052 int frame_complete = __ pc() - start; |
2052 | 2053 |
2053 // push java thread (becomes first argument of C function) | 2054 // push java thread (becomes first argument of C function) |
2054 __ movl(Address(rsp, thread_off * wordSize), java_thread); | 2055 __ movptr(Address(rsp, thread_off * wordSize), java_thread); |
2055 | 2056 |
2056 // Set up last_Java_sp and last_Java_fp | 2057 // Set up last_Java_sp and last_Java_fp |
2057 __ set_last_Java_frame(java_thread, rsp, rbp, NULL); | 2058 __ set_last_Java_frame(java_thread, rsp, rbp, NULL); |
2058 | 2059 |
2059 // Call runtime | 2060 // Call runtime |
2073 __ leave(); // required for proper stackwalking of RuntimeStub frame | 2074 __ leave(); // required for proper stackwalking of RuntimeStub frame |
2074 | 2075 |
2075 // check for pending exceptions | 2076 // check for pending exceptions |
2076 #ifdef ASSERT | 2077 #ifdef ASSERT |
2077 Label L; | 2078 Label L; |
2078 __ cmpl(Address(java_thread, Thread::pending_exception_offset()), NULL_WORD); | 2079 __ cmpptr(Address(java_thread, Thread::pending_exception_offset()), (int32_t)NULL_WORD); |
2079 __ jcc(Assembler::notEqual, L); | 2080 __ jcc(Assembler::notEqual, L); |
2080 __ should_not_reach_here(); | 2081 __ should_not_reach_here(); |
2081 __ bind(L); | 2082 __ bind(L); |
2082 #endif /* ASSERT */ | 2083 #endif /* ASSERT */ |
2083 __ jump(RuntimeAddress(StubRoutines::forward_exception_entry())); | 2084 __ jump(RuntimeAddress(StubRoutines::forward_exception_entry())); |
2135 generate_handler_for_unsafe_access(); | 2136 generate_handler_for_unsafe_access(); |
2136 | 2137 |
2137 // platform dependent | 2138 // platform dependent |
2138 create_control_words(); | 2139 create_control_words(); |
2139 | 2140 |
2140 StubRoutines::i486::_verify_mxcsr_entry = generate_verify_mxcsr(); | 2141 StubRoutines::x86::_verify_mxcsr_entry = generate_verify_mxcsr(); |
2141 StubRoutines::i486::_verify_fpu_cntrl_wrd_entry = generate_verify_fpu_cntrl_wrd(); | 2142 StubRoutines::x86::_verify_fpu_cntrl_wrd_entry = generate_verify_fpu_cntrl_wrd(); |
2142 StubRoutines::_d2i_wrapper = generate_d2i_wrapper(T_INT, | 2143 StubRoutines::_d2i_wrapper = generate_d2i_wrapper(T_INT, |
2143 CAST_FROM_FN_PTR(address, SharedRuntime::d2i)); | 2144 CAST_FROM_FN_PTR(address, SharedRuntime::d2i)); |
2144 StubRoutines::_d2l_wrapper = generate_d2i_wrapper(T_LONG, | 2145 StubRoutines::_d2l_wrapper = generate_d2i_wrapper(T_LONG, |
2145 CAST_FROM_FN_PTR(address, SharedRuntime::d2l)); | 2146 CAST_FROM_FN_PTR(address, SharedRuntime::d2l)); |
2146 } | 2147 } |