Changeset 8012
- Timestamp:
- Jan 7, 2008, 8:15:00 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/working-0711/ccl/level-0/X86/x86-misc.lisp
r7886 r8012 760 760 (restore-simple-frame) 761 761 (single-value-return)) 762 763 ;;; This is a prototype; it can't easily keep its arguments on the stack, 764 ;;; or in registers, because its job involves unwinding the stack and 765 ;;; restoring registers. Its parameters are thus kept in constants, 766 ;;; and this protoype is cloned (with the right parameters). 767 768 (defx86lapfunction %%apply-in-frame-proto () 769 (:fixed-constants (target-frame target-catch target-db-link target-xcf target-tsp target-foreign-sp save0-offset save1-offset save2-offset save3-offset function args)) 770 (check-nargs 0) 771 (movq (@ 'target-catch (% fn)) (% temp0)) 772 (xorl (%l imm0) (%l imm0)) 773 (cmpb ($ x8664::fulltag-nil) (%b temp0)) 774 (movq (@ (% :rcontext) target::tcr.catch-top) (% arg_z)) 775 (jz @did-catch) 776 @find-catch 777 (testq (% arg_z) (% arg_z)) 778 (jz @did-catch) ; never found target catch 779 (addq ($ '1) (% imm0)) 780 (cmpq (% temp0) (% arg_z)) 781 (je @found-catch) 782 (movq (@ target::catch-frame.link (% arg_z)) (% arg_z)) 783 (jmp @find-catch) 784 @found-catch 785 (set-nargs 0) ; redundant, but ... 786 (lea (@ (:^ @back-from-nthrow) (% fn)) (% ra0)) 787 (:talign 4) 788 (jmp-subprim .SPnthrowvalues) 789 @back-from-nthrow 790 (recover-fn-from-rip) 791 @did-catch 792 ;; Restore special bindings 793 (movq (@ 'target-db-link (% fn)) (% imm0)) 794 (cmpb ($ x8664::fulltag-nil) (%b imm0)) 795 (jz @no-unbind) 796 (call-subprim .SPunbind-to) 797 @no-unbind 798 ;; If there's at least one exception frame between the target 799 ;; frame and the last catch (or the point of departure), restore 800 ;; the NVRs and foreign sp from the oldest such frame 801 (movq (@ 'target-xcf (% fn)) (% arg_z)) 802 (cmpb ($ x8664::fulltag-nil) (%b arg_z)) 803 (jz @no-xcf) 804 (movq (@ target::xcf.xp (% arg_z)) (% arg_y)) 805 ;; arg_y points to a "portable" ucontext. Find the platform-specifc 806 ;; "gpr vector" in the uc_mcontext, load the NVRs and stack/frame 807 ;; pointer from there. 808 #+linuxx8664-target 809 (progn 810 (addq ($ gp-regs-offset) (% arg_y)) 811 (movq (@ (* #$REG_R15 8) (% arg_y)) (% r15)) 812 (movq (@ (* #$REG_R14 8) (% arg_y)) (% r14)) 813 (movq (@ (* #$REG_R12 8) (% arg_y)) (% r12)) 814 (movq (@ (* #$REG_R11 8) (% arg_y)) (% r11)) 815 (movq (@ (* #$REG_RBP 8) (% arg_y)) (% rbp)) 816 (movq (@ (* #$REG_RSP 8) (% arg_y)) (% rsp))) 817 #+freebsdx8664-target 818 (progn 819 ;; If you think that this is ugly, just wait until you see the Darwin 820 ;; version. 821 (addq ($ gp-regs-offset) (% arg_y)) 822 (movq (@ (ash (foreign-record-field-offset (%find-foreign-record-type-field (parse-foreign-type '(:struct :__mcontext)) :mc_r15)) -3) (% arg_y)) (% r15)) 823 (movq (@ (ash (foreign-record-field-offset (%find-foreign-record-type-field (parse-foreign-type '(:struct :__mcontext)) :mc_r14)) -3) (% arg_y)) (% r14)) 824 (movq (@ (ash (foreign-record-field-offset (%find-foreign-record-type-field (parse-foreign-type '(:struct :__mcontext)) :mc_r12)) -3) (% arg_y)) (% r12)) 825 (movq (@ (ash (foreign-record-field-offset (%find-foreign-record-type-field (parse-foreign-type '(:struct :__mcontext)) :mc_r11)) -3) (% arg_y)) (% r11)) 826 (movq (@ (ash (foreign-record-field-offset (%find-foreign-record-type-field (parse-foreign-type '(:struct :__mcontext)) :mc_rbp)) -3) (% arg_y)) (% rbp)) 827 (movq (@ (ash (foreign-record-field-offset (%find-foreign-record-type-field (parse-foreign-type '(:struct :__mcontext)) :mc_rsp) -3) (% arg_y)) (% rsp)))) 828 #+darwinx8664-target 829 (progn 830 (fix this)) 831 ;; This is our best (possibly only) chance to get 832 ;; the foreign sp right. 833 (movq (@ target::xcf.prev-xframe (% arg_z)) (% temp0)) 834 (movq (@ target::xcf.foreign-sp (% arg_z)) (% imm0)) 835 (movq (% temp0) (@ (% :rcontext) target::tcr.xframe)) 836 (movq (% imm0) (@ (% :rcontext) target::tcr.foreign-sp)) 837 ;; All done processing the xcf. NVRs may have been 838 ;; saved between the last catch/last xcf and the 839 ;; target frame. The save-n-offset parameter/constants 840 ;; are either 0 or negative offsets from the target frame 841 ;; of the stack location where the corresponding GPR 842 ;; was saved. 843 @no-xcf 844 (movq (@ 'target-tsp (% fn)) (% imm0)) 845 (cmpb ($ x8664::fulltag-nil) (%b imm0)) 846 (movq (@ 'target-foreign-sp (% fn)) (% temp0)) 847 (je @no-tsp) 848 (movq (% imm0) (@ (% :rcontext) target::tcr.save-tsp)) 849 (movq (% imm0) (@ (% :rcontext) target::tcr.next-tsp)) 850 @no-tsp 851 (cmpb ($ x8664::fulltag-nil) (%b temp0)) 852 (je @no-sp) 853 (movq (% temp0) (@ (% :rcontext) target::tcr.foreign-sp)) 854 @no-sp 855 (movq (@ 'target-frame (% fn)) (% rbp)) 856 (movq (@ 'save0-offset (% fn)) (% arg_x)) 857 (movq (@ 'save1-offset (% fn)) (% arg_y)) 858 (movq (@ 'save2-offset (% fn)) (% arg_z)) 859 (movq (@ 'save3-offset (% fn)) (% temp0)) 860 (testq (% arg_x) (% arg_x)) 861 (cmovneq (@ (% rbp) (% arg_x)) (% save0)) 862 (testq (% arg_y) (% arg_y)) 863 (cmovneq (@ (% rbp) (% arg_x)) (% save1)) 864 (testq (% arg_z) (% arg_z)) 865 (cmovneq (@ (% rbp) (% arg_x)) (% save2)) 866 (testq (% temp0) (% temp0)) 867 (cmovneq (@ (% rbp) (% arg_x)) (% save3)) 868 (leave) 869 (pop (% temp0)) ; return address, not used by subprim 870 (set-nargs 0) 871 (movq (@ 'args (% fn)) (% arg_z)) 872 (lea (@ (:^ @back-from-spread) (% fn)) (% ra0)) 873 (:talign 4) 874 (jmp-subprim .SPspreadargz) 875 @back-from-spread 876 (recover-fn-from-rip) ; .SPspreadargz preserves %fn, but ... 877 (jmp (@ 'function (% fn)))) 762 878 763 879 880 881 882 883 884 764 885 ;;; end of x86-misc.lisp
Note:
See TracChangeset
for help on using the changeset viewer.
