Fix make-array transforms.
[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 alien-funcall-saves-fp-and-pc
49     (if (<= speed debug) 3 0)
50   ("no" "maybe" "yes" "yes")
51   "Control ALIEN-FUNCALL saving frame-pointer and program counter for
52 more reliable bactracing across foreign calls.")
53
54 (define-optimization-quality verify-arg-count
55     (if (zerop safety) 0 3)
56   ("no" "maybe" "yes" "yes"))
57
58 (define-optimization-quality insert-debug-catch
59     (if (> debug (max speed space))
60         3
61         0)
62   ("no" "maybe" "yes" "yes")
63   "Enables possibility of returning from stack frames with the debugger.
64 Enabling this option causes apparent tail calls to no longer be in a tail
65 position -- effectively disabling tail-merging, hence causing apparently tail
66 recursive functions to no longer execute in constant stack space")
67
68 (define-optimization-quality recognize-self-calls
69     (if (> (max speed space) debug)
70         3
71         0)
72   ("no" "maybe" "yes" "yes")
73   "When enabled, reference to a function FOO inside the body of (DEFUN
74 FOO ...) is considered to be the reference to the function being
75 defined. Calls to FOO are compiled as local. This allows better
76 optimization and type checking, but TRACE will not show recursive
77 calls. If the function object is bound to another name BAR, and FOO is
78 bound to another function, calls to FOO inside BAR will remain to be
79 recursive.
80
81 When disabled, internal references to a function FOO will be
82 considered ti be a call of a function, bound to the symbol at
83 run-time, which is less efficient. TRACE will show recursive calls. In
84 case of renaming described above, calls to FOO will not be recursive
85 and will refer to the new function, bound to FOO.")
86
87 (define-optimization-quality float-accuracy
88     3
89   ("degraded" "full" "full" "full"))
90
91 (define-optimization-quality insert-step-conditions
92     (if (> debug (max speed space compilation-speed))
93         debug
94         0)
95   ("no" "no" "partial" "full")
96   "Control instrumentation of code, enabling single-stepping through
97 it in the debugger.
98
99 This option has no effect without COMPUTE-DEBUG-FUN.")
100
101 (define-optimization-quality compute-debug-fun
102     debug
103   ("no" "minimal" "yes" "yes"))
104
105 (define-optimization-quality preserve-single-use-debug-variables
106     (if (and (>= debug 2)
107              (< speed 3))
108         3
109         0)
110   ("no" "no" "no" "yes")
111   "When disabled, LET variable, which is never set and is referenced
112 exactly once, is eliminated and the reference is substituted with the
113 initial value. This allows better type inference and some algebraic
114 optimizations.
115
116 When enabled, the variable is preserved and can be seen in the
117 debugger.")
118
119 (define-optimization-quality insert-array-bounds-checks
120     (if (= safety 0) 0 3)
121   ("no" "yes" "yes" "yes"))
122
123 (define-optimization-quality store-xref-data
124     (if (= space 3)
125         0
126         3)
127   ("no" "yes" "yes" "yes"))
128
129 (define-optimization-quality store-coverage-data
130     0
131   ("no" "no" "yes" "yes"))
132
133 #!+sb-safepoint
134 (define-optimization-quality inhibit-safepoints
135     0
136   ("no" "no" "yes" "yes")
137   "When disabled, the compiler will insert safepoints at strategic
138 points (loop edges, function prologues) to ensure that potentially
139 long-running code can be interrupted.
140
141 When enabled, no safepoints will be inserted explicitly.  Note that
142 this declaration does not prevent out-of-line function calls, which
143 will encounter safepoints unless the target function has also been
144 compiled with this declaration in effect.")