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 (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
)
21 (:temporary
(:sc non-descriptor-reg
:offset nl3-offset
) pa-flag
)
22 (:temporary
(:scs
(non-descriptor-reg)) alloc-temp
)
24 (:results
(result :scs
(descriptor-reg)))
28 #!-gencgc
(:ignore alloc-temp
)
31 (move result null-tn
))
33 (move result
(tn-ref-tn things
)))
39 ((any-reg descriptor-reg zero null
)
42 (load-stack-tn temp
,tn
)
44 (let* ((dx-p (node-stack-allocate-p node
))
45 (cons-cells (if star
(1- num
) num
))
46 (alloc (* (pad-data-block cons-size
) cons-cells
)))
47 (pseudo-atomic (pa-flag)
51 (inst clrrwi res csp-tn n-lowtag-bits
)
52 (inst ori res res list-pointer-lowtag
)
53 (inst addi csp-tn csp-tn alloc
))
54 (allocation res alloc list-pointer-lowtag
:temp-tn alloc-temp
57 (dotimes (i (1- cons-cells
))
58 (storew (maybe-load (tn-ref-tn things
)) ptr
59 cons-car-slot list-pointer-lowtag
)
60 (setf things
(tn-ref-across things
))
61 (inst addi ptr ptr
(pad-data-block cons-size
))
63 (- cons-cdr-slot cons-size
)
65 (storew (maybe-load (tn-ref-tn things
)) ptr
66 cons-car-slot list-pointer-lowtag
)
68 (maybe-load (tn-ref-tn (tn-ref-across things
)))
70 ptr cons-cdr-slot list-pointer-lowtag
))
71 (move result res
)))))))
73 (define-vop (list list-or-list
*)
76 (define-vop (list* list-or-list
*)
80 ;;;; Special purpose inline allocators.
82 (define-vop (allocate-code-object)
83 (:args
(boxed-arg :scs
(any-reg))
84 (unboxed-arg :scs
(any-reg)))
85 (:results
(result :scs
(descriptor-reg)))
86 (:temporary
(:scs
(non-descriptor-reg)) ndescr
)
87 (:temporary
(:scs
(non-descriptor-reg)) size
)
88 (:temporary
(:scs
(any-reg) :from
(:argument
0)) boxed
)
89 (:temporary
(:scs
(non-descriptor-reg)) unboxed
)
90 (:temporary
(:sc non-descriptor-reg
:offset nl3-offset
) pa-flag
)
92 (inst addi boxed boxed-arg
(fixnumize (1+ code-constants-offset
)))
93 (inst clrrwi boxed boxed n-lowtag-bits
)
94 (inst srwi unboxed unboxed-arg word-shift
)
95 (inst addi unboxed unboxed lowtag-mask
)
96 (inst clrrwi unboxed unboxed n-lowtag-bits
)
97 (pseudo-atomic (pa-flag)
98 ;; Note: we don't have to subtract off the 4 that was added by
99 ;; pseudo-atomic, because oring in other-pointer-lowtag just adds
101 (inst add size boxed unboxed
)
102 (allocation result size other-pointer-lowtag
:temp-tn ndescr
:flag-tn pa-flag
)
103 (inst slwi ndescr boxed
(- n-widetag-bits word-shift
))
104 (inst ori ndescr ndescr code-header-widetag
)
105 (storew ndescr result
0 other-pointer-lowtag
)
106 (storew unboxed-arg result code-code-size-slot other-pointer-lowtag
)
107 (storew null-tn result code-debug-info-slot other-pointer-lowtag
))))
109 (define-vop (make-fdefn)
110 (:args
(name :scs
(descriptor-reg) :to
:eval
))
111 (:temporary
(:scs
(non-descriptor-reg)) temp
)
112 (:temporary
(:sc non-descriptor-reg
:offset nl3-offset
) pa-flag
)
113 (:results
(result :scs
(descriptor-reg) :from
:argument
))
115 (:translate make-fdefn
)
117 (with-fixed-allocation (result pa-flag temp fdefn-widetag fdefn-size
)
118 (inst lr temp
(make-fixup 'undefined-tramp
:assembly-routine
))
119 (storew name result fdefn-name-slot other-pointer-lowtag
)
120 (storew null-tn result fdefn-fun-slot other-pointer-lowtag
)
121 (storew temp result fdefn-raw-addr-slot other-pointer-lowtag
))))
123 (define-vop (make-closure)
124 (:args
(function :to
:save
:scs
(descriptor-reg)))
125 (:info length stack-allocate-p
)
126 (:temporary
(:scs
(non-descriptor-reg)) temp
)
127 (:temporary
(:sc non-descriptor-reg
:offset nl3-offset
) pa-flag
)
128 (:results
(result :scs
(descriptor-reg)))
130 (let* ((size (+ length closure-info-offset
))
131 (alloc-size (pad-data-block size
)))
132 (pseudo-atomic (pa-flag)
136 (inst clrrwi. result csp-tn n-lowtag-bits
)
137 (inst addi csp-tn csp-tn alloc-size
)
138 (inst ori result result fun-pointer-lowtag
)
139 (inst lr temp
(logior (ash (1- size
) n-widetag-bits
) closure-header-widetag
)))
141 (allocation result
(pad-data-block size
)
142 fun-pointer-lowtag
:temp-tn temp
:flag-tn pa-flag
)
143 (inst lr temp
(logior (ash (1- size
) n-widetag-bits
) closure-header-widetag
))))
144 (storew temp result
0 fun-pointer-lowtag
)
145 (storew function result closure-fun-slot fun-pointer-lowtag
)))))
147 ;;; The compiler likes to be able to directly make value cells.
149 (define-vop (make-value-cell)
150 (:args
(value :to
:save
:scs
(descriptor-reg any-reg
)))
151 (:temporary
(:scs
(non-descriptor-reg)) temp
)
152 (:temporary
(:sc non-descriptor-reg
:offset nl3-offset
) pa-flag
)
153 (:info stack-allocate-p
)
154 (:ignore stack-allocate-p
)
155 (:results
(result :scs
(descriptor-reg)))
157 (with-fixed-allocation (result pa-flag temp value-cell-widetag value-cell-size
)
158 (storew value result value-cell-value-slot other-pointer-lowtag
))))
162 ;;;; Automatic allocators for primitive objects.
164 (define-vop (make-unbound-marker)
166 (:results
(result :scs
(descriptor-reg any-reg
)))
168 (inst li result unbound-marker-widetag
)))
170 (define-vop (make-funcallable-instance-tramp)
172 (:results
(result :scs
(any-reg)))
174 (inst lr result
(make-fixup 'funcallable-instance-tramp
:assembly-routine
))))
176 (define-vop (fixed-alloc)
178 (:info name words type lowtag stack-allocate-p
)
180 (:results
(result :scs
(descriptor-reg)))
181 (:temporary
(:scs
(non-descriptor-reg)) temp
)
182 (:temporary
(:sc non-descriptor-reg
:offset nl3-offset
) pa-flag
)
184 (with-fixed-allocation (result pa-flag temp type words
186 :stack-allocate-p stack-allocate-p
)
189 (define-vop (var-alloc)
190 (:args
(extra :scs
(any-reg)))
191 (:arg-types positive-fixnum
)
192 (:info name words type lowtag
)
193 (:ignore name
#!-gencgc temp
)
194 (:results
(result :scs
(descriptor-reg)))
195 (:temporary
(:scs
(any-reg)) bytes
)
196 (:temporary
(:scs
(non-descriptor-reg)) header
)
197 (:temporary
(:scs
(non-descriptor-reg)) temp
)
198 (:temporary
(:sc non-descriptor-reg
:offset nl3-offset
) pa-flag
)
200 (inst addi bytes extra
(* (1+ words
) n-word-bytes
))
201 (inst slwi header bytes
(- n-widetag-bits n-fixnum-tag-bits
))
202 (inst addi header header
(+ (ash -
2 n-widetag-bits
) type
))
203 (inst clrrwi bytes bytes n-lowtag-bits
)
204 (pseudo-atomic (pa-flag)
205 (allocation result bytes lowtag
:temp-tn temp
:flag-tn pa-flag
)
206 (storew header result
0 lowtag
))))