4 ;;;; Type frobbing VOPs
6 (define-vop (lowtag-of)
9 (:args (object :scs (any-reg descriptor-reg) :target result))
10 (:results (result :scs (unsigned-reg)))
11 (:result-types positive-fixnum)
13 (inst extru object 31 3 result)))
15 (define-vop (widetag-of)
16 (:translate widetag-of)
18 (:args (object :scs (descriptor-reg) :to (:eval 1)))
19 (:results (result :scs (unsigned-reg) :from (:eval 0)))
20 (:result-types positive-fixnum)
22 (inst extru object 31 3 result)
23 (inst comib := other-pointer-lowtag result other-ptr :nullify t)
24 (inst comib := fun-pointer-lowtag result function-ptr :nullify t)
25 (inst bb t object 31 done :nullify t)
26 (inst extru object 31 2 result :=)
27 (inst extru object 31 8 result)
31 (load-type result object (- fun-pointer-lowtag))
35 (load-type result object (- other-pointer-lowtag))
39 (define-vop (fun-subtype)
40 (:translate fun-subtype)
42 (:args (function :scs (descriptor-reg)))
43 (:results (result :scs (unsigned-reg)))
44 (:result-types positive-fixnum)
46 (load-type result function (- fun-pointer-lowtag))))
48 (define-vop (set-fun-subtype)
49 (:translate (setf fun-subtype))
51 (:args (type :scs (unsigned-reg) :target result)
52 (function :scs (descriptor-reg)))
53 (:arg-types positive-fixnum *)
54 (:results (result :scs (unsigned-reg)))
55 (:result-types positive-fixnum)
57 (inst stb type (- 3 fun-pointer-lowtag) function)
60 (define-vop (get-header-data)
61 (:translate get-header-data)
63 (:args (x :scs (descriptor-reg)))
64 (:results (res :scs (unsigned-reg)))
65 (:result-types positive-fixnum)
67 (loadw res x 0 other-pointer-lowtag)
68 (inst srl res 8 res)))
70 (define-vop (get-closure-length)
71 (:translate get-closure-length)
73 (:args (x :scs (descriptor-reg)))
74 (:results (res :scs (unsigned-reg)))
75 (:result-types positive-fixnum)
77 (loadw res x 0 fun-pointer-lowtag)
78 (inst srl res 8 res)))
80 (define-vop (set-header-data)
81 (:translate set-header-data)
83 (:args (x :scs (descriptor-reg) :target res)
84 (data :scs (unsigned-reg)))
85 (:arg-types * positive-fixnum)
86 (:results (res :scs (descriptor-reg)))
87 (:temporary (:scs (non-descriptor-reg)) temp)
89 (loadw temp x 0 other-pointer-lowtag)
90 (inst dep data 23 24 temp)
91 (storew temp x 0 other-pointer-lowtag)
94 (define-vop (set-header-data-c)
95 (:translate set-header-data)
97 (:args (x :scs (descriptor-reg) :target res))
98 (:arg-types * (:constant (signed-byte 5)))
100 (:results (res :scs (descriptor-reg)))
101 (:temporary (:scs (non-descriptor-reg)) temp)
103 (loadw temp x 0 other-pointer-lowtag)
104 (inst dep data 23 24 temp)
105 (storew temp x 0 other-pointer-lowtag)
108 (define-vop (make-fixnum)
109 (:args (ptr :scs (any-reg descriptor-reg)))
110 (:results (res :scs (any-reg descriptor-reg)))
113 ;; Some code (the hash table code) depends on this returning a
114 ;; positive number so make sure it does.
115 (inst zdep ptr 29 29 res)))
117 (define-vop (make-other-immediate-type)
118 (:args (val :scs (any-reg descriptor-reg))
119 (type :scs (any-reg descriptor-reg) :target temp))
120 (:results (res :scs (any-reg descriptor-reg) :from (:argument 0)))
121 (:temporary (:scs (non-descriptor-reg)) temp)
123 (inst sll val (- n-widetag-bits 2) res)
124 (inst sra type 2 temp)
125 (inst or res temp res)))
130 (define-vop (dynamic-space-free-pointer)
131 (:results (int :scs (sap-reg)))
132 (:result-types system-area-pointer)
133 (:translate dynamic-space-free-pointer)
136 (move alloc-tn int)))
138 (define-vop (binding-stack-pointer-sap)
139 (:results (int :scs (sap-reg)))
140 (:result-types system-area-pointer)
141 (:translate binding-stack-pointer-sap)
146 (define-vop (control-stack-pointer-sap)
147 (:results (int :scs (sap-reg)))
148 (:result-types system-area-pointer)
149 (:translate control-stack-pointer-sap)
155 ;;;; Code object frobbing.
157 (define-vop (code-instructions)
158 (:translate code-instructions)
160 (:args (code :scs (descriptor-reg)))
161 (:temporary (:scs (non-descriptor-reg)) ndescr)
162 (:results (sap :scs (sap-reg)))
163 (:result-types system-area-pointer)
165 (loadw ndescr code 0 other-pointer-lowtag)
166 (inst srl ndescr 8 ndescr)
167 (inst sll ndescr 2 ndescr)
168 (inst addi (- other-pointer-lowtag) ndescr ndescr)
169 (inst add code ndescr sap)))
171 (define-vop (compute-fun)
172 (:args (code :scs (descriptor-reg))
173 (offset :scs (signed-reg unsigned-reg)))
174 (:arg-types * positive-fixnum)
175 (:results (func :scs (descriptor-reg)))
176 (:temporary (:scs (non-descriptor-reg)) ndescr)
178 (loadw ndescr code 0 other-pointer-lowtag)
179 (inst srl ndescr 8 ndescr)
180 (inst sll ndescr 2 ndescr)
181 (inst add ndescr offset ndescr)
182 (inst addi (- fun-pointer-lowtag other-pointer-lowtag) ndescr ndescr)
183 (inst add ndescr code func)))
186 ;;;; Other random VOPs.
189 (defknown sb!unix::receive-pending-interrupt () (values))
190 (define-vop (sb!unix::receive-pending-interrupt)
192 (:translate sb!unix::receive-pending-interrupt)
194 (inst break pending-interrupt-trap)))
199 (inst break halt-trap)))
202 ;;;; Dynamic vop count collection support
204 (define-vop (count-me)
205 (:args (count-vector :scs (descriptor-reg)))
207 (:temporary (:scs (non-descriptor-reg)) count)
210 (- (* (+ index vector-data-offset) n-word-bytes) other-pointer-lowtag)))
211 (inst ldw offset count-vector count)
212 (inst addi 1 count count)
213 (inst stw count offset count-vector))))