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 ;;; ANSI limits on compilation
19 (defconstant sb!xc:call-arguments-limit most-positive-fixnum
21 "The exclusive upper bound on the number of arguments which may be passed
22 to a function, including &REST args.")
23 (defconstant sb!xc:lambda-parameters-limit most-positive-fixnum
25 "The exclusive upper bound on the number of parameters which may be specifed
26 in a given lambda list. This is actually the limit on required and &OPTIONAL
27 parameters. With &KEY and &AUX you can get more.")
28 (defconstant sb!xc:multiple-values-limit most-positive-fixnum
30 "The exclusive upper bound on the number of multiple VALUES that you can
33 (defconstant-eqx sb!xc:lambda-list-keywords
45 "symbols which are magical in a lambda list")
47 ;;;; cross-compiler-only versions of CL special variables, so that we
48 ;;;; don't have weird interactions with the host compiler
50 (defvar sb!xc:*compile-file-pathname*)
51 (defvar sb!xc:*compile-file-truename*)
52 (defvar sb!xc:*compile-print*)
53 (defvar sb!xc:*compile-verbose*)
55 ;;;; miscellaneous types used both in the cross-compiler and on the target
57 ;;;; FIXME: The INDEX and LAYOUT-DEPTHOID definitions probably belong
58 ;;;; somewhere else, not "early-c", since they're after all not part
61 ;;; the type of LAYOUT-DEPTHOID slot values
62 (def!type sb!kernel::layout-depthoid () '(or index (integer -1 -1)))
64 ;;; possible values for the INLINE-ness of a function.
66 '(member :inline :maybe-inline :notinline nil))
67 (defparameter *inlinep-translations*
69 (notinline . :notinline)
70 (maybe-inline . :maybe-inline)))
72 ;;; the lexical environment we are currently converting in
74 (declaim (type lexenv *lexenv*))
76 ;;; *FREE-VARIABLES* translates from the names of variables referenced
77 ;;; globally to the LEAF structures for them. *FREE-FUNCTIONS* is like
78 ;;; *FREE-VARIABLES*, only it deals with function names.
79 (defvar *free-variables*)
80 (defvar *free-functions*)
81 (declaim (type hash-table *free-variables* *free-functions*))
83 ;;; We use the same CONSTANT structure to represent all equal anonymous
84 ;;; constants. This hashtable translates from constants to the LEAFs that
87 (declaim (type hash-table *constants*))
89 ;;; miscellaneous forward declarations
90 (defvar *code-segment*)
91 #!+sb-dyncount (defvar *collect-dynamic-statistics*)
92 (defvar *component-being-compiled*)
93 (defvar *compiler-error-context*)
94 (defvar *compiler-error-count*)
95 (defvar *compiler-warning-count*)
96 (defvar *compiler-style-warning-count*)
97 (defvar *compiler-note-count*)
98 (defvar *compiler-trace-output*)
99 (defvar *constraint-number*)
100 (defvar *count-vop-usages*)
101 (defvar *current-path*)
102 (defvar *current-component*)
103 (defvar *delayed-ir1-transforms*)
105 (defvar *dynamic-counts-tn*)
107 (defvar *event-info*)
108 (defvar *event-note-threshold*)
112 (defvar *info-environment*)
114 (defvar *source-info*)
115 (defvar *trace-table*)
116 (defvar *undefined-warnings*)
117 (defvar *warnings-p*)
119 ;;;; miscellaneous utilities
121 ;;; Delete any undefined warnings for NAME and KIND. This is for the
122 ;;; benefit of the compiler, but it's sometimes called from stuff like
123 ;;; type-defining code which isn't logically part of the compiler.
124 (declaim (ftype (function ((or symbol cons) keyword) (values))
126 (defun note-name-defined (name kind)
127 ;; We do this BOUNDP check because this function can be called when
128 ;; not in a compilation unit (as when loading top level forms).
129 (when (boundp '*undefined-warnings*)
130 (setq *undefined-warnings*
131 (delete-if (lambda (x)
132 (and (equal (undefined-warning-name x) name)
133 (eq (undefined-warning-kind x) kind)))
134 *undefined-warnings*)))
137 ;;; to be called when a variable is lexically bound
138 (declaim (ftype (function (symbol) (values)) note-lexical-binding))
139 (defun note-lexical-binding (symbol)
140 ;; This check is intended to protect us from getting silently
141 ;; burned when we define
144 ;; (DEFUN FOO (X) (+ X *FOO*))
149 ;; and then we happen to compile bar.lisp before foo.lisp.
150 (when (looks-like-name-of-special-var-p symbol)
151 ;; FIXME: should be COMPILER-STYLE-WARNING?
152 (style-warn "using the lexical binding of the symbol ~S, not the~@
153 dynamic binding, even though the symbol name follows the usual naming~@
154 convention (names like *FOO*) for special variables" symbol))