1 ;;;; machine-independent aspects of the object representation
3 ;;;; This software is part of the SBCL system. See the README file for
6 ;;;; This software is derived from the CMU CL system, which was
7 ;;;; written at Carnegie Mellon University and released into the
8 ;;;; public domain. The software is in the public domain and is
9 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
10 ;;;; files for more information.
14 ;;;; the primitive objects themselves
16 (define-primitive-object (cons :lowtag list-pointer-lowtag
18 (car :ref-trans car :set-trans sb!c::%rplaca :init :arg)
19 (cdr :ref-trans cdr :set-trans sb!c::%rplacd :init :arg))
21 (define-primitive-object (instance :lowtag instance-pointer-lowtag
22 :widetag instance-header-widetag
23 :alloc-trans %make-instance)
26 (define-primitive-object (bignum :lowtag other-pointer-lowtag
27 :widetag bignum-widetag
28 :alloc-trans sb!bignum::%allocate-bignum)
29 (digits :rest-p t :c-type #!-alpha "long" #!+alpha "u32"))
31 (define-primitive-object (ratio :type ratio
32 :lowtag other-pointer-lowtag
33 :widetag ratio-widetag
34 :alloc-trans %make-ratio)
35 (numerator :type integer
36 :ref-known (flushable movable)
39 (denominator :type integer
40 :ref-known (flushable movable)
41 :ref-trans %denominator
44 (define-primitive-object (single-float :lowtag other-pointer-lowtag
45 :widetag single-float-widetag)
46 (value :c-type "float"))
48 (define-primitive-object (double-float :lowtag other-pointer-lowtag
49 :widetag double-float-widetag)
51 (value :c-type "double" :length 2))
54 (define-primitive-object (long-float :lowtag other-pointer-lowtag
55 :widetag long-float-widetag)
57 (value :c-type "long double" :length #!+x86 3 #!+sparc 4))
59 (define-primitive-object (complex :type complex
60 :lowtag other-pointer-lowtag
61 :widetag complex-widetag
62 :alloc-trans %make-complex)
64 :ref-known (flushable movable)
68 :ref-known (flushable movable)
72 (define-primitive-object (array :lowtag other-pointer-lowtag
74 (fill-pointer :type index
75 :ref-trans %array-fill-pointer
76 :ref-known (flushable foldable)
77 :set-trans (setf %array-fill-pointer)
79 (fill-pointer-p :type (member t nil)
80 :ref-trans %array-fill-pointer-p
81 :ref-known (flushable foldable)
82 :set-trans (setf %array-fill-pointer-p)
85 :ref-trans %array-available-elements
86 :ref-known (flushable foldable)
87 :set-trans (setf %array-available-elements)
90 :ref-trans %array-data-vector
91 :ref-known (flushable foldable)
92 :set-trans (setf %array-data-vector)
94 (displacement :type (or index null)
95 :ref-trans %array-displacement
96 :ref-known (flushable foldable)
97 :set-trans (setf %array-displacement)
99 (displaced-p :type (member t nil)
100 :ref-trans %array-displaced-p
101 :ref-known (flushable foldable)
102 :set-trans (setf %array-displaced-p)
104 (dimensions :rest-p t))
106 (define-primitive-object (vector :type vector
107 :lowtag other-pointer-lowtag
109 (length :ref-trans sb!c::vector-length
111 (data :rest-p t :c-type #!-alpha "unsigned long" #!+alpha "u32"))
113 (define-primitive-object (code :type code-component
114 :lowtag other-pointer-lowtag
116 (code-size :type index
117 :ref-known (flushable movable)
118 :ref-trans %code-code-size)
119 (entry-points :type (or function null)
120 :ref-known (flushable)
121 :ref-trans %code-entry-points
123 :set-trans (setf %code-entry-points))
125 :ref-known (flushable)
126 :ref-trans %code-debug-info
128 :set-trans (setf %code-debug-info))
130 (constants :rest-p t))
132 (define-primitive-object (fdefn :type fdefn
133 :lowtag other-pointer-lowtag
134 :widetag fdefn-widetag)
135 (name :ref-trans fdefn-name)
136 (fun :type (or function null) :ref-trans fdefn-fun)
137 (raw-addr :c-type #!-alpha "char *" #!+alpha "u32"))
139 ;;; a simple function (as opposed to hairier things like closures
140 ;;; which are also subtypes of Common Lisp's FUNCTION type)
141 (define-primitive-object (simple-fun :type function
142 :lowtag fun-pointer-lowtag
143 :widetag simple-fun-header-widetag)
144 #!-x86 (self :ref-trans %simple-fun-self
145 :set-trans (setf %simple-fun-self))
147 ;; KLUDGE: There's no :SET-KNOWN, :SET-TRANS, :REF-KNOWN, or
148 ;; :REF-TRANS here in this case. Instead, there's separate
149 ;; DEFKNOWN/DEFINE-VOP/DEFTRANSFORM stuff in
150 ;; compiler/x86/system.lisp to define and declare them by
151 ;; hand. I don't know why this is, but that's (basically)
152 ;; the way it was done in CMU CL, and it works. (It's not
153 ;; exactly the same way it was done in CMU CL in that CMU
154 ;; CL's allows duplicate DEFKNOWNs, blithely overwriting any
155 ;; previous data associated with the previous DEFKNOWN, and
156 ;; that property was used to mask the definitions here. In
157 ;; SBCL as of 0.6.12.64 that's not allowed -- too confusing!
158 ;; -- so we have to explicitly suppress the DEFKNOWNish
159 ;; stuff here in order to allow this old hack to work in the
160 ;; new world. -- WHN 2001-08-82
162 (next :type (or function null)
163 :ref-known (flushable)
164 :ref-trans %simple-fun-next
166 :set-trans (setf %simple-fun-next))
167 (name :ref-known (flushable)
168 :ref-trans %simple-fun-name
170 :set-trans (setf %simple-fun-name))
171 (arglist :ref-known (flushable)
172 :ref-trans %simple-fun-arglist
174 :set-trans (setf %simple-fun-arglist))
175 (type :ref-known (flushable)
176 :ref-trans %simple-fun-type
178 :set-trans (setf %simple-fun-type))
179 ;; the SB!C::DEBUG-FUN object corresponding to this object, or NIL for none
180 #+nil ; FIXME: doesn't work (gotcha, lowly maintenoid!) See notes on bug 137.
181 (debug-fun :ref-known (flushable)
182 :ref-trans %simple-fun-debug-fun
184 :set-trans (setf %simple-fun-debug-fun))
185 (code :rest-p t :c-type "unsigned char"))
187 (define-primitive-object (return-pc :lowtag other-pointer-lowtag :widetag t)
188 (return-point :c-type "unsigned char" :rest-p t))
190 (define-primitive-object (closure :lowtag fun-pointer-lowtag
191 :widetag closure-header-widetag)
192 (fun :init :arg :ref-trans %closure-fun)
195 (define-primitive-object (funcallable-instance
196 :lowtag fun-pointer-lowtag
197 :widetag funcallable-instance-header-widetag
198 :alloc-trans %make-funcallable-instance)
201 :ref-known (flushable) :ref-trans %funcallable-instance-fun
202 :set-known (unsafe) :set-trans (setf %funcallable-instance-fun))
205 :ref-known (flushable) :ref-trans %funcallable-instance-fun
206 ;; KLUDGE: There's no :SET-KNOWN or :SET-TRANS in this case.
207 ;; Instead, later in compiler/x86/system.lisp there's a separate
208 ;; DEFKNOWN for (SETF %FUNCALLABLE-INSTANCE-FUN), and a weird
209 ;; unexplained DEFTRANSFORM from (SETF %SIMPLE-FUN-INSTANCE-FUN)
210 ;; into (SETF %SIMPLE-FUN-SELF). The #!+X86 wrapped around this case
211 ;; is a literal translation of the old CMU CL implementation into
212 ;; the new world of sbcl-0.6.12.63, where multiple DEFKNOWNs for
213 ;; the same operator cause an error (instead of silently deleting
214 ;; all information associated with the old DEFKNOWN, as before).
215 ;; It's definitely not very clean, with too many #!+ conditionals and
216 ;; too little documentation, but I have more urgent things to
217 ;; clean up right now, so I've just left it as a literal
218 ;; translation without trying to fix it. -- WHN 2001-08-02
220 (lexenv :ref-known (flushable) :ref-trans %funcallable-instance-lexenv
221 :set-known (unsafe) :set-trans (setf %funcallable-instance-lexenv))
223 :ref-known (flushable) :ref-trans %funcallable-instance-layout
224 :set-known (unsafe) :set-trans (setf %funcallable-instance-layout))
227 (define-primitive-object (value-cell :lowtag other-pointer-lowtag
228 :widetag value-cell-header-widetag
229 :alloc-trans make-value-cell)
230 (value :set-trans value-cell-set
232 :ref-trans value-cell-ref
233 :ref-known (flushable)
237 (define-primitive-object (sap :lowtag other-pointer-lowtag
238 :widetag sap-widetag)
240 (pointer :c-type "char *" :length 2))
243 (define-primitive-object (sap :lowtag other-pointer-lowtag
244 :widetag sap-widetag)
245 (pointer :c-type "char *"))
248 (define-primitive-object (weak-pointer :type weak-pointer
249 :lowtag other-pointer-lowtag
250 :widetag weak-pointer-widetag
251 :alloc-trans make-weak-pointer)
252 (value :ref-trans sb!c::%weak-pointer-value :ref-known (flushable)
254 (broken :type (member t nil)
255 :ref-trans sb!c::%weak-pointer-broken :ref-known (flushable)
257 (next :c-type #!-alpha "struct weak_pointer *" #!+alpha "u32"))
259 ;;;; other non-heap data blocks
261 (define-primitive-object (binding)
265 (define-primitive-object (unwind-block)
266 (current-uwp :c-type #!-alpha "struct unwind_block *" #!+alpha "u32")
267 (current-cont :c-type #!-alpha "lispobj *" #!+alpha "u32")
271 (define-primitive-object (catch-block)
272 (current-uwp :c-type #!-alpha "struct unwind_block *" #!+alpha "u32")
273 (current-cont :c-type #!-alpha "lispobj *" #!+alpha "u32")
277 (previous-catch :c-type #!-alpha "struct catch_block *" #!+alpha "u32")
280 ;;; (For an explanation of this, see the comments at the definition of
281 ;;; KLUDGE-NONDETERMINISTIC-CATCH-BLOCK-SIZE.)
282 (aver (= kludge-nondeterministic-catch-block-size catch-block-size))
287 (defknown symbol-hash (symbol) (integer 0 #.*target-most-positive-fixnum*)
290 (define-primitive-object (symbol :lowtag other-pointer-lowtag
291 :widetag symbol-header-widetag
292 #!-x86 :alloc-trans #!-x86 make-symbol)
293 (value :set-trans %set-symbol-value
296 (plist :ref-trans symbol-plist
297 :set-trans %set-symbol-plist
299 (name :ref-trans symbol-name :init :arg)
300 (package :ref-trans symbol-package
301 :set-trans %set-symbol-package
304 (define-primitive-object (complex-single-float
305 :lowtag other-pointer-lowtag
306 :widetag complex-single-float-widetag)
307 (real :c-type "float")
308 (imag :c-type "float"))
310 (define-primitive-object (complex-double-float
311 :lowtag other-pointer-lowtag
312 :widetag complex-double-float-widetag)
314 (real :c-type "double" :length 2)
315 (imag :c-type "double" :length 2))
318 (define-primitive-object (complex-long-float
319 :lowtag other-pointer-lowtag
320 :widetag complex-long-float-widetag)
322 (real :c-type "long double" :length #!+x86 3 #!+sparc 4)
323 (imag :c-type "long double" :length #!+x86 3 #!+sparc 4))