2558 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, Deoptimization::fetch_unroll_info))); 2559 2560 // Need to have an oopmap that tells fetch_unroll_info where to 2561 // find any register it might need. 2562 2563 oop_maps->add_gc_map( __ pc()-start, map); 2564 2565 // Discard arg to fetch_unroll_info 2566 __ pop(rcx); 2567 2568 __ get_thread(rcx); 2569 __ reset_last_Java_frame(rcx, false, false); 2570 2571 // Load UnrollBlock into EDI 2572 __ mov(rdi, rax); 2573 2574 // Move the unpack kind to a safe place in the UnrollBlock because 2575 // we are very short of registers 2576 2577 Address unpack_kind(rdi, Deoptimization::UnrollBlock::unpack_kind_offset_in_bytes()); 2578 // retrieve the deopt kind from where we left it. 2579 __ pop(rax); 2580 __ movl(unpack_kind, rax); // save the unpack_kind value 2581 2582 Label noException; 2583 __ cmpl(rax, Deoptimization::Unpack_exception); // Was exception pending? 2584 __ jcc(Assembler::notEqual, noException); 2585 __ movptr(rax, Address(rcx, JavaThread::exception_oop_offset())); 2586 __ movptr(rdx, Address(rcx, JavaThread::exception_pc_offset())); 2587 __ movptr(Address(rcx, JavaThread::exception_oop_offset()), NULL_WORD); 2588 __ movptr(Address(rcx, JavaThread::exception_pc_offset()), NULL_WORD); 2589 2590 __ verify_oop(rax); 2591 2592 // Overwrite the result registers with the exception results. 2593 __ movptr(Address(rsp, RegisterSaver::raxOffset()*wordSize), rax); 2594 __ movptr(Address(rsp, RegisterSaver::rdxOffset()*wordSize), rdx); 2595 2596 __ bind(noException); 2597 2598 // Stack is back to only having register save data on the stack. 2599 // Now restore the result registers. Everything else is either dead or captured 2600 // in the vframeArray. 2770 // make sure all code is generated 2771 masm->flush(); 2772 2773 _deopt_blob = DeoptimizationBlob::create( &buffer, oop_maps, 0, exception_offset, reexecute_offset, frame_size_in_words); 2774 _deopt_blob->set_unpack_with_exception_in_tls_offset(exception_in_tls_offset); 2775 } 2776 2777 2778 #ifdef COMPILER2 2779 //------------------------------generate_uncommon_trap_blob-------------------- 2780 void SharedRuntime::generate_uncommon_trap_blob() { 2781 // allocate space for the code 2782 ResourceMark rm; 2783 // setup code generation tools 2784 CodeBuffer buffer("uncommon_trap_blob", 512, 512); 2785 MacroAssembler* masm = new MacroAssembler(&buffer); 2786 2787 enum frame_layout { 2788 arg0_off, // thread sp + 0 // Arg location for 2789 arg1_off, // unloaded_class_index sp + 1 // calling C 2790 // The frame sender code expects that rbp will be in the "natural" place and 2791 // will override any oopMap setting for it. We must therefore force the layout 2792 // so that it agrees with the frame sender code. 2793 rbp_off, // callee saved register sp + 2 2794 return_off, // slot for return address sp + 3 2795 framesize 2796 }; 2797 2798 address start = __ pc(); 2799 2800 if (UseRTMLocking) { 2801 // Abort RTM transaction before possible nmethod deoptimization. 2802 __ xabort(0); 2803 } 2804 2805 // Push self-frame. 2806 __ subptr(rsp, return_off*wordSize); // Epilog! 2807 2808 // rbp, is an implicitly saved callee saved register (i.e. the calling 2809 // convention will save restore it in prolog/epilog) Other than that 2810 // there are no callee save registers no that adapter frames are gone. 2811 __ movptr(Address(rsp, rbp_off*wordSize), rbp); 2812 2813 // Clear the floating point exception stack 2814 __ empty_FPU_stack(); 2815 2816 // set last_Java_sp 2817 __ get_thread(rdx); 2818 __ set_last_Java_frame(rdx, noreg, noreg, NULL); 2819 2820 // Call C code. Need thread but NOT official VM entry 2821 // crud. We cannot block on this call, no GC can happen. Call should 2822 // capture callee-saved registers as well as return values. 2823 __ movptr(Address(rsp, arg0_off*wordSize), rdx); 2824 // argument already in ECX 2825 __ movl(Address(rsp, arg1_off*wordSize),rcx); 2826 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, Deoptimization::uncommon_trap))); 2827 2828 // Set an oopmap for the call site 2829 OopMapSet *oop_maps = new OopMapSet(); 2830 OopMap* map = new OopMap( framesize, 0 ); 2831 // No oopMap for rbp, it is known implicitly 2832 2833 oop_maps->add_gc_map( __ pc()-start, map); 2834 2835 __ get_thread(rcx); 2836 2837 __ reset_last_Java_frame(rcx, false, false); 2838 2839 // Load UnrollBlock into EDI 2840 __ movptr(rdi, rax); 2841 2842 // Pop all the frames we must move/replace. 2843 // 2844 // Frame picture (youngest to oldest) 2845 // 1: self-frame (no frame link) 2846 // 2: deopting frame (no frame link) 2847 // 3: caller of deopting frame (could be compiled/interpreted). 2848 2849 // Pop self-frame. We have no frame, and must rely only on EAX and ESP. 2850 __ addptr(rsp,(framesize-1)*wordSize); // Epilog! 2851 2852 // Pop deoptimized frame 2853 __ movl2ptr(rcx, Address(rdi,Deoptimization::UnrollBlock::size_of_deoptimized_frame_offset_in_bytes())); 2854 __ addptr(rsp, rcx); 2855 2856 // sp should be pointing at the return address to the caller (3) 2857 2858 // Pick up the initial fp we should save 2859 // restore rbp before stack bang because if stack overflow is thrown it needs to be pushed (and preserved) 2860 __ movptr(rbp, Address(rdi, Deoptimization::UnrollBlock::initial_info_offset_in_bytes())); | 2558 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, Deoptimization::fetch_unroll_info))); 2559 2560 // Need to have an oopmap that tells fetch_unroll_info where to 2561 // find any register it might need. 2562 2563 oop_maps->add_gc_map( __ pc()-start, map); 2564 2565 // Discard arg to fetch_unroll_info 2566 __ pop(rcx); 2567 2568 __ get_thread(rcx); 2569 __ reset_last_Java_frame(rcx, false, false); 2570 2571 // Load UnrollBlock into EDI 2572 __ mov(rdi, rax); 2573 2574 // Move the unpack kind to a safe place in the UnrollBlock because 2575 // we are very short of registers 2576 2577 Address unpack_kind(rdi, Deoptimization::UnrollBlock::unpack_kind_offset_in_bytes()); 2578 // retrieve the deopt kind from the UnrollBlock. 2579 __ movl(rax, unpack_kind); 2580 2581 Label noException; 2582 __ cmpl(rax, Deoptimization::Unpack_exception); // Was exception pending? 2583 __ jcc(Assembler::notEqual, noException); 2584 __ movptr(rax, Address(rcx, JavaThread::exception_oop_offset())); 2585 __ movptr(rdx, Address(rcx, JavaThread::exception_pc_offset())); 2586 __ movptr(Address(rcx, JavaThread::exception_oop_offset()), NULL_WORD); 2587 __ movptr(Address(rcx, JavaThread::exception_pc_offset()), NULL_WORD); 2588 2589 __ verify_oop(rax); 2590 2591 // Overwrite the result registers with the exception results. 2592 __ movptr(Address(rsp, RegisterSaver::raxOffset()*wordSize), rax); 2593 __ movptr(Address(rsp, RegisterSaver::rdxOffset()*wordSize), rdx); 2594 2595 __ bind(noException); 2596 2597 // Stack is back to only having register save data on the stack. 2598 // Now restore the result registers. Everything else is either dead or captured 2599 // in the vframeArray. 2769 // make sure all code is generated 2770 masm->flush(); 2771 2772 _deopt_blob = DeoptimizationBlob::create( &buffer, oop_maps, 0, exception_offset, reexecute_offset, frame_size_in_words); 2773 _deopt_blob->set_unpack_with_exception_in_tls_offset(exception_in_tls_offset); 2774 } 2775 2776 2777 #ifdef COMPILER2 2778 //------------------------------generate_uncommon_trap_blob-------------------- 2779 void SharedRuntime::generate_uncommon_trap_blob() { 2780 // allocate space for the code 2781 ResourceMark rm; 2782 // setup code generation tools 2783 CodeBuffer buffer("uncommon_trap_blob", 512, 512); 2784 MacroAssembler* masm = new MacroAssembler(&buffer); 2785 2786 enum frame_layout { 2787 arg0_off, // thread sp + 0 // Arg location for 2788 arg1_off, // unloaded_class_index sp + 1 // calling C 2789 arg2_off, // exec_mode sp + 2 2790 // The frame sender code expects that rbp will be in the "natural" place and 2791 // will override any oopMap setting for it. We must therefore force the layout 2792 // so that it agrees with the frame sender code. 2793 rbp_off, // callee saved register sp + 3 2794 return_off, // slot for return address sp + 4 2795 framesize 2796 }; 2797 2798 address start = __ pc(); 2799 2800 if (UseRTMLocking) { 2801 // Abort RTM transaction before possible nmethod deoptimization. 2802 __ xabort(0); 2803 } 2804 2805 // Push self-frame. 2806 __ subptr(rsp, return_off*wordSize); // Epilog! 2807 2808 // rbp, is an implicitly saved callee saved register (i.e. the calling 2809 // convention will save restore it in prolog/epilog) Other than that 2810 // there are no callee save registers no that adapter frames are gone. 2811 __ movptr(Address(rsp, rbp_off*wordSize), rbp); 2812 2813 // Clear the floating point exception stack 2814 __ empty_FPU_stack(); 2815 2816 // set last_Java_sp 2817 __ get_thread(rdx); 2818 __ set_last_Java_frame(rdx, noreg, noreg, NULL); 2819 2820 // Call C code. Need thread but NOT official VM entry 2821 // crud. We cannot block on this call, no GC can happen. Call should 2822 // capture callee-saved registers as well as return values. 2823 __ movptr(Address(rsp, arg0_off*wordSize), rdx); 2824 // argument already in ECX 2825 __ movl(Address(rsp, arg1_off*wordSize),rcx); 2826 __ movl(Address(rsp, arg2_off*wordSize), Deoptimization::Unpack_uncommon_trap); 2827 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, Deoptimization::uncommon_trap))); 2828 2829 // Set an oopmap for the call site 2830 OopMapSet *oop_maps = new OopMapSet(); 2831 OopMap* map = new OopMap( framesize, 0 ); 2832 // No oopMap for rbp, it is known implicitly 2833 2834 oop_maps->add_gc_map( __ pc()-start, map); 2835 2836 __ get_thread(rcx); 2837 2838 __ reset_last_Java_frame(rcx, false, false); 2839 2840 // Load UnrollBlock into EDI 2841 __ movptr(rdi, rax); 2842 2843 #ifdef ASSERT 2844 { Label L; 2845 __ cmpptr(Address(rdi, Deoptimization::UnrollBlock::unpack_kind_offset_in_bytes()), 2846 (int32_t)Deoptimization::Unpack_uncommon_trap); 2847 __ jcc(Assembler::equal, L); 2848 __ stop("SharedRuntime::generate_deopt_blob: expected Unpack_uncommon_trap"); 2849 __ bind(L); 2850 } 2851 #endif 2852 2853 // Pop all the frames we must move/replace. 2854 // 2855 // Frame picture (youngest to oldest) 2856 // 1: self-frame (no frame link) 2857 // 2: deopting frame (no frame link) 2858 // 3: caller of deopting frame (could be compiled/interpreted). 2859 2860 // Pop self-frame. We have no frame, and must rely only on EAX and ESP. 2861 __ addptr(rsp,(framesize-1)*wordSize); // Epilog! 2862 2863 // Pop deoptimized frame 2864 __ movl2ptr(rcx, Address(rdi,Deoptimization::UnrollBlock::size_of_deoptimized_frame_offset_in_bytes())); 2865 __ addptr(rsp, rcx); 2866 2867 // sp should be pointing at the return address to the caller (3) 2868 2869 // Pick up the initial fp we should save 2870 // restore rbp before stack bang because if stack overflow is thrown it needs to be pushed (and preserved) 2871 __ movptr(rbp, Address(rdi, Deoptimization::UnrollBlock::initial_info_offset_in_bytes())); |