Mercurial > hg > graal-compiler
comparison src/cpu/x86/vm/sharedRuntime_x86_32.cpp @ 304:dc7f315e41f7
5108146: Merge i486 and amd64 cpu directories
6459804: Want client (c1) compiler for x86_64 (amd64) for faster start-up
Reviewed-by: kvn
author | never |
---|---|
date | Wed, 27 Aug 2008 00:21:55 -0700 |
parents | d1605aabd0a1 |
children | db4caa99ef11 70998f2e05ef |
comparison
equal
deleted
inserted
replaced
303:fa4d1d240383 | 304:dc7f315e41f7 |
---|---|
116 assert(FPUStateSizeInWords == 27, "update stack layout"); | 116 assert(FPUStateSizeInWords == 27, "update stack layout"); |
117 | 117 |
118 // save registers, fpu state, and flags | 118 // save registers, fpu state, and flags |
119 // We assume caller has already has return address slot on the stack | 119 // We assume caller has already has return address slot on the stack |
120 // We push epb twice in this sequence because we want the real rbp, | 120 // We push epb twice in this sequence because we want the real rbp, |
121 // to be under the return like a normal enter and we want to use pushad | 121 // to be under the return like a normal enter and we want to use pusha |
122 // We push by hand instead of pusing push | 122 // We push by hand instead of pusing push |
123 __ enter(); | 123 __ enter(); |
124 __ pushad(); | 124 __ pusha(); |
125 __ pushfd(); | 125 __ pushf(); |
126 __ subl(rsp,FPU_regs_live*sizeof(jdouble)); // Push FPU registers space | 126 __ subptr(rsp,FPU_regs_live*sizeof(jdouble)); // Push FPU registers space |
127 __ push_FPU_state(); // Save FPU state & init | 127 __ push_FPU_state(); // Save FPU state & init |
128 | 128 |
129 if (verify_fpu) { | 129 if (verify_fpu) { |
130 // Some stubs may have non standard FPU control word settings so | 130 // Some stubs may have non standard FPU control word settings so |
131 // only check and reset the value when it required to be the | 131 // only check and reset the value when it required to be the |
268 __ movdbl(xmm5,Address(rsp,xmm5_off*wordSize)); | 268 __ movdbl(xmm5,Address(rsp,xmm5_off*wordSize)); |
269 __ movdbl(xmm6,Address(rsp,xmm6_off*wordSize)); | 269 __ movdbl(xmm6,Address(rsp,xmm6_off*wordSize)); |
270 __ movdbl(xmm7,Address(rsp,xmm7_off*wordSize)); | 270 __ movdbl(xmm7,Address(rsp,xmm7_off*wordSize)); |
271 } | 271 } |
272 __ pop_FPU_state(); | 272 __ pop_FPU_state(); |
273 __ addl(rsp,FPU_regs_live*sizeof(jdouble)); // Pop FPU registers | 273 __ addptr(rsp, FPU_regs_live*sizeof(jdouble)); // Pop FPU registers |
274 | 274 |
275 __ popfd(); | 275 __ popf(); |
276 __ popad(); | 276 __ popa(); |
277 // Get the rbp, described implicitly by the frame sender code (no oopMap) | 277 // Get the rbp, described implicitly by the frame sender code (no oopMap) |
278 __ popl(rbp); | 278 __ pop(rbp); |
279 | 279 |
280 } | 280 } |
281 | 281 |
282 void RegisterSaver::restore_result_registers(MacroAssembler* masm) { | 282 void RegisterSaver::restore_result_registers(MacroAssembler* masm) { |
283 | 283 |
294 if( UseSSE == 1 ) { | 294 if( UseSSE == 1 ) { |
295 __ movflt(xmm0, Address(rsp, xmm0_off*wordSize)); | 295 __ movflt(xmm0, Address(rsp, xmm0_off*wordSize)); |
296 } else if( UseSSE >= 2 ) { | 296 } else if( UseSSE >= 2 ) { |
297 __ movdbl(xmm0, Address(rsp, xmm0_off*wordSize)); | 297 __ movdbl(xmm0, Address(rsp, xmm0_off*wordSize)); |
298 } | 298 } |
299 __ movl(rax, Address(rsp, rax_off*wordSize)); | 299 __ movptr(rax, Address(rsp, rax_off*wordSize)); |
300 __ movl(rdx, Address(rsp, rdx_off*wordSize)); | 300 __ movptr(rdx, Address(rsp, rdx_off*wordSize)); |
301 // Pop all of the register save are off the stack except the return address | 301 // Pop all of the register save are off the stack except the return address |
302 __ addl(rsp, return_off * wordSize); | 302 __ addptr(rsp, return_off * wordSize); |
303 } | 303 } |
304 | 304 |
305 // The java_calling_convention describes stack locations as ideal slots on | 305 // The java_calling_convention describes stack locations as ideal slots on |
306 // a frame with no abi restrictions. Since we must observe abi restrictions | 306 // a frame with no abi restrictions. Since we must observe abi restrictions |
307 // (like the placement of the register window) the slots must be biased by | 307 // (like the placement of the register window) the slots must be biased by |
446 | 446 |
447 // Patch the callers callsite with entry to compiled code if it exists. | 447 // Patch the callers callsite with entry to compiled code if it exists. |
448 static void patch_callers_callsite(MacroAssembler *masm) { | 448 static void patch_callers_callsite(MacroAssembler *masm) { |
449 Label L; | 449 Label L; |
450 __ verify_oop(rbx); | 450 __ verify_oop(rbx); |
451 __ cmpl(Address(rbx, in_bytes(methodOopDesc::code_offset())), NULL_WORD); | 451 __ cmpptr(Address(rbx, in_bytes(methodOopDesc::code_offset())), (int32_t)NULL_WORD); |
452 __ jcc(Assembler::equal, L); | 452 __ jcc(Assembler::equal, L); |
453 // Schedule the branch target address early. | 453 // Schedule the branch target address early. |
454 // Call into the VM to patch the caller, then jump to compiled callee | 454 // Call into the VM to patch the caller, then jump to compiled callee |
455 // rax, isn't live so capture return address while we easily can | 455 // rax, isn't live so capture return address while we easily can |
456 __ movl(rax, Address(rsp, 0)); | 456 __ movptr(rax, Address(rsp, 0)); |
457 __ pushad(); | 457 __ pusha(); |
458 __ pushfd(); | 458 __ pushf(); |
459 | 459 |
460 if (UseSSE == 1) { | 460 if (UseSSE == 1) { |
461 __ subl(rsp, 2*wordSize); | 461 __ subptr(rsp, 2*wordSize); |
462 __ movflt(Address(rsp, 0), xmm0); | 462 __ movflt(Address(rsp, 0), xmm0); |
463 __ movflt(Address(rsp, wordSize), xmm1); | 463 __ movflt(Address(rsp, wordSize), xmm1); |
464 } | 464 } |
465 if (UseSSE >= 2) { | 465 if (UseSSE >= 2) { |
466 __ subl(rsp, 4*wordSize); | 466 __ subptr(rsp, 4*wordSize); |
467 __ movdbl(Address(rsp, 0), xmm0); | 467 __ movdbl(Address(rsp, 0), xmm0); |
468 __ movdbl(Address(rsp, 2*wordSize), xmm1); | 468 __ movdbl(Address(rsp, 2*wordSize), xmm1); |
469 } | 469 } |
470 #ifdef COMPILER2 | 470 #ifdef COMPILER2 |
471 // C2 may leave the stack dirty if not in SSE2+ mode | 471 // C2 may leave the stack dirty if not in SSE2+ mode |
475 __ empty_FPU_stack(); | 475 __ empty_FPU_stack(); |
476 } | 476 } |
477 #endif /* COMPILER2 */ | 477 #endif /* COMPILER2 */ |
478 | 478 |
479 // VM needs caller's callsite | 479 // VM needs caller's callsite |
480 __ pushl(rax); | 480 __ push(rax); |
481 // VM needs target method | 481 // VM needs target method |
482 __ pushl(rbx); | 482 __ push(rbx); |
483 __ verify_oop(rbx); | 483 __ verify_oop(rbx); |
484 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::fixup_callers_callsite))); | 484 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::fixup_callers_callsite))); |
485 __ addl(rsp, 2*wordSize); | 485 __ addptr(rsp, 2*wordSize); |
486 | 486 |
487 if (UseSSE == 1) { | 487 if (UseSSE == 1) { |
488 __ movflt(xmm0, Address(rsp, 0)); | 488 __ movflt(xmm0, Address(rsp, 0)); |
489 __ movflt(xmm1, Address(rsp, wordSize)); | 489 __ movflt(xmm1, Address(rsp, wordSize)); |
490 __ addl(rsp, 2*wordSize); | 490 __ addptr(rsp, 2*wordSize); |
491 } | 491 } |
492 if (UseSSE >= 2) { | 492 if (UseSSE >= 2) { |
493 __ movdbl(xmm0, Address(rsp, 0)); | 493 __ movdbl(xmm0, Address(rsp, 0)); |
494 __ movdbl(xmm1, Address(rsp, 2*wordSize)); | 494 __ movdbl(xmm1, Address(rsp, 2*wordSize)); |
495 __ addl(rsp, 4*wordSize); | 495 __ addptr(rsp, 4*wordSize); |
496 } | 496 } |
497 | 497 |
498 __ popfd(); | 498 __ popf(); |
499 __ popad(); | 499 __ popa(); |
500 __ bind(L); | 500 __ bind(L); |
501 } | 501 } |
502 | 502 |
503 | 503 |
504 // Helper function to put tags in interpreter stack. | 504 // Helper function to put tags in interpreter stack. |
505 static void tag_stack(MacroAssembler *masm, const BasicType sig, int st_off) { | 505 static void tag_stack(MacroAssembler *masm, const BasicType sig, int st_off) { |
506 if (TaggedStackInterpreter) { | 506 if (TaggedStackInterpreter) { |
507 int tag_offset = st_off + Interpreter::expr_tag_offset_in_bytes(0); | 507 int tag_offset = st_off + Interpreter::expr_tag_offset_in_bytes(0); |
508 if (sig == T_OBJECT || sig == T_ARRAY) { | 508 if (sig == T_OBJECT || sig == T_ARRAY) { |
509 __ movl(Address(rsp, tag_offset), frame::TagReference); | 509 __ movptr(Address(rsp, tag_offset), frame::TagReference); |
510 } else if (sig == T_LONG || sig == T_DOUBLE) { | 510 } else if (sig == T_LONG || sig == T_DOUBLE) { |
511 int next_tag_offset = st_off + Interpreter::expr_tag_offset_in_bytes(1); | 511 int next_tag_offset = st_off + Interpreter::expr_tag_offset_in_bytes(1); |
512 __ movl(Address(rsp, next_tag_offset), frame::TagValue); | 512 __ movptr(Address(rsp, next_tag_offset), frame::TagValue); |
513 __ movl(Address(rsp, tag_offset), frame::TagValue); | 513 __ movptr(Address(rsp, tag_offset), frame::TagValue); |
514 } else { | 514 } else { |
515 __ movl(Address(rsp, tag_offset), frame::TagValue); | 515 __ movptr(Address(rsp, tag_offset), frame::TagValue); |
516 } | 516 } |
517 } | 517 } |
518 } | 518 } |
519 | 519 |
520 // Double and long values with Tagged stacks are not contiguous. | 520 // Double and long values with Tagged stacks are not contiguous. |
559 // stack_element_size is the | 559 // stack_element_size is the |
560 // space we need. | 560 // space we need. |
561 int extraspace = total_args_passed * Interpreter::stackElementSize(); | 561 int extraspace = total_args_passed * Interpreter::stackElementSize(); |
562 | 562 |
563 // Get return address | 563 // Get return address |
564 __ popl(rax); | 564 __ pop(rax); |
565 | 565 |
566 // set senderSP value | 566 // set senderSP value |
567 __ movl(rsi, rsp); | 567 __ movptr(rsi, rsp); |
568 | 568 |
569 __ subl(rsp, extraspace); | 569 __ subptr(rsp, extraspace); |
570 | 570 |
571 // Now write the args into the outgoing interpreter space | 571 // Now write the args into the outgoing interpreter space |
572 for (int i = 0; i < total_args_passed; i++) { | 572 for (int i = 0; i < total_args_passed; i++) { |
573 if (sig_bt[i] == T_VOID) { | 573 if (sig_bt[i] == T_VOID) { |
574 assert(i > 0 && (sig_bt[i-1] == T_LONG || sig_bt[i-1] == T_DOUBLE), "missing half"); | 574 assert(i > 0 && (sig_bt[i-1] == T_LONG || sig_bt[i-1] == T_DOUBLE), "missing half"); |
575 continue; | 575 continue; |
576 } | 576 } |
577 | 577 |
578 // st_off points to lowest address on stack. | 578 // st_off points to lowest address on stack. |
579 int st_off = ((total_args_passed - 1) - i) * Interpreter::stackElementSize(); | 579 int st_off = ((total_args_passed - 1) - i) * Interpreter::stackElementSize(); |
580 int next_off = st_off - Interpreter::stackElementSize(); | |
581 | |
580 // Say 4 args: | 582 // Say 4 args: |
581 // i st_off | 583 // i st_off |
582 // 0 12 T_LONG | 584 // 0 12 T_LONG |
583 // 1 8 T_VOID | 585 // 1 8 T_VOID |
584 // 2 4 T_OBJECT | 586 // 2 4 T_OBJECT |
594 // memory to memory use fpu stack top | 596 // memory to memory use fpu stack top |
595 int ld_off = r_1->reg2stack() * VMRegImpl::stack_slot_size + extraspace; | 597 int ld_off = r_1->reg2stack() * VMRegImpl::stack_slot_size + extraspace; |
596 | 598 |
597 if (!r_2->is_valid()) { | 599 if (!r_2->is_valid()) { |
598 __ movl(rdi, Address(rsp, ld_off)); | 600 __ movl(rdi, Address(rsp, ld_off)); |
599 __ movl(Address(rsp, st_off), rdi); | 601 __ movptr(Address(rsp, st_off), rdi); |
600 tag_stack(masm, sig_bt[i], st_off); | 602 tag_stack(masm, sig_bt[i], st_off); |
601 } else { | 603 } else { |
602 | 604 |
603 // ld_off == LSW, ld_off+VMRegImpl::stack_slot_size == MSW | 605 // ld_off == LSW, ld_off+VMRegImpl::stack_slot_size == MSW |
604 // st_off == MSW, st_off-wordSize == LSW | 606 // st_off == MSW, st_off-wordSize == LSW |
605 | 607 |
606 int next_off = st_off - Interpreter::stackElementSize(); | 608 __ movptr(rdi, Address(rsp, ld_off)); |
607 __ movl(rdi, Address(rsp, ld_off)); | 609 __ movptr(Address(rsp, next_off), rdi); |
608 __ movl(Address(rsp, next_off), rdi); | 610 #ifndef _LP64 |
609 __ movl(rdi, Address(rsp, ld_off + wordSize)); | 611 __ movptr(rdi, Address(rsp, ld_off + wordSize)); |
610 __ movl(Address(rsp, st_off), rdi); | 612 __ movptr(Address(rsp, st_off), rdi); |
613 #else | |
614 #ifdef ASSERT | |
615 // Overwrite the unused slot with known junk | |
616 __ mov64(rax, CONST64(0xdeadffffdeadaaaa)); | |
617 __ movptr(Address(rsp, st_off), rax); | |
618 #endif /* ASSERT */ | |
619 #endif // _LP64 | |
611 tag_stack(masm, sig_bt[i], next_off); | 620 tag_stack(masm, sig_bt[i], next_off); |
612 } | 621 } |
613 } else if (r_1->is_Register()) { | 622 } else if (r_1->is_Register()) { |
614 Register r = r_1->as_Register(); | 623 Register r = r_1->as_Register(); |
615 if (!r_2->is_valid()) { | 624 if (!r_2->is_valid()) { |
616 __ movl(Address(rsp, st_off), r); | 625 __ movl(Address(rsp, st_off), r); |
617 tag_stack(masm, sig_bt[i], st_off); | 626 tag_stack(masm, sig_bt[i], st_off); |
618 } else { | 627 } else { |
619 // long/double in gpr | 628 // long/double in gpr |
620 ShouldNotReachHere(); | 629 NOT_LP64(ShouldNotReachHere()); |
630 // Two VMRegs can be T_OBJECT, T_ADDRESS, T_DOUBLE, T_LONG | |
631 // T_DOUBLE and T_LONG use two slots in the interpreter | |
632 if ( sig_bt[i] == T_LONG || sig_bt[i] == T_DOUBLE) { | |
633 // long/double in gpr | |
634 #ifdef ASSERT | |
635 // Overwrite the unused slot with known junk | |
636 LP64_ONLY(__ mov64(rax, CONST64(0xdeadffffdeadaaab))); | |
637 __ movptr(Address(rsp, st_off), rax); | |
638 #endif /* ASSERT */ | |
639 __ movptr(Address(rsp, next_off), r); | |
640 tag_stack(masm, sig_bt[i], next_off); | |
641 } else { | |
642 __ movptr(Address(rsp, st_off), r); | |
643 tag_stack(masm, sig_bt[i], st_off); | |
644 } | |
621 } | 645 } |
622 } else { | 646 } else { |
623 assert(r_1->is_XMMRegister(), ""); | 647 assert(r_1->is_XMMRegister(), ""); |
624 if (!r_2->is_valid()) { | 648 if (!r_2->is_valid()) { |
625 __ movflt(Address(rsp, st_off), r_1->as_XMMRegister()); | 649 __ movflt(Address(rsp, st_off), r_1->as_XMMRegister()); |
630 } | 654 } |
631 } | 655 } |
632 } | 656 } |
633 | 657 |
634 // Schedule the branch target address early. | 658 // Schedule the branch target address early. |
635 __ movl(rcx, Address(rbx, in_bytes(methodOopDesc::interpreter_entry_offset()))); | 659 __ movptr(rcx, Address(rbx, in_bytes(methodOopDesc::interpreter_entry_offset()))); |
636 // And repush original return address | 660 // And repush original return address |
637 __ pushl(rax); | 661 __ push(rax); |
638 __ jmp(rcx); | 662 __ jmp(rcx); |
639 } | 663 } |
640 | 664 |
641 | 665 |
642 // For tagged stacks, double or long value aren't contiguous on the stack | 666 // For tagged stacks, double or long value aren't contiguous on the stack |
643 // so get them contiguous for the xmm load | 667 // so get them contiguous for the xmm load |
644 static void move_i2c_double(MacroAssembler *masm, XMMRegister r, Register saved_sp, int ld_off) { | 668 static void move_i2c_double(MacroAssembler *masm, XMMRegister r, Register saved_sp, int ld_off) { |
645 int next_val_off = ld_off - Interpreter::stackElementSize(); | 669 int next_val_off = ld_off - Interpreter::stackElementSize(); |
646 if (TaggedStackInterpreter) { | 670 if (TaggedStackInterpreter) { |
647 // use tag slot temporarily for MSW | 671 // use tag slot temporarily for MSW |
648 __ movl(rsi, Address(saved_sp, ld_off)); | 672 __ movptr(rsi, Address(saved_sp, ld_off)); |
649 __ movl(Address(saved_sp, next_val_off+wordSize), rsi); | 673 __ movptr(Address(saved_sp, next_val_off+wordSize), rsi); |
650 __ movdbl(r, Address(saved_sp, next_val_off)); | 674 __ movdbl(r, Address(saved_sp, next_val_off)); |
651 // restore tag | 675 // restore tag |
652 __ movl(Address(saved_sp, next_val_off+wordSize), frame::TagValue); | 676 __ movptr(Address(saved_sp, next_val_off+wordSize), frame::TagValue); |
653 } else { | 677 } else { |
654 __ movdbl(r, Address(saved_sp, next_val_off)); | 678 __ movdbl(r, Address(saved_sp, next_val_off)); |
655 } | 679 } |
656 } | 680 } |
657 | 681 |
683 // Note: rsi contains the senderSP on entry. We must preserve it since | 707 // Note: rsi contains the senderSP on entry. We must preserve it since |
684 // we may do a i2c -> c2i transition if we lose a race where compiled | 708 // we may do a i2c -> c2i transition if we lose a race where compiled |
685 // code goes non-entrant while we get args ready. | 709 // code goes non-entrant while we get args ready. |
686 | 710 |
687 // Pick up the return address | 711 // Pick up the return address |
688 __ movl(rax, Address(rsp, 0)); | 712 __ movptr(rax, Address(rsp, 0)); |
689 | 713 |
690 // If UseSSE >= 2 then no cleanup is needed on the return to the | 714 // If UseSSE >= 2 then no cleanup is needed on the return to the |
691 // interpreter so skip fixing up the return entry point unless | 715 // interpreter so skip fixing up the return entry point unless |
692 // VerifyFPU is enabled. | 716 // VerifyFPU is enabled. |
693 if (UseSSE < 2 || VerifyFPU) { | 717 if (UseSSE < 2 || VerifyFPU) { |
694 Label skip, chk_int; | 718 Label skip, chk_int; |
695 // If we were called from the call stub we need to do a little bit different | 719 // If we were called from the call stub we need to do a little bit different |
696 // cleanup than if the interpreter returned to the call stub. | 720 // cleanup than if the interpreter returned to the call stub. |
697 | 721 |
698 ExternalAddress stub_return_address(StubRoutines::_call_stub_return_address); | 722 ExternalAddress stub_return_address(StubRoutines::_call_stub_return_address); |
699 __ cmp32(rax, stub_return_address.addr()); | 723 __ cmpptr(rax, stub_return_address.addr()); |
700 __ jcc(Assembler::notEqual, chk_int); | 724 __ jcc(Assembler::notEqual, chk_int); |
701 assert(StubRoutines::i486::get_call_stub_compiled_return() != NULL, "must be set"); | 725 assert(StubRoutines::x86::get_call_stub_compiled_return() != NULL, "must be set"); |
702 __ lea(rax, ExternalAddress(StubRoutines::i486::get_call_stub_compiled_return())); | 726 __ lea(rax, ExternalAddress(StubRoutines::x86::get_call_stub_compiled_return())); |
703 __ jmp(skip); | 727 __ jmp(skip); |
704 | 728 |
705 // It must be the interpreter since we never get here via a c2i (unlike Azul) | 729 // It must be the interpreter since we never get here via a c2i (unlike Azul) |
706 | 730 |
707 __ bind(chk_int); | 731 __ bind(chk_int); |
708 #ifdef ASSERT | 732 #ifdef ASSERT |
709 { | 733 { |
710 Label ok; | 734 Label ok; |
711 __ cmpl(Address(rax, -8), Interpreter::return_sentinel); | 735 __ cmpl(Address(rax, -2*wordSize), Interpreter::return_sentinel); |
712 __ jcc(Assembler::equal, ok); | 736 __ jcc(Assembler::equal, ok); |
713 __ int3(); | 737 __ int3(); |
714 __ bind(ok); | 738 __ bind(ok); |
715 } | 739 } |
716 #endif // ASSERT | 740 #endif // ASSERT |
717 __ movl(rax, Address(rax, -4)); | 741 __ movptr(rax, Address(rax, -wordSize)); |
718 __ bind(skip); | 742 __ bind(skip); |
719 } | 743 } |
720 | 744 |
721 // rax, now contains the compiled return entry point which will do an | 745 // rax, now contains the compiled return entry point which will do an |
722 // cleanup needed for the return from compiled to interpreted. | 746 // cleanup needed for the return from compiled to interpreted. |
723 | 747 |
724 // Must preserve original SP for loading incoming arguments because | 748 // Must preserve original SP for loading incoming arguments because |
725 // we need to align the outgoing SP for compiled code. | 749 // we need to align the outgoing SP for compiled code. |
726 __ movl(rdi, rsp); | 750 __ movptr(rdi, rsp); |
727 | 751 |
728 // Cut-out for having no stack args. Since up to 2 int/oop args are passed | 752 // Cut-out for having no stack args. Since up to 2 int/oop args are passed |
729 // in registers, we will occasionally have no stack args. | 753 // in registers, we will occasionally have no stack args. |
730 int comp_words_on_stack = 0; | 754 int comp_words_on_stack = 0; |
731 if (comp_args_on_stack) { | 755 if (comp_args_on_stack) { |
735 // int comp_args_on_stack = VMRegImpl::reg2stack(max_arg); | 759 // int comp_args_on_stack = VMRegImpl::reg2stack(max_arg); |
736 // Convert 4-byte stack slots to words. | 760 // Convert 4-byte stack slots to words. |
737 comp_words_on_stack = round_to(comp_args_on_stack*4, wordSize)>>LogBytesPerWord; | 761 comp_words_on_stack = round_to(comp_args_on_stack*4, wordSize)>>LogBytesPerWord; |
738 // Round up to miminum stack alignment, in wordSize | 762 // Round up to miminum stack alignment, in wordSize |
739 comp_words_on_stack = round_to(comp_words_on_stack, 2); | 763 comp_words_on_stack = round_to(comp_words_on_stack, 2); |
740 __ subl(rsp, comp_words_on_stack * wordSize); | 764 __ subptr(rsp, comp_words_on_stack * wordSize); |
741 } | 765 } |
742 | 766 |
743 // Align the outgoing SP | 767 // Align the outgoing SP |
744 __ andl(rsp, -(StackAlignmentInBytes)); | 768 __ andptr(rsp, -(StackAlignmentInBytes)); |
745 | 769 |
746 // push the return address on the stack (note that pushing, rather | 770 // push the return address on the stack (note that pushing, rather |
747 // than storing it, yields the correct frame alignment for the callee) | 771 // than storing it, yields the correct frame alignment for the callee) |
748 __ pushl(rax); | 772 __ push(rax); |
749 | 773 |
750 // Put saved SP in another register | 774 // Put saved SP in another register |
751 const Register saved_sp = rax; | 775 const Register saved_sp = rax; |
752 __ movl(saved_sp, rdi); | 776 __ movptr(saved_sp, rdi); |
753 | 777 |
754 | 778 |
755 // Will jump to the compiled code just as if compiled code was doing it. | 779 // Will jump to the compiled code just as if compiled code was doing it. |
756 // Pre-load the register-jump target early, to schedule it better. | 780 // Pre-load the register-jump target early, to schedule it better. |
757 __ movl(rdi, Address(rbx, in_bytes(methodOopDesc::from_compiled_offset()))); | 781 __ movptr(rdi, Address(rbx, in_bytes(methodOopDesc::from_compiled_offset()))); |
758 | 782 |
759 // Now generate the shuffle code. Pick up all register args and move the | 783 // Now generate the shuffle code. Pick up all register args and move the |
760 // rest through the floating point stack top. | 784 // rest through the floating point stack top. |
761 for (int i = 0; i < total_args_passed; i++) { | 785 for (int i = 0; i < total_args_passed; i++) { |
762 if (sig_bt[i] == T_VOID) { | 786 if (sig_bt[i] == T_VOID) { |
792 // we be generated. | 816 // we be generated. |
793 if (!r_2->is_valid()) { | 817 if (!r_2->is_valid()) { |
794 // __ fld_s(Address(saved_sp, ld_off)); | 818 // __ fld_s(Address(saved_sp, ld_off)); |
795 // __ fstp_s(Address(rsp, st_off)); | 819 // __ fstp_s(Address(rsp, st_off)); |
796 __ movl(rsi, Address(saved_sp, ld_off)); | 820 __ movl(rsi, Address(saved_sp, ld_off)); |
797 __ movl(Address(rsp, st_off), rsi); | 821 __ movptr(Address(rsp, st_off), rsi); |
798 } else { | 822 } else { |
799 // Interpreter local[n] == MSW, local[n+1] == LSW however locals | 823 // Interpreter local[n] == MSW, local[n+1] == LSW however locals |
800 // are accessed as negative so LSW is at LOW address | 824 // are accessed as negative so LSW is at LOW address |
801 | 825 |
802 // ld_off is MSW so get LSW | 826 // ld_off is MSW so get LSW |
803 // st_off is LSW (i.e. reg.first()) | 827 // st_off is LSW (i.e. reg.first()) |
804 // __ fld_d(Address(saved_sp, next_off)); | 828 // __ fld_d(Address(saved_sp, next_off)); |
805 // __ fstp_d(Address(rsp, st_off)); | 829 // __ fstp_d(Address(rsp, st_off)); |
806 __ movl(rsi, Address(saved_sp, next_off)); | 830 // |
807 __ movl(Address(rsp, st_off), rsi); | 831 // We are using two VMRegs. This can be either T_OBJECT, T_ADDRESS, T_LONG, or T_DOUBLE |
808 __ movl(rsi, Address(saved_sp, ld_off)); | 832 // the interpreter allocates two slots but only uses one for thr T_LONG or T_DOUBLE case |
809 __ movl(Address(rsp, st_off + wordSize), rsi); | 833 // So we must adjust where to pick up the data to match the interpreter. |
834 // | |
835 // Interpreter local[n] == MSW, local[n+1] == LSW however locals | |
836 // are accessed as negative so LSW is at LOW address | |
837 | |
838 // ld_off is MSW so get LSW | |
839 const int offset = (NOT_LP64(true ||) sig_bt[i]==T_LONG||sig_bt[i]==T_DOUBLE)? | |
840 next_off : ld_off; | |
841 __ movptr(rsi, Address(saved_sp, offset)); | |
842 __ movptr(Address(rsp, st_off), rsi); | |
843 #ifndef _LP64 | |
844 __ movptr(rsi, Address(saved_sp, ld_off)); | |
845 __ movptr(Address(rsp, st_off + wordSize), rsi); | |
846 #endif // _LP64 | |
810 } | 847 } |
811 } else if (r_1->is_Register()) { // Register argument | 848 } else if (r_1->is_Register()) { // Register argument |
812 Register r = r_1->as_Register(); | 849 Register r = r_1->as_Register(); |
813 assert(r != rax, "must be different"); | 850 assert(r != rax, "must be different"); |
814 if (r_2->is_valid()) { | 851 if (r_2->is_valid()) { |
852 // | |
853 // We are using two VMRegs. This can be either T_OBJECT, T_ADDRESS, T_LONG, or T_DOUBLE | |
854 // the interpreter allocates two slots but only uses one for thr T_LONG or T_DOUBLE case | |
855 // So we must adjust where to pick up the data to match the interpreter. | |
856 | |
857 const int offset = (NOT_LP64(true ||) sig_bt[i]==T_LONG||sig_bt[i]==T_DOUBLE)? | |
858 next_off : ld_off; | |
859 | |
860 // this can be a misaligned move | |
861 __ movptr(r, Address(saved_sp, offset)); | |
862 #ifndef _LP64 | |
815 assert(r_2->as_Register() != rax, "need another temporary register"); | 863 assert(r_2->as_Register() != rax, "need another temporary register"); |
816 // Remember r_1 is low address (and LSB on x86) | 864 // Remember r_1 is low address (and LSB on x86) |
817 // So r_2 gets loaded from high address regardless of the platform | 865 // So r_2 gets loaded from high address regardless of the platform |
818 __ movl(r_2->as_Register(), Address(saved_sp, ld_off)); | 866 __ movptr(r_2->as_Register(), Address(saved_sp, ld_off)); |
819 __ movl(r, Address(saved_sp, next_off)); | 867 #endif // _LP64 |
820 } else { | 868 } else { |
821 __ movl(r, Address(saved_sp, ld_off)); | 869 __ movl(r, Address(saved_sp, ld_off)); |
822 } | 870 } |
823 } else { | 871 } else { |
824 assert(r_1->is_XMMRegister(), ""); | 872 assert(r_1->is_XMMRegister(), ""); |
839 // we try and find the callee by normal means a safepoint | 887 // we try and find the callee by normal means a safepoint |
840 // is possible. So we stash the desired callee in the thread | 888 // is possible. So we stash the desired callee in the thread |
841 // and the vm will find there should this case occur. | 889 // and the vm will find there should this case occur. |
842 | 890 |
843 __ get_thread(rax); | 891 __ get_thread(rax); |
844 __ movl(Address(rax, JavaThread::callee_target_offset()), rbx); | 892 __ movptr(Address(rax, JavaThread::callee_target_offset()), rbx); |
845 | 893 |
846 // move methodOop to rax, in case we end up in an c2i adapter. | 894 // move methodOop to rax, in case we end up in an c2i adapter. |
847 // the c2i adapters expect methodOop in rax, (c2) because c2's | 895 // the c2i adapters expect methodOop in rax, (c2) because c2's |
848 // resolve stubs return the result (the method) in rax,. | 896 // resolve stubs return the result (the method) in rax,. |
849 // I'd love to fix this. | 897 // I'd love to fix this. |
850 __ movl(rax, rbx); | 898 __ mov(rax, rbx); |
851 | 899 |
852 __ jmp(rdi); | 900 __ jmp(rdi); |
853 } | 901 } |
854 | 902 |
855 // --------------------------------------------------------------- | 903 // --------------------------------------------------------------- |
881 { | 929 { |
882 | 930 |
883 Label missed; | 931 Label missed; |
884 | 932 |
885 __ verify_oop(holder); | 933 __ verify_oop(holder); |
886 __ movl(temp, Address(receiver, oopDesc::klass_offset_in_bytes())); | 934 __ movptr(temp, Address(receiver, oopDesc::klass_offset_in_bytes())); |
887 __ verify_oop(temp); | 935 __ verify_oop(temp); |
888 | 936 |
889 __ cmpl(temp, Address(holder, compiledICHolderOopDesc::holder_klass_offset())); | 937 __ cmpptr(temp, Address(holder, compiledICHolderOopDesc::holder_klass_offset())); |
890 __ movl(rbx, Address(holder, compiledICHolderOopDesc::holder_method_offset())); | 938 __ movptr(rbx, Address(holder, compiledICHolderOopDesc::holder_method_offset())); |
891 __ jcc(Assembler::notEqual, missed); | 939 __ jcc(Assembler::notEqual, missed); |
892 // Method might have been compiled since the call site was patched to | 940 // Method might have been compiled since the call site was patched to |
893 // interpreted if that is the case treat it as a miss so we can get | 941 // interpreted if that is the case treat it as a miss so we can get |
894 // the call site corrected. | 942 // the call site corrected. |
895 __ cmpl(Address(rbx, in_bytes(methodOopDesc::code_offset())), NULL_WORD); | 943 __ cmpptr(Address(rbx, in_bytes(methodOopDesc::code_offset())), (int32_t)NULL_WORD); |
896 __ jcc(Assembler::equal, skip_fixup); | 944 __ jcc(Assembler::equal, skip_fixup); |
897 | 945 |
898 __ bind(missed); | 946 __ bind(missed); |
899 __ jump(RuntimeAddress(SharedRuntime::get_ic_miss_stub())); | 947 __ jump(RuntimeAddress(SharedRuntime::get_ic_miss_stub())); |
900 } | 948 } |
951 if (src.first()->is_stack()) { | 999 if (src.first()->is_stack()) { |
952 if (dst.first()->is_stack()) { | 1000 if (dst.first()->is_stack()) { |
953 // stack to stack | 1001 // stack to stack |
954 // __ ld(FP, reg2offset(src.first()) + STACK_BIAS, L5); | 1002 // __ ld(FP, reg2offset(src.first()) + STACK_BIAS, L5); |
955 // __ st(L5, SP, reg2offset(dst.first()) + STACK_BIAS); | 1003 // __ st(L5, SP, reg2offset(dst.first()) + STACK_BIAS); |
956 __ movl(rax, Address(rbp, reg2offset_in(src.first()))); | 1004 __ movl2ptr(rax, Address(rbp, reg2offset_in(src.first()))); |
957 __ movl(Address(rsp, reg2offset_out(dst.first())), rax); | 1005 __ movptr(Address(rsp, reg2offset_out(dst.first())), rax); |
958 } else { | 1006 } else { |
959 // stack to reg | 1007 // stack to reg |
960 __ movl(dst.first()->as_Register(), Address(rbp, reg2offset_in(src.first()))); | 1008 __ movl2ptr(dst.first()->as_Register(), Address(rbp, reg2offset_in(src.first()))); |
961 } | 1009 } |
962 } else if (dst.first()->is_stack()) { | 1010 } else if (dst.first()->is_stack()) { |
963 // reg to stack | 1011 // reg to stack |
964 __ movl(Address(rsp, reg2offset_out(dst.first())), src.first()->as_Register()); | 1012 // no need to sign extend on 64bit |
1013 __ movptr(Address(rsp, reg2offset_out(dst.first())), src.first()->as_Register()); | |
965 } else { | 1014 } else { |
966 __ movl(dst.first()->as_Register(), src.first()->as_Register()); | 1015 if (dst.first() != src.first()) { |
1016 __ mov(dst.first()->as_Register(), src.first()->as_Register()); | |
1017 } | |
967 } | 1018 } |
968 } | 1019 } |
969 | 1020 |
970 // An oop arg. Must pass a handle not the oop itself | 1021 // An oop arg. Must pass a handle not the oop itself |
971 static void object_move(MacroAssembler* masm, | 1022 static void object_move(MacroAssembler* masm, |
985 | 1036 |
986 if (src.first()->is_stack()) { | 1037 if (src.first()->is_stack()) { |
987 // Oop is already on the stack as an argument | 1038 // Oop is already on the stack as an argument |
988 Register rHandle = rax; | 1039 Register rHandle = rax; |
989 Label nil; | 1040 Label nil; |
990 __ xorl(rHandle, rHandle); | 1041 __ xorptr(rHandle, rHandle); |
991 __ cmpl(Address(rbp, reg2offset_in(src.first())), NULL_WORD); | 1042 __ cmpptr(Address(rbp, reg2offset_in(src.first())), (int32_t)NULL_WORD); |
992 __ jcc(Assembler::equal, nil); | 1043 __ jcc(Assembler::equal, nil); |
993 __ leal(rHandle, Address(rbp, reg2offset_in(src.first()))); | 1044 __ lea(rHandle, Address(rbp, reg2offset_in(src.first()))); |
994 __ bind(nil); | 1045 __ bind(nil); |
995 __ movl(Address(rsp, reg2offset_out(dst.first())), rHandle); | 1046 __ movptr(Address(rsp, reg2offset_out(dst.first())), rHandle); |
996 | 1047 |
997 int offset_in_older_frame = src.first()->reg2stack() + SharedRuntime::out_preserve_stack_slots(); | 1048 int offset_in_older_frame = src.first()->reg2stack() + SharedRuntime::out_preserve_stack_slots(); |
998 map->set_oop(VMRegImpl::stack2reg(offset_in_older_frame + framesize_in_slots)); | 1049 map->set_oop(VMRegImpl::stack2reg(offset_in_older_frame + framesize_in_slots)); |
999 if (is_receiver) { | 1050 if (is_receiver) { |
1000 *receiver_offset = (offset_in_older_frame + framesize_in_slots) * VMRegImpl::stack_slot_size; | 1051 *receiver_offset = (offset_in_older_frame + framesize_in_slots) * VMRegImpl::stack_slot_size; |
1005 const Register rOop = src.first()->as_Register(); | 1056 const Register rOop = src.first()->as_Register(); |
1006 const Register rHandle = rax; | 1057 const Register rHandle = rax; |
1007 int oop_slot = (rOop == rcx ? 0 : 1) * VMRegImpl::slots_per_word + oop_handle_offset; | 1058 int oop_slot = (rOop == rcx ? 0 : 1) * VMRegImpl::slots_per_word + oop_handle_offset; |
1008 int offset = oop_slot*VMRegImpl::stack_slot_size; | 1059 int offset = oop_slot*VMRegImpl::stack_slot_size; |
1009 Label skip; | 1060 Label skip; |
1010 __ movl(Address(rsp, offset), rOop); | 1061 __ movptr(Address(rsp, offset), rOop); |
1011 map->set_oop(VMRegImpl::stack2reg(oop_slot)); | 1062 map->set_oop(VMRegImpl::stack2reg(oop_slot)); |
1012 __ xorl(rHandle, rHandle); | 1063 __ xorptr(rHandle, rHandle); |
1013 __ cmpl(rOop, NULL_WORD); | 1064 __ cmpptr(rOop, (int32_t)NULL_WORD); |
1014 __ jcc(Assembler::equal, skip); | 1065 __ jcc(Assembler::equal, skip); |
1015 __ leal(rHandle, Address(rsp, offset)); | 1066 __ lea(rHandle, Address(rsp, offset)); |
1016 __ bind(skip); | 1067 __ bind(skip); |
1017 // Store the handle parameter | 1068 // Store the handle parameter |
1018 __ movl(Address(rsp, reg2offset_out(dst.first())), rHandle); | 1069 __ movptr(Address(rsp, reg2offset_out(dst.first())), rHandle); |
1019 if (is_receiver) { | 1070 if (is_receiver) { |
1020 *receiver_offset = offset; | 1071 *receiver_offset = offset; |
1021 } | 1072 } |
1022 } | 1073 } |
1023 } | 1074 } |
1031 | 1082 |
1032 assert(dst.first()->is_stack() && ( src.first()->is_stack() || src.first()->is_XMMRegister()), "bad parameters"); | 1083 assert(dst.first()->is_stack() && ( src.first()->is_stack() || src.first()->is_XMMRegister()), "bad parameters"); |
1033 | 1084 |
1034 if (src.first()->is_stack()) { | 1085 if (src.first()->is_stack()) { |
1035 __ movl(rax, Address(rbp, reg2offset_in(src.first()))); | 1086 __ movl(rax, Address(rbp, reg2offset_in(src.first()))); |
1036 __ movl(Address(rsp, reg2offset_out(dst.first())), rax); | 1087 __ movptr(Address(rsp, reg2offset_out(dst.first())), rax); |
1037 } else { | 1088 } else { |
1038 // reg to stack | 1089 // reg to stack |
1039 __ movflt(Address(rsp, reg2offset_out(dst.first())), src.first()->as_XMMRegister()); | 1090 __ movflt(Address(rsp, reg2offset_out(dst.first())), src.first()->as_XMMRegister()); |
1040 } | 1091 } |
1041 } | 1092 } |
1048 // as neither the java or C calling convention will use registers | 1099 // as neither the java or C calling convention will use registers |
1049 // for longs. | 1100 // for longs. |
1050 | 1101 |
1051 if (src.first()->is_stack() && dst.first()->is_stack()) { | 1102 if (src.first()->is_stack() && dst.first()->is_stack()) { |
1052 assert(src.second()->is_stack() && dst.second()->is_stack(), "must be all stack"); | 1103 assert(src.second()->is_stack() && dst.second()->is_stack(), "must be all stack"); |
1053 __ movl(rax, Address(rbp, reg2offset_in(src.first()))); | 1104 __ movptr(rax, Address(rbp, reg2offset_in(src.first()))); |
1054 __ movl(rbx, Address(rbp, reg2offset_in(src.second()))); | 1105 NOT_LP64(__ movptr(rbx, Address(rbp, reg2offset_in(src.second())))); |
1055 __ movl(Address(rsp, reg2offset_out(dst.first())), rax); | 1106 __ movptr(Address(rsp, reg2offset_out(dst.first())), rax); |
1056 __ movl(Address(rsp, reg2offset_out(dst.second())), rbx); | 1107 NOT_LP64(__ movptr(Address(rsp, reg2offset_out(dst.second())), rbx)); |
1057 } else { | 1108 } else { |
1058 ShouldNotReachHere(); | 1109 ShouldNotReachHere(); |
1059 } | 1110 } |
1060 } | 1111 } |
1061 | 1112 |
1072 | 1123 |
1073 assert(dst.first()->is_stack() && (src.first()->is_XMMRegister() || src.first()->is_stack()), "bad args"); | 1124 assert(dst.first()->is_stack() && (src.first()->is_XMMRegister() || src.first()->is_stack()), "bad args"); |
1074 | 1125 |
1075 if (src.first()->is_stack()) { | 1126 if (src.first()->is_stack()) { |
1076 // source is all stack | 1127 // source is all stack |
1077 __ movl(rax, Address(rbp, reg2offset_in(src.first()))); | 1128 __ movptr(rax, Address(rbp, reg2offset_in(src.first()))); |
1078 __ movl(rbx, Address(rbp, reg2offset_in(src.second()))); | 1129 NOT_LP64(__ movptr(rbx, Address(rbp, reg2offset_in(src.second())))); |
1079 __ movl(Address(rsp, reg2offset_out(dst.first())), rax); | 1130 __ movptr(Address(rsp, reg2offset_out(dst.first())), rax); |
1080 __ movl(Address(rsp, reg2offset_out(dst.second())), rbx); | 1131 NOT_LP64(__ movptr(Address(rsp, reg2offset_out(dst.second())), rbx)); |
1081 } else { | 1132 } else { |
1082 // reg to stack | 1133 // reg to stack |
1083 // No worries about stack alignment | 1134 // No worries about stack alignment |
1084 __ movdbl(Address(rsp, reg2offset_out(dst.first())), src.first()->as_XMMRegister()); | 1135 __ movdbl(Address(rsp, reg2offset_out(dst.first())), src.first()->as_XMMRegister()); |
1085 } | 1136 } |
1096 case T_DOUBLE: | 1147 case T_DOUBLE: |
1097 __ fstp_d(Address(rbp, -2*wordSize)); | 1148 __ fstp_d(Address(rbp, -2*wordSize)); |
1098 break; | 1149 break; |
1099 case T_VOID: break; | 1150 case T_VOID: break; |
1100 case T_LONG: | 1151 case T_LONG: |
1101 __ movl(Address(rbp, -wordSize), rax); | 1152 __ movptr(Address(rbp, -wordSize), rax); |
1102 __ movl(Address(rbp, -2*wordSize), rdx); | 1153 NOT_LP64(__ movptr(Address(rbp, -2*wordSize), rdx)); |
1103 break; | 1154 break; |
1104 default: { | 1155 default: { |
1105 __ movl(Address(rbp, -wordSize), rax); | 1156 __ movptr(Address(rbp, -wordSize), rax); |
1106 } | 1157 } |
1107 } | 1158 } |
1108 } | 1159 } |
1109 | 1160 |
1110 void SharedRuntime::restore_native_result(MacroAssembler *masm, BasicType ret_type, int frame_slots) { | 1161 void SharedRuntime::restore_native_result(MacroAssembler *masm, BasicType ret_type, int frame_slots) { |
1116 break; | 1167 break; |
1117 case T_DOUBLE: | 1168 case T_DOUBLE: |
1118 __ fld_d(Address(rbp, -2*wordSize)); | 1169 __ fld_d(Address(rbp, -2*wordSize)); |
1119 break; | 1170 break; |
1120 case T_LONG: | 1171 case T_LONG: |
1121 __ movl(rax, Address(rbp, -wordSize)); | 1172 __ movptr(rax, Address(rbp, -wordSize)); |
1122 __ movl(rdx, Address(rbp, -2*wordSize)); | 1173 NOT_LP64(__ movptr(rdx, Address(rbp, -2*wordSize))); |
1123 break; | 1174 break; |
1124 case T_VOID: break; | 1175 case T_VOID: break; |
1125 default: { | 1176 default: { |
1126 __ movl(rax, Address(rbp, -wordSize)); | 1177 __ movptr(rax, Address(rbp, -wordSize)); |
1127 } | 1178 } |
1128 } | 1179 } |
1129 } | 1180 } |
1130 | 1181 |
1131 // --------------------------------------------------------------------------- | 1182 // --------------------------------------------------------------------------- |
1266 Label hit; | 1317 Label hit; |
1267 Label exception_pending; | 1318 Label exception_pending; |
1268 | 1319 |
1269 | 1320 |
1270 __ verify_oop(receiver); | 1321 __ verify_oop(receiver); |
1271 __ cmpl(ic_reg, Address(receiver, oopDesc::klass_offset_in_bytes())); | 1322 __ cmpptr(ic_reg, Address(receiver, oopDesc::klass_offset_in_bytes())); |
1272 __ jcc(Assembler::equal, hit); | 1323 __ jcc(Assembler::equal, hit); |
1273 | 1324 |
1274 __ jump(RuntimeAddress(SharedRuntime::get_ic_miss_stub())); | 1325 __ jump(RuntimeAddress(SharedRuntime::get_ic_miss_stub())); |
1275 | 1326 |
1276 // verified entry must be aligned for code patching. | 1327 // verified entry must be aligned for code patching. |
1289 // Since hashCode is usually polymorphic at call sites we can't do | 1340 // Since hashCode is usually polymorphic at call sites we can't do |
1290 // this optimization at the call site without a lot of work. | 1341 // this optimization at the call site without a lot of work. |
1291 Label slowCase; | 1342 Label slowCase; |
1292 Register receiver = rcx; | 1343 Register receiver = rcx; |
1293 Register result = rax; | 1344 Register result = rax; |
1294 __ movl(result, Address(receiver, oopDesc::mark_offset_in_bytes())); | 1345 __ movptr(result, Address(receiver, oopDesc::mark_offset_in_bytes())); |
1295 | 1346 |
1296 // check if locked | 1347 // check if locked |
1297 __ testl (result, markOopDesc::unlocked_value); | 1348 __ testptr(result, markOopDesc::unlocked_value); |
1298 __ jcc (Assembler::zero, slowCase); | 1349 __ jcc (Assembler::zero, slowCase); |
1299 | 1350 |
1300 if (UseBiasedLocking) { | 1351 if (UseBiasedLocking) { |
1301 // Check if biased and fall through to runtime if so | 1352 // Check if biased and fall through to runtime if so |
1302 __ testl (result, markOopDesc::biased_lock_bit_in_place); | 1353 __ testptr(result, markOopDesc::biased_lock_bit_in_place); |
1303 __ jcc (Assembler::notZero, slowCase); | 1354 __ jcc (Assembler::notZero, slowCase); |
1304 } | 1355 } |
1305 | 1356 |
1306 // get hash | 1357 // get hash |
1307 __ andl (result, markOopDesc::hash_mask_in_place); | 1358 __ andptr(result, markOopDesc::hash_mask_in_place); |
1308 // test if hashCode exists | 1359 // test if hashCode exists |
1309 __ jcc (Assembler::zero, slowCase); | 1360 __ jcc (Assembler::zero, slowCase); |
1310 __ shrl (result, markOopDesc::hash_shift); | 1361 __ shrptr(result, markOopDesc::hash_shift); |
1311 __ ret(0); | 1362 __ ret(0); |
1312 __ bind (slowCase); | 1363 __ bind (slowCase); |
1313 } | 1364 } |
1314 #endif // COMPILER1 | 1365 #endif // COMPILER1 |
1315 | 1366 |
1327 } | 1378 } |
1328 | 1379 |
1329 // Generate a new frame for the wrapper. | 1380 // Generate a new frame for the wrapper. |
1330 __ enter(); | 1381 __ enter(); |
1331 // -2 because return address is already present and so is saved rbp, | 1382 // -2 because return address is already present and so is saved rbp, |
1332 __ subl(rsp, stack_size - 2*wordSize); | 1383 __ subptr(rsp, stack_size - 2*wordSize); |
1333 | 1384 |
1334 // Frame is now completed as far a size and linkage. | 1385 // Frame is now completed as far a size and linkage. |
1335 | 1386 |
1336 int frame_complete = ((intptr_t)__ pc()) - start; | 1387 int frame_complete = ((intptr_t)__ pc()) - start; |
1337 | 1388 |
1448 | 1499 |
1449 // load opp into a register | 1500 // load opp into a register |
1450 __ movoop(oop_handle_reg, JNIHandles::make_local(Klass::cast(method->method_holder())->java_mirror())); | 1501 __ movoop(oop_handle_reg, JNIHandles::make_local(Klass::cast(method->method_holder())->java_mirror())); |
1451 | 1502 |
1452 // Now handlize the static class mirror it's known not-null. | 1503 // Now handlize the static class mirror it's known not-null. |
1453 __ movl(Address(rsp, klass_offset), oop_handle_reg); | 1504 __ movptr(Address(rsp, klass_offset), oop_handle_reg); |
1454 map->set_oop(VMRegImpl::stack2reg(klass_slot_offset)); | 1505 map->set_oop(VMRegImpl::stack2reg(klass_slot_offset)); |
1455 | 1506 |
1456 // Now get the handle | 1507 // Now get the handle |
1457 __ leal(oop_handle_reg, Address(rsp, klass_offset)); | 1508 __ lea(oop_handle_reg, Address(rsp, klass_offset)); |
1458 // store the klass handle as second argument | 1509 // store the klass handle as second argument |
1459 __ movl(Address(rsp, wordSize), oop_handle_reg); | 1510 __ movptr(Address(rsp, wordSize), oop_handle_reg); |
1460 } | 1511 } |
1461 | 1512 |
1462 // Change state to native (we save the return address in the thread, since it might not | 1513 // Change state to native (we save the return address in the thread, since it might not |
1463 // be pushed on the stack when we do a a stack traversal). It is enough that the pc() | 1514 // be pushed on the stack when we do a a stack traversal). It is enough that the pc() |
1464 // points into the right code segment. It does not have to be the correct return pc. | 1515 // points into the right code segment. It does not have to be the correct return pc. |
1495 | 1546 |
1496 | 1547 |
1497 const int mark_word_offset = BasicLock::displaced_header_offset_in_bytes(); | 1548 const int mark_word_offset = BasicLock::displaced_header_offset_in_bytes(); |
1498 | 1549 |
1499 // Get the handle (the 2nd argument) | 1550 // Get the handle (the 2nd argument) |
1500 __ movl(oop_handle_reg, Address(rsp, wordSize)); | 1551 __ movptr(oop_handle_reg, Address(rsp, wordSize)); |
1501 | 1552 |
1502 // Get address of the box | 1553 // Get address of the box |
1503 | 1554 |
1504 __ leal(lock_reg, Address(rbp, lock_slot_rbp_offset)); | 1555 __ lea(lock_reg, Address(rbp, lock_slot_rbp_offset)); |
1505 | 1556 |
1506 // Load the oop from the handle | 1557 // Load the oop from the handle |
1507 __ movl(obj_reg, Address(oop_handle_reg, 0)); | 1558 __ movptr(obj_reg, Address(oop_handle_reg, 0)); |
1508 | 1559 |
1509 if (UseBiasedLocking) { | 1560 if (UseBiasedLocking) { |
1510 // Note that oop_handle_reg is trashed during this call | 1561 // Note that oop_handle_reg is trashed during this call |
1511 __ biased_locking_enter(lock_reg, obj_reg, swap_reg, oop_handle_reg, false, lock_done, &slow_path_lock); | 1562 __ biased_locking_enter(lock_reg, obj_reg, swap_reg, oop_handle_reg, false, lock_done, &slow_path_lock); |
1512 } | 1563 } |
1513 | 1564 |
1514 // Load immediate 1 into swap_reg %rax, | 1565 // Load immediate 1 into swap_reg %rax, |
1515 __ movl(swap_reg, 1); | 1566 __ movptr(swap_reg, 1); |
1516 | 1567 |
1517 // Load (object->mark() | 1) into swap_reg %rax, | 1568 // Load (object->mark() | 1) into swap_reg %rax, |
1518 __ orl(swap_reg, Address(obj_reg, 0)); | 1569 __ orptr(swap_reg, Address(obj_reg, 0)); |
1519 | 1570 |
1520 // Save (object->mark() | 1) into BasicLock's displaced header | 1571 // Save (object->mark() | 1) into BasicLock's displaced header |
1521 __ movl(Address(lock_reg, mark_word_offset), swap_reg); | 1572 __ movptr(Address(lock_reg, mark_word_offset), swap_reg); |
1522 | 1573 |
1523 if (os::is_MP()) { | 1574 if (os::is_MP()) { |
1524 __ lock(); | 1575 __ lock(); |
1525 } | 1576 } |
1526 | 1577 |
1527 // src -> dest iff dest == rax, else rax, <- dest | 1578 // src -> dest iff dest == rax, else rax, <- dest |
1528 // *obj_reg = lock_reg iff *obj_reg == rax, else rax, = *(obj_reg) | 1579 // *obj_reg = lock_reg iff *obj_reg == rax, else rax, = *(obj_reg) |
1529 __ cmpxchg(lock_reg, Address(obj_reg, 0)); | 1580 __ cmpxchgptr(lock_reg, Address(obj_reg, 0)); |
1530 __ jcc(Assembler::equal, lock_done); | 1581 __ jcc(Assembler::equal, lock_done); |
1531 | 1582 |
1532 // Test if the oopMark is an obvious stack pointer, i.e., | 1583 // Test if the oopMark is an obvious stack pointer, i.e., |
1533 // 1) (mark & 3) == 0, and | 1584 // 1) (mark & 3) == 0, and |
1534 // 2) rsp <= mark < mark + os::pagesize() | 1585 // 2) rsp <= mark < mark + os::pagesize() |
1536 // expression: ((mark - rsp) & (3 - os::vm_page_size())), | 1587 // expression: ((mark - rsp) & (3 - os::vm_page_size())), |
1537 // assuming both stack pointer and pagesize have their | 1588 // assuming both stack pointer and pagesize have their |
1538 // least significant 2 bits clear. | 1589 // least significant 2 bits clear. |
1539 // NOTE: the oopMark is in swap_reg %rax, as the result of cmpxchg | 1590 // NOTE: the oopMark is in swap_reg %rax, as the result of cmpxchg |
1540 | 1591 |
1541 __ subl(swap_reg, rsp); | 1592 __ subptr(swap_reg, rsp); |
1542 __ andl(swap_reg, 3 - os::vm_page_size()); | 1593 __ andptr(swap_reg, 3 - os::vm_page_size()); |
1543 | 1594 |
1544 // Save the test result, for recursive case, the result is zero | 1595 // Save the test result, for recursive case, the result is zero |
1545 __ movl(Address(lock_reg, mark_word_offset), swap_reg); | 1596 __ movptr(Address(lock_reg, mark_word_offset), swap_reg); |
1546 __ jcc(Assembler::notEqual, slow_path_lock); | 1597 __ jcc(Assembler::notEqual, slow_path_lock); |
1547 // Slow path will re-enter here | 1598 // Slow path will re-enter here |
1548 __ bind(lock_done); | 1599 __ bind(lock_done); |
1549 | 1600 |
1550 if (UseBiasedLocking) { | 1601 if (UseBiasedLocking) { |
1551 // Re-fetch oop_handle_reg as we trashed it above | 1602 // Re-fetch oop_handle_reg as we trashed it above |
1552 __ movl(oop_handle_reg, Address(rsp, wordSize)); | 1603 __ movptr(oop_handle_reg, Address(rsp, wordSize)); |
1553 } | 1604 } |
1554 } | 1605 } |
1555 | 1606 |
1556 | 1607 |
1557 // Finally just about ready to make the JNI call | 1608 // Finally just about ready to make the JNI call |
1558 | 1609 |
1559 | 1610 |
1560 // get JNIEnv* which is first argument to native | 1611 // get JNIEnv* which is first argument to native |
1561 | 1612 |
1562 __ leal(rdx, Address(thread, in_bytes(JavaThread::jni_environment_offset()))); | 1613 __ lea(rdx, Address(thread, in_bytes(JavaThread::jni_environment_offset()))); |
1563 __ movl(Address(rsp, 0), rdx); | 1614 __ movptr(Address(rsp, 0), rdx); |
1564 | 1615 |
1565 // Now set thread in native | 1616 // Now set thread in native |
1566 __ movl(Address(thread, JavaThread::thread_state_offset()), _thread_in_native); | 1617 __ movl(Address(thread, JavaThread::thread_state_offset()), _thread_in_native); |
1567 | 1618 |
1568 __ call(RuntimeAddress(method->native_function())); | 1619 __ call(RuntimeAddress(method->native_function())); |
1573 // relative addressing. | 1624 // relative addressing. |
1574 | 1625 |
1575 // Unpack native results. | 1626 // Unpack native results. |
1576 switch (ret_type) { | 1627 switch (ret_type) { |
1577 case T_BOOLEAN: __ c2bool(rax); break; | 1628 case T_BOOLEAN: __ c2bool(rax); break; |
1578 case T_CHAR : __ andl(rax, 0xFFFF); break; | 1629 case T_CHAR : __ andptr(rax, 0xFFFF); break; |
1579 case T_BYTE : __ sign_extend_byte (rax); break; | 1630 case T_BYTE : __ sign_extend_byte (rax); break; |
1580 case T_SHORT : __ sign_extend_short(rax); break; | 1631 case T_SHORT : __ sign_extend_short(rax); break; |
1581 case T_INT : /* nothing to do */ break; | 1632 case T_INT : /* nothing to do */ break; |
1582 case T_DOUBLE : | 1633 case T_DOUBLE : |
1583 case T_FLOAT : | 1634 case T_FLOAT : |
1600 // didn't see any synchronization is progress, and escapes. | 1651 // didn't see any synchronization is progress, and escapes. |
1601 __ movl(Address(thread, JavaThread::thread_state_offset()), _thread_in_native_trans); | 1652 __ movl(Address(thread, JavaThread::thread_state_offset()), _thread_in_native_trans); |
1602 | 1653 |
1603 if(os::is_MP()) { | 1654 if(os::is_MP()) { |
1604 if (UseMembar) { | 1655 if (UseMembar) { |
1605 __ membar(); // Force this write out before the read below | 1656 // Force this write out before the read below |
1657 __ membar(Assembler::Membar_mask_bits( | |
1658 Assembler::LoadLoad | Assembler::LoadStore | | |
1659 Assembler::StoreLoad | Assembler::StoreStore)); | |
1606 } else { | 1660 } else { |
1607 // Write serialization page so VM thread can do a pseudo remote membar. | 1661 // Write serialization page so VM thread can do a pseudo remote membar. |
1608 // We use the current thread pointer to calculate a thread specific | 1662 // We use the current thread pointer to calculate a thread specific |
1609 // offset to write to within the page. This minimizes bus traffic | 1663 // offset to write to within the page. This minimizes bus traffic |
1610 // due to cache line collision. | 1664 // due to cache line collision. |
1634 // Also can't use call_VM_leaf either as it will check to see if rsi & rdi are | 1688 // Also can't use call_VM_leaf either as it will check to see if rsi & rdi are |
1635 // preserved and correspond to the bcp/locals pointers. So we do a runtime call | 1689 // preserved and correspond to the bcp/locals pointers. So we do a runtime call |
1636 // by hand. | 1690 // by hand. |
1637 // | 1691 // |
1638 save_native_result(masm, ret_type, stack_slots); | 1692 save_native_result(masm, ret_type, stack_slots); |
1639 __ pushl(thread); | 1693 __ push(thread); |
1640 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, | 1694 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, |
1641 JavaThread::check_special_condition_for_native_trans))); | 1695 JavaThread::check_special_condition_for_native_trans))); |
1642 __ increment(rsp, wordSize); | 1696 __ increment(rsp, wordSize); |
1643 // Restore any method result value | 1697 // Restore any method result value |
1644 restore_native_result(masm, ret_type, stack_slots); | 1698 restore_native_result(masm, ret_type, stack_slots); |
1667 if (method->is_synchronized()) { | 1721 if (method->is_synchronized()) { |
1668 | 1722 |
1669 Label done; | 1723 Label done; |
1670 | 1724 |
1671 // Get locked oop from the handle we passed to jni | 1725 // Get locked oop from the handle we passed to jni |
1672 __ movl(obj_reg, Address(oop_handle_reg, 0)); | 1726 __ movptr(obj_reg, Address(oop_handle_reg, 0)); |
1673 | 1727 |
1674 if (UseBiasedLocking) { | 1728 if (UseBiasedLocking) { |
1675 __ biased_locking_exit(obj_reg, rbx, done); | 1729 __ biased_locking_exit(obj_reg, rbx, done); |
1676 } | 1730 } |
1677 | 1731 |
1678 // Simple recursive lock? | 1732 // Simple recursive lock? |
1679 | 1733 |
1680 __ cmpl(Address(rbp, lock_slot_rbp_offset), NULL_WORD); | 1734 __ cmpptr(Address(rbp, lock_slot_rbp_offset), (int32_t)NULL_WORD); |
1681 __ jcc(Assembler::equal, done); | 1735 __ jcc(Assembler::equal, done); |
1682 | 1736 |
1683 // Must save rax, if if it is live now because cmpxchg must use it | 1737 // Must save rax, if if it is live now because cmpxchg must use it |
1684 if (ret_type != T_FLOAT && ret_type != T_DOUBLE && ret_type != T_VOID) { | 1738 if (ret_type != T_FLOAT && ret_type != T_DOUBLE && ret_type != T_VOID) { |
1685 save_native_result(masm, ret_type, stack_slots); | 1739 save_native_result(masm, ret_type, stack_slots); |
1686 } | 1740 } |
1687 | 1741 |
1688 // get old displaced header | 1742 // get old displaced header |
1689 __ movl(rbx, Address(rbp, lock_slot_rbp_offset)); | 1743 __ movptr(rbx, Address(rbp, lock_slot_rbp_offset)); |
1690 | 1744 |
1691 // get address of the stack lock | 1745 // get address of the stack lock |
1692 __ leal(rax, Address(rbp, lock_slot_rbp_offset)); | 1746 __ lea(rax, Address(rbp, lock_slot_rbp_offset)); |
1693 | 1747 |
1694 // Atomic swap old header if oop still contains the stack lock | 1748 // Atomic swap old header if oop still contains the stack lock |
1695 if (os::is_MP()) { | 1749 if (os::is_MP()) { |
1696 __ lock(); | 1750 __ lock(); |
1697 } | 1751 } |
1698 | 1752 |
1699 // src -> dest iff dest == rax, else rax, <- dest | 1753 // src -> dest iff dest == rax, else rax, <- dest |
1700 // *obj_reg = rbx, iff *obj_reg == rax, else rax, = *(obj_reg) | 1754 // *obj_reg = rbx, iff *obj_reg == rax, else rax, = *(obj_reg) |
1701 __ cmpxchg(rbx, Address(obj_reg, 0)); | 1755 __ cmpxchgptr(rbx, Address(obj_reg, 0)); |
1702 __ jcc(Assembler::notEqual, slow_path_unlock); | 1756 __ jcc(Assembler::notEqual, slow_path_unlock); |
1703 | 1757 |
1704 // slow path re-enters here | 1758 // slow path re-enters here |
1705 __ bind(unlock_done); | 1759 __ bind(unlock_done); |
1706 if (ret_type != T_FLOAT && ret_type != T_DOUBLE && ret_type != T_VOID) { | 1760 if (ret_type != T_FLOAT && ret_type != T_DOUBLE && ret_type != T_VOID) { |
1727 __ reset_last_Java_frame(thread, false, true); | 1781 __ reset_last_Java_frame(thread, false, true); |
1728 | 1782 |
1729 // Unpack oop result | 1783 // Unpack oop result |
1730 if (ret_type == T_OBJECT || ret_type == T_ARRAY) { | 1784 if (ret_type == T_OBJECT || ret_type == T_ARRAY) { |
1731 Label L; | 1785 Label L; |
1732 __ cmpl(rax, NULL_WORD); | 1786 __ cmpptr(rax, (int32_t)NULL_WORD); |
1733 __ jcc(Assembler::equal, L); | 1787 __ jcc(Assembler::equal, L); |
1734 __ movl(rax, Address(rax, 0)); | 1788 __ movptr(rax, Address(rax, 0)); |
1735 __ bind(L); | 1789 __ bind(L); |
1736 __ verify_oop(rax); | 1790 __ verify_oop(rax); |
1737 } | 1791 } |
1738 | 1792 |
1739 // reset handle block | 1793 // reset handle block |
1740 __ movl(rcx, Address(thread, JavaThread::active_handles_offset())); | 1794 __ movptr(rcx, Address(thread, JavaThread::active_handles_offset())); |
1741 | 1795 |
1742 __ movl(Address(rcx, JNIHandleBlock::top_offset_in_bytes()), 0); | 1796 __ movptr(Address(rcx, JNIHandleBlock::top_offset_in_bytes()), (int32_t)NULL_WORD); |
1743 | 1797 |
1744 // Any exception pending? | 1798 // Any exception pending? |
1745 __ cmpl(Address(thread, in_bytes(Thread::pending_exception_offset())), NULL_WORD); | 1799 __ cmpptr(Address(thread, in_bytes(Thread::pending_exception_offset())), (int32_t)NULL_WORD); |
1746 __ jcc(Assembler::notEqual, exception_pending); | 1800 __ jcc(Assembler::notEqual, exception_pending); |
1747 | 1801 |
1748 | 1802 |
1749 // no exception, we're almost done | 1803 // no exception, we're almost done |
1750 | 1804 |
1780 | 1834 |
1781 __ bind(slow_path_lock); | 1835 __ bind(slow_path_lock); |
1782 | 1836 |
1783 // has last_Java_frame setup. No exceptions so do vanilla call not call_VM | 1837 // has last_Java_frame setup. No exceptions so do vanilla call not call_VM |
1784 // args are (oop obj, BasicLock* lock, JavaThread* thread) | 1838 // args are (oop obj, BasicLock* lock, JavaThread* thread) |
1785 __ pushl(thread); | 1839 __ push(thread); |
1786 __ pushl(lock_reg); | 1840 __ push(lock_reg); |
1787 __ pushl(obj_reg); | 1841 __ push(obj_reg); |
1788 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::complete_monitor_locking_C))); | 1842 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::complete_monitor_locking_C))); |
1789 __ addl(rsp, 3*wordSize); | 1843 __ addptr(rsp, 3*wordSize); |
1790 | 1844 |
1791 #ifdef ASSERT | 1845 #ifdef ASSERT |
1792 { Label L; | 1846 { Label L; |
1793 __ cmpl(Address(thread, in_bytes(Thread::pending_exception_offset())), (int)NULL_WORD); | 1847 __ cmpptr(Address(thread, in_bytes(Thread::pending_exception_offset())), (int)NULL_WORD); |
1794 __ jcc(Assembler::equal, L); | 1848 __ jcc(Assembler::equal, L); |
1795 __ stop("no pending exception allowed on exit from monitorenter"); | 1849 __ stop("no pending exception allowed on exit from monitorenter"); |
1796 __ bind(L); | 1850 __ bind(L); |
1797 } | 1851 } |
1798 #endif | 1852 #endif |
1808 if (ret_type == T_FLOAT || ret_type == T_DOUBLE ) { | 1862 if (ret_type == T_FLOAT || ret_type == T_DOUBLE ) { |
1809 save_native_result(masm, ret_type, stack_slots); | 1863 save_native_result(masm, ret_type, stack_slots); |
1810 } | 1864 } |
1811 // Save pending exception around call to VM (which contains an EXCEPTION_MARK) | 1865 // Save pending exception around call to VM (which contains an EXCEPTION_MARK) |
1812 | 1866 |
1813 __ pushl(Address(thread, in_bytes(Thread::pending_exception_offset()))); | 1867 __ pushptr(Address(thread, in_bytes(Thread::pending_exception_offset()))); |
1814 __ movl(Address(thread, in_bytes(Thread::pending_exception_offset())), NULL_WORD); | 1868 __ movptr(Address(thread, in_bytes(Thread::pending_exception_offset())), (int32_t)NULL_WORD); |
1815 | 1869 |
1816 | 1870 |
1817 // should be a peal | 1871 // should be a peal |
1818 // +wordSize because of the push above | 1872 // +wordSize because of the push above |
1819 __ leal(rax, Address(rbp, lock_slot_rbp_offset)); | 1873 __ lea(rax, Address(rbp, lock_slot_rbp_offset)); |
1820 __ pushl(rax); | 1874 __ push(rax); |
1821 | 1875 |
1822 __ pushl(obj_reg); | 1876 __ push(obj_reg); |
1823 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::complete_monitor_unlocking_C))); | 1877 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::complete_monitor_unlocking_C))); |
1824 __ addl(rsp, 2*wordSize); | 1878 __ addptr(rsp, 2*wordSize); |
1825 #ifdef ASSERT | 1879 #ifdef ASSERT |
1826 { | 1880 { |
1827 Label L; | 1881 Label L; |
1828 __ cmpl(Address(thread, in_bytes(Thread::pending_exception_offset())), NULL_WORD); | 1882 __ cmpptr(Address(thread, in_bytes(Thread::pending_exception_offset())), (int32_t)NULL_WORD); |
1829 __ jcc(Assembler::equal, L); | 1883 __ jcc(Assembler::equal, L); |
1830 __ stop("no pending exception allowed on exit complete_monitor_unlocking_C"); | 1884 __ stop("no pending exception allowed on exit complete_monitor_unlocking_C"); |
1831 __ bind(L); | 1885 __ bind(L); |
1832 } | 1886 } |
1833 #endif /* ASSERT */ | 1887 #endif /* ASSERT */ |
1834 | 1888 |
1835 __ popl(Address(thread, in_bytes(Thread::pending_exception_offset()))); | 1889 __ popptr(Address(thread, in_bytes(Thread::pending_exception_offset()))); |
1836 | 1890 |
1837 if (ret_type == T_FLOAT || ret_type == T_DOUBLE ) { | 1891 if (ret_type == T_FLOAT || ret_type == T_DOUBLE ) { |
1838 restore_native_result(masm, ret_type, stack_slots); | 1892 restore_native_result(masm, ret_type, stack_slots); |
1839 } | 1893 } |
1840 __ jmp(unlock_done); | 1894 __ jmp(unlock_done); |
2318 | 2372 |
2319 // Save everything in sight. | 2373 // Save everything in sight. |
2320 | 2374 |
2321 map = RegisterSaver::save_live_registers(masm, additional_words, &frame_size_in_words); | 2375 map = RegisterSaver::save_live_registers(masm, additional_words, &frame_size_in_words); |
2322 // Normal deoptimization | 2376 // Normal deoptimization |
2323 __ pushl(Deoptimization::Unpack_deopt); | 2377 __ push(Deoptimization::Unpack_deopt); |
2324 __ jmp(cont); | 2378 __ jmp(cont); |
2325 | 2379 |
2326 int reexecute_offset = __ pc() - start; | 2380 int reexecute_offset = __ pc() - start; |
2327 | 2381 |
2328 // Reexecute case | 2382 // Reexecute case |
2329 // return address is the pc describes what bci to do re-execute at | 2383 // return address is the pc describes what bci to do re-execute at |
2330 | 2384 |
2331 // No need to update map as each call to save_live_registers will produce identical oopmap | 2385 // No need to update map as each call to save_live_registers will produce identical oopmap |
2332 (void) RegisterSaver::save_live_registers(masm, additional_words, &frame_size_in_words); | 2386 (void) RegisterSaver::save_live_registers(masm, additional_words, &frame_size_in_words); |
2333 | 2387 |
2334 __ pushl(Deoptimization::Unpack_reexecute); | 2388 __ push(Deoptimization::Unpack_reexecute); |
2335 __ jmp(cont); | 2389 __ jmp(cont); |
2336 | 2390 |
2337 int exception_offset = __ pc() - start; | 2391 int exception_offset = __ pc() - start; |
2338 | 2392 |
2339 // Prolog for exception case | 2393 // Prolog for exception case |
2342 // rdx which contain the exception oop and exception pc | 2396 // rdx which contain the exception oop and exception pc |
2343 // respectively. Set them in TLS and fall thru to the | 2397 // respectively. Set them in TLS and fall thru to the |
2344 // unpack_with_exception_in_tls entry point. | 2398 // unpack_with_exception_in_tls entry point. |
2345 | 2399 |
2346 __ get_thread(rdi); | 2400 __ get_thread(rdi); |
2347 __ movl(Address(rdi, JavaThread::exception_pc_offset()), rdx); | 2401 __ movptr(Address(rdi, JavaThread::exception_pc_offset()), rdx); |
2348 __ movl(Address(rdi, JavaThread::exception_oop_offset()), rax); | 2402 __ movptr(Address(rdi, JavaThread::exception_oop_offset()), rax); |
2349 | 2403 |
2350 int exception_in_tls_offset = __ pc() - start; | 2404 int exception_in_tls_offset = __ pc() - start; |
2351 | 2405 |
2352 // new implementation because exception oop is now passed in JavaThread | 2406 // new implementation because exception oop is now passed in JavaThread |
2353 | 2407 |
2358 // args are on the stack, no return address) | 2412 // args are on the stack, no return address) |
2359 | 2413 |
2360 // make room on stack for the return address | 2414 // make room on stack for the return address |
2361 // It will be patched later with the throwing pc. The correct value is not | 2415 // It will be patched later with the throwing pc. The correct value is not |
2362 // available now because loading it from memory would destroy registers. | 2416 // available now because loading it from memory would destroy registers. |
2363 __ pushl(0); | 2417 __ push(0); |
2364 | 2418 |
2365 // Save everything in sight. | 2419 // Save everything in sight. |
2366 | 2420 |
2367 // No need to update map as each call to save_live_registers will produce identical oopmap | 2421 // No need to update map as each call to save_live_registers will produce identical oopmap |
2368 (void) RegisterSaver::save_live_registers(masm, additional_words, &frame_size_in_words); | 2422 (void) RegisterSaver::save_live_registers(masm, additional_words, &frame_size_in_words); |
2369 | 2423 |
2370 // Now it is safe to overwrite any register | 2424 // Now it is safe to overwrite any register |
2371 | 2425 |
2372 // store the correct deoptimization type | 2426 // store the correct deoptimization type |
2373 __ pushl(Deoptimization::Unpack_exception); | 2427 __ push(Deoptimization::Unpack_exception); |
2374 | 2428 |
2375 // load throwing pc from JavaThread and patch it as the return address | 2429 // load throwing pc from JavaThread and patch it as the return address |
2376 // of the current frame. Then clear the field in JavaThread | 2430 // of the current frame. Then clear the field in JavaThread |
2377 __ get_thread(rdi); | 2431 __ get_thread(rdi); |
2378 __ movl(rdx, Address(rdi, JavaThread::exception_pc_offset())); | 2432 __ movptr(rdx, Address(rdi, JavaThread::exception_pc_offset())); |
2379 __ movl(Address(rbp, wordSize), rdx); | 2433 __ movptr(Address(rbp, wordSize), rdx); |
2380 __ movl(Address(rdi, JavaThread::exception_pc_offset()), NULL_WORD); | 2434 __ movptr(Address(rdi, JavaThread::exception_pc_offset()), (int32_t)NULL_WORD); |
2381 | 2435 |
2382 #ifdef ASSERT | 2436 #ifdef ASSERT |
2383 // verify that there is really an exception oop in JavaThread | 2437 // verify that there is really an exception oop in JavaThread |
2384 __ movl(rax, Address(rdi, JavaThread::exception_oop_offset())); | 2438 __ movptr(rax, Address(rdi, JavaThread::exception_oop_offset())); |
2385 __ verify_oop(rax); | 2439 __ verify_oop(rax); |
2386 | 2440 |
2387 // verify that there is no pending exception | 2441 // verify that there is no pending exception |
2388 Label no_pending_exception; | 2442 Label no_pending_exception; |
2389 __ movl(rax, Address(rdi, Thread::pending_exception_offset())); | 2443 __ movptr(rax, Address(rdi, Thread::pending_exception_offset())); |
2390 __ testl(rax, rax); | 2444 __ testptr(rax, rax); |
2391 __ jcc(Assembler::zero, no_pending_exception); | 2445 __ jcc(Assembler::zero, no_pending_exception); |
2392 __ stop("must not have pending exception here"); | 2446 __ stop("must not have pending exception here"); |
2393 __ bind(no_pending_exception); | 2447 __ bind(no_pending_exception); |
2394 #endif | 2448 #endif |
2395 | 2449 |
2400 | 2454 |
2401 | 2455 |
2402 // Call C code. Need thread and this frame, but NOT official VM entry | 2456 // Call C code. Need thread and this frame, but NOT official VM entry |
2403 // crud. We cannot block on this call, no GC can happen. | 2457 // crud. We cannot block on this call, no GC can happen. |
2404 __ get_thread(rcx); | 2458 __ get_thread(rcx); |
2405 __ pushl(rcx); | 2459 __ push(rcx); |
2406 // fetch_unroll_info needs to call last_java_frame() | 2460 // fetch_unroll_info needs to call last_java_frame() |
2407 __ set_last_Java_frame(rcx, noreg, noreg, NULL); | 2461 __ set_last_Java_frame(rcx, noreg, noreg, NULL); |
2408 | 2462 |
2409 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, Deoptimization::fetch_unroll_info))); | 2463 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, Deoptimization::fetch_unroll_info))); |
2410 | 2464 |
2412 // find any register it might need. | 2466 // find any register it might need. |
2413 | 2467 |
2414 oop_maps->add_gc_map( __ pc()-start, map); | 2468 oop_maps->add_gc_map( __ pc()-start, map); |
2415 | 2469 |
2416 // Discard arg to fetch_unroll_info | 2470 // Discard arg to fetch_unroll_info |
2417 __ popl(rcx); | 2471 __ pop(rcx); |
2418 | 2472 |
2419 __ get_thread(rcx); | 2473 __ get_thread(rcx); |
2420 __ reset_last_Java_frame(rcx, false, false); | 2474 __ reset_last_Java_frame(rcx, false, false); |
2421 | 2475 |
2422 // Load UnrollBlock into EDI | 2476 // Load UnrollBlock into EDI |
2423 __ movl(rdi, rax); | 2477 __ mov(rdi, rax); |
2424 | 2478 |
2425 // Move the unpack kind to a safe place in the UnrollBlock because | 2479 // Move the unpack kind to a safe place in the UnrollBlock because |
2426 // we are very short of registers | 2480 // we are very short of registers |
2427 | 2481 |
2428 Address unpack_kind(rdi, Deoptimization::UnrollBlock::unpack_kind_offset_in_bytes()); | 2482 Address unpack_kind(rdi, Deoptimization::UnrollBlock::unpack_kind_offset_in_bytes()); |
2429 // retrieve the deopt kind from where we left it. | 2483 // retrieve the deopt kind from where we left it. |
2430 __ popl(rax); | 2484 __ pop(rax); |
2431 __ movl(unpack_kind, rax); // save the unpack_kind value | 2485 __ movl(unpack_kind, rax); // save the unpack_kind value |
2432 | 2486 |
2433 Label noException; | 2487 Label noException; |
2434 __ cmpl(rax, Deoptimization::Unpack_exception); // Was exception pending? | 2488 __ cmpl(rax, Deoptimization::Unpack_exception); // Was exception pending? |
2435 __ jcc(Assembler::notEqual, noException); | 2489 __ jcc(Assembler::notEqual, noException); |
2436 __ movl(rax, Address(rcx, JavaThread::exception_oop_offset())); | 2490 __ movptr(rax, Address(rcx, JavaThread::exception_oop_offset())); |
2437 __ movl(rdx, Address(rcx, JavaThread::exception_pc_offset())); | 2491 __ movptr(rdx, Address(rcx, JavaThread::exception_pc_offset())); |
2438 __ movl(Address(rcx, JavaThread::exception_oop_offset()), NULL_WORD); | 2492 __ movptr(Address(rcx, JavaThread::exception_oop_offset()), (int32_t)NULL_WORD); |
2439 __ movl(Address(rcx, JavaThread::exception_pc_offset()), NULL_WORD); | 2493 __ movptr(Address(rcx, JavaThread::exception_pc_offset()), (int32_t)NULL_WORD); |
2440 | 2494 |
2441 __ verify_oop(rax); | 2495 __ verify_oop(rax); |
2442 | 2496 |
2443 // Overwrite the result registers with the exception results. | 2497 // Overwrite the result registers with the exception results. |
2444 __ movl(Address(rsp, RegisterSaver::raxOffset()*wordSize), rax); | 2498 __ movptr(Address(rsp, RegisterSaver::raxOffset()*wordSize), rax); |
2445 __ movl(Address(rsp, RegisterSaver::rdxOffset()*wordSize), rdx); | 2499 __ movptr(Address(rsp, RegisterSaver::rdxOffset()*wordSize), rdx); |
2446 | 2500 |
2447 __ bind(noException); | 2501 __ bind(noException); |
2448 | 2502 |
2449 // Stack is back to only having register save data on the stack. | 2503 // Stack is back to only having register save data on the stack. |
2450 // Now restore the result registers. Everything else is either dead or captured | 2504 // Now restore the result registers. Everything else is either dead or captured |
2465 // Note: by leaving the return address of self-frame on the stack | 2519 // Note: by leaving the return address of self-frame on the stack |
2466 // and using the size of frame 2 to adjust the stack | 2520 // and using the size of frame 2 to adjust the stack |
2467 // when we are done the return to frame 3 will still be on the stack. | 2521 // when we are done the return to frame 3 will still be on the stack. |
2468 | 2522 |
2469 // Pop deoptimized frame | 2523 // Pop deoptimized frame |
2470 __ addl(rsp,Address(rdi,Deoptimization::UnrollBlock::size_of_deoptimized_frame_offset_in_bytes())); | 2524 __ addptr(rsp, Address(rdi,Deoptimization::UnrollBlock::size_of_deoptimized_frame_offset_in_bytes())); |
2471 | 2525 |
2472 // sp should be pointing at the return address to the caller (3) | 2526 // sp should be pointing at the return address to the caller (3) |
2473 | 2527 |
2474 // Stack bang to make sure there's enough room for these interpreter frames. | 2528 // Stack bang to make sure there's enough room for these interpreter frames. |
2475 if (UseStackBanging) { | 2529 if (UseStackBanging) { |
2476 __ movl(rbx, Address(rdi ,Deoptimization::UnrollBlock::total_frame_sizes_offset_in_bytes())); | 2530 __ movl(rbx, Address(rdi ,Deoptimization::UnrollBlock::total_frame_sizes_offset_in_bytes())); |
2477 __ bang_stack_size(rbx, rcx); | 2531 __ bang_stack_size(rbx, rcx); |
2478 } | 2532 } |
2479 | 2533 |
2480 // Load array of frame pcs into ECX | 2534 // Load array of frame pcs into ECX |
2481 __ movl(rcx,Address(rdi,Deoptimization::UnrollBlock::frame_pcs_offset_in_bytes())); | 2535 __ movptr(rcx,Address(rdi,Deoptimization::UnrollBlock::frame_pcs_offset_in_bytes())); |
2482 | 2536 |
2483 __ popl(rsi); // trash the old pc | 2537 __ pop(rsi); // trash the old pc |
2484 | 2538 |
2485 // Load array of frame sizes into ESI | 2539 // Load array of frame sizes into ESI |
2486 __ movl(rsi,Address(rdi,Deoptimization::UnrollBlock::frame_sizes_offset_in_bytes())); | 2540 __ movptr(rsi,Address(rdi,Deoptimization::UnrollBlock::frame_sizes_offset_in_bytes())); |
2487 | 2541 |
2488 Address counter(rdi, Deoptimization::UnrollBlock::counter_temp_offset_in_bytes()); | 2542 Address counter(rdi, Deoptimization::UnrollBlock::counter_temp_offset_in_bytes()); |
2489 | 2543 |
2490 __ movl(rbx, Address(rdi, Deoptimization::UnrollBlock::number_of_frames_offset_in_bytes())); | 2544 __ movl(rbx, Address(rdi, Deoptimization::UnrollBlock::number_of_frames_offset_in_bytes())); |
2491 __ movl(counter, rbx); | 2545 __ movl(counter, rbx); |
2492 | 2546 |
2493 // Pick up the initial fp we should save | 2547 // Pick up the initial fp we should save |
2494 __ movl(rbp, Address(rdi, Deoptimization::UnrollBlock::initial_fp_offset_in_bytes())); | 2548 __ movptr(rbp, Address(rdi, Deoptimization::UnrollBlock::initial_fp_offset_in_bytes())); |
2495 | 2549 |
2496 // Now adjust the caller's stack to make up for the extra locals | 2550 // Now adjust the caller's stack to make up for the extra locals |
2497 // but record the original sp so that we can save it in the skeletal interpreter | 2551 // but record the original sp so that we can save it in the skeletal interpreter |
2498 // frame and the stack walking of interpreter_sender will get the unextended sp | 2552 // frame and the stack walking of interpreter_sender will get the unextended sp |
2499 // value and not the "real" sp value. | 2553 // value and not the "real" sp value. |
2500 | 2554 |
2501 Address sp_temp(rdi, Deoptimization::UnrollBlock::sender_sp_temp_offset_in_bytes()); | 2555 Address sp_temp(rdi, Deoptimization::UnrollBlock::sender_sp_temp_offset_in_bytes()); |
2502 __ movl(sp_temp, rsp); | 2556 __ movptr(sp_temp, rsp); |
2503 __ subl(rsp, Address(rdi, Deoptimization::UnrollBlock::caller_adjustment_offset_in_bytes())); | 2557 __ movl2ptr(rbx, Address(rdi, Deoptimization::UnrollBlock::caller_adjustment_offset_in_bytes())); |
2558 __ subptr(rsp, rbx); | |
2504 | 2559 |
2505 // Push interpreter frames in a loop | 2560 // Push interpreter frames in a loop |
2506 Label loop; | 2561 Label loop; |
2507 __ bind(loop); | 2562 __ bind(loop); |
2508 __ movl(rbx, Address(rsi, 0)); // Load frame size | 2563 __ movptr(rbx, Address(rsi, 0)); // Load frame size |
2509 #ifdef CC_INTERP | 2564 #ifdef CC_INTERP |
2510 __ subl(rbx, 4*wordSize); // we'll push pc and ebp by hand and | 2565 __ subptr(rbx, 4*wordSize); // we'll push pc and ebp by hand and |
2511 #ifdef ASSERT | 2566 #ifdef ASSERT |
2512 __ pushl(0xDEADDEAD); // Make a recognizable pattern | 2567 __ push(0xDEADDEAD); // Make a recognizable pattern |
2513 __ pushl(0xDEADDEAD); | 2568 __ push(0xDEADDEAD); |
2514 #else /* ASSERT */ | 2569 #else /* ASSERT */ |
2515 __ subl(rsp, 2*wordSize); // skip the "static long no_param" | 2570 __ subptr(rsp, 2*wordSize); // skip the "static long no_param" |
2516 #endif /* ASSERT */ | 2571 #endif /* ASSERT */ |
2517 #else /* CC_INTERP */ | 2572 #else /* CC_INTERP */ |
2518 __ subl(rbx, 2*wordSize); // we'll push pc and rbp, by hand | 2573 __ subptr(rbx, 2*wordSize); // we'll push pc and rbp, by hand |
2519 #endif /* CC_INTERP */ | 2574 #endif /* CC_INTERP */ |
2520 __ pushl(Address(rcx, 0)); // save return address | 2575 __ pushptr(Address(rcx, 0)); // save return address |
2521 __ enter(); // save old & set new rbp, | 2576 __ enter(); // save old & set new rbp, |
2522 __ subl(rsp, rbx); // Prolog! | 2577 __ subptr(rsp, rbx); // Prolog! |
2523 __ movl(rbx, sp_temp); // sender's sp | 2578 __ movptr(rbx, sp_temp); // sender's sp |
2524 #ifdef CC_INTERP | 2579 #ifdef CC_INTERP |
2525 __ movl(Address(rbp, | 2580 __ movptr(Address(rbp, |
2526 -(sizeof(BytecodeInterpreter)) + in_bytes(byte_offset_of(BytecodeInterpreter, _sender_sp))), | 2581 -(sizeof(BytecodeInterpreter)) + in_bytes(byte_offset_of(BytecodeInterpreter, _sender_sp))), |
2527 rbx); // Make it walkable | 2582 rbx); // Make it walkable |
2528 #else /* CC_INTERP */ | 2583 #else /* CC_INTERP */ |
2529 // This value is corrected by layout_activation_impl | 2584 // This value is corrected by layout_activation_impl |
2530 __ movl(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), NULL_WORD ); | 2585 __ movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), (int32_t)NULL_WORD ); |
2531 __ movl(Address(rbp, frame::interpreter_frame_sender_sp_offset * wordSize), rbx); // Make it walkable | 2586 __ movptr(Address(rbp, frame::interpreter_frame_sender_sp_offset * wordSize), rbx); // Make it walkable |
2532 #endif /* CC_INTERP */ | 2587 #endif /* CC_INTERP */ |
2533 __ movl(sp_temp, rsp); // pass to next frame | 2588 __ movptr(sp_temp, rsp); // pass to next frame |
2534 __ addl(rsi, 4); // Bump array pointer (sizes) | 2589 __ addptr(rsi, wordSize); // Bump array pointer (sizes) |
2535 __ addl(rcx, 4); // Bump array pointer (pcs) | 2590 __ addptr(rcx, wordSize); // Bump array pointer (pcs) |
2536 __ decrement(counter); // decrement counter | 2591 __ decrementl(counter); // decrement counter |
2537 __ jcc(Assembler::notZero, loop); | 2592 __ jcc(Assembler::notZero, loop); |
2538 __ pushl(Address(rcx, 0)); // save final return address | 2593 __ pushptr(Address(rcx, 0)); // save final return address |
2539 | 2594 |
2540 // Re-push self-frame | 2595 // Re-push self-frame |
2541 __ enter(); // save old & set new rbp, | 2596 __ enter(); // save old & set new rbp, |
2542 | 2597 |
2543 // Return address and rbp, are in place | 2598 // Return address and rbp, are in place |
2544 // We'll push additional args later. Just allocate a full sized | 2599 // We'll push additional args later. Just allocate a full sized |
2545 // register save area | 2600 // register save area |
2546 __ subl(rsp, (frame_size_in_words-additional_words - 2) * wordSize); | 2601 __ subptr(rsp, (frame_size_in_words-additional_words - 2) * wordSize); |
2547 | 2602 |
2548 // Restore frame locals after moving the frame | 2603 // Restore frame locals after moving the frame |
2549 __ movl(Address(rsp, RegisterSaver::raxOffset()*wordSize), rax); | 2604 __ movptr(Address(rsp, RegisterSaver::raxOffset()*wordSize), rax); |
2550 __ movl(Address(rsp, RegisterSaver::rdxOffset()*wordSize), rdx); | 2605 __ movptr(Address(rsp, RegisterSaver::rdxOffset()*wordSize), rdx); |
2551 __ fstp_d(Address(rsp, RegisterSaver::fpResultOffset()*wordSize)); // Pop float stack and store in local | 2606 __ fstp_d(Address(rsp, RegisterSaver::fpResultOffset()*wordSize)); // Pop float stack and store in local |
2552 if( UseSSE>=2 ) __ movdbl(Address(rsp, RegisterSaver::xmm0Offset()*wordSize), xmm0); | 2607 if( UseSSE>=2 ) __ movdbl(Address(rsp, RegisterSaver::xmm0Offset()*wordSize), xmm0); |
2553 if( UseSSE==1 ) __ movflt(Address(rsp, RegisterSaver::xmm0Offset()*wordSize), xmm0); | 2608 if( UseSSE==1 ) __ movflt(Address(rsp, RegisterSaver::xmm0Offset()*wordSize), xmm0); |
2554 | 2609 |
2555 // Set up the args to unpack_frame | 2610 // Set up the args to unpack_frame |
2556 | 2611 |
2557 __ pushl(unpack_kind); // get the unpack_kind value | 2612 __ pushl(unpack_kind); // get the unpack_kind value |
2558 __ get_thread(rcx); | 2613 __ get_thread(rcx); |
2559 __ pushl(rcx); | 2614 __ push(rcx); |
2560 | 2615 |
2561 // set last_Java_sp, last_Java_fp | 2616 // set last_Java_sp, last_Java_fp |
2562 __ set_last_Java_frame(rcx, noreg, rbp, NULL); | 2617 __ set_last_Java_frame(rcx, noreg, rbp, NULL); |
2563 | 2618 |
2564 // Call C code. Need thread but NOT official VM entry | 2619 // Call C code. Need thread but NOT official VM entry |
2567 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, Deoptimization::unpack_frames))); | 2622 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, Deoptimization::unpack_frames))); |
2568 // Set an oopmap for the call site | 2623 // Set an oopmap for the call site |
2569 oop_maps->add_gc_map( __ pc()-start, new OopMap( frame_size_in_words, 0 )); | 2624 oop_maps->add_gc_map( __ pc()-start, new OopMap( frame_size_in_words, 0 )); |
2570 | 2625 |
2571 // rax, contains the return result type | 2626 // rax, contains the return result type |
2572 __ pushl(rax); | 2627 __ push(rax); |
2573 | 2628 |
2574 __ get_thread(rcx); | 2629 __ get_thread(rcx); |
2575 __ reset_last_Java_frame(rcx, false, false); | 2630 __ reset_last_Java_frame(rcx, false, false); |
2576 | 2631 |
2577 // Collect return values | 2632 // Collect return values |
2578 __ movl(rax,Address(rsp, (RegisterSaver::raxOffset() + additional_words + 1)*wordSize)); | 2633 __ movptr(rax,Address(rsp, (RegisterSaver::raxOffset() + additional_words + 1)*wordSize)); |
2579 __ movl(rdx,Address(rsp, (RegisterSaver::rdxOffset() + additional_words + 1)*wordSize)); | 2634 __ movptr(rdx,Address(rsp, (RegisterSaver::rdxOffset() + additional_words + 1)*wordSize)); |
2580 | 2635 |
2581 // Clear floating point stack before returning to interpreter | 2636 // Clear floating point stack before returning to interpreter |
2582 __ empty_FPU_stack(); | 2637 __ empty_FPU_stack(); |
2583 | 2638 |
2584 // Check if we should push the float or double return value. | 2639 // Check if we should push the float or double return value. |
2635 framesize | 2690 framesize |
2636 }; | 2691 }; |
2637 | 2692 |
2638 address start = __ pc(); | 2693 address start = __ pc(); |
2639 // Push self-frame. | 2694 // Push self-frame. |
2640 __ subl(rsp, return_off*wordSize); // Epilog! | 2695 __ subptr(rsp, return_off*wordSize); // Epilog! |
2641 | 2696 |
2642 // rbp, is an implicitly saved callee saved register (i.e. the calling | 2697 // rbp, is an implicitly saved callee saved register (i.e. the calling |
2643 // convention will save restore it in prolog/epilog) Other than that | 2698 // convention will save restore it in prolog/epilog) Other than that |
2644 // there are no callee save registers no that adapter frames are gone. | 2699 // there are no callee save registers no that adapter frames are gone. |
2645 __ movl(Address(rsp, rbp_off*wordSize),rbp); | 2700 __ movptr(Address(rsp, rbp_off*wordSize), rbp); |
2646 | 2701 |
2647 // Clear the floating point exception stack | 2702 // Clear the floating point exception stack |
2648 __ empty_FPU_stack(); | 2703 __ empty_FPU_stack(); |
2649 | 2704 |
2650 // set last_Java_sp | 2705 // set last_Java_sp |
2652 __ set_last_Java_frame(rdx, noreg, noreg, NULL); | 2707 __ set_last_Java_frame(rdx, noreg, noreg, NULL); |
2653 | 2708 |
2654 // Call C code. Need thread but NOT official VM entry | 2709 // Call C code. Need thread but NOT official VM entry |
2655 // crud. We cannot block on this call, no GC can happen. Call should | 2710 // crud. We cannot block on this call, no GC can happen. Call should |
2656 // capture callee-saved registers as well as return values. | 2711 // capture callee-saved registers as well as return values. |
2657 __ movl(Address(rsp, arg0_off*wordSize),rdx); | 2712 __ movptr(Address(rsp, arg0_off*wordSize), rdx); |
2658 // argument already in ECX | 2713 // argument already in ECX |
2659 __ movl(Address(rsp, arg1_off*wordSize),rcx); | 2714 __ movl(Address(rsp, arg1_off*wordSize),rcx); |
2660 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, Deoptimization::uncommon_trap))); | 2715 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, Deoptimization::uncommon_trap))); |
2661 | 2716 |
2662 // Set an oopmap for the call site | 2717 // Set an oopmap for the call site |
2669 __ get_thread(rcx); | 2724 __ get_thread(rcx); |
2670 | 2725 |
2671 __ reset_last_Java_frame(rcx, false, false); | 2726 __ reset_last_Java_frame(rcx, false, false); |
2672 | 2727 |
2673 // Load UnrollBlock into EDI | 2728 // Load UnrollBlock into EDI |
2674 __ movl(rdi, rax); | 2729 __ movptr(rdi, rax); |
2675 | 2730 |
2676 // Pop all the frames we must move/replace. | 2731 // Pop all the frames we must move/replace. |
2677 // | 2732 // |
2678 // Frame picture (youngest to oldest) | 2733 // Frame picture (youngest to oldest) |
2679 // 1: self-frame (no frame link) | 2734 // 1: self-frame (no frame link) |
2680 // 2: deopting frame (no frame link) | 2735 // 2: deopting frame (no frame link) |
2681 // 3: caller of deopting frame (could be compiled/interpreted). | 2736 // 3: caller of deopting frame (could be compiled/interpreted). |
2682 | 2737 |
2683 // Pop self-frame. We have no frame, and must rely only on EAX and ESP. | 2738 // Pop self-frame. We have no frame, and must rely only on EAX and ESP. |
2684 __ addl(rsp,(framesize-1)*wordSize); // Epilog! | 2739 __ addptr(rsp,(framesize-1)*wordSize); // Epilog! |
2685 | 2740 |
2686 // Pop deoptimized frame | 2741 // Pop deoptimized frame |
2687 __ addl(rsp,Address(rdi,Deoptimization::UnrollBlock::size_of_deoptimized_frame_offset_in_bytes())); | 2742 __ movl2ptr(rcx, Address(rdi,Deoptimization::UnrollBlock::size_of_deoptimized_frame_offset_in_bytes())); |
2743 __ addptr(rsp, rcx); | |
2688 | 2744 |
2689 // sp should be pointing at the return address to the caller (3) | 2745 // sp should be pointing at the return address to the caller (3) |
2690 | 2746 |
2691 // Stack bang to make sure there's enough room for these interpreter frames. | 2747 // Stack bang to make sure there's enough room for these interpreter frames. |
2692 if (UseStackBanging) { | 2748 if (UseStackBanging) { |
2696 | 2752 |
2697 | 2753 |
2698 // Load array of frame pcs into ECX | 2754 // Load array of frame pcs into ECX |
2699 __ movl(rcx,Address(rdi,Deoptimization::UnrollBlock::frame_pcs_offset_in_bytes())); | 2755 __ movl(rcx,Address(rdi,Deoptimization::UnrollBlock::frame_pcs_offset_in_bytes())); |
2700 | 2756 |
2701 __ popl(rsi); // trash the pc | 2757 __ pop(rsi); // trash the pc |
2702 | 2758 |
2703 // Load array of frame sizes into ESI | 2759 // Load array of frame sizes into ESI |
2704 __ movl(rsi,Address(rdi,Deoptimization::UnrollBlock::frame_sizes_offset_in_bytes())); | 2760 __ movptr(rsi,Address(rdi,Deoptimization::UnrollBlock::frame_sizes_offset_in_bytes())); |
2705 | 2761 |
2706 Address counter(rdi, Deoptimization::UnrollBlock::counter_temp_offset_in_bytes()); | 2762 Address counter(rdi, Deoptimization::UnrollBlock::counter_temp_offset_in_bytes()); |
2707 | 2763 |
2708 __ movl(rbx, Address(rdi, Deoptimization::UnrollBlock::number_of_frames_offset_in_bytes())); | 2764 __ movl(rbx, Address(rdi, Deoptimization::UnrollBlock::number_of_frames_offset_in_bytes())); |
2709 __ movl(counter, rbx); | 2765 __ movl(counter, rbx); |
2710 | 2766 |
2711 // Pick up the initial fp we should save | 2767 // Pick up the initial fp we should save |
2712 __ movl(rbp, Address(rdi, Deoptimization::UnrollBlock::initial_fp_offset_in_bytes())); | 2768 __ movptr(rbp, Address(rdi, Deoptimization::UnrollBlock::initial_fp_offset_in_bytes())); |
2713 | 2769 |
2714 // Now adjust the caller's stack to make up for the extra locals | 2770 // Now adjust the caller's stack to make up for the extra locals |
2715 // but record the original sp so that we can save it in the skeletal interpreter | 2771 // but record the original sp so that we can save it in the skeletal interpreter |
2716 // frame and the stack walking of interpreter_sender will get the unextended sp | 2772 // frame and the stack walking of interpreter_sender will get the unextended sp |
2717 // value and not the "real" sp value. | 2773 // value and not the "real" sp value. |
2718 | 2774 |
2719 Address sp_temp(rdi, Deoptimization::UnrollBlock::sender_sp_temp_offset_in_bytes()); | 2775 Address sp_temp(rdi, Deoptimization::UnrollBlock::sender_sp_temp_offset_in_bytes()); |
2720 __ movl(sp_temp, rsp); | 2776 __ movptr(sp_temp, rsp); |
2721 __ subl(rsp, Address(rdi, Deoptimization::UnrollBlock::caller_adjustment_offset_in_bytes())); | 2777 __ movl(rbx, Address(rdi, Deoptimization::UnrollBlock::caller_adjustment_offset_in_bytes())); |
2778 __ subptr(rsp, rbx); | |
2722 | 2779 |
2723 // Push interpreter frames in a loop | 2780 // Push interpreter frames in a loop |
2724 Label loop; | 2781 Label loop; |
2725 __ bind(loop); | 2782 __ bind(loop); |
2726 __ movl(rbx, Address(rsi, 0)); // Load frame size | 2783 __ movptr(rbx, Address(rsi, 0)); // Load frame size |
2727 #ifdef CC_INTERP | 2784 #ifdef CC_INTERP |
2728 __ subl(rbx, 4*wordSize); // we'll push pc and ebp by hand and | 2785 __ subptr(rbx, 4*wordSize); // we'll push pc and ebp by hand and |
2729 #ifdef ASSERT | 2786 #ifdef ASSERT |
2730 __ pushl(0xDEADDEAD); // Make a recognizable pattern | 2787 __ push(0xDEADDEAD); // Make a recognizable pattern |
2731 __ pushl(0xDEADDEAD); // (parm to RecursiveInterpreter...) | 2788 __ push(0xDEADDEAD); // (parm to RecursiveInterpreter...) |
2732 #else /* ASSERT */ | 2789 #else /* ASSERT */ |
2733 __ subl(rsp, 2*wordSize); // skip the "static long no_param" | 2790 __ subptr(rsp, 2*wordSize); // skip the "static long no_param" |
2734 #endif /* ASSERT */ | 2791 #endif /* ASSERT */ |
2735 #else /* CC_INTERP */ | 2792 #else /* CC_INTERP */ |
2736 __ subl(rbx, 2*wordSize); // we'll push pc and rbp, by hand | 2793 __ subptr(rbx, 2*wordSize); // we'll push pc and rbp, by hand |
2737 #endif /* CC_INTERP */ | 2794 #endif /* CC_INTERP */ |
2738 __ pushl(Address(rcx, 0)); // save return address | 2795 __ pushptr(Address(rcx, 0)); // save return address |
2739 __ enter(); // save old & set new rbp, | 2796 __ enter(); // save old & set new rbp, |
2740 __ subl(rsp, rbx); // Prolog! | 2797 __ subptr(rsp, rbx); // Prolog! |
2741 __ movl(rbx, sp_temp); // sender's sp | 2798 __ movptr(rbx, sp_temp); // sender's sp |
2742 #ifdef CC_INTERP | 2799 #ifdef CC_INTERP |
2743 __ movl(Address(rbp, | 2800 __ movptr(Address(rbp, |
2744 -(sizeof(BytecodeInterpreter)) + in_bytes(byte_offset_of(BytecodeInterpreter, _sender_sp))), | 2801 -(sizeof(BytecodeInterpreter)) + in_bytes(byte_offset_of(BytecodeInterpreter, _sender_sp))), |
2745 rbx); // Make it walkable | 2802 rbx); // Make it walkable |
2746 #else /* CC_INTERP */ | 2803 #else /* CC_INTERP */ |
2747 // This value is corrected by layout_activation_impl | 2804 // This value is corrected by layout_activation_impl |
2748 __ movl(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), NULL_WORD ); | 2805 __ movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), (int32_t)NULL_WORD ); |
2749 __ movl(Address(rbp, frame::interpreter_frame_sender_sp_offset * wordSize), rbx); // Make it walkable | 2806 __ movptr(Address(rbp, frame::interpreter_frame_sender_sp_offset * wordSize), rbx); // Make it walkable |
2750 #endif /* CC_INTERP */ | 2807 #endif /* CC_INTERP */ |
2751 __ movl(sp_temp, rsp); // pass to next frame | 2808 __ movptr(sp_temp, rsp); // pass to next frame |
2752 __ addl(rsi, 4); // Bump array pointer (sizes) | 2809 __ addptr(rsi, wordSize); // Bump array pointer (sizes) |
2753 __ addl(rcx, 4); // Bump array pointer (pcs) | 2810 __ addptr(rcx, wordSize); // Bump array pointer (pcs) |
2754 __ decrement(counter); // decrement counter | 2811 __ decrementl(counter); // decrement counter |
2755 __ jcc(Assembler::notZero, loop); | 2812 __ jcc(Assembler::notZero, loop); |
2756 __ pushl(Address(rcx, 0)); // save final return address | 2813 __ pushptr(Address(rcx, 0)); // save final return address |
2757 | 2814 |
2758 // Re-push self-frame | 2815 // Re-push self-frame |
2759 __ enter(); // save old & set new rbp, | 2816 __ enter(); // save old & set new rbp, |
2760 __ subl(rsp, (framesize-2) * wordSize); // Prolog! | 2817 __ subptr(rsp, (framesize-2) * wordSize); // Prolog! |
2761 | 2818 |
2762 | 2819 |
2763 // set last_Java_sp, last_Java_fp | 2820 // set last_Java_sp, last_Java_fp |
2764 __ get_thread(rdi); | 2821 __ get_thread(rdi); |
2765 __ set_last_Java_frame(rdi, noreg, rbp, NULL); | 2822 __ set_last_Java_frame(rdi, noreg, rbp, NULL); |
2766 | 2823 |
2767 // Call C code. Need thread but NOT official VM entry | 2824 // Call C code. Need thread but NOT official VM entry |
2768 // crud. We cannot block on this call, no GC can happen. Call should | 2825 // crud. We cannot block on this call, no GC can happen. Call should |
2769 // restore return values to their stack-slots with the new SP. | 2826 // restore return values to their stack-slots with the new SP. |
2770 __ movl(Address(rsp,arg0_off*wordSize),rdi); | 2827 __ movptr(Address(rsp,arg0_off*wordSize),rdi); |
2771 __ movl(Address(rsp,arg1_off*wordSize), Deoptimization::Unpack_uncommon_trap); | 2828 __ movl(Address(rsp,arg1_off*wordSize), Deoptimization::Unpack_uncommon_trap); |
2772 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, Deoptimization::unpack_frames))); | 2829 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, Deoptimization::unpack_frames))); |
2773 // Set an oopmap for the call site | 2830 // Set an oopmap for the call site |
2774 oop_maps->add_gc_map( __ pc()-start, new OopMap( framesize, 0 ) ); | 2831 oop_maps->add_gc_map( __ pc()-start, new OopMap( framesize, 0 ) ); |
2775 | 2832 |
2822 // that is safepoint. We can leave this return on the stack and | 2879 // that is safepoint. We can leave this return on the stack and |
2823 // effectively complete the return and safepoint in the caller. | 2880 // effectively complete the return and safepoint in the caller. |
2824 // Otherwise we push space for a return address that the safepoint | 2881 // Otherwise we push space for a return address that the safepoint |
2825 // handler will install later to make the stack walking sensible. | 2882 // handler will install later to make the stack walking sensible. |
2826 if( !cause_return ) | 2883 if( !cause_return ) |
2827 __ pushl(rbx); // Make room for return address (or push it again) | 2884 __ push(rbx); // Make room for return address (or push it again) |
2828 | 2885 |
2829 map = RegisterSaver::save_live_registers(masm, additional_words, &frame_size_in_words, false); | 2886 map = RegisterSaver::save_live_registers(masm, additional_words, &frame_size_in_words, false); |
2830 | 2887 |
2831 // The following is basically a call_VM. However, we need the precise | 2888 // The following is basically a call_VM. However, we need the precise |
2832 // address of the call in order to generate an oopmap. Hence, we do all the | 2889 // address of the call in order to generate an oopmap. Hence, we do all the |
2833 // work ourselves. | 2890 // work ourselves. |
2834 | 2891 |
2835 // Push thread argument and setup last_Java_sp | 2892 // Push thread argument and setup last_Java_sp |
2836 __ get_thread(java_thread); | 2893 __ get_thread(java_thread); |
2837 __ pushl(java_thread); | 2894 __ push(java_thread); |
2838 __ set_last_Java_frame(java_thread, noreg, noreg, NULL); | 2895 __ set_last_Java_frame(java_thread, noreg, noreg, NULL); |
2839 | 2896 |
2840 // if this was not a poll_return then we need to correct the return address now. | 2897 // if this was not a poll_return then we need to correct the return address now. |
2841 if( !cause_return ) { | 2898 if( !cause_return ) { |
2842 __ movl(rax, Address(java_thread, JavaThread::saved_exception_pc_offset())); | 2899 __ movptr(rax, Address(java_thread, JavaThread::saved_exception_pc_offset())); |
2843 __ movl(Address(rbp, wordSize), rax); | 2900 __ movptr(Address(rbp, wordSize), rax); |
2844 } | 2901 } |
2845 | 2902 |
2846 // do the call | 2903 // do the call |
2847 __ call(RuntimeAddress(call_ptr)); | 2904 __ call(RuntimeAddress(call_ptr)); |
2848 | 2905 |
2852 // debug-info recordings, as well as let GC find all oops. | 2909 // debug-info recordings, as well as let GC find all oops. |
2853 | 2910 |
2854 oop_maps->add_gc_map( __ pc() - start, map); | 2911 oop_maps->add_gc_map( __ pc() - start, map); |
2855 | 2912 |
2856 // Discard arg | 2913 // Discard arg |
2857 __ popl(rcx); | 2914 __ pop(rcx); |
2858 | 2915 |
2859 Label noException; | 2916 Label noException; |
2860 | 2917 |
2861 // Clear last_Java_sp again | 2918 // Clear last_Java_sp again |
2862 __ get_thread(java_thread); | 2919 __ get_thread(java_thread); |
2863 __ reset_last_Java_frame(java_thread, false, false); | 2920 __ reset_last_Java_frame(java_thread, false, false); |
2864 | 2921 |
2865 __ cmpl(Address(java_thread, Thread::pending_exception_offset()), NULL_WORD); | 2922 __ cmpptr(Address(java_thread, Thread::pending_exception_offset()), (int32_t)NULL_WORD); |
2866 __ jcc(Assembler::equal, noException); | 2923 __ jcc(Assembler::equal, noException); |
2867 | 2924 |
2868 // Exception pending | 2925 // Exception pending |
2869 | 2926 |
2870 RegisterSaver::restore_live_registers(masm); | 2927 RegisterSaver::restore_live_registers(masm); |
2917 int frame_complete = __ offset(); | 2974 int frame_complete = __ offset(); |
2918 | 2975 |
2919 const Register thread = rdi; | 2976 const Register thread = rdi; |
2920 __ get_thread(rdi); | 2977 __ get_thread(rdi); |
2921 | 2978 |
2922 __ pushl(thread); | 2979 __ push(thread); |
2923 __ set_last_Java_frame(thread, noreg, rbp, NULL); | 2980 __ set_last_Java_frame(thread, noreg, rbp, NULL); |
2924 | 2981 |
2925 __ call(RuntimeAddress(destination)); | 2982 __ call(RuntimeAddress(destination)); |
2926 | 2983 |
2927 | 2984 |
2931 | 2988 |
2932 oop_maps->add_gc_map( __ offset() - start, map); | 2989 oop_maps->add_gc_map( __ offset() - start, map); |
2933 | 2990 |
2934 // rax, contains the address we are going to jump to assuming no exception got installed | 2991 // rax, contains the address we are going to jump to assuming no exception got installed |
2935 | 2992 |
2936 __ addl(rsp, wordSize); | 2993 __ addptr(rsp, wordSize); |
2937 | 2994 |
2938 // clear last_Java_sp | 2995 // clear last_Java_sp |
2939 __ reset_last_Java_frame(thread, true, false); | 2996 __ reset_last_Java_frame(thread, true, false); |
2940 // check for pending exceptions | 2997 // check for pending exceptions |
2941 Label pending; | 2998 Label pending; |
2942 __ cmpl(Address(thread, Thread::pending_exception_offset()), NULL_WORD); | 2999 __ cmpptr(Address(thread, Thread::pending_exception_offset()), (int32_t)NULL_WORD); |
2943 __ jcc(Assembler::notEqual, pending); | 3000 __ jcc(Assembler::notEqual, pending); |
2944 | 3001 |
2945 // get the returned methodOop | 3002 // get the returned methodOop |
2946 __ movl(rbx, Address(thread, JavaThread::vm_result_offset())); | 3003 __ movptr(rbx, Address(thread, JavaThread::vm_result_offset())); |
2947 __ movl(Address(rsp, RegisterSaver::rbx_offset() * wordSize), rbx); | 3004 __ movptr(Address(rsp, RegisterSaver::rbx_offset() * wordSize), rbx); |
2948 | 3005 |
2949 __ movl(Address(rsp, RegisterSaver::rax_offset() * wordSize), rax); | 3006 __ movptr(Address(rsp, RegisterSaver::rax_offset() * wordSize), rax); |
2950 | 3007 |
2951 RegisterSaver::restore_live_registers(masm); | 3008 RegisterSaver::restore_live_registers(masm); |
2952 | 3009 |
2953 // We are back the the original state on entry and ready to go. | 3010 // We are back the the original state on entry and ready to go. |
2954 | 3011 |
2961 RegisterSaver::restore_live_registers(masm); | 3018 RegisterSaver::restore_live_registers(masm); |
2962 | 3019 |
2963 // exception pending => remove activation and forward to exception handler | 3020 // exception pending => remove activation and forward to exception handler |
2964 | 3021 |
2965 __ get_thread(thread); | 3022 __ get_thread(thread); |
2966 __ movl(Address(thread, JavaThread::vm_result_offset()), NULL_WORD); | 3023 __ movptr(Address(thread, JavaThread::vm_result_offset()), (int32_t)NULL_WORD); |
2967 __ movl(rax, Address(thread, Thread::pending_exception_offset())); | 3024 __ movptr(rax, Address(thread, Thread::pending_exception_offset())); |
2968 __ jump(RuntimeAddress(StubRoutines::forward_exception_entry())); | 3025 __ jump(RuntimeAddress(StubRoutines::forward_exception_entry())); |
2969 | 3026 |
2970 // ------------- | 3027 // ------------- |
2971 // make sure all code is generated | 3028 // make sure all code is generated |
2972 masm->flush(); | 3029 masm->flush(); |