0.6.11.10:
[sbcl.git] / src / compiler / fixup.lisp
1 ;;;; fixups, extracted from codegen.lisp by WHN 19990227 in order
2 ;;;; to help with cross-compiling bootstrapping
3
4 ;;;; This software is part of the SBCL system. See the README file for
5 ;;;; more information.
6 ;;;;
7 ;;;; This software is derived from the CMU CL system, which was
8 ;;;; written at Carnegie Mellon University and released into the
9 ;;;; public domain. The software is in the public domain and is
10 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
11 ;;;; files for more information.
12
13 (in-package "SB!C")
14
15 ;;; a fixup of some kind
16 (defstruct (fixup
17             (:constructor make-fixup (name flavor &optional offset))
18             (:copier nil))
19   ;; the name and flavor of the fixup. The assembler makes no
20   ;; assumptions about the contents of these fields; their semantics
21   ;; are imposed by the dumper.
22   name
23   flavor
24   ;; OFFSET is an optional offset from whatever external label this
25   ;; fixup refers to. Or in the case of the :CODE-OBJECT flavor of
26   ;; fixups on the :X86 architecture, NAME is always NIL, so this
27   ;; fixup doesn't refer to an external label, and OFFSET is an offset
28   ;; from the beginning of the current code block.
29   offset)
30
31 ;;; KLUDGE: Despite its name, this is not a list of FIXUP objects, but rather a
32 ;;; list of `(,KIND ,FIXUP ,POSN). Perhaps this non-mnemonicity could be
33 ;;; reduced by naming what's currently a FIXUP structure a FIXUP-REQUEST, and
34 ;;; then renaming *FIXUPS* to *NOTED-FIXUPS*.-- WHN 19990905
35 (defvar *fixups*)
36
37 ;;; Setting this variable lets you see what's going on as items are
38 ;;; being pushed onto *FIXUPS*.
39 #!+sb-show (defvar *show-fixups-being-pushed-p* nil)
40
41 ;;; This function is called by assembler instruction emitters when
42 ;;; they find themselves trying to deal with a fixup.
43 (defun note-fixup (segment kind fixup)
44   (sb!assem:emit-back-patch segment
45                             0
46                             (lambda (segment posn)
47                               (declare (ignore segment))
48                               ;; Why use EMIT-BACK-PATCH to cause this PUSH to
49                               ;; be done later, instead of just doing it now?
50                               ;; I'm not sure. Perhaps there's some concern
51                               ;; that POSN isn't known accurately now? Perhaps
52                               ;; there's a desire for all fixing up to go
53                               ;; through EMIT-BACK-PATCH whether it needs to or
54                               ;; not? -- WHN 19990905
55                               (push (list kind fixup posn) *fixups*)))
56   (values))