1 ;;;; allocation VOPs for the Alpha port
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)
22 (:results (result :scs (descriptor-reg)))
28 (move null-tn result))
30 (move (tn-ref-tn things) result))
33 ((store-car (tn list &optional (slot cons-car-slot))
36 ((any-reg descriptor-reg) ,tn)
40 (load-stack-tn temp ,tn)
42 (storew reg ,list ,slot list-pointer-lowtag))))
43 (let* ((dx-p (node-stack-allocate-p node))
44 (cons-cells (if star (1- num) num))
45 (space (* (pad-data-block cons-size) cons-cells)))
46 (pseudo-atomic (:extra (if dx-p 0 space))
49 (inst bis csp-tn list-pointer-lowtag res)
50 (inst lda csp-tn space csp-tn))
52 (inst bis alloc-tn list-pointer-lowtag res)))
54 (dotimes (i (1- cons-cells))
55 (store-car (tn-ref-tn things) ptr)
56 (setf things (tn-ref-across things))
57 (inst lda ptr (pad-data-block cons-size) ptr)
59 (- cons-cdr-slot cons-size)
61 (store-car (tn-ref-tn things) ptr)
63 (setf things (tn-ref-across things))
64 (store-car (tn-ref-tn things) ptr cons-cdr-slot))
67 cons-cdr-slot list-pointer-lowtag)))
68 (aver (null (tn-ref-across things)))
69 (move res result))))))))
71 (define-vop (list list-or-list*)
74 (define-vop (list* list-or-list*)
77 ;;;; special purpose inline allocators
79 (define-vop (allocate-code-object)
80 (:args (boxed-arg :scs (any-reg))
81 (unboxed-arg :scs (any-reg)))
82 (:results (result :scs (descriptor-reg)))
83 (:temporary (:scs (non-descriptor-reg)) ndescr)
84 (:temporary (:scs (any-reg) :from (:argument 0)) boxed)
85 (:temporary (:scs (non-descriptor-reg) :from (:argument 1)) unboxed)
87 (inst li (lognot lowtag-mask) ndescr)
88 (inst lda boxed (fixnumize (1+ code-trace-table-offset-slot))
90 (inst and boxed ndescr boxed)
91 (inst srl unboxed-arg word-shift unboxed)
92 (inst lda unboxed lowtag-mask unboxed)
93 (inst and unboxed ndescr unboxed)
94 (inst sll boxed (- n-widetag-bits word-shift) ndescr)
95 (inst bis ndescr code-header-widetag ndescr)
98 (inst bis alloc-tn other-pointer-lowtag result)
99 (storew ndescr result 0 other-pointer-lowtag)
100 (storew unboxed result code-code-size-slot other-pointer-lowtag)
101 (storew null-tn result code-entry-points-slot other-pointer-lowtag)
102 (inst addq alloc-tn boxed alloc-tn)
103 (inst addq alloc-tn unboxed alloc-tn))
105 (storew null-tn result code-debug-info-slot other-pointer-lowtag)))
107 (define-vop (make-fdefn)
109 (:translate make-fdefn)
110 (:args (name :scs (descriptor-reg) :to :eval))
111 (:temporary (:scs (non-descriptor-reg)) temp)
112 (:results (result :scs (descriptor-reg) :from :argument))
114 (with-fixed-allocation (result temp fdefn-widetag fdefn-size)
115 (storew name result fdefn-name-slot other-pointer-lowtag)
116 (storew null-tn result fdefn-fun-slot other-pointer-lowtag)
117 (inst li (make-fixup "undefined_tramp" :foreign) temp)
118 (storew temp result fdefn-raw-addr-slot other-pointer-lowtag))))
120 (define-vop (make-closure)
121 (:args (function :to :save :scs (descriptor-reg)))
122 (:info length stack-allocate-p)
123 (:temporary (:scs (non-descriptor-reg)) temp)
124 (:results (result :scs (descriptor-reg)))
126 (let* ((size (+ length closure-info-offset))
127 (alloc-size (pad-data-block size)))
129 (logior (ash (1- size) n-widetag-bits) closure-header-widetag)
131 (pseudo-atomic (:extra (if stack-allocate-p 0 alloc-size))
132 (cond (stack-allocate-p
134 (inst bis csp-tn fun-pointer-lowtag result)
135 (inst lda csp-tn alloc-size csp-tn))
137 (inst bis alloc-tn fun-pointer-lowtag result)))
138 (storew temp result 0 fun-pointer-lowtag)
139 (storew function result closure-fun-slot fun-pointer-lowtag)))))
141 ;;; The compiler likes to be able to directly make value cells.
142 (define-vop (make-value-cell)
143 (:args (value :to :save :scs (descriptor-reg any-reg null zero)))
144 (:temporary (:scs (non-descriptor-reg)) temp)
145 (:info stack-allocate-p)
146 (:ignore stack-allocate-p)
147 (:results (result :scs (descriptor-reg)))
149 (with-fixed-allocation
150 (result temp value-cell-header-widetag value-cell-size)
151 (storew value result value-cell-value-slot other-pointer-lowtag))))
153 ;;;; automatic allocators for primitive objects
155 (define-vop (make-unbound-marker)
157 (:results (result :scs (any-reg)))
159 (inst li unbound-marker-widetag result)))
161 (define-vop (make-funcallable-instance-tramp)
163 (:results (result :scs (any-reg)))
165 (inst li (make-fixup "funcallable_instance_tramp" :foreign) result)))
167 (define-vop (fixed-alloc)
169 (:info name words type lowtag stack-allocate-p)
170 (:ignore name stack-allocate-p)
171 (:results (result :scs (descriptor-reg)))
172 (:temporary (:scs (non-descriptor-reg)) temp)
174 (pseudo-atomic (:extra (pad-data-block words))
175 (inst bis alloc-tn lowtag result)
177 (inst li (logior (ash (1- words) n-widetag-bits) type) temp)
178 (storew temp result 0 lowtag)))))
180 (define-vop (var-alloc)
181 (:args (extra :scs (any-reg)))
182 (:arg-types positive-fixnum)
183 (:info name words type lowtag)
185 (:results (result :scs (descriptor-reg)))
186 (:temporary (:scs (non-descriptor-reg)) header)
187 (:temporary (:scs (non-descriptor-reg)) bytes)
189 (inst lda bytes (* (1+ words) n-word-bytes) extra)
190 (inst sll bytes (- n-widetag-bits 2) header)
191 (inst lda header (+ (ash -2 n-widetag-bits) type) header)
192 (inst srl bytes n-lowtag-bits bytes)
193 (inst sll bytes n-lowtag-bits bytes)
195 (inst bis alloc-tn lowtag result)
196 (storew header result 0 lowtag)
197 (inst addq alloc-tn bytes alloc-tn))))