naming 2/2 - use naming_db_path provider
[hiphop-php.git] / hphp / hhbbc / options.h
blob304250c03953d29d81a1660fe6a28c96e6ccbb79
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
16 #ifndef incl_HPHP_HHBBC_OPTIONS_H_
17 #define incl_HPHP_HHBBC_OPTIONS_H_
19 #include <string>
20 #include <utility>
22 #include "hphp/hhbbc/hhbbc.h"
24 namespace HPHP {
26 namespace HHBBC {
28 //////////////////////////////////////////////////////////////////////
31 * Publically-settable options that control compilation.
33 struct Options {
35 * When debugging, it can be useful to ask for certain functions to be traced
36 * at a higher level than the rest of the program.
38 MethodMap TraceFunctions;
41 * When debugging, it can be useful to ask for a list of functions
42 * that use particular bytecodes.
44 OpcodeSet TraceBytecodes;
47 * If non-empty, dump jemalloc memory profiles at key points during
48 * the build, using this as a prefix.
50 std::string profileMemory;
52 //////////////////////////////////////////////////////////////////////
55 * Flags for various limits on when to perform widening operations.
56 * See analyze.cpp for details.
58 uint32_t analyzeFuncWideningLimit = 12;
59 uint32_t analyzeClassWideningLimit = 6;
62 * When to stop refining return types.
64 * This needs to be limited because types can walk downwards in our
65 * type lattice indefinitely. The index never contains incorrect
66 * return types, since the return types only shrink, which means we
67 * can just stop refining a return type whenever we want to without
68 * causing problems.
70 * For an example of where this can occur, imagine the analysis of the
71 * following function:
73 * function foo() { return array('x' => foo()); }
75 * Each time we visit `foo', we'll discover a slightly smaller return
76 * type, in a downward-moving sequence that would never terminate:
78 * InitCell, CArrN(x:InitCell), CArrN(x:CArrN(x:InitCell)), ...
80 uint32_t returnTypeRefineLimit = 15;
83 * Limit public static property refinement for the same reason.
85 uint32_t publicSPropRefineLimit = 15;
88 * Whether to produce extended stats information. (Takes extra
89 * time.)
91 bool extendedStats = false;
93 //////////////////////////////////////////////////////////////////////
96 * If true, all optimizations are disabled, and analysis isn't even
97 * performed.
99 bool NoOptimizations = false;
102 * If true, analyze calls to functions in a context-sensitive way.
104 * Disabled by default because its slow, with very little gain.
106 bool ContextSensitiveInterp = false;
109 * If true, completely remove jumps to blocks that are inferred to be dead.
110 * When false, dead blocks are replaced with Fatal bytecodes.
112 bool RemoveDeadBlocks = true;
115 * Whether to propagate constant values by replacing instructions which are
116 * known to always produce a constant with instructions that produce that
117 * constant.
119 bool ConstantProp = true;
122 * Whether we should evaluate side-effect free builtins at compile time when
123 * they have compile-time constant arguments.
125 bool ConstantFoldBuiltins = true;
128 * Whether to perform local or global dead code elimination. This removes
129 * unnecessary instructions within a single block, or across blocks,
130 * respectively.
132 bool LocalDCE = true;
133 bool GlobalDCE = true;
136 * Whether to remove completely unused local variables. This requires
137 * GlobalDCE.
139 bool RemoveUnusedLocals = true;
142 * If true, insert opcodes that assert inferred types, so we can assume them
143 * at runtime.
145 bool InsertAssertions = true;
146 bool InsertStackAssertions = true;
149 * If true, try to filter asserts out that are "obvious" (this is a code size
150 * optimization). It can be useful to turn this option off for debugging.
152 * Has no effect if !InsertStackAssertions.
154 bool FilterAssertions = true;
157 * Whether to replace bytecode with less expensive bytecodes when we can.
158 * E.g. InstanceOf -> InstanceOfD or FCallFunc -> FCallFuncD.
160 bool StrengthReduce = true;
163 * Whether to enable 'FuncFamily' method resolution.
165 * This allows possible overrides of a method to be resolved as a
166 * set of candidates when we aren't sure which one it would be.
168 bool FuncFamilies = true;
171 * Whether or not hhbbc should attempt to do anything intelligent to
172 * pseudomains.
174 bool AnalyzePseudomains = true;
177 * Should we do an extra whole-program pass to try to determine the types of
178 * public static properties. This will not yield any useful information for
179 * programs that contain any sets to static properties with both a dynamic
180 * property name and an unknown class type.
182 bool AnalyzePublicStatics = true;
184 //////////////////////////////////////////////////////////////////////
185 // Flags below this line perform optimizations that intentionally
186 // may have user-visible changes to program behavior.
187 //////////////////////////////////////////////////////////////////////
190 * If true, we'll try to infer the types of declared private class
191 * properties.
193 * This is in the can-potentially-change-program-behavior section
194 * because if you unserialize specially-constructed strings you
195 * could create instances with private properties that don't follow
196 * the inferred types. HHVM tracks the types that were inferred,
197 * and if an unserialize happens that would violate what we've
198 * inferred, we'll raise a notice and unserialize() returns false.
200 bool HardPrivatePropInference = true;
203 * Whether to flatten trait methods and properties into the classes
204 * that use them.
206 bool FlattenTraits = true;
209 * The filepath where to save the stats file. If the path is empty, then we
210 * save the stats file to a temporary file.
212 std::string stats_file;
214 extern Options options;
218 #endif