1800 // because it can be patched on the fly by make_non_entrant. The stack bang 1801 // instruction fits that requirement. 1802 1803 // Generate stack overflow check 1804 1805 if (UseStackBanging) { 1806 __ bang_stack_with_offset(StackShadowPages*os::vm_page_size()); 1807 } else { 1808 // need a 5 byte instruction to allow MT safe patching to non-entrant 1809 __ fat_nop(); 1810 } 1811 1812 // Generate a new frame for the wrapper. 1813 __ enter(); 1814 // -2 because return address is already present and so is saved rbp 1815 __ subptr(rsp, stack_size - 2*wordSize); 1816 1817 // Frame is now completed as far as size and linkage. 1818 int frame_complete = ((intptr_t)__ pc()) - start; 1819 1820 // Calculate the difference between rsp and rbp,. We need to know it 1821 // after the native call because on windows Java Natives will pop 1822 // the arguments and it is painful to do rsp relative addressing 1823 // in a platform independent way. So after the call we switch to 1824 // rbp, relative addressing. 1825 1826 int fp_adjustment = stack_size - 2*wordSize; 1827 1828 #ifdef COMPILER2 1829 // C2 may leave the stack dirty if not in SSE2+ mode 1830 if (UseSSE >= 2) { 1831 __ verify_FPU(0, "c2i transition should have clean FPU stack"); 1832 } else { 1833 __ empty_FPU_stack(); 1834 } 1835 #endif /* COMPILER2 */ 1836 1837 // Compute the rbp, offset for any slots used after the jni call 1838 1839 int lock_slot_rbp_offset = (lock_slot_offset*VMRegImpl::stack_slot_size) - fp_adjustment; 3153 //------------------------------generate_uncommon_trap_blob-------------------- 3154 void SharedRuntime::generate_uncommon_trap_blob() { 3155 // allocate space for the code 3156 ResourceMark rm; 3157 // setup code generation tools 3158 CodeBuffer buffer("uncommon_trap_blob", 512, 512); 3159 MacroAssembler* masm = new MacroAssembler(&buffer); 3160 3161 enum frame_layout { 3162 arg0_off, // thread sp + 0 // Arg location for 3163 arg1_off, // unloaded_class_index sp + 1 // calling C 3164 // The frame sender code expects that rbp will be in the "natural" place and 3165 // will override any oopMap setting for it. We must therefore force the layout 3166 // so that it agrees with the frame sender code. 3167 rbp_off, // callee saved register sp + 2 3168 return_off, // slot for return address sp + 3 3169 framesize 3170 }; 3171 3172 address start = __ pc(); 3173 // Push self-frame. 3174 __ subptr(rsp, return_off*wordSize); // Epilog! 3175 3176 // rbp, is an implicitly saved callee saved register (i.e. the calling 3177 // convention will save restore it in prolog/epilog) Other than that 3178 // there are no callee save registers no that adapter frames are gone. 3179 __ movptr(Address(rsp, rbp_off*wordSize), rbp); 3180 3181 // Clear the floating point exception stack 3182 __ empty_FPU_stack(); 3183 3184 // set last_Java_sp 3185 __ get_thread(rdx); 3186 __ set_last_Java_frame(rdx, noreg, noreg, NULL); 3187 3188 // Call C code. Need thread but NOT official VM entry 3189 // crud. We cannot block on this call, no GC can happen. Call should 3190 // capture callee-saved registers as well as return values. 3191 __ movptr(Address(rsp, arg0_off*wordSize), rdx); 3192 // argument already in ECX 3338 // Account for thread arg in our frame 3339 const int additional_words = 1; 3340 int frame_size_in_words; 3341 3342 assert (StubRoutines::forward_exception_entry() != NULL, "must be generated before"); 3343 3344 ResourceMark rm; 3345 OopMapSet *oop_maps = new OopMapSet(); 3346 OopMap* map; 3347 3348 // allocate space for the code 3349 // setup code generation tools 3350 CodeBuffer buffer("handler_blob", 1024, 512); 3351 MacroAssembler* masm = new MacroAssembler(&buffer); 3352 3353 const Register java_thread = rdi; // callee-saved for VC++ 3354 address start = __ pc(); 3355 address call_pc = NULL; 3356 bool cause_return = (poll_type == POLL_AT_RETURN); 3357 bool save_vectors = (poll_type == POLL_AT_VECTOR_LOOP); 3358 // If cause_return is true we are at a poll_return and there is 3359 // the return address on the stack to the caller on the nmethod 3360 // that is safepoint. We can leave this return on the stack and 3361 // effectively complete the return and safepoint in the caller. 3362 // Otherwise we push space for a return address that the safepoint 3363 // handler will install later to make the stack walking sensible. 3364 if (!cause_return) 3365 __ push(rbx); // Make room for return address (or push it again) 3366 3367 map = RegisterSaver::save_live_registers(masm, additional_words, &frame_size_in_words, false, save_vectors); 3368 3369 // The following is basically a call_VM. However, we need the precise 3370 // address of the call in order to generate an oopmap. Hence, we do all the 3371 // work ourselves. 3372 3373 // Push thread argument and setup last_Java_sp 3374 __ get_thread(java_thread); 3375 __ push(java_thread); 3376 __ set_last_Java_frame(java_thread, noreg, noreg, NULL); 3377 | 1800 // because it can be patched on the fly by make_non_entrant. The stack bang 1801 // instruction fits that requirement. 1802 1803 // Generate stack overflow check 1804 1805 if (UseStackBanging) { 1806 __ bang_stack_with_offset(StackShadowPages*os::vm_page_size()); 1807 } else { 1808 // need a 5 byte instruction to allow MT safe patching to non-entrant 1809 __ fat_nop(); 1810 } 1811 1812 // Generate a new frame for the wrapper. 1813 __ enter(); 1814 // -2 because return address is already present and so is saved rbp 1815 __ subptr(rsp, stack_size - 2*wordSize); 1816 1817 // Frame is now completed as far as size and linkage. 1818 int frame_complete = ((intptr_t)__ pc()) - start; 1819 1820 if (UseRTMLocking) { 1821 __ xabort(0); 1822 } 1823 1824 // Calculate the difference between rsp and rbp,. We need to know it 1825 // after the native call because on windows Java Natives will pop 1826 // the arguments and it is painful to do rsp relative addressing 1827 // in a platform independent way. So after the call we switch to 1828 // rbp, relative addressing. 1829 1830 int fp_adjustment = stack_size - 2*wordSize; 1831 1832 #ifdef COMPILER2 1833 // C2 may leave the stack dirty if not in SSE2+ mode 1834 if (UseSSE >= 2) { 1835 __ verify_FPU(0, "c2i transition should have clean FPU stack"); 1836 } else { 1837 __ empty_FPU_stack(); 1838 } 1839 #endif /* COMPILER2 */ 1840 1841 // Compute the rbp, offset for any slots used after the jni call 1842 1843 int lock_slot_rbp_offset = (lock_slot_offset*VMRegImpl::stack_slot_size) - fp_adjustment; 3157 //------------------------------generate_uncommon_trap_blob-------------------- 3158 void SharedRuntime::generate_uncommon_trap_blob() { 3159 // allocate space for the code 3160 ResourceMark rm; 3161 // setup code generation tools 3162 CodeBuffer buffer("uncommon_trap_blob", 512, 512); 3163 MacroAssembler* masm = new MacroAssembler(&buffer); 3164 3165 enum frame_layout { 3166 arg0_off, // thread sp + 0 // Arg location for 3167 arg1_off, // unloaded_class_index sp + 1 // calling C 3168 // The frame sender code expects that rbp will be in the "natural" place and 3169 // will override any oopMap setting for it. We must therefore force the layout 3170 // so that it agrees with the frame sender code. 3171 rbp_off, // callee saved register sp + 2 3172 return_off, // slot for return address sp + 3 3173 framesize 3174 }; 3175 3176 address start = __ pc(); 3177 3178 if (UseRTMLocking) { 3179 __ xabort(0); 3180 } 3181 3182 // Push self-frame. 3183 __ subptr(rsp, return_off*wordSize); // Epilog! 3184 3185 // rbp, is an implicitly saved callee saved register (i.e. the calling 3186 // convention will save restore it in prolog/epilog) Other than that 3187 // there are no callee save registers no that adapter frames are gone. 3188 __ movptr(Address(rsp, rbp_off*wordSize), rbp); 3189 3190 // Clear the floating point exception stack 3191 __ empty_FPU_stack(); 3192 3193 // set last_Java_sp 3194 __ get_thread(rdx); 3195 __ set_last_Java_frame(rdx, noreg, noreg, NULL); 3196 3197 // Call C code. Need thread but NOT official VM entry 3198 // crud. We cannot block on this call, no GC can happen. Call should 3199 // capture callee-saved registers as well as return values. 3200 __ movptr(Address(rsp, arg0_off*wordSize), rdx); 3201 // argument already in ECX 3347 // Account for thread arg in our frame 3348 const int additional_words = 1; 3349 int frame_size_in_words; 3350 3351 assert (StubRoutines::forward_exception_entry() != NULL, "must be generated before"); 3352 3353 ResourceMark rm; 3354 OopMapSet *oop_maps = new OopMapSet(); 3355 OopMap* map; 3356 3357 // allocate space for the code 3358 // setup code generation tools 3359 CodeBuffer buffer("handler_blob", 1024, 512); 3360 MacroAssembler* masm = new MacroAssembler(&buffer); 3361 3362 const Register java_thread = rdi; // callee-saved for VC++ 3363 address start = __ pc(); 3364 address call_pc = NULL; 3365 bool cause_return = (poll_type == POLL_AT_RETURN); 3366 bool save_vectors = (poll_type == POLL_AT_VECTOR_LOOP); 3367 3368 if (UseRTMLocking) { 3369 __ xabort(0); 3370 } 3371 3372 // If cause_return is true we are at a poll_return and there is 3373 // the return address on the stack to the caller on the nmethod 3374 // that is safepoint. We can leave this return on the stack and 3375 // effectively complete the return and safepoint in the caller. 3376 // Otherwise we push space for a return address that the safepoint 3377 // handler will install later to make the stack walking sensible. 3378 if (!cause_return) 3379 __ push(rbx); // Make room for return address (or push it again) 3380 3381 map = RegisterSaver::save_live_registers(masm, additional_words, &frame_size_in_words, false, save_vectors); 3382 3383 // The following is basically a call_VM. However, we need the precise 3384 // address of the call in order to generate an oopmap. Hence, we do all the 3385 // work ourselves. 3386 3387 // Push thread argument and setup last_Java_sp 3388 __ get_thread(java_thread); 3389 __ push(java_thread); 3390 __ set_last_Java_frame(java_thread, noreg, noreg, NULL); 3391 |