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-type))))
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-type 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-type)))
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 (- type-bits word-shift) ndescr)
89 (inst bis ndescr code-header-type ndescr)
92 (inst bis alloc-tn other-pointer-type result)
93 (storew ndescr result 0 other-pointer-type)
94 (storew unboxed result code-code-size-slot other-pointer-type)
95 (storew null-tn result code-entry-points-slot other-pointer-type)
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-type)))
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-type fdefn-size)
109 (storew name result fdefn-name-slot other-pointer-type)
110 (storew null-tn result fdefn-function-slot other-pointer-type)
111 (inst li (make-fixup "undefined_tramp" :foreign) temp)
112 (storew temp result fdefn-raw-addr-slot other-pointer-type))))
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)))
121 (inst li (logior (ash (1- size) type-bits) closure-header-type) temp)
122 (pseudo-atomic (:extra (pad-data-block size))
123 (inst bis alloc-tn function-pointer-type result)
124 (storew temp result 0 function-pointer-type))
125 (storew function result closure-function-slot function-pointer-type))))
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 null zero)))
131 (:temporary (:scs (non-descriptor-reg)) temp)
132 (:results (result :scs (descriptor-reg)))
134 (with-fixed-allocation
135 (result temp value-cell-header-type value-cell-size))
136 (storew value result value-cell-value-slot other-pointer-type)))
139 ;;;; automatic allocators for primitive objects
141 (define-vop (make-unbound-marker)
143 (:results (result :scs (any-reg)))
145 (inst li unbound-marker-type result)))
147 (define-vop (fixed-alloc)
149 (:info name words type lowtag)
151 (:results (result :scs (descriptor-reg)))
152 (:temporary (:scs (non-descriptor-reg)) temp)
154 (pseudo-atomic (:extra (pad-data-block words))
155 (inst bis alloc-tn lowtag result)
157 (inst li (logior (ash (1- words) type-bits) type) temp)
158 (storew temp result 0 lowtag)))))
160 (define-vop (var-alloc)
161 (:args (extra :scs (any-reg)))
162 (:arg-types positive-fixnum)
163 (:info name words type lowtag)
165 (:results (result :scs (descriptor-reg)))
166 (:temporary (:scs (non-descriptor-reg)) header)
167 (:temporary (:scs (non-descriptor-reg)) bytes)
169 (inst lda bytes (* (1+ words) word-bytes) extra)
170 (inst sll bytes (- type-bits 2) header)
171 (inst lda header (+ (ash -2 type-bits) type) header)
172 (inst srl bytes lowtag-bits bytes)
173 (inst sll bytes lowtag-bits bytes)
175 (inst bis alloc-tn lowtag result)
176 (storew header result 0 lowtag)
177 (inst addq alloc-tn bytes alloc-tn))))