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-type
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-type
22 :header instance-header-type
23 :alloc-trans %make-instance)
26 (define-primitive-object (bignum :lowtag other-pointer-type
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-type
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-type
45 :header single-float-type)
46 (value :c-type "float"))
48 (define-primitive-object (double-float :lowtag other-pointer-type
49 :header double-float-type)
51 (value :c-type "double" :length 2))
54 (define-primitive-object (long-float :lowtag other-pointer-type
55 :header long-float-type)
57 (value :c-type "long double" :length #!+x86 3 #!+sparc 4))
59 (define-primitive-object (complex :type complex
60 :lowtag other-pointer-type
62 :alloc-trans %make-complex)
64 :ref-known (flushable movable)
68 :ref-known (flushable movable)
72 (define-primitive-object (array :lowtag other-pointer-type
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-type
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-type
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-type
135 (name :ref-trans fdefn-name)
136 (function :type (or function null) :ref-trans fdefn-function)
137 (raw-addr :c-type #!-alpha "char *" #!+alpha "u32"))
139 (define-primitive-object (function :type function
140 :lowtag function-pointer-type
141 :header function-header-type)
142 #!-(or gengc x86) (self :ref-trans %function-self
143 :set-trans (setf %function-self))
145 ;; KLUDGE: There's no :SET-KNOWN, :SET-TRANS, :REF-KNOWN, or
146 ;; :REF-TRANS here in this case. Instead, there's separate
147 ;; DEFKNOWN/DEFINE-VOP/DEFTRANSFORM stuff in
148 ;; compiler/x86/system.lisp to define and declare them by
149 ;; hand. I don't know why this is, but that's (basically)
150 ;; the way it was done in CMU CL, and it works. (It's not
151 ;; exactly the same way it was done in CMU CL in that CMU
152 ;; CL's allows duplicate DEFKNOWNs, blithely overwriting any
153 ;; previous data associated with the previous DEFKNOWN, and
154 ;; that property was used to mask the definitions here. In
155 ;; SBCL as of 0.6.12.64 that's not allowed -- too confusing!
156 ;; -- so we have to explicitly suppress the DEFKNOWNish
157 ;; stuff here in order to allow this old hack to work in the
158 ;; new world. -- WHN 2001-08-82
160 #!+gengc (entry-point :c-type "char *")
161 (next :type (or function null)
162 :ref-known (flushable)
163 :ref-trans %function-next
165 :set-trans (setf %function-next))
166 (name :ref-known (flushable)
167 :ref-trans %function-name
169 :set-trans (setf %function-name))
170 (arglist :ref-known (flushable)
171 :ref-trans %function-arglist
173 :set-trans (setf %function-arglist))
174 (type :ref-known (flushable)
175 :ref-trans %function-type
177 :set-trans (setf %function-type))
178 (code :rest-p t :c-type "unsigned char"))
181 (define-primitive-object (return-pc :lowtag other-pointer-type :header t)
182 (return-point :c-type "unsigned char" :rest-p t))
184 (define-primitive-object (closure :lowtag function-pointer-type
185 :header closure-header-type)
186 #!-gengc (function :init :arg :ref-trans %closure-function)
187 #!+gengc (entry-point :c-type "char *")
190 (define-primitive-object (funcallable-instance
191 :lowtag function-pointer-type
192 :header funcallable-instance-header-type
193 :alloc-trans %make-funcallable-instance)
196 :ref-known (flushable) :ref-trans %funcallable-instance-function
197 :set-known (unsafe) :set-trans (setf %funcallable-instance-function))
200 :ref-known (flushable) :ref-trans %funcallable-instance-function
201 ;; KLUDGE: There's no :SET-KNOWN or :SET-TRANS in this case.
202 ;; Instead, later in compiler/x86/system.lisp there's a separate
203 ;; DEFKNOWN for (SETF %FUNCALLABLE-INSTANCE-FUNCTION), and a weird
204 ;; unexplained DEFTRANSFORM from (SETF %FUNCTION-INSTANCE-FUNCTION)
205 ;; into (SETF %FUNCTION-SELF). The #!+X86 wrapped around this case
206 ;; is a literal translation of the old CMU CL implementation into
207 ;; the new world of sbcl-0.6.12.63, where multiple DEFKNOWNs for
208 ;; the same operator cause an error (instead of silently deleting
209 ;; all information associated with the old DEFKNOWN, as before).
210 ;; It's definitely not very clean, with too many #!+ conditionals,
211 ;; too little documentation, and an implicit assumption that GENGC
212 ;; and X86 are mutually exclusive, but I have more urgent things to
213 ;; clean up right now, so I've just left it as a literal
214 ;; translation without trying to fix it. -- WHN 2001-08-02
216 #!+gengc (entry-point :c-type "char *")
217 (lexenv :ref-known (flushable) :ref-trans %funcallable-instance-lexenv
218 :set-known (unsafe) :set-trans (setf %funcallable-instance-lexenv))
220 :ref-known (flushable) :ref-trans %funcallable-instance-layout
221 :set-known (unsafe) :set-trans (setf %funcallable-instance-layout))
224 (define-primitive-object (value-cell :lowtag other-pointer-type
225 :header value-cell-header-type
226 :alloc-trans make-value-cell)
227 (value :set-trans value-cell-set
229 :ref-trans value-cell-ref
230 :ref-known (flushable)
234 (define-primitive-object (sap :lowtag other-pointer-type
237 (pointer :c-type "char *" :length 2))
240 (define-primitive-object (sap :lowtag other-pointer-type
242 (pointer :c-type "char *"))
245 (define-primitive-object (weak-pointer :type weak-pointer
246 :lowtag other-pointer-type
247 :header weak-pointer-type
248 :alloc-trans make-weak-pointer)
249 (value :ref-trans sb!c::%weak-pointer-value :ref-known (flushable)
251 (broken :type (member t nil)
252 :ref-trans sb!c::%weak-pointer-broken :ref-known (flushable)
254 (next :c-type #!-alpha "struct weak_pointer *" #!+alpha "u32"))
256 ;;;; other non-heap data blocks
258 (define-primitive-object (binding)
262 (define-primitive-object (unwind-block)
263 (current-uwp :c-type #!-alpha "struct unwind_block *" #!+alpha "u32")
264 (current-cont :c-type #!-alpha "lispobj *" #!+alpha "u32")
268 (define-primitive-object (catch-block)
269 (current-uwp :c-type #!-alpha "struct unwind_block *" #!+alpha "u32")
270 (current-cont :c-type #!-alpha "lispobj *" #!+alpha "u32")
274 (previous-catch :c-type #!-alpha "struct catch_block *" #!+alpha "u32")
277 ;;; (For an explanation of this, see the comments at the definition of
278 ;;; KLUDGE-NONDETERMINISTIC-CATCH-BLOCK-SIZE.)
279 (aver (= sb!vm::kludge-nondeterministic-catch-block-size catch-block-size))
284 (defknown %make-symbol (index simple-string) symbol
288 (defknown symbol-hash (symbol) index
292 (defknown symbol-hash (symbol) (integer 0 #.*target-most-positive-fixnum*)
295 (define-primitive-object (symbol :lowtag other-pointer-type
296 :header symbol-header-type
298 #!-(or gengc x86) make-symbol
299 #!+gengc %make-symbol)
300 (value :set-trans %set-symbol-value
302 #!-(or gengc x86) unused
303 #!+gengc (hash :init :arg)
305 (plist :ref-trans symbol-plist
306 :set-trans %set-symbol-plist
308 (name :ref-trans symbol-name :init :arg)
309 (package :ref-trans symbol-package
310 :set-trans %set-symbol-package
313 (define-primitive-object (complex-single-float
314 :lowtag other-pointer-type
315 :header complex-single-float-type)
316 (real :c-type "float")
317 (imag :c-type "float"))
319 (define-primitive-object (complex-double-float
320 :lowtag other-pointer-type
321 :header complex-double-float-type)
323 (real :c-type "double" :length 2)
324 (imag :c-type "double" :length 2))
327 (define-primitive-object (complex-long-float
328 :lowtag other-pointer-type
329 :header complex-long-float-type)
331 (real :c-type "long double" :length #!+x86 3 #!+sparc 4)
332 (imag :c-type "long double" :length #!+x86 3 #!+sparc 4))