Compiler policy is controlled by the optimize
declaration,
supporting all ANSI optimization qualities (debug
,
safety
, space
, and speed
).1
For effects of various optimization qualities on type-safety and debuggability see Declarations as Assertions and Debugger Policy Control.
Ordinarily, when the speed
quality is high, the compiler emits
notes to notify the programmer about its inability to apply various
optimizations. For selective muffling of these notes See Controlling Verbosity.
The value of space
mostly influences the compiler's decision
whether to inline operations, which tend to increase the size of
programs. Use the value 0
with caution, since it can cause the
compiler to inline operations so indiscriminately that the net effect
is to slow the program by causing cache misses or even swapping.
Assing a minimum value to an optimization quality.
quality
is the name of the optimization quality to restrict, andmin
(defaulting to zero) is the minimum allowed value.Returns the alist describing the current policy restrictions.
If
quality
isnil
or not given, nothing is done.Otherwise, if
min
is zero or not given, any existing restrictions ofquality
are removed. Ifmin
is between one and three inclusive, it becomes the new minimum value for the optimization quality: any future proclamations or declarations of the quality with a value less thenmin
behave as if the value wasmin
instead.This is intended to be used interactively, to facilitate recompiling large bodies of code with eg. a known minimum safety.
See also
:policy
option inwith-compilation-unit
.
experimental
interface:
Subject to change.
Affects compilations that take place within its dynamic extent. It is intended to be eg. wrapped around the compilation of all files in the same system.
Following options are defined:
:override
Boolean-Form- One of the effects of this form is to delay undefined warnings until the end of the form, instead of giving them at the end of each compilation. If
override
isnil
(the default), then the outermostwith-compilation-unit
form grabs the undefined warnings. Specifyingoverride
true causes that form to grab any enclosed warnings, even if it is enclosed by anotherwith-compilation-unit
.:policy
Optimize-Declaration-Form- Provides dynamic scoping for global compiler optimization qualities and restrictions, limiting effects of subsequent
optimize
proclamations and calls tosb-ext:restrict-compiler-policy
to the dynamic scope ofbody
.If
override
is false, specifiedpolicy
is merged with current global policy. Ifoverride
is true, current global policy, including any restrictions, is discarded in favor of the specifiedpolicy
.Supplying
policy
nil
is equivalent to the option not being supplied at all, ie. dynamic scoping of policy does not take place.This option is an SBCL-specific experimental extension: Interface subject to change.
:source-plist
Plist-Form- Attaches the value returned by the Plist-Form to internal debug-source information of functions compiled in within the dynamic extent of
body
.Primarily for use by development environments, in order to eg. associate function definitions with editor-buffers. Can be accessed using
sb-introspect:definition-source-plist
.If an outer
with-compilation-unit
form also provide asource-plist
, it is appended to the end of the providedsource-plist
. Unaffected by:override
.This is an SBCL-specific extension.
Examples:
;; Prevent proclamations from the file leaking, and restrict ;; SAFETY to 3 -- otherwise uses the current global policy. (with-compilation-unit (:policy '(optimize)) (restrict-compiler-policy 'safety 3) (load "foo.lisp")) ;; Using default policy instead of the current global one, ;; except for DEBUG 3. (with-compilation-unit (:policy '(optimize debug) :override t) (load "foo.lisp")) ;; Same as if :POLICY had not been specified at all: SAFETY 3 ;; proclamation leaks out from WITH-COMPILATION-UNIT. (with-compilation-unit (:policy nil) (declaim (optimize safety)) (load "foo.lisp"))
[1] A deprecated
extension sb-ext:inhibit-warnings
is still supported, but
liable to go away at any time.