Changeset 586


Ignore:
Timestamp:
Feb 28, 2004, 1:22:22 AM (21 years ago)
Author:
Gary Byers
Message:

Don't cache things involving certain MEMBER-CTYPEs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ccl/level-1/l1-typesys.lisp

    r477 r586  
    13661366  (defconstant type-cache-mask (1- type-cache-size)))
    13671367
     1368;;; We can get in trouble if we try to cache certain kinds of ctypes,
     1369;;; notably MEMBER types which refer to objects which might
     1370;;; be stack-allocated or might be EQUAL without being EQL.
     1371(defun cacheable-ctype-p (ctype)
     1372  (case (%svref ctype 0)
     1373    (member-ctype
     1374     (dolist (m (member-ctype-members ctype) t)
     1375       (when (or (typep m 'cons)
     1376                 (typep m 'array))
     1377         nil)))
     1378    (union-ctype
     1379     (every #'cacheable-ctype-p (union-ctype-types ctype)))
     1380    (intersection-ctype
     1381     (every #'cacheable-ctype-p (intersection-ctype-types ctype)))
     1382    (array-ctype
     1383     (cacheable-ctype-p (array-ctype-element-type ctype)))
     1384    ((values-ctype function-ctype)
     1385     (and (every #'cacheable-ctype-p (values-ctype-required ctype))
     1386          (every #'cacheable-ctype-p (values-ctype-optional ctype))
     1387          (let* ((rest (values-ctype-rest ctype)))
     1388            (or (null rest) (cacheable-ctype-p rest)))
     1389          (every #'(lambda (info)
     1390                     (cacheable-ctype-p (key-info-type info)))
     1391                 (values-ctype-keywords ctype))
     1392          (or (not (eq (%svref ctype 0) 'function-ctype))
     1393              (let* ((result (function-ctype-returns ctype)))
     1394                (or (null result)
     1395                    (cacheable-ctype-p result))))))
     1396    (t t)))
     1397               
     1398     
     1399   
     1400
    13681401(defun hash-type-specifier (spec)
    13691402  (logand (sxhash spec) type-cache-mask))
     
    14021435                  (let* ((ctype (values-specifier-type-internal spec)))
    14031436                    (if ctype
    1404                       (setf (svref type-cache-specs idx) (copy-tree spec)       ; in case it was stack-consed
    1405                             (svref type-cache-ctypes idx) ctype)
     1437                      (progn
     1438                        (when (cacheable-ctype-p ctype)
     1439                          (setf (svref type-cache-specs idx) (copy-tree spec)       ; in case it was stack-consed
     1440                                (svref type-cache-ctypes idx) ctype))
     1441                        ctype)
    14061442                      (make-unknown-ctype :specifier spec)))))
    14071443              (values-specifier-type-internal spec)))
Note: See TracChangeset for help on using the changeset viewer.