1 ;;;; Sparc 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.
14 ;;;; type frobbing VOPs
16 (define-vop (lowtag-of)
17 (:translate lowtag-of)
19 (:args (object :scs (any-reg descriptor-reg)))
20 (:results (result :scs (unsigned-reg)))
21 (:result-types positive-fixnum)
23 (inst and result object lowtag-mask)))
25 (define-vop (widetag-of)
26 (:translate widetag-of)
28 (:args (object :scs (descriptor-reg) :to (:eval 1)))
29 (:results (result :scs (unsigned-reg) :from (:eval 0)))
30 (:result-types positive-fixnum)
33 (inst andcc result object lowtag-mask)
34 ;; Check for various pointer types.
35 (inst cmp result list-pointer-lowtag)
37 (inst cmp result other-pointer-lowtag)
38 (inst b :eq other-pointer)
39 (inst cmp result fun-pointer-lowtag)
40 (inst b :eq function-pointer)
41 (inst cmp result instance-pointer-lowtag)
43 ;; Okay, it is an immediate. If fixnum, we want zero. Otherwise,
44 ;; we want the low 8 bits.
45 (inst andcc zero-tn object fixnum-tag-mask)
48 ;; It wasn't a fixnum, so get the low 8 bits.
50 (inst and result object widetag-mask)
54 (load-type result object (- fun-pointer-lowtag))
57 (load-type result object (- other-pointer-lowtag))
62 (define-vop (fun-subtype)
63 (:translate fun-subtype)
65 (:args (function :scs (descriptor-reg)))
66 (:results (result :scs (unsigned-reg)))
67 (:result-types positive-fixnum)
69 (load-type result function (- fun-pointer-lowtag))))
71 ;;; Is this VOP dead? I can't see anywhere that it is used... -- CSR,
73 (define-vop (set-fun-subtype)
74 (:translate (setf fun-subtype))
76 (:args (type :scs (unsigned-reg) :target result)
77 (function :scs (descriptor-reg)))
78 (:arg-types positive-fixnum *)
79 (:results (result :scs (unsigned-reg)))
80 (:result-types positive-fixnum)
82 ;; FIXME: I don't understand what this hardcoded 3 is doing
83 ;; here. -- CSR, 2002-02-08
84 (inst stb type function (- 3 fun-pointer-lowtag))
87 (define-vop (get-header-data)
88 (:translate get-header-data)
90 (:args (x :scs (descriptor-reg)))
91 (:results (res :scs (unsigned-reg)))
92 (:result-types positive-fixnum)
94 (loadw res x 0 other-pointer-lowtag)
95 (inst srl res res n-widetag-bits)))
97 (define-vop (get-closure-length)
98 (:translate get-closure-length)
100 (:args (x :scs (descriptor-reg)))
101 (:results (res :scs (unsigned-reg)))
102 (:result-types positive-fixnum)
104 (loadw res x 0 fun-pointer-lowtag)
105 (inst srl res res n-widetag-bits)))
107 (define-vop (set-header-data)
108 (:translate set-header-data)
110 (:args (x :scs (descriptor-reg) :target res)
111 (data :scs (any-reg immediate zero)))
112 (:arg-types * positive-fixnum)
113 (:results (res :scs (descriptor-reg)))
114 (:temporary (:scs (non-descriptor-reg)) t1 t2)
116 (loadw t1 x 0 other-pointer-lowtag)
117 (inst and t1 widetag-mask)
120 (inst sll t2 data (- n-widetag-bits n-fixnum-tag-bits))
123 (inst or t1 (ash (tn-value data) n-widetag-bits)))
125 (storew t1 x 0 other-pointer-lowtag)
129 (define-vop (pointer-hash)
130 (:translate pointer-hash)
131 (:args (ptr :scs (any-reg descriptor-reg)))
132 (:results (res :scs (any-reg descriptor-reg)))
135 ;; FIXME: It would be better if this would mask the lowtag,
136 ;; and shift the result into a positive fixnum like on x86.
138 (inst srl res res 1)))
143 (define-vop (dynamic-space-free-pointer)
144 (:results (int :scs (sap-reg)))
145 (:result-types system-area-pointer)
146 (:translate dynamic-space-free-pointer)
149 (move int alloc-tn)))
151 (define-vop (binding-stack-pointer-sap)
152 (:results (int :scs (sap-reg)))
153 (:result-types system-area-pointer)
154 (:translate binding-stack-pointer-sap)
159 (define-vop (control-stack-pointer-sap)
160 (:results (int :scs (sap-reg)))
161 (:result-types system-area-pointer)
162 (:translate control-stack-pointer-sap)
168 ;;;; code object frobbing.
170 (define-vop (code-instructions)
171 (:translate code-instructions)
173 (:args (code :scs (descriptor-reg)))
174 (:temporary (:scs (non-descriptor-reg)) ndescr)
175 (:results (sap :scs (sap-reg)))
176 (:result-types system-area-pointer)
178 (loadw ndescr code 0 other-pointer-lowtag)
179 (inst srl ndescr n-widetag-bits)
180 (inst sll ndescr word-shift)
181 (inst sub ndescr other-pointer-lowtag)
182 (inst add sap code ndescr)))
184 (define-vop (compute-fun)
185 (:args (code :scs (descriptor-reg))
186 (offset :scs (signed-reg unsigned-reg)))
187 (:arg-types * positive-fixnum)
188 (:results (func :scs (descriptor-reg)))
189 (:temporary (:scs (non-descriptor-reg)) ndescr)
191 (loadw ndescr code 0 other-pointer-lowtag)
192 (inst srl ndescr n-widetag-bits)
193 (inst sll ndescr word-shift)
194 (inst add ndescr offset)
195 (inst add ndescr (- fun-pointer-lowtag other-pointer-lowtag))
196 (inst add func code ndescr)))
200 ;;;; other random VOPs.
203 (defknown sb!unix::receive-pending-interrupt () (values))
204 (define-vop (sb!unix::receive-pending-interrupt)
206 (:translate sb!unix::receive-pending-interrupt)
208 (inst unimp pending-interrupt-trap)))
211 (error "write a VOP for CURRENT-THREAD-OFFSET-SAP")
215 (inst unimp 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)
228 other-pointer-lowtag)))
229 (aver (typep offset '(signed-byte 13)))
230 (inst ld count count-vector offset)
232 (inst st count count-vector offset))))
234 ;;;; Dummy definition for a spin-loop hint VOP
235 (define-vop (spin-loop-hint)
236 (:translate spin-loop-hint)