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