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 (if (typep alloc
'(signed-byte 14))
49 (inst ldo alloc csp-tn csp-tn
)
50 ;; FIXME: We have TEMP available, so can do an
51 ;; LIDL / LDO / ADD sequence here instead of
53 (error "VOP LIST-OR-LIST* can't stack-allocate more than 511 CONSes at once")))
55 (dotimes (i (1- cons-cells
))
56 (store-car (tn-ref-tn things
) ptr
)
57 (setf things
(tn-ref-across things
))
58 (inst addi
(pad-data-block cons-size
) ptr ptr
)
60 (- cons-cdr-slot cons-size
)
62 (store-car (tn-ref-tn things
) ptr
)
64 (setf things
(tn-ref-across things
))
65 (store-car (tn-ref-tn things
) ptr cons-cdr-slot
))
68 cons-cdr-slot list-pointer-lowtag
)))
69 (aver (null (tn-ref-across things
)))
70 (move res result
))))))))
72 (define-vop (list list-or-list
*)
75 (define-vop (list* list-or-list
*)
79 ;;;; Special purpose inline allocators.
81 (define-vop (allocate-vector-on-heap)
82 (:args
(type :scs
(unsigned-reg))
83 (length :scs
(any-reg))
84 (words :scs
(any-reg)))
85 (:arg-types positive-fixnum
88 (:temporary
(:sc non-descriptor-reg
) bytes
)
89 (:results
(result :scs
(descriptor-reg) :from
:load
))
90 #!-stack-allocatable-vectors
91 (:translate allocate-vector
)
94 (inst addi
(+ lowtag-mask
95 (* vector-data-offset n-word-bytes
)) words bytes
)
96 (inst dep
0 31 n-lowtag-bits bytes
)
98 (set-lowtag other-pointer-lowtag alloc-tn result
)
99 (inst add bytes alloc-tn alloc-tn
)
100 (storew type result
0 other-pointer-lowtag
)
101 (storew length result vector-length-slot other-pointer-lowtag
))))
103 (define-vop (allocate-vector-on-stack)
104 (:args
(type :scs
(unsigned-reg))
105 (length :scs
(any-reg))
106 (words :scs
(any-reg)))
107 (:arg-types positive-fixnum
110 (:temporary
(:sc non-descriptor-reg
) bytes temp
)
111 (:results
(result :scs
(descriptor-reg) :from
:load
))
114 (inst addi
(+ lowtag-mask
115 (* vector-data-offset n-word-bytes
)) words bytes
)
116 (inst dep
0 31 n-lowtag-bits bytes
)
117 ;; FIXME: It would be good to check for stack overflow here.
120 (set-lowtag other-pointer-lowtag csp-tn result
)
121 (inst addi
(* vector-data-offset n-word-bytes
) csp-tn temp
)
122 (inst add bytes csp-tn csp-tn
)
123 (storew type result
0 other-pointer-lowtag
)
124 (storew length result vector-length-slot other-pointer-lowtag
)
125 (let ((loop (gen-label)))
127 (inst comb
:<> temp csp-tn loop
:nullify t
)
128 (inst stwm zero-tn n-word-bytes temp
)))))
130 (define-vop (allocate-code-object)
131 (:args
(boxed-arg :scs
(any-reg))
132 (unboxed-arg :scs
(any-reg)))
133 (:results
(result :scs
(descriptor-reg)))
134 (:temporary
(:scs
(non-descriptor-reg)) ndescr
)
135 (:temporary
(:scs
(any-reg) :from
(:argument
0)) boxed
)
136 (:temporary
(:scs
(non-descriptor-reg)) unboxed
)
138 (inst addi
(fixnumize (1+ code-constants-offset
)) boxed-arg boxed
)
139 (inst dep
0 31 n-lowtag-bits boxed
)
140 (inst srl unboxed-arg word-shift unboxed
)
141 (inst addi lowtag-mask unboxed unboxed
)
142 (inst dep
0 31 n-lowtag-bits unboxed
)
143 (inst sll boxed
(- n-widetag-bits word-shift
) ndescr
)
144 (inst addi code-header-widetag ndescr ndescr
)
146 (set-lowtag other-pointer-lowtag alloc-tn result
)
147 (inst add alloc-tn boxed alloc-tn
)
148 (inst add alloc-tn unboxed alloc-tn
)
149 (storew ndescr result
0 other-pointer-lowtag
)
150 (storew unboxed-arg result code-code-size-slot other-pointer-lowtag
)
151 (storew null-tn result code-debug-info-slot other-pointer-lowtag
))))
153 (define-vop (make-fdefn)
154 (:translate make-fdefn
)
156 (:args
(name :scs
(descriptor-reg) :to
:eval
))
157 (:temporary
(:scs
(non-descriptor-reg)) temp
)
158 (:results
(result :scs
(descriptor-reg) :from
:argument
))
160 (with-fixed-allocation (result nil temp fdefn-widetag fdefn-size nil
)
161 (inst li
(make-fixup 'undefined-tramp
:assembly-routine
) temp
)
162 (storew name result fdefn-name-slot other-pointer-lowtag
)
163 (storew null-tn result fdefn-fun-slot other-pointer-lowtag
)
164 (storew temp result fdefn-raw-addr-slot other-pointer-lowtag
))))
166 (define-vop (make-closure)
167 (:args
(function :to
:save
:scs
(descriptor-reg)))
168 (:info length stack-allocate-p
)
169 (:temporary
(:scs
(non-descriptor-reg)) temp
)
170 (:results
(result :scs
(descriptor-reg)))
172 (with-fixed-allocation
173 (result nil temp closure-header-widetag
174 (+ length closure-info-offset
)
175 stack-allocate-p
:lowtag fun-pointer-lowtag
)
176 (storew function result closure-fun-slot fun-pointer-lowtag
))))
178 ;;; The compiler likes to be able to directly make value cells.
179 (define-vop (make-value-cell)
180 (:args
(value :to
:save
:scs
(descriptor-reg any-reg
)))
181 (:temporary
(:scs
(non-descriptor-reg)) temp
)
182 (:results
(result :scs
(descriptor-reg)))
183 (:info stack-allocate-p
)
185 (with-fixed-allocation
186 (result nil temp value-cell-header-widetag value-cell-size stack-allocate-p
)
187 (storew value result value-cell-value-slot other-pointer-lowtag
))))
189 ;;;; Automatic allocators for primitive objects.
191 (define-vop (make-unbound-marker)
193 (:results
(result :scs
(descriptor-reg any-reg
)))
195 (inst li unbound-marker-widetag result
)))
197 (define-vop (make-funcallable-instance-tramp)
199 (:results
(result :scs
(any-reg)))
201 (inst li
(make-fixup 'funcallable-instance-tramp
:assembly-routine
)
204 (define-vop (fixed-alloc)
206 (:info name words type lowtag stack-allocate-p
)
208 (:results
(result :scs
(descriptor-reg)))
209 (:temporary
(:scs
(non-descriptor-reg)) temp
)
211 (with-fixed-allocation
212 (result nil temp type words stack-allocate-p
213 :lowtag lowtag
:maybe-write t
))))
215 (define-vop (var-alloc)
216 (:args
(extra :scs
(any-reg)))
217 (:arg-types positive-fixnum
)
218 (:info name words type lowtag
)
220 (:results
(result :scs
(descriptor-reg)))
221 (:temporary
(:scs
(any-reg)) bytes
)
222 (:temporary
(:scs
(non-descriptor-reg)) header
)
224 (inst addi
(* (1+ words
) n-word-bytes
) extra bytes
)
225 (inst sll bytes
(- n-widetag-bits
2) header
)
226 (inst addi
(+ (ash -
2 n-widetag-bits
) type
) header header
)
227 (inst dep
0 31 n-lowtag-bits bytes
)
229 (set-lowtag lowtag alloc-tn result
)
230 (storew header result
0 lowtag
)
231 (inst add alloc-tn bytes alloc-tn
))))