0.6.12.29:
[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 (defconstant +fasl-header-string-stop-char-code+ 255)
38
39 ;;; This value should be incremented when the system changes in such
40 ;;; a way that it will no longer work reliably with old fasl files.
41 (defconstant +fasl-file-version+ 14)
42 ;;; 2 = sbcl-0.6.4 uses COMPILE-OR-LOAD-DEFGENERIC.
43 ;;; 3 = sbcl-0.6.6 uses private symbol, not :EMPTY, for empty HASH-TABLE slot.
44 ;;; 4 = sbcl-0.6.7 uses HAIRY-DATA-VECTOR-REF and HAIRY-DATA-VECTOR-SET
45 ;;;     when array headers or data element type uncertainty exist, and
46 ;;;     uses DATA-VECTOR-REF and DATA-VECTOR-SET only for VOPs. (Thus,
47 ;;;     full calls to DATA-VECTOR-REF and DATA-VECTOR-SET from older
48 ;;;     fasl files would fail, because there are no DEFUNs for these
49 ;;;     operations any more.)
50 ;;; 5 = sbcl-0.6.8 has rearranged static symbols.
51 ;;; 6 = sbcl-0.6.9, got rid of non-ANSI %DEFCONSTANT/%%DEFCONSTANT stuff
52 ;;;     and deleted a slot from DEBUG-SOURCE structure.
53 ;;; 7 = around sbcl-0.6.9.8, merged SB-CONDITIONS package into SB-KERNEL
54 ;;; 8 = sbcl-0.6.10.4 revived Gray stream support, changing stream layouts.
55 ;;; 9 = deleted obsolete CONS-UNIQUE-TAG bytecode in sbcl-0.6.11.8
56 ;;; (somewhere in here also changes to AND and OR CTYPE layouts) 
57 ;;; 10 = new layout for CONDITION in sbcl-0.6.11.38
58 ;;; 11 = (a) new helper functions for MAKE-LOAD-FORM (HASH-TABLE) in
59 ;;;          sbcl-0.6.12.11
60 ;;;      (b) new address space constants for OpenBSD in 0.6.12.17
61 ;;;          (doesn't need separate version from (a) because the
62 ;;;          OpenBSD port was broken from sometime before 0.6.12.11
63 ;;;          until the address space was changed)
64 ;;; 12 = sbcl-0.6.12.22 added new SB-FASL package
65 ;;; 13 = sbcl-0.6.12.28 removed some elements from *STATIC-SYMBOLS* 
66 ;;; 14 = sbcl-0.6.12.29 removed more elements from *STATIC-SYMBOLS* 
67
68 ;;; the conventional file extension for fasl files on this
69 ;;; architecture, e.g. "x86f"
70 (declaim (type (or simple-string null) *backend-fasl-file-type*))
71 (defvar *backend-fasl-file-type* nil)
72
73 ;;; This is a sort of pun that we inherited from CMU CL. For ordinary,
74 ;;; non-byte-coded fasl files, the "implementation" is basically the
75 ;;; CPU. For byte-coded fasl files, the "implementation" is whether
76 ;;; the data are stored big-endianly or little-endianly.
77 (defun backend-byte-fasl-file-implementation ()
78   *backend-byte-order*)
79 \f
80 ;;; information about below-Lisp-level linkage
81 ;;;
82 ;;; Note:
83 ;;;   Assembler routines are named by full Lisp symbols: they
84 ;;;     have packages and that sort of native Lisp stuff associated
85 ;;;     with them. We can compare them with EQ.
86 ;;;   Foreign symbols are named by Lisp strings: the Lisp package
87 ;;;     system doesn't extend out to symbols in languages like C.
88 ;;;     We want to use EQUAL to compare them.
89 ;;;   *STATIC-FOREIGN-SYMBOLS* are static as opposed to "dynamic" (not
90 ;;;     as opposed to "extern"). The table contains symbols known at 
91 ;;;     the time that the program was built, but not symbols defined
92 ;;;     in object files which have been loaded dynamically since then.
93 (declaim (type hash-table *assembler-routines* *static-foreign-symbols*))
94 (defvar *assembler-routines* (make-hash-table :test 'eq))
95 (defvar *static-foreign-symbols* (make-hash-table :test 'equal))
96 \f
97 ;;;; the FOP database
98
99 (declaim (simple-vector *fop-names* *fop-functions*))
100
101 ;;; a vector indexed by a FaslOP that yields the FOP's name
102 (defvar *fop-names* (make-array 256 :initial-element nil))
103
104 ;;; a vector indexed by a FaslOP that yields a function of 0 arguments
105 ;;; which will perform the operation
106 (defvar *fop-functions*
107   (make-array 256
108               :initial-element (lambda ()
109                                  (error "corrupt fasl file: losing FOP"))))
110 \f
111 ;;;; other miscellaneous loading-related stuff
112
113 \f
114 ;;;; variables
115
116 (defvar *load-depth* 0
117   #!+sb-doc
118   "the current number of recursive LOADs")
119 (declaim (type index *load-depth*))
120
121 ;;; the FASL file we're reading from
122 (defvar *fasl-input-stream*)
123 (declaim (type lisp-stream *fasl-input-stream*))
124
125 (defvar *load-print* nil
126   #!+sb-doc
127   "the default for the :PRINT argument to LOAD")
128 (defvar *load-verbose* nil
129   ;; Note that CMU CL's default for this was T, and ANSI says it's
130   ;; implementation-dependent. We choose NIL on the theory that it's
131   ;; a nicer default behavior for Unix programs.
132   #!+sb-doc
133   "the default for the :VERBOSE argument to LOAD")
134
135 (defvar *load-code-verbose* nil)
136