Fix comment about *code-coverage-info*.
[sbcl.git] / src / compiler / generic / early-vm.lisp
blob1cf02614a592d97965741a3a9e57c54995af560c
1 ;;;; This software is part of the SBCL system. See the README file for
2 ;;;; more information.
3 ;;;;
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.
10 (in-package "SB!VM")
12 ;;; the number of bits at the low end of a pointer used for type
13 ;;; information
14 (def!constant n-lowtag-bits
15 (integer-length (1- (/ (* 2 n-word-bits) n-byte-bits))))
16 ;;; a mask to extract the low tag bits from a pointer
17 (def!constant lowtag-mask (1- (ash 1 n-lowtag-bits)))
18 ;;; the exclusive upper bound on the value of the low tag bits from a
19 ;;; pointer
20 (def!constant lowtag-limit (ash 1 n-lowtag-bits))
21 ;;; the number of tag bits used for a fixnum
22 (def!constant n-fixnum-tag-bits
23 ;; On 64-bit targets, this may be as low as 1 (for 63-bit
24 ;; fixnums) and as high as 3 (for 61-bit fixnums). The
25 ;; constraint on the low end is that we need at least one bit
26 ;; to determine if a value is a fixnum or not, and the
27 ;; constraint on the high end is that it must not exceed
28 ;; WORD-SHIFT (defined below) due to the use of unboxed
29 ;; word-aligned byte pointers as boxed values in various
30 ;; places. FIXME: This should possibly be exposed for
31 ;; configuration via customize-target-features.
32 #!+64-bit 1
33 ;; On 32-bit targets, this may be as low as 2 (for 30-bit
34 ;; fixnums) and as high as 2 (for 30-bit fixnums). The
35 ;; constraint on the low end is simple overcrowding of the
36 ;; lowtag space, and the constraint on the high end is that it
37 ;; must not exceed WORD-SHIFT.
38 #!-64-bit (1- n-lowtag-bits))
39 ;;; the fixnum tag mask
40 (def!constant fixnum-tag-mask (1- (ash 1 n-fixnum-tag-bits)))
41 ;;; the bit width of fixnums
42 (def!constant n-fixnum-bits (- n-word-bits n-fixnum-tag-bits))
43 ;;; the bit width of positive fixnums
44 (def!constant n-positive-fixnum-bits (1- n-fixnum-bits))
46 ;;; the number of bits to shift between word addresses and byte addresses
47 (def!constant word-shift (1- (integer-length (/ n-word-bits n-byte-bits))))
49 ;;; the number of bytes in a word
50 (def!constant n-word-bytes (/ n-word-bits n-byte-bits))
52 ;;; the number of bytes in a machine word
53 (def!constant n-machine-word-bytes (/ n-machine-word-bits n-byte-bits))
55 ;;; the number of bits used in the header word of a data block to store
56 ;;; the type
57 (def!constant n-widetag-bits 8)
58 ;;; a mask to extract the type from a data block header word
59 (def!constant widetag-mask (1- (ash 1 n-widetag-bits)))
61 (def!constant sb!xc:most-positive-fixnum
62 (1- (ash 1 n-positive-fixnum-bits))
63 #!+sb-doc
64 "the fixnum closest in value to positive infinity")
65 (def!constant sb!xc:most-negative-fixnum
66 (ash -1 n-positive-fixnum-bits)
67 #!+sb-doc
68 "the fixnum closest in value to negative infinity")
70 (def!constant most-positive-word (1- (expt 2 n-word-bits))
71 #!+sb-doc
72 "The most positive integer that is of type SB-EXT:WORD.")
74 (def!constant most-positive-exactly-single-float-fixnum
75 (min #xffffff sb!xc:most-positive-fixnum))
76 (def!constant most-negative-exactly-single-float-fixnum
77 (max #x-ffffff sb!xc:most-negative-fixnum))
78 (def!constant most-positive-exactly-double-float-fixnum
79 (min #x1fffffffffffff sb!xc:most-positive-fixnum))
80 (def!constant most-negative-exactly-double-float-fixnum
81 (max #x-1fffffffffffff sb!xc:most-negative-fixnum))
83 ;;;; Point where continuous area starting at dynamic-space-start bumps into
84 ;;;; next space.
85 #!+gencgc
86 (def!constant max-dynamic-space-end
87 (let ((stop (1- (ash 1 n-word-bits)))
88 (start dynamic-space-start))
89 (dolist (other-start (list read-only-space-start static-space-start
90 #!+linkage-table
91 linkage-table-space-start))
92 (declare (notinline <)) ; avoid dead code note
93 (when (< start other-start)
94 (setf stop (min stop other-start))))
95 stop))
97 ;; The lowest index that you can pass to %INSTANCE-REF accessing
98 ;; a slot of data that is not the instance-layout.
99 ;; To get a layout, you must call %INSTANCE-LAYOUT - don't assume index 0.
100 (def!constant instance-data-start 1)
102 ;;; Is X a fixnum in the target Lisp?
103 #+sb-xc-host
104 (defun fixnump (x)
105 (and (integerp x)
106 (<= sb!xc:most-negative-fixnum x sb!xc:most-positive-fixnum)))