X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fpcl%2Fcompiler-support.lisp;h=e00deee1111d1498d278580d633b2dd0ed0a8d8e;hb=d25e3478acccec70402ff32554669a982be8e281;hp=58e462f73542a670a38db5c8468171eb5e10130d;hpb=1a405defbd26ca767e71494b67127fcc00a8af12;p=sbcl.git diff --git a/src/pcl/compiler-support.lisp b/src/pcl/compiler-support.lisp index 58e462f..e00deee 100644 --- a/src/pcl/compiler-support.lisp +++ b/src/pcl/compiler-support.lisp @@ -69,13 +69,6 @@ (define-function-name-syntax ,name ,@body) (pushnew ',name sb-pcl::*internal-pcl-generalized-fun-name-symbols*))) -(define-internal-pcl-function-name-syntax sb-pcl::class-predicate (list) - (when (cdr list) - (destructuring-bind (name &rest rest) (cdr list) - (when (and (symbolp name) - (null rest)) - (values t name))))) - (define-internal-pcl-function-name-syntax sb-pcl::slot-accessor (list) (when (= (length list) 4) (destructuring-bind (class slot rwb) (cdr list) @@ -105,3 +98,44 @@ new-value) (defsetf sb-pcl::random-documentation sb-pcl::set-random-documentation) + +;;;; SLOT-VALUE optimizations + +(defknown slot-value (t symbol) t (any)) +(defknown sb-pcl::set-slot-value (t symbol t) t (any)) + +(defun pcl-boot-state-complete-p () + (eq 'sb-pcl::complete sb-pcl::*boot-state*)) + +;;; These essentially duplicate what the compiler-macros in slots.lisp +;;; do, but catch more cases. We retain the compiler-macros since they +;;; can be used during the build, and because they catch common cases +;;; slightly more cheaply then the transforms. (Transforms add new +;;; lambdas, which requires more work by the compiler.) + +(deftransform slot-value ((object slot-name)) + "optimize" + (let (c-slot-name) + (if (and (pcl-boot-state-complete-p) + (constant-lvar-p slot-name) + (setf c-slot-name (lvar-value slot-name)) + (sb-pcl::interned-symbol-p c-slot-name)) + `(sb-pcl::accessor-slot-value object ',c-slot-name) + (give-up-ir1-transform "Slot name is not constant.")))) + +(deftransform sb-pcl::set-slot-value ((object slot-name new-value) + (t symbol t) t + ;; Safe code wants to check the + ;; type, and the global accessor + ;; won't do that. Also see the + ;; comment in the + ;; compiler-macro. + :policy (< safety 3)) + "optimize" + (let (c-slot-name) + (if (and (pcl-boot-state-complete-p) + (constant-lvar-p slot-name) + (setf c-slot-name (lvar-value slot-name)) + (sb-pcl::interned-symbol-p c-slot-name)) + `(sb-pcl::accessor-set-slot-value object ',c-slot-name new-value) + (give-up-ir1-transform "Slot name is not constant."))))