X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcompiler%2Fx86-64%2Fstatic-fn.lisp;h=ec4809a1e46b2e58a8febbba8ed57e936552accd;hb=a3d4610158f227d53cb5eac287dd2661e975fc70;hp=ee2baea3c5a3805dffc53ce5f233f78caa30a174;hpb=2973941cf214a5ea274cd0381a651ce0e1a7fab2;p=sbcl.git diff --git a/src/compiler/x86-64/static-fn.lisp b/src/compiler/x86-64/static-fn.lisp index ee2baea..ec4809a 100644 --- a/src/compiler/x86-64/static-fn.lisp +++ b/src/compiler/x86-64/static-fn.lisp @@ -16,9 +16,6 @@ (:policy :safe) (:variant-vars function) (:vop-var vop) - ;;(:node-var node) - (:temporary (:sc unsigned-reg :offset ebx-offset - :from (:eval 0) :to (:eval 2)) ebx) (:temporary (:sc unsigned-reg :offset ecx-offset :from (:eval 0) :to (:eval 2)) ecx)) @@ -41,7 +38,12 @@ (<= num-results register-arg-count)) (error "either too many args (~W) or too many results (~W); max = ~W" num-args num-results register-arg-count)) - (let ((num-temps (max num-args num-results))) + (let ((num-temps (max num-args num-results)) + (node (sb!xc:gensym "NODE-")) + (new-rbp-ea + '(make-ea :qword + :disp (frame-byte-offset (+ sp->fp-offset -3 ocfp-save-offset)) + :base rsp-tn))) (collect ((temp-names) (temps) (arg-names) (args) (result-names) (results)) (dotimes (i num-results) (let ((result-name (intern (format nil "RESULT-~D" i)))) @@ -71,34 +73,26 @@ static-fun-template) (:args ,@(args)) ,@(temps) - (:temporary (:sc unsigned-reg) call-target) (:results ,@(results)) + (:node-var ,node) (:generator ,(+ 50 num-args num-results) ,@(moves (temp-names) (arg-names)) - ;; If speed not more important than size, duplicate the + ;; If speed is at least as important as size, duplicate the ;; effect of the ENTER with discrete instructions. Takes - ;; 2+1+3+2=8 bytes as opposed to 4+3=7 bytes. - (cond (t ;(policy node (>= speed space)) - (inst mov ebx rsp-tn) - ;; Dummy for return address + ;; 3+4+4=11 bytes as opposed to 1+4=5 bytes. + (cond ((policy ,node (>= speed space)) + (inst sub rsp-tn (* 3 n-word-bytes)) + (inst mov ,new-rbp-ea rbp-tn) + (inst lea rbp-tn ,new-rbp-ea)) + (t + ;; Dummy for return address. (inst push rbp-tn) - ;; Save the old-fp - (inst push rbp-tn) - ;; Ensure that at least three slots are available; one - ;; above, two more needed. - (inst sub rsp-tn (fixnumize 1)) - (inst mov rbp-tn ebx)) - #+(or) (t - (inst enter (fixnumize 2)) - ;; The enter instruction pushes EBP and then copies - ;; ESP into EBP. We want the new EBP to be the - ;; original ESP, so we fix it up afterwards. - (inst add rbp-tn (fixnumize 1)))) + (inst enter n-word-bytes))) ,(if (zerop num-args) '(inst xor ecx ecx) - `(inst mov ecx (fixnumize ,num-args))) + `(inst mov ecx ,(fixnumize num-args))) (note-this-location vop :call-site) ;; Old CMU CL comment: @@ -114,14 +108,7 @@ ;; longer executed? Does it not depend on the ;; 1+3=4=fdefn_raw_address_offset relationship above? ;; Is something else going on?) - - ;; Need to load the target address into a register, since - ;; immediate call arguments are just a 32-bit displacement, - ;; which obviously can't work with >4G spaces. - (inst mov call-target - (make-ea :qword - :disp (+ nil-value (static-fun-offset function)))) - (inst call call-target) + (call-indirect (+ nil-value (static-fun-offset function))) ,(collect ((bindings) (links)) (do ((temp (temp-names) (cdr temp)) (name 'values (gensym)) @@ -137,7 +124,8 @@ (default-unknown-values vop ,(if (zerop num-results) nil 'values) - ,num-results))) + ,num-results + ,node))) ,@(moves (result-names) (temp-names))))))) ) ; EVAL-WHEN