Initial revision
[sbcl.git] / src / code / early-load.lisp
1 ;;;; needed-early stuff for the loader
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!IMPL")
13
14 (file-comment
15   "$Header$")
16
17 ;;; information about non-Lisp-level linkage
18 ;;;
19 ;;; Note:
20 ;;;   Assembler routines are named by full Lisp symbols: they
21 ;;;     have packages and that sort of native Lisp stuff associated
22 ;;;     with them. We can compare them with EQ.
23 ;;;   Foreign symbols are named by Lisp strings: the Lisp package
24 ;;;     system doesn't extend out to symbols in languages like C.
25 ;;;     We want to use EQUAL to compare them.
26 ;;;   *STATIC-FOREIGN-SYMBOLS* are static as opposed to "dynamic" (not
27 ;;;     as opposed to "extern"). The table contains symbols known at 
28 ;;;     the time that the program was built, but not symbols defined
29 ;;;     in object files which have been loaded dynamically since then.
30 (declaim (type hash-table *assembler-routines* *static-foreign-symbols*))
31 (defvar *assembler-routines* (make-hash-table :test 'eq))
32 (defvar *static-foreign-symbols* (make-hash-table :test 'equal))
33
34 ;;; the FOP database
35 (defvar *fop-names* (make-array 256 :initial-element nil)
36   #!+sb-doc
37   "a vector indexed by a FaslOP that yields the FOP's name")
38 (defvar *fop-functions*
39   (make-array 256
40               :initial-element (lambda ()
41                                  (error "corrupt fasl file: losing FOP")))
42   #!+sb-doc
43   "a vector indexed by a FaslOP that yields a function of 0 arguments which
44   will perform the operation")
45 (declaim (simple-vector *fop-names* *fop-functions*))
46
47 (defvar *load-code-verbose* nil)
48
49 ;;; Moving native code during a GC or purify is not trivial on the x86
50 ;;; port, so there are a few options for code placement.
51 ;;;
52 ;;; Byte-compiled code objects can always be moved so can be place in
53 ;;; the dynamics heap. This is enabled with
54 ;;; *load-byte-compiled-code-to-dynamic-space*.
55 ;;;   FIXME: See whether this really works. Also, now that we have gencgc
56 ;;;       and all code moves, perhaps we could just remove this conditional
57 ;;;       and make this fixed behavior.
58 ;;;
59 ;;; Native code top level forms only have a short life so can be
60 ;;; safely loaded into the dynamic heap (without fixups) so long as
61 ;;; the GC is not active. This could be handy during a world load to
62 ;;; save core space without the need to enable the support for moving
63 ;;; x86 native code. Enable with *load-x86-tlf-to-dynamic-space*.
64 ;;;   FIXME: Yikes! Could we punt this?
65 ;;;
66 ;;; One strategy for allowing the loading of x86 native code into the
67 ;;; dynamic heap requires that the addresses of fixups be saved for
68 ;;; all these code objects. After a purify these fixups can be
69 ;;; dropped. This is enabled with *enable-dynamic-space-code*.
70 ;;;
71 ;;; A little analysis of the header information is used to determine
72 ;;; if a code object is byte compiled, or native code.
73 (defvar *load-byte-compiled-code-to-dynamic-space* t)
74 (defvar *load-x86-tlf-to-dynamic-space* nil)  ; potentially dangerous with CGC.
75                                               ; KLUDGE: Yikes squared!
76 (defvar *enable-dynamic-space-code* #!-gencgc nil #!+gencgc t)
77 ;;; FIXME: I think all of these should go away. I can't see a good reason
78 ;;; not to just make everything relocatable.