1 ;;;; allocation VOPs for the ARM
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 (define-vop (list-or-list*)
15 (:args
(things :more t
:scs
(control-stack)))
16 (:temporary
(:scs
(descriptor-reg) :type list
) ptr
)
17 (:temporary
(:scs
(descriptor-reg) :type list
:to
(:result
0) :target result
)
19 (:temporary
(:sc non-descriptor-reg
) pa-flag temp
)
20 (:temporary
(:scs
(interior-reg)) lip
)
22 (:results
(result :scs
(descriptor-reg)))
28 (move result null-tn
))
30 (move result
(tn-ref-tn things
)))
36 ((any-reg descriptor-reg null
)
39 (load-stack-tn temp
,tn
)
41 (let* ((cons-cells (if star
(1- num
) num
))
42 (alloc (* (pad-data-block cons-size
) cons-cells
)))
43 (pseudo-atomic (pa-flag)
44 (allocation res alloc list-pointer-lowtag
46 :stack-allocate-p
(node-stack-allocate-p node
)
49 (dotimes (i (1- cons-cells
))
50 (storew (maybe-load (tn-ref-tn things
)) ptr
51 cons-car-slot list-pointer-lowtag
)
52 (setf things
(tn-ref-across things
))
53 (inst add ptr ptr
(pad-data-block cons-size
))
55 (- cons-cdr-slot cons-size
)
57 (storew (maybe-load (tn-ref-tn things
)) ptr
58 cons-car-slot list-pointer-lowtag
)
60 (maybe-load (tn-ref-tn (tn-ref-across things
)))
62 ptr cons-cdr-slot list-pointer-lowtag
))
63 (move result res
)))))))
65 (define-vop (list list-or-list
*)
68 (define-vop (list* list-or-list
*)
71 ;;;; Special purpose inline allocators.
73 (define-vop (allocate-code-object)
74 (:args
(boxed-arg :scs
(any-reg))
75 (unboxed-arg :scs
(any-reg)))
76 (:results
(result :scs
(descriptor-reg)))
77 (:temporary
(:scs
(non-descriptor-reg)) ndescr
)
78 (:temporary
(:scs
(non-descriptor-reg)) size
)
79 (:temporary
(:scs
(any-reg) :from
(:argument
0)) boxed
)
80 (:temporary
(:scs
(non-descriptor-reg)) unboxed
)
81 (:temporary
(:sc non-descriptor-reg
) pa-flag
)
82 (:temporary
(:scs
(interior-reg)) lip
)
84 (inst add boxed boxed-arg
(fixnumize (1+ code-constants-offset
)))
85 (inst and boxed boxed
(bic-mask lowtag-mask
))
86 (inst lsr unboxed unboxed-arg word-shift
)
87 (inst add unboxed unboxed lowtag-mask
)
88 (inst and unboxed unboxed
(bic-mask lowtag-mask
))
89 (inst lsl ndescr boxed
(- n-widetag-bits word-shift
))
90 (inst orr ndescr ndescr code-header-widetag
)
91 (inst add size boxed unboxed
)
92 (pseudo-atomic (pa-flag)
93 (allocation result size other-pointer-lowtag
:flag-tn pa-flag
:lip lip
)
94 (storew ndescr result
0 other-pointer-lowtag
)
95 (storew unboxed-arg result code-code-size-slot other-pointer-lowtag
)
96 (storew null-tn result code-debug-info-slot other-pointer-lowtag
))))
98 (define-vop (make-fdefn)
99 (:args
(name :scs
(descriptor-reg) :to
:eval
))
100 (:temporary
(:sc non-descriptor-reg
) pa-flag temp
)
101 (:temporary
(:scs
(interior-reg)) lip
)
102 (:results
(result :scs
(descriptor-reg) :from
:argument
))
104 (:translate make-fdefn
)
106 (with-fixed-allocation (result pa-flag fdefn-widetag fdefn-size
:lip lip
)
107 (load-inline-constant temp
'(:fixup undefined-tramp
:assembly-routine
) lip
)
108 (storew name result fdefn-name-slot other-pointer-lowtag
)
109 (storew null-tn result fdefn-fun-slot other-pointer-lowtag
)
110 (storew temp result fdefn-raw-addr-slot other-pointer-lowtag
))))
112 (define-vop (make-closure)
113 (:args
(function :to
:save
:scs
(descriptor-reg)))
114 (:info length stack-allocate-p
)
115 (:temporary
(:sc non-descriptor-reg
) pa-flag
)
116 (:temporary
(:scs
(interior-reg)) lip
)
117 (:results
(result :scs
(descriptor-reg)))
119 (let* ((size (+ length closure-info-offset
))
120 (alloc-size (pad-data-block size
)))
121 (pseudo-atomic (pa-flag)
122 (allocation result alloc-size
125 :stack-allocate-p stack-allocate-p
127 (load-immediate-word pa-flag
129 (ash (1- size
) n-widetag-bits
)
130 closure-header-widetag
))
131 (storew pa-flag result
0 fun-pointer-lowtag
)
132 (storew function result closure-fun-slot fun-pointer-lowtag
)))))
134 ;;; The compiler likes to be able to directly make value cells.
136 (define-vop (make-value-cell)
137 (:args
(value :to
:save
:scs
(descriptor-reg any-reg
)))
138 (:temporary
(:sc non-descriptor-reg
) pa-flag
)
139 (:temporary
(:scs
(interior-reg)) lip
)
140 (:info stack-allocate-p
)
141 (:results
(result :scs
(descriptor-reg)))
143 (with-fixed-allocation (result pa-flag value-cell-widetag
144 value-cell-size
:stack-allocate-p stack-allocate-p
146 (storew value result value-cell-value-slot other-pointer-lowtag
))))
148 ;;;; Automatic allocators for primitive objects.
150 (define-vop (make-unbound-marker)
152 (:results
(result :scs
(descriptor-reg any-reg
)))
154 (inst mov result unbound-marker-widetag
)))
156 (define-vop (make-funcallable-instance-tramp)
158 (:temporary
(:scs
(interior-reg)) lip
)
159 (:results
(result :scs
(any-reg)))
161 (load-inline-constant result
'(:fixup funcallable-instance-tramp
:assembly-routine
) lip
)))
163 (define-vop (fixed-alloc)
165 (:info name words type lowtag stack-allocate-p
)
167 (:results
(result :scs
(descriptor-reg)))
168 (:temporary
(:sc non-descriptor-reg
) pa-flag
)
169 (:temporary
(:scs
(interior-reg)) lip
)
171 (with-fixed-allocation (result pa-flag type words
173 :stack-allocate-p stack-allocate-p
176 (define-vop (var-alloc)
177 (:args
(extra :scs
(any-reg)))
178 (:arg-types positive-fixnum
)
179 (:info name words type lowtag
)
181 (:results
(result :scs
(descriptor-reg)))
182 (:temporary
(:scs
(any-reg) :from
:argument
) bytes
)
183 (:temporary
(:sc non-descriptor-reg
) pa-flag header
)
184 (:temporary
(:scs
(interior-reg)) lip
)
186 ;; Build the object header, assuming that the header was in WORDS
187 ;; but should not be in the header
188 (inst lsl bytes extra
(- word-shift n-fixnum-tag-bits
))
189 (inst add bytes bytes
(add-sub-immediate (* (1- words
) n-word-bytes
)))
190 (inst lsl header bytes
(- n-widetag-bits word-shift
))
191 (inst add header header type
)
192 ;; Add the object header to the allocation size and round up to
193 ;; the allocation granularity
194 (inst add bytes bytes
(* 2 n-word-bytes
))
195 (inst and bytes bytes
(bic-mask lowtag-mask
))
196 ;; Allocate the object and set its header
197 (pseudo-atomic (pa-flag)
198 (allocation result bytes lowtag
:flag-tn pa-flag
:lip lip
)
199 (storew header result
0 lowtag
))))