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.
16 (define-vop (list-or-list*)
17 (:args (things :more t))
18 (:temporary (:scs (descriptor-reg) :type list) ptr)
19 (:temporary (:scs (descriptor-reg)) temp)
20 (:temporary (:scs (descriptor-reg) :type list :to (:result 0) :target result)
23 (: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 ((cons-cells (if star (1- num) num)))
44 (pseudo-atomic (:extra (* (pad-data-block cons-size)
46 (inst bis alloc-tn list-pointer-lowtag res)
48 (dotimes (i (1- cons-cells))
49 (store-car (tn-ref-tn things) ptr)
50 (setf things (tn-ref-across things))
51 (inst lda ptr (pad-data-block cons-size) ptr)
53 (- cons-cdr-slot cons-size)
55 (store-car (tn-ref-tn things) ptr)
57 (setf things (tn-ref-across things))
58 (store-car (tn-ref-tn things) ptr cons-cdr-slot))
61 cons-cdr-slot list-pointer-lowtag)))
62 (assert (null (tn-ref-across things)))
63 (move res result))))))))
65 (define-vop (list list-or-list*)
68 (define-vop (list* list-or-list*)
71 ;;;; special purpose inline allocators
73 (define-vop (allocate-code-object)
74 (:args (boxed-arg :scs (any-reg))
75 (unboxed-arg :scs (any-reg)))
76 (:results (result :scs (descriptor-reg)))
77 (:temporary (:scs (non-descriptor-reg)) ndescr)
78 (:temporary (:scs (any-reg) :from (:argument 0)) boxed)
79 (:temporary (:scs (non-descriptor-reg) :from (:argument 1)) unboxed)
81 (inst li (lognot lowtag-mask) ndescr)
82 (inst lda boxed (fixnumize (1+ code-trace-table-offset-slot))
84 (inst and boxed ndescr boxed)
85 (inst srl unboxed-arg word-shift unboxed)
86 (inst lda unboxed lowtag-mask unboxed)
87 (inst and unboxed ndescr unboxed)
88 (inst sll boxed (- n-widetag-bits word-shift) ndescr)
89 (inst bis ndescr code-header-widetag ndescr)
92 (inst bis alloc-tn other-pointer-lowtag result)
93 (storew ndescr result 0 other-pointer-lowtag)
94 (storew unboxed result code-code-size-slot other-pointer-lowtag)
95 (storew null-tn result code-entry-points-slot other-pointer-lowtag)
96 (inst addq alloc-tn boxed alloc-tn)
97 (inst addq alloc-tn unboxed alloc-tn))
99 (storew null-tn result code-debug-info-slot other-pointer-lowtag)))
101 (define-vop (make-fdefn)
103 (:translate make-fdefn)
104 (:args (name :scs (descriptor-reg) :to :eval))
105 (:temporary (:scs (non-descriptor-reg)) temp)
106 (:results (result :scs (descriptor-reg) :from :argument))
108 (with-fixed-allocation (result temp fdefn-widetag fdefn-size)
109 (storew name result fdefn-name-slot other-pointer-lowtag)
110 (storew null-tn result fdefn-fun-slot other-pointer-lowtag)
111 (inst li (make-fixup "undefined_tramp" :foreign) temp)
112 (storew temp result fdefn-raw-addr-slot other-pointer-lowtag))))
114 (define-vop (make-closure)
115 (:args (function :to :save :scs (descriptor-reg)))
117 (:temporary (:scs (non-descriptor-reg)) temp)
118 (:results (result :scs (descriptor-reg)))
120 (let ((size (+ length closure-info-offset)))
122 (logior (ash (1- size) n-widetag-bits) closure-header-widetag)
124 (pseudo-atomic (:extra (pad-data-block size))
125 (inst bis alloc-tn fun-pointer-lowtag result)
126 (storew temp result 0 fun-pointer-lowtag))
127 (storew function result closure-fun-slot fun-pointer-lowtag))))
129 ;;; The compiler likes to be able to directly make value cells.
131 (define-vop (make-value-cell)
132 (:args (value :to :save :scs (descriptor-reg any-reg null zero)))
133 (:temporary (:scs (non-descriptor-reg)) temp)
134 (:results (result :scs (descriptor-reg)))
136 (with-fixed-allocation
137 (result temp value-cell-header-widetag value-cell-size))
138 (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 unbound-marker-widetag result)))
149 (define-vop (fixed-alloc)
151 (:info name words type lowtag)
153 (:results (result :scs (descriptor-reg)))
154 (:temporary (:scs (non-descriptor-reg)) temp)
156 (pseudo-atomic (:extra (pad-data-block words))
157 (inst bis alloc-tn lowtag result)
159 (inst li (logior (ash (1- words) n-widetag-bits) type) temp)
160 (storew temp result 0 lowtag)))))
162 (define-vop (var-alloc)
163 (:args (extra :scs (any-reg)))
164 (:arg-types positive-fixnum)
165 (:info name words type lowtag)
167 (:results (result :scs (descriptor-reg)))
168 (:temporary (:scs (non-descriptor-reg)) header)
169 (:temporary (:scs (non-descriptor-reg)) bytes)
171 (inst lda bytes (* (1+ words) n-word-bytes) extra)
172 (inst sll bytes (- n-widetag-bits 2) header)
173 (inst lda header (+ (ash -2 n-widetag-bits) type) header)
174 (inst srl bytes n-lowtag-bits bytes)
175 (inst sll bytes n-lowtag-bits bytes)
177 (inst bis alloc-tn lowtag result)
178 (storew header result 0 lowtag)
179 (inst addq alloc-tn bytes alloc-tn))))