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 (pointer-hash)
109 (:translate pointer-hash)
110 (:args (ptr :scs (any-reg descriptor-reg)))
111 (:results (res :scs (any-reg descriptor-reg)))
114 ;; FIXME: It would be better if this would mask the lowtag,
115 ;; and shift the result into a positive fixnum like on x86.
116 (inst zdep ptr 29 29 res)))
118 (define-vop (make-other-immediate-type)
119 (:args (val :scs (any-reg descriptor-reg))
120 (type :scs (any-reg descriptor-reg) :target temp))
121 (:results (res :scs (any-reg descriptor-reg) :from (:argument 0)))
122 (:temporary (:scs (non-descriptor-reg)) temp)
124 (inst sll val (- n-widetag-bits 2) res)
125 (inst sra type 2 temp)
126 (inst or res temp res)))
131 (define-vop (dynamic-space-free-pointer)
132 (:results (int :scs (sap-reg)))
133 (:result-types system-area-pointer)
134 (:translate dynamic-space-free-pointer)
137 (move alloc-tn int)))
139 (define-vop (binding-stack-pointer-sap)
140 (:results (int :scs (sap-reg)))
141 (:result-types system-area-pointer)
142 (:translate binding-stack-pointer-sap)
147 (define-vop (control-stack-pointer-sap)
148 (:results (int :scs (sap-reg)))
149 (:result-types system-area-pointer)
150 (:translate control-stack-pointer-sap)
156 ;;;; Code object frobbing.
158 (define-vop (code-instructions)
159 (:translate code-instructions)
161 (:args (code :scs (descriptor-reg)))
162 (:temporary (:scs (non-descriptor-reg)) ndescr)
163 (:results (sap :scs (sap-reg)))
164 (:result-types system-area-pointer)
166 (loadw ndescr code 0 other-pointer-lowtag)
167 (inst srl ndescr 8 ndescr)
168 (inst sll ndescr 2 ndescr)
169 (inst addi (- other-pointer-lowtag) ndescr ndescr)
170 (inst add code ndescr sap)))
172 (define-vop (compute-fun)
173 (:args (code :scs (descriptor-reg))
174 (offset :scs (signed-reg unsigned-reg)))
175 (:arg-types * positive-fixnum)
176 (:results (func :scs (descriptor-reg)))
177 (:temporary (:scs (non-descriptor-reg)) ndescr)
179 (loadw ndescr code 0 other-pointer-lowtag)
180 (inst srl ndescr 8 ndescr)
181 (inst sll ndescr 2 ndescr)
182 (inst add ndescr offset ndescr)
183 (inst addi (- fun-pointer-lowtag other-pointer-lowtag) ndescr ndescr)
184 (inst add ndescr code func)))
187 ;;;; Other random VOPs.
190 (defknown sb!unix::receive-pending-interrupt () (values))
191 (define-vop (sb!unix::receive-pending-interrupt)
193 (:translate sb!unix::receive-pending-interrupt)
195 (inst break pending-interrupt-trap)))
200 (inst break halt-trap)))
203 ;;;; Dynamic vop count collection support
205 (define-vop (count-me)
206 (:args (count-vector :scs (descriptor-reg)))
208 (:temporary (:scs (non-descriptor-reg)) count)
211 (- (* (+ index vector-data-offset) n-word-bytes) other-pointer-lowtag)))
212 (inst ldw offset count-vector count)
213 (inst addi 1 count count)
214 (inst stw count offset count-vector))))