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) :from (:argument 1)) unboxed)
90 (:temporary (:sc non-descriptor-reg :offset nl3-offset) pa-flag)
92 (inst addi boxed boxed-arg (fixnumize (1+ code-trace-table-offset-slot)))
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 result code-code-size-slot other-pointer-lowtag)
107 (storew null-tn result code-entry-points-slot other-pointer-lowtag)
108 (storew null-tn result code-debug-info-slot other-pointer-lowtag))))
110 (define-vop (make-fdefn)
111 (:args (name :scs (descriptor-reg) :to :eval))
112 (:temporary (:scs (non-descriptor-reg)) temp)
113 (:temporary (:sc non-descriptor-reg :offset nl3-offset) pa-flag)
114 (:results (result :scs (descriptor-reg) :from :argument))
116 (:translate make-fdefn)
118 (with-fixed-allocation (result pa-flag temp fdefn-widetag fdefn-size)
119 (inst lr temp (make-fixup "undefined_tramp" :foreign))
120 (storew name result fdefn-name-slot other-pointer-lowtag)
121 (storew null-tn result fdefn-fun-slot other-pointer-lowtag)
122 (storew temp result fdefn-raw-addr-slot other-pointer-lowtag))))
124 (define-vop (make-closure)
125 (:args (function :to :save :scs (descriptor-reg)))
126 (:info length stack-allocate-p)
127 (:temporary (:scs (non-descriptor-reg)) temp)
128 (:temporary (:sc non-descriptor-reg :offset nl3-offset) pa-flag)
129 (:results (result :scs (descriptor-reg)))
131 (let* ((size (+ length closure-info-offset))
132 (alloc-size (pad-data-block size)))
133 (pseudo-atomic (pa-flag)
137 (inst clrrwi. result csp-tn n-lowtag-bits)
138 (inst addi csp-tn csp-tn alloc-size)
139 (inst ori result result fun-pointer-lowtag)
140 (inst lr temp (logior (ash (1- size) n-widetag-bits) closure-header-widetag)))
142 (allocation result (pad-data-block size)
143 fun-pointer-lowtag :temp-tn temp :flag-tn pa-flag)
144 (inst lr temp (logior (ash (1- size) n-widetag-bits) closure-header-widetag))))
145 (storew temp result 0 fun-pointer-lowtag)
146 (storew function result closure-fun-slot fun-pointer-lowtag)))))
148 ;;; The compiler likes to be able to directly make value cells.
150 (define-vop (make-value-cell)
151 (:args (value :to :save :scs (descriptor-reg any-reg)))
152 (:temporary (:scs (non-descriptor-reg)) temp)
153 (:temporary (:sc non-descriptor-reg :offset nl3-offset) pa-flag)
154 (:info stack-allocate-p)
155 (:ignore stack-allocate-p)
156 (:results (result :scs (descriptor-reg)))
158 (with-fixed-allocation (result pa-flag temp value-cell-header-widetag value-cell-size)
159 (storew value result value-cell-value-slot other-pointer-lowtag))))
163 ;;;; Automatic allocators for primitive objects.
165 (define-vop (make-unbound-marker)
167 (:results (result :scs (descriptor-reg any-reg)))
169 (inst li result unbound-marker-widetag)))
171 (define-vop (make-funcallable-instance-tramp)
173 (:results (result :scs (any-reg)))
175 (inst lr result (make-fixup "funcallable_instance_tramp" :foreign))))
177 (define-vop (fixed-alloc)
179 (:info name words type lowtag stack-allocate-p)
181 (:results (result :scs (descriptor-reg)))
182 (:temporary (:scs (non-descriptor-reg)) temp)
183 (:temporary (:sc non-descriptor-reg :offset nl3-offset) pa-flag)
185 (with-fixed-allocation (result pa-flag temp type words
187 :stack-allocate-p stack-allocate-p)
190 (define-vop (var-alloc)
191 (:args (extra :scs (any-reg)))
192 (:arg-types positive-fixnum)
193 (:info name words type lowtag)
194 (:ignore name #!-gencgc temp)
195 (:results (result :scs (descriptor-reg)))
196 (:temporary (:scs (any-reg)) bytes)
197 (:temporary (:scs (non-descriptor-reg)) header)
198 (:temporary (:scs (non-descriptor-reg)) temp)
199 (:temporary (:sc non-descriptor-reg :offset nl3-offset) pa-flag)
201 (inst addi bytes extra (* (1+ words) n-word-bytes))
202 (inst slwi header bytes (- n-widetag-bits n-fixnum-tag-bits))
203 (inst addi header header (+ (ash -2 n-widetag-bits) type))
204 (inst clrrwi bytes bytes n-lowtag-bits)
205 (pseudo-atomic (pa-flag)
206 (allocation result bytes lowtag :temp-tn temp :flag-tn pa-flag)
207 (storew header result 0 lowtag))))