1993 // because it can be patched on the fly by make_non_entrant. The stack bang
1994 // instruction fits that requirement.
1995
1996 // Generate stack overflow check
1997
1998 if (UseStackBanging) {
1999 __ bang_stack_with_offset(StackShadowPages*os::vm_page_size());
2000 } else {
2001 // need a 5 byte instruction to allow MT safe patching to non-entrant
2002 __ fat_nop();
2003 }
2004
2005 // Generate a new frame for the wrapper.
2006 __ enter();
2007 // -2 because return address is already present and so is saved rbp
2008 __ subptr(rsp, stack_size - 2*wordSize);
2009
2010 // Frame is now completed as far as size and linkage.
2011 int frame_complete = ((intptr_t)__ pc()) - start;
2012
2013 #ifdef ASSERT
2014 {
2015 Label L;
2016 __ mov(rax, rsp);
2017 __ andptr(rax, -16); // must be 16 byte boundary (see amd64 ABI)
2018 __ cmpptr(rax, rsp);
2019 __ jcc(Assembler::equal, L);
2020 __ stop("improperly aligned stack");
2021 __ bind(L);
2022 }
2023 #endif /* ASSERT */
2024
2025
2026 // We use r14 as the oop handle for the receiver/klass
2027 // It is callee save so it survives the call to native
2028
2029 const Register oop_handle_reg = r14;
2030
2031 if (is_critical_native) {
2032 check_needs_gc_for_critical_native(masm, stack_slots, total_c_args, total_in_args,
3593 // Make sure all code is generated
3594 masm->flush();
3595
3596 _deopt_blob = DeoptimizationBlob::create(&buffer, oop_maps, 0, exception_offset, reexecute_offset, frame_size_in_words);
3597 _deopt_blob->set_unpack_with_exception_in_tls_offset(exception_in_tls_offset);
3598 }
3599
3600 #ifdef COMPILER2
3601 //------------------------------generate_uncommon_trap_blob--------------------
3602 void SharedRuntime::generate_uncommon_trap_blob() {
3603 // Allocate space for the code
3604 ResourceMark rm;
3605 // Setup code generation tools
3606 CodeBuffer buffer("uncommon_trap_blob", 2048, 1024);
3607 MacroAssembler* masm = new MacroAssembler(&buffer);
3608
3609 assert(SimpleRuntimeFrame::framesize % 4 == 0, "sp not 16-byte aligned");
3610
3611 address start = __ pc();
3612
3613 // Push self-frame. We get here with a return address on the
3614 // stack, so rsp is 8-byte aligned until we allocate our frame.
3615 __ subptr(rsp, SimpleRuntimeFrame::return_off << LogBytesPerInt); // Epilog!
3616
3617 // No callee saved registers. rbp is assumed implicitly saved
3618 __ movptr(Address(rsp, SimpleRuntimeFrame::rbp_off << LogBytesPerInt), rbp);
3619
3620 // compiler left unloaded_class_index in j_rarg0 move to where the
3621 // runtime expects it.
3622 __ movl(c_rarg1, j_rarg0);
3623
3624 __ set_last_Java_frame(noreg, noreg, NULL);
3625
3626 // Call C code. Need thread but NOT official VM entry
3627 // crud. We cannot block on this call, no GC can happen. Call should
3628 // capture callee-saved registers as well as return values.
3629 // Thread is in rdi already.
3630 //
3631 // UnrollBlock* uncommon_trap(JavaThread* thread, jint unloaded_class_index);
3632
3773 // and setup oopmap.
3774 //
3775 SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, int poll_type) {
3776 assert(StubRoutines::forward_exception_entry() != NULL,
3777 "must be generated before");
3778
3779 ResourceMark rm;
3780 OopMapSet *oop_maps = new OopMapSet();
3781 OopMap* map;
3782
3783 // Allocate space for the code. Setup code generation tools.
3784 CodeBuffer buffer("handler_blob", 2048, 1024);
3785 MacroAssembler* masm = new MacroAssembler(&buffer);
3786
3787 address start = __ pc();
3788 address call_pc = NULL;
3789 int frame_size_in_words;
3790 bool cause_return = (poll_type == POLL_AT_RETURN);
3791 bool save_vectors = (poll_type == POLL_AT_VECTOR_LOOP);
3792
3793 // Make room for return address (or push it again)
3794 if (!cause_return) {
3795 __ push(rbx);
3796 }
3797
3798 // Save registers, fpu state, and flags
3799 map = RegisterSaver::save_live_registers(masm, 0, &frame_size_in_words, save_vectors);
3800
3801 // The following is basically a call_VM. However, we need the precise
3802 // address of the call in order to generate an oopmap. Hence, we do all the
3803 // work outselves.
3804
3805 __ set_last_Java_frame(noreg, noreg, NULL);
3806
3807 // The return address must always be correct so that frame constructor never
3808 // sees an invalid pc.
3809
3810 if (!cause_return) {
3811 // overwrite the dummy value we pushed on entry
3812 __ movptr(c_rarg0, Address(r15_thread, JavaThread::saved_exception_pc_offset()));
|
1993 // because it can be patched on the fly by make_non_entrant. The stack bang
1994 // instruction fits that requirement.
1995
1996 // Generate stack overflow check
1997
1998 if (UseStackBanging) {
1999 __ bang_stack_with_offset(StackShadowPages*os::vm_page_size());
2000 } else {
2001 // need a 5 byte instruction to allow MT safe patching to non-entrant
2002 __ fat_nop();
2003 }
2004
2005 // Generate a new frame for the wrapper.
2006 __ enter();
2007 // -2 because return address is already present and so is saved rbp
2008 __ subptr(rsp, stack_size - 2*wordSize);
2009
2010 // Frame is now completed as far as size and linkage.
2011 int frame_complete = ((intptr_t)__ pc()) - start;
2012
2013 if (UseRTMLocking) {
2014 // Abort RTM transaction before calling JNI
2015 // because critical section will be large and will be
2016 // aborted anyway. Also nmethod could be deoptimized.
2017 __ xabort(0);
2018 }
2019
2020 #ifdef ASSERT
2021 {
2022 Label L;
2023 __ mov(rax, rsp);
2024 __ andptr(rax, -16); // must be 16 byte boundary (see amd64 ABI)
2025 __ cmpptr(rax, rsp);
2026 __ jcc(Assembler::equal, L);
2027 __ stop("improperly aligned stack");
2028 __ bind(L);
2029 }
2030 #endif /* ASSERT */
2031
2032
2033 // We use r14 as the oop handle for the receiver/klass
2034 // It is callee save so it survives the call to native
2035
2036 const Register oop_handle_reg = r14;
2037
2038 if (is_critical_native) {
2039 check_needs_gc_for_critical_native(masm, stack_slots, total_c_args, total_in_args,
3600 // Make sure all code is generated
3601 masm->flush();
3602
3603 _deopt_blob = DeoptimizationBlob::create(&buffer, oop_maps, 0, exception_offset, reexecute_offset, frame_size_in_words);
3604 _deopt_blob->set_unpack_with_exception_in_tls_offset(exception_in_tls_offset);
3605 }
3606
3607 #ifdef COMPILER2
3608 //------------------------------generate_uncommon_trap_blob--------------------
3609 void SharedRuntime::generate_uncommon_trap_blob() {
3610 // Allocate space for the code
3611 ResourceMark rm;
3612 // Setup code generation tools
3613 CodeBuffer buffer("uncommon_trap_blob", 2048, 1024);
3614 MacroAssembler* masm = new MacroAssembler(&buffer);
3615
3616 assert(SimpleRuntimeFrame::framesize % 4 == 0, "sp not 16-byte aligned");
3617
3618 address start = __ pc();
3619
3620 if (UseRTMLocking) {
3621 // Abort RTM transaction before possible nmethod deoptimization.
3622 __ xabort(0);
3623 }
3624
3625 // Push self-frame. We get here with a return address on the
3626 // stack, so rsp is 8-byte aligned until we allocate our frame.
3627 __ subptr(rsp, SimpleRuntimeFrame::return_off << LogBytesPerInt); // Epilog!
3628
3629 // No callee saved registers. rbp is assumed implicitly saved
3630 __ movptr(Address(rsp, SimpleRuntimeFrame::rbp_off << LogBytesPerInt), rbp);
3631
3632 // compiler left unloaded_class_index in j_rarg0 move to where the
3633 // runtime expects it.
3634 __ movl(c_rarg1, j_rarg0);
3635
3636 __ set_last_Java_frame(noreg, noreg, NULL);
3637
3638 // Call C code. Need thread but NOT official VM entry
3639 // crud. We cannot block on this call, no GC can happen. Call should
3640 // capture callee-saved registers as well as return values.
3641 // Thread is in rdi already.
3642 //
3643 // UnrollBlock* uncommon_trap(JavaThread* thread, jint unloaded_class_index);
3644
3785 // and setup oopmap.
3786 //
3787 SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, int poll_type) {
3788 assert(StubRoutines::forward_exception_entry() != NULL,
3789 "must be generated before");
3790
3791 ResourceMark rm;
3792 OopMapSet *oop_maps = new OopMapSet();
3793 OopMap* map;
3794
3795 // Allocate space for the code. Setup code generation tools.
3796 CodeBuffer buffer("handler_blob", 2048, 1024);
3797 MacroAssembler* masm = new MacroAssembler(&buffer);
3798
3799 address start = __ pc();
3800 address call_pc = NULL;
3801 int frame_size_in_words;
3802 bool cause_return = (poll_type == POLL_AT_RETURN);
3803 bool save_vectors = (poll_type == POLL_AT_VECTOR_LOOP);
3804
3805 if (UseRTMLocking) {
3806 // Abort RTM transaction before calling runtime
3807 // because critical section will be large and will be
3808 // aborted anyway. Also nmethod could be deoptimized.
3809 __ xabort(0);
3810 }
3811
3812 // Make room for return address (or push it again)
3813 if (!cause_return) {
3814 __ push(rbx);
3815 }
3816
3817 // Save registers, fpu state, and flags
3818 map = RegisterSaver::save_live_registers(masm, 0, &frame_size_in_words, save_vectors);
3819
3820 // The following is basically a call_VM. However, we need the precise
3821 // address of the call in order to generate an oopmap. Hence, we do all the
3822 // work outselves.
3823
3824 __ set_last_Java_frame(noreg, noreg, NULL);
3825
3826 // The return address must always be correct so that frame constructor never
3827 // sees an invalid pc.
3828
3829 if (!cause_return) {
3830 // overwrite the dummy value we pushed on entry
3831 __ movptr(c_rarg0, Address(r15_thread, JavaThread::saved_exception_pc_offset()));
|