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