1 ;;;; allocation VOPs for the HPPA
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.
17 (define-vop (list-or-list*)
18 (:args
(things :more t
))
19 (:temporary
(:scs
(descriptor-reg) :type list
) ptr
)
20 (:temporary
(:scs
(descriptor-reg)) temp
)
21 (:temporary
(:scs
(descriptor-reg) :type list
:to
(:result
0) :target result
)
24 (:results
(result :scs
(descriptor-reg)))
30 (move null-tn result
))
32 (move (tn-ref-tn things
) result
))
38 ((any-reg descriptor-reg zero null
)
41 (load-stack-tn temp
,tn
)
43 (let* ((cons-cells (if star
(1- num
) num
))
44 (alloc (* (pad-data-block cons-size
) cons-cells
)))
45 (pseudo-atomic (:extra alloc
)
47 (inst dep list-pointer-lowtag
31 3 res
)
49 (dotimes (i (1- cons-cells
))
50 (storew (maybe-load (tn-ref-tn things
)) ptr
51 cons-car-slot list-pointer-lowtag
)
52 (setf things
(tn-ref-across things
))
53 (inst addi
(pad-data-block cons-size
) ptr ptr
)
55 (- cons-cdr-slot cons-size
)
57 (storew (maybe-load (tn-ref-tn things
)) ptr
58 cons-car-slot list-pointer-lowtag
)
60 (maybe-load (tn-ref-tn (tn-ref-across things
)))
62 ptr cons-cdr-slot list-pointer-lowtag
))
63 (move res result
)))))))
66 (define-vop (list list-or-list
*)
69 (define-vop (list* list-or-list
*)
73 ;;;; Special purpose inline allocators.
75 (define-vop (allocate-code-object)
76 (:args
(boxed-arg :scs
(any-reg))
77 (unboxed-arg :scs
(any-reg)))
78 (:results
(result :scs
(descriptor-reg)))
79 (:temporary
(:scs
(non-descriptor-reg)) ndescr
)
80 (:temporary
(:scs
(any-reg) :from
(:argument
0)) boxed
)
81 (:temporary
(:scs
(non-descriptor-reg) :from
(:argument
1)) unboxed
)
83 (inst addi
(fixnumize (1+ code-trace-table-offset-slot
)) boxed-arg boxed
)
84 (inst dep
0 31 3 boxed
)
85 (inst srl unboxed-arg word-shift unboxed
)
86 (inst addi lowtag-mask unboxed unboxed
)
87 (inst dep
0 31 3 unboxed
)
89 ;; Note: we don't have to subtract off the 4 that was added by
90 ;; pseudo-atomic, because depositing other-pointer-lowtag just adds
92 (inst move alloc-tn result
)
93 (inst dep other-pointer-lowtag
31 3 result
)
94 (inst add alloc-tn boxed alloc-tn
)
95 (inst add alloc-tn unboxed alloc-tn
)
96 (inst sll boxed
(- n-widetag-bits word-shift
) ndescr
)
97 (inst addi code-header-widetag ndescr ndescr
)
98 (storew ndescr result
0 other-pointer-lowtag
)
99 (storew unboxed result code-code-size-slot other-pointer-lowtag
)
100 (storew null-tn result code-entry-points-slot other-pointer-lowtag
)
101 (storew null-tn result code-debug-info-slot other-pointer-lowtag
))))
103 (define-vop (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 (:translate make-fdefn
)
110 (with-fixed-allocation (result temp fdefn-widetag fdefn-size
)
111 (inst li
(make-fixup "undefined_tramp" :foreign
) temp
)
112 (storew name result fdefn-name-slot other-pointer-lowtag
)
113 (storew null-tn result fdefn-fun-slot other-pointer-lowtag
)
114 (storew temp result fdefn-raw-addr-slot other-pointer-lowtag
))))
116 (define-vop (make-closure)
117 (:args
(function :to
:save
:scs
(descriptor-reg)))
118 (:info length stack-allocate-p
)
119 (:ignore stack-allocate-p
)
120 (:temporary
(:scs
(non-descriptor-reg)) temp
)
121 (:results
(result :scs
(descriptor-reg)))
123 (let ((size (+ length closure-info-offset
)))
124 (pseudo-atomic (:extra
(pad-data-block size
))
125 (inst move alloc-tn result
)
126 (inst dep fun-pointer-lowtag
31 3 result
)
127 (inst li
(logior (ash (1- size
) n-widetag-bits
) closure-header-widetag
) temp
)
128 (storew temp result
0 fun-pointer-lowtag
)
129 (storew function result closure-fun-slot fun-pointer-lowtag
)))))
131 ;;; The compiler likes to be able to directly make value cells.
132 (define-vop (make-value-cell)
133 (:args
(value :to
:save
:scs
(descriptor-reg any-reg
)))
134 (:temporary
(:scs
(non-descriptor-reg)) temp
)
135 (:results
(result :scs
(descriptor-reg)))
136 (:info stack-allocate-p
)
137 (:ignore stack-allocate-p
)
139 (with-fixed-allocation
140 (result temp value-cell-header-widetag value-cell-size
))
141 (storew value result value-cell-value-slot other-pointer-lowtag
)))
145 ;;;; Automatic allocators for primitive objects.
147 (define-vop (make-unbound-marker)
149 (:results
(result :scs
(any-reg)))
151 (inst li unbound-marker-widetag result
)))
153 (define-vop (make-funcallable-instance-tramp)
155 (:results
(result :scs
(any-reg)))
157 (inst li
(make-fixup "funcallable_instance_tramp" :foreign
) result
)))
159 (define-vop (fixed-alloc)
161 (:info name words type lowtag stack-allocate-p
)
162 (:ignore name stack-allocate-p
)
163 (:results
(result :scs
(descriptor-reg)))
164 (:temporary
(:scs
(non-descriptor-reg)) temp
)
166 (pseudo-atomic (:extra
(pad-data-block words
))
167 (inst move alloc-tn result
)
168 (inst dep lowtag
31 3 result
)
170 (inst li
(logior (ash (1- words
) n-widetag-bits
) type
) temp
)
171 (storew temp result
0 lowtag
)))))
173 (define-vop (var-alloc)
174 (:args
(extra :scs
(any-reg)))
175 (:arg-types positive-fixnum
)
176 (:info name words type lowtag
)
178 (:results
(result :scs
(descriptor-reg)))
179 (:temporary
(:scs
(any-reg)) bytes
)
180 (:temporary
(:scs
(non-descriptor-reg)) header
)
182 (inst addi
(* (1+ words
) n-word-bytes
) extra bytes
)
183 (inst sll bytes
(- n-widetag-bits
2) header
)
184 (inst addi
(+ (ash -
2 n-widetag-bits
) type
) header header
)
185 (inst dep
0 31 3 bytes
)
187 (inst move alloc-tn result
)
188 (inst dep lowtag
31 3 result
)
189 (storew header result
0 lowtag
)
190 (inst add alloc-tn bytes alloc-tn
))))