Eliminate style-warning about undefined type GLOBAL-VAR
[sbcl.git] / src / compiler / policies.lisp
blobd35f6b7368022826bf81d6aca34c6f8146733f0b
1 ;;;; aimed optimization qualities
3 ;;;; This software is part of the SBCL system. See the README file for
4 ;;;; more information.
5 ;;;;
6 ;;;; This software is derived from the CMU CL system, which was
7 ;;;; written at Carnegie Mellon University and released into the
8 ;;;; public domain. The software is in the public domain and is
9 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
10 ;;;; files for more information.
12 (in-package "SB!C")
14 ;; The print method is here on account of it not working in 'policy.lisp'
15 (defmethod print-object ((self policy) stream)
16 (if *print-readably*
17 (call-next-method)
18 (print-unreadable-object (self stream :type t)
19 (write (policy-to-decl-spec self) :stream stream))))
21 (define-optimization-quality check-constant-modification
22 safety
23 ("no" "maybe" "yes" "yes")
24 "Control whether the compiler should check for constant
25 modification. Defaults to SAFETY.")
27 (define-optimization-quality type-check
28 ;; FIXME: grepping the tree for "policy.*safety" yields some
29 ;; places which might want to use this instead -- or
30 ;; some other derived policy.
31 (cond ((= safety 0) 0)
32 ((and (< safety 2) (< safety speed)) 2)
33 (t 3))
34 ("no" "maybe" "weak" "full")
35 "Control the way to perform runtime type checking:
36 0: declared types are simply trusted; no runtime checks are performed;
37 2: fast checks are performed: declared types are weakened to
38 FIXNUM/SINGLE-FLOAT/FLOAT/NUMBER/structure/specialized array etc.;
39 3: declared types are fully checked (several exceptions exist;
40 see \"SBCL User Manual\", Compiler->Handling of Types->
41 Implementation Limitations for details).")
43 (define-optimization-quality check-tag-existence
44 (cond ((= safety 0) 0)
45 (t 3))
46 ("no" "maybe" "yes" "yes")
47 "Control whether GO and RETURN-FROM check liveness of the destination tag.
48 Enabling this option can increase heap consing of closures.")
50 (define-optimization-quality let-conversion
51 (if (<= debug speed) 3 0)
52 ("off" "maybe" "on" "on")
53 "Control inline-substitution of used-once local functions.")
55 (define-optimization-quality alien-funcall-saves-fp-and-pc
56 (if (<= speed debug) 3 0)
57 ("no" "maybe" "yes" "yes")
58 "Control ALIEN-FUNCALL saving frame-pointer and program counter for
59 more reliable bactracing across foreign calls.")
61 (define-optimization-quality verify-arg-count
62 (if (zerop safety) 0 3)
63 ("no" "maybe" "yes" "yes"))
65 (define-optimization-quality insert-debug-catch
66 ;; It's more expansive to be enabled by default without
67 ;; UNWIND-TO-FRAME-AND-CALL
68 #!-unwind-to-frame-and-call-vop
69 (if (> debug (max speed space))
72 #!+unwind-to-frame-and-call-vop
73 (cond ((and (= debug 3)
74 (> debug speed))
76 ((and (> debug 0)
77 (>= debug speed))
80 0))
81 ("no" "maybe" "yes" "yes")
82 "Enables possibility of returning from stack frames with the debugger.
83 The default value 1 doesn't prevent tail call optimization, while >1 does.")
85 (define-optimization-quality recognize-self-calls
86 (if (> (max speed space) debug)
89 ("no" "maybe" "yes" "yes")
90 "When enabled, reference to a function FOO inside the body of (DEFUN
91 FOO ...) is considered to be the reference to the function being
92 defined. Calls to FOO are compiled as local. This allows better
93 optimization and type checking, but TRACE will not show recursive
94 calls. If the function object is bound to another name BAR, and FOO is
95 bound to another function, calls to FOO inside BAR will remain to be
96 recursive.
98 When disabled, internal references to a function FOO will be
99 considered ti be a call of a function, bound to the symbol at
100 run-time, which is less efficient. TRACE will show recursive calls. In
101 case of renaming described above, calls to FOO will not be recursive
102 and will refer to the new function, bound to FOO.")
104 (define-optimization-quality float-accuracy
106 ("degraded" "full" "full" "full"))
108 (define-optimization-quality insert-step-conditions
109 (if (> debug (max speed space compilation-speed))
110 debug
112 ("no" "no" "partial" "full")
113 "Control instrumentation of code, enabling single-stepping through
114 it in the debugger.
116 This option has no effect without COMPUTE-DEBUG-FUN.")
118 (define-optimization-quality compute-debug-fun
119 debug
120 ("no" "minimal" "yes" "yes"))
122 (define-optimization-quality preserve-single-use-debug-variables
123 (if (and (>= debug 2)
124 (< speed 3))
127 ("no" "no" "no" "yes")
128 "When disabled, LET variable, which is never set and is referenced
129 exactly once, is eliminated and the reference is substituted with the
130 initial value. This allows better type inference and some algebraic
131 optimizations.
133 When enabled, the variable is preserved and can be seen in the
134 debugger.")
136 (define-optimization-quality insert-array-bounds-checks
137 (if (= safety 0) 0 3)
138 ("no" "yes" "yes" "yes"))
140 (define-optimization-quality store-xref-data
141 (if (= space 3)
144 ("no" "yes" "yes" "yes"))
146 (define-optimization-quality store-coverage-data
148 ("no" "no" "yes" "yes"))
150 #!+sb-safepoint
151 (define-optimization-quality inhibit-safepoints
153 ("no" "no" "yes" "yes")
154 "When disabled, the compiler will insert safepoints at strategic
155 points (loop edges, function prologues) to ensure that potentially
156 long-running code can be interrupted.
158 When enabled, no safepoints will be inserted explicitly. Note that
159 this declaration does not prevent out-of-line function calls, which
160 will encounter safepoints unless the target function has also been
161 compiled with this declaration in effect.")
163 (define-optimization-quality store-closure-debug-pointer
165 ("no" "no" "yes" "yes"))
167 ;;; ALLOW-NON-RETURNING-TAIL-CALL unsupresses the supression of tail-call
168 ;;; optimization of nil-returning functions.
170 ;;; At present this is used only by the ARG-COUNT-ERROR function, but would be
171 ;;; useful in similar functions whose sole purpose is to accept positional
172 ;;; arguments, shaping them into keyword arguments with which to call ERROR.
173 ;;; Generally any function tail-calling a nil-returning function remains on the
174 ;;; stack to allow a debugger to see variables in the signaling frame.
175 ;;; However ARG-COUNT-ERROR is not supposed to be visible.
176 ;;; Techniques that evolved to address its invisibility were brittle:
177 ;;; undocumented DEBUG versus SPEED policy-based decisions in TAIL-ANNOTATE,
178 ;;; or inefficient (performing FIND-CALLER-FRAME before calling ERROR).
179 ;;; Frobbing *STACK-TOP-HINT* seems no better than a declaration saying
180 ;;; "do what I mean," as the latter at least produces a consistent backtrace
181 ;;; between Lisp and ldb or gdb.
183 (define-optimization-quality allow-non-returning-tail-call
185 ("no" "no" "no" "yes"))
187 ;;; On the cross-compilation host, we initialize at load time
188 #+sb-xc-host (!policy-cold-init-or-resanify)