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 (widetag-of)
17 (:translate widetag-of
)
19 (:args
(object :scs
(descriptor-reg) :to
(:eval
1)))
20 (:results
(result :scs
(unsigned-reg) :from
(:eval
0)))
21 (:result-types positive-fixnum
)
24 (inst andcc result object lowtag-mask
)
25 ;; Check for various pointer types.
26 (inst cmp result list-pointer-lowtag
)
28 (inst cmp result other-pointer-lowtag
)
29 (inst b
:eq other-pointer
)
30 (inst cmp result fun-pointer-lowtag
)
31 (inst b
:eq function-pointer
)
32 (inst cmp result instance-pointer-lowtag
)
34 ;; Okay, it is an immediate. If fixnum, we want zero. Otherwise,
35 ;; we want the low 8 bits.
36 (inst andcc zero-tn object fixnum-tag-mask
)
39 ;; It wasn't a fixnum, so get the low 8 bits.
41 (inst and result object widetag-mask
)
45 (load-type result object
(- fun-pointer-lowtag
))
48 (load-type result object
(- other-pointer-lowtag
))
52 (define-vop (%other-pointer-widetag
)
53 (:translate %other-pointer-widetag
)
55 (:args
(object :scs
(descriptor-reg)))
56 (:results
(result :scs
(unsigned-reg)))
57 (:result-types positive-fixnum
)
59 (load-type result object
(- other-pointer-lowtag
))))
61 (define-vop (fun-subtype)
62 (:translate fun-subtype
)
64 (:args
(function :scs
(descriptor-reg)))
65 (:results
(result :scs
(unsigned-reg)))
66 (:result-types positive-fixnum
)
68 (load-type result function
(- fun-pointer-lowtag
))))
70 (define-vop (get-header-data)
71 (:translate get-header-data
)
73 (:args
(x :scs
(descriptor-reg)))
74 (:results
(res :scs
(unsigned-reg)))
75 (:result-types positive-fixnum
)
77 (loadw res x
0 other-pointer-lowtag
)
78 (inst srl res res n-widetag-bits
)))
80 (define-vop (get-closure-length)
81 (:translate get-closure-length
)
83 (:args
(x :scs
(descriptor-reg)))
84 (:results
(res :scs
(unsigned-reg)))
85 (:result-types positive-fixnum
)
87 (loadw res x
0 fun-pointer-lowtag
)
88 (let* ((n-size-bits (integer-length short-header-max-words
))
89 (lshift (- n-word-bits
(+ n-size-bits n-widetag-bits
))))
90 ;; To avoid constructing a 15-bit mask which would require another
91 ;; instruction, (ldb (byte n-size-bits n-widetag-bits) ...)
92 ;; is done as "shift left, shift right" discarding bits out both ends.
93 (inst sll res res lshift
)
94 (inst srl res res
(+ lshift n-widetag-bits
)))))
96 (define-vop (set-header-data)
97 (:translate set-header-data
)
99 (:args
(x :scs
(descriptor-reg) :target res
)
100 (data :scs
(any-reg immediate zero
)))
101 (:arg-types
* positive-fixnum
)
102 (:results
(res :scs
(descriptor-reg)))
103 (:temporary
(:scs
(non-descriptor-reg)) t1 t2
)
105 (loadw t1 x
0 other-pointer-lowtag
)
106 (inst and t1 widetag-mask
)
109 (inst sll t2 data
(- n-widetag-bits n-fixnum-tag-bits
))
112 (let ((val (ash (tn-value data
) n-widetag-bits
)))
113 (cond ((typep val
'(signed-byte 13))
119 (storew t1 x
0 other-pointer-lowtag
)
123 (define-vop (pointer-hash)
124 (:translate pointer-hash
)
125 (:args
(ptr :scs
(any-reg descriptor-reg
)))
126 (:results
(res :scs
(any-reg descriptor-reg
)))
129 ;; FIXME: It would be better if this would mask the lowtag,
130 ;; and shift the result into a positive fixnum like on x86.
132 (inst srl res res
1)))
137 (define-vop (dynamic-space-free-pointer)
138 (:results
(int :scs
(sap-reg)))
139 (:result-types system-area-pointer
)
140 (:translate dynamic-space-free-pointer
)
143 (move int alloc-tn
)))
145 (define-vop (binding-stack-pointer-sap)
146 (:results
(int :scs
(sap-reg)))
147 (:result-types system-area-pointer
)
148 (:translate binding-stack-pointer-sap
)
153 (define-vop (control-stack-pointer-sap)
154 (:results
(int :scs
(sap-reg)))
155 (:result-types system-area-pointer
)
156 (:translate control-stack-pointer-sap
)
162 ;;;; code object frobbing.
164 (define-vop (code-instructions)
165 (:translate code-instructions
)
167 (:args
(code :scs
(descriptor-reg)))
168 (:temporary
(:scs
(non-descriptor-reg)) ndescr
)
169 (:results
(sap :scs
(sap-reg)))
170 (:result-types system-area-pointer
)
172 (loadw ndescr code
0 other-pointer-lowtag
)
173 (inst srl ndescr n-widetag-bits
)
174 (inst sll ndescr word-shift
)
175 (inst sub ndescr other-pointer-lowtag
)
176 (inst add sap code ndescr
)))
178 (define-vop (compute-fun)
179 (:args
(code :scs
(descriptor-reg))
180 (offset :scs
(signed-reg unsigned-reg
)))
181 (:arg-types
* positive-fixnum
)
182 (:results
(func :scs
(descriptor-reg)))
183 (:temporary
(:scs
(non-descriptor-reg)) ndescr
)
185 (loadw ndescr code
0 other-pointer-lowtag
)
186 (inst srl ndescr n-widetag-bits
)
187 (inst sll ndescr word-shift
)
188 (inst add ndescr offset
)
189 (inst add ndescr
(- fun-pointer-lowtag other-pointer-lowtag
))
190 (inst add func code ndescr
)))
194 ;;;; other random VOPs.
197 (defknown sb
!unix
::receive-pending-interrupt
() (values))
198 (define-vop (sb!unix
::receive-pending-interrupt
)
200 (:translate sb
!unix
::receive-pending-interrupt
)
202 (inst unimp pending-interrupt-trap
)))
205 (error "write a VOP for CURRENT-THREAD-OFFSET-SAP")
209 (inst unimp halt-trap
)))
213 ;;;; dynamic VOP count collection support
215 (define-vop (count-me)
216 (:args
(count-vector :scs
(descriptor-reg)))
218 (:temporary
(:scs
(non-descriptor-reg)) count
)
221 (- (* (+ index vector-data-offset
) n-word-bytes
)
222 other-pointer-lowtag
)))
223 (aver (typep offset
'(signed-byte 13)))
224 (inst ld count count-vector offset
)
226 (inst st count count-vector offset
))))
228 ;;;; Dummy definition for a spin-loop hint VOP
229 (define-vop (spin-loop-hint)
230 (:translate spin-loop-hint
)