Add `recordbasenativesp` instr and support it in vasm-xls
[hiphop-php.git] / hphp / runtime / base / runtime-option.h
blob031e99f4b20876a632ec419dcef64be770161ed1
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, EmitFuncPointers, true) \
90 E(bool, EmitInstMethPointers, EmitFuncPointers) \
91 H(bool, AllowUnstableFeatures, false) \
92 H(bool, EnableXHPClassModifier, true) \
93 H(bool, DisableXHPElementMangling, true) \
94 H(bool, DisableArray, true) \
95 H(bool, DisableArrayCast, true) \
96 H(bool, DisableArrayTypehint, true) \
97 /**/
99 /**/
101 #define AUTOLOADFLAGS() \
102 N(std::string, Query, "") \
103 N(std::string, TrustedDBPath, "") \
104 /**/
106 std::string path() const { return m_path; }
107 std::string cacheKeyRaw() const;
108 std::string cacheKeySha1() const;
109 std::string toJSON() const;
110 folly::dynamic toDynamic() const;
111 struct stat stat() const { return m_stat; }
112 std::string autoloadQuery() const noexcept { return Query; }
113 std::string trustedDBPath() const noexcept { return TrustedDBPath; }
115 bool operator==(const RepoOptions& o) const;
117 static const RepoOptions& defaults();
118 static void setDefaults(const Hdf& hdf, const IniSettingMap& ini);
120 static const RepoOptions& forFile(const char* path);
122 private:
123 RepoOptions() = default;
124 explicit RepoOptions(const char* file);
126 void filterNamespaces();
127 void initDefaults(const Hdf& hdf, const IniSettingMap& ini);
129 #define N(t, n, ...) t n;
130 #define P(t, n, ...) t n;
131 #define H(t, n, ...) t n;
132 #define E(t, n, ...) t n;
133 PARSERFLAGS()
134 AUTOLOADFLAGS()
135 #undef N
136 #undef P
137 #undef H
138 #undef E
140 std::string m_path;
141 struct stat m_stat;
143 static bool s_init;
144 static RepoOptions s_defaults;
148 * Configurable options set from command line or configurable file at startup
149 * time.
151 struct RuntimeOption {
152 static void Load(
153 IniSettingMap &ini, Hdf& config,
154 const std::vector<std::string>& iniClis = std::vector<std::string>(),
155 const std::vector<std::string>& hdfClis = std::vector<std::string>(),
156 std::vector<std::string>* messages = nullptr,
157 std::string cmd = "");
159 static bool ServerExecutionMode() {
160 return ServerMode;
163 static bool GcSamplingEnabled() {
164 return EvalGCSampleRate > 0;
167 static bool JitSamplingEnabled() {
168 return EvalJit && EvalJitSampleRate > 0;
171 static void ReadSatelliteInfo(
172 const IniSettingMap& ini,
173 const Hdf& hdf,
174 std::vector<std::shared_ptr<SatelliteServerInfo>>& infos,
175 std::string& xboxPassword,
176 std::set<std::string>& xboxPasswords
179 static folly::Optional<folly::fs::path> GetHomePath(
180 const folly::StringPiece user);
182 static std::string GetDefaultUser();
185 * Find a config file corresponding to the given user and parse its
186 * settings into the given ini and hdf objects.
188 * Return true on success and false on failure.
190 static bool ReadPerUserSettings(const folly::fs::path& confFileName,
191 IniSettingMap& ini, Hdf& config);
193 static std::string getTraceOutputFile();
195 static bool ServerMode;
196 static std::string BuildId;
197 static std::string InstanceId;
198 static std::string DeploymentId; // ID for set of instances deployed at once
199 static int64_t ConfigId; // Queryable to verify a specific config was read
200 static std::string PidFile;
202 static std::map<std::string, ErrorLogFileData> ErrorLogs;
203 static std::string LogFile;
204 static std::string LogFileSymLink;
205 static uint16_t LogFilePeriodMultiplier;
207 static int LogHeaderMangle;
208 static bool AlwaysEscapeLog;
209 static bool AlwaysLogUnhandledExceptions;
210 static bool NoSilencer;
211 static int ErrorUpgradeLevel; // Bitmask of errors to upgrade to E_USER_ERROR
212 static bool CallUserHandlerOnFatals;
213 static bool ThrowExceptionOnBadMethodCall;
214 static bool LogNativeStackOnOOM;
215 static int RuntimeErrorReportingLevel;
216 static int ForceErrorReportingLevel; // Bitmask ORed with the reporting level
218 static std::string ServerUser; // run server under this user account
219 static bool AllowRunAsRoot; // Allow running hhvm as root.
221 static int MaxSerializedStringSize;
222 static bool NoInfiniteRecursionDetection;
223 static bool AssertEmitted;
224 static int64_t NoticeFrequency; // output 1 out of NoticeFrequency notices
225 static int64_t WarningFrequency;
226 static int RaiseDebuggingFrequency;
227 static int64_t SerializationSizeLimit;
229 static std::string AccessLogDefaultFormat;
230 static std::map<std::string, AccessLogFileData> AccessLogs;
232 static std::string AdminLogFormat;
233 static std::string AdminLogFile;
234 static std::string AdminLogSymLink;
236 static std::map<std::string, AccessLogFileData> RPCLogs;
238 static std::string Host;
239 static std::string DefaultServerNameSuffix;
240 static std::string ServerType;
241 static std::string ServerIP;
242 static std::string ServerFileSocket;
243 static const std::string& GetServerPrimaryIPv4();
244 static const std::string& GetServerPrimaryIPv6();
245 static int ServerPort;
246 static int ServerPortFd;
247 static int ServerBacklog;
248 static int ServerConnectionLimit;
249 static int ServerThreadCount;
250 static int ServerQueueCount;
251 static int ServerIOThreadCount;
252 static int ServerHighQueueingThreshold;
253 static bool ServerLegacyBehavior;
254 // Number of worker threads with stack partially on huge pages.
255 static int ServerHugeThreadCount;
256 static int ServerHugeStackKb;
257 static uint32_t ServerLoopSampleRate;
258 static int ServerWarmupThrottleRequestCount;
259 static int ServerWarmupThrottleThreadCount;
260 static int ServerThreadDropCacheTimeoutSeconds;
261 static int ServerThreadJobLIFOSwitchThreshold;
262 static int ServerThreadJobMaxQueuingMilliSeconds;
263 static bool AlwaysDecodePostDataDefault;
264 static bool ServerThreadDropStack;
265 static bool ServerHttpSafeMode;
266 static bool ServerStatCache;
267 static bool ServerFixPathInfo;
268 static bool ServerAddVaryEncoding;
269 static bool ServerLogSettingsOnStartup;
270 static bool ServerLogReorderProps;
271 static bool ServerForkEnabled;
272 static bool ServerForkLogging;
273 static bool ServerWarmupConcurrently;
274 static bool ServerDedupeWarmupRequests;
275 static int ServerWarmupThreadCount;
276 static int ServerExtendedWarmupThreadCount;
277 static unsigned ServerExtendedWarmupRepeat;
278 static unsigned ServerExtendedWarmupDelaySeconds;
279 static std::vector<std::string> ServerWarmupRequests;
280 static std::vector<std::string> ServerExtendedWarmupRequests;
281 static std::string ServerCleanupRequest;
282 static int ServerInternalWarmupThreads;
283 static boost::container::flat_set<std::string> ServerHighPriorityEndPoints;
284 static bool ServerExitOnBindFail;
285 static int PageletServerThreadCount;
286 static int PageletServerHugeThreadCount;
287 static int PageletServerThreadDropCacheTimeoutSeconds;
288 static int PageletServerQueueLimit;
289 static bool PageletServerThreadDropStack;
291 static int RequestTimeoutSeconds;
292 static int PspTimeoutSeconds;
293 static int PspCpuTimeoutSeconds;
294 static int64_t MaxRequestAgeFactor;
295 static int64_t RequestMemoryMaxBytes;
296 // Approximate upper bound for thread heap that is backed by huge pages. This
297 // doesn't include the first slab colocated with thread stack, if any.
298 static int64_t RequestHugeMaxBytes;
299 static int64_t ImageMemoryMaxBytes;
300 static int ServerGracefulShutdownWait;
301 static bool ServerHarshShutdown;
302 static bool ServerEvilShutdown;
303 static bool ServerKillOnTimeout;
304 static bool Server503OnShutdownAbort;
305 static int ServerPreShutdownWait;
306 static int ServerShutdownListenWait;
307 static int ServerShutdownEOMWait;
308 static int ServerPrepareToStopTimeout;
309 static int ServerPartialPostStatusCode;
310 // If `StopOldServer` is set, we try to stop the old server running
311 // on the local host earlier when we initialize, and we do not start
312 // serving requests until we are confident that the system can give
313 // the new server `ServerRSSNeededMb` resident memory, or till
314 // `OldServerWait` seconds passes after an effort to stop the old
315 // server is made.
316 static bool StopOldServer;
317 static int64_t ServerRSSNeededMb;
318 // Threshold of free memory below which the old server is shutdown immediately
319 // upon a memory pressure check.
320 static int64_t ServerCriticalFreeMb;
321 static int OldServerWait;
322 // The percentage of page caches that can be considered as free (0 -
323 // 100). This is experimental.
324 static int CacheFreeFactor;
325 static std::vector<std::string> ServerNextProtocols;
326 static bool ServerEnableH2C;
327 static int BrotliCompressionEnabled;
328 static int BrotliChunkedCompressionEnabled;
329 static int BrotliCompressionMode;
330 // Base 2 logarithm of the sliding window size. Range is 10-24.
331 static int BrotliCompressionLgWindowSize;
332 static int BrotliCompressionQuality;
333 static int ZstdCompressionEnabled;
334 static int ZstdCompressionLevel;
335 static int ZstdChecksumRate;
336 static int GzipCompressionLevel;
337 static int GzipMaxCompressionLevel;
338 static bool EnableKeepAlive;
339 static bool ExposeHPHP;
340 static bool ExposeXFBServer;
341 static bool ExposeXFBDebug;
342 static std::string XFBDebugSSLKey;
343 static int ConnectionTimeoutSeconds;
344 static bool EnableOutputBuffering;
345 static std::string OutputHandler;
346 static bool ImplicitFlush;
347 static bool EnableEarlyFlush;
348 static bool ForceChunkedEncoding;
349 static int64_t MaxPostSize;
350 static int64_t LowestMaxPostSize;
351 static bool AlwaysPopulateRawPostData;
352 static int64_t UploadMaxFileSize;
353 static std::string UploadTmpDir;
354 static bool EnableFileUploads;
355 static bool EnableUploadProgress;
356 static int64_t MaxFileUploads;
357 static int Rfc1867Freq;
358 static std::string Rfc1867Prefix;
359 static std::string Rfc1867Name;
360 static bool ExpiresActive;
361 static int ExpiresDefault;
362 static std::string DefaultCharsetName;
363 static bool ForceServerNameToHeader;
364 static bool PathDebug;
365 static std::vector<std::shared_ptr<VirtualHost>> VirtualHosts;
366 static std::shared_ptr<IpBlockMap> IpBlocks;
367 static std::vector<std::shared_ptr<SatelliteServerInfo>>
368 SatelliteServerInfos;
370 // If a request has a body over this limit, switch to on-demand reading.
371 // -1 for no limit.
372 static int64_t RequestBodyReadLimit;
374 static bool EnableSSL;
375 static int SSLPort;
376 static int SSLPortFd;
377 static std::string SSLCertificateFile;
378 static std::string SSLCertificateKeyFile;
379 static std::string SSLCertificateDir;
380 static std::string SSLTicketSeedFile;
381 static bool TLSDisableTLS1_2;
382 static std::string TLSClientCipherSpec;
383 static bool EnableSSLWithPlainText;
384 // Level of TLS client auth. Valid values are
385 // 0 => disabled (default)
386 // 1 => optional (verify if client presents a cert)
387 // 2 => required (client must present a valid cert)
388 static int SSLClientAuthLevel;
389 // CA file to verify client cert against.
390 static std::string SSLClientCAFile;
391 // [DEPRECATED] Sampling ratio for client auth logging.
392 // Must be an int within [0, 100]. 0 => disabled; 100 => log all connections.
393 static uint32_t SSLClientAuthLoggingSampleRatio;
395 // Which ACL identity and action to check the client against.
396 static std::string ClientAuthAclIdentity;
397 static std::string ClientAuthAclAction;
398 // If true, terminate connection immediately if a client fails ACL,
399 // otherwise log it and let in.
400 static bool ClientAuthFailClose;
402 // On average, sample X connections per ClientAuthLogSampleBase connections,
403 // where X is ClientAuthSuccessLogSampleRatio for client auth successes, and
404 // ClientAuthFailureLogSampleRatio for client auth failures. Set X to 0 to
405 // disable sampling.
406 // For example, if ClientAuthLogSampleBase = 100,
407 // ClientAuthSuccessLogSampleRatio = 0, and
408 // ClientAuthFailureLogSampleRatio = 50, then no (0/100) client auth successes
409 // and half (50/100) of client auth failures will be logged.
410 static uint32_t ClientAuthLogSampleBase;
411 static uint32_t ClientAuthSuccessLogSampleRatio;
412 static uint32_t ClientAuthFailureLogSampleRatio;
414 static int XboxServerThreadCount;
415 static int XboxServerMaxQueueLength;
416 static int XboxServerPort;
417 static int XboxDefaultLocalTimeoutMilliSeconds;
418 static int XboxDefaultRemoteTimeoutSeconds;
419 static int XboxServerInfoMaxRequest;
420 static int XboxServerInfoDuration;
421 static std::string XboxServerInfoReqInitFunc;
422 static std::string XboxServerInfoReqInitDoc;
423 static bool XboxServerInfoAlwaysReset;
424 static bool XboxServerLogInfo;
425 static std::string XboxProcessMessageFunc;
426 static std::string XboxPassword;
427 static std::set<std::string> XboxPasswords;
429 static std::string SourceRoot;
430 static std::vector<std::string> IncludeSearchPaths;
433 * Legal root directory expressions in an include expression. For example,
435 * include_once $PHP_ROOT . '/lib.php';
437 * Here, "$PHP_ROOT" is a legal include root. Stores what it resolves to.
439 * RuntimeOption::IncludeRoots["$PHP_ROOT"] = "";
440 * RuntimeOption::IncludeRoots["$LIB_ROOT"] = "lib";
442 static std::map<std::string, std::string> IncludeRoots;
443 static std::map<std::string, std::string> AutoloadRoots;
445 static bool AutoloadEnabled;
446 static std::string AutoloadDBPath;
448 static std::string FileCache;
449 static std::string DefaultDocument;
450 static std::string GlobalDocument;
451 static std::string ErrorDocument404;
452 static bool ForbiddenAs404;
453 static std::string ErrorDocument500;
454 static std::string FatalErrorMessage;
455 static std::string FontPath;
456 static bool EnableStaticContentFromDisk;
457 static bool EnableOnDemandUncompress;
458 static bool EnableStaticContentMMap;
460 static bool Utf8izeReplace;
462 static std::string RequestInitFunction;
463 static std::string RequestInitDocument;
464 static std::string AutoPrependFile;
465 static std::string AutoAppendFile;
467 static bool SafeFileAccess;
468 static std::vector<std::string> AllowedDirectories;
469 static std::set<std::string> AllowedFiles;
470 static hphp_string_imap<std::string> StaticFileExtensions;
471 static hphp_string_imap<std::string> PhpFileExtensions;
472 static std::set<std::string> ForbiddenFileExtensions;
473 static std::set<std::string> StaticFileGenerators;
474 static std::vector<std::shared_ptr<FilesMatch>> FilesMatches;
476 static bool WhitelistExec;
477 static bool WhitelistExecWarningOnly;
478 static std::vector<std::string> AllowedExecCmds;
480 static bool UnserializationWhitelistCheck;
481 static bool UnserializationWhitelistCheckWarningOnly;
482 static int64_t UnserializationBigMapThreshold;
484 static std::string TakeoverFilename;
485 static std::string AdminServerIP;
486 static int AdminServerPort;
487 static int AdminThreadCount;
488 static bool AdminServerEnableSSLWithPlainText;
489 static bool AdminServerStatsNeedPassword;
490 static std::string AdminPassword;
491 static std::set<std::string> AdminPasswords;
492 static std::set<std::string> HashedAdminPasswords;
495 * Options related to reverse proxying. ProxyOriginRaw and ProxyPercentageRaw
496 * may be mutated by background threads and should only be read or written
497 * using the helper functions defined with HttpRequestHandler.
499 static std::string ProxyOriginRaw;
500 static int ProxyPercentageRaw;
501 static int ProxyRetry;
502 static bool UseServeURLs;
503 static std::set<std::string> ServeURLs;
504 static bool UseProxyURLs;
505 static std::set<std::string> ProxyURLs;
506 static std::vector<std::string> ProxyPatterns;
507 static bool AlwaysUseRelativePath;
509 static int HttpDefaultTimeout;
510 static int HttpSlowQueryThreshold;
512 static bool NativeStackTrace;
513 static bool ServerErrorMessage;
514 static bool RecordInput;
515 static bool ClearInputOnSuccess;
516 static std::string ProfilerOutputDir;
517 static std::string CoreDumpEmail;
518 static bool CoreDumpReport;
519 static std::string CoreDumpReportDirectory;
520 static std::string StackTraceFilename;
521 static int StackTraceTimeout;
522 static std::string RemoteTraceOutputDir;
523 static std::set<std::string, stdltistr> TraceFunctions;
524 static uint32_t TraceFuncId;
526 static bool EnableStats;
527 static bool EnableAPCStats;
528 static bool EnableWebStats;
529 static bool EnableMemoryStats;
530 static bool EnableSQLStats;
531 static bool EnableSQLTableStats;
532 static bool EnableNetworkIOStatus;
533 static std::string StatsXSL;
534 static std::string StatsXSLProxy;
535 static uint32_t StatsSlotDuration;
536 static uint32_t StatsMaxSlot;
538 static bool EnableHotProfiler;
539 static int32_t ProfilerTraceBuffer;
540 static double ProfilerTraceExpansion;
541 static int32_t ProfilerMaxTraceBuffer;
543 static int64_t MaxSQLRowCount;
544 static int64_t SocketDefaultTimeout;
545 static bool LockCodeMemory;
546 static int MaxArrayChain;
547 static bool WarnOnCollectionToArray;
548 static bool UseDirectCopy;
550 static bool DisableSmallAllocator;
552 static std::map<std::string, std::string> ServerVariables;
554 static std::map<std::string, std::string> EnvVariables;
556 // The file name that is used by LightProcess to bind the socket
557 // is the following prefix followed by the pid of the hphp process.
558 static std::string LightProcessFilePrefix;
559 static int LightProcessCount;
561 // Eval options
562 static bool EnableHipHopSyntax;
563 static bool EnableShortTags;
564 static bool EnableXHP;
565 static bool EnableIntrinsicsExtension;
566 static bool CheckSymLink;
567 static bool TrustAutoloaderPath;
568 static bool EnableArgsInBacktraces;
569 static bool EnableZendIniCompat;
570 static bool TimeoutsUseWallTime;
571 static bool CheckFlushOnUserClose;
572 static bool EvalAuthoritativeMode;
573 static int CheckCLIClientCommands;
574 static int CheckIntOverflow;
575 static HackStrictOption StrictArrayFillKeys;
576 static bool LookForTypechecker;
577 static bool AutoTypecheck;
578 static uint32_t EvalInitialStaticStringTableSize;
579 static uint32_t EvalInitialNamedEntityTableSize;
580 static JitSerdesMode EvalJitSerdesMode;
581 static int ProfDataTTLHours;
582 static std::string EvalJitSerdesFile;
583 static std::string ProfDataTag;
584 static bool DumpPreciseProfData;
585 static bool EnableFirstClassFunctionPointers;
587 // ENABLED (1) selects PHP7 behavior.
588 static bool PHP7_NoHexNumerics;
589 static bool PHP7_Builtins;
590 static bool PHP7_EngineExceptions;
591 static bool PHP7_Substr;
592 static bool PHP7_DisallowUnsafeCurlUploads;
594 static int64_t HeapSizeMB;
595 static int64_t HeapResetCountBase;
596 static int64_t HeapResetCountMultiple;
597 static int64_t HeapLowWaterMark;
598 static int64_t HeapHighWaterMark;
600 // Disables PHP's call_user_func function.
601 // Valid values are 0 => enabled (default),
602 // 1 => warning, 2 => error.
603 static uint64_t DisableCallUserFunc;
604 // Disables PHP's call_user_func_array function.
605 // Valid values are 0 => enabled (default),
606 // 1 => warning, 2 => error.
607 static uint64_t DisableCallUserFuncArray;
608 // Disables PHP's constant function
609 // valid values are 0 => enabled (default)
610 // 1 => warning, 2 => error
611 static uint64_t DisableConstant;
612 // Disables PHP's assert() function
613 // valid values are 0 => enabled (default)
614 // 1 => warning, 2 => error
615 static uint64_t DisableAssert;
616 // Disables non-top-level declarations
617 // true => error, false => default behaviour
618 static bool DisableNontoplevelDeclarations;
619 // Disables static closures
620 // true => error, false => default behaviour
621 static bool DisableStaticClosures;
622 // Enables the class-level where constraints
623 // true => allow the feature, false => disable the feature
624 static bool EnableClassLevelWhereClauses;
626 static int GetScannerType();
628 static hphp_string_imap<TypedValue> ConstantFunctions;
630 static const uint32_t kPCREInitialTableSize = 96 * 1024;
632 static std::string ExtensionDir;
633 static std::vector<std::string> Extensions;
634 static std::string DynamicExtensionPath;
635 static std::vector<std::string> DynamicExtensions;
637 static std::vector<std::string> TzdataSearchPaths;
639 #define HAC_CHECK_OPTS \
640 HC(Compare, compare) \
641 HC(ArrayKeyCast, array_key_cast) \
642 HC(ArrayPlus, array_plus)
644 #define EVALFLAGS() \
645 /* F(type, name, defaultVal) */ \
646 /* \
647 * Maximum number of elements on the VM execution stack. \
648 */ \
649 F(uint64_t, VMStackElms, kEvalVMStackElmsDefault) \
650 /* \
651 * Initial space reserved for the global variable environment (in \
652 * number of global variables). \
653 */ \
654 F(uint32_t, VMInitialGlobalTableSize, \
655 kEvalVMInitialGlobalTableSizeDefault) \
656 F(bool, Jit, evalJitDefault()) \
657 F(bool, JitEvaledCode, true) \
658 F(bool, JitRequireWriteLease, false) \
659 F(uint64_t, JitRelocationSize, kJitRelocationSizeDefault) \
660 F(uint64_t, JitMatureSize, 125 << 20) \
661 F(bool, JitMatureAfterWarmup, true) \
662 F(double, JitMaturityExponent, 1.) \
663 F(bool, JitTimer, kJitTimerDefault) \
664 F(int, JitConcurrently, 1) \
665 F(int, JitThreads, 4) \
666 F(int, JitWorkerThreads, std::max(1, Process::GetCPUCount() / 2)) \
667 F(int, JitWorkerThreadsForSerdes, 0) \
668 F(int, JitWorkerArenas, std::max(1, Process::GetCPUCount() / 4)) \
669 F(bool, JitParallelDeserialize, true) \
670 F(int, JitLdimmqSpan, 8) \
671 F(int, JitPrintOptimizedIR, 0) \
672 F(bool, RecordSubprocessTimes, false) \
673 F(bool, AllowHhas, false) \
674 F(bool, GenerateDocComments, true) \
675 F(bool, DisassemblerDocComments, true) \
676 F(bool, DisassemblerPropDocComments, true) \
677 F(bool, LoadFilepathFromUnitCache, false) \
678 F(bool, FatalOnParserOptionMismatch, true) \
679 F(bool, WarnOnSkipFrameLookup, true) \
680 /* \
681 * 0 - Code coverage cannot be enabled through request param \
682 * 1 - Code coverage can be enabled through request param \
683 * 2 - Code coverage enabled \
684 */ \
685 F(uint32_t, EnableCodeCoverage, 0) \
686 /* Whether to use the embedded hackc binary */ \
687 F(bool, HackCompilerUseEmbedded, facebook) \
688 /* Whether to trust existing versions of the extracted compiler */ \
689 F(bool, HackCompilerTrustExtract, true) \
690 /* When using an embedded hackc, extract it to the ExtractPath or the
691 ExtractFallback. */ \
692 F(string, HackCompilerExtractPath, "/var/run/hackc_%{schema}") \
693 F(string, HackCompilerFallbackPath, "/tmp/hackc_%{schema}_XXXXXX") \
694 /* Arguments to run embedded hackc binary with */ \
695 F(string, HackCompilerArgs, hackCompilerArgsDefault()) \
696 /* The command to invoke to spawn hh_single_compile in server mode. */\
697 F(string, HackCompilerCommand, hackCompilerCommandDefault()) \
698 /* The number of hh_single_compile daemons to keep alive. */ \
699 F(uint64_t, HackCompilerWorkers, Process::GetCPUCount()) \
700 /* The number of hh_single_compile daemons to keep alive during a \
701 * repo build after the files in the tree are parsed--set to 0 to \
702 * disable resizing the pool of compilers */ \
703 F(uint64_t, HackCompilerSecondaryWorkers, 2) \
704 /* The number of times to retry after an infra failure communicating
705 with a compiler process. */ \
706 F(uint64_t, HackCompilerMaxRetries, 0) \
707 /* Whether to log extern compiler performance */ \
708 F(bool, LogExternCompilerPerf, false) \
709 /* Whether to write verbose log messages to the error log and include
710 the hhas from failing units in the fatal error messages produced by
711 bad hh_single_compile units. */ \
712 F(bool, HackCompilerVerboseErrors, true) \
713 /* Whether the HackC compiler should inherit the compiler config of the
714 HHVM process that launches it. */ \
715 F(bool, HackCompilerInheritConfig, true) \
716 /* When using embedded data, extract it to the ExtractPath or the
717 * ExtractFallback. */ \
718 F(string, EmbeddedDataExtractPath, "/var/run/hhvm_%{type}_%{buildid}") \
719 F(string, EmbeddedDataFallbackPath, "/tmp/hhvm_%{type}_%{buildid}_XXXXXX") \
720 /* Whether to trust existing versions of extracted embedded data. */ \
721 F(bool, EmbeddedDataTrustExtract, true) \
722 F(bool, LogThreadCreateBacktraces, false) \
723 F(bool, FailJitPrologs, false) \
724 F(bool, UseHHBBC, !getenv("HHVM_DISABLE_HHBBC")) \
725 /* Equivalent to setting the --test-compression HHBBC-only flag. */ \
726 F(bool, HHBBCTestCompression, false) \
727 F(bool, EnablePerRepoOptions, true) \
728 F(bool, CachePerRepoOptionsPath, true) \
729 /* ThrowOnNonExhaustiveSwitch
730 * Generates warnings when switch statements are non exhaustive.
731 * 0 - Nothing
732 * 1 - Raise Warning
733 * >1 - Throw Exception
734 */ \
735 F(uint32_t, ThrowOnNonExhaustiveSwitch, 1) \
737 CheckPropTypeHints:
738 0 - No checks or enforcement of property type hints.
739 1 - Raises E_WARNING if a property type hint fails.
740 2 - Raises E_RECOVERABLE_ERROR if regular property type hint fails, raises
741 E_WARNING if soft property type hint fails. If a regular property type
742 hint fails, it's possible for execution to resume normally if the user
743 error handler doesn't throw and returns something other than boolean
744 false.
745 3 - Same as 2, except if a regular property type hint fails the runtime will
746 not allow execution to resume normally; if the user error handler
747 returns something other than boolean false, the runtime will throw a
748 fatal error.
749 */ \
750 F(int32_t, CheckPropTypeHints, 1) \
751 /* Enables enforcing upper-bounds for generic types
752 1 => warning, 2 => error
753 */ \
754 F(int32_t, EnforceGenericsUB, 1) \
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, EnableImplicitContext, false) \
770 F(bool, MoreAccurateMemStats, 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(uint32_t, ThreadTCMainBufferSize, 6 << 20) \
782 F(uint32_t, ThreadTCColdBufferSize, 6 << 20) \
783 F(uint32_t, ThreadTCFrozenBufferSize,4 << 20) \
784 F(uint32_t, ThreadTCDataBufferSize, 256 << 10) \
785 F(uint32_t, JitTargetCacheSize, 64 << 20) \
786 F(uint32_t, HHBCArenaChunkSize, 10 << 20) \
787 F(bool, ProfileBC, false) \
788 F(bool, ProfileHeapAcrossRequests, false) \
789 F(bool, ProfileHWEnable, true) \
790 F(string, ProfileHWEvents, std::string("")) \
791 F(bool, ProfileHWExcludeKernel, false) \
792 F(bool, ProfileHWFastReads, false) \
793 F(bool, ProfileHWStructLog, false) \
794 F(int32_t, ProfileHWExportInterval, 30) \
795 F(string, ReorderProps, reorderPropsDefault()) \
796 F(bool, JitAlwaysInterpOne, false) \
797 F(int32_t, JitNopInterval, 0) \
798 F(uint32_t, JitMaxTranslations, 10) \
799 F(uint32_t, JitMaxProfileTranslations, 30) \
800 F(uint32_t, JitTraceletGuardsLimit, 5) \
801 F(uint64_t, JitGlobalTranslationLimit, -1) \
802 F(int64_t, JitMaxRequestTranslationTime, -1) \
803 F(uint32_t, JitMaxRegionInstrs, 1347) \
804 F(uint32_t, JitMaxLiveRegionInstrs, 50) \
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, JitPGOVasmBlockCounters, true) \
814 F(bool, JitPGOVasmBlockCountersForceSaveSF, false) \
815 F(bool, JitPGOVasmBlockCountersForceSaveGP, false) \
816 F(uint32_t, JitPGOVasmBlockCountersMaxOpMismatches, 12) \
817 F(uint32_t, JitPGOVasmBlockCountersMinEntryValue, \
818 ServerExecutionMode() ? 200 : 0) \
819 F(bool, JitPGOVasmBlockCountersSkipFixWeights, false) \
820 F(double, JitPGOVasmBlockCountersHotWeightMultiplier, 0) \
821 F(bool, JitLayoutSeparateZeroWeightBlocks, false) \
822 F(bool, JitLayoutPrologueSplitHotCold, layoutPrologueSplitHotColdDefault()) \
823 F(bool, JitLayoutProfileSplitHotCold, true) \
824 F(uint64_t, JitLayoutMinHotThreshold, 0) \
825 F(uint64_t, JitLayoutMinColdThreshold, 0) \
826 F(double, JitLayoutHotThreshold, 0.01) \
827 F(double, JitLayoutColdThreshold, 0.0005) \
828 F(int32_t, JitLayoutMainFactor, 1000) \
829 F(int32_t, JitLayoutColdFactor, 5) \
830 F(bool, JitAHotSizeRoundUp, true) \
831 F(uint32_t, GdbSyncChunks, 128) \
832 F(bool, JitKeepDbgFiles, false) \
833 /* despite the unfortunate name, this enables function renaming and
834 * interception in the interpreter as well as the jit, and also
835 * implies all functions may be used with fb_intercept */ \
836 F(bool, JitEnableRenameFunction, EvalJitEnableRenameFunction) \
837 F(bool, JitUseVtuneAPI, false) \
838 F(bool, TraceCommandLineRequest, true) \
840 F(bool, JitDisabledByHphpd, false) \
841 F(uint32_t, JitWarmupStatusBytes, ((25 << 10) + 1)) \
842 F(uint32_t, JitWarmupMaxCodeGenRate, 20000) \
843 F(uint32_t, JitWarmupRateSeconds, 64) \
844 F(uint32_t, JitWriteLeaseExpiration, 1500) /* in microseconds */ \
845 F(int, JitRetargetJumps, 1) \
846 /* Sync VM reg state for all native calls. */ \
847 F(bool, JitForceVMRegSync, false) \
848 /* Log the profile used to optimize array-like gets and sets. */ \
849 F(bool, LogArrayAccessProfile, false) \
850 /* Log the profile used to target iterator specialization. */ \
851 F(bool, LogArrayIterProfile, false) \
852 /* We use PGO to target specialization for "foreach" iterator loops. \
853 * We specialize if the chosen specialization covers this fraction \
854 * of profiled loops. If the value is > 1.0, we won't specialize. */ \
855 F(double, ArrayIterSpecializationRate, 0.99) \
856 F(bool, HHIRSimplification, true) \
857 F(bool, HHIRGenOpts, true) \
858 F(bool, HHIRRefcountOpts, true) \
859 F(bool, HHIREnableGenTimeInlining, true) \
860 F(uint32_t, HHIRInliningCostFactorMain, 100) \
861 F(uint32_t, HHIRInliningCostFactorCold, 32) \
862 F(uint32_t, HHIRInliningCostFactorFrozen, 10) \
863 F(uint32_t, HHIRInliningVasmCostLimit, 10500) \
864 F(uint32_t, HHIRInliningMinVasmCostLimit, 10000) \
865 F(uint32_t, HHIRInliningMaxVasmCostLimit, 40000) \
866 F(uint32_t, HHIRAlwaysInlineVasmCostLimit, 4800) \
867 F(uint32_t, HHIRInliningMaxDepth, 1000) \
868 F(double, HHIRInliningVasmCallerExp, .5) \
869 F(double, HHIRInliningVasmCalleeExp, .5) \
870 F(double, HHIRInliningDepthExp, 0) \
871 F(uint32_t, HHIRInliningMaxReturnDecRefs, 24) \
872 F(uint32_t, HHIRInliningMaxReturnLocals, 40) \
873 F(uint32_t, HHIRInliningMaxInitObjProps, 12) \
874 F(bool, HHIRInliningIgnoreHints, !debug) \
875 F(bool, HHIRInliningUseStackedCost, true) \
876 F(bool, HHIRInliningUseLayoutBlocks, false) \
877 F(bool, HHIRInlineFrameOpts, true) \
878 F(bool, HHIRPartialInlineFrameOpts, true) \
879 F(bool, HHIRAlwaysInterpIgnoreHint, !debug) \
880 F(bool, HHIRGenerateAsserts, false) \
881 F(bool, HHIRDeadCodeElim, true) \
882 F(bool, HHIRGlobalValueNumbering, true) \
883 F(bool, HHIRPredictionOpts, true) \
884 F(bool, HHIRMemoryOpts, true) \
885 F(bool, AssemblerFoldDefaultValues, true) \
886 F(uint64_t, AssemblerMaxScalarSize, 1073741824) /* 1GB */ \
887 F(uint32_t, HHIRLoadElimMaxIters, 10) \
888 /* Temporarily only enable in debug builds so the optimizations get
889 * tested */ \
890 F(bool, HHIRLoadEnableTeardownOpts, debug) \
891 F(uint32_t, HHIRLoadStackTeardownMaxDecrefs, 8) \
892 F(uint32_t, HHIRLoadThrowMaxDecrefs, 64) \
893 F(bool, HHIRStorePRE, true) \
894 F(bool, HHIROutlineGenericIncDecRef, true) \
895 /* How many elements to inline for packed- or mixed-array inits. */ \
896 F(uint32_t, HHIRMaxInlineInitPackedElements, 8) \
897 F(uint32_t, HHIRMaxInlineInitMixedElements, 4) \
898 F(double, HHIROffsetArrayProfileThreshold, 0.85) \
899 F(double, HHIRSmallArrayProfileThreshold, 0.8) \
900 F(double, HHIRMissingArrayProfileThreshold, 0.8) \
901 F(double, HHIRExitArrayProfileThreshold, 0.98) \
902 F(double, HHIROffsetExitArrayProfileThreshold, 1.2) /* disabled */ \
903 F(double, HHIRIsTypeStructProfileThreshold, 0.95) \
904 /* Register allocation flags */ \
905 F(bool, HHIREnablePreColoring, true) \
906 F(bool, HHIREnableCoalescing, true) \
907 F(bool, HHIRAllocSIMDRegs, true) \
908 F(bool, HHIRStressSpill, false) \
909 F(bool, JitStressTestLiveness, false) \
910 /* Region compiler flags */ \
911 F(string, JitRegionSelector, regionSelectorDefault()) \
912 F(bool, JitPGO, pgoDefault()) \
913 F(string, JitPGORegionSelector, "hotcfg") \
914 F(uint64_t, JitPGOThreshold, pgoThresholdDefault()) \
915 F(bool, JitPGOOnly, false) \
916 F(bool, JitPGOUsePostConditions, true) \
917 F(bool, JitPGOUseAddrCountedCheck, false) \
918 F(uint32_t, JitPGOUnlikelyIncRefCountedPercent, 2) \
919 F(uint32_t, JitPGOUnlikelyIncRefIncrementPercent, 5) \
920 F(uint32_t, JitPGOUnlikelyDecRefReleasePercent, 5) \
921 F(uint32_t, JitPGOUnlikelyDecRefCountedPercent, 2) \
922 F(uint32_t, JitPGOUnlikelyDecRefPersistPercent, 5) \
923 F(uint32_t, JitPGOUnlikelyDecRefSurvivePercent, 5) \
924 F(uint32_t, JitPGOUnlikelyDecRefDecrementPercent, 5) \
925 F(double, JitPGODecRefNZReleasePercentCOW, \
926 ServerExecutionMode() ? 0.5 : 0) \
927 F(double, JitPGODecRefNZReleasePercent, \
928 ServerExecutionMode() ? 5 : 0) \
929 F(double, JitPGODecRefNopDecPercentCOW, \
930 ServerExecutionMode() ? 0.5 : 0) \
931 F(double, JitPGODecRefNopDecPercent, ServerExecutionMode() ? 5 : 0) \
932 F(bool, JitPGOArrayGetStress, false) \
933 F(double, JitPGOMinBlockCountPercent, 0.025) \
934 F(double, JitPGOMinArcProbability, 0.0) \
935 F(uint32_t, JitPGOMaxFuncSizeDupBody, 80) \
936 F(uint32_t, JitPGORelaxPercent, 100) \
937 F(uint32_t, JitPGORelaxUncountedToGenPercent, 20) \
938 F(uint32_t, JitPGORelaxCountedToGenPercent, 75) \
939 F(double, JitPGOCalledFuncCheckThreshold, 50) \
940 F(double, JitPGOCalledFuncExitThreshold, 99.9) \
941 F(bool, JitPGODumpCallGraph, false) \
942 F(bool, JitPGOOptCodeCallGraph, true) \
943 F(bool, JitPGORacyProfiling, false) \
944 F(uint32_t, JitLiveThreshold, ServerExecutionMode() ? 1000 : 0) \
945 F(uint32_t, JitProfileThreshold, ServerExecutionMode() ? 200 : 0) \
946 F(uint32_t, JitSrcKeyThreshold, 0) \
947 F(uint64_t, FuncCountHint, 10000) \
948 F(uint64_t, PGOFuncCountHint, 1000) \
949 F(bool, RegionRelaxGuards, true) \
950 /* DumpBytecode =1 dumps user php, =2 dumps systemlib & user php */ \
951 F(int32_t, DumpBytecode, 0) \
952 /* DumpHhas =1 dumps user php, =2 dumps systemlib & user php */ \
953 F(int32_t, DumpHhas, 0) \
954 F(string, DumpHhasToFile, "") \
955 F(bool, DumpTC, false) \
956 F(string, DumpTCPath, "/tmp") \
957 F(bool, DumpTCAnchors, false) \
958 F(uint32_t, DumpIR, 0) \
959 F(uint32_t, DumpIRJson, 0) \
960 F(bool, DumpTCAnnotationsForAllTrans,debug) \
961 /* DumpInlDecision 0=none ; 1=refuses ; 2=refuses+accepts */ \
962 F(uint32_t, DumpInlDecision, 0) \
963 F(uint32_t, DumpRegion, 0) \
964 F(bool, DumpCallTargets, false) \
965 F(bool, DumpLayoutCFG, false) \
966 F(bool, DumpVBC, false) \
967 F(bool, DumpAst, false) \
968 F(bool, DumpTargetProfiles, false) \
969 F(bool, MapTgtCacheHuge, false) \
970 F(bool, NewTHPHotText, false) \
971 F(bool, FileBackedColdArena, useFileBackedArenaDefault()) \
972 F(string, ColdArenaFileDir, "/tmp") \
973 F(uint32_t, MaxHotTextHugePages, hotTextHugePagesDefault()) \
974 F(uint32_t, MaxLowMemHugePages, hugePagesSoundNice() ? 8 : 0) \
975 F(uint32_t, MaxHighArenaHugePages, 0) \
976 F(uint32_t, Num1GPagesForSlabs, 0) \
977 F(uint32_t, Num2MPagesForSlabs, 0) \
978 F(uint32_t, Num1GPagesForReqHeap, 0) \
979 F(uint32_t, Num2MPagesForReqHeap, 0) \
980 F(uint32_t, NumReservedSlabs, 0) \
981 F(uint32_t, Num1GPagesForA0, 0) \
982 F(uint32_t, Num2MPagesForA0, 0) \
983 F(bool, BigAllocUseLocalArena, true) \
984 F(bool, JsonParserUseLocalArena, true) \
985 F(bool, XmlParserUseLocalArena, true) \
986 F(bool, LowStaticArrays, true) \
987 F(int64_t, HeapPurgeWindowSize, 5 * 1000000) \
988 F(uint64_t, HeapPurgeThreshold, 128 * 1024 * 1024) \
989 /* GC Options: See heap-collect.cpp for more details */ \
990 F(bool, EagerGC, eagerGcDefault()) \
991 F(bool, FilterGCPoints, true) \
992 F(bool, Quarantine, eagerGcDefault()) \
993 F(bool, HeapAllocSampleNativeStack, false) \
994 F(bool, LogKilledRequests, true) \
995 F(uint32_t, GCSampleRate, 0) \
996 F(uint32_t, HeapAllocSampleRequests, 0) \
997 F(uint32_t, HeapAllocSampleBytes, 256 * 1024) \
998 F(uint32_t, SlabAllocAlign, 64) \
999 F(int64_t, GCMinTrigger, 64L<<20) \
1000 F(double, GCTriggerPct, 0.5) \
1001 F(bool, TwoPhaseGC, false) \
1002 F(bool, EnableGC, enableGcDefault()) \
1003 /* End of GC Options */ \
1004 F(bool, Verify, (getenv("HHVM_VERIFY") || \
1005 !EvalHackCompilerCommand.empty())) \
1006 F(bool, VerifyOnly, false) \
1007 F(bool, FatalOnVerifyError, !RepoAuthoritative) \
1008 F(bool, AbortBuildOnVerifyError, true) \
1009 F(bool, AbortBuildOnCompilerError, true) \
1010 F(uint32_t, StaticContentsLogRate, 100) \
1011 F(uint32_t, LogUnitLoadRate, 0) \
1012 F(uint32_t, MaxDeferredErrors, 50) \
1013 F(bool, JitAlignMacroFusionPairs, alignMacroFusionPairs()) \
1014 F(bool, JitAlignUniqueStubs, true) \
1015 F(uint32_t, SerDesSampleRate, 0) \
1016 F(bool, JitSerdesModeForceOff, false) \
1017 F(bool, JitDesUnitPreload, false) \
1018 F(std::set<std::string>, JitSerdesDebugFunctions, {}) \
1019 F(uint32_t, JitSerializeOptProfSeconds, ServerExecutionMode() ? 300 : 0)\
1020 F(uint32_t, JitSerializeOptProfRequests, 0) \
1021 F(int, SimpleJsonMaxLength, 2 << 20) \
1022 F(uint32_t, JitSampleRate, 0) \
1023 F(uint32_t, TraceServerRequestRate, 0) \
1024 /* Tracing Options */ \
1025 /* Base tracing sample rate for all requests */ \
1026 F(uint32_t, TracingSampleRate, 0) \
1027 /* Tracing sample rate for first N requests */ \
1028 F(uint32_t, TracingPerRequestCount, 0) \
1029 F(uint32_t, TracingPerRequestSampleRate, 0) \
1030 /* Tracing sample rate for first N requests per URL */ \
1031 F(uint32_t, TracingFirstRequestsCount, 0) \
1032 F(uint32_t, TracingFirstRequestsSampleRate, 0) \
1033 /* Empty string disables any Artillery tracing */ \
1034 F(std::string, ArtilleryTracePolicy, "") \
1035 /* Opaque tag to add to each trace. Useful for aggregation */ \
1036 F(std::string, TracingTagId, "") \
1037 /* Log the sizes and metadata for all translations in the TC broken
1038 * down by function and inclusive/exclusive size for inlined regions.
1039 * When set to "" TC size data will be sampled on a per function basis
1040 * as determined by JitSampleRate. When set to a non-empty string all
1041 * translations will be logged, and run_key column will be logged with
1042 * the value of this option. */ \
1043 F(string, JitLogAllInlineRegions, "") \
1044 F(bool, JitProfileGuardTypes, false) \
1045 F(uint32_t, JitFilterLease, 1) \
1046 F(uint32_t, PCRETableSize, kPCREInitialTableSize) \
1047 F(uint64_t, PCREExpireInterval, 2 * 60 * 60) \
1048 F(string, PCRECacheType, std::string("static")) \
1049 F(bool, EnableCompactBacktrace, true) \
1050 F(bool, EnableNuma, (numa_num_nodes > 1) && ServerExecutionMode()) \
1051 /* Use 1G pages for jemalloc metadata. */ \
1052 F(bool, EnableArenaMetadata1GPage, false) \
1053 /* Use 1G pages for jemalloc metadata (NUMA arenas if applicable). */ \
1054 F(bool, EnableNumaArenaMetadata1GPage, false) \
1055 /* Reserved space on 1G pages for jemalloc metadata (arena0). */ \
1056 F(uint64_t, ArenaMetadataReservedSize, 216 << 20) \
1057 F(bool, EnableCallBuiltin, true) \
1058 F(bool, EnableReusableTC, reuseTCDefault()) \
1059 F(bool, LogServerRestartStats, false) \
1060 /* Extra bytes added to each area (Hot/Cold/Frozen) of a translation. \
1061 * If we don't end up using a reusable TC, we'll drop the padding. */ \
1062 F(uint32_t, ReusableTCPadding, 128) \
1063 F(int64_t, StressUnitCacheFreq, 0) \
1064 /* Perf warning sampling rates. The SelectHotCFG warning is noisy. */ \
1065 F(int64_t, PerfWarningSampleRate, 1) \
1066 F(int64_t, SelectHotCFGSampleRate, 100) \
1067 F(int64_t, FunctionCallSampleRate, 0) \
1068 F(double, InitialLoadFactor, 1.0) \
1069 /* Controls emitting checks for bespoke arrays and using logging \
1070 * arrays at runtime. \
1072 * 0 - Disable bespokes. We assume that all array-likes have their \
1073 * standard (aka "vanilla") layouts. \
1074 * 1 - Test bespokes. We emit checks for vanilla layouts and produce \
1075 * logging arrays based on the request ID. If rid % 2 == 1, then \
1076 * a logging array is generated. \
1077 * 2 - Production bespokes. We emit checks as in (1), and produce \
1078 * logging arrays based on per creation site sampling with the \
1079 * sample rate specified by EmitLoggingArraySampleRate. If the \
1080 * sample rate is 0, logging arrays are never constructed. \
1081 * Logging arrays are only created before RTA has begun. */ \
1082 F(int32_t, BespokeArrayLikeMode, 0) \
1083 F(uint64_t, EmitLoggingArraySampleRate, 0) \
1084 F(string, ExportLoggingArrayDataPath, "") \
1085 /* Raise notices on various array operations which may present \
1086 * compatibility issues with Hack arrays. \
1088 * The various *Notices options independently control separate \
1089 * subsets of notices. The Check* options are subordinate to the \
1090 * HackArrCompatNotices option, and control whether various runtime
1091 * checks are made; they do not affect any optimizations. */ \
1092 F(bool, HackArrCompatNotices, false) \
1093 F(bool, HackArrCompatCheckCompare, false) \
1094 F(bool, HackArrCompatCheckArrayPlus, false) \
1095 F(bool, HackArrCompatFBSerializeHackArraysNotices, false) \
1096 /* Raise notices on intish-cast (which may use an is_array check) */ \
1097 F(bool, HackArrCompatIntishCastNotices, false) \
1098 /* Raise notices when is_array is called with any hack array */ \
1099 F(bool, HackArrCompatIsArrayNotices, false) \
1100 /* Raise notices when is_vec or is_dict is called with a v/darray */ \
1101 F(bool, HackArrCompatIsVecDictNotices, false) \
1102 F(bool, HackArrCompatSerializeNotices, false) \
1103 /* Raise notices when fb_compact_*() would change behavior */ \
1104 F(bool, HackArrCompatCompactSerializeNotices, false) \
1105 /* When this flag is on, d/varray constructions are marked. */ \
1106 F(bool, HackArrDVArrMark, false) \
1107 /* When this flag is on, var_dump outputs d/varrays. */ \
1108 F(bool, HackArrDVArrVarDump, false) \
1109 /* This is the flag for "unification", meaning that darrays are \
1110 * replaced by dicts and varrays by vecs. */ \
1111 F(bool, HackArrDVArrs, false) \
1112 /* Raise a notice for `$dict is shape` and `$vec is tuple`. */ \
1113 F(bool, HackArrIsShapeTupleNotices, false) \
1114 /* Enable instrumentation and information in the repo for tracking \
1115 * the source of vecs and dicts whose vec/dict-ness is observed \
1116 * during program execution \
1118 * Latches to false at startup if either the repo we're loading in \
1119 * RepoAuthoritativeMode wasn't built with this flag or if the \
1120 * flag LogArrayProvenance is unset */ \
1121 F(bool, ArrayProvenance, false) \
1122 /* Log the source of dvarrays whose dvarray-ness is observed, e.g. \
1123 * through serialization. If this flag is off, we won't bother to \
1124 * track array provenance at runtime, because it isn't exposed. \
1126 * Code should just depend on ArrayProvenance alone - we'll set it \
1127 * based on this flag when loading a repo build. */ \
1128 F(bool, LogArrayProvenance, false) \
1129 /* Log only out out of this many array headers when serializing */ \
1130 F(uint32_t, LogArrayProvenanceSampleRatio, 1000) \
1131 /* Use dummy tags for enums with this many values, to avoid copies */ \
1132 F(uint32_t, ArrayProvenanceLargeEnumLimit, 256) \
1133 /* What fraction of array provenance diagnostics should be logged? \
1134 * Set to 0 to disable diagnostics entirely */ \
1135 F(uint32_t, LogArrayProvenanceDiagnosticsSampleRate, 0) \
1136 /* Warn if is expression are used with type aliases that cannot be |
1137 * resolved */ \
1138 F(bool, IsExprEnableUnresolvedWarning, false) \
1139 /* Raise a notice if a Class type is passed to is_string */ \
1140 F(bool, ClassIsStringNotices, false) \
1141 /* Raise a notice if a Class type is passed to function that expects a
1142 string */ \
1143 F(bool, ClassStringHintNotices, false) \
1144 /* Raise a notice if a ClsMeth type is passed to is_vec/is_array */ \
1145 F(bool, IsVecNotices, false) \
1146 /* Raise a notice if a ClsMeth type is passed to a function that
1147 * expects a vec/varray */ \
1148 F(bool, VecHintNotices, false) \
1149 /* Switches on miscellaneous junk. */ \
1150 F(bool, NoticeOnCreateDynamicProp, false) \
1151 F(bool, NoticeOnReadDynamicProp, false) \
1152 F(bool, NoticeOnImplicitInvokeToString, false) \
1153 F(bool, FatalOnConvertObjectToString, false) \
1154 F(bool, NoticeOnBuiltinDynamicCalls, false) \
1155 F(bool, RxPretendIsEnabled, false) \
1156 /* Raise warning when class pointers are used as strings. */ \
1157 F(bool, RaiseClassConversionWarning, false) \
1158 F(bool, EmitClsMethPointers, false) \
1159 /* EmitClassPointers:
1160 * 0 => convert Foo::class to string "Foo"
1161 * 1 => convert Foo::class to class pointer
1162 * 2 => convert Foo::class to lazy class */ \
1163 F(int32_t, EmitClassPointers, 0) \
1164 /* false to skip type refinement for ClsMeth type at HHBBC. */ \
1165 F(bool, IsCompatibleClsMethType, false) \
1166 /* Raise warning if a ClsMeth type is compared to other types. */ \
1167 F(bool, RaiseClsMethComparisonWarning, false) \
1168 /* Raise warning when ClsMethDataRef is used as varray/vec. */ \
1169 F(bool, RaiseClsMethConversionWarning, false) \
1170 /* Raise warning when strings are used as classes. */ \
1171 F(bool, RaiseStrToClsConversionWarning, false) \
1172 F(bool, EmitMethCallerFuncPointers, false) \
1173 /* trigger E_USER_WARNING error when getClassName()/getMethodName()
1174 * is used on __SystemLib\MethCallerHelper */ \
1175 F(bool, NoticeOnMethCallerHelperUse, false) \
1176 F(bool, NoticeOnCollectionToBool, false) \
1177 F(bool, NoticeOnSimpleXMLBehavior, false) \
1178 F(bool, ForbidDivisionByZero, true) \
1179 /* Enables Hack records. */ \
1180 F(bool, HackRecords, false) \
1181 /* \
1182 * Control dynamic calls to functions and dynamic constructs of \
1183 * classes which haven't opted into being called that way. \
1185 * 0 - Nothing \
1186 * 1 - Warn if target is not annotated or dynamic callsite is using \
1187 * a raw string or array \
1188 * (depending on ForbidDynamicCallsWithAttr setting) \
1189 * 2 - Throw exception if target is not annotated, and warn if \
1190 * dynamic callsite is using a raw string or array \
1191 * 3 - Throw exception \
1193 */ \
1194 F(int32_t, ForbidDynamicCallsToFunc, 0) \
1195 F(int32_t, ForbidDynamicCallsToClsMeth, 0) \
1196 F(int32_t, ForbidDynamicCallsToInstMeth, 0) \
1197 F(int32_t, ForbidDynamicConstructs, 0) \
1198 /* \
1199 * Keep logging dynamic calls according to options above even if \
1200 * __DynamicallyCallable attribute is present at declaration. \
1201 */ \
1202 F(bool, ForbidDynamicCallsWithAttr, false) \
1203 /* Toggles logging for expressions of type $var::name() */ \
1204 F(bool, LogKnownMethodsAsDynamicCalls, true) \
1205 /* \
1206 * Don't allow unserializing to __PHP_Incomplete_Class \
1207 * 0 - Nothing \
1208 * 1 - Warn \
1209 * 2 - Throw exception \
1210 */ \
1211 F(int32_t, ForbidUnserializeIncompleteClass, 0) \
1212 F(int32_t, RxEnforceCalls, 0) \
1213 /* \
1214 * 0 - Nothing \
1215 * 1 - Warn \
1216 * 2 - Fail unit verification (i.e. fail to load it) \
1217 */ \
1218 F(int32_t, RxVerifyBody, 0) \
1219 F(bool, RxIsEnabled, EvalRxPretendIsEnabled) \
1220 /* \
1221 * Controls behavior on reflection to default value expressions \
1222 * that throw during evaluation \
1223 * 0 - Nothing \
1224 * 1 - Warn and retain current behavior \
1225 * 2 - Return null for parameter value \
1226 */ \
1227 F(int32_t, FixDefaultArgReflection, 1) \
1228 F(int32_t, ServerOOMAdj, 0) \
1229 F(std::string, PreludePath, "") \
1230 F(uint32_t, NonSharedInstanceMemoCaches, 10) \
1231 F(bool, UseGraphColor, false) \
1232 F(std::vector<std::string>, IniGetHide, std::vector<std::string>()) \
1233 F(std::string, UseRemoteUnixServer, "no") \
1234 F(std::string, UnixServerPath, "") \
1235 F(uint32_t, UnixServerWorkers, Process::GetCPUCount()) \
1236 F(bool, UnixServerQuarantineApc, false) \
1237 F(bool, UnixServerQuarantineUnits, false) \
1238 F(bool, UnixServerVerifyExeAccess, false) \
1239 F(bool, UnixServerFailWhenBusy, false) \
1240 F(std::vector<std::string>, UnixServerAllowedUsers, \
1241 std::vector<std::string>()) \
1242 F(std::vector<std::string>, UnixServerAllowedGroups, \
1243 std::vector<std::string>()) \
1244 /* Options for testing */ \
1245 F(bool, TrashFillOnRequestExit, false) \
1246 /****************** \
1247 | ARM Options. | \
1248 *****************/ \
1249 F(bool, JitArmLse, armLseDefault()) \
1250 /****************** \
1251 | PPC64 Options. | \
1252 *****************/ \
1253 /* Minimum immediate size to use TOC */ \
1254 F(uint16_t, PPC64MinTOCImmSize, 64) \
1255 /* Relocation features. Use with care on production */ \
1256 /* Allow a Far branch be converted to a Near branch. */ \
1257 F(bool, PPC64RelocationShrinkFarBranches, false) \
1258 /* Remove nops from a Far branch. */ \
1259 F(bool, PPC64RelocationRemoveFarBranchesNops, true) \
1260 /******************** \
1261 | Profiling flags. | \
1262 ********************/ \
1263 /* Whether to maintain the address-to-VM-object mapping. */ \
1264 F(bool, EnableReverseDataMap, true) \
1265 /* Turn on perf-mem-event sampling roughly every this many requests. \
1266 * To maintain the same overall sampling rate, the ratio between the \
1267 * request and sample frequencies should be kept constant. */ \
1268 F(uint32_t, PerfMemEventRequestFreq, 0) \
1269 /* Sample this many memory instructions per second. This should be \
1270 * kept low to avoid the risk of collecting a sample while we're \
1271 * processing a previous sample. */ \
1272 F(uint32_t, PerfMemEventSampleFreq, 80) \
1273 /* Sampling frequency for TC branch profiling. */ \
1274 F(uint32_t, ProfBranchSampleFreq, 0) \
1275 /* Sampling frequency for profiling packed array accesses. */ \
1276 F(uint32_t, ProfPackedArraySampleFreq, 0) \
1277 F(bool, UseXedAssembler, false) \
1278 /* Record the first N units loaded via StructuredLog::log() */ \
1279 F(uint64_t, RecordFirstUnits, 0) \
1280 /* More aggresively reuse already compiled units based on SHA1 */ \
1281 F(bool, CheckUnitSHA1, true) \
1282 /* When dynamic_fun is called on a function not marked as
1283 __DynamicallyCallable:
1285 0 - do nothing
1286 1 - raise a warning
1287 2 - throw */ \
1288 F(uint64_t, DynamicFunLevel, 1) \
1289 /* When dynamic_class_meth is called on a method not marked as
1290 __DynamicallyCallable:
1292 0 - do nothing
1293 1 - raise a warning
1294 2 - throw */ \
1295 F(uint64_t, DynamicClsMethLevel, 1) \
1296 F(bool, APCSerializeFuncs, true) \
1297 /* When set:
1298 * - `is_array` becomes equivalent to `is_any_array` or
1299 * `isTvArrayLike` instead of being a strict PHP array check.
1300 * - For safety, we still log when these calls receive Hack arrays.
1301 * See `SuppressWidenIsArrayLogs`.
1302 */ \
1303 F(bool, WidenIsArray, false) \
1304 F(bool, WidenIsArrayLogs, true) \
1305 F(bool, EnablePerFileCoverage, false) \
1306 /* Should we use the autoload map from the repo */ \
1307 F(bool, UseRepoAutoloadMap, true) \
1308 F(bool, LogOnIsArrayFunction, false) \
1309 /* Unit prefetching options */ \
1310 F(uint32_t, UnitPrefetcherMaxThreads, 0) \
1311 F(uint32_t, UnitPrefetcherMinThreads, 0) \
1312 F(uint32_t, UnitPrefetcherIdleThreadTimeoutSecs, 60) \
1313 /* */
1315 private:
1316 using string = std::string;
1318 // Custom settings. This should be accessed via the GetServerCustomSetting
1319 // APIs.
1320 static std::map<std::string, std::string> CustomSettings;
1322 public:
1323 #define F(type, name, unused) \
1324 static type Eval ## name;
1325 EVALFLAGS()
1326 #undef F
1328 static bool RecordCodeCoverage;
1329 static std::string CodeCoverageOutputFile;
1331 // Repo (hhvm bytecode repository) options
1332 static std::string RepoLocalMode;
1333 static std::string RepoLocalPath;
1334 static std::string RepoCentralPath;
1335 static int32_t RepoCentralFileMode;
1336 static std::string RepoCentralFileUser;
1337 static std::string RepoCentralFileGroup;
1338 static bool RepoAllowFallbackPath;
1339 static std::string RepoEvalMode;
1340 static std::string RepoJournal;
1341 static bool RepoCommit;
1342 static bool RepoDebugInfo;
1343 static bool RepoAuthoritative;
1344 static int64_t RepoLocalReadaheadRate;
1345 static bool RepoLitstrLazyLoad;
1346 static bool RepoLocalReadaheadConcurrent;
1347 static uint32_t RepoBusyTimeoutMS;
1349 // pprof/hhprof options
1350 static bool HHProfEnabled;
1351 static bool HHProfActive;
1352 static bool HHProfAccum;
1353 static bool HHProfRequest;
1354 static bool TrackPerUnitMemory;
1356 // Sandbox options
1357 static bool SandboxMode;
1358 static std::string SandboxPattern;
1359 static std::string SandboxHome;
1360 static std::string SandboxFallback;
1361 static std::string SandboxConfFile;
1362 static std::map<std::string, std::string> SandboxServerVariables;
1363 static bool SandboxFromCommonRoot;
1364 static std::string SandboxDirectoriesRoot;
1365 static std::string SandboxLogsRoot;
1366 static std::string SandboxDefaultUserFile;
1367 static std::string SandboxHostAlias;
1369 // Debugger options
1370 static bool EnableHphpdDebugger;
1371 static bool EnableVSDebugger;
1372 static int VSDebuggerListenPort;
1373 static std::string VSDebuggerDomainSocketPath;
1374 static bool VSDebuggerNoWait;
1375 static bool EnableDebuggerColor;
1376 static bool EnableDebuggerPrompt;
1377 static bool EnableDebuggerServer;
1378 static bool EnableDebuggerUsageLog;
1379 static bool DebuggerDisableIPv6;
1380 static std::string DebuggerServerIP;
1381 static int DebuggerServerPort;
1382 static int DebuggerDefaultRpcPort;
1383 static std::string DebuggerDefaultRpcAuth;
1384 static std::string DebuggerRpcHostDomain;
1385 static int DebuggerDefaultRpcTimeout;
1386 static std::string DebuggerDefaultSandboxPath;
1387 static std::string DebuggerStartupDocument;
1388 static int DebuggerSignalTimeout;
1389 static std::string DebuggerAuthTokenScriptBin;
1390 static std::string DebuggerSessionAuthScriptBin;
1392 // Mail options
1393 static std::string SendmailPath;
1394 static std::string MailForceExtraParameters;
1396 // preg stack depth and debug support options
1397 static int64_t PregBacktraceLimit;
1398 static int64_t PregRecursionLimit;
1399 static bool EnablePregErrorLog;
1401 // SimpleXML options
1402 static bool SimpleXMLEmptyNamespaceMatchesAll;
1404 // Cookie options
1405 static bool AllowDuplicateCookies;
1407 #ifdef FACEBOOK
1408 // fb303 server
1409 static bool EnableFb303Server;
1410 static int Fb303ServerPort;
1411 static int Fb303ServerThreadStackSizeMb;
1412 static int Fb303ServerWorkerThreads;
1413 static int Fb303ServerPoolThreads;
1414 #endif
1416 // Xenon options
1417 static double XenonPeriodSeconds;
1418 static uint32_t XenonRequestFreq;
1419 static bool XenonForceAlwaysOn;
1421 // Strobelight options
1422 static bool StrobelightEnabled;
1424 static bool SetProfileNullThisObject;
1426 static_assert(sizeof(RuntimeOption) == 1, "no instance variables");
1428 using RO = RuntimeOption;
1430 inline bool isJitDeserializing() {
1431 auto const m = RuntimeOption::EvalJitSerdesMode;
1432 return static_cast<std::underlying_type<JitSerdesMode>::type>(m) & 0x2;
1435 inline bool isJitSerializing() {
1436 auto const m = RuntimeOption::EvalJitSerdesMode;
1437 return static_cast<std::underlying_type<JitSerdesMode>::type>(m) & 0x1;
1440 inline bool unitPrefetchingEnabled() {
1441 return RO::EvalUnitPrefetcherMaxThreads > 0;
1444 ///////////////////////////////////////////////////////////////////////////////
1447 #endif // incl_HPHP_RUNTIME_OPTION_H_