1 ;;;; This file contains compiler code and compiler-related stuff which
2 ;;;; can be built early on. Some of the stuff may be here because it's
3 ;;;; needed early on, some other stuff (e.g. constants) just because
4 ;;;; it might as well be done early so we don't have to think about
5 ;;;; whether it's done early enough.
7 ;;;; This software is part of the SBCL system. See the README file for
10 ;;;; This software is derived from the CMU CL system, which was
11 ;;;; written at Carnegie Mellon University and released into the
12 ;;;; public domain. The software is in the public domain and is
13 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
14 ;;;; files for more information.
18 ;;; FIXME: Shouldn't SB!C::&MORE be in this list?
19 (defconstant-eqx sb!xc:lambda-list-keywords
20 '(&optional &rest &key &aux &body &whole &allow-other-keys &environment)
23 "symbols which are magical in a lambda list")
25 ;;;; cross-compiler-only versions of CL special variables, so that we
26 ;;;; don't have weird interactions with the host compiler
28 (defvar sb!xc:*compile-file-pathname*)
29 (defvar sb!xc:*compile-file-truename*)
30 (defvar sb!xc:*compile-print*)
31 (defvar sb!xc:*compile-verbose*)
33 ;;;; miscellaneous types used both in the cross-compiler and on the target
35 ;;;; FIXME: The INDEX and LAYOUT-DEPTHOID definitions probably belong
36 ;;;; somewhere else, not "early-c", since they're after all not part
39 ;;; the type of LAYOUT-DEPTHOID slot values
40 (def!type sb!kernel::layout-depthoid () '(or index (integer -1 -1)))
42 ;;; possible values for the INLINE-ness of a function.
44 '(member :inline :maybe-inline :notinline nil))
45 (defparameter *inlinep-translations*
47 (notinline . :notinline)
48 (maybe-inline . :maybe-inline)))
50 ;;; the lexical environment we are currently converting in
52 (declaim (type lexenv *lexenv*))
54 ;;; *FREE-VARIABLES* translates from the names of variables referenced
55 ;;; globally to the LEAF structures for them. *FREE-FUNCTIONS* is like
56 ;;; *FREE-VARIABLES*, only it deals with function names.
57 (defvar *free-variables*)
58 (defvar *free-functions*)
59 (declaim (type hash-table *free-variables* *free-functions*))
61 ;;; We use the same CONSTANT structure to represent all equal anonymous
62 ;;; constants. This hashtable translates from constants to the LEAFs that
65 (declaim (type hash-table *constants*))
67 ;;; miscellaneous forward declarations
68 (defvar *code-segment*)
69 #!+sb-dyncount (defvar *collect-dynamic-statistics*)
70 (defvar *component-being-compiled*)
71 (defvar *compiler-error-context*)
72 (defvar *compiler-error-count*)
73 (defvar *compiler-warning-count*)
74 (defvar *compiler-style-warning-count*)
75 (defvar *compiler-note-count*)
76 (defvar *compiler-trace-output*)
77 (defvar *constraint-number*)
78 (defvar *converting-for-interpreter*)
79 (defvar *count-vop-usages*)
80 (defvar *current-path*)
81 (defvar *current-component*)
82 (defvar *delayed-ir1-transforms*)
84 (defvar *dynamic-counts-tn*)
87 (defvar *event-note-threshold*)
91 (defvar *info-environment*)
93 (defvar *source-info*)
94 (defvar *trace-table*)
95 (defvar *undefined-warnings*)
98 ;;;; miscellaneous utilities
100 ;;; Delete any undefined warnings for NAME and KIND. This is for the
101 ;;; benefit of the compiler, but it's sometimes called from stuff like
102 ;;; type-defining code which isn't logically part of the compiler.
103 (declaim (ftype (function ((or symbol cons) keyword) (values))
105 (defun note-name-defined (name kind)
106 ;; We do this BOUNDP check because this function can be called when
107 ;; not in a compilation unit (as when loading top-level forms).
108 (when (boundp '*undefined-warnings*)
109 (setq *undefined-warnings*
110 (delete-if (lambda (x)
111 (and (equal (undefined-warning-name x) name)
112 (eq (undefined-warning-kind x) kind)))
113 *undefined-warnings*)))
116 ;;; to be called when a variable is lexically bound
117 (declaim (ftype (function (symbol) (values)) note-lexical-binding))
118 (defun note-lexical-binding (symbol)
119 ;; This check is intended to protect us from getting silently
120 ;; burned when we define
123 ;; (DEFUN FOO (X) (+ X *FOO*))
128 ;; and then we happen to compile bar.lisp before foo.lisp.
129 (when (looks-like-name-of-special-var-p symbol)
130 ;; FIXME: should be COMPILER-STYLE-WARNING?
131 (style-warn "using the lexical binding of the symbol ~S, not the~@
132 dynamic binding, even though the symbol name follows the usual naming~@
133 convention (names like *FOO*) for special variables" symbol))