Fix "Cosmetic problem" per remark in compiler/generic/parms
[sbcl.git] / src / compiler / generic / parms.lisp
blobbe2cabd44c8b49c24a6be8f272c26f1308c91879
1 ;;;; This file contains some parameterizations of various VM
2 ;;;; attributes common to all architectures.
4 ;;;; This software is part of the SBCL system. See the README file for
5 ;;;; more information.
6 ;;;;
7 ;;;; This software is derived from the CMU CL system, which was
8 ;;;; written at Carnegie Mellon University and released into the
9 ;;;; public domain. The software is in the public domain and is
10 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
11 ;;;; files for more information.
13 (in-package "SB!VM")
15 (defmacro !configure-dynamic-space-end (&optional default)
16 (with-open-file (f "output/dynamic-space-size.txt")
17 (let ((line (read-line f)))
18 (multiple-value-bind (number end)
19 (parse-integer line :junk-allowed t)
20 (if number
21 (let* ((ext (subseq line end))
22 (mult (cond ((or (zerop (length ext))
23 (member ext '("MB MIB") :test #'equalp))
24 (expt 2 20))
25 ((member ext '("GB" "GIB") :test #'equalp)
26 (expt 2 30))
28 (error "Invalid --dynamic-space-size=~A" line)))))
29 `(+ dynamic-space-start ,(* number mult)))
30 (or default
31 `(+ dynamic-space-start
32 (ecase n-word-bits
33 (32 (expt 2 29))
34 (64 (expt 2 30))))))))))
36 #!+gencgc
37 ;; Define START/END constants for GENCGC spaces.
38 ;; Assumptions:
39 ;; We only need very small read-only and static spaces, because
40 ;; gencgc does not purify any more. We can count on being able to
41 ;; allocate them with roughly the same size, and next to each other.
43 ;; There is one page of unmapped buffer between them for good measure.
45 ;; The linkage table (if enabled) can be treated the same way.
47 ;; Dynamic space traditionally sits elsewhere, so has its own
48 ;; parameter. But if not specified, it is allocated right after
49 ;; the other spaces (used on Windows/x86).
51 ;; The safepoint page (if enabled) is to be allocated immediately
52 ;; prior to static page. For x86(-64) this would not matter, because
53 ;; they can only reference it using an absolute fixup anyway, but
54 ;; for RISC platforms we can (and must) do better.
56 ;; The safepoint page needs to be small enough that the offset from
57 ;; static space is immediate, e.g. >= -2^12 for SPARC. #x1000 works
58 ;; for almost all platforms, but is too small to make VirtualProtect
59 ;; happy -- hence the need for an extra `alignment' configuration
60 ;; option below, which parms.lisp can set to #x10000 on Windows.
62 (defmacro !gencgc-space-setup
63 (small-spaces-start
64 &key ((:dynamic-space-start dynamic-space-start*))
65 default-dynamic-space-size
66 ;; Smallest os_validate()able alignment; used as safepoint
67 ;; page size. Default suitable for POSIX platforms.
68 (alignment #x1000)
69 ;; traditional distance between spaces -- including the margin:
70 (small-space-spread #x100000)
71 ;; traditional margin between spaces
72 (margin-size #x1000))
73 (let* ((spaces '(read-only static #!+linkage-table linkage-table))
74 (ptr small-spaces-start)
75 safepoint-address
76 (small-space-forms
77 (loop for (space next-space) on spaces appending
78 (let* ((next-start (+ ptr small-space-spread))
79 (end next-start))
80 (when (eq next-space 'static)
81 ;; margin becomes safepoint page; substract margin again.
82 (decf end alignment)
83 (setf safepoint-address end))
84 (prog1
85 `((def!constant ,(symbolicate space "-SPACE-START")
86 ,ptr)
87 (def!constant ,(symbolicate space "-SPACE-END")
88 ,(- end margin-size)))
89 (setf ptr next-start)))))
90 (safepoint-page-forms
91 (list #!+sb-safepoint
92 `(def!constant gc-safepoint-page-addr ,safepoint-address)))
93 (dynamic-space-start* (or dynamic-space-start* ptr))
94 (optional-dynamic-space-end
95 (when default-dynamic-space-size
96 (list (+ dynamic-space-start* default-dynamic-space-size)))))
97 `(progn
98 ,@safepoint-page-forms
99 ,@small-space-forms
100 (def!constant dynamic-space-start ,dynamic-space-start*)
101 (def!constant dynamic-space-end (!configure-dynamic-space-end
102 ,@optional-dynamic-space-end)))))
104 (defparameter *c-callable-static-symbols*
105 '(sub-gc
106 sb!kernel::post-gc
107 internal-error
108 sb!kernel::control-stack-exhausted-error
109 sb!kernel::binding-stack-exhausted-error
110 sb!kernel::alien-stack-exhausted-error
111 sb!kernel::heap-exhausted-error
112 sb!kernel::undefined-alien-variable-error
113 sb!kernel::memory-fault-error
114 sb!kernel::unhandled-trap-error
115 ;; On these it's called through the internal errors mechanism
116 #!-(or arm arm64 x86-64) undefined-alien-fun-error
117 sb!di::handle-breakpoint
118 sb!di::handle-single-step-trap
119 #!+win32 sb!kernel::handle-win32-exception
120 #!+sb-thruption sb!thread::run-interruption
121 #!+sb-thread sb!thread::enter-foreign-callback
122 #!+(and sb-safepoint-strictly (not win32))
123 sb!unix::signal-handler-callback))
125 (defparameter *common-static-symbols*
128 ;; filled in by the C code to propagate to Lisp
129 *posix-argv* *core-string*
131 ;; free pointers. Note that these are FIXNUM word counts, not (as
132 ;; one might expect) byte counts or SAPs. The reason seems to be
133 ;; that by representing them this way, we can avoid consing
134 ;; bignums. -- WHN 2000-10-02
135 *read-only-space-free-pointer*
136 *static-space-free-pointer*
138 ;; things needed for non-local-exit
139 *current-catch-block*
140 *current-unwind-protect-block*
142 #!+hpux *c-lra*
144 ;; stack pointers
145 *binding-stack-start*
146 *control-stack-start*
147 *control-stack-end*
149 ;; interrupt handling
150 *alloc-signal*
151 *free-interrupt-context-index*
152 sb!unix::*allow-with-interrupts*
153 sb!unix::*interrupts-enabled*
154 sb!unix::*interrupt-pending*
155 #!+sb-thruption sb!unix::*thruption-pending*
156 #!+sb-thruption sb!impl::*restart-clusters*
157 sb!vm::*in-without-gcing*
158 *gc-inhibit*
159 *gc-pending*
160 #!-sb-thread
161 *stepping*
162 #!+sb-safepoint sb!impl::*gc-safe*
163 #!+sb-safepoint sb!impl::*in-safepoint*
165 ;; threading support
166 #!+sb-thread *stop-for-gc-pending*
167 #!+sb-thread *free-tls-index*
168 #!+sb-thread *tls-index-lock*
170 ;; dynamic runtime linking support
171 #!+sb-dynamic-core *required-runtime-c-symbols*
172 sb!kernel::*gc-epoch*
174 ;; Dispatch tables for generic array access
175 sb!impl::%%data-vector-reffers%%
176 sb!impl::%%data-vector-reffers/check-bounds%%
177 sb!impl::%%data-vector-setters%%
178 sb!impl::%%data-vector-setters/check-bounds%%
180 ;; non-x86oid gencgc object pinning
181 #!+(and gencgc (not (or x86 x86-64)))
182 *pinned-objects*
184 ;; hash table weaknesses
185 :key
186 :value
187 :key-and-value
188 :key-or-value))
190 ;;; Number of entries in the thread local storage. Limits the number
191 ;;; of symbols with thread local bindings.
192 (def!constant tls-size 4096)
193 ;;; Refer to the lengthy comment in 'src/runtime/interrupt.h' about
194 ;;; the choice of this number. Rather than have to two copies
195 ;;; of the comment, please see that file before adjusting this.
196 (def!constant max-interrupts 1024)
198 #!+gencgc
199 (progn
200 (def!constant +highest-normal-generation+ 5)
201 (def!constant +pseudo-static-generation+ 6))