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
(any-reg)) temp
)
18 (:temporary
(:scs
(descriptor-reg) :type list
:to
(:result
0) :target result
)
20 (:temporary
(:sc non-descriptor-reg
:offset ocfp-offset
) pa-flag
)
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
))
48 (dotimes (i (1- cons-cells
))
49 (storew (maybe-load (tn-ref-tn things
)) ptr
50 cons-car-slot list-pointer-lowtag
)
51 (setf things
(tn-ref-across things
))
52 (inst add ptr ptr
(pad-data-block cons-size
))
54 (- cons-cdr-slot cons-size
)
56 (storew (maybe-load (tn-ref-tn things
)) ptr
57 cons-car-slot list-pointer-lowtag
)
59 (maybe-load (tn-ref-tn (tn-ref-across things
)))
61 ptr cons-cdr-slot list-pointer-lowtag
))
62 (move result res
)))))))
64 (define-vop (list list-or-list
*)
67 (define-vop (list* list-or-list
*)
70 ;;;; Special purpose inline allocators.
72 (define-vop (allocate-code-object)
73 (:args
(boxed-arg :scs
(any-reg))
74 (unboxed-arg :scs
(any-reg)))
75 (:results
(result :scs
(descriptor-reg)))
76 (:temporary
(:scs
(non-descriptor-reg)) ndescr
)
77 (:temporary
(:scs
(non-descriptor-reg)) size
)
78 (:temporary
(:scs
(any-reg) :from
(:argument
0)) boxed
)
79 (:temporary
(:scs
(non-descriptor-reg)) unboxed
)
80 (:temporary
(:sc non-descriptor-reg
:offset ocfp-offset
) pa-flag
)
82 (inst add boxed boxed-arg
(fixnumize (1+ code-constants-offset
)))
83 (inst bic boxed boxed lowtag-mask
)
84 (inst mov unboxed
(lsr unboxed-arg word-shift
))
85 (inst add unboxed unboxed lowtag-mask
)
86 (inst bic unboxed unboxed lowtag-mask
)
87 (inst mov ndescr
(lsl boxed
(- n-widetag-bits word-shift
)))
88 (inst orr ndescr ndescr code-header-widetag
)
89 (inst add size boxed unboxed
)
90 (pseudo-atomic (pa-flag)
91 (allocation result size other-pointer-lowtag
:flag-tn pa-flag
)
92 (storew ndescr result
0 other-pointer-lowtag
)
93 (storew unboxed-arg result code-code-size-slot other-pointer-lowtag
)
94 (storew null-tn result code-debug-info-slot other-pointer-lowtag
))))
96 (define-vop (make-fdefn)
97 (:args
(name :scs
(descriptor-reg) :to
:eval
))
98 (:temporary
(:scs
(non-descriptor-reg)) temp
)
99 (:temporary
(:sc non-descriptor-reg
:offset ocfp-offset
) pa-flag
)
100 (:results
(result :scs
(descriptor-reg) :from
:argument
))
101 (:temporary
(:sc interior-reg
) lip
)
103 (:translate make-fdefn
)
105 (let ((undefined-tramp-fixup (gen-label)))
106 (with-fixed-allocation (result pa-flag fdefn-widetag fdefn-size
)
107 (inst load-from-label temp lip undefined-tramp-fixup
)
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
))
111 (assemble (*elsewhere
*)
112 (emit-label undefined-tramp-fixup
)
113 (inst word
(make-fixup 'undefined-tramp
:assembly-routine
))))))
115 (define-vop (make-closure)
116 (:args
(function :to
:save
:scs
(descriptor-reg)))
117 (:info length stack-allocate-p
)
118 (:temporary
(:sc non-descriptor-reg
:offset ocfp-offset
) pa-flag
)
119 (:results
(result :scs
(descriptor-reg)))
121 (let* ((size (+ length closure-info-offset
))
122 (alloc-size (pad-data-block size
)))
123 (pseudo-atomic (pa-flag)
124 (allocation result alloc-size
127 :stack-allocate-p stack-allocate-p
)
128 (load-immediate-word pa-flag
130 (ash (1- size
) n-widetag-bits
)
131 closure-header-widetag
))
132 (storew pa-flag result
0 fun-pointer-lowtag
)
133 (storew function result closure-fun-slot fun-pointer-lowtag
)))))
135 ;;; The compiler likes to be able to directly make value cells.
137 (define-vop (make-value-cell)
138 (:args
(value :to
:save
:scs
(descriptor-reg any-reg
)))
139 (:temporary
(:sc non-descriptor-reg
:offset ocfp-offset
) pa-flag
)
140 (:info stack-allocate-p
)
141 (:results
(result :scs
(descriptor-reg)))
143 (with-fixed-allocation (result pa-flag value-cell-header-widetag
144 value-cell-size
:stack-allocate-p stack-allocate-p
)
145 (storew value result value-cell-value-slot other-pointer-lowtag
))))
147 ;;;; Automatic allocators for primitive objects.
149 (define-vop (make-unbound-marker)
151 (:results
(result :scs
(descriptor-reg any-reg
)))
153 (inst mov result unbound-marker-widetag
)))
155 (define-vop (make-funcallable-instance-tramp)
157 (:results
(result :scs
(any-reg)))
158 (:temporary
(:sc interior-reg
) lip
)
160 (let ((fixup (gen-label)))
161 (inst load-from-label result lip fixup
)
162 (assemble (*elsewhere
*)
164 (inst word
(make-fixup 'funcallable-instance-tramp
:assembly-routine
))))))
166 (define-vop (fixed-alloc)
168 (:info name words type lowtag stack-allocate-p
)
170 (:results
(result :scs
(descriptor-reg)))
171 (:temporary
(:sc non-descriptor-reg
:offset ocfp-offset
) pa-flag
)
173 (with-fixed-allocation (result pa-flag type words
175 :stack-allocate-p stack-allocate-p
))))
177 (define-vop (var-alloc)
178 (:args
(extra :scs
(any-reg)))
179 (:arg-types positive-fixnum
)
180 (:info name words type lowtag
)
182 (:results
(result :scs
(descriptor-reg)))
183 (:temporary
(:scs
(any-reg)) bytes
)
184 (:temporary
(:scs
(non-descriptor-reg)) header
)
185 (:temporary
(:sc non-descriptor-reg
:offset ocfp-offset
) pa-flag
)
187 ;; Build the object header, assuming that the header was in WORDS
188 ;; but should not be in the header
189 (inst add bytes extra
(* (1- words
) n-word-bytes
))
190 (inst mov header
(lsl bytes
(- n-widetag-bits n-fixnum-tag-bits
)))
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 bic bytes bytes lowtag-mask
)
196 ;; Allocate the object and set its header
197 (pseudo-atomic (pa-flag)
198 (allocation result bytes lowtag
:flag-tn pa-flag
)
199 (storew header result
0 lowtag
))))