1 ;;;; This software is part of the SBCL system. See the README file for
4 ;;;; This software is derived from the CMU CL system, which was
5 ;;;; written at Carnegie Mellon University and released into the
6 ;;;; public domain. The software is in the public domain and is
7 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
8 ;;;; files for more information.
14 ;;;; We represent the place where some value is stored with a SC-OFFSET,
15 ;;;; which is the SC number and offset encoded as an integer.
17 ;;;; The concrete encoding is exported to sc-offset.h during genesis
18 ;;;; for use by the runtime.
20 (def!type sc-offset
() '(unsigned-byte 27))
22 (defconstant-eqx +sc-offset-scn-bytes
+
23 `(,(byte 2 0) ,(byte 4 23))
26 (defconstant-eqx +sc-offset-offset-bytes
+
30 (declaim (ftype (sfunction ((unsigned-byte 6) (unsigned-byte 21)) sc-offset
)
32 (defun make-sc-offset (sc-number offset
)
34 (flet ((add-bits (bytes source
)
35 (loop for byte in bytes
36 for size
= (byte-size byte
)
39 (setf result
(dpb (ldb (byte size i
) source
) byte result
))
41 (add-bits +sc-offset-scn-bytes
+ sc-number
)
42 (add-bits +sc-offset-offset-bytes
+ offset
))
45 (declaim (ftype (sfunction (sc-offset) unsigned-byte
)
46 sc-offset-scn sc-offset-offset
))
47 (flet ((extract-bits (bytes source
)
50 for size
= (byte-size byte
)
53 (setf result
(dpb (ldb byte source
) (byte size i
) result
))
55 finally
(return result
))))
57 (defun sc-offset-scn (sc-offset)
58 (extract-bits +sc-offset-scn-bytes
+ sc-offset
))
60 (defun sc-offset-offset (sc-offset)
61 (extract-bits +sc-offset-offset-bytes
+ sc-offset
)))