749
750 void MacroAssembler::reset_last_Java_frame(bool clear_fp,
751 bool clear_pc) {
752 // we must set sp to zero to clear frame
753 movptr(Address(r15_thread, JavaThread::last_Java_sp_offset()), NULL_WORD);
754 // must clear fp, so that compiled frames are not confused; it is
755 // possible that we need it only for debugging
756 if (clear_fp) {
757 movptr(Address(r15_thread, JavaThread::last_Java_fp_offset()), NULL_WORD);
758 }
759
760 if (clear_pc) {
761 movptr(Address(r15_thread, JavaThread::last_Java_pc_offset()), NULL_WORD);
762 }
763 }
764
765 void MacroAssembler::set_last_Java_frame(Register last_java_sp,
766 Register last_java_fp,
767 address last_java_pc) {
768 // determine last_java_sp register
769 if (!last_java_sp->is_valid()) {
770 last_java_sp = rsp;
771 }
772
773 // last_java_fp is optional
774 if (last_java_fp->is_valid()) {
775 movptr(Address(r15_thread, JavaThread::last_Java_fp_offset()),
776 last_java_fp);
777 }
778
779 // last_java_pc is optional
780 if (last_java_pc != NULL) {
781 Address java_pc(r15_thread,
782 JavaThread::frame_anchor_offset() + JavaFrameAnchor::last_Java_pc_offset());
783 lea(rscratch1, InternalAddress(last_java_pc));
784 movptr(java_pc, rscratch1);
785 }
786
787 movptr(Address(r15_thread, JavaThread::last_Java_sp_offset()), last_java_sp);
788 }
789
790 static void pass_arg0(MacroAssembler* masm, Register arg) {
791 if (c_rarg0 != arg ) {
792 masm->mov(c_rarg0, arg);
793 }
794 }
2483 Register arg_1,
2484 Register arg_2,
2485 Register arg_3,
2486 bool check_exceptions) {
2487 LP64_ONLY(assert(arg_1 != c_rarg3, "smashed arg"));
2488 LP64_ONLY(assert(arg_2 != c_rarg3, "smashed arg"));
2489 pass_arg3(this, arg_3);
2490 LP64_ONLY(assert(arg_1 != c_rarg2, "smashed arg"));
2491 pass_arg2(this, arg_2);
2492 pass_arg1(this, arg_1);
2493 super_call_VM(oop_result, last_java_sp, entry_point, 3, check_exceptions);
2494 }
2495
2496 void MacroAssembler::call_VM_base(Register oop_result,
2497 Register java_thread,
2498 Register last_java_sp,
2499 address entry_point,
2500 int number_of_arguments,
2501 bool check_exceptions) {
2502 // determine java_thread register
2503 if (!java_thread->is_valid()) {
2504 #ifdef _LP64
2505 java_thread = r15_thread;
2506 #else
2507 java_thread = rdi;
2508 get_thread(java_thread);
2509 #endif // LP64
2510 }
2511 // determine last_java_sp register
2512 if (!last_java_sp->is_valid()) {
2513 last_java_sp = rsp;
2514 }
2515 // debugging support
2516 assert(number_of_arguments >= 0 , "cannot have negative number of arguments");
2517 LP64_ONLY(assert(java_thread == r15_thread, "unexpected register"));
2518 #ifdef ASSERT
2519 // TraceBytecodes does not use r12 but saves it over the call, so don't verify
2520 // r12 is the heapbase.
2521 LP64_ONLY(if ((UseCompressedOops || UseCompressedClassPointers) && !TraceBytecodes) verify_heapbase("call_VM_base: heap base corrupted?");)
2522 #endif // ASSERT
2523
2524 assert(java_thread != oop_result , "cannot use the same register for java_thread & oop_result");
2525 assert(java_thread != last_java_sp, "cannot use the same register for java_thread & last_java_sp");
2526
2527 // push java thread (becomes first argument of C function)
2528
2529 NOT_LP64(push(java_thread); number_of_arguments++);
2530 LP64_ONLY(mov(c_rarg0, r15_thread));
2531
2532 // set last Java frame before call
2570
2571 if (check_exceptions) {
2572 // check for pending exceptions (java_thread is set upon return)
2573 cmpptr(Address(java_thread, Thread::pending_exception_offset()), (int32_t) NULL_WORD);
2574 #ifndef _LP64
2575 jump_cc(Assembler::notEqual,
2576 RuntimeAddress(StubRoutines::forward_exception_entry()));
2577 #else
2578 // This used to conditionally jump to forward_exception however it is
2579 // possible if we relocate that the branch will not reach. So we must jump
2580 // around so we can always reach
2581
2582 Label ok;
2583 jcc(Assembler::equal, ok);
2584 jump(RuntimeAddress(StubRoutines::forward_exception_entry()));
2585 bind(ok);
2586 #endif // LP64
2587 }
2588
2589 // get oop result if there is one and reset the value in the thread
2590 if (oop_result->is_valid()) {
2591 get_vm_result(oop_result, java_thread);
2592 }
2593 }
2594
2595 void MacroAssembler::call_VM_helper(Register oop_result, address entry_point, int number_of_arguments, bool check_exceptions) {
2596
2597 // Calculate the value for last_Java_sp
2598 // somewhat subtle. call_VM does an intermediate call
2599 // which places a return address on the stack just under the
2600 // stack pointer as the user finsihed with it. This allows
2601 // use to retrieve last_Java_pc from last_Java_sp[-1].
2602 // On 32bit we then have to push additional args on the stack to accomplish
2603 // the actual requested call. On 64bit call_VM only can use register args
2604 // so the only extra space is the return address that call_VM created.
2605 // This hopefully explains the calculations here.
2606
2607 #ifdef _LP64
2608 // We've pushed one address, correct last_Java_sp
2609 lea(rax, Address(rsp, wordSize));
2610 #else
3773 void MacroAssembler::push_FPU_state() {
3774 subptr(rsp, FPUStateSizeInWords * wordSize);
3775 #ifndef _LP64
3776 fnsave(Address(rsp, 0));
3777 fwait();
3778 #else
3779 fxsave(Address(rsp, 0));
3780 #endif // LP64
3781 }
3782
3783 void MacroAssembler::push_IU_state() {
3784 // Push flags first because pusha kills them
3785 pushf();
3786 // Make sure rsp stays 16-byte aligned
3787 LP64_ONLY(subq(rsp, 8));
3788 pusha();
3789 }
3790
3791 void MacroAssembler::reset_last_Java_frame(Register java_thread, bool clear_fp, bool clear_pc) {
3792 // determine java_thread register
3793 if (!java_thread->is_valid()) {
3794 java_thread = rdi;
3795 get_thread(java_thread);
3796 }
3797 // we must set sp to zero to clear frame
3798 movptr(Address(java_thread, JavaThread::last_Java_sp_offset()), NULL_WORD);
3799 if (clear_fp) {
3800 movptr(Address(java_thread, JavaThread::last_Java_fp_offset()), NULL_WORD);
3801 }
3802
3803 if (clear_pc)
3804 movptr(Address(java_thread, JavaThread::last_Java_pc_offset()), NULL_WORD);
3805
3806 }
3807
3808 void MacroAssembler::restore_rax(Register tmp) {
3809 if (tmp == noreg) pop(rax);
3810 else if (tmp != rax) mov(rax, tmp);
3811 }
3812
3813 void MacroAssembler::round_to(Register reg, int modulus) {
3829 shrl(tmp, os::get_serialize_page_shift_count());
3830 andl(tmp, (os::vm_page_size() - sizeof(int)));
3831
3832 Address index(noreg, tmp, Address::times_1);
3833 ExternalAddress page(os::get_memory_serialize_page());
3834
3835 // Size of store must match masking code above
3836 movl(as_Address(ArrayAddress(page, index)), tmp);
3837 }
3838
3839 // Calls to C land
3840 //
3841 // When entering C land, the rbp, & rsp of the last Java frame have to be recorded
3842 // in the (thread-local) JavaThread object. When leaving C land, the last Java fp
3843 // has to be reset to 0. This is required to allow proper stack traversal.
3844 void MacroAssembler::set_last_Java_frame(Register java_thread,
3845 Register last_java_sp,
3846 Register last_java_fp,
3847 address last_java_pc) {
3848 // determine java_thread register
3849 if (!java_thread->is_valid()) {
3850 java_thread = rdi;
3851 get_thread(java_thread);
3852 }
3853 // determine last_java_sp register
3854 if (!last_java_sp->is_valid()) {
3855 last_java_sp = rsp;
3856 }
3857
3858 // last_java_fp is optional
3859
3860 if (last_java_fp->is_valid()) {
3861 movptr(Address(java_thread, JavaThread::last_Java_fp_offset()), last_java_fp);
3862 }
3863
3864 // last_java_pc is optional
3865
3866 if (last_java_pc != NULL) {
3867 lea(Address(java_thread,
3868 JavaThread::frame_anchor_offset() + JavaFrameAnchor::last_Java_pc_offset()),
3869 InternalAddress(last_java_pc));
3870
3871 }
3872 movptr(Address(java_thread, JavaThread::last_Java_sp_offset()), last_java_sp);
3873 }
3874
3875 void MacroAssembler::shlptr(Register dst, int imm8) {
3876 LP64_ONLY(shlq(dst, imm8)) NOT_LP64(shll(dst, imm8));
3877 }
3878
3879 void MacroAssembler::shrptr(Register dst, int imm8) {
3880 LP64_ONLY(shrq(dst, imm8)) NOT_LP64(shrl(dst, imm8));
3881 }
3882
3883 void MacroAssembler::sign_extend_byte(Register reg) {
3884 if (LP64_ONLY(true ||) (VM_Version::is_P6() && reg->has_byte_register())) {
3885 movsbl(reg, reg); // movsxb
3886 } else {
3887 shll(reg, 24);
3888 sarl(reg, 24);
3889 }
3890 }
3891
3892 void MacroAssembler::sign_extend_short(Register reg) {
3893 if (LP64_ONLY(true ||) VM_Version::is_P6()) {
3894 movswl(reg, reg); // movsxw
3895 } else {
3896 shll(reg, 16);
3897 sarl(reg, 16);
3898 }
3899 }
3900
3901 void MacroAssembler::testl(Register dst, AddressLiteral src) {
3902 assert(reachable(src), "Address should be reachable");
3903 testl(dst, as_Address(src));
3904 }
4517
4518 bind(ok);
4519 pop(tsize);
4520 }
4521 #endif
4522 movptr(Address(thread_reg, in_bytes(JavaThread::tlab_start_offset())), top);
4523 movptr(Address(thread_reg, in_bytes(JavaThread::tlab_top_offset())), top);
4524 addptr(top, t1);
4525 subptr(top, (int32_t)ThreadLocalAllocBuffer::alignment_reserve_in_bytes());
4526 movptr(Address(thread_reg, in_bytes(JavaThread::tlab_end_offset())), top);
4527 verify_tlab();
4528 jmp(retry);
4529
4530 return thread_reg; // for use by caller
4531 }
4532
4533 void MacroAssembler::incr_allocated_bytes(Register thread,
4534 Register var_size_in_bytes,
4535 int con_size_in_bytes,
4536 Register t1) {
4537 if (!thread->is_valid()) {
4538 #ifdef _LP64
4539 thread = r15_thread;
4540 #else
4541 assert(t1->is_valid(), "need temp reg");
4542 thread = t1;
4543 get_thread(thread);
4544 #endif
4545 }
4546
4547 #ifdef _LP64
4548 if (var_size_in_bytes->is_valid()) {
4549 addq(Address(thread, in_bytes(JavaThread::allocated_bytes_offset())), var_size_in_bytes);
4550 } else {
4551 addq(Address(thread, in_bytes(JavaThread::allocated_bytes_offset())), con_size_in_bytes);
4552 }
4553 #else
4554 if (var_size_in_bytes->is_valid()) {
4555 addl(Address(thread, in_bytes(JavaThread::allocated_bytes_offset())), var_size_in_bytes);
4556 } else {
4557 addl(Address(thread, in_bytes(JavaThread::allocated_bytes_offset())), con_size_in_bytes);
4558 }
4559 adcl(Address(thread, in_bytes(JavaThread::allocated_bytes_offset())+4), 0);
4560 #endif
4561 }
4562
4563 void MacroAssembler::fp_runtime_fallback(address runtime_entry, int nb_args, int num_fpu_regs_in_use) {
4564 pusha();
4565
4566 // if we are coming from c1, xmm registers may be live
4567 int off = 0;
4568 if (UseSSE == 1) {
4569 subptr(rsp, sizeof(jdouble)*8);
4570 movflt(Address(rsp,off++*sizeof(jdouble)),xmm0);
4571 movflt(Address(rsp,off++*sizeof(jdouble)),xmm1);
4572 movflt(Address(rsp,off++*sizeof(jdouble)),xmm2);
4573 movflt(Address(rsp,off++*sizeof(jdouble)),xmm3);
4574 movflt(Address(rsp,off++*sizeof(jdouble)),xmm4);
5133
5134 void MacroAssembler::cmov32(Condition cc, Register dst, Register src) {
5135 if (VM_Version::supports_cmov()) {
5136 cmovl(cc, dst, src);
5137 } else {
5138 Label L;
5139 jccb(negate_condition(cc), L);
5140 movl(dst, src);
5141 bind(L);
5142 }
5143 }
5144
5145 void MacroAssembler::verify_oop(Register reg, const char* s) {
5146 if (!VerifyOops) return;
5147
5148 // Pass register number to verify_oop_subroutine
5149 const char* b = NULL;
5150 {
5151 ResourceMark rm;
5152 stringStream ss;
5153 ss.print("verify_oop: %s: %s", reg->name(), s);
5154 b = code_string(ss.as_string());
5155 }
5156 BLOCK_COMMENT("verify_oop {");
5157 #ifdef _LP64
5158 push(rscratch1); // save r10, trashed by movptr()
5159 #endif
5160 push(rax); // save rax,
5161 push(reg); // pass register argument
5162 ExternalAddress buffer((address) b);
5163 // avoid using pushptr, as it modifies scratch registers
5164 // and our contract is not to modify anything
5165 movptr(rax, buffer.addr());
5166 push(rax);
5167 // call indirectly to solve generation ordering problem
5168 movptr(rax, ExternalAddress(StubRoutines::verify_oop_subroutine_entry_address()));
5169 call(rax);
5170 // Caller pops the arguments (oop, message) and restores rax, r10
5171 BLOCK_COMMENT("} verify_oop");
5172 }
5173
|
749
750 void MacroAssembler::reset_last_Java_frame(bool clear_fp,
751 bool clear_pc) {
752 // we must set sp to zero to clear frame
753 movptr(Address(r15_thread, JavaThread::last_Java_sp_offset()), NULL_WORD);
754 // must clear fp, so that compiled frames are not confused; it is
755 // possible that we need it only for debugging
756 if (clear_fp) {
757 movptr(Address(r15_thread, JavaThread::last_Java_fp_offset()), NULL_WORD);
758 }
759
760 if (clear_pc) {
761 movptr(Address(r15_thread, JavaThread::last_Java_pc_offset()), NULL_WORD);
762 }
763 }
764
765 void MacroAssembler::set_last_Java_frame(Register last_java_sp,
766 Register last_java_fp,
767 address last_java_pc) {
768 // determine last_java_sp register
769 if (!last_java_sp.is_valid()) {
770 last_java_sp = rsp;
771 }
772
773 // last_java_fp is optional
774 if (last_java_fp.is_valid()) {
775 movptr(Address(r15_thread, JavaThread::last_Java_fp_offset()),
776 last_java_fp);
777 }
778
779 // last_java_pc is optional
780 if (last_java_pc != NULL) {
781 Address java_pc(r15_thread,
782 JavaThread::frame_anchor_offset() + JavaFrameAnchor::last_Java_pc_offset());
783 lea(rscratch1, InternalAddress(last_java_pc));
784 movptr(java_pc, rscratch1);
785 }
786
787 movptr(Address(r15_thread, JavaThread::last_Java_sp_offset()), last_java_sp);
788 }
789
790 static void pass_arg0(MacroAssembler* masm, Register arg) {
791 if (c_rarg0 != arg ) {
792 masm->mov(c_rarg0, arg);
793 }
794 }
2483 Register arg_1,
2484 Register arg_2,
2485 Register arg_3,
2486 bool check_exceptions) {
2487 LP64_ONLY(assert(arg_1 != c_rarg3, "smashed arg"));
2488 LP64_ONLY(assert(arg_2 != c_rarg3, "smashed arg"));
2489 pass_arg3(this, arg_3);
2490 LP64_ONLY(assert(arg_1 != c_rarg2, "smashed arg"));
2491 pass_arg2(this, arg_2);
2492 pass_arg1(this, arg_1);
2493 super_call_VM(oop_result, last_java_sp, entry_point, 3, check_exceptions);
2494 }
2495
2496 void MacroAssembler::call_VM_base(Register oop_result,
2497 Register java_thread,
2498 Register last_java_sp,
2499 address entry_point,
2500 int number_of_arguments,
2501 bool check_exceptions) {
2502 // determine java_thread register
2503 if (!java_thread.is_valid()) {
2504 #ifdef _LP64
2505 java_thread = r15_thread;
2506 #else
2507 java_thread = rdi;
2508 get_thread(java_thread);
2509 #endif // LP64
2510 }
2511 // determine last_java_sp register
2512 if (!last_java_sp.is_valid()) {
2513 last_java_sp = rsp;
2514 }
2515 // debugging support
2516 assert(number_of_arguments >= 0 , "cannot have negative number of arguments");
2517 LP64_ONLY(assert(java_thread == r15_thread, "unexpected register"));
2518 #ifdef ASSERT
2519 // TraceBytecodes does not use r12 but saves it over the call, so don't verify
2520 // r12 is the heapbase.
2521 LP64_ONLY(if ((UseCompressedOops || UseCompressedClassPointers) && !TraceBytecodes) verify_heapbase("call_VM_base: heap base corrupted?");)
2522 #endif // ASSERT
2523
2524 assert(java_thread != oop_result , "cannot use the same register for java_thread & oop_result");
2525 assert(java_thread != last_java_sp, "cannot use the same register for java_thread & last_java_sp");
2526
2527 // push java thread (becomes first argument of C function)
2528
2529 NOT_LP64(push(java_thread); number_of_arguments++);
2530 LP64_ONLY(mov(c_rarg0, r15_thread));
2531
2532 // set last Java frame before call
2570
2571 if (check_exceptions) {
2572 // check for pending exceptions (java_thread is set upon return)
2573 cmpptr(Address(java_thread, Thread::pending_exception_offset()), (int32_t) NULL_WORD);
2574 #ifndef _LP64
2575 jump_cc(Assembler::notEqual,
2576 RuntimeAddress(StubRoutines::forward_exception_entry()));
2577 #else
2578 // This used to conditionally jump to forward_exception however it is
2579 // possible if we relocate that the branch will not reach. So we must jump
2580 // around so we can always reach
2581
2582 Label ok;
2583 jcc(Assembler::equal, ok);
2584 jump(RuntimeAddress(StubRoutines::forward_exception_entry()));
2585 bind(ok);
2586 #endif // LP64
2587 }
2588
2589 // get oop result if there is one and reset the value in the thread
2590 if (oop_result.is_valid()) {
2591 get_vm_result(oop_result, java_thread);
2592 }
2593 }
2594
2595 void MacroAssembler::call_VM_helper(Register oop_result, address entry_point, int number_of_arguments, bool check_exceptions) {
2596
2597 // Calculate the value for last_Java_sp
2598 // somewhat subtle. call_VM does an intermediate call
2599 // which places a return address on the stack just under the
2600 // stack pointer as the user finsihed with it. This allows
2601 // use to retrieve last_Java_pc from last_Java_sp[-1].
2602 // On 32bit we then have to push additional args on the stack to accomplish
2603 // the actual requested call. On 64bit call_VM only can use register args
2604 // so the only extra space is the return address that call_VM created.
2605 // This hopefully explains the calculations here.
2606
2607 #ifdef _LP64
2608 // We've pushed one address, correct last_Java_sp
2609 lea(rax, Address(rsp, wordSize));
2610 #else
3773 void MacroAssembler::push_FPU_state() {
3774 subptr(rsp, FPUStateSizeInWords * wordSize);
3775 #ifndef _LP64
3776 fnsave(Address(rsp, 0));
3777 fwait();
3778 #else
3779 fxsave(Address(rsp, 0));
3780 #endif // LP64
3781 }
3782
3783 void MacroAssembler::push_IU_state() {
3784 // Push flags first because pusha kills them
3785 pushf();
3786 // Make sure rsp stays 16-byte aligned
3787 LP64_ONLY(subq(rsp, 8));
3788 pusha();
3789 }
3790
3791 void MacroAssembler::reset_last_Java_frame(Register java_thread, bool clear_fp, bool clear_pc) {
3792 // determine java_thread register
3793 if (!java_thread.is_valid()) {
3794 java_thread = rdi;
3795 get_thread(java_thread);
3796 }
3797 // we must set sp to zero to clear frame
3798 movptr(Address(java_thread, JavaThread::last_Java_sp_offset()), NULL_WORD);
3799 if (clear_fp) {
3800 movptr(Address(java_thread, JavaThread::last_Java_fp_offset()), NULL_WORD);
3801 }
3802
3803 if (clear_pc)
3804 movptr(Address(java_thread, JavaThread::last_Java_pc_offset()), NULL_WORD);
3805
3806 }
3807
3808 void MacroAssembler::restore_rax(Register tmp) {
3809 if (tmp == noreg) pop(rax);
3810 else if (tmp != rax) mov(rax, tmp);
3811 }
3812
3813 void MacroAssembler::round_to(Register reg, int modulus) {
3829 shrl(tmp, os::get_serialize_page_shift_count());
3830 andl(tmp, (os::vm_page_size() - sizeof(int)));
3831
3832 Address index(noreg, tmp, Address::times_1);
3833 ExternalAddress page(os::get_memory_serialize_page());
3834
3835 // Size of store must match masking code above
3836 movl(as_Address(ArrayAddress(page, index)), tmp);
3837 }
3838
3839 // Calls to C land
3840 //
3841 // When entering C land, the rbp, & rsp of the last Java frame have to be recorded
3842 // in the (thread-local) JavaThread object. When leaving C land, the last Java fp
3843 // has to be reset to 0. This is required to allow proper stack traversal.
3844 void MacroAssembler::set_last_Java_frame(Register java_thread,
3845 Register last_java_sp,
3846 Register last_java_fp,
3847 address last_java_pc) {
3848 // determine java_thread register
3849 if (!java_thread.is_valid()) {
3850 java_thread = rdi;
3851 get_thread(java_thread);
3852 }
3853 // determine last_java_sp register
3854 if (!last_java_sp.is_valid()) {
3855 last_java_sp = rsp;
3856 }
3857
3858 // last_java_fp is optional
3859
3860 if (last_java_fp.is_valid()) {
3861 movptr(Address(java_thread, JavaThread::last_Java_fp_offset()), last_java_fp);
3862 }
3863
3864 // last_java_pc is optional
3865
3866 if (last_java_pc != NULL) {
3867 lea(Address(java_thread,
3868 JavaThread::frame_anchor_offset() + JavaFrameAnchor::last_Java_pc_offset()),
3869 InternalAddress(last_java_pc));
3870
3871 }
3872 movptr(Address(java_thread, JavaThread::last_Java_sp_offset()), last_java_sp);
3873 }
3874
3875 void MacroAssembler::shlptr(Register dst, int imm8) {
3876 LP64_ONLY(shlq(dst, imm8)) NOT_LP64(shll(dst, imm8));
3877 }
3878
3879 void MacroAssembler::shrptr(Register dst, int imm8) {
3880 LP64_ONLY(shrq(dst, imm8)) NOT_LP64(shrl(dst, imm8));
3881 }
3882
3883 void MacroAssembler::sign_extend_byte(Register reg) {
3884 if (LP64_ONLY(true ||) (VM_Version::is_P6() && reg.has_byte_register())) {
3885 movsbl(reg, reg); // movsxb
3886 } else {
3887 shll(reg, 24);
3888 sarl(reg, 24);
3889 }
3890 }
3891
3892 void MacroAssembler::sign_extend_short(Register reg) {
3893 if (LP64_ONLY(true ||) VM_Version::is_P6()) {
3894 movswl(reg, reg); // movsxw
3895 } else {
3896 shll(reg, 16);
3897 sarl(reg, 16);
3898 }
3899 }
3900
3901 void MacroAssembler::testl(Register dst, AddressLiteral src) {
3902 assert(reachable(src), "Address should be reachable");
3903 testl(dst, as_Address(src));
3904 }
4517
4518 bind(ok);
4519 pop(tsize);
4520 }
4521 #endif
4522 movptr(Address(thread_reg, in_bytes(JavaThread::tlab_start_offset())), top);
4523 movptr(Address(thread_reg, in_bytes(JavaThread::tlab_top_offset())), top);
4524 addptr(top, t1);
4525 subptr(top, (int32_t)ThreadLocalAllocBuffer::alignment_reserve_in_bytes());
4526 movptr(Address(thread_reg, in_bytes(JavaThread::tlab_end_offset())), top);
4527 verify_tlab();
4528 jmp(retry);
4529
4530 return thread_reg; // for use by caller
4531 }
4532
4533 void MacroAssembler::incr_allocated_bytes(Register thread,
4534 Register var_size_in_bytes,
4535 int con_size_in_bytes,
4536 Register t1) {
4537 if (!thread.is_valid()) {
4538 #ifdef _LP64
4539 thread = r15_thread;
4540 #else
4541 assert(t1.is_valid(), "need temp reg");
4542 thread = t1;
4543 get_thread(thread);
4544 #endif
4545 }
4546
4547 #ifdef _LP64
4548 if (var_size_in_bytes.is_valid()) {
4549 addq(Address(thread, in_bytes(JavaThread::allocated_bytes_offset())), var_size_in_bytes);
4550 } else {
4551 addq(Address(thread, in_bytes(JavaThread::allocated_bytes_offset())), con_size_in_bytes);
4552 }
4553 #else
4554 if (var_size_in_bytes.is_valid()) {
4555 addl(Address(thread, in_bytes(JavaThread::allocated_bytes_offset())), var_size_in_bytes);
4556 } else {
4557 addl(Address(thread, in_bytes(JavaThread::allocated_bytes_offset())), con_size_in_bytes);
4558 }
4559 adcl(Address(thread, in_bytes(JavaThread::allocated_bytes_offset())+4), 0);
4560 #endif
4561 }
4562
4563 void MacroAssembler::fp_runtime_fallback(address runtime_entry, int nb_args, int num_fpu_regs_in_use) {
4564 pusha();
4565
4566 // if we are coming from c1, xmm registers may be live
4567 int off = 0;
4568 if (UseSSE == 1) {
4569 subptr(rsp, sizeof(jdouble)*8);
4570 movflt(Address(rsp,off++*sizeof(jdouble)),xmm0);
4571 movflt(Address(rsp,off++*sizeof(jdouble)),xmm1);
4572 movflt(Address(rsp,off++*sizeof(jdouble)),xmm2);
4573 movflt(Address(rsp,off++*sizeof(jdouble)),xmm3);
4574 movflt(Address(rsp,off++*sizeof(jdouble)),xmm4);
5133
5134 void MacroAssembler::cmov32(Condition cc, Register dst, Register src) {
5135 if (VM_Version::supports_cmov()) {
5136 cmovl(cc, dst, src);
5137 } else {
5138 Label L;
5139 jccb(negate_condition(cc), L);
5140 movl(dst, src);
5141 bind(L);
5142 }
5143 }
5144
5145 void MacroAssembler::verify_oop(Register reg, const char* s) {
5146 if (!VerifyOops) return;
5147
5148 // Pass register number to verify_oop_subroutine
5149 const char* b = NULL;
5150 {
5151 ResourceMark rm;
5152 stringStream ss;
5153 ss.print("verify_oop: %s: %s", reg.name(), s);
5154 b = code_string(ss.as_string());
5155 }
5156 BLOCK_COMMENT("verify_oop {");
5157 #ifdef _LP64
5158 push(rscratch1); // save r10, trashed by movptr()
5159 #endif
5160 push(rax); // save rax,
5161 push(reg); // pass register argument
5162 ExternalAddress buffer((address) b);
5163 // avoid using pushptr, as it modifies scratch registers
5164 // and our contract is not to modify anything
5165 movptr(rax, buffer.addr());
5166 push(rax);
5167 // call indirectly to solve generation ordering problem
5168 movptr(rax, ExternalAddress(StubRoutines::verify_oop_subroutine_entry_address()));
5169 call(rax);
5170 // Caller pops the arguments (oop, message) and restores rax, r10
5171 BLOCK_COMMENT("} verify_oop");
5172 }
5173
|