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 (macrolet ((define-fasl-format-features ()
37 (let (;; master value for *F-P-A-F-F*
38 (fpaff '(:sb-thread :sb-package-locks :sb-unicode :gencgc)))
40 ;; a list of *(SHEBANG-)FEATURES* flags which affect
41 ;; binary compatibility, i.e. which must be the same
42 ;; between the SBCL which compiles the code and the
43 ;; SBCL which executes the code
45 ;; This is a property of SBCL executables in the
46 ;; abstract, not of this particular SBCL executable,
47 ;; so any flag in this list may or may not be present
48 ;; in the *FEATURES* list of this particular build.
49 (defparameter *features-potentially-affecting-fasl-format*
51 ;; a string representing flags of *F-P-A-F-F* which
52 ;; are in this particular build
54 ;; (A list is the natural logical representation for
55 ;; this, but we represent it as a string because
56 ;; that's physically convenient for writing to and
57 ;; reading from fasl files, and because we don't
58 ;; need to do anything sophisticated with its
59 ;; logical structure, just test it for equality.)
60 (defparameter *features-affecting-fasl-format*
61 ,(let ((*print-pretty* nil))
65 (intersection sb-cold:*shebang-features* fpaff))
67 :key #'symbol-name))))))))
68 (define-fasl-format-features))
70 ;;; the code for a character which terminates a fasl file header
71 (def!constant +fasl-header-string-stop-char-code+ 255)
73 ;;; This value should be incremented when the system changes in such a
74 ;;; way that it will no longer work reliably with old fasl files. In
75 ;;; practice, I (WHN) have often forgotten to increment it for CVS
76 ;;; versions which break binary compatibility. But it certainly should
77 ;;; be incremented for release versions which break binary
79 (def!constant +fasl-file-version+ 66)
80 ;;; (record of versions before 2003 deleted in 2003-04-26/0.pre8.107 or so)
81 ;;; 38: (2003-01-05) changed names of internal SORT machinery
82 ;;; 39: (2003-02-20) in 0.7.12.1 a slot was added to
83 ;;; DEFSTRUCT-SLOT-DESCRIPTION
84 ;;; 40: (2003-03-11) changed value of (SXHASH NIL)
85 ;;; 41: (2003-04-26) enforced binary incompatibility between +SB-THREAD
86 ;;; and -SB-THREAD builds
87 ;;; 42: (2003-05-22) %NAME slot changed to NAME in
88 ;;; DEFSTRUCT-SLOT-DESCRIPTION
89 ;;; 43: (2003-07-18) Something could easily have changed incompatibly in
90 ;;; recent maintenance, e.g. from (VECTOR NIL)-as-string support.
91 ;;; (And experimental results suggest that compatibility was broken
92 ;;; between about 0.8.1.29 and 0.8.1.39.)
93 ;;; 44: (2003-08-25) various changes leading up to 0.8.3
94 ;;; <dan`b> what happened this month to stalate the fasls?
95 ;;; <Krystof_> I think I renumbered everything again
96 ;;; <Krystof_> simple-array-unsigned-byte-7, probably
97 ;;; <Krystof_> (thanks to pfdietz)
98 ;;; 45: (2003-10-02) I (WHN) incremented the version for the 0.8.4
99 ;;; release because I couldn't immediately convince myself that
100 ;;; .fasl files could never possibly ever refer to the SB-C
101 ;;; CONTINUATION-related data types which were changed
102 ;;; incompatibly in 0.8.3.62.
103 ;;; 46: (2003-11-11) Tim Daly, Jr. (and Christophe Rhodes) reported
104 ;;; .fasl incompatibility on sbcl-devel 2003-11-09.
105 ;;; 47: (2003-11-30) Static variables were rearranged in 0.8.6.11.
106 ;;; 48: (2004-03-01) Renumbered all the widetags to allow for more
107 ;;; microefficiency in sbcl-0.8.8.10
108 ;;; 49: (2004-05-04) Changed implementation of DEFFOO macros and the
109 ;;; functions they expand to.
110 ;;; 50: (2004-05-20) Changed %COMPILER-DEFUN signature again.
111 ;;; 51: (2004-07-24) Package locks (SBCL 0.8.12.7) changed signature of
113 ;;; 52: (2004-11-02) Merge of SB-UNICODE.
114 ;;; 53: (2005-02-22) Something introduced in SBCL 0.8.19.26 (give or take
115 ;;; a couple of patches) invalidated some FFI-related fasls. Probably
116 ;;; caused by "lazy alien resolution improvements".
117 ;;; 54: (2005-03-22) At least "0.8.20.6: Make FILE-STREAM and STRING-STREAM
118 ;;; potential mixins in CLOS" and "0.8.20.21: Add immediate single-floats
120 ;;; 55: (2005-04-06) EXTERN-ALIEN-NAME logic moved from fixups to
121 ;;; FIND-FOREIGN-SYMBOL-IN-TABLE &co.
122 ;;; 56: (2005-05-22) Something between 0.9.0.1 and 0.9.0.14. My money is
123 ;;; on 0.9.0.6 (MORE CASE CONSISTENCY).
124 ;;; 57: (2005-06-12) Raw slot rearrangement in 0.9.1.38
125 ;;; 58: (2005-08-16) Multiple incompatible changes between 0.9.3 and 0.9.3.60
126 ;;; 59: (2005-09-18) METAOBJECT implementation, removal of INSTANCE and
127 ;;; FUNCALLABLE-INSTANCE classes.
128 ;;; 60: (2005-10-24) Bumped for 0.9.6
129 ;;; 61: (2005-11-06) Improved source location recording added extra parameters
130 ;;; to multiple %DEFMUMBLE functions.
131 ;;; 62: (2005-12-30) Make the count of FASL header counted strings
132 ;;; a 32-bit value also on 64-bit platforms.
133 ;;; 63: (2006-01-27) Shuffle storage classes around to reduce the error
134 ;;; trap information size on RISCy platforms.
135 ;;; 64: (2006-03-24) New calling convention for unknown-values on x86 and
136 ;;; x86-64. Also (belatedly) PPC/gencgc, including :gencgc on FPAFF.
137 ;;; 65: (2006-04-11) Package locking interface changed.
138 ;;; 66: (2006-05-13) Fopcompiler
140 ;;; the conventional file extension for our fasl files
141 (declaim (type simple-string *fasl-file-type*))
142 (defvar *fasl-file-type* "fasl")
144 ;;;; information about below-Lisp-level linkage
147 ;;; Assembler routines are named by full Lisp symbols: they
148 ;;; have packages and that sort of native Lisp stuff associated
149 ;;; with them. We can compare them with EQ.
150 (declaim (type hash-table *assembler-routines*))
151 (defvar *assembler-routines* (make-hash-table :test 'eq))
154 ;;;; the FOP database
156 (declaim (simple-vector *fop-names* *fop-funs*))
158 ;;; a vector indexed by a FaslOP that yields the FOP's name
159 (defvar *fop-names* (make-array 256 :initial-element nil))
161 ;;; a vector indexed by a FaslOP that yields a function of 0 arguments
162 ;;; which will perform the operation
165 :initial-element (lambda ()
166 (error "corrupt fasl file: losing FOP"))))
170 (defvar *load-depth* 0
172 "the current number of recursive LOADs")
173 (declaim (type index *load-depth*))
175 ;;; the FASL file we're reading from
176 (defvar *fasl-input-stream*)
177 (declaim (type ansi-stream *fasl-input-stream*))
179 (defvar *load-code-verbose* nil)