1 ;;;; allocation VOPs for the HPPA
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.
15 (define-vop (list-or-list*)
16 (:args (things :more t))
17 (:temporary (:scs (descriptor-reg) :type list) ptr)
18 (:temporary (:scs (descriptor-reg)) temp)
19 (:temporary (:scs (descriptor-reg) :type list :to (:result 0) :target result)
22 (:results (result :scs (descriptor-reg)))
28 (move null-tn result))
30 (move (tn-ref-tn things) result))
33 ((store-car (tn list &optional (slot cons-car-slot))
34 `(let ((reg (sc-case ,tn
35 ((any-reg descriptor-reg zero null) ,tn)
37 (load-stack-tn temp ,tn)
39 (storew reg ,list ,slot list-pointer-lowtag))))
40 (let* ((dx-p (node-stack-allocate-p node))
41 (cons-cells (if star (1- num) num))
42 (alloc (* (pad-data-block cons-size) cons-cells)))
43 (pseudo-atomic (:extra (if dx-p 0 alloc))
46 (set-lowtag list-pointer-lowtag (if dx-p csp-tn alloc-tn) res)
48 (inst addi alloc csp-tn csp-tn))
50 (dotimes (i (1- cons-cells))
51 (store-car (tn-ref-tn things) ptr)
52 (setf things (tn-ref-across things))
53 (inst addi (pad-data-block cons-size) ptr ptr)
55 (- cons-cdr-slot cons-size)
57 (store-car (tn-ref-tn things) ptr)
59 (setf things (tn-ref-across things))
60 (store-car (tn-ref-tn things) ptr cons-cdr-slot))
63 cons-cdr-slot list-pointer-lowtag)))
64 (aver (null (tn-ref-across things)))
65 (move res result))))))))
67 (define-vop (list list-or-list*)
70 (define-vop (list* list-or-list*)
74 ;;;; Special purpose inline allocators.
76 (define-vop (allocate-vector-on-heap)
77 (:args (type :scs (unsigned-reg))
78 (length :scs (any-reg))
79 (words :scs (any-reg)))
80 (:arg-types positive-fixnum
83 (:temporary (:sc non-descriptor-reg) bytes)
84 (:results (result :scs (descriptor-reg) :from :load))
87 (inst addi (+ lowtag-mask
88 (* vector-data-offset n-word-bytes)) words bytes)
89 (inst dep 0 31 n-lowtag-bits bytes)
91 (set-lowtag other-pointer-lowtag alloc-tn result)
92 (inst add bytes alloc-tn alloc-tn)
93 (storew type result 0 other-pointer-lowtag)
94 (storew length result vector-length-slot other-pointer-lowtag))))
96 (define-vop (allocate-vector-on-stack)
97 (:args (type :scs (unsigned-reg))
98 (length :scs (any-reg))
99 (words :scs (any-reg)))
100 (:arg-types positive-fixnum
103 (:temporary (:sc non-descriptor-reg) bytes temp)
104 (:results (result :scs (descriptor-reg) :from :load))
107 (inst addi (+ lowtag-mask
108 (* vector-data-offset n-word-bytes)) words bytes)
109 (inst dep 0 31 n-lowtag-bits bytes)
110 ;; FIXME: It would be good to check for stack overflow here.
113 (set-lowtag other-pointer-lowtag csp-tn result)
114 (inst addi (* vector-data-offset n-word-bytes) csp-tn temp)
115 (inst add bytes csp-tn csp-tn)
116 (storew type result 0 other-pointer-lowtag)
117 (storew length result vector-length-slot other-pointer-lowtag)
118 (let ((loop (gen-label)))
120 (inst comb :<> temp csp-tn loop :nullify t)
121 (inst stwm zero-tn n-word-bytes temp)))))
123 (define-vop (allocate-code-object)
124 (:args (boxed-arg :scs (any-reg))
125 (unboxed-arg :scs (any-reg)))
126 (:results (result :scs (descriptor-reg)))
127 (:temporary (:scs (non-descriptor-reg)) ndescr)
128 (:temporary (:scs (any-reg) :from (:argument 0)) boxed)
129 (:temporary (:scs (non-descriptor-reg) :from (:argument 1)) unboxed)
131 (inst addi (fixnumize (1+ code-trace-table-offset-slot)) boxed-arg boxed)
132 (inst dep 0 31 n-lowtag-bits boxed)
133 (inst srl unboxed-arg word-shift unboxed)
134 (inst addi lowtag-mask unboxed unboxed)
135 (inst dep 0 31 n-lowtag-bits unboxed)
136 (inst sll boxed (- n-widetag-bits word-shift) ndescr)
137 (inst addi code-header-widetag ndescr ndescr)
139 (set-lowtag other-pointer-lowtag alloc-tn result)
140 (inst add alloc-tn boxed alloc-tn)
141 (inst add alloc-tn unboxed alloc-tn)
142 (storew ndescr result 0 other-pointer-lowtag)
143 (storew unboxed result code-code-size-slot other-pointer-lowtag)
144 (storew null-tn result code-entry-points-slot other-pointer-lowtag)
145 (storew null-tn result code-debug-info-slot other-pointer-lowtag))))
147 (define-vop (make-fdefn)
148 (:translate make-fdefn)
150 (:args (name :scs (descriptor-reg) :to :eval))
151 (:temporary (:scs (non-descriptor-reg)) temp)
152 (:results (result :scs (descriptor-reg) :from :argument))
154 (with-fixed-allocation (result nil temp fdefn-widetag fdefn-size nil)
155 (inst li (make-fixup "undefined_tramp" :foreign) temp)
156 (storew name result fdefn-name-slot other-pointer-lowtag)
157 (storew null-tn result fdefn-fun-slot other-pointer-lowtag)
158 (storew temp result fdefn-raw-addr-slot other-pointer-lowtag))))
160 (define-vop (make-closure)
161 (:args (function :to :save :scs (descriptor-reg)))
162 (:info length stack-allocate-p)
163 (:temporary (:scs (non-descriptor-reg)) temp)
164 (:results (result :scs (descriptor-reg)))
166 (with-fixed-allocation
167 (result nil temp closure-header-widetag
168 (+ length closure-info-offset)
169 stack-allocate-p :lowtag fun-pointer-lowtag)
170 (storew function result closure-fun-slot fun-pointer-lowtag))))
172 ;;; The compiler likes to be able to directly make value cells.
173 (define-vop (make-value-cell)
174 (:args (value :to :save :scs (descriptor-reg any-reg)))
175 (:temporary (:scs (non-descriptor-reg)) temp)
176 (:results (result :scs (descriptor-reg)))
177 (:info stack-allocate-p)
179 (with-fixed-allocation
180 (result nil temp value-cell-header-widetag value-cell-size stack-allocate-p)
181 (storew value result value-cell-value-slot other-pointer-lowtag))))
183 ;;;; Automatic allocators for primitive objects.
185 (define-vop (make-unbound-marker)
187 (:results (result :scs (any-reg)))
189 (inst li unbound-marker-widetag result)))
191 (define-vop (make-funcallable-instance-tramp)
193 (:results (result :scs (any-reg)))
195 (inst li (make-fixup 'funcallable-instance-tramp :assembly-routine)
198 (define-vop (fixed-alloc)
200 (:info name words type lowtag stack-allocate-p)
202 (:results (result :scs (descriptor-reg)))
203 (:temporary (:scs (non-descriptor-reg)) temp)
205 (with-fixed-allocation
206 (result nil temp type words stack-allocate-p
207 :lowtag lowtag :maybe-write t))))
209 (define-vop (var-alloc)
210 (:args (extra :scs (any-reg)))
211 (:arg-types positive-fixnum)
212 (:info name words type lowtag)
214 (:results (result :scs (descriptor-reg)))
215 (:temporary (:scs (any-reg)) bytes)
216 (:temporary (:scs (non-descriptor-reg)) header)
218 (inst addi (* (1+ words) n-word-bytes) extra bytes)
219 (inst sll bytes (- n-widetag-bits 2) header)
220 (inst addi (+ (ash -2 n-widetag-bits) type) header header)
221 (inst dep 0 31 n-lowtag-bits bytes)
223 (set-lowtag lowtag alloc-tn result)
224 (storew header result 0 lowtag)
225 (inst add alloc-tn bytes alloc-tn))))