06c77daebc08ddbc78f4ed527ad8be2baf1dd6a2
[sbcl.git] / src / code / early-fasl.lisp
1 ;;;; needed-early, or at least meaningful-early, stuff for FASL files
2
3 ;;;; This software is part of the SBCL system. See the README file for
4 ;;;; more information.
5 ;;;;
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.
11
12 (in-package "SB!FASL")
13 \f
14 ;;;; various constants and essentially-constants
15
16 ;;; a string which appears at the start of a fasl file header
17 ;;;
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
33 ;;;   against.
34 (defparameter *fasl-header-string-start-string* "# FASL")
35
36 ;;; the code for a character which terminates a fasl file header
37 (def!constant +fasl-header-string-stop-char-code+ 255)
38
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 forget to increment it for CVS
42 ;;; versions which break binary compatibility. But it certainly should
43 ;;; be incremented for release versions which break binary
44 ;;; compatibility.
45 (def!constant +fasl-file-version+ 40)
46 ;;; (record of versions before 0.7.0 deleted in 0.7.1.41)
47 ;;; 23 = sbcl-0.7.0.1 deleted no-longer-used EVAL-STACK stuff,
48 ;;;      causing changes in *STATIC-SYMBOLS*.
49 ;;; 24 = sbcl-0.7.1.19 changed PCL service routines which might be
50 ;;;      called from macroexpanded code
51 ;;; 25 = sbcl-0.7.1.41 (and immediately preceding versions, actually)
52 ;;;      introduced new functions to check for control stack exhaustion
53 ;;; 26 = sbcl-0.7.2.4 or so added :VARIABLE :MACRO-EXPANSION to INFO codes
54 ;;; 27: (2002-04-08) added MIGHT-CONTAIN-OTHER-TYPES? slot to CTYPE
55 ;;; 28: (2002-05-08) new convention for foreign symbols to support
56 ;;;     dynamic loading in OpenBSD
57 ;;; 29: (2002-06-24) removed *!INITIAL-FDEFN-OBJECTS* from static symbols
58 ;;; 30: (2002-07-26) deleted all references to %DETECT-STACK-EXHAUSTION, 
59 ;;;     which was introduced in version 25, since now control stack
60 ;;;     is checked using mmap() page protection
61 ;;; 31: (2002-08-14) changed encoding of PCL internal MAKE-INSTANCE
62 ;;;     function names so they're insensitive to whether the class name
63 ;;;     is currently external to its package
64 ;;; 32: (2002-09-21) changes in implementation of sequence functions,
65 ;;;     causing old utility functions like COERCE-TO-SIMPLE-VECTOR to go away
66 ;;; 33: (2002-10-02) (again) changes in implementation of sequence functions,
67 ;;;     causing old utility functions like COERCE-TO-SIMPLE-VECTOR to go away
68 ;;; 34: (2002-10-05) changed implementation of DEFMACRO, so %%DEFMACRO
69 ;;;      was deleted
70 ;;; 35: (2002-11-27) (incremented version before 0.7.10 release,
71 ;;;     reflecting changes from a week or more ago) changed layout of
72 ;;;     CLOS objects to support SXHASH returning values other than 42
73 ;;;     for STANDARD-OBJECT
74 ;;; 36: (2002-12-04) DEFSTRUCT-DESCRIPTION layout changed to accommodate
75 ;;;     correct behaviour of colliding accessors
76 ;;; 37: (2002-12-09) changed implementation of DEFINE-COMPILER-MACRO,
77 ;;;     deleting %%DEFINE-COMPILER-MACRO
78 ;;; 38: (2003-01-05) changed names of internal SORT machinery
79 ;;; 39: (2003-02-20) in 0.7.12.1 a slot was added to
80 ;;;     DEFSTRUCT-SLOT-DESCRIPTION
81 ;;; 40: (2003-03-11) changed value of (SXHASH NIL)
82
83 ;;; the conventional file extension for our fasl files
84 (declaim (type simple-string *fasl-file-type*))
85 (defvar *fasl-file-type* "fasl")
86 \f
87 ;;;; information about below-Lisp-level linkage
88
89 ;;; Note:
90 ;;;   Assembler routines are named by full Lisp symbols: they
91 ;;;     have packages and that sort of native Lisp stuff associated
92 ;;;     with them. We can compare them with EQ.
93 ;;;   Foreign symbols are named by Lisp STRINGs: the Lisp package
94 ;;;     system doesn't extend out to symbols in languages like C.
95 ;;;     We want to use EQUAL to compare them.
96 ;;;   *STATIC-FOREIGN-SYMBOLS* are static as opposed to "dynamic" (not
97 ;;;     as opposed to C's "extern"). The table contains symbols known at 
98 ;;;     the time that the program was built, but not symbols defined
99 ;;;     in object files which have been loaded dynamically since then.
100 (declaim (type hash-table *assembler-routines* *static-foreign-symbols*))
101 (defvar *assembler-routines* (make-hash-table :test 'eq))
102 (defvar *static-foreign-symbols* (make-hash-table :test 'equal))
103 \f
104 ;;;; the FOP database
105
106 (declaim (simple-vector *fop-names* *fop-funs*))
107
108 ;;; a vector indexed by a FaslOP that yields the FOP's name
109 (defvar *fop-names* (make-array 256 :initial-element nil))
110
111 ;;; a vector indexed by a FaslOP that yields a function of 0 arguments
112 ;;; which will perform the operation
113 (defvar *fop-funs*
114   (make-array 256
115               :initial-element (lambda ()
116                                  (error "corrupt fasl file: losing FOP"))))
117 \f
118 ;;;; other miscellaneous loading-related stuff
119
120 \f
121 ;;;; variables
122
123 (defvar *load-depth* 0
124   #!+sb-doc
125   "the current number of recursive LOADs")
126 (declaim (type index *load-depth*))
127
128 ;;; the FASL file we're reading from
129 (defvar *fasl-input-stream*)
130 (declaim (type ansi-stream *fasl-input-stream*))
131
132 (defvar *load-print* nil
133   #!+sb-doc
134   "the default for the :PRINT argument to LOAD")
135 (defvar *load-verbose* nil
136   ;; Note that CMU CL's default for this was T, and ANSI says it's
137   ;; implementation-dependent. We choose NIL on the theory that it's
138   ;; a nicer default behavior for Unix programs.
139   #!+sb-doc
140   "the default for the :VERBOSE argument to LOAD")
141
142 (defvar *load-code-verbose* nil)
143