From: Nikodemus S. <nik...@ra...> - 2008-05-31 19:20:09
|
Making FIND-CONSTANT like this allows a bit more coalesing: ;;; Return a LEAF which represents the specified constant object. If ;;; the object is not in *CONSTANTS*, then we create a new constant ;;; LEAF and enter it. If we are producing a fasl file, make sure that ;;; MAKE-LOAD-FORM gets used on any parts of the constant that it ;;; needs to be. (defun find-constant (object) (labels ((make-it () (when (producing-fasl-file) (maybe-emit-make-load-forms object)) (make-constant :value object :%source-name '.anonymous. :type (ctype-of object) :where-from :defined)) (coalescep (x) ;; Object types to coalesce: things where an EQUAL hash table does TRT wrt. ;; CLHS 3.2.4.2.2. (if (consp x) (unless (maybe-cyclic-p x) (do ((y x (cdr y))) ((atom y) (coalescep y)) (unless (coalescep (car y)) (return nil)))) ;; Amusingly enough, we see CLAMBDAs --among other things-- ;; here, from compiling things like %ALLOCATE-CLOSUREs forms. ;; No point in stuffing them in the hash-table. (and (not (leaf-p x)) (not (node-p x)) (typep x '(or symbol number character instance pathname (simple-array character (*)) simple-bit-vector)))))) (if (and (boundp '*constants*) (coalescep object)) (or (gethash object *constants*) (setf (gethash object *constants*) (make-it))) (make-it)))) Addressing OPTIMIZATIONS #34 among other things. I'm mainly wondering if there are potential problems with it that I am not seeing? Cheers, -- Nikodemus |