Add logging for array_key_exists(null, X) when X is a Hack array
[hiphop-php.git] / hphp / runtime / base / runtime-option.h
blob690ef0e3771addd49a672550e8365239ad0b061c
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 +----------------------------------------------------------------------+
17 #ifndef incl_HPHP_RUNTIME_OPTION_H_
18 #define incl_HPHP_RUNTIME_OPTION_H_
20 #include <folly/dynamic.h>
22 #include <unordered_map>
23 #include <algorithm>
24 #include <vector>
25 #include <string>
26 #include <map>
27 #include <set>
28 #include <boost/container/flat_set.hpp>
29 #include <memory>
30 #include <sys/stat.h>
32 #include "hphp/runtime/base/config.h"
33 #include "hphp/runtime/base/typed-value.h"
34 #include "hphp/util/compilation-flags.h"
35 #include "hphp/util/hash-map.h"
36 #include "hphp/util/functional.h"
38 namespace HPHP {
39 ///////////////////////////////////////////////////////////////////////////////
41 struct AccessLogFileData;
42 struct ErrorLogFileData;
43 struct VirtualHost;
44 struct IpBlockMap;
45 struct SatelliteServerInfo;
46 struct FilesMatch;
47 struct Hdf;
48 struct IniSettingMap;
50 constexpr int kDefaultInitialStaticStringTableSize = 500000;
52 enum class JitSerdesMode {
53 // NB: if changing the encoding here, make sure to update isJitSerializing()
54 // and isJitDeserializing() as needed.
56 // Bit 0: serialize
57 // Bit 1: deserialize
58 Off = 0x0,
59 Serialize = 0x1, // 00001
60 SerializeAndExit = 0x5, // 00101
61 Deserialize = 0x2, // 00010
62 DeserializeOrFail = 0x6, // 00110
63 DeserializeOrGenerate = 0xa, // 01010
64 DeserializeAndDelete = 0xe, // 01110
65 DeserializeAndExit = 0x12, // 10010
68 struct RepoOptions {
69 RepoOptions(const RepoOptions&) = default;
70 RepoOptions(RepoOptions&&) = default;
72 using StringMap = std::map<std::string, std::string>;
73 // (Type, HDFName, DV)
74 // (N=no-prefix, P=PHP7, E=Eval, H=Hack.Lang)
75 #define PARSERFLAGS() \
76 N(StringMap, AliasedNamespaces, StringMap{}) \
77 P(bool, UVS, s_PHP7_master) \
78 P(bool, LTRAssign, s_PHP7_master) \
79 H(bool, EnableCoroutines, true) \
80 H(bool, Hacksperimental, false) \
81 H(bool, DisableLvalAsAnExpression, false) \
82 H(bool, HackCompilerUseRustParser, true) \
83 H(bool, AllowNewAttributeSyntax, false) \
84 H(bool, ConstDefaultFuncArgs, false) \
85 H(bool, ConstStaticProps, false) \
86 H(bool, AbstractStaticProps, false) \
87 H(bool, DisableUnsetClassConst, false) \
88 E(bool, CreateInOutWrapperFunctions, true) \
89 E(std::string, HHJSAdditionalTransform, "") \
90 E(bool, HHJSNoBabel, false) \
91 E(bool, HHJSUniqueFilenames, true) \
92 E(std::string, HHJSBabelTransform, \
93 hhjsBabelTransformDefault()) \
94 E(bool, HHJSSetLocs, false) \
95 E(std::string, HHJSNodeModules, "") \
96 E(bool, EmitFuncPointers, true) \
97 E(bool, EmitInstMethPointers, EmitFuncPointers) \
98 /**/
100 #define AUTOLOADFLAGS() \
101 N(std::string, Query, "") \
102 /**/
104 std::string path() const { return m_path; }
105 std::string cacheKeyRaw() const;
106 std::string cacheKeySha1() const;
107 std::string toJSON() const;
108 folly::dynamic toDynamic() const;
109 struct stat stat() const { return m_stat; }
110 std::string autoloadQuery() const noexcept { return Query; }
112 bool operator==(const RepoOptions& o) const;
114 static const RepoOptions& defaults();
115 static void setDefaults(const Hdf& hdf, const IniSettingMap& ini);
117 static const RepoOptions& forFile(const char* path);
119 private:
120 RepoOptions() = default;
121 explicit RepoOptions(const char* file);
123 void filterNamespaces();
124 void initDefaults(const Hdf& hdf, const IniSettingMap& ini);
126 #define N(t, n, ...) t n;
127 #define P(t, n, ...) t n;
128 #define H(t, n, ...) t n;
129 #define E(t, n, ...) t n;
130 PARSERFLAGS()
131 AUTOLOADFLAGS()
132 #undef N
133 #undef P
134 #undef H
135 #undef E
137 std::string m_path;
138 struct stat m_stat;
140 static bool s_init;
141 static RepoOptions s_defaults;
145 * Configurable options set from command line or configurable file at startup
146 * time.
148 struct RuntimeOption {
149 static void Load(
150 IniSettingMap &ini, Hdf& config,
151 const std::vector<std::string>& iniClis = std::vector<std::string>(),
152 const std::vector<std::string>& hdfClis = std::vector<std::string>(),
153 std::vector<std::string>* messages = nullptr,
154 std::string cmd = "");
156 static bool ServerExecutionMode() {
157 return ServerMode;
160 static bool GcSamplingEnabled() {
161 return EvalGCSampleRate > 0;
164 static bool JitSamplingEnabled() {
165 return EvalJit && EvalJitSampleRate > 0;
168 static void ReadSatelliteInfo(
169 const IniSettingMap& ini,
170 const Hdf& hdf,
171 std::vector<std::shared_ptr<SatelliteServerInfo>>& infos,
172 std::string& xboxPassword,
173 std::set<std::string>& xboxPasswords
176 static std::string getTraceOutputFile();
178 static bool ServerMode;
179 static std::string BuildId;
180 static std::string InstanceId;
181 static std::string DeploymentId; // ID for set of instances deployed at once
182 static int64_t ConfigId; // Queryable to verify a specific config was read
183 static std::string PidFile;
185 static std::map<std::string, ErrorLogFileData> ErrorLogs;
186 static std::string LogFile;
187 static std::string LogFileSymLink;
188 static uint16_t LogFilePeriodMultiplier;
190 static int LogHeaderMangle;
191 static bool AlwaysEscapeLog;
192 static bool AlwaysLogUnhandledExceptions;
193 static bool NoSilencer;
194 static int ErrorUpgradeLevel; // Bitmask of errors to upgrade to E_USER_ERROR
195 static bool CallUserHandlerOnFatals;
196 static bool ThrowExceptionOnBadMethodCall;
197 static bool LogNativeStackOnOOM;
198 static int RuntimeErrorReportingLevel;
199 static int ForceErrorReportingLevel; // Bitmask ORed with the reporting level
201 static std::string ServerUser; // run server under this user account
202 static bool AllowRunAsRoot; // Allow running hhvm as root.
204 static int MaxSerializedStringSize;
205 static bool NoInfiniteRecursionDetection;
206 static bool AssertEmitted;
207 static int64_t NoticeFrequency; // output 1 out of NoticeFrequency notices
208 static int64_t WarningFrequency;
209 static int RaiseDebuggingFrequency;
210 static int64_t SerializationSizeLimit;
212 static std::string AccessLogDefaultFormat;
213 static std::map<std::string, AccessLogFileData> AccessLogs;
215 static std::string AdminLogFormat;
216 static std::string AdminLogFile;
217 static std::string AdminLogSymLink;
219 static std::map<std::string, AccessLogFileData> RPCLogs;
221 static std::string Host;
222 static std::string DefaultServerNameSuffix;
223 static std::string ServerType;
224 static std::string ServerIP;
225 static std::string ServerFileSocket;
226 static const std::string& GetServerPrimaryIPv4();
227 static const std::string& GetServerPrimaryIPv6();
228 static int ServerPort;
229 static int ServerPortFd;
230 static int ServerBacklog;
231 static int ServerConnectionLimit;
232 static int ServerThreadCount;
233 static int ServerQueueCount;
234 // Number of worker threads with stack partially on huge pages.
235 static int ServerHugeThreadCount;
236 static int ServerHugeStackKb;
237 static uint32_t ServerLoopSampleRate;
238 static int ServerWarmupThrottleRequestCount;
239 static int ServerWarmupThrottleThreadCount;
240 static int ServerThreadDropCacheTimeoutSeconds;
241 static int ServerThreadJobLIFOSwitchThreshold;
242 static int ServerThreadJobMaxQueuingMilliSeconds;
243 static bool AlwaysDecodePostDataDefault;
244 static bool ServerThreadDropStack;
245 static bool ServerHttpSafeMode;
246 static bool ServerStatCache;
247 static bool ServerFixPathInfo;
248 static bool ServerAddVaryEncoding;
249 static bool ServerLogSettingsOnStartup;
250 static bool ServerLogReorderProps;
251 static bool ServerForkEnabled;
252 static bool ServerForkLogging;
253 static bool ServerWarmupConcurrently;
254 static int ServerWarmupThreadCount;
255 static int ServerExtendedWarmupThreadCount;
256 static unsigned ServerExtendedWarmupRepeat;
257 static unsigned ServerExtendedWarmupDelaySeconds;
258 static std::vector<std::string> ServerWarmupRequests;
259 static std::vector<std::string> ServerExtendedWarmupRequests;
260 static std::string ServerCleanupRequest;
261 static int ServerInternalWarmupThreads;
262 static boost::container::flat_set<std::string> ServerHighPriorityEndPoints;
263 static bool ServerExitOnBindFail;
264 static int PageletServerThreadCount;
265 static int PageletServerHugeThreadCount;
266 static int PageletServerThreadDropCacheTimeoutSeconds;
267 static int PageletServerQueueLimit;
268 static bool PageletServerThreadDropStack;
270 static int RequestTimeoutSeconds;
271 static int PspTimeoutSeconds;
272 static int PspCpuTimeoutSeconds;
273 static int64_t MaxRequestAgeFactor;
274 static int64_t RequestMemoryMaxBytes;
275 // Threshold for aborting when host is low on memory.
276 static int64_t RequestMemoryOOMKillBytes;
277 // Approximate upper bound for thread heap that is backed by huge pages. This
278 // doesn't include the first slab colocated with thread stack, if any.
279 static int64_t RequestHugeMaxBytes;
280 static int64_t ImageMemoryMaxBytes;
281 static int ServerGracefulShutdownWait;
282 static bool ServerHarshShutdown;
283 static bool ServerEvilShutdown;
284 static bool ServerKillOnTimeout;
285 static int ServerPreShutdownWait;
286 static int ServerShutdownListenWait;
287 static int ServerShutdownEOMWait;
288 static int ServerPrepareToStopTimeout;
289 static int ServerPartialPostStatusCode;
290 // If `StopOldServer` is set, we try to stop the old server running
291 // on the local host earlier when we initialize, and we do not start
292 // serving requests until we are confident that the system can give
293 // the new server `ServerRSSNeededMb` resident memory, or till
294 // `OldServerWait` seconds passes after an effort to stop the old
295 // server is made.
296 static bool StopOldServer;
297 static int64_t ServerRSSNeededMb;
298 // Threshold of free memory below which the old server is shutdown immediately
299 // upon a memory pressure check.
300 static int64_t ServerCriticalFreeMb;
301 static int OldServerWait;
302 // The percentage of page caches that can be considered as free (0 -
303 // 100). This is experimental.
304 static int CacheFreeFactor;
305 static std::vector<std::string> ServerNextProtocols;
306 static bool ServerEnableH2C;
307 static int BrotliCompressionEnabled;
308 static int BrotliChunkedCompressionEnabled;
309 static int BrotliCompressionMode;
310 // Base 2 logarithm of the sliding window size. Range is 10-24.
311 static int BrotliCompressionLgWindowSize;
312 static int BrotliCompressionQuality;
313 static int ZstdCompressionEnabled;
314 static int ZstdCompressionLevel;
315 static int GzipCompressionLevel;
316 static int GzipMaxCompressionLevel;
317 static bool EnableKeepAlive;
318 static bool ExposeHPHP;
319 static bool ExposeXFBServer;
320 static bool ExposeXFBDebug;
321 static std::string XFBDebugSSLKey;
322 static int ConnectionTimeoutSeconds;
323 static bool EnableOutputBuffering;
324 static std::string OutputHandler;
325 static bool ImplicitFlush;
326 static bool EnableEarlyFlush;
327 static bool ForceChunkedEncoding;
328 static int64_t MaxPostSize;
329 static int64_t LowestMaxPostSize;
330 static bool AlwaysPopulateRawPostData;
331 static int64_t UploadMaxFileSize;
332 static std::string UploadTmpDir;
333 static bool EnableFileUploads;
334 static bool EnableUploadProgress;
335 static int64_t MaxFileUploads;
336 static int Rfc1867Freq;
337 static std::string Rfc1867Prefix;
338 static std::string Rfc1867Name;
339 static bool ExpiresActive;
340 static int ExpiresDefault;
341 static std::string DefaultCharsetName;
342 static bool ForceServerNameToHeader;
343 static bool PathDebug;
344 static std::vector<std::shared_ptr<VirtualHost>> VirtualHosts;
345 static std::shared_ptr<IpBlockMap> IpBlocks;
346 static std::vector<std::shared_ptr<SatelliteServerInfo>>
347 SatelliteServerInfos;
349 // If a request has a body over this limit, switch to on-demand reading.
350 // -1 for no limit.
351 static int64_t RequestBodyReadLimit;
353 static bool EnableSSL;
354 static int SSLPort;
355 static int SSLPortFd;
356 static std::string SSLCertificateFile;
357 static std::string SSLCertificateKeyFile;
358 static std::string SSLCertificateDir;
359 static std::string SSLTicketSeedFile;
360 static bool TLSDisableTLS1_2;
361 static std::string TLSClientCipherSpec;
362 static bool EnableSSLWithPlainText;
363 // Level of TLS client auth. Valid values are
364 // 0 => disabled (default)
365 // 1 => optional (verify if client presents a cert)
366 // 2 => required (client must present a valid cert)
367 static int SSLClientAuthLevel;
368 // CA file to verify client cert against.
369 static std::string SSLClientCAFile;
370 // Sampling ratio for client auth logging. Must be an int within [0, 100].
371 // 0 => disabled; 100 => log all connections.
372 static uint32_t SSLClientAuthLoggingSampleRatio;
374 static int XboxServerThreadCount;
375 static int XboxServerMaxQueueLength;
376 static int XboxServerPort;
377 static int XboxDefaultLocalTimeoutMilliSeconds;
378 static int XboxDefaultRemoteTimeoutSeconds;
379 static int XboxServerInfoMaxRequest;
380 static int XboxServerInfoDuration;
381 static std::string XboxServerInfoReqInitFunc;
382 static std::string XboxServerInfoReqInitDoc;
383 static bool XboxServerInfoAlwaysReset;
384 static bool XboxServerLogInfo;
385 static std::string XboxProcessMessageFunc;
386 static std::string XboxPassword;
387 static std::set<std::string> XboxPasswords;
389 static std::string SourceRoot;
390 static std::vector<std::string> IncludeSearchPaths;
393 * Legal root directory expressions in an include expression. For example,
395 * include_once $PHP_ROOT . '/lib.php';
397 * Here, "$PHP_ROOT" is a legal include root. Stores what it resolves to.
399 * RuntimeOption::IncludeRoots["$PHP_ROOT"] = "";
400 * RuntimeOption::IncludeRoots["$LIB_ROOT"] = "lib";
402 static std::map<std::string, std::string> IncludeRoots;
403 static std::map<std::string, std::string> AutoloadRoots;
405 static bool AutoloadEnabled;
406 static std::string AutoloadDBPath;
408 static std::string FileCache;
409 static std::string DefaultDocument;
410 static std::string ErrorDocument404;
411 static bool ForbiddenAs404;
412 static std::string ErrorDocument500;
413 static std::string FatalErrorMessage;
414 static std::string FontPath;
415 static bool EnableStaticContentFromDisk;
416 static bool EnableOnDemandUncompress;
417 static bool EnableStaticContentMMap;
419 static bool Utf8izeReplace;
421 static std::string RequestInitFunction;
422 static std::string RequestInitDocument;
423 static std::string AutoPrependFile;
424 static std::string AutoAppendFile;
426 static bool SafeFileAccess;
427 static std::vector<std::string> AllowedDirectories;
428 static std::set<std::string> AllowedFiles;
429 static hphp_string_imap<std::string> StaticFileExtensions;
430 static hphp_string_imap<std::string> PhpFileExtensions;
431 static std::set<std::string> ForbiddenFileExtensions;
432 static std::set<std::string> StaticFileGenerators;
433 static std::vector<std::shared_ptr<FilesMatch>> FilesMatches;
435 static bool WhitelistExec;
436 static bool WhitelistExecWarningOnly;
437 static std::vector<std::string> AllowedExecCmds;
439 static bool UnserializationWhitelistCheck;
440 static bool UnserializationWhitelistCheckWarningOnly;
441 static int64_t UnserializationBigMapThreshold;
443 static std::string TakeoverFilename;
444 static std::string AdminServerIP;
445 static int AdminServerPort;
446 static int AdminThreadCount;
447 static std::string AdminPassword;
448 static std::set<std::string> AdminPasswords;
449 static std::set<std::string> HashedAdminPasswords;
452 * Options related to reverse proxying. ProxyOriginRaw and ProxyPercentageRaw
453 * may be mutated by background threads and should only be read or written
454 * using the helper functions defined with HttpRequestHandler.
456 static std::string ProxyOriginRaw;
457 static int ProxyPercentageRaw;
458 static int ProxyRetry;
459 static bool UseServeURLs;
460 static std::set<std::string> ServeURLs;
461 static bool UseProxyURLs;
462 static std::set<std::string> ProxyURLs;
463 static std::vector<std::string> ProxyPatterns;
464 static bool AlwaysUseRelativePath;
466 static int HttpDefaultTimeout;
467 static int HttpSlowQueryThreshold;
469 static bool NativeStackTrace;
470 static bool ServerErrorMessage;
471 static bool RecordInput;
472 static bool ClearInputOnSuccess;
473 static std::string ProfilerOutputDir;
474 static std::string CoreDumpEmail;
475 static bool CoreDumpReport;
476 static std::string CoreDumpReportDirectory;
477 static std::string StackTraceFilename;
478 static int StackTraceTimeout;
479 static std::string RemoteTraceOutputDir;
480 static std::set<std::string, stdltistr> TraceFunctions;
481 static uint32_t TraceFuncId;
483 static bool EnableStats;
484 static bool EnableAPCStats;
485 static bool EnableWebStats;
486 static bool EnableMemoryStats;
487 static bool EnableSQLStats;
488 static bool EnableSQLTableStats;
489 static bool EnableNetworkIOStatus;
490 static std::string StatsXSL;
491 static std::string StatsXSLProxy;
492 static uint32_t StatsSlotDuration;
493 static uint32_t StatsMaxSlot;
495 static bool EnableHotProfiler;
496 static int32_t ProfilerTraceBuffer;
497 static double ProfilerTraceExpansion;
498 static int32_t ProfilerMaxTraceBuffer;
500 static int64_t MaxSQLRowCount;
501 static int64_t SocketDefaultTimeout;
502 static bool LockCodeMemory;
503 static int MaxArrayChain;
504 static bool WarnOnCollectionToArray;
505 static bool UseDirectCopy;
507 static bool DisableSmallAllocator;
509 static std::map<std::string, std::string> ServerVariables;
511 static std::map<std::string, std::string> EnvVariables;
513 // The file name that is used by LightProcess to bind the socket
514 // is the following prefix followed by the pid of the hphp process.
515 static std::string LightProcessFilePrefix;
516 static int LightProcessCount;
518 // Eval options
519 static bool EnableHipHopSyntax;
520 static bool EnableShortTags;
521 static bool EnableXHP;
522 static bool EnableIntrinsicsExtension;
523 static bool CheckSymLink;
524 static bool TrustAutoloaderPath;
525 static bool EnableArgsInBacktraces;
526 static bool EnableZendIniCompat;
527 static bool TimeoutsUseWallTime;
528 static bool CheckFlushOnUserClose;
529 static bool EvalAuthoritativeMode;
530 static HackStrictOption StrictArrayFillKeys;
531 static bool LookForTypechecker;
532 static bool AutoTypecheck;
533 static uint32_t EvalInitialStaticStringTableSize;
534 static uint32_t EvalInitialNamedEntityTableSize;
535 static JitSerdesMode EvalJitSerdesMode;
536 static int ProfDataTTLHours;
537 static std::string EvalJitSerdesFile;
538 static std::string ProfDataTag;
539 static bool DumpPreciseProfData;
540 static bool EnablePocketUniverses;
542 // ENABLED (1) selects PHP7 behavior.
543 static bool PHP7_IntSemantics;
544 static bool PHP7_NoHexNumerics;
545 static bool PHP7_Builtins;
546 static bool PHP7_EngineExceptions;
547 static bool PHP7_Substr;
548 static bool PHP7_DisallowUnsafeCurlUploads;
550 static int64_t HeapSizeMB;
551 static int64_t HeapResetCountBase;
552 static int64_t HeapResetCountMultiple;
553 static int64_t HeapLowWaterMark;
554 static int64_t HeapHighWaterMark;
556 // Disables PHP's call_user_func function.
557 // Valid values are 0 => enabled (default),
558 // 1 => warning, 2 => error.
559 static uint64_t DisableCallUserFunc;
560 // Disables PHP's call_user_func_array function.
561 // Valid values are 0 => enabled (default),
562 // 1 => warning, 2 => error.
563 static uint64_t DisableCallUserFuncArray;
564 // Disables PHP's parse_str function with one argument
565 // valid values are 0 => enabled (default)
566 // 1 => warning, 2 => error
567 static uint64_t DisableParseStrSingleArg;
568 // Disables PHP's backtick language
569 // true => error, false => default behaviour
570 static bool DisallowExecutionOperator;
571 // Disables PHP's constant function
572 // valid values are 0 => enabled (default)
573 // 1 => warning, 2 => error
574 static uint64_t DisableConstant;
575 // Disables PHP's assert() function
576 // valid values are 0 => enabled (default)
577 // 1 => warning, 2 => error
578 static uint64_t DisableAssert;
579 // Disables non-top-level declarations
580 // true => error, false => default behaviour
581 static bool DisableNontoplevelDeclarations;
582 // Disables static closures
583 // true => error, false => default behaviour
584 static bool DisableStaticClosures;
585 // Enables the class-level where constraints
586 // true => allow the feature, false => disable the feature
587 static bool EnableClassLevelWhereClauses;
589 // Disables the setting of reserved variable php_errorsmg
590 // true => error, false => php_errormsg can be set
591 static bool DisableReservedVariables;
592 static int GetScannerType();
594 static std::set<std::string, stdltistr> DynamicInvokeFunctions;
595 static hphp_string_imap<Cell> ConstantFunctions;
597 static const uint32_t kPCREInitialTableSize = 96 * 1024;
599 static std::string ExtensionDir;
600 static std::vector<std::string> Extensions;
601 static std::string DynamicExtensionPath;
602 static std::vector<std::string> DynamicExtensions;
604 static std::vector<std::string> TzdataSearchPaths;
606 #define HAC_CHECK_OPTS \
607 HC(RefBind, ref_bind) \
608 HC(FalseyPromote, falsey_promote) \
609 HC(EmptyStringPromote, empty_string_promote) \
610 HC(Compare, compare) \
611 HC(ArrayKeyCast, array_key_cast) \
612 HC(ArrayPlus, array_plus)
614 #define EVALFLAGS() \
615 /* F(type, name, defaultVal) */ \
616 /* \
617 * Maximum number of elements on the VM execution stack. \
618 */ \
619 F(uint64_t, VMStackElms, kEvalVMStackElmsDefault) \
620 /* \
621 * Initial space reserved for the global variable environment (in \
622 * number of global variables). \
623 */ \
624 F(uint32_t, VMInitialGlobalTableSize, \
625 kEvalVMInitialGlobalTableSizeDefault) \
626 F(bool, Jit, evalJitDefault()) \
627 F(bool, JitEvaledCode, true) \
628 F(bool, JitRequireWriteLease, false) \
629 F(uint64_t, JitRelocationSize, kJitRelocationSizeDefault) \
630 F(uint64_t, JitMatureSize, 125 << 20) \
631 F(bool, JitMatureAfterWarmup, true) \
632 F(double, JitMaturityExponent, 1.) \
633 F(bool, JitTimer, kJitTimerDefault) \
634 F(int, JitConcurrently, 1) \
635 F(int, JitThreads, 4) \
636 F(int, JitWorkerThreads, std::max(1, Process::GetCPUCount() / 2)) \
637 F(int, JitWorkerThreadsForSerdes, 0) \
638 F(int, JitWorkerArenas, std::max(1, Process::GetCPUCount() / 4)) \
639 F(bool, JitParallelDeserialize, true) \
640 F(int, JitLdimmqSpan, 8) \
641 F(int, JitPrintOptimizedIR, 0) \
642 F(bool, RecordSubprocessTimes, false) \
643 F(bool, AllowHhas, false) \
644 F(bool, DisassemblerSourceMapping, true) \
645 F(bool, GenerateDocComments, true) \
646 F(bool, DisassemblerDocComments, true) \
647 F(bool, DisassemblerPropDocComments, true) \
648 F(bool, LoadFilepathFromUnitCache, false) \
649 F(bool, WarnOnCoerceBuiltinParams, false) \
650 F(bool, FatalOnParserOptionMismatch, true) \
651 F(bool, WarnOnSkipFrameLookup, true) \
652 /* \
653 * -1 - No checks on code coverage \
654 * 0 - Code coverage cannot be enabled through request param \
655 * 1 - Code coverage can be enabled through request param \
656 * 2 - Code coverage enabled \
657 */ \
658 F(int32_t, EnableCodeCoverage, -1) \
659 /* Whether to use the embedded hackc binary */ \
660 F(bool, HackCompilerUseEmbedded, facebook) \
661 /* Whether to trust existing versions of the extracted compiler */ \
662 F(bool, HackCompilerTrustExtract, true) \
663 /* When using an embedded hackc, extract it to the ExtractPath or the
664 ExtractFallback. */ \
665 F(string, HackCompilerExtractPath, "/var/run/hackc_%{schema}") \
666 F(string, HackCompilerFallbackPath, "/tmp/hackc_%{schema}_XXXXXX") \
667 /* Arguments to run embedded hackc binary with */ \
668 F(string, HackCompilerArgs, hackCompilerArgsDefault()) \
669 /* The command to invoke to spawn hh_single_compile in server mode. */\
670 F(string, HackCompilerCommand, hackCompilerCommandDefault()) \
671 /* The number of hh_single_compile daemons to keep alive. */ \
672 F(uint64_t, HackCompilerWorkers, Process::GetCPUCount()) \
673 /* The number of times to retry after an infra failure communicating
674 with a compiler process. */ \
675 F(uint64_t, HackCompilerMaxRetries, 0) \
676 /* Whether to log extern compiler performance */ \
677 F(bool, LogExternCompilerPerf, false) \
678 /* Whether to write verbose log messages to the error log and include
679 the hhas from failing units in the fatal error messages produced by
680 bad hh_single_compile units. */ \
681 F(bool, HackCompilerVerboseErrors, true) \
682 /* Whether the HackC compiler should inherit the compiler config of the
683 HHVM process that launches it. */ \
684 F(bool, HackCompilerInheritConfig, true) \
685 /* When using embedded data, extract it to the ExtractPath or the
686 * ExtractFallback. */ \
687 F(string, EmbeddedDataExtractPath, "/var/run/hhvm_%{type}_%{buildid}") \
688 F(string, EmbeddedDataFallbackPath, "/tmp/hhvm_%{type}_%{buildid}_XXXXXX") \
689 /* Whether to trust existing versions of extracted embedded data. */ \
690 F(bool, EmbeddedDataTrustExtract, true) \
691 F(bool, EmitSwitch, true) \
692 F(bool, LogThreadCreateBacktraces, false) \
693 F(bool, FailJitPrologs, false) \
694 F(bool, EnableHHJS, false) \
695 F(bool, DumpHHJS, false) \
696 F(bool, UseHHBBC, !getenv("HHVM_DISABLE_HHBBC")) \
697 F(bool, EnablePerRepoOptions, true) \
698 F(bool, CachePerRepoOptionsPath, true) \
699 /* Generate warning of side effect of the pseudomain is called by \
700 top-level code.*/ \
701 F(bool, WarnOnRealPseudomain, false) \
702 /* Generate warnings of side effect on top-level code that is not \
703 * called by pseudomain directly (include from other file) \
704 * 0 - Nothing \
705 * 1 - Raise Warning \
706 * 2 - Throw exception \
707 */ \
708 F(int32_t, WarnOnUncalledPseudomain, 0) \
709 /* The following option enables the runtime checks for `this` typehints.
710 * There are 4 possible options:
711 * 0 - No checking of `this` typehints.
712 * 1 - Check `this` as hard `self` typehints.
713 * 2 - Check `this` typehints as soft `this` typehints
714 * 3 - Check `this` typehints as hard `this` typehints (unless explicitly
715 * soft). This is the only option which enable optimization in HHBBC.
716 */ \
717 F(int32_t, ThisTypeHintLevel, 3) \
718 /* CheckReturnTypeHints:
719 0 - No checks or enforcement for return type hints.
720 1 - Raises E_WARNING if a return type hint fails.
721 2 - Raises E_RECOVERABLE_ERROR if regular return type hint fails,
722 raises E_WARNING if soft return type hint fails. If a regular
723 return type hint fails, it's possible for execution to resume
724 normally if the user error handler doesn't throw and returns
725 something other than boolean false.
726 3 - Same as 2, except if a regular type hint fails the runtime
727 will not allow execution to resume normally; if the user
728 error handler returns something other than boolean false,
729 the runtime will throw a fatal error. */ \
730 F(int32_t, CheckReturnTypeHints, 2) \
732 CheckPropTypeHints:
733 0 - No checks or enforcement of property type hints.
734 1 - Raises E_WARNING if a property type hint fails.
735 2 - Raises E_RECOVERABLE_ERROR if regular property type hint fails, raises
736 E_WARNING if soft property type hint fails. If a regular property type
737 hint fails, it's possible for execution to resume normally if the user
738 error handler doesn't throw and returns something other than boolean
739 false.
740 3 - Same as 2, except if a regular property type hint fails the runtime will
741 not allow execution to resume normally; if the user error handler
742 returns something other than boolean false, the runtime will throw a
743 fatal error.
744 */ \
745 F(int32_t, CheckPropTypeHints, 0) \
746 /* WarnOnTooManyArguments:
747 * 0 -> no warning, 1 -> warning, 2 -> exception
748 */ \
749 F(uint32_t, WarnOnTooManyArguments, 0) \
750 /* GetClassBadArgument:
751 * 0 -> no warning, 1 -> warning, 2 -> exception
752 */ \
753 F(uint32_t, GetClassBadArgument, 0) \
754 /* WarnOnIncDecInvalidType:
755 * 0 - No restrictions on types that can be incremented or decremented
756 * 1 - Warn when incrementing or decrementing non numeric types
757 * 2 - Throw when incrementing or decrementing non numeric types
758 */ \
759 F(uint32_t, WarnOnIncDecInvalidType, 0) \
760 F(bool, PromoteEmptyObject, false) \
761 F(bool, LibXMLUseSafeSubtrees, true) \
762 F(bool, AllowScopeBinding, false) \
763 F(bool, JitNoGdb, true) \
764 F(bool, SpinOnCrash, false) \
765 F(uint32_t, DumpRingBufferOnCrash, 0) \
766 F(bool, PerfPidMap, true) \
767 F(bool, PerfPidMapIncludeFilePath, true) \
768 F(bool, PerfJitDump, false) \
769 F(string, PerfJitDumpDir, "/tmp") \
770 F(bool, PerfDataMap, false) \
771 F(bool, KeepPerfPidMap, false) \
772 F(int, PerfRelocate, 0) \
773 F(uint32_t, ThreadTCMainBufferSize, 6 << 20) \
774 F(uint32_t, ThreadTCColdBufferSize, 6 << 20) \
775 F(uint32_t, ThreadTCFrozenBufferSize,4 << 20) \
776 F(uint32_t, ThreadTCDataBufferSize, 256 << 10) \
777 F(uint32_t, JitTargetCacheSize, 64 << 20) \
778 F(uint32_t, HHBCArenaChunkSize, 10 << 20) \
779 F(bool, ProfileBC, false) \
780 F(bool, ProfileHeapAcrossRequests, false) \
781 F(bool, ProfileHWEnable, true) \
782 F(string, ProfileHWEvents, std::string("")) \
783 F(bool, ProfileHWExcludeKernel, false) \
784 F(bool, ProfileHWFastReads, false) \
785 F(bool, ProfileHWStructLog, false) \
786 F(int32_t, ProfileHWExportInterval, 30) \
787 F(string, ReorderProps, reorderPropsDefault()) \
788 F(bool, JitAlwaysInterpOne, false) \
789 F(int32_t, JitNopInterval, 0) \
790 F(uint32_t, JitMaxTranslations, 10) \
791 F(uint32_t, JitMaxProfileTranslations, 30) \
792 F(uint32_t, JitTraceletGuardsLimit, 5) \
793 F(uint64_t, JitGlobalTranslationLimit, -1) \
794 F(int64_t, JitMaxRequestTranslationTime, -1) \
795 F(uint32_t, JitMaxRegionInstrs, 1347) \
796 F(uint32_t, JitMaxAwaitAllUnroll, 8) \
797 F(bool, JitProfileWarmupRequests, false) \
798 F(uint32_t, JitProfileRequests, profileRequestsDefault()) \
799 F(uint32_t, JitProfileBCSize, profileBCSizeDefault()) \
800 F(uint32_t, JitResetProfCountersRequest, resetProfCountersDefault()) \
801 F(uint32_t, JitRetranslateAllRequest, retranslateAllRequestDefault()) \
802 F(uint32_t, JitRetranslateAllSeconds, retranslateAllSecondsDefault()) \
803 F(bool, JitPGOLayoutSplitHotCold, pgoLayoutSplitHotColdDefault()) \
804 F(bool, JitLayoutPrologueSplitHotCold, layoutPrologueSplitHotColdDefault()) \
805 F(bool, JitLayoutProfileSplitHotCold, true) \
806 F(double, JitLayoutHotThreshold, 0.05) \
807 F(int32_t, JitLayoutMainFactor, 1000) \
808 F(int32_t, JitLayoutColdFactor, 5) \
809 F(bool, JitAHotSizeRoundUp, true) \
810 F(uint32_t, GdbSyncChunks, 128) \
811 F(bool, JitKeepDbgFiles, false) \
812 /* despite the unfortunate name, this enables function renaming and
813 * interception in the interpreter as well as the jit, and also
814 * implies all functions may be used with fb_intercept */ \
815 F(bool, JitEnableRenameFunction, EvalJitEnableRenameFunction) \
816 F(bool, JitUseVtuneAPI, false) \
817 F(bool, TraceCommandLineRequest, true) \
819 F(bool, JitDisabledByHphpd, false) \
820 F(bool, JitPseudomain, true) \
821 F(bool, JitPGOPseudomain, false) \
822 F(uint32_t, JitWarmupStatusBytes, ((25 << 10) + 1)) \
823 F(uint32_t, JitWarmupMaxCodeGenRate, 20000) \
824 F(uint32_t, JitWarmupRateSeconds, 64) \
825 F(uint32_t, JitWriteLeaseExpiration, 1500) /* in microseconds */ \
826 F(int, JitRetargetJumps, 1) \
827 /* Sync VM reg state for all native calls. */ \
828 F(bool, JitForceVMRegSync, false) \
829 F(bool, HHIRLICM, false) \
830 F(bool, HHIRSimplification, true) \
831 F(bool, HHIRGenOpts, true) \
832 F(bool, HHIRRefcountOpts, true) \
833 F(bool, HHIREnableGenTimeInlining, true) \
834 F(uint32_t, HHIRInliningCostFactorMain, 100) \
835 F(uint32_t, HHIRInliningCostFactorCold, 32) \
836 F(uint32_t, HHIRInliningCostFactorFrozen, 10) \
837 F(uint32_t, HHIRInliningVasmCostLimit, 10500) \
838 F(uint32_t, HHIRInliningMinVasmCostLimit, 10000) \
839 F(uint32_t, HHIRInliningMaxVasmCostLimit, 40000) \
840 F(uint32_t, HHIRAlwaysInlineVasmCostLimit, 4800) \
841 F(uint32_t, HHIRInliningMaxDepth, 1000) \
842 F(double, HHIRInliningVasmCallerExp, .5) \
843 F(double, HHIRInliningVasmCalleeExp, .5) \
844 F(double, HHIRInliningDepthExp, 0) \
845 F(uint32_t, HHIRInliningMaxReturnDecRefs, 24) \
846 F(uint32_t, HHIRInliningMaxReturnLocals, 40) \
847 F(uint32_t, HHIRInliningMaxInitObjProps, 12) \
848 F(bool, HHIRInliningIgnoreHints, !debug) \
849 F(bool, HHIRInliningUseStackedCost, true) \
850 F(bool, HHIRInliningUseReachableCost, true) \
851 F(bool, HHIRInliningUseLayoutBlocks, false) \
852 F(bool, HHIRInlineFrameOpts, true) \
853 F(bool, HHIRPartialInlineFrameOpts, true) \
854 F(bool, HHIRGenerateAsserts, false) \
855 F(bool, HHIRDeadCodeElim, true) \
856 F(bool, HHIRGlobalValueNumbering, true) \
857 F(bool, HHIRPredictionOpts, true) \
858 F(bool, HHIRMemoryOpts, true) \
859 F(bool, AssemblerFoldDefaultValues, true) \
860 F(uint64_t, AssemblerMaxScalarSize, 1073741824) /* 1GB */ \
861 F(uint32_t, HHIRLoadElimMaxIters, 10) \
862 F(bool, HHIRStorePRE, true) \
863 F(bool, HHIROutlineGenericIncDecRef, true) \
864 F(double, HHIRMixedArrayProfileThreshold, 0.8554) \
865 F(double, HHIRSmallArrayProfileThreshold, 0.8) \
866 /* Register allocation flags */ \
867 F(bool, HHIREnablePreColoring, true) \
868 F(bool, HHIREnableCoalescing, true) \
869 F(bool, HHIRAllocSIMDRegs, true) \
870 F(bool, HHIRStressSpill, false) \
871 /* Region compiler flags */ \
872 F(string, JitRegionSelector, regionSelectorDefault()) \
873 F(bool, JitPGO, pgoDefault()) \
874 F(string, JitPGORegionSelector, "hotcfg") \
875 F(uint64_t, JitPGOThreshold, pgoThresholdDefault()) \
876 F(bool, JitPGOOnly, false) \
877 F(bool, JitPGOUsePostConditions, true) \
878 F(bool, JitPGOUseAddrCountedCheck, false) \
879 F(uint32_t, JitPGOUnlikelyIncRefCountedPercent, 2) \
880 F(uint32_t, JitPGOUnlikelyIncRefIncrementPercent, 5) \
881 F(uint32_t, JitPGOUnlikelyDecRefReleasePercent, 5) \
882 F(uint32_t, JitPGOUnlikelyDecRefCountedPercent, 2) \
883 F(uint32_t, JitPGOUnlikelyDecRefPersistPercent, 5) \
884 F(uint32_t, JitPGOUnlikelyDecRefSurvivePercent, 5) \
885 F(uint32_t, JitPGOUnlikelyDecRefDecrementPercent, 5) \
886 F(double, JitPGODecRefNZReleasePercentCOW, \
887 ServerExecutionMode() ? 0.5 : 0) \
888 F(double, JitPGODecRefNZReleasePercent, \
889 ServerExecutionMode() ? 5 : 0) \
890 F(double, JitPGODecRefNopDecPercentCOW, \
891 ServerExecutionMode() ? 0.5 : 0) \
892 F(double, JitPGODecRefNopDecPercent, ServerExecutionMode() ? 5 : 0) \
893 F(uint32_t, JitPGOReleaseVVMinPercent, 8) \
894 F(bool, JitPGOArrayGetStress, false) \
895 F(double, JitPGOMinBlockCountPercent, 0.05) \
896 F(double, JitPGOMinArcProbability, 0.0) \
897 F(uint32_t, JitPGOMaxFuncSizeDupBody, 80) \
898 F(uint32_t, JitPGORelaxPercent, 100) \
899 F(uint32_t, JitPGORelaxUncountedToGenPercent, 20) \
900 F(uint32_t, JitPGORelaxCountedToGenPercent, 75) \
901 F(uint32_t, JitPGOBindCallThreshold, 50) \
902 F(double, JitPGOCalledFuncCheckThreshold, 50) \
903 F(double, JitPGOCalledFuncExitThreshold, 99.9) \
904 F(bool, JitPGODumpCallGraph, false) \
905 F(bool, JitPGORacyProfiling, false) \
906 F(uint32_t, JitLiveThreshold, ServerExecutionMode() ? 1000 : 0) \
907 F(uint32_t, JitProfileThreshold, ServerExecutionMode() ? 200 : 0) \
908 F(uint32_t, JitSrcKeyThreshold, 0) \
909 F(uint64_t, FuncCountHint, 10000) \
910 F(uint64_t, PGOFuncCountHint, 1000) \
911 F(bool, RegionRelaxGuards, true) \
912 /* DumpBytecode =1 dumps user php, =2 dumps systemlib & user php */ \
913 F(int32_t, DumpBytecode, 0) \
914 /* DumpHhas =1 dumps user php, =2 dumps systemlib & user php */ \
915 F(int32_t, DumpHhas, 0) \
916 F(string, DumpHhasToFile, "") \
917 F(bool, DumpTC, false) \
918 F(string, DumpTCPath, "/tmp") \
919 F(bool, DumpTCAnchors, false) \
920 F(uint32_t, DumpIR, 0) \
921 F(uint32_t, DumpIRJson, 0) \
922 F(bool, DumpTCAnnotationsForAllTrans,debug) \
923 /* DumpInlDecision 0=none ; 1=refuses ; 2=refuses+accepts */ \
924 F(uint32_t, DumpInlDecision, 0) \
925 F(uint32_t, DumpRegion, 0) \
926 F(bool, DumpCallTargets, false) \
927 F(bool, DumpAst, false) \
928 F(bool, DumpTargetProfiles, false) \
929 F(bool, MapTgtCacheHuge, false) \
930 F(uint32_t, MaxHotTextHugePages, hotTextHugePagesDefault()) \
931 F(uint32_t, MaxLowMemHugePages, hugePagesSoundNice() ? 8 : 0) \
932 F(uint32_t, MaxHighArenaHugePages, 0) \
933 F(uint32_t, Num1GPagesForSlabs, 0) \
934 F(uint32_t, Num2MPagesForSlabs, 0) \
935 F(uint32_t, Num1GPagesForReqHeap, 0) \
936 F(uint32_t, Num2MPagesForReqHeap, 0) \
937 F(uint32_t, NumReservedSlabs, 0) \
938 F(uint32_t, Num1GPagesForA0, 0) \
939 F(uint32_t, Num2MPagesForA0, 0) \
940 F(bool, BigAllocUseLocalArena, true) \
941 F(bool, JsonParserUseLocalArena, true) \
942 F(bool, XmlParserUseLocalArena, true) \
943 F(bool, LowStaticArrays, true) \
944 F(int64_t, HeapPurgeWindowSize, 5 * 1000000) \
945 F(uint64_t, HeapPurgeThreshold, 128 * 1024 * 1024) \
946 /* GC Options: See heap-collect.cpp for more details */ \
947 F(bool, EagerGC, eagerGcDefault()) \
948 F(bool, FilterGCPoints, true) \
949 F(bool, Quarantine, eagerGcDefault()) \
950 F(uint32_t, GCSampleRate, 0) \
951 F(int64_t, GCMinTrigger, 64L<<20) \
952 F(double, GCTriggerPct, 0.5) \
953 F(bool, GCForAPC, false) \
954 F(int64_t, GCForAPCTrigger, 1024*1024*1024) \
955 F(bool, TwoPhaseGC, false) \
956 F(bool, EnableGC, enableGcDefault()) \
957 /* End of GC Options */ \
958 F(bool, Verify, (getenv("HHVM_VERIFY") || \
959 !EvalHackCompilerCommand.empty())) \
960 F(bool, VerifyOnly, false) \
961 F(bool, FatalOnVerifyError, !RepoAuthoritative) \
962 F(bool, AbortBuildOnVerifyError, true) \
963 F(uint32_t, StaticContentsLogRate, 100) \
964 F(uint32_t, LogUnitLoadRate, 0) \
965 F(uint32_t, MaxDeferredErrors, 50) \
966 F(bool, JitAlignMacroFusionPairs, alignMacroFusionPairs()) \
967 F(bool, JitAlignUniqueStubs, true) \
968 F(uint32_t, SerDesSampleRate, 0) \
969 F(bool, JitSerdesModeForceOff, false) \
970 F(std::set<std::string>, JitSerdesDebugFunctions, {}) \
971 F(int, SimpleJsonMaxLength, 2 << 20) \
972 F(uint32_t, JitSampleRate, 0) \
973 F(uint32_t, TraceServerRequestRate, 0) \
974 /* Log the sizes and metadata for all translations in the TC broken
975 * down by function and inclusive/exclusive size for inlined regions.
976 * When set to "" TC size data will be sampled on a per function basis
977 * as determined by JitSampleRate. When set to a non-empty string all
978 * translations will be logged, and run_key column will be logged with
979 * the value of this option. */ \
980 F(string, JitLogAllInlineRegions, "") \
981 F(bool, JitProfileGuardTypes, false) \
982 F(uint32_t, JitFilterLease, 1) \
983 F(bool, DisableSomeRepoAuthNotices, true) \
984 F(uint32_t, PCRETableSize, kPCREInitialTableSize) \
985 F(uint64_t, PCREExpireInterval, 2 * 60 * 60) \
986 F(string, PCRECacheType, std::string("static")) \
987 F(bool, EnableCompactBacktrace, true) \
988 F(bool, EnableNuma, (numa_num_nodes > 1) && ServerExecutionMode()) \
989 /* Use 1G pages for jemalloc metadata. */ \
990 F(bool, EnableArenaMetadata1GPage, false) \
991 /* Use 1G pages for jemalloc metadata (NUMA arenas if applicable). */ \
992 F(bool, EnableNumaArenaMetadata1GPage, false) \
993 /* Reserved space on 1G pages for jemalloc metadata (arena0). */ \
994 F(uint64_t, ArenaMetadataReservedSize, 216 << 20) \
995 F(bool, EnableCallBuiltin, true) \
996 F(bool, EnableReusableTC, reuseTCDefault()) \
997 F(bool, LogServerRestartStats, false) \
998 F(uint32_t, ReusableTCPadding, 128) \
999 F(int64_t, StressUnitCacheFreq, 0) \
1000 F(int64_t, PerfWarningSampleRate, 1) \
1001 F(int64_t, FunctionCallSampleRate, 0) \
1002 F(double, InitialLoadFactor, 1.0) \
1003 /* Raise notices on various array operations which may present \
1004 * compatibility issues with Hack arrays. \
1006 * The various *Notices options independently control separate \
1007 * subsets of notices. The Check* options are subordinate to the \
1008 * HackArrCompatNotices option, and control whether various runtime
1009 * checks are made; they do not affect any optimizations. */ \
1010 F(bool, HackArrCompatNotices, false) \
1011 F(bool, HackArrCompatCheckRefBind, false) \
1012 F(bool, HackArrCompatCheckFalseyPromote, false) \
1013 F(bool, HackArrCompatCheckEmptyStringPromote, false) \
1014 F(bool, HackArrCompatCheckCompare, false) \
1015 F(bool, HackArrCompatCheckArrayPlus, false) \
1016 F(bool, HackArrCompatCheckArrayKeyCast, false) \
1017 F(bool, HackArrCompatCheckNullHackArrayKey, false) \
1018 /* Raise notices when is_array is called with any hack array */ \
1019 F(bool, HackArrCompatIsArrayNotices, false) \
1020 /* Raise notices when is_vec or is_dict is called with a v/darray */ \
1021 F(bool, HackArrCompatIsVecDictNotices, false) \
1022 /* Raise a notice when a varray is promoted to a darray through: \
1023 * - inserting at a key that would force the array to be mixed \
1024 * - unsetting _any_ key \
1025 */ \
1026 F(bool, HackArrCompatCheckVarrayPromote, false) \
1027 /* Raise a notice when a varray is implicitly appended to by \
1028 * inserting at n == count(arr) \
1029 */ \
1030 F(bool, HackArrCompatCheckImplicitVarrayAppend, false) \
1031 F(bool, HackArrCompatTypeHintNotices, false) \
1032 F(bool, HackArrCompatTypeHintPolymorphism, false) \
1033 F(bool, HackArrCompatDVCmpNotices, false) \
1034 F(bool, HackArrCompatSerializeNotices, false) \
1035 /* Raise notices when fb_compact_*() would change behavior */ \
1036 F(bool, HackArrCompatCompactSerializeNotices, false) \
1037 /* Raises notice when a function that returns a PHP array, not */ \
1038 /* a v/darray, is called */ \
1039 F(bool, HackArrCompatArrayProducingFuncNotices, false) \
1040 F(bool, HackArrDVArrs, false) \
1041 /* Enable instrumentation and information in the repo for tracking \
1042 * the source of vecs and dicts whose vec/dict-ness is observed \
1043 * during program execution \
1045 * Latches to false at startup if either the repo we're loading in \
1046 * RepoAuthoritativeMode wasn't built with this flag or if the \
1047 * flag LogArrayProvenance is unset */ \
1048 F(bool, ArrayProvenance, false) \
1049 /* Enable experimental array provenance opportunistic creation of \
1050 * tagged empty arrays */ \
1051 F(bool, ArrayProvenancePromoteEmptyArrays, true) \
1052 /* Enable logging the source of vecs/dicts whose vec/dict-ness is \
1053 * observed, e.g. through serialization */ \
1054 F(bool, LogArrayProvenance, false) \
1055 /* Log only out out of this many array headers when serializing */ \
1056 F(uint32_t, LogArrayProvenanceSampleRatio, 1000) \
1057 /* Warn if is expression are used with type aliases that cannot be |
1058 * resolved */ \
1059 F(bool, IsExprEnableUnresolvedWarning, false) \
1060 /* Raise a notice if a Func type is passed to is_string */ \
1061 F(bool, IsStringNotices, false) \
1062 /* Raise a notice if a Func type is passed to function that expects a
1063 string */ \
1064 F(bool, StringHintNotices, false) \
1065 /* Raise a notice if a ClsMeth type is passed to is_vec/is_array */ \
1066 F(bool, IsVecNotices, false) \
1067 /* Raise a notice if a ClsMeth type is passed to a function that
1068 * expects a vec/varray */ \
1069 F(bool, VecHintNotices, false) \
1070 /* Switches on miscellaneous junk. */ \
1071 F(bool, NoticeOnCreateDynamicProp, false) \
1072 F(bool, NoticeOnReadDynamicProp, false) \
1073 F(bool, NoticeOnImplicitInvokeToString, false) \
1074 F(bool, FatalOnConvertObjectToString, false) \
1075 /* Indicates whether parameters of overridden methods must match the
1076 reffiness of the parent method. When set to enforcing mode, inout
1077 wrappers will be created for methods.
1078 0 - do nothing
1079 1 - raise a warning on reffiness mismatch
1080 2 - raise a fatal on reffiness mismatch */ \
1081 F(uint32_t, ReffinessInvariance, 0) \
1082 F(bool, NoticeOnBuiltinDynamicCalls, false) \
1083 F(bool, RxPretendIsEnabled, false) \
1084 F(bool, NoArrayAccessInIdx, false) \
1085 F(bool, NoticeOnArrayAccessUse, false) \
1086 /* Raise warning when function pointers are used as strings. */ \
1087 F(bool, RaiseFuncConversionWarning, false) \
1088 /* Raise warning when class pointers are used as strings. */ \
1089 F(bool, RaiseClassConversionWarning, false) \
1090 F(bool, EmitClsMethPointers, false) \
1091 /* false to skip type refinement for ClsMeth type at HHBBC. */ \
1092 F(bool, IsCompatibleClsMethType, false) \
1093 /* Raise warning when ClsMethDataRef is used as varray/vec. */ \
1094 F(bool, RaiseClsMethConversionWarning, false) \
1095 /* Raise warning when strings are used as classes. */ \
1096 F(bool, RaiseStrToClsConversionWarning, false) \
1097 F(bool, EmitMethCallerFuncPointers, false) \
1098 /* trigger E_USER_WARNING error when getClassName()/getMethodName()
1099 * is used on __SystemLib\MethCallerHelper */ \
1100 F(bool, NoticeOnMethCallerHelperUse, false) \
1101 F(bool, NoticeOnCollectionToBool, false) \
1102 F(bool, NoticeOnSimpleXMLBehavior, false) \
1103 F(bool, NoticeOnBadMethodStaticness, true) \
1104 F(bool, ForbidDivisionByZero, true) \
1105 F(bool, NoticeOnByRefArgumentTypehintViolation, false) \
1106 /* Enables Hack records. */ \
1107 F(bool, HackRecords, false) \
1108 F(bool, HackRecordArrays, false) \
1109 /* \
1110 * Control dynamic calls to functions and dynamic constructs of \
1111 * classes which haven't opted into being called that way. \
1113 * 0 - Nothing \
1114 * 1 - Warn \
1115 * 2 - Throw exception \
1117 */ \
1118 F(int32_t, ForbidDynamicCallsToFunc, 0) \
1119 F(int32_t, ForbidDynamicCallsToClsMeth, 0) \
1120 F(int32_t, ForbidDynamicCallsToInstMeth, 0) \
1121 F(int32_t, ForbidDynamicConstructs, 0) \
1122 /* \
1123 * Keep logging dynamic calls according to options above even if \
1124 * __DynamicallyCallable attribute is present at declaration. \
1125 */ \
1126 F(bool, ForbidDynamicCallsWithAttr, false) \
1127 F(bool, WarnOnNonLiteralClsMeth, false) \
1128 /* \
1129 * Control handling of out-of-range integer values in the compact \
1130 * Thrift serializer. \
1132 * 0 - Nothing \
1133 * 1 - Warn \
1134 * 2 - Throw exception \
1135 */ \
1136 F(int32_t, ForbidThriftIntegerValuesOutOfRange, 0) \
1137 /* \
1138 * Don't allow unserializing to __PHP_Incomplete_Class \
1139 * 0 - Nothing \
1140 * 1 - Warn \
1141 * 2 - Throw exception \
1142 */ \
1143 F(int32_t, ForbidUnserializeIncompleteClass, 0) \
1144 F(int32_t, RxEnforceCalls, 0) \
1145 /* \
1146 * 0 - Nothing \
1147 * 1 - Warn \
1148 * 2 - Fail unit verification (i.e. fail to load it) \
1149 */ \
1150 F(int32_t, RxVerifyBody, 0) \
1151 F(bool, RxIsEnabled, EvalRxPretendIsEnabled) \
1152 F(int32_t, ServerOOMAdj, 0) \
1153 F(std::string, PreludePath, "") \
1154 F(uint32_t, NonSharedInstanceMemoCaches, 10) \
1155 F(bool, UseGraphColor, false) \
1156 F(std::vector<std::string>, IniGetHide, std::vector<std::string>()) \
1157 F(std::string, UseRemoteUnixServer, "no") \
1158 F(std::string, UnixServerPath, "") \
1159 F(uint32_t, UnixServerWorkers, Process::GetCPUCount()) \
1160 F(bool, UnixServerQuarantineApc, false) \
1161 F(bool, UnixServerQuarantineUnits, false) \
1162 F(bool, UnixServerVerifyExeAccess, false) \
1163 F(bool, UnixServerFailWhenBusy, false) \
1164 F(std::vector<std::string>, UnixServerAllowedUsers, \
1165 std::vector<std::string>()) \
1166 F(std::vector<std::string>, UnixServerAllowedGroups, \
1167 std::vector<std::string>()) \
1168 /* Options for testing */ \
1169 F(bool, TrashFillOnRequestExit, false) \
1170 /****************** \
1171 | ARM Options. | \
1172 *****************/ \
1173 F(bool, JitArmLse, armLseDefault()) \
1174 /****************** \
1175 | PPC64 Options. | \
1176 *****************/ \
1177 /* Minimum immediate size to use TOC */ \
1178 F(uint16_t, PPC64MinTOCImmSize, 64) \
1179 /* Relocation features. Use with care on production */ \
1180 /* Allow a Far branch be converted to a Near branch. */ \
1181 F(bool, PPC64RelocationShrinkFarBranches, false) \
1182 /* Remove nops from a Far branch. */ \
1183 F(bool, PPC64RelocationRemoveFarBranchesNops, true) \
1184 /******************** \
1185 | Profiling flags. | \
1186 ********************/ \
1187 /* Whether to maintain the address-to-VM-object mapping. */ \
1188 F(bool, EnableReverseDataMap, true) \
1189 /* Turn on perf-mem-event sampling roughly every this many requests. \
1190 * To maintain the same overall sampling rate, the ratio between the \
1191 * request and sample frequencies should be kept constant. */ \
1192 F(uint32_t, PerfMemEventRequestFreq, 0) \
1193 /* Sample this many memory instructions per second. This should be \
1194 * kept low to avoid the risk of collecting a sample while we're \
1195 * processing a previous sample. */ \
1196 F(uint32_t, PerfMemEventSampleFreq, 80) \
1197 /* Sampling frequency for TC branch profiling. */ \
1198 F(uint32_t, ProfBranchSampleFreq, 0) \
1199 /* Sampling frequency for profiling packed array accesses. */ \
1200 F(uint32_t, ProfPackedArraySampleFreq, 0) \
1201 F(bool, UseXedAssembler, false) \
1202 /* Record the first N units loaded via StructuredLog::log() */ \
1203 F(uint64_t, RecordFirstUnits, 0) \
1204 /* More aggresively reuse already compiled units based on SHA1 */ \
1205 F(bool, CheckUnitSHA1, true) \
1206 /* When dynamic_fun is called on a function not marked as
1207 __DynamicallyCallable:
1209 0 - do nothing
1210 1 - raise a warning
1211 2 - throw */ \
1212 F(uint64_t, DynamicFunLevel, 1) \
1213 /* When dynamic_class_meth is called on a method not marked as
1214 __DynamicallyCallable:
1216 0 - do nothing
1217 1 - raise a warning
1218 2 - throw */ \
1219 F(uint64_t, DynamicClsMethLevel, 1) \
1220 F(bool, APCSerializeFuncs, true) \
1221 /* */
1223 private:
1224 using string = std::string;
1226 // Custom settings. This should be accessed via the GetServerCustomSetting
1227 // APIs.
1228 static std::map<std::string, std::string> CustomSettings;
1230 public:
1231 #define F(type, name, unused) \
1232 static type Eval ## name;
1233 EVALFLAGS()
1234 #undef F
1236 static bool RecordCodeCoverage;
1237 static std::string CodeCoverageOutputFile;
1239 // Repo (hhvm bytecode repository) options
1240 static std::string RepoLocalMode;
1241 static std::string RepoLocalPath;
1242 static std::string RepoCentralPath;
1243 static int32_t RepoCentralFileMode;
1244 static std::string RepoCentralFileUser;
1245 static std::string RepoCentralFileGroup;
1246 static bool RepoAllowFallbackPath;
1247 static std::string RepoEvalMode;
1248 static std::string RepoJournal;
1249 static bool RepoCommit;
1250 static bool RepoDebugInfo;
1251 static bool RepoAuthoritative;
1252 static int64_t RepoLocalReadaheadRate;
1253 static bool RepoLocalReadaheadConcurrent;
1254 static uint32_t RepoBusyTimeoutMS;
1256 // pprof/hhprof options
1257 static bool HHProfEnabled;
1258 static bool HHProfActive;
1259 static bool HHProfAccum;
1260 static bool HHProfRequest;
1261 static bool TrackPerUnitMemory;
1263 // Sandbox options
1264 static bool SandboxMode;
1265 static std::string SandboxPattern;
1266 static std::string SandboxHome;
1267 static std::string SandboxFallback;
1268 static std::string SandboxConfFile;
1269 static std::map<std::string, std::string> SandboxServerVariables;
1270 static bool SandboxFromCommonRoot;
1271 static std::string SandboxDirectoriesRoot;
1272 static std::string SandboxLogsRoot;
1274 // Debugger options
1275 static bool EnableHphpdDebugger;
1276 static bool EnableVSDebugger;
1277 static int VSDebuggerListenPort;
1278 static std::string VSDebuggerDomainSocketPath;
1279 static bool VSDebuggerNoWait;
1280 static bool EnableDebuggerColor;
1281 static bool EnableDebuggerPrompt;
1282 static bool EnableDebuggerServer;
1283 static bool EnableDebuggerUsageLog;
1284 static bool DebuggerDisableIPv6;
1285 static std::string DebuggerServerIP;
1286 static int DebuggerServerPort;
1287 static int DebuggerDefaultRpcPort;
1288 static std::string DebuggerDefaultRpcAuth;
1289 static std::string DebuggerRpcHostDomain;
1290 static int DebuggerDefaultRpcTimeout;
1291 static std::string DebuggerDefaultSandboxPath;
1292 static std::string DebuggerStartupDocument;
1293 static int DebuggerSignalTimeout;
1294 static std::string DebuggerAuthTokenScriptBin;
1295 static std::string DebuggerSessionAuthScriptBin;
1296 static bool ForceDebuggerBpToInterp;
1298 // Mail options
1299 static std::string SendmailPath;
1300 static std::string MailForceExtraParameters;
1302 // preg stack depth and debug support options
1303 static int64_t PregBacktraceLimit;
1304 static int64_t PregRecursionLimit;
1305 static bool EnablePregErrorLog;
1307 // SimpleXML options
1308 static bool SimpleXMLEmptyNamespaceMatchesAll;
1310 // Cookie options
1311 static bool AllowDuplicateCookies;
1313 #ifdef FACEBOOK
1314 // fb303 server
1315 static bool EnableFb303Server;
1316 static int Fb303ServerPort;
1317 static int Fb303ServerThreadStackSizeMb;
1318 static int Fb303ServerWorkerThreads;
1319 static int Fb303ServerPoolThreads;
1320 #endif
1322 // Xenon options
1323 static double XenonPeriodSeconds;
1324 static uint32_t XenonRequestFreq;
1325 static bool XenonForceAlwaysOn;
1327 static bool SetProfileNullThisObject;
1329 static_assert(sizeof(RuntimeOption) == 1, "no instance variables");
1331 inline bool isJitDeserializing() {
1332 auto const m = RuntimeOption::EvalJitSerdesMode;
1333 return static_cast<std::underlying_type<JitSerdesMode>::type>(m) & 0x2;
1336 inline bool isJitSerializing() {
1337 auto const m = RuntimeOption::EvalJitSerdesMode;
1338 return static_cast<std::underlying_type<JitSerdesMode>::type>(m) & 0x1;
1341 ///////////////////////////////////////////////////////////////////////////////
1344 #endif // incl_HPHP_RUNTIME_OPTION_H_