2 +----------------------------------------------------------------------+
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 +----------------------------------------------------------------------+
21 #include "hphp/hhbbc/hhbbc.h"
27 //////////////////////////////////////////////////////////////////////
30 * Publically-settable options that control compilation.
34 * When debugging, it can be useful to ask for certain functions to be traced
35 * at a higher level than the rest of the program.
37 MethodMap TraceFunctions
;
40 * When debugging, it can be useful to ask for a list of functions
41 * that use particular bytecodes.
43 OpcodeSet TraceBytecodes
;
46 * If non-empty, dump jemalloc memory profiles at key points during
47 * the build, using this as a prefix.
49 std::string profileMemory
;
51 //////////////////////////////////////////////////////////////////////
54 * Flags for various limits on when to perform widening operations.
55 * See analyze.cpp for details.
57 uint32_t analyzeFuncWideningLimit
= 8;
58 uint32_t analyzeClassWideningLimit
= 6;
61 * When to stop refining return types.
63 * This needs to be limited because types can walk downwards in our
64 * type lattice indefinitely. The index never contains incorrect
65 * return types, since the return types only shrink, which means we
66 * can just stop refining a return type whenever we want to without
69 * For an example of where this can occur, imagine the analysis of the
72 * function foo() { return array('x' => foo()); }
74 * Each time we visit `foo', we'll discover a slightly smaller return
75 * type, in a downward-moving sequence that would never terminate:
77 * InitCell, CArrN(x:InitCell), CArrN(x:CArrN(x:InitCell)), ...
79 uint32_t returnTypeRefineLimit
= 8;
82 * Limit public static property refinement for the same reason.
84 uint32_t publicSPropRefineLimit
= 8;
87 * Whether to produce extended stats information. (Takes extra
90 bool extendedStats
= false;
92 //////////////////////////////////////////////////////////////////////
95 * If true, all optimizations are disabled, and analysis isn't even
98 bool NoOptimizations
= false;
101 * If true, analyze calls to functions in a context-sensitive way.
103 * Disabled by default because its slow, with very little gain.
105 bool ContextSensitiveInterp
= false;
108 * If true, completely remove jumps to blocks that are inferred to be dead.
109 * When false, dead blocks are replaced with Fatal bytecodes.
111 bool RemoveDeadBlocks
= true;
114 * Whether to propagate constant values by replacing instructions which are
115 * known to always produce a constant with instructions that produce that
118 bool ConstantProp
= true;
121 * Whether we should evaluate side-effect free builtins at compile time when
122 * they have compile-time constant arguments.
124 bool ConstantFoldBuiltins
= true;
127 * Whether to perform local or global dead code elimination. This removes
128 * unnecessary instructions within a single block, or across blocks,
131 bool LocalDCE
= true;
132 bool GlobalDCE
= true;
135 * Whether to remove completely unused local names. This requires
138 bool RemoveUnusedLocalNames
= true;
141 * Whether to compact local slot usage by having non conflicting locals share
142 * a local slot. This requires GlobalDCE.
144 bool CompactLocalSlots
= true;
147 * If true, insert opcodes that assert inferred types, so we can assume them
150 bool InsertAssertions
= true;
151 bool InsertStackAssertions
= true;
154 * If true, try to filter asserts out that are "obvious" (this is a code size
155 * optimization). It can be useful to turn this option off for debugging.
157 * Has no effect if !InsertStackAssertions.
159 bool FilterAssertions
= true;
162 * Whether to replace bytecode with less expensive bytecodes when we can.
163 * E.g. InstanceOf -> InstanceOfD or FCallFunc -> FCallFuncD.
165 bool StrengthReduce
= true;
168 * Whether to enable 'FuncFamily' method resolution.
170 * This allows possible overrides of a method to be resolved as a
171 * set of candidates when we aren't sure which one it would be.
173 bool FuncFamilies
= true;
176 * Should we do an extra whole-program pass to try to determine the types of
177 * public static properties. This will not yield any useful information for
178 * programs that contain any sets to static properties with both a dynamic
179 * property name and an unknown class type.
181 bool AnalyzePublicStatics
= true;
183 //////////////////////////////////////////////////////////////////////
184 // Flags below this line perform optimizations that intentionally
185 // may have user-visible changes to program behavior.
186 //////////////////////////////////////////////////////////////////////
189 * If true, we'll try to infer the types of declared private class
192 * This is in the can-potentially-change-program-behavior section
193 * because if you unserialize specially-constructed strings you
194 * could create instances with private properties that don't follow
195 * the inferred types. HHVM tracks the types that were inferred,
196 * and if an unserialize happens that would violate what we've
197 * inferred, we'll raise a notice and unserialize() returns false.
199 bool HardPrivatePropInference
= true;
202 * Whether to flatten trait methods and properties into the classes
205 bool FlattenTraits
= true;
208 * The filepath where to save the stats file. If the path is empty, then we
209 * save the stats file to a temporary file.
211 std::string stats_file
;
214 * Run a test of HHBBC memory compression (e.g. bytecode compression).
216 bool TestCompression
;
218 extern Options options
;