1.0.14.16: add explicit CHECK-CONSTANT-MODIFICATION policy
[sbcl/pkhuong.git] / src / compiler / policies.lisp
blob9164e6b0ccb7f2916501aef7323c88122f4d8f4f
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 (define-optimization-quality check-constant-modification
15 safety
16 ("no" "maybe" "yes" "yes")
17 "Control whether the compiler should check for constant
18 modification. Defaults to SAFETY.")
20 (define-optimization-quality type-check
21 ;; FIXME: grepping the tree for "policy.*safety" yields some
22 ;; places which might want to use this instead -- or
23 ;; some other derived policy.
24 (cond ((= safety 0) 0)
25 ((and (< safety 2) (< safety speed)) 2)
26 (t 3))
27 ("no" "maybe" "weak" "full")
28 "Control the way to perform runtime type checking:
29 0: declared types are simply trusted; no runtime checks are performed;
30 2: fast checks are performed: declared types are weakened to
31 FIXNUM/SINGLE-FLOAT/FLOAT/NUMBER/structure/specialized array etc.;
32 3: declared types are fully checked (several exceptions exist;
33 see \"SBCL User Manual\", Compiler->Handling of Types->
34 Implementation Limitations for details).")
36 (define-optimization-quality check-tag-existence
37 (cond ((= safety 0) 0)
38 (t 3))
39 ("no" "maybe" "yes" "yes")
40 "Control whether GO and RETURN-FROM check liveness of the destination tag.
41 Enabling this option can increase heap consing of closures.")
43 (define-optimization-quality let-conversion
44 (if (<= debug speed) 3 0)
45 ("off" "maybe" "on" "on")
46 "Control inline-substitution of used-once local functions.")
48 (define-optimization-quality verify-arg-count
49 (if (zerop safety) 0 3)
50 ("no" "maybe" "yes" "yes"))
52 (define-optimization-quality merge-tail-calls
53 (if (or (> space debug)
54 (> speed debug))
57 ("no" "maybe" "yes" "yes")
58 "Control whether tail-calls should reuse caller stack frame.
59 Enabling this option make functions use less stack space, and make
60 tail-recursive functions execute in constant stack, but debugging
61 become harder, because backtraces show only part of function call
62 sequence.
64 This options has no effect when INSERT-DEBUG-CATCH is set.")
66 (define-optimization-quality insert-debug-catch
67 (if (> debug (max speed space))
70 ("no" "maybe" "yes" "yes")
71 "Enable possibility of returning from stack frames with the debugger.
73 Enabling this option effectively disables MERGE-TAIL-CALLS.")
75 (define-optimization-quality recognize-self-calls
76 (if (> (max speed space) debug)
79 ("no" "maybe" "yes" "yes")
80 "When enabled, reference to a function FOO inside the body of (DEFUN
81 FOO ...) is considered to be the reference to the function being
82 defined. Calls to FOO are compiled as local. This allows better
83 optimization and type checking, but TRACE will not show recursive
84 calls. If the function object is bound to another name BAR, and FOO is
85 bound to another function, calls to FOO inside BAR will remain to be
86 recursive.
88 When disabled, internal references to a function FOO will be
89 considered ti be a call of a function, bound to the symbol at
90 run-time, which is less efficient. TRACE will show recursive calls. In
91 case of renaming described above, calls to FOO will not be recursive
92 and will refer to the new function, bound to FOO.")
94 (define-optimization-quality stack-allocate-dynamic-extent
95 (if (and (> (max speed space) (max debug safety))
96 (< safety 3))
99 ("no" "maybe" "yes" "yes")
100 "Control whether allocate objects, declared DYNAMIC-EXTENT, on
101 stack.")
103 (define-optimization-quality stack-allocate-vector
104 (cond ((= stack-allocate-dynamic-extent 0) 0)
105 ((= safety 0) 3)
106 (t 2))
107 ("no" "maybe" "one page" "yes")
108 "Control what vectors, declared DYNAMIC-EXTENT, are allocated on stack:
109 0: no vectors are allocated on stack;
110 2: only short vectors (compiler knows them to fit on one page);
111 3: every.
113 This option has an effect only when STACK-ALLOCATE-DYNAMIC-EXTENT is
114 set.")
116 (define-optimization-quality float-accuracy
118 ("degraded" "full" "full" "full"))
120 (define-optimization-quality insert-step-conditions
121 (if (> debug (max speed space compilation-speed))
122 debug
124 ("no" "no" "partial" "full")
125 "Control instrumentation of code, enabling single-stepping through
126 it in the debugger.
128 This option has no effect without COMPUTE-DEBUG-FUN.")
130 (define-optimization-quality compute-debug-fun
131 debug
132 ("no" "minimal" "yes" "yes"))
134 (define-optimization-quality preserve-single-use-debug-variables
135 (if (and (>= debug 2)
136 (< speed 3))
139 ("no" "no" "no" "yes")
140 "When disabled, LET variable, which is never set and is referenced
141 exactly once, is eliminated and the reference is substituted with the
142 initial value. This allows better type inference and some algebraic
143 optimizations.
145 When enabled, the variable is preserved and can be seen in the
146 debugger.")
148 (define-optimization-quality insert-array-bounds-checks
149 (if (= safety 0) 0 3)
150 ("no" "yes" "yes" "yes"))
152 (define-optimization-quality store-xref-data
153 (if (= space 3)
156 ("no" "yes" "yes" "yes"))
158 (define-optimization-quality store-coverage-data
160 ("no" "no" "yes" "yes"))