X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fpcl%2Fdlisp.lisp;h=2639eb635639c32f61b64a411f8e88a017e9e8ac;hb=0c7ffa8fb85a94482814835c9f28abfd0400ab99;hp=8e769f36d2ca2fbd2e40bb957f50d0fa4c6f6d38;hpb=a530bbe337109d898d5b4a001fc8f1afa3b5dc39;p=sbcl.git diff --git a/src/pcl/dlisp.lisp b/src/pcl/dlisp.lisp index 8e769f3..2639eb6 100644 --- a/src/pcl/dlisp.lisp +++ b/src/pcl/dlisp.lisp @@ -22,15 +22,12 @@ ;;;; specification. (in-package "SB-PCL") - -(sb-int:file-comment - "$Header$") -;;; This file is (almost) functionally equivalent to dlap.lisp, but easier to -;;; read. +;;; This file is (almost) functionally equivalent to dlap.lisp, but +;;; easier to read. -;;; Might generate faster code, too, depending on the compiler and whether an -;;; implementation-specific lap assembler was used. +;;; Might generate faster code, too, depending on the compiler and +;;; whether an implementation-specific lap assembler was used. (defun emit-one-class-reader (class-slot-p) (emit-reader/writer :reader 1 class-slot-p)) @@ -109,7 +106,7 @@ ,form))))) (values (if *precompiling-lap* `#',lambda - (compile-lambda lambda)) + (compile nil lambda)) nil))) ;;; note on implementation for CMU 17 and later (including SBCL): @@ -158,7 +155,7 @@ (eq wrapper wrapper-1))))) ,@(if readp `((let ((value ,read-form)) - (unless (eq value *slot-unbound*) + (unless (eq value +slot-unbound+) (return-from access value)))) `((return-from access (setf ,read-form ,(car arglist)))))) (funcall miss-fn ,@arglist)))))) @@ -166,19 +163,26 @@ (defun emit-slot-read-form (class-slot-p index slots) (if class-slot-p `(cdr ,index) - `(%instance-ref ,slots ,index))) + `(clos-slots-ref ,slots ,index))) + +(defun emit-slot-write-form (class-slot-p index slots value) + (if class-slot-p + `(setf (cdr ,index) ,value) + `(and ,slots (setf (clos-slots-ref ,slots ,index) ,value)))) (defun emit-boundp-check (value-form miss-fn arglist) `(let ((value ,value-form)) - (if (eq value *slot-unbound*) + (if (eq value +slot-unbound+) (funcall ,miss-fn ,@arglist) value))) (defun emit-slot-access (reader/writer class-slot-p slots index miss-fn arglist) - (let ((read-form (emit-slot-read-form class-slot-p index slots))) + (let ((read-form (emit-slot-read-form class-slot-p index slots)) + (write-form (emit-slot-write-form + class-slot-p index slots (car arglist)))) (ecase reader/writer (:reader (emit-boundp-check read-form miss-fn arglist)) - (:writer `(setf ,read-form ,(car arglist)))))) + (:writer write-form)))) (defmacro emit-reader/writer-macro (reader/writer 1-or-2-class class-slot-p) (let ((*emit-function-p* nil) @@ -249,15 +253,15 @@ (defun emit-dlap (args metatypes hit miss value-reg &optional slot-regs) (let* ((index -1) - (wrapper-bindings (mapcan #'(lambda (arg mt) - (unless (eq mt 't) - (incf index) - `((,(intern (format nil - "WRAPPER-~D" - index) - *pcl-package*) - ,(emit-fetch-wrapper mt arg 'miss - (pop slot-regs)))))) + (wrapper-bindings (mapcan (lambda (arg mt) + (unless (eq mt t) + (incf index) + `((,(intern (format nil + "WRAPPER-~D" + index) + *pcl-package*) + ,(emit-fetch-wrapper + mt arg 'miss (pop slot-regs)))))) args metatypes)) (wrappers (mapcar #'car wrapper-bindings))) (declare (fixnum index)) @@ -337,13 +341,15 @@ (let ((location primary) (next-location 0)) (declare (fixnum location next-location)) (block search - (loop (setq next-location (the fixnum (+ location ,cache-line-size))) + (loop (setq next-location + (the fixnum (+ location ,cache-line-size))) (when (and ,@(mapcar - #'(lambda (wrapper) - `(eq ,wrapper - (cache-vector-ref cache-vector - (setq location - (the fixnum (+ location 1)))))) + (lambda (wrapper) + `(eq ,wrapper + (cache-vector-ref + cache-vector + (setq location + (the fixnum (+ location 1)))))) wrappers)) ,@(when value `((setq location (the fixnum (+ location 1))) @@ -355,8 +361,9 @@ (when (= location primary) (dolist (entry overflow) (let ((entry-wrappers (car entry))) - (when (and ,@(mapcar #'(lambda (wrapper) - `(eq ,wrapper (pop entry-wrappers))) + (when (and ,@(mapcar (lambda (wrapper) + `(eq ,wrapper + (pop entry-wrappers))) wrappers)) ,@(when value `((setq ,value (cdr entry)))) @@ -379,19 +386,20 @@ `(progn ,@(let ((adds 0) (len (length wrappers))) (declare (fixnum adds len)) - (mapcar #'(lambda (wrapper) - `(let ((wrapper-cache-no (wrapper-cache-number-vector-ref - ,wrapper field))) - (declare (fixnum wrapper-cache-no)) - (when (zerop wrapper-cache-no) (go ,miss-label)) - (setq primary (the fixnum (+ primary wrapper-cache-no))) - ,@(progn - (incf adds) - (when (or (zerop (mod adds wrapper-cache-number-adds-ok)) - (eql adds len)) - `((setq primary - ,(let ((form `(logand primary mask))) - `(the fixnum ,form)))))))) + (mapcar (lambda (wrapper) + `(let ((wrapper-cache-no (wrapper-cache-number-vector-ref + ,wrapper field))) + (declare (fixnum wrapper-cache-no)) + (when (zerop wrapper-cache-no) (go ,miss-label)) + (setq primary (the fixnum (+ primary wrapper-cache-no))) + ,@(progn + (incf adds) + (when (or (zerop (mod adds + wrapper-cache-number-adds-ok)) + (eql adds len)) + `((setq primary + ,(let ((form `(logand primary mask))) + `(the fixnum ,form)))))))) wrappers)))) ;;; CMU17 (and SBCL) note: Since STD-INSTANCE-P is weakened in the CMU/SBCL