0.pre7.82:
authorWilliam Harold Newman <william.newman@airmail.net>
Thu, 1 Nov 2001 21:53:27 +0000 (21:53 +0000)
committerWilliam Harold Newman <william.newman@airmail.net>
Thu, 1 Nov 2001 21:53:27 +0000 (21:53 +0000)
s/static-function/static-fun/
another DEFSTRUCT cleanup..
..rewrote structure constructor form to try to make it more
concise and readable

17 files changed:
package-data-list.lisp-expr
src/assembly/alpha/arith.lisp
src/assembly/x86/arith.lisp
src/code/defstruct.lisp
src/code/target-defstruct.lisp
src/compiler/alpha/arith.lisp
src/compiler/alpha/parms.lisp
src/compiler/alpha/static-fn.lisp
src/compiler/alpha/subprim.lisp
src/compiler/generic/genesis.lisp
src/compiler/generic/utils.lisp
src/compiler/target-disassem.lisp
src/compiler/x86/arith.lisp
src/compiler/x86/parms.lisp
src/compiler/x86/static-fn.lisp
src/compiler/x86/subprim.lisp
version.lisp-expr

index c273c69..d5fedf8 100644 (file)
@@ -1818,7 +1818,7 @@ structure representations"
              "SINGLE-STEP-BREAKPOINT-TRAP"
              "SINGLE-VALUE-RETURN-BYTE-OFFSET" "SLOT-DOCS"
              "SLOT-LENGTH" "SLOT-NAME" "SLOT-OFFSET" "SLOT-OPTIONS"
-             "SLOT-REST-P" "*STATIC-FUNCTIONS*" "STATIC-FUNCTION-OFFSET"
+             "SLOT-REST-P" "*STATIC-FUNS*" "STATIC-FUN-OFFSET"
              "STATIC-SYMBOL-OFFSET" "STATIC-SYMBOL-P"
              "*STATIC-SPACE-FREE-POINTER*" "*STATIC-SYMBOLS*"
              "STRUCTURE-USAGE"
index f9ede95..e3d7216 100644 (file)
@@ -61,7 +61,7 @@
   (lisp-return lra lip :offset 2)
 
   DO-STATIC-FUN
-  (inst ldl lip (static-function-offset 'two-arg-+) null-tn)
+  (inst ldl lip (static-fun-offset 'two-arg-+) null-tn)
   (inst li (fixnumize 2) nargs)
   (inst move cfp-tn ocfp)
   (inst move csp-tn cfp-tn)
   (lisp-return lra lip :offset 2)
 
   DO-STATIC-FUN
-  (inst ldl lip (static-function-offset 'two-arg--) null-tn)
+  (inst ldl lip (static-fun-offset 'two-arg--) null-tn)
   (inst li (fixnumize 2) nargs)
   (inst move cfp-tn ocfp)
   (inst move csp-tn cfp-tn)
   (lisp-return lra lip :offset 2)
 
   DO-STATIC-FUN
-  (inst ldl lip (static-function-offset 'two-arg-*) null-tn)
+  (inst ldl lip (static-fun-offset 'two-arg-*) null-tn)
   (inst li (fixnumize 2) nargs)
   (inst move cfp-tn ocfp)
   (inst move csp-tn cfp-tn)
          (inst beq temp DO-COMPARE)
          
          DO-STATIC-FN
-         (inst ldl lip (static-function-offset ',static-fn) null-tn)
+         (inst ldl lip (static-fun-offset ',static-fn) null-tn)
          (inst li (fixnumize 2) nargs)
          (inst move cfp-tn ocfp)
          (inst move csp-tn cfp-tn)
   (lisp-return lra lip :offset 2)
 
   DO-STATIC-FN
-  (inst ldl lip (static-function-offset 'eql) null-tn)
+  (inst ldl lip (static-fun-offset 'eql) null-tn)
   (inst li (fixnumize 2) nargs)
   (inst move cfp-tn ocfp)
   (inst move csp-tn cfp-tn)
   (lisp-return lra lip :offset 2)
 
   DO-STATIC-FN
-  (inst ldl lip (static-function-offset 'two-arg-=) null-tn)
+  (inst ldl lip (static-fun-offset 'two-arg-=) null-tn)
   (inst li (fixnumize 2) nargs)
   (inst move cfp-tn ocfp)
   (inst move csp-tn cfp-tn)
   (lisp-return lra lip :offset 2)
 
   DO-STATIC-FN
-  (inst ldl lip (static-function-offset 'two-arg-=) null-tn)
+  (inst ldl lip (static-fun-offset 'two-arg-=) null-tn)
   (inst li (fixnumize 2) nargs)
   (inst move cfp-tn ocfp)
   (inst move csp-tn cfp-tn)
index 92c270a..392f67c 100644 (file)
@@ -50,7 +50,7 @@
                (inst jmp
                      (make-ea :dword
                               :disp (+ nil-value
-                                       (static-function-offset
+                                       (static-fun-offset
                                         ',(symbolicate "TWO-ARG-" fun)))))
 
                DO-BODY
   (inst push eax)
   (inst mov ecx (fixnumize 1))   ; arg count
   (inst jmp (make-ea :dword
-                    :disp (+ nil-value (static-function-offset '%negate))))
+                    :disp (+ nil-value (static-fun-offset '%negate))))
 
   FIXNUM
   (move res x)
                                        ; should be named parallelly.
                (inst jmp (make-ea :dword
                                   :disp (+ nil-value
-                                           (static-function-offset
-                                            ',static-fn))))
+                                           (static-fun-offset ',static-fn))))
 
                INLINE-FIXNUM-COMPARE
                (inst cmp x y)
   (inst push eax)
   (inst mov ecx (fixnumize 2))
   (inst jmp (make-ea :dword
-                    :disp (+ nil-value (static-function-offset 'eql))))
+                    :disp (+ nil-value (static-fun-offset 'eql))))
 
   RETURN-T
   (load-symbol res t)
   (inst push eax)
   (inst mov ecx (fixnumize 2))
   (inst jmp (make-ea :dword
-                    :disp (+ nil-value (static-function-offset 'two-arg-=))))
+                    :disp (+ nil-value (static-fun-offset 'two-arg-=))))
 
   RETURN-T
   (load-symbol res t))
index 472e2e4..5c3eb5c 100644 (file)
                          vars types))
        (list ,@vals))))
 (defun create-structure-constructor (dd cons-name arglist vars types values)
-  (let* ((temp (gensym))
-        (raw-index (dd-raw-index dd))
-        (n-raw-data (when raw-index (gensym))))
+  (let* ((instance (gensym "INSTANCE"))
+        (raw-index (dd-raw-index dd)))
     `(defun ,cons-name ,arglist
-       (declare ,@(mapcar #'(lambda (var type) `(type ,type ,var))
+       (declare ,@(mapcar (lambda (var type) `(type ,type ,var))
                          vars types))
-       (let ((,temp (truly-the ,(dd-name dd)
-                              (%make-instance ,(dd-length dd))))
-            ,@(when n-raw-data
-                `((,n-raw-data
-                   (make-array ,(dd-raw-length dd)
-                               :element-type '(unsigned-byte 32))))))
-        (setf (%instance-layout ,temp)
-              (%delayed-get-compiler-layout ,(dd-name dd)))
-        ,@(when n-raw-data
-            `((setf (%instance-ref ,temp ,raw-index) ,n-raw-data)))
+       (let ((,instance (truly-the ,(dd-name dd)
+                         (%make-instance-with-layout
+                          (%delayed-get-compiler-layout ,(dd-name dd))))))
+        (declare (optimize (safety 0))) ; Suppress redundant slot type checks.
+        ,@(when raw-index
+            `((setf (%instance-ref ,instance ,raw-index)
+                    (make-array ,(dd-raw-length dd)
+                                :element-type '(unsigned-byte 32)))))
         ,@(mapcar (lambda (dsd value)
-                    ;; (Note that we can't in general use the ordinary
-                    ;; slot accessor function here because the slot
-                    ;; might be :READ-ONLY.)
-                    `(,(slot-setter-lambda-form dd dsd) ,value ,temp))
+                    ;; (Note that we can't in general use the
+                    ;; ordinary named slot setter function here
+                    ;; because the slot might be :READ-ONLY, so we
+                    ;; whip up new LAMBDA representations of slot
+                    ;; setters for the occasion.)
+                    `(,(slot-setter-lambda-form dd dsd) ,value ,instance))
                   (dd-slots dd)
                   values)
-        ,temp))))
+        ,instance))))
 
 ;;; Create a default (non-BOA) keyword constructor.
 (defun create-keyword-constructor (defstruct creator)
index 07a3124..7e30c7b 100644 (file)
        (if (funcallable-instance-p new-value)
            (%funcallable-instance-lexenv new-value)
            new-value)))
+
+;;; service function for structure constructors
+(defun %make-instance-with-layout (layout)
+  (let ((result (%make-instance (layout-length layout))))
+    (setf (%instance-layout result) layout)
+    result))
 \f
 ;;;; target-only parts of the DEFSTRUCT top-level code
 
                        (dsd-raw-type (dsd-raw-type dsd)))
                    #+sb-xc (/show0 "in %NATIVE-SLOT-ACCESSOR-FUNS macroexpanded code")
                    ;; Map over all the possible RAW-TYPEs, compiling
-                   ;; a different closure-function for each one, so
+                   ;; a different closure function for each one, so
                    ;; that once the COND over RAW-TYPEs happens (at
                    ;; the time closure is allocated) there are no
                    ;; more decisions to be made and things execute
index 4f5de2e..d4b6df7 100644 (file)
 \f
 ;;;; static functions
 
-(define-static-function two-arg-gcd (x y) :translate gcd)
-(define-static-function two-arg-lcm (x y) :translate lcm)
-
-(define-static-function two-arg-+ (x y) :translate +)
-(define-static-function two-arg-- (x y) :translate -)
-(define-static-function two-arg-* (x y) :translate *)
-(define-static-function two-arg-/ (x y) :translate /)
-
-(define-static-function two-arg-< (x y) :translate <)
-(define-static-function two-arg-<= (x y) :translate <=)
-(define-static-function two-arg-> (x y) :translate >)
-(define-static-function two-arg->= (x y) :translate >=)
-(define-static-function two-arg-= (x y) :translate =)
-(define-static-function two-arg-/= (x y) :translate /=)
-
-(define-static-function %negate (x) :translate %negate)
-
-(define-static-function two-arg-and (x y) :translate logand)
-(define-static-function two-arg-ior (x y) :translate logior)
-(define-static-function two-arg-xor (x y) :translate logxor)
+(define-static-fun two-arg-gcd (x y) :translate gcd)
+(define-static-fun two-arg-lcm (x y) :translate lcm)
+
+(define-static-fun two-arg-+ (x y) :translate +)
+(define-static-fun two-arg-- (x y) :translate -)
+(define-static-fun two-arg-* (x y) :translate *)
+(define-static-fun two-arg-/ (x y) :translate /)
+
+(define-static-fun two-arg-< (x y) :translate <)
+(define-static-fun two-arg-<= (x y) :translate <=)
+(define-static-fun two-arg-> (x y) :translate >)
+(define-static-fun two-arg->= (x y) :translate >=)
+(define-static-fun two-arg-= (x y) :translate =)
+(define-static-fun two-arg-/= (x y) :translate /=)
+
+(define-static-fun %negate (x) :translate %negate)
+
+(define-static-fun two-arg-and (x y) :translate logand)
+(define-static-fun two-arg-ior (x y) :translate logior)
+(define-static-fun two-arg-xor (x y) :translate logxor)
index 4ef93e3..a73dc08 100644 (file)
     sb!unix::*interrupts-enabled*
     sb!unix::*interrupt-pending*))
 
-(defparameter *static-functions*
+(defparameter *static-funs*
   '(length
     sb!kernel:two-arg-+
     sb!kernel:two-arg--
index f5197ae..026b910 100644 (file)
@@ -11,7 +11,7 @@
 
 (in-package "SB!VM")
 
-(define-vop (static-function-template)
+(define-vop (static-fun-template)
   (:save-p t)
   (:policy :safe)
   (:variant-vars symbol)
@@ -26,8 +26,8 @@
 
 (eval-when  (: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 (src dst)
@@ -38,7 +38,7 @@
       (moves `(move ,(car src) ,(car dst))))
     (moves)))
 
-(defun static-function-template-vop (num-args num-results)
+(defun static-fun-template-vop (num-args num-results)
   (assert (and (<= num-args register-arg-count)
               (<= num-results register-arg-count))
          (num-args num-results)
@@ -67,8 +67,8 @@
          (args `(,arg-name
                  :scs (any-reg descriptor-reg null zero)
                  :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))
@@ -77,7 +77,7 @@
                 (cur-nfp (current-nfp-tn vop)))
             ,@(moves (arg-names) (temp-names))
             (inst li (fixnumize ,num-args) nargs)
-            (inst ldl entry-point (static-function-offset symbol) null-tn)
+            (inst ldl entry-point (static-fun-offset symbol) null-tn)
             (when cur-nfp
               (store-stack-tn nfp-save cur-nfp))
             (inst move cfp-tn ocfp)
 (expand
  (collect ((templates (list 'progn)))
    (dotimes (i register-arg-count)
-     (templates (static-function-template-vop i 1)))
+     (templates (static-fun-template-vop i 1)))
    (templates)))
 
-(defmacro define-static-function (name args &key (results '(x)) translate
+(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
index 66e9ef8..d81cf12 100644 (file)
@@ -48,4 +48,4 @@
     DONE
     (move count result)))
        
-(define-static-function length (object) :translate length)
+(define-static-fun length (object) :translate length)
index bfe95ec..ed4db16 100644 (file)
 
 (defun initialize-static-fns ()
   (let ((*cold-fdefn-gspace* *static*))
-    (dolist (sym sb!vm:*static-functions*)
+    (dolist (sym sb!vm:*static-funs*)
       (let* ((fdefn (cold-fdefinition-object (cold-intern sym)))
             (offset (- (+ (- (descriptor-low fdefn)
                              sb!vm:other-pointer-lowtag)
                           (* sb!vm:fdefn-raw-addr-slot sb!vm:n-word-bytes))
                        (descriptor-low *nil-descriptor*)))
-            (desired (sb!vm:static-function-offset sym)))
+            (desired (sb!vm:static-fun-offset sym)))
        (unless (= offset desired)
          ;; FIXME: should be fatal
          (warn "Offset from FDEFN ~S to ~S is ~D, not ~D."
index cd08569..f690caa 100644 (file)
@@ -11,9 +11,8 @@
 
 (in-package "SB!VM")
 \f
+;;; Make a fixnum out of NUM. (I.e. shift by two bits if it will fit.)
 (defun fixnumize (num)
-  #!+sb-doc
-  "Make a fixnum out of NUM. (i.e. shift by two bits if it will fit.)"
   (if (<= #x-20000000 num #x1fffffff)
       (ash num 2)
       (error "~D is too big for a fixnum." num)))
@@ -24,9 +23,8 @@
   (or (null symbol)
       (and (member symbol *static-symbols*) t)))
 
+;;; the byte offset of the static symbol SYMBOL
 (defun static-symbol-offset (symbol)
-  #!+sb-doc
-  "the byte offset of the static symbol SYMBOL"
   (if symbol
       (let ((posn (position symbol *static-symbols*)))
        (unless posn (error "~S is not a static symbol." symbol))
@@ -36,9 +34,8 @@
           (- list-pointer-lowtag)))
       0))
 
+;;; Given a byte offset, OFFSET, return the appropriate static symbol.
 (defun offset-static-symbol (offset)
-  #!+sb-doc
-  "Given a byte offset, OFFSET, return the appropriate static symbol."
   (if (zerop offset)
       nil
       (multiple-value-bind (n rem)
          (error "The byte offset ~D is not valid." offset))
        (elt *static-symbols* n))))
 
-(defun static-function-offset (name)
-  #!+sb-doc
-  "Return the (byte) offset from NIL to the start of the fdefn object
-   for the static function NAME."
+;;; Return the (byte) offset from NIL to the start of the fdefn object
+;;; for the static function NAME.
+(defun static-fun-offset (name)
   (let ((static-syms (length *static-symbols*))
-       (static-function-index (position name *static-functions*)))
-    (unless static-function-index
+       (static-fun-index (position name *static-funs*)))
+    (unless static-fun-index
       (error "~S isn't a static function." name))
     (+ (* static-syms (pad-data-block symbol-size))
        (pad-data-block (1- symbol-size))
        (- list-pointer-lowtag)
-       (* static-function-index (pad-data-block fdefn-size))
+       (* static-fun-index (pad-data-block fdefn-size))
        (* fdefn-raw-addr-slot n-word-bytes))))
index 0e3877e..4cb57de 100644 (file)
 ;;;    <padding to dual-word boundary>
 ;;;    start of instructions
 ;;;    ...
-;;;    function-headers and lra's buried in here randomly
+;;;    fun-headers and lra's buried in here randomly
 ;;;    ...
 ;;;    start of trace-table
 ;;;    <padding to dual-word boundary>
     (incf (dstate-next-offs dstate) lra-size))
   nil)
 
-;;; Print the function-header (entry-point) pseudo-instruction at the
+;;; Print the fun-header (entry-point) pseudo-instruction at the
 ;;; current location in DSTATE to STREAM.
 (defun fun-header-hook (stream dstate)
   (declare (type (or null stream) stream)
index ee96782..a857524 100644 (file)
 \f
 ;;;; static functions
 
-(define-static-function two-arg-/ (x y) :translate /)
+(define-static-fun two-arg-/ (x y) :translate /)
 
-(define-static-function two-arg-gcd (x y) :translate gcd)
-(define-static-function two-arg-lcm (x y) :translate lcm)
+(define-static-fun two-arg-gcd (x y) :translate gcd)
+(define-static-fun two-arg-lcm (x y) :translate lcm)
 
-(define-static-function two-arg-and (x y) :translate logand)
-(define-static-function two-arg-ior (x y) :translate logior)
-(define-static-function two-arg-xor (x y) :translate logxor)
+(define-static-fun two-arg-and (x y) :translate logand)
+(define-static-fun two-arg-ior (x y) :translate logior)
+(define-static-fun two-arg-xor (x y) :translate logxor)
 
 \f
 ;;; Support for the Mersenne Twister, MT19937, random number generator
index 852d4d5..9e31f18 100644 (file)
     ;; the ordinary unbound marker for this.
     sb!pcl::..slot-unbound..))
 
-(defparameter *static-functions*
+(defparameter *static-funs*
   '(length
     sb!kernel:two-arg-+
     sb!kernel:two-arg--
index da2966d..cb26b35 100644 (file)
@@ -11,7 +11,7 @@
 
 (in-package "SB!VM")
 
-(define-vop (static-function-template)
+(define-vop (static-fun-template)
   (:save-p t)
   (:policy :safe)
   (:variant-vars function)
@@ -24,8 +24,8 @@
 
 (eval-when (: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)
@@ -36,7 +36,7 @@
       (moves `(move ,(car dst) ,(car src))))
     (moves)))
 
-(defun static-function-template-vop (num-args num-results)
+(defun static-fun-template-vop (num-args num-results)
   (unless (and (<= num-args register-arg-count)
               (<= num-results register-arg-count))
     (error "either too many args (~D) or too many results (~D); max = ~D"
@@ -67,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))
              `(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))))
+                                     (static-fun-offset function))))
         ,(collect ((bindings) (links))
                   (do ((temp (temp-names) (cdr temp))
                        (name 'values (gensym))
 ) ; 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
index 1dbdc40..1e9e532 100644 (file)
@@ -79,4 +79,4 @@
     (inst jmp :ne loop)
     DONE))
 
-(define-static-function length (object) :translate length)
+(define-static-fun length (object) :translate length)
index dc5e79a..2eafd4f 100644 (file)
@@ -18,4 +18,4 @@
 ;;; for internal versions, especially for internal versions off the
 ;;; main CVS branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
 
-"0.pre7.81"
+"0.pre7.82"