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 ;;; FIXME: Shouldn't SB!C::&MORE be in this list?
34 (defconstant-eqx sb!xc:lambda-list-keywords
35 '(&optional &rest &key &aux &body &whole &allow-other-keys &environment)
38 "symbols which are magical in a lambda list")
40 ;;;; cross-compiler-only versions of CL special variables, so that we
41 ;;;; don't have weird interactions with the host compiler
43 (defvar sb!xc:*compile-file-pathname*)
44 (defvar sb!xc:*compile-file-truename*)
45 (defvar sb!xc:*compile-print*)
46 (defvar sb!xc:*compile-verbose*)
48 ;;;; miscellaneous types used both in the cross-compiler and on the target
50 ;;;; FIXME: The INDEX and LAYOUT-DEPTHOID definitions probably belong
51 ;;;; somewhere else, not "early-c", since they're after all not part
54 ;;; the type of LAYOUT-DEPTHOID slot values
55 (def!type sb!kernel::layout-depthoid () '(or index (integer -1 -1)))
57 ;;; possible values for the INLINE-ness of a function.
59 '(member :inline :maybe-inline :notinline nil))
60 (defparameter *inlinep-translations*
62 (notinline . :notinline)
63 (maybe-inline . :maybe-inline)))
65 ;;; the lexical environment we are currently converting in
67 (declaim (type lexenv *lexenv*))
69 ;;; *FREE-VARIABLES* translates from the names of variables referenced
70 ;;; globally to the LEAF structures for them. *FREE-FUNCTIONS* is like
71 ;;; *FREE-VARIABLES*, only it deals with function names.
72 (defvar *free-variables*)
73 (defvar *free-functions*)
74 (declaim (type hash-table *free-variables* *free-functions*))
76 ;;; We use the same CONSTANT structure to represent all equal anonymous
77 ;;; constants. This hashtable translates from constants to the LEAFs that
80 (declaim (type hash-table *constants*))
82 ;;; miscellaneous forward declarations
83 (defvar *code-segment*)
84 #!+sb-dyncount (defvar *collect-dynamic-statistics*)
85 (defvar *component-being-compiled*)
86 (defvar *compiler-error-context*)
87 (defvar *compiler-error-count*)
88 (defvar *compiler-warning-count*)
89 (defvar *compiler-style-warning-count*)
90 (defvar *compiler-note-count*)
91 (defvar *compiler-trace-output*)
92 (defvar *constraint-number*)
93 (defvar *converting-for-interpreter*)
94 (defvar *count-vop-usages*)
95 (defvar *current-path*)
96 (defvar *current-component*)
97 (defvar *delayed-ir1-transforms*)
99 (defvar *dynamic-counts-tn*)
101 (defvar *event-info*)
102 (defvar *event-note-threshold*)
106 (defvar *info-environment*)
108 (defvar *source-info*)
109 (defvar *trace-table*)
110 (defvar *undefined-warnings*)
111 (defvar *warnings-p*)
113 ;;;; miscellaneous utilities
115 ;;; Delete any undefined warnings for NAME and KIND. This is for the
116 ;;; benefit of the compiler, but it's sometimes called from stuff like
117 ;;; type-defining code which isn't logically part of the compiler.
118 (declaim (ftype (function ((or symbol cons) keyword) (values))
120 (defun note-name-defined (name kind)
121 ;; We do this BOUNDP check because this function can be called when
122 ;; not in a compilation unit (as when loading top-level forms).
123 (when (boundp '*undefined-warnings*)
124 (setq *undefined-warnings*
125 (delete-if (lambda (x)
126 (and (equal (undefined-warning-name x) name)
127 (eq (undefined-warning-kind x) kind)))
128 *undefined-warnings*)))
131 ;;; to be called when a variable is lexically bound
132 (declaim (ftype (function (symbol) (values)) note-lexical-binding))
133 (defun note-lexical-binding (symbol)
134 ;; This check is intended to protect us from getting silently
135 ;; burned when we define
138 ;; (DEFUN FOO (X) (+ X *FOO*))
143 ;; and then we happen to compile bar.lisp before foo.lisp.
144 (when (looks-like-name-of-special-var-p symbol)
145 ;; FIXME: should be COMPILER-STYLE-WARNING?
146 (style-warn "using the lexical binding of the symbol ~S, not the~@
147 dynamic binding, even though the symbol name follows the usual naming~@
148 convention (names like *FOO*) for special variables" symbol))