1 ;;;; allocation VOPs for the PPC
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 (defoptimizer (list stack-allocate-result
) ((&rest args
))
17 (defoptimizer (list* stack-allocate-result
) ((&rest args
))
18 (not (null (rest args
))))
20 (define-vop (list-or-list*)
21 (:args
(things :more t
))
22 (:temporary
(:scs
(descriptor-reg) :type list
) ptr
)
23 (:temporary
(:scs
(descriptor-reg)) temp
)
24 (:temporary
(:scs
(descriptor-reg) :type list
:to
(:result
0) :target result
)
26 (:temporary
(:sc non-descriptor-reg
:offset nl3-offset
) pa-flag
)
27 (:temporary
(:scs
(non-descriptor-reg)) alloc-temp
)
29 (:results
(result :scs
(descriptor-reg)))
33 #!-gencgc
(:ignore alloc-temp
)
36 (move result null-tn
))
38 (move result
(tn-ref-tn things
)))
44 ((any-reg descriptor-reg zero null
)
47 (load-stack-tn temp
,tn
)
49 (let* ((dx-p (node-stack-allocate-p node
))
50 (cons-cells (if star
(1- num
) num
))
51 (alloc (* (pad-data-block cons-size
) cons-cells
)))
52 (pseudo-atomic (pa-flag)
56 (inst clrrwi res csp-tn n-lowtag-bits
)
57 (inst ori res res list-pointer-lowtag
)
58 (inst addi csp-tn csp-tn alloc
))
59 (allocation res alloc list-pointer-lowtag
:temp-tn alloc-temp
62 (dotimes (i (1- cons-cells
))
63 (storew (maybe-load (tn-ref-tn things
)) ptr
64 cons-car-slot list-pointer-lowtag
)
65 (setf things
(tn-ref-across things
))
66 (inst addi ptr ptr
(pad-data-block cons-size
))
68 (- cons-cdr-slot cons-size
)
70 (storew (maybe-load (tn-ref-tn things
)) ptr
71 cons-car-slot list-pointer-lowtag
)
73 (maybe-load (tn-ref-tn (tn-ref-across things
)))
75 ptr cons-cdr-slot list-pointer-lowtag
))
76 (move result res
)))))))
78 (define-vop (list list-or-list
*)
81 (define-vop (list* list-or-list
*)
85 ;;;; Special purpose inline allocators.
87 (define-vop (allocate-code-object)
88 (:args
(boxed-arg :scs
(any-reg))
89 (unboxed-arg :scs
(any-reg)))
90 (:results
(result :scs
(descriptor-reg)))
91 (:temporary
(:scs
(non-descriptor-reg)) ndescr
)
92 (:temporary
(:scs
(non-descriptor-reg)) size
)
93 (:temporary
(:scs
(any-reg) :from
(:argument
0)) boxed
)
94 (:temporary
(:scs
(non-descriptor-reg) :from
(:argument
1)) unboxed
)
95 (:temporary
(:sc non-descriptor-reg
:offset nl3-offset
) pa-flag
)
97 (inst addi boxed boxed-arg
(fixnumize (1+ code-trace-table-offset-slot
)))
98 (inst clrrwi boxed boxed n-lowtag-bits
)
99 (inst srwi unboxed unboxed-arg word-shift
)
100 (inst addi unboxed unboxed lowtag-mask
)
101 (inst clrrwi unboxed unboxed n-lowtag-bits
)
102 (pseudo-atomic (pa-flag)
103 ;; Note: we don't have to subtract off the 4 that was added by
104 ;; pseudo-atomic, because oring in other-pointer-lowtag just adds
106 (inst add size boxed unboxed
)
107 (allocation result size other-pointer-lowtag
:temp-tn ndescr
:flag-tn pa-flag
)
108 (inst slwi ndescr boxed
(- n-widetag-bits word-shift
))
109 (inst ori ndescr ndescr code-header-widetag
)
110 (storew ndescr result
0 other-pointer-lowtag
)
111 (storew unboxed result code-code-size-slot other-pointer-lowtag
)
112 (storew null-tn result code-entry-points-slot other-pointer-lowtag
)
113 (storew null-tn result code-debug-info-slot other-pointer-lowtag
))))
115 (define-vop (make-fdefn)
116 (:args
(name :scs
(descriptor-reg) :to
:eval
))
117 (:temporary
(:scs
(non-descriptor-reg)) temp
)
118 (:temporary
(:sc non-descriptor-reg
:offset nl3-offset
) pa-flag
)
119 (:results
(result :scs
(descriptor-reg) :from
:argument
))
121 (:translate make-fdefn
)
123 (with-fixed-allocation (result pa-flag temp fdefn-widetag fdefn-size
)
124 (inst lr temp
(make-fixup "undefined_tramp" :foreign
))
125 (storew name result fdefn-name-slot other-pointer-lowtag
)
126 (storew null-tn result fdefn-fun-slot other-pointer-lowtag
)
127 (storew temp result fdefn-raw-addr-slot other-pointer-lowtag
))))
129 (define-vop (make-closure)
130 (:args
(function :to
:save
:scs
(descriptor-reg)))
131 (:info length stack-allocate-p
)
132 (:temporary
(:scs
(non-descriptor-reg)) temp
)
133 (:temporary
(:sc non-descriptor-reg
:offset nl3-offset
) pa-flag
)
134 (:results
(result :scs
(descriptor-reg)))
136 (let* ((size (+ length closure-info-offset
))
137 (alloc-size (pad-data-block size
)))
138 (pseudo-atomic (pa-flag)
142 (inst clrrwi. result csp-tn n-lowtag-bits
)
143 (inst addi csp-tn csp-tn alloc-size
)
144 (inst ori result result fun-pointer-lowtag
)
145 (inst lr temp
(logior (ash (1- size
) n-widetag-bits
) closure-header-widetag
)))
147 (allocation result
(pad-data-block size
)
148 fun-pointer-lowtag
:temp-tn temp
:flag-tn pa-flag
)
149 (inst lr temp
(logior (ash (1- size
) n-widetag-bits
) closure-header-widetag
))))
150 ;;; should this be closure-fun-slot instead of 0?
151 (storew temp result
0 fun-pointer-lowtag
)
152 (storew function result closure-fun-slot fun-pointer-lowtag
)))))
154 ;;; The compiler likes to be able to directly make value cells.
156 (define-vop (make-value-cell)
157 (:args
(value :to
:save
:scs
(descriptor-reg any-reg
)))
158 (:temporary
(:scs
(non-descriptor-reg)) temp
)
159 (:temporary
(:sc non-descriptor-reg
:offset nl3-offset
) pa-flag
)
160 (:info stack-allocate-p
)
161 (:ignore stack-allocate-p
)
162 (:results
(result :scs
(descriptor-reg)))
164 (with-fixed-allocation (result pa-flag temp value-cell-header-widetag value-cell-size
)
165 (storew value result value-cell-value-slot other-pointer-lowtag
))))
169 ;;;; Automatic allocators for primitive objects.
171 (define-vop (make-unbound-marker)
173 (:results
(result :scs
(any-reg)))
175 (inst li result unbound-marker-widetag
)))
177 (define-vop (make-funcallable-instance-tramp)
179 (:results
(result :scs
(any-reg)))
181 (inst lr result
(make-fixup "funcallable_instance_tramp" :foreign
))))
183 (define-vop (fixed-alloc)
185 (:info name words type lowtag
)
187 (:results
(result :scs
(descriptor-reg)))
188 (:temporary
(:scs
(non-descriptor-reg)) temp
)
189 (:temporary
(:sc non-descriptor-reg
:offset nl3-offset
) pa-flag
)
191 (with-fixed-allocation (result pa-flag temp type words
:lowtag lowtag
)
194 (define-vop (var-alloc)
195 (:args
(extra :scs
(any-reg)))
196 (:arg-types positive-fixnum
)
197 (:info name words type lowtag
)
198 (:ignore name
#!-gencgc temp
)
199 (:results
(result :scs
(descriptor-reg)))
200 (:temporary
(:scs
(any-reg)) bytes
)
201 (:temporary
(:scs
(non-descriptor-reg)) header
)
202 (:temporary
(:scs
(non-descriptor-reg)) temp
)
203 (:temporary
(:sc non-descriptor-reg
:offset nl3-offset
) pa-flag
)
205 (inst addi bytes extra
(* (1+ words
) n-word-bytes
))
206 (inst slwi header bytes
(- n-widetag-bits
2))
207 (inst addi header header
(+ (ash -
2 n-widetag-bits
) type
))
208 (inst clrrwi bytes bytes n-lowtag-bits
)
209 (pseudo-atomic (pa-flag)
210 (allocation result bytes lowtag
:temp-tn temp
:flag-tn pa-flag
)
211 (storew header result
0 lowtag
))))