2 ;;; Written by William Lott.
10 (define-vop (list-or-list*)
11 (:args (things :more t))
12 (:temporary (:scs (descriptor-reg) :type list) ptr)
13 (:temporary (:scs (descriptor-reg)) temp)
14 (:temporary (:scs (descriptor-reg) :type list :to (:result 0) :target result)
16 (:temporary (:sc non-descriptor-reg :offset nl3-offset) pa-flag)
18 (:results (result :scs (descriptor-reg)))
23 (move result null-tn))
25 (move result (tn-ref-tn things)))
31 ((any-reg descriptor-reg zero null)
34 (load-stack-tn temp ,tn)
36 (let* ((cons-cells (if star (1- num) num))
37 (alloc (* (pad-data-block cons-size) cons-cells)))
38 (pseudo-atomic (pa-flag :extra alloc)
39 (inst clrrwi res alloc-tn n-lowtag-bits)
40 (inst ori res res list-pointer-lowtag)
42 (dotimes (i (1- cons-cells))
43 (storew (maybe-load (tn-ref-tn things)) ptr
44 cons-car-slot list-pointer-lowtag)
45 (setf things (tn-ref-across things))
46 (inst addi ptr ptr (pad-data-block cons-size))
48 (- cons-cdr-slot cons-size)
50 (storew (maybe-load (tn-ref-tn things)) ptr
51 cons-car-slot list-pointer-lowtag)
53 (maybe-load (tn-ref-tn (tn-ref-across things)))
55 ptr cons-cdr-slot list-pointer-lowtag))
56 (move result res)))))))
58 (define-vop (list list-or-list*)
61 (define-vop (list* list-or-list*)
65 ;;;; Special purpose inline allocators.
67 (define-vop (allocate-code-object)
68 (:args (boxed-arg :scs (any-reg))
69 (unboxed-arg :scs (any-reg)))
70 (:results (result :scs (descriptor-reg)))
71 (:temporary (:scs (non-descriptor-reg)) ndescr)
72 (:temporary (:scs (any-reg) :from (:argument 0)) boxed)
73 (:temporary (:scs (non-descriptor-reg) :from (:argument 1)) unboxed)
74 (:temporary (:sc non-descriptor-reg :offset nl3-offset) pa-flag)
76 (inst addi boxed boxed-arg (fixnumize (1+ code-trace-table-offset-slot)))
77 (inst clrrwi boxed boxed n-lowtag-bits)
78 (inst srwi unboxed unboxed-arg word-shift)
79 (inst addi unboxed unboxed lowtag-mask)
80 (inst clrrwi unboxed unboxed n-lowtag-bits)
81 (pseudo-atomic (pa-flag)
82 ;; Note: we don't have to subtract off the 4 that was added by
83 ;; pseudo-atomic, because oring in other-pointer-lowtag just adds
85 (inst ori result alloc-tn other-pointer-lowtag)
86 (inst add alloc-tn alloc-tn boxed)
87 (inst add alloc-tn alloc-tn unboxed)
88 (inst slwi ndescr boxed (- n-widetag-bits word-shift))
89 (inst ori ndescr ndescr code-header-widetag)
90 (storew ndescr result 0 other-pointer-lowtag)
91 (storew unboxed result code-code-size-slot other-pointer-lowtag)
92 (storew null-tn result code-entry-points-slot other-pointer-lowtag)
93 (storew null-tn result code-debug-info-slot other-pointer-lowtag))))
95 (define-vop (make-fdefn)
96 (:args (name :scs (descriptor-reg) :to :eval))
97 (:temporary (:scs (non-descriptor-reg)) temp)
98 (:temporary (:sc non-descriptor-reg :offset nl3-offset) pa-flag)
99 (:results (result :scs (descriptor-reg) :from :argument))
101 (:translate make-fdefn)
103 (with-fixed-allocation (result pa-flag temp fdefn-widetag fdefn-size)
104 (inst lr temp (make-fixup "undefined_tramp" :foreign))
105 (storew name result fdefn-name-slot other-pointer-lowtag)
106 (storew null-tn result fdefn-fun-slot other-pointer-lowtag)
107 (storew temp result fdefn-raw-addr-slot other-pointer-lowtag))))
110 (define-vop (make-closure)
111 (:args (function :to :save :scs (descriptor-reg)))
113 (:temporary (:scs (non-descriptor-reg)) temp)
114 (:temporary (:sc non-descriptor-reg :offset nl3-offset) pa-flag)
115 (:results (result :scs (descriptor-reg)))
117 (let ((size (+ length closure-info-offset)))
118 (pseudo-atomic (pa-flag :extra (pad-data-block size))
119 (inst clrrwi. result alloc-tn n-lowtag-bits)
120 (inst ori result result fun-pointer-lowtag)
121 (inst lr temp (logior (ash (1- size) n-widetag-bits) closure-header-widetag))
122 (storew temp result 0 fun-pointer-lowtag)))
123 ;(inst lis temp (ash 18 10))
124 ;(storew temp result closure-jump-insn-slot function-pointer-type)
125 (storew function result closure-fun-slot fun-pointer-lowtag)))
127 ;;; The compiler likes to be able to directly make value cells.
129 (define-vop (make-value-cell)
130 (:args (value :to :save :scs (descriptor-reg any-reg)))
131 (:temporary (:scs (non-descriptor-reg)) temp)
132 (:temporary (:sc non-descriptor-reg :offset nl3-offset) pa-flag)
133 (:results (result :scs (descriptor-reg)))
135 (with-fixed-allocation
136 (result pa-flag temp value-cell-header-widetag value-cell-size))
137 (storew value result value-cell-value-slot other-pointer-lowtag)))
141 ;;;; Automatic allocators for primitive objects.
143 (define-vop (make-unbound-marker)
145 (:results (result :scs (any-reg)))
147 (inst li result unbound-marker-widetag)))
149 (define-vop (fixed-alloc)
151 (:info name words type lowtag)
153 (:results (result :scs (descriptor-reg)))
154 (:temporary (:scs (non-descriptor-reg)) temp)
155 (:temporary (:sc non-descriptor-reg :offset nl3-offset) pa-flag)
157 (pseudo-atomic (pa-flag :extra (pad-data-block words))
158 (cond ((logbitp 2 lowtag)
159 (inst ori result alloc-tn lowtag))
161 (inst clrrwi result alloc-tn n-lowtag-bits)
162 (inst ori result result lowtag)))
164 (inst lr temp (logior (ash (1- words) n-widetag-bits) type))
165 (storew temp result 0 lowtag)))))
167 (define-vop (var-alloc)
168 (:args (extra :scs (any-reg)))
169 (:arg-types positive-fixnum)
170 (:info name words type lowtag)
172 (:results (result :scs (descriptor-reg)))
173 (:temporary (:scs (any-reg)) bytes header)
174 (:temporary (:sc non-descriptor-reg :offset nl3-offset) pa-flag)
176 (inst addi bytes extra (* (1+ words) n-word-bytes))
177 (inst slwi header bytes (- n-widetag-bits 2))
178 (inst addi header header (+ (ash -2 n-widetag-bits) type))
179 (inst clrrwi bytes bytes n-lowtag-bits)
180 (pseudo-atomic (pa-flag)
181 (cond ((logbitp 2 lowtag)
182 (inst ori result alloc-tn lowtag))
184 (inst clrrwi result alloc-tn n-lowtag-bits)
185 (inst ori result result lowtag)))
186 (storew header result 0 lowtag)
187 (inst add alloc-tn alloc-tn bytes))))