1 ;;;; MIPS VM definitions of various system hacking operations
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.
15 ;;;; Type frobbing VOPs
17 (define-vop (lowtag-of)
18 (:translate lowtag-of)
20 (:args (object :scs (any-reg descriptor-reg)))
21 (:results (result :scs (unsigned-reg)))
22 (:result-types positive-fixnum)
24 (inst and result object lowtag-mask)))
26 (define-vop (widetag-of)
27 (:translate widetag-of)
29 (:args (object :scs (descriptor-reg)))
30 (:temporary (:scs (non-descriptor-reg)) ndescr)
31 (:results (result :scs (unsigned-reg)))
32 (:result-types positive-fixnum)
34 ;; Pick off objects with headers.
35 (inst and ndescr object lowtag-mask)
36 (inst xor ndescr other-pointer-lowtag)
37 (inst beq ndescr other-ptr)
38 (inst xor ndescr (logxor other-pointer-lowtag fun-pointer-lowtag))
39 (inst beq ndescr function-ptr)
42 (inst and result object fixnum-tag-mask)
43 (inst beq result done)
45 ;; Pick off structure and list pointers.
46 (inst and result object 1)
47 (inst bne result lowtag-only)
50 ;; Must be an other immediate.
52 (inst and result object widetag-mask)
55 (load-type result object (- fun-pointer-lowtag))
61 (inst and result object lowtag-mask)
64 (load-type result object (- other-pointer-lowtag))
69 (define-vop (fun-subtype)
70 (:translate fun-subtype)
72 (:args (function :scs (descriptor-reg)))
73 (:results (result :scs (unsigned-reg)))
74 (:result-types positive-fixnum)
76 (load-type result function (- fun-pointer-lowtag))
79 (define-vop (set-fun-subtype)
80 (:translate (setf fun-subtype))
82 (:args (type :scs (unsigned-reg) :target result)
83 (function :scs (descriptor-reg)))
84 (:arg-types positive-fixnum *)
85 (:results (result :scs (unsigned-reg)))
86 (:result-types positive-fixnum)
88 (inst sb type function (- fun-pointer-lowtag))
92 (define-vop (get-header-data)
93 (:translate get-header-data)
95 (:args (x :scs (descriptor-reg)))
96 (:results (res :scs (unsigned-reg)))
97 (:result-types positive-fixnum)
99 (loadw res x 0 other-pointer-lowtag)
100 (inst srl res res n-widetag-bits)))
102 (define-vop (get-closure-length)
103 (:translate get-closure-length)
105 (:args (x :scs (descriptor-reg)))
106 (:results (res :scs (unsigned-reg)))
107 (:result-types positive-fixnum)
109 (loadw res x 0 fun-pointer-lowtag)
110 (inst srl res res n-widetag-bits)))
112 (define-vop (set-header-data)
113 (:translate set-header-data)
115 (:args (x :scs (descriptor-reg) :target res)
116 (data :scs (any-reg immediate zero)))
117 (:arg-types * positive-fixnum)
118 (:results (res :scs (descriptor-reg)))
119 (:temporary (:scs (non-descriptor-reg)) t1 t2)
121 (loadw t1 x 0 other-pointer-lowtag)
122 (inst and t1 widetag-mask)
125 (inst sll t2 data (- n-widetag-bits n-fixnum-tag-bits))
128 (inst or t1 (ash (tn-value data) n-widetag-bits)))
130 (storew t1 x 0 other-pointer-lowtag)
133 (define-vop (pointer-hash)
134 (:translate pointer-hash)
135 (:args (ptr :scs (any-reg descriptor-reg)))
136 (:results (res :scs (any-reg descriptor-reg)))
139 ;; FIXME: It would be better if this would mask the lowtag,
140 ;; and shift the result into a positive fixnum like on x86.
142 (inst srl res res 1)))
147 (define-vop (dynamic-space-free-pointer)
148 (:results (int :scs (sap-reg)))
149 (:result-types system-area-pointer)
150 (:translate dynamic-space-free-pointer)
153 (move int alloc-tn)))
155 (define-vop (binding-stack-pointer-sap)
156 (:results (int :scs (sap-reg)))
157 (:result-types system-area-pointer)
158 (:translate binding-stack-pointer-sap)
163 (define-vop (control-stack-pointer-sap)
164 (:results (int :scs (sap-reg)))
165 (:result-types system-area-pointer)
166 (:translate control-stack-pointer-sap)
172 ;;;; Code object frobbing.
174 (define-vop (code-instructions)
175 (:translate code-instructions)
177 (:args (code :scs (descriptor-reg)))
178 (:temporary (:scs (non-descriptor-reg)) ndescr)
179 (:results (sap :scs (sap-reg)))
180 (:result-types system-area-pointer)
182 (loadw ndescr code 0 other-pointer-lowtag)
183 (inst srl ndescr n-widetag-bits)
184 (inst sll ndescr word-shift)
185 (inst subu ndescr other-pointer-lowtag)
186 (inst addu sap code ndescr)))
188 (define-vop (compute-fun)
189 (:args (code :scs (descriptor-reg))
190 (offset :scs (signed-reg unsigned-reg)))
191 (:arg-types * positive-fixnum)
192 (:results (func :scs (descriptor-reg)))
193 (:temporary (:scs (non-descriptor-reg)) ndescr)
195 (loadw ndescr code 0 other-pointer-lowtag)
196 (inst srl ndescr n-widetag-bits)
197 (inst sll ndescr word-shift)
198 (inst addu ndescr offset)
199 (inst addu ndescr (- fun-pointer-lowtag other-pointer-lowtag))
200 (inst addu func code ndescr)))
203 ;;;; Other random VOPs.
206 (defknown sb!unix::receive-pending-interrupt () (values))
207 (define-vop (sb!unix::receive-pending-interrupt)
209 (:translate sb!unix::receive-pending-interrupt)
211 (inst break 0 pending-interrupt-trap)))
216 (inst break 0 halt-trap)))
219 ;;;; Dynamic vop count collection support
221 (define-vop (count-me)
222 (:args (count-vector :scs (descriptor-reg)))
224 (:temporary (:scs (non-descriptor-reg)) count)
227 (- (* (+ index vector-data-offset) n-word-bytes) other-pointer-lowtag)))
228 (inst lw count count-vector offset)
231 (inst sw count count-vector offset))))
233 ;;;; Dummy definition for a spin-loop hint VOP
234 (define-vop (spin-loop-hint)
235 (:translate spin-loop-hint)