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)
28 (:results (result :scs (descriptor-reg)))
34 (move result null-tn))
36 (move result (tn-ref-tn things)))
42 ((any-reg descriptor-reg zero null)
45 (load-stack-tn temp ,tn)
47 (let* ((dx-p (node-stack-allocate-p node))
48 (cons-cells (if star (1- num) num))
49 (alloc (* (pad-data-block cons-size) cons-cells)))
50 (pseudo-atomic (pa-flag :extra (if dx-p 0 alloc))
51 (let ((allocation-area-tn (if dx-p csp-tn alloc-tn)))
54 (inst clrrwi res allocation-area-tn n-lowtag-bits)
55 (inst ori res res list-pointer-lowtag)
57 (inst addi csp-tn csp-tn alloc)))
59 (dotimes (i (1- cons-cells))
60 (storew (maybe-load (tn-ref-tn things)) ptr
61 cons-car-slot list-pointer-lowtag)
62 (setf things (tn-ref-across things))
63 (inst addi ptr ptr (pad-data-block cons-size))
65 (- cons-cdr-slot cons-size)
67 (storew (maybe-load (tn-ref-tn things)) ptr
68 cons-car-slot list-pointer-lowtag)
70 (maybe-load (tn-ref-tn (tn-ref-across things)))
72 ptr cons-cdr-slot list-pointer-lowtag))
73 (move result res)))))))
75 (define-vop (list list-or-list*)
78 (define-vop (list* list-or-list*)
82 ;;;; Special purpose inline allocators.
84 (define-vop (allocate-code-object)
85 (:args (boxed-arg :scs (any-reg))
86 (unboxed-arg :scs (any-reg)))
87 (:results (result :scs (descriptor-reg)))
88 (:temporary (:scs (non-descriptor-reg)) ndescr)
89 (:temporary (:scs (any-reg) :from (:argument 0)) boxed)
90 (:temporary (:scs (non-descriptor-reg) :from (:argument 1)) unboxed)
91 (:temporary (:sc non-descriptor-reg :offset nl3-offset) pa-flag)
93 (inst addi boxed boxed-arg (fixnumize (1+ code-trace-table-offset-slot)))
94 (inst clrrwi boxed boxed n-lowtag-bits)
95 (inst srwi unboxed unboxed-arg word-shift)
96 (inst addi unboxed unboxed lowtag-mask)
97 (inst clrrwi unboxed unboxed n-lowtag-bits)
98 (pseudo-atomic (pa-flag)
99 ;; Note: we don't have to subtract off the 4 that was added by
100 ;; pseudo-atomic, because oring in other-pointer-lowtag just adds
102 (inst ori result alloc-tn other-pointer-lowtag)
103 (inst add alloc-tn alloc-tn boxed)
104 (inst add alloc-tn alloc-tn unboxed)
105 (inst slwi ndescr boxed (- n-widetag-bits word-shift))
106 (inst ori ndescr ndescr code-header-widetag)
107 (storew ndescr result 0 other-pointer-lowtag)
108 (storew unboxed result code-code-size-slot other-pointer-lowtag)
109 (storew null-tn result code-entry-points-slot other-pointer-lowtag)
110 (storew null-tn result code-debug-info-slot other-pointer-lowtag))))
112 (define-vop (make-fdefn)
113 (:args (name :scs (descriptor-reg) :to :eval))
114 (:temporary (:scs (non-descriptor-reg)) temp)
115 (:temporary (:sc non-descriptor-reg :offset nl3-offset) pa-flag)
116 (:results (result :scs (descriptor-reg) :from :argument))
118 (:translate make-fdefn)
120 (with-fixed-allocation (result pa-flag temp fdefn-widetag fdefn-size)
121 (inst lr temp (make-fixup "undefined_tramp" :foreign))
122 (storew name result fdefn-name-slot other-pointer-lowtag)
123 (storew null-tn result fdefn-fun-slot other-pointer-lowtag)
124 (storew temp result fdefn-raw-addr-slot other-pointer-lowtag))))
126 (define-vop (make-closure)
127 (:args (function :to :save :scs (descriptor-reg)))
128 (:info length stack-allocate-p)
129 (:temporary (:scs (non-descriptor-reg)) temp)
130 (:temporary (:sc non-descriptor-reg :offset nl3-offset) pa-flag)
131 (:results (result :scs (descriptor-reg)))
133 (let* ((size (+ length closure-info-offset))
134 (alloc-size (pad-data-block size))
135 (allocation-area-tn (if stack-allocate-p csp-tn alloc-tn)))
136 (pseudo-atomic (pa-flag :extra (if stack-allocate-p 0 alloc-size))
137 (when stack-allocate-p
139 (inst clrrwi. result allocation-area-tn n-lowtag-bits)
140 (when stack-allocate-p
141 (inst addi csp-tn csp-tn alloc-size))
142 (inst ori result result fun-pointer-lowtag)
143 (inst lr temp (logior (ash (1- size) n-widetag-bits) closure-header-widetag))
144 (storew temp result 0 fun-pointer-lowtag)))
145 ;(inst lis temp (ash 18 10))
146 ;(storew temp result closure-jump-insn-slot function-pointer-type)
147 (storew result result closure-self-slot fun-pointer-lowtag)
148 (storew function result closure-fun-slot fun-pointer-lowtag)))
150 ;;; The compiler likes to be able to directly make value cells.
152 (define-vop (make-value-cell)
153 (:args (value :to :save :scs (descriptor-reg any-reg)))
154 (:temporary (:scs (non-descriptor-reg)) temp)
155 (:temporary (:sc non-descriptor-reg :offset nl3-offset) pa-flag)
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 (any-reg)))
169 (inst li result unbound-marker-widetag)))
171 (define-vop (fixed-alloc)
173 (:info name words type lowtag)
175 (:results (result :scs (descriptor-reg)))
176 (:temporary (:scs (non-descriptor-reg)) temp)
177 (:temporary (:sc non-descriptor-reg :offset nl3-offset) pa-flag)
179 (pseudo-atomic (pa-flag :extra (pad-data-block words))
180 (cond ((logbitp 2 lowtag)
181 (inst ori result alloc-tn lowtag))
183 (inst clrrwi result alloc-tn n-lowtag-bits)
184 (inst ori result result lowtag)))
186 (inst lr temp (logior (ash (1- words) n-widetag-bits) type))
187 (storew temp result 0 lowtag)))))
189 (define-vop (var-alloc)
190 (:args (extra :scs (any-reg)))
191 (:arg-types positive-fixnum)
192 (:info name words type lowtag)
194 (:results (result :scs (descriptor-reg)))
195 (:temporary (:scs (any-reg)) bytes)
196 (:temporary (:scs (non-descriptor-reg)) header)
197 (:temporary (:sc non-descriptor-reg :offset nl3-offset) pa-flag)
199 (inst addi bytes extra (* (1+ words) n-word-bytes))
200 (inst slwi header bytes (- n-widetag-bits 2))
201 (inst addi header header (+ (ash -2 n-widetag-bits) type))
202 (inst clrrwi bytes bytes n-lowtag-bits)
203 (pseudo-atomic (pa-flag)
204 (cond ((logbitp 2 lowtag)
205 (inst ori result alloc-tn lowtag))
207 (inst clrrwi result alloc-tn n-lowtag-bits)
208 (inst ori result result lowtag)))
209 (storew header result 0 lowtag)
210 (inst add alloc-tn alloc-tn bytes))))