Fix make-array transforms.
[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
23     (if (= 64 sb!vm:n-word-bits)
24         ;; On 64-bit targets, this may be as low as 1 (for 63-bit
25         ;; fixnums) and as high as 3 (for 61-bit fixnums).  The
26         ;; constraint on the low end is that we need at least one bit
27         ;; to determine if a value is a fixnum or not, and the
28         ;; constraint on the high end is that it must not exceed
29         ;; WORD-SHIFT (defined below) due to the use of unboxed
30         ;; word-aligned byte pointers as boxed values in various
31         ;; places.  FIXME: This should possibly be exposed for
32         ;; configuration via customize-target-features.
33         1
34         ;; On 32-bit targets, this may be as low as 2 (for 30-bit
35         ;; fixnums) and as high as 2 (for 30-bit fixnums).  The
36         ;; constraint on the low end is simple overcrowding of the
37         ;; lowtag space, and the constraint on the high end is that it
38         ;; must not exceed WORD-SHIFT.
39         (1- n-lowtag-bits)))
40 ;;; the fixnum tag mask
41 (def!constant fixnum-tag-mask (1- (ash 1 n-fixnum-tag-bits)))
42 ;;; the bit width of fixnums
43 (def!constant n-fixnum-bits (- n-word-bits n-fixnum-tag-bits))
44 ;;; the bit width of positive fixnums
45 (def!constant n-positive-fixnum-bits (1- n-fixnum-bits))
46
47 ;;; the number of bits to shift between word addresses and byte addresses
48 (def!constant word-shift (1- (integer-length (/ n-word-bits n-byte-bits))))
49
50 ;;; the number of bytes in a word
51 (def!constant n-word-bytes (/ n-word-bits n-byte-bits))
52
53 ;;; the number of bits used in the header word of a data block to store
54 ;;; the type
55 (def!constant n-widetag-bits 8)
56 ;;; a mask to extract the type from a data block header word
57 (def!constant widetag-mask (1- (ash 1 n-widetag-bits)))
58
59 (def!constant sb!xc:most-positive-fixnum
60     (1- (ash 1 n-positive-fixnum-bits))
61   #!+sb-doc
62   "the fixnum closest in value to positive infinity")
63 (def!constant sb!xc:most-negative-fixnum
64     (ash -1 n-positive-fixnum-bits)
65   #!+sb-doc
66   "the fixnum closest in value to negative infinity")
67
68 (def!constant most-positive-word (1- (expt 2 n-word-bits))
69   "The most positive integer that is of type SB-EXT:WORD.")
70
71 (def!constant most-positive-exactly-single-float-fixnum
72   (min #xffffff sb!xc:most-positive-fixnum))
73 (def!constant most-negative-exactly-single-float-fixnum
74   (max #x-ffffff sb!xc:most-negative-fixnum))
75 (def!constant most-positive-exactly-double-float-fixnum
76   (min #x1fffffffffffff sb!xc:most-positive-fixnum))
77 (def!constant most-negative-exactly-double-float-fixnum
78   (max #x-1fffffffffffff sb!xc:most-negative-fixnum))
79
80 ;;;; Point where continuous area starting at dynamic-space-start bumps into
81 ;;;; next space.
82 #!+gencgc
83 (def!constant max-dynamic-space-end
84     (let ((stop (1- (ash 1 n-word-bits)))
85           (start dynamic-space-start))
86       (dolist (other-start (list read-only-space-start static-space-start linkage-table-space-start))
87         (when (< start other-start)
88           (setf stop (min stop other-start))))
89       stop))