X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcompiler%2Fx86%2Fstatic-fn.lisp;h=9e080e4bf89218c57c503ab81b4a208e25598a8f;hb=22b819c0cd0ca0ea5be52ba280b9e9e0b8e86210;hp=2989928c374e762dc0450ad697ca4e2d90924336;hpb=a530bbe337109d898d5b4a001fc8f1afa3b5dc39;p=sbcl.git diff --git a/src/compiler/x86/static-fn.lisp b/src/compiler/x86/static-fn.lisp index 2989928..9e080e4 100644 --- a/src/compiler/x86/static-fn.lisp +++ b/src/compiler/x86/static-fn.lisp @@ -11,10 +11,7 @@ (in-package "SB!VM") -(file-comment - "$Header$") - -(define-vop (static-function-template) +(define-vop (static-fun-template) (:save-p t) (:policy :safe) (:variant-vars function) @@ -25,10 +22,10 @@ (:temporary (:sc unsigned-reg :offset ecx-offset :from (:eval 0) :to (:eval 2)) ecx)) -(eval-when (:compile-toplevel :load-toplevel :execute) +(eval-when (#-sb-xc :compile-toplevel :load-toplevel :execute) -(defun static-function-template-name (num-args num-results) - (intern (format nil "~:@(~R-arg-~R-result-static-function~)" +(defun static-fun-template-name (num-args num-results) + (intern (format nil "~:@(~R-arg-~R-result-static-fun~)" num-args num-results))) (defun moves (dst src) @@ -39,12 +36,11 @@ (moves `(move ,(car dst) ,(car src)))) (moves))) -(defun static-function-template-vop (num-args num-results) - (assert (and (<= num-args register-arg-count) +(defun static-fun-template-vop (num-args num-results) + (unless (and (<= num-args register-arg-count) (<= num-results register-arg-count)) - (num-args num-results) - "Either too many args (~D) or too many results (~D). Max = ~D" - num-args 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))) (collect ((temp-names) (temps) (arg-names) (args) (result-names) (results)) (dotimes (i num-results) @@ -55,7 +51,7 @@ (let ((temp-name (intern (format nil "TEMP-~D" i)))) (temp-names temp-name) (temps `(:temporary (:sc descriptor-reg - :offset ,(nth i register-arg-offsets) + :offset ,(nth i *register-arg-offsets*) :from ,(if (< i num-args) `(:argument ,i) '(:eval 1)) @@ -71,8 +67,8 @@ (args `(,arg-name :scs (any-reg descriptor-reg) :target ,(nth i (temp-names)))))) - `(define-vop (,(static-function-template-name num-args num-results) - static-function-template) + `(define-vop (,(static-fun-template-name num-args num-results) + static-fun-template) (:args ,@(args)) ,@(temps) (:results ,@(results)) @@ -102,14 +98,22 @@ `(inst mov ecx (fixnumize ,num-args))) (note-this-location vop :call-site) - ;; Static-function-offset gives the offset from the start of - ;; the nil object to the static function fdefn and has the - ;; low tag of 1 added. When the nil symbol value with its - ;; low tag of 3 is added the resulting value points to the - ;; raw address slot of the fdefn (at +4). + ;; Old CMU CL comment: + ;; STATIC-FUN-OFFSET gives the offset from the start of + ;; the NIL object to the static function FDEFN and has the + ;; low tag of 1 added. When the NIL symbol value with its + ;; low tag of 3 is added the resulting value points to the + ;; raw address slot of the fdefn (at +4). + ;; FIXME: Since the fork from CMU CL, we've swapped + ;; FUN-POINTER-LOWTAG and INSTANCE-POINTER-LOWTAG, so the + ;; text above is no longer right. Mysteriously, things still + ;; work. It would be good to explain why. (Is this code no + ;; longer executed? Does it not depend on the + ;; 1+3=4=fdefn_raw_address_offset relationship above? + ;; Is something else going on?) (inst call (make-ea :dword - :disp (+ *nil-value* - (static-function-offset function)))) + :disp (+ nil-value + (static-fun-offset function)))) ,(collect ((bindings) (links)) (do ((temp (temp-names) (cdr temp)) (name 'values (gensym)) @@ -128,22 +132,22 @@ ,num-results))) ,@(moves (result-names) (temp-names))))))) -) ; eval-when (compile load eval) +) ; EVAL-WHEN (macrolet ((frob (num-args num-res) - (static-function-template-vop (eval num-args) (eval num-res)))) + (static-fun-template-vop (eval num-args) (eval num-res)))) (frob 0 1) (frob 1 1) (frob 2 1) (frob 3 1)) -(defmacro define-static-function (name args &key (results '(x)) translate - policy cost arg-types result-types) +(defmacro define-static-fun (name args &key (results '(x)) translate + policy cost arg-types result-types) `(define-vop (,name - ,(static-function-template-name (length args) - (length results))) + ,(static-fun-template-name (length args) + (length results))) (:variant ',name) - (:note ,(format nil "static-function ~@(~S~)" name)) + (:note ,(format nil "static-fun ~@(~S~)" name)) ,@(when translate `((:translate ,translate))) ,@(when policy