736d28755a357ecfa7746ad3e88a1fe368135810
[sbcl.git] / src / compiler / policies.lisp
1 ;;;; aimed optimization qualities
2
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.
11
12 (in-package "SB!C")
13
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.")
19
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).")
35
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.")
42
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.")
47
48 (define-optimization-quality rest-conversion
49     (if (= debug 3) 0 3)
50   ("off" "maybe" "on" "on")
51   "Control conversion of &REST argments to &MORE arguments when
52 only used as the final argument to APPLY.")
53
54 (define-optimization-quality verify-arg-count
55     (if (zerop safety) 0 3)
56   ("no" "maybe" "yes" "yes"))
57
58 (define-optimization-quality merge-tail-calls
59     (if (or (> space debug)
60             (> speed debug))
61         3
62         0)
63   ("no" "maybe" "yes" "yes")
64   "Control whether tail-calls should reuse caller stack frame.
65 Enabling this option make functions use less stack space, and make
66 tail-recursive functions execute in constant stack, but debugging
67 become harder, because backtraces show only part of function call
68 sequence.
69
70 This options has no effect when INSERT-DEBUG-CATCH is set.")
71
72 (define-optimization-quality insert-debug-catch
73     (if (> debug (max speed space))
74         3
75         0)
76   ("no" "maybe" "yes" "yes")
77   "Enable possibility of returning from stack frames with the debugger.
78
79 Enabling this option effectively disables MERGE-TAIL-CALLS.")
80
81 (define-optimization-quality recognize-self-calls
82     (if (> (max speed space) debug)
83         3
84         0)
85   ("no" "maybe" "yes" "yes")
86   "When enabled, reference to a function FOO inside the body of (DEFUN
87 FOO ...) is considered to be the reference to the function being
88 defined. Calls to FOO are compiled as local. This allows better
89 optimization and type checking, but TRACE will not show recursive
90 calls. If the function object is bound to another name BAR, and FOO is
91 bound to another function, calls to FOO inside BAR will remain to be
92 recursive.
93
94 When disabled, internal references to a function FOO will be
95 considered ti be a call of a function, bound to the symbol at
96 run-time, which is less efficient. TRACE will show recursive calls. In
97 case of renaming described above, calls to FOO will not be recursive
98 and will refer to the new function, bound to FOO.")
99
100 (define-optimization-quality float-accuracy
101     3
102   ("degraded" "full" "full" "full"))
103
104 (define-optimization-quality insert-step-conditions
105     (if (> debug (max speed space compilation-speed))
106         debug
107         0)
108   ("no" "no" "partial" "full")
109   "Control instrumentation of code, enabling single-stepping through
110 it in the debugger.
111
112 This option has no effect without COMPUTE-DEBUG-FUN.")
113
114 (define-optimization-quality compute-debug-fun
115     debug
116   ("no" "minimal" "yes" "yes"))
117
118 (define-optimization-quality preserve-single-use-debug-variables
119     (if (and (>= debug 2)
120              (< speed 3))
121         3
122         0)
123   ("no" "no" "no" "yes")
124   "When disabled, LET variable, which is never set and is referenced
125 exactly once, is eliminated and the reference is substituted with the
126 initial value. This allows better type inference and some algebraic
127 optimizations.
128
129 When enabled, the variable is preserved and can be seen in the
130 debugger.")
131
132 (define-optimization-quality insert-array-bounds-checks
133     (if (= safety 0) 0 3)
134   ("no" "yes" "yes" "yes"))
135
136 (define-optimization-quality store-xref-data
137     (if (= space 3)
138         0
139         3)
140   ("no" "yes" "yes" "yes"))
141
142 (define-optimization-quality store-coverage-data
143     0
144   ("no" "no" "yes" "yes"))