1 ;;;; needed-early, or at least meaningful-early, stuff for FASL files
3 ;;;; This software is part of the SBCL system. See the README file for
6 ;;;; This software is derived from the CMU CL system, which was
7 ;;;; written at Carnegie Mellon University and released into the
8 ;;;; public domain. The software is in the public domain and is
9 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
10 ;;;; files for more information.
12 (in-package "SB!FASL")
14 ;;;; various constants and essentially-constants
16 ;;; a string which appears at the start of a fasl file header
18 ;;; This value is used to identify fasl files. Even though this is not
19 ;;; declared as a constant (because ANSI Common Lisp has no facility
20 ;;; for declaring values which are constant under EQUAL but not EQL),
21 ;;; obviously you shouldn't mess with it lightly. If you do set a new
22 ;;; value for some reason, keep these things in mind:
23 ;;; * To avoid confusion with the similar but incompatible CMU CL
24 ;;; fasl file format, the value should not be "FASL FILE", which
25 ;;; is what CMU CL used for the same purpose.
26 ;;; * Since its presence at the head of a file is used by LOAD to
27 ;;; decide whether a file is to be fasloaded or just loaded
28 ;;; ordinarily (as source), the value should be something which
29 ;;; can't legally appear at the head of a Lisp source file.
30 ;;; * The value should not contain any line-terminating characters,
31 ;;; because they're hard to express portably and because the LOAD
32 ;;; code might reasonably use READ-LINE to get the value to compare
34 (defparameter *fasl-header-string-start-string* "# FASL")
36 ;;; the code for a character which terminates a fasl file header
37 (defconstant +fasl-header-string-stop-char-code+ 255)
39 ;;; This value should be incremented when the system changes in such a
40 ;;; way that it will no longer work reliably with old fasl files. In
41 ;;; practice, I (WHN) fairly often neglect to increment it for CVS
42 ;;; versions which break binary compatibility. But it certainly should
43 ;;; be incremented for release versions which break binary
45 (defconstant +fasl-file-version+ 24)
46 ;;; 2 = sbcl-0.6.4 uses COMPILE-OR-LOAD-DEFGENERIC.
47 ;;; 3 = sbcl-0.6.6 uses private symbol, not :EMPTY, for empty HASH-TABLE slot.
48 ;;; 4 = sbcl-0.6.7 uses HAIRY-DATA-VECTOR-REF and HAIRY-DATA-VECTOR-SET
49 ;;; when array headers or data element type uncertainty exist, and
50 ;;; uses DATA-VECTOR-REF and DATA-VECTOR-SET only for VOPs. (Thus,
51 ;;; full calls to DATA-VECTOR-REF and DATA-VECTOR-SET from older
52 ;;; fasl files would fail, because there are no DEFUNs for these
53 ;;; operations any more.)
54 ;;; 5 = sbcl-0.6.8 has rearranged static symbols.
55 ;;; 6 = sbcl-0.6.9, got rid of non-ANSI %DEFCONSTANT/%%DEFCONSTANT stuff
56 ;;; and deleted a slot from DEBUG-SOURCE structure.
57 ;;; 7 = around sbcl-0.6.9.8, merged SB-CONDITIONS package into SB-KERNEL
58 ;;; 8 = sbcl-0.6.10.4 revived Gray stream support, changing stream layouts.
59 ;;; 9 = deleted obsolete CONS-UNIQUE-TAG bytecode in sbcl-0.6.11.8
60 ;;; (somewhere in here also changes to AND and OR CTYPE layouts)
61 ;;; 10 = new layout for CONDITION in sbcl-0.6.11.38
62 ;;; 11 = (a) new helper functions for MAKE-LOAD-FORM (HASH-TABLE) in
64 ;;; (b) new address space constants for OpenBSD in 0.6.12.17
65 ;;; (doesn't need separate version from (a) because the
66 ;;; OpenBSD port was broken from sometime before 0.6.12.11
67 ;;; until the address space was changed)
68 ;;; 12 = sbcl-0.6.12.22 added new SB-FASL package
69 ;;; 13 = sbcl-0.6.12.28 removed some elements from *STATIC-SYMBOLS*
70 ;;; 14 = sbcl-0.6.12.29 removed more elements from *STATIC-SYMBOLS*
71 ;;; 15 = sbcl-0.6.12.33 changed the layout of STREAM
72 ;;; 16 = sbcl-0.pre7.15 changed the layout of PRETTY-STREAM
73 ;;; 17 = sbcl-0.pre7.38 (merging many changes accumulated in
74 ;;; the sbcl-0.pre7.37.flaky5.* branch back into the main branch)
75 ;;; got rid of byte compiler, byte interpreter, and IR1
76 ;;; interpreter, changed %DEFUN and DEFSTRUCT, changed the
77 ;;; meaning of FOP-FSET, and changed the layouts of various
78 ;;; internal compiler structures (e.g. DEFSTRUCT CLAMBDA)
79 ;;; 18 = sbcl-0.pre7.39 swapped FUNCTION-POINTER-TYPE and
80 ;;; INSTANCE-POINTER-LOWTAG low-level type codes to help with
82 ;;; (In 0.pre7.48, the low-level object layout of SYMBOL on the
83 ;;; non-X86 ports changed. I forgot to bump the fasl version number:
84 ;;; I only have an X86.. -- WHN)
85 ;;; 19 = sbcl-0.pre7.50 deleted byte-compiler-related low-level type codes
86 ;;; 20 = sbcl-0.pre7.51 modified names and layouts of
87 ;;; physical-environment-related structures in the compiler
88 ;;; 21 = sbcl-0.pre7.62 finally incremented the version after several
89 ;;; incompatible changes in earlier versions: many many symbols
90 ;;; renamed, changes in globaldb representation of constants
91 ;;; and inline functions, and change in the value of
92 ;;; INTERNAL-TIME-UNITS-PER-SECOND
93 ;;; 22 = about a zillion changes between sbcl-0.pre7.62 and
94 ;;; sbcl-0.pre7.133, during which time it seemed too much
95 ;;; trouble to increment the counter
96 ;;; 23 = sbcl-0.7.0.1 deleted no-longer-used EVAL-STACK stuff,
97 ;;; causing changes in *STATIC-SYMBOLS*.
98 ;;; 24 = sbcl-0.7.1.19 changed PCL service routines which might be
99 ;;; called from macroexpanded code
101 ;;; the conventional file extension for our fasl files
102 (declaim (type simple-string *fasl-file-type*))
103 (defvar *fasl-file-type* "fasl")
105 ;;; information about below-Lisp-level linkage
108 ;;; Assembler routines are named by full Lisp symbols: they
109 ;;; have packages and that sort of native Lisp stuff associated
110 ;;; with them. We can compare them with EQ.
111 ;;; Foreign symbols are named by Lisp STRINGs: the Lisp package
112 ;;; system doesn't extend out to symbols in languages like C.
113 ;;; We want to use EQUAL to compare them.
114 ;;; *STATIC-FOREIGN-SYMBOLS* are static as opposed to "dynamic" (not
115 ;;; as opposed to C's "extern"). The table contains symbols known at
116 ;;; the time that the program was built, but not symbols defined
117 ;;; in object files which have been loaded dynamically since then.
118 (declaim (type hash-table *assembler-routines* *static-foreign-symbols*))
119 (defvar *assembler-routines* (make-hash-table :test 'eq))
120 (defvar *static-foreign-symbols* (make-hash-table :test 'equal))
122 ;;;; the FOP database
124 (declaim (simple-vector *fop-names* *fop-funs*))
126 ;;; a vector indexed by a FaslOP that yields the FOP's name
127 (defvar *fop-names* (make-array 256 :initial-element nil))
129 ;;; a vector indexed by a FaslOP that yields a function of 0 arguments
130 ;;; which will perform the operation
133 :initial-element (lambda ()
134 (error "corrupt fasl file: losing FOP"))))
136 ;;;; other miscellaneous loading-related stuff
141 (defvar *load-depth* 0
143 "the current number of recursive LOADs")
144 (declaim (type index *load-depth*))
146 ;;; the FASL file we're reading from
147 (defvar *fasl-input-stream*)
148 (declaim (type ansi-stream *fasl-input-stream*))
150 (defvar *load-print* nil
152 "the default for the :PRINT argument to LOAD")
153 (defvar *load-verbose* nil
154 ;; Note that CMU CL's default for this was T, and ANSI says it's
155 ;; implementation-dependent. We choose NIL on the theory that it's
156 ;; a nicer default behavior for Unix programs.
158 "the default for the :VERBOSE argument to LOAD")
160 (defvar *load-code-verbose* nil)