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
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.
15 (def!macro !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)
21 (let* ((ext (subseq line end))
22 (mult (cond ((or (zerop (length ext))
23 (member ext '("MB MIB") :test #'equalp))
25 ((member ext '("GB" "GIB") :test #'equalp)
28 (error "Invalid --dynamic-space-size=~A" line)))))
29 `(+ dynamic-space-start ,(* number mult)))
31 `(+ dynamic-space-start
34 (64 (expt 2 30))))))))))
37 ;; Define START/END constants for GENCGC spaces.
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.
64 ;; In the interest of readability, &KEY would be much nicer than
65 ;; &OPTIONAL. But is it possible to use keyword arguments to
68 (def!macro !gencgc-space-setup
70 &optional dynamic-space-start*
71 default-dynamic-space-size
72 ;; Smallest os_validate()able alignment; used as safepoint
73 ;; page size. Default suitable for POSIX platforms.
75 ;; traditional distance between spaces -- including the margin:
76 (small-space-spread #x100000)
77 ;; traditional margin between spaces
79 (let* ((spaces '(read-only static #!+linkage-table linkage-table))
80 (ptr small-spaces-start)
83 (loop for (space next-space) on spaces appending
84 (let* ((next-start (+ ptr small-space-spread))
86 (when (eq next-space 'static)
87 ;; margin becomes safepoint page; substract margin again.
89 (setf safepoint-address end))
91 `((def!constant ,(symbolicate space "-SPACE-START")
93 (def!constant ,(symbolicate space "-SPACE-END")
94 ,(- end margin-size)))
95 (setf ptr next-start)))))
98 `(def!constant gc-safepoint-page-addr ,safepoint-address)))
99 (dynamic-space-start* (or dynamic-space-start* ptr))
100 (optional-dynamic-space-end
101 (when default-dynamic-space-size
102 (list (+ dynamic-space-start* default-dynamic-space-size)))))
104 ,@safepoint-page-forms
106 (def!constant dynamic-space-start ,dynamic-space-start*)
107 (def!constant dynamic-space-end (!configure-dynamic-space-end
108 ,@optional-dynamic-space-end)))))
110 (defparameter *c-callable-static-symbols*
113 sb!kernel::internal-error
114 sb!kernel::control-stack-exhausted-error
115 sb!kernel::binding-stack-exhausted-error
116 sb!kernel::alien-stack-exhausted-error
117 sb!kernel::heap-exhausted-error
118 sb!kernel::undefined-alien-variable-error
119 sb!kernel::undefined-alien-function-error
120 sb!kernel::memory-fault-error
121 sb!kernel::unhandled-trap-error
122 sb!di::handle-breakpoint
123 sb!di::handle-single-step-trap
125 #!+win32 sb!kernel::handle-win32-exception
126 #!+sb-thruption sb!thread::run-interruption))
128 (defparameter *common-static-symbols*
131 ;; filled in by the C code to propagate to Lisp
132 *posix-argv* *core-string*
134 ;; free pointers. Note that these are FIXNUM word counts, not (as
135 ;; one might expect) byte counts or SAPs. The reason seems to be
136 ;; that by representing them this way, we can avoid consing
137 ;; bignums. -- WHN 2000-10-02
138 *read-only-space-free-pointer*
139 *static-space-free-pointer*
141 ;; things needed for non-local-exit
142 *current-catch-block*
143 *current-unwind-protect-block*
148 *binding-stack-start*
149 *control-stack-start*
152 ;; interrupt handling
154 *free-interrupt-context-index*
155 sb!unix::*allow-with-interrupts*
156 sb!unix::*interrupts-enabled*
157 sb!unix::*interrupt-pending*
158 #!+sb-thruption sb!unix::*thruption-pending*
159 #!+sb-thruption sb!impl::*restart-clusters*
165 #!+sb-safepoint sb!impl::*gc-safe*
166 #!+sb-safepoint sb!impl::*in-safepoint*
169 #!+sb-thread *stop-for-gc-pending*
170 #!+sb-thread *free-tls-index*
171 #!+sb-thread *tls-index-lock*
173 ;; dynamic runtime linking support
174 #!+sb-dynamic-core *required-runtime-c-symbols*
175 sb!kernel::*gc-epoch*
177 ;; Dispatch tables for generic array access
178 sb!impl::%%data-vector-reffers%%
179 sb!impl::%%data-vector-reffers/check-bounds%%
180 sb!impl::%%data-vector-setters%%
181 sb!impl::%%data-vector-setters/check-bounds%%
183 ;; non-x86oid gencgc object pinning
184 #!+(and gencgc (not (or x86 x86-64)))
187 ;; hash table weaknesses
193 ;;; Number of entries in the thread local storage. Limits the number
194 ;;; of symbols with thread local bindings.
195 (def!constant tls-size 4096)
199 (def!constant +highest-normal-generation+ 5)
200 (def!constant +pseudo-static-generation+ 6))
204 trace-table-call-site
205 trace-table-fun-prologue
206 trace-table-fun-epilogue)