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-entry-points-slot other-pointer-lowtag
)
95 (storew null-tn result code-debug-info-slot other-pointer-lowtag
))))
97 (define-vop (make-fdefn)
98 (:args
(name :scs
(descriptor-reg) :to
:eval
))
99 (:temporary
(:scs
(non-descriptor-reg)) temp
)
100 (:temporary
(:sc non-descriptor-reg
:offset ocfp-offset
) pa-flag
)
101 (:results
(result :scs
(descriptor-reg) :from
:argument
))
102 (:temporary
(:sc interior-reg
) lip
)
104 (:translate make-fdefn
)
106 (let ((undefined-tramp-fixup (gen-label)))
107 (with-fixed-allocation (result pa-flag fdefn-widetag fdefn-size
)
108 (inst load-from-label temp lip undefined-tramp-fixup
)
109 (storew name result fdefn-name-slot other-pointer-lowtag
)
110 (storew null-tn result fdefn-fun-slot other-pointer-lowtag
)
111 (storew temp result fdefn-raw-addr-slot other-pointer-lowtag
))
112 (assemble (*elsewhere
*)
113 (emit-label undefined-tramp-fixup
)
114 (inst word
(make-fixup "undefined_tramp" :foreign
))))))
116 (define-vop (make-closure)
117 (:args
(function :to
:save
:scs
(descriptor-reg)))
118 (:info length stack-allocate-p
)
119 (:temporary
(:sc non-descriptor-reg
:offset ocfp-offset
) pa-flag
)
120 (:results
(result :scs
(descriptor-reg)))
122 (let* ((size (+ length closure-info-offset
))
123 (alloc-size (pad-data-block size
)))
124 (pseudo-atomic (pa-flag)
125 (allocation result alloc-size
128 :stack-allocate-p stack-allocate-p
)
129 (load-immediate-word pa-flag
131 (ash (1- size
) n-widetag-bits
)
132 closure-header-widetag
))
133 (storew pa-flag result
0 fun-pointer-lowtag
)
134 (storew function result closure-fun-slot fun-pointer-lowtag
)))))
136 ;;; The compiler likes to be able to directly make value cells.
138 (define-vop (make-value-cell)
139 (:args
(value :to
:save
:scs
(descriptor-reg any-reg
)))
140 (:temporary
(:sc non-descriptor-reg
:offset ocfp-offset
) pa-flag
)
141 (:info stack-allocate-p
)
142 (:results
(result :scs
(descriptor-reg)))
144 (with-fixed-allocation (result pa-flag value-cell-header-widetag
145 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 (:results
(result :scs
(any-reg)))
159 (:temporary
(:sc interior-reg
) lip
)
161 (let ((fixup (gen-label)))
162 (inst load-from-label result lip fixup
)
163 (assemble (*elsewhere
*)
165 (inst word
(make-fixup "funcallable_instance_tramp" :foreign
))))))
167 (define-vop (fixed-alloc)
169 (:info name words type lowtag stack-allocate-p
)
171 (:results
(result :scs
(descriptor-reg)))
172 (:temporary
(:sc non-descriptor-reg
:offset ocfp-offset
) pa-flag
)
174 (with-fixed-allocation (result pa-flag type words
176 :stack-allocate-p stack-allocate-p
))))
178 (define-vop (var-alloc)
179 (:args
(extra :scs
(any-reg)))
180 (:arg-types positive-fixnum
)
181 (:info name words type lowtag
)
183 (:results
(result :scs
(descriptor-reg)))
184 (:temporary
(:scs
(any-reg)) bytes
)
185 (:temporary
(:scs
(non-descriptor-reg)) header
)
186 (:temporary
(:sc non-descriptor-reg
:offset ocfp-offset
) pa-flag
)
188 ;; Build the object header, assuming that the header was in WORDS
189 ;; but should not be in the header
190 (inst add bytes extra
(* (1- words
) n-word-bytes
))
191 (inst mov header
(lsl bytes
(- n-widetag-bits n-fixnum-tag-bits
)))
192 (inst add header header type
)
193 ;; Add the object header to the allocation size and round up to
194 ;; the allocation granularity
195 (inst add bytes bytes
(* 2 n-word-bytes
))
196 (inst bic bytes bytes lowtag-mask
)
197 ;; Allocate the object and set its header
198 (pseudo-atomic (pa-flag)
199 (allocation result bytes lowtag
:flag-tn pa-flag
)
200 (storew header result
0 lowtag
))))