Changeset 168
- Timestamp:
- Dec 31, 2003, 3:11:15 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/ccl/level-1/l1-clos-boot.lisp (modified) (26 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ccl/level-1/l1-clos-boot.lisp
r151 r168 824 824 (dolist (msp (%method-specializers m2) t) 825 825 (let ((spec (%pop specs))) 826 (unless (if (typep msp 'eql-specializer) 827 (and (typep spec 'eql-specializer) 828 (eql (eql-specializer-object msp) 829 (eql-specializer-object spec))) 830 (eq msp spec)) 826 (unless (eq msp spec) 831 827 (return nil)))))))) 832 828 … … 910 906 (index 0)) 911 907 (clear-accessor-method-offsets (%gf-dispatch-table-gf dt) method) 912 (if ( listp class) ; eql specializer913 (setq class (class-of ( secondclass))))908 (if (typep class 'eql-specializer) ; eql specializer 909 (setq class (class-of (eql-specializer-object class)))) 914 910 (while (%i< index size) 915 911 (let* ((wrapper (%gf-dispatch-table-ref dt index)) … … 1251 1247 (defun compute-cpl (class) 1252 1248 (flet ((%real-class-cpl (class) 1253 (or (%class .cpl class)1249 (or (%class-cpl class) 1254 1250 (compute-cpl class)))) 1255 1251 (let* ((predecessors (list (list class))) candidates cpl) 1256 (dolist (sup (%class .local-supers class))1252 (dolist (sup (%class-direct-superclasses class)) 1257 1253 (when (symbolp sup) (report-bad-arg sup 'class)) 1258 1254 (dolist (sup (%real-class-cpl sup)) 1259 1255 (unless (assq sup predecessors) (push (list sup) predecessors)))) 1260 1256 (labels ((compute-predecessors (class table) 1261 (dolist (sup (%class .local-supers class) table)1257 (dolist (sup (%class-direct-superclasses class) table) 1262 1258 (compute-predecessors sup table) 1263 1259 ;(push class (cdr (assq sup table))) … … 1273 1269 (setq candidates (nremove c candidates)) 1274 1270 (setq cpl (%rplacd c cpl)) 1275 (dolist (sup (%class .local-supers (%car c)))1271 (dolist (sup (%class-direct-superclasses (%car c))) 1276 1272 (when (setq c (assq sup predecessors)) (push c candidates))) 1277 1273 (return)))) … … 1329 1325 (setq sup (%car supers)) 1330 1326 (if (symbolp sup) (setf (%car supers) (setq sup (find-class (%car supers))))) 1331 (unless (or (eq sup *t-class*) (std-class-p sup))1327 #+nil (unless (or (eq sup *t-class*) (std-class-p sup)) 1332 1328 (error "~a is not of type ~a" sup 'std-class)))) 1333 1329 (setf (%class.local-supers class) supers) … … 1367 1363 (let* ((wrapper (instance.class-wrapper thing))) 1368 1364 (if (uvectorp wrapper) ;; ???? - probably ok 1369 wrapper)))) 1365 wrapper)) 1366 (if (typep thing 'macptr) 1367 (foreign-instance-class-wrapper thing)))) 1370 1368 1371 1369 … … 1443 1441 (make-standard-class 'forward-referenced-class *class-class*)) 1444 1442 1445 ;; Has to be a standard class because code currently depends on T being the 1446 ;; only non-standard class in the CPL of a standard class. 1447 (defvar *function-class* (make-standard-class 'function *t-class*)) 1443 (defvar *function-class* (make-built-in-class 'function)) 1448 1444 1449 1445 ;Right now, all functions are compiled. … … 1534 1530 (defvar *slot-vector-class* (make-built-in-class 'slot-vector (find-class 'gvector))) 1535 1531 1536 (make-built-in-class 'macptr) 1532 (defvar *macptr-class* (make-built-in-class 'macptr)) 1533 (defvar *foreign-standard-object-class* 1534 (make-standard-class 'foreign-standard-object 1535 *standard-object-class* *macptr-class*)) 1536 1537 (defvar *foreign-class-class* 1538 (make-standard-class 'foreign-class *foreign-standard-object-class* *slots-class*)) 1539 1537 1540 (make-built-in-class 'population) 1538 1541 (make-built-in-class 'pool) … … 1705 1708 1706 1709 1710 (def-accessors (foreign-object-domain) %svref 1711 nil ; foreign-object-domain 1712 foreign-object-domain-index ; 1..n 1713 foreign-object-domain-name ; 1714 foreign-object-domain-recognize ; function: is object one of ours ? 1715 foreign-object-domain-class-of ; function: returns class of object 1716 foreign-object-domain-classp ; function: true if object is a class 1717 foreign-object-domain-instance-class-wrapper ; function: returns wrapper of object's class 1718 foreign-object-domain-class-own-wrapper ; function: returns class own wrapper if class 1719 foreign-object-domain-slots-vector ; returns slots vector of object or nil 1720 ) 1721 1722 (defun make-foreign-object-domain (&key index name recognize class-of classp 1723 instance-class-wrapper 1724 class-own-wrapper 1725 slots-vector) 1726 (%istruct 'foreign-object-domain index name recognize class-of classp 1727 instance-class-wrapper class-own-wrapper slots-vector)) 1728 1729 (let* ((n-foreign-object-domains 0) 1730 (foreign-object-domains (make-array 10)) 1731 (foreign-object-domain-lock (make-lock))) 1732 (defun register-foreign-object-domain (name 1733 &key 1734 recognize 1735 class-of 1736 classp 1737 instance-class-wrapper 1738 class-own-wrapper 1739 slots-vector) 1740 (with-lock-grabbed (foreign-object-domain-lock) 1741 (dotimes (i n-foreign-object-domains) 1742 (let* ((already (svref foreign-object-domains i))) 1743 (when (eq name (foreign-object-domain-name already)) 1744 (setf (foreign-object-domain-recognize already) recognize 1745 (foreign-object-domain-class-of already) class-of 1746 (foreign-object-domain-classp already) classp 1747 (foreign-object-domain-instance-class-wrapper already) 1748 instance-class-wrapper 1749 (foreign-object-domain-class-own-wrapper already) 1750 class-own-wrapper 1751 (foreign-object-domain-slots-vector already) slots-vector) 1752 (return-from register-foreign-object-domain i)))) 1753 (let* ((i n-foreign-object-domains) 1754 (new (make-foreign-object-domain :index i 1755 :name name 1756 :recognize recognize 1757 :class-of class-of 1758 :classp classp 1759 :instance-class-wrapper 1760 instance-class-wrapper 1761 :class-own-wrapper 1762 class-own-wrapper 1763 :slots-vector 1764 slots-vector))) 1765 (incf n-foreign-object-domains) 1766 (if (= i (length foreign-object-domains)) 1767 (setq foreign-object-domains (%extend-vector i foreign-object-domains (* i 2)))) 1768 (setf (svref foreign-object-domains i) new) 1769 i))) 1770 (defun foreign-class-of (p) 1771 (funcall (foreign-object-domain-class-of (svref foreign-object-domains (%macptr-domain p))) p)) 1772 (defun foreign-classp (p) 1773 (funcall (foreign-object-domain-classp (svref foreign-object-domains (%macptr-domain p))) p)) 1774 (defun foreign-instance-class-wrapper (p) 1775 (funcall (foreign-object-domain-instance-class-wrapper (svref foreign-object-domains (%macptr-domain p))) p)) 1776 (defun foreign-class-own-wrapper (p) 1777 (funcall (foreign-object-domain-class-own-wrapper (svref foreign-object-domains (%macptr-domain p))) p)) 1778 (defun foreign-slots-vector (p) 1779 (funcall (foreign-object-domain-slots-vector (svref foreign-object-domains (%macptr-domain p))) p)) 1780 (defun classify-foreign-pointer (p) 1781 (do* ((i (1- n-foreign-object-domains) (1- i))) 1782 ((zerop i) (error "this can't happen")) 1783 (when (funcall (foreign-object-domain-recognize (svref foreign-object-domains i)) p) 1784 (%set-macptr-domain p i) 1785 (return p))))) 1786 1787 (defun constantly (x) 1788 #'(lambda (&rest ignore) 1789 (declare (dynamic-extent ignore) 1790 (ignore ignore)) 1791 x)) 1792 1793 (register-foreign-object-domain :unclassified 1794 :recognize #'(lambda (p) 1795 (declare (ignore p)) 1796 (error "Shouldn't happen")) 1797 :class-of #'(lambda (p) 1798 (foreign-class-of 1799 (classify-foreign-pointer p))) 1800 :classp #'(lambda (p) 1801 (foreign-classp 1802 (classify-foreign-pointer p))) 1803 :instance-class-wrapper 1804 #'(lambda (p) 1805 (foreign-instance-class-wrapper 1806 (classify-foreign-pointer p))) 1807 :class-own-wrapper 1808 #'(lambda (p) 1809 (foreign-class-own-wrapper 1810 (classify-foreign-pointer p))) 1811 :slots-vector 1812 #'(lambda (p) 1813 (foreign-slots-vector 1814 (classify-foreign-pointer p)))) 1815 1816 ;;; "Raw" macptrs, that aren't recognized as "standard foreign objects" 1817 ;;; in some other domain, should always be recognized as such (and this 1818 ;;; pretty much has to be domain #1.) 1819 1820 (register-foreign-object-domain :raw 1821 :recognize #'true 1822 :class-of (constantly *macptr-class*) 1823 :classp #'false 1824 :instance-class-wrapper 1825 (constantly (%class.own-wrapper *macptr-class*)) 1826 :class-own-wrapper #'false 1827 :slots-vector #'false) 1828 1707 1829 1708 1830 (defparameter *class-table* … … 1725 1847 (map-subtag ppc32::subtag-double-float double-float) 1726 1848 (map-subtag ppc32::subtag-single-float short-float) 1727 (map-subtag ppc32::subtag-macptr macptr)1728 1849 (map-subtag ppc32::subtag-dead-macptr ivector) 1729 1850 (map-subtag ppc32::subtag-code-vector code-vector) … … 1757 1878 (setf (%svref v ppc32::subtag-arrayH) *array-class*) 1758 1879 ; These need to be special-cased: 1880 (setf (%svref v ppc32::subtag-macptr) #'foreign-class-of) 1759 1881 (setf (%svref v ppc32::subtag-character) 1760 1882 #'(lambda (c) (let* ((code (%char-code c))) … … 1838 1960 ; Can't use typep at bootstrapping time. 1839 1961 (defun classp (x) 1840 (let ((wrapper (standard-object-p x))) 1841 (and wrapper 1842 (let ((super (%wrapper-class wrapper))) 1843 (memq *class-class* (%inited-class-cpl super t)))))) 1962 (or (and (typep x 'macptr) (foreign-classp x)) ; often faster 1963 (let ((wrapper (standard-object-p x))) 1964 (or 1965 (and wrapper 1966 (let ((super (%wrapper-class wrapper))) 1967 (memq *class-class* (%inited-class-cpl super t)))))))) 1844 1968 1845 1969 (set-type-predicate 'class 'classp) … … 1953 2077 (unless (setq s (pop ss)) 1954 2078 (err)) 1955 (unless (if (typep s 'eql-specializer) 1956 (and (typep spec 'eql-specializer) 1957 (eql (eql-specializer-object s) 1958 (eql-specializer-object spec))) 1959 (eq s spec)) 2079 (unless (eq s spec) 1960 2080 (return)))))))) 1961 2081 … … 2077 2197 (find name slots :key #'%slot-definition-name)) 2078 2198 2079 (defun %std-slot-value-using-class (instance slotd) 2199 (declaim (inline %std-slot-vector-value)) 2200 2201 (defun %std-slot-vector-value (slot-vector slotd) 2080 2202 (let* ((loc (standard-effective-slot-definition.location slotd))) 2081 (typecase loc 2082 (fixnum 2083 (standard-instance-instance-location-access instance loc)) 2084 (cons 2085 (let* ((val (%cdr loc))) 2086 (if (eq val (%slot-unbound-marker)) 2087 (slot-unbound (class-of instance) instance (standard-effective-slot-definition.name slotd)) 2203 (symbol-macrolet ((instance (slot-vector.instance slot-vector))) 2204 (typecase loc 2205 (fixnum 2206 (%slot-ref slot-vector loc)) 2207 (cons 2208 (let* ((val (%cdr loc))) 2209 (if (eq val (%slot-unbound-marker)) 2210 (slot-unbound (class-of instance) instance (standard-effective-slot-definition.name slotd)) 2088 2211 val))) 2089 2212 (t 2090 2213 (error "Slot definition ~s has invalid location ~s (allocation ~s)." 2091 slotd loc (slot-definition-allocation slotd)))))) 2214 slotd loc (slot-definition-allocation slotd))))))) 2215 2092 2216 2093 2217 (defmethod slot-value-using-class ((class standard-class) 2094 2218 instance 2095 2219 (slotd standard-effective-slot-definition)) 2096 (%std-slot-v alue-using-class instanceslotd))2220 (%std-slot-vector-value (instance.slots instance) slotd)) 2097 2221 2098 2222 (defun %maybe-std-slot-value-using-class (class instance slotd) … … 2102 2226 (instance.class-wrapper slotd)) 2103 2227 (eq *standard-class-wrapper* (instance.class-wrapper class))) 2104 (%std-slot-v alue-using-class instanceslotd)2228 (%std-slot-vector-value (instance.slots instance) slotd) 2105 2229 (slot-value-using-class class instance slotd))) 2106 2230 2107 2108 2109 (defun %std-setf-slot-value-using-class (instance slotd new) 2231 2232 (declaim (inline %set-std-slot-vector-value)) 2233 2234 (defun %set-std-slot-vector-value (slot-vector slotd new) 2110 2235 (let* ((loc (standard-effective-slot-definition.location slotd)) 2111 2236 (type (standard-effective-slot-definition.type slotd)) … … 2116 2241 (typecase loc 2117 2242 (fixnum 2118 (setf 2119 (standard-instance-instance-location-access instance loc) new)) 2243 (setf (%svref slot-vector loc) new)) 2120 2244 (cons 2121 2245 (setf (%cdr loc) new)) … … 2124 2248 slotd loc (slot-definition-allocation slotd)))))) 2125 2249 2250 2126 2251 (defmethod (setf slot-value-using-class) 2127 2252 (new … … 2129 2254 instance 2130 2255 (slotd standard-effective-slot-definition)) 2131 (%s td-setf-slot-value-using-class instanceslotd new))2256 (%set-std-slot-vector-value (instance.slots instance) slotd new)) 2132 2257 2133 2258 … … 2138 2263 (instance.class-wrapper slotd)) 2139 2264 (eq *standard-class-wrapper* (instance.class-wrapper class))) 2140 (%s td-setf-slot-value-using-class instanceslotd new)2265 (%set-std-slot-vector-value (instance.slots instance) slotd new) 2141 2266 (setf (slot-value-using-class class instance slotd) new))) 2142 2267 … … 2144 2269 instance 2145 2270 (slotd standard-effective-slot-definition)) 2146 (let* ((loc (standard-effective-slot-definition.location slotd))) 2147 (typecase loc 2148 (fixnum 2149 (standard-generic-function-instance-location-access instance loc)) 2150 (cons 2151 (let* ((val (%cdr loc))) 2152 (if (eq val (%slot-unbound-marker)) 2153 (slot-unbound class instance (standard-effective-slot-definition.name slotd)) 2154 val))) 2155 (t 2156 (error "Slot definition ~s has invalid location ~s (allocation ~s)." 2157 slotd loc (slot-definition-allocation slotd)))))) 2271 (%std-slot-vector-value (gf.slots instance) slotd)) 2158 2272 2159 2273 (defmethod (setf slot-value-using-class) … … 2162 2276 instance 2163 2277 (slotd standard-effective-slot-definition)) 2164 (let* ((loc (standard-effective-slot-definition.location slotd)) 2165 (type (standard-effective-slot-definition.type slotd))) 2166 (if (and type (not (eq type t))) 2167 (unless (or (eq new (%slot-unbound-marker)) (typep new type)) 2168 (setq new (require-type new type)))) 2169 (typecase loc 2170 (fixnum 2171 (setf 2172 (standard-generic-function-instance-location-access instance loc) new)) 2173 (cons 2174 (setf (%cdr loc) new)) 2175 (t 2176 (error "Slot definition ~s has invalid location ~s (allocation ~s)." 2177 slotd loc (slot-definition-allocation slotd)))))) 2178 2179 2278 (%set-std-slot-vector-value (gf.slots instance) slotd new)) 2180 2279 2181 2280 (defun slot-value (instance slot-name) … … 2221 2320 (slot-missing class instance name 'slot-makunbound)))) 2222 2321 2223 2322 (defun %std-slot-vector-boundp (slot-vector slotd) 2323 (let* ((loc (standard-effective-slot-definition.location slotd))) 2324 (typecase loc 2325 (fixnum 2326 (not (eq (%svref slot-vector loc) (%slot-unbound-marker)))) 2327 (cons 2328 (not (eq (%cdr loc) (%slot-unbound-marker)))) 2329 (t 2330 (error "Slot definition ~s has invalid location ~s (allocation ~s)." 2331 slotd loc (slot-definition-allocation slotd)))))) 2224 2332 2225 2333 (defmethod slot-boundp-using-class ((class standard-class) 2226 2334 instance 2227 2335 (slotd standard-effective-slot-definition)) 2228 (if (eql 0 (%wrapper-instance-slots (instance.class-wrapper instance))) 2229 (progn 2230 (update-obsolete-instance instance) 2231 (slot-boundp instance (standard-effective-slot-definition.name slotd))) 2232 (let* ((loc (standard-effective-slot-definition.location slotd))) 2233 (typecase loc 2234 (fixnum 2235 (not (eq (%standard-instance-instance-location-access instance loc) 2236 (%slot-unbound-marker)))) 2237 (cons 2238 (not (eq (%cdr loc) (%slot-unbound-marker)))) 2239 (t 2240 (error "Slot definition ~s has invalid location ~s (allocation ~s)." 2241 slotd loc (slot-definition-allocation slotd))))))) 2336 (%std-slot-vector-boundp (instance.slots instance) slotd)) 2242 2337 2243 2338 (defmethod slot-boundp-using-class ((class funcallable-standard-class) 2244 2339 instance 2245 2340 (slotd standard-effective-slot-definition)) 2246 (if (eql 0 (%wrapper-instance-slots (gf.instance.class-wrapper instance))) 2247 (progn 2248 (update-obsolete-instance instance) 2249 (slot-boundp instance (standard-effective-slot-definition.name slotd))) 2250 (let* ((loc (standard-effective-slot-definition.location slotd))) 2251 (typecase loc 2252 (fixnum 2253 (not (eq (%standard-generic-function-instance-location-access instance loc) 2254 (%slot-unbound-marker)))) 2255 (cons 2256 (not (eq (%cdr loc) (%slot-unbound-marker)))) 2257 (t 2258 (error "Slot definition ~s has invalid location ~s (allocation ~s)." 2259 slotd loc (slot-definition-allocation slotd))))))) 2341 (%std-slot-vector-boundp (gf.slots instance) slotd)) 2260 2342 2261 2343 … … 2280 2362 2281 2363 (defun slot-id-value (instance slot-id) 2282 (let* ((wrapper (if (eq (typecode instance) ppc32::subtag-instance) 2283 (instance.class-wrapper instance) 2364 (let* ((wrapper (or (standard-object-p instance) 2284 2365 (%class.own-wrapper (class-of instance))))) 2285 2366 (funcall (%wrapper-slot-id-value wrapper) instance slot-id))) 2286 2367 2287 2368 (defun set-slot-id-value (instance slot-id value) 2288 (let* ((wrapper (if (eq (typecode instance) ppc32::subtag-instance) 2289 (instance.class-wrapper instance) 2369 (let* ((wrapper (or (standard-object-p instance) 2290 2370 (%class.own-wrapper (class-of instance))))) 2291 2371 (funcall (%wrapper-set-slot-id-value wrapper) instance slot-id value))) … … 2478 2558 (let* ((old-size (uvsize old-instance-slots)) 2479 2559 (new-size (uvsize new-instance-slots))) 2480 (declare (fix mum old-size new-size))2560 (declare (fixnum old-size new-size)) 2481 2561 (dotimes (i old-size) 2482 2562 (declare (fixnum i)) … … 2909 2989 (class-precedence-list class))) 2910 2990 2911 (defmethod class-precedence-list ((class standard-class))2991 (defmethod class-precedence-list ((class class)) 2912 2992 (%inited-class-cpl class)) 2913 2993 2914 (defmethod class-precedence-list ((class class)) 2915 (or (%class.cpl class) 2916 (error "~s has no class-precedence-list." class))) 2994 2917 2995 2918 2996 … … 3072 3150 (nreverse res)) 3073 3151 (mapcar '%slot-definition-name 3074 (extract-instance-effective-slotds 3075 ( %class-slots (class-of object)))))))3152 (extract-instance-effective-slotds 3153 (class-of object)))))) 3076 3154 (values 3077 3155 (let* ((form (gethash class-name *make-load-form-saving-slots-hash*)))
Note:
See TracChangeset
for help on using the changeset viewer.
