Fixnum and unsigned-fixnum array cleanups.
[sbcl.git] / src / compiler / generic / early-vm.lisp
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.
9
10 (in-package "SB!VM")
11
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 (1- n-lowtag-bits))
23 ;;; the fixnum tag mask
24 (def!constant fixnum-tag-mask (1- (ash 1 n-fixnum-tag-bits)))
25 ;;; the bit width of fixnums
26 (def!constant n-fixnum-bits (- n-word-bits n-fixnum-tag-bits))
27 ;;; the bit width of positive fixnums
28 (def!constant n-positive-fixnum-bits (1- n-fixnum-bits))
29
30 ;;; the number of bits to shift between word addresses and byte addresses
31 (def!constant word-shift (1- (integer-length (/ n-word-bits n-byte-bits))))
32
33 ;;; the number of bytes in a word
34 (def!constant n-word-bytes (/ n-word-bits n-byte-bits))
35
36 ;;; the number of bits used in the header word of a data block to store
37 ;;; the type
38 (def!constant n-widetag-bits 8)
39 ;;; a mask to extract the type from a data block header word
40 (def!constant widetag-mask (1- (ash 1 n-widetag-bits)))
41
42 (def!constant sb!xc:most-positive-fixnum
43     (1- (ash 1 n-positive-fixnum-bits))
44   #!+sb-doc
45   "the fixnum closest in value to positive infinity")
46 (def!constant sb!xc:most-negative-fixnum
47     (ash -1 n-positive-fixnum-bits)
48   #!+sb-doc
49   "the fixnum closest in value to negative infinity")
50
51 (def!constant most-positive-word (1- (expt 2 n-word-bits))
52   "The most positive integer that is of type SB-EXT:WORD.")
53
54 (def!constant most-positive-exactly-single-float-fixnum
55   (min #xffffff sb!xc:most-positive-fixnum))
56 (def!constant most-negative-exactly-single-float-fixnum
57   (max #x-ffffff sb!xc:most-negative-fixnum))
58 (def!constant most-positive-exactly-double-float-fixnum
59   (min #x1fffffffffffff sb!xc:most-positive-fixnum))
60 (def!constant most-negative-exactly-double-float-fixnum
61   (max #x-1fffffffffffff sb!xc:most-negative-fixnum))
62
63 ;;;; Point where continuous area starting at dynamic-space-start bumps into
64 ;;;; next space.
65 #!+gencgc
66 (def!constant max-dynamic-space-end
67     (let ((stop (1- (ash 1 n-word-bits)))
68           (start dynamic-space-start))
69       (dolist (other-start (list read-only-space-start static-space-start linkage-table-space-start))
70         (when (< start other-start)
71           (setf stop (min stop other-start))))
72       stop))