Add support for HHBC ops with 5 immediates
[hiphop-php.git] / hphp / runtime / base / runtime-option.h
bloba8134dc41310a5ac0b4918e6714769c949881dce
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
17 #ifndef incl_HPHP_RUNTIME_OPTION_H_
18 #define incl_HPHP_RUNTIME_OPTION_H_
20 #include <folly/dynamic.h>
22 #include <unordered_map>
23 #include <vector>
24 #include <string>
25 #include <map>
26 #include <set>
27 #include <boost/container/flat_set.hpp>
28 #include <memory>
30 #include "hphp/runtime/base/config.h"
31 #include "hphp/runtime/base/typed-value.h"
32 #include "hphp/util/compilation-flags.h"
33 #include "hphp/util/hash-map-typedefs.h"
34 #include "hphp/util/functional.h"
36 namespace HPHP {
37 ///////////////////////////////////////////////////////////////////////////////
39 struct AccessLogFileData;
40 struct ErrorLogFileData;
41 struct VirtualHost;
42 struct IpBlockMap;
43 struct SatelliteServerInfo;
44 struct FilesMatch;
45 struct Hdf;
46 struct IniSettingMap;
48 constexpr int kDefaultInitialStaticStringTableSize = 500000;
50 /**
51 * Configurable options set from command line or configurable file at startup
52 * time.
54 struct RuntimeOption {
55 static void Load(
56 IniSettingMap &ini, Hdf& config,
57 const std::vector<std::string>& iniClis = std::vector<std::string>(),
58 const std::vector<std::string>& hdfClis = std::vector<std::string>(),
59 std::vector<std::string>* messages = nullptr,
60 std::string cmd = "");
62 static bool ServerExecutionMode() {
63 return ServerMode;
66 static bool GcSamplingEnabled() {
67 return EvalGCSampleRate > 0;
70 static bool JitSamplingEnabled() {
71 return EvalJit && EvalJitSampleRate > 0;
74 static bool AllowObjectDestructors() {
75 // When one_bit_refcount == true, skip the runtime check since destructors
76 // are never allowed.
77 return !one_bit_refcount && EvalAllowObjectDestructors;
80 static void ReadSatelliteInfo(
81 const IniSettingMap& ini,
82 const Hdf& hdf,
83 std::vector<std::shared_ptr<SatelliteServerInfo>>& infos,
84 std::string& xboxPassword,
85 std::set<std::string>& xboxPasswords
88 static std::string getTraceOutputFile();
90 static bool ServerMode;
91 static std::string BuildId;
92 static std::string InstanceId;
93 static std::string DeploymentId; // ID for set of instances deployed at once
94 static std::string PidFile;
96 static std::map<std::string, ErrorLogFileData> ErrorLogs;
97 static std::string LogFile;
98 static std::string LogFileSymLink;
99 static uint16_t LogFilePeriodMultiplier;
101 static int LogHeaderMangle;
102 static bool AlwaysEscapeLog;
103 static bool AlwaysLogUnhandledExceptions;
104 static bool NoSilencer;
105 static int ErrorUpgradeLevel; // Bitmask of errors to upgrade to E_USER_ERROR
106 static bool CallUserHandlerOnFatals;
107 static bool ThrowExceptionOnBadMethodCall;
108 static bool LogNativeStackOnOOM;
109 static int RuntimeErrorReportingLevel;
110 static int ForceErrorReportingLevel; // Bitmask ORed with the reporting level
112 static std::string ServerUser; // run server under this user account
113 static bool AllowRunAsRoot; // Allow running hhvm as root.
115 static int MaxSerializedStringSize;
116 static bool NoInfiniteRecursionDetection;
117 static bool AssertEmitted;
118 static int64_t NoticeFrequency; // output 1 out of NoticeFrequency notices
119 static int64_t WarningFrequency;
120 static int RaiseDebuggingFrequency;
121 static int64_t SerializationSizeLimit;
123 static std::string AccessLogDefaultFormat;
124 static std::map<std::string, AccessLogFileData> AccessLogs;
126 static std::string AdminLogFormat;
127 static std::string AdminLogFile;
128 static std::string AdminLogSymLink;
130 static std::map<std::string, AccessLogFileData> RPCLogs;
132 static std::string Host;
133 static std::string DefaultServerNameSuffix;
134 static std::string ServerType;
135 static std::string ServerIP;
136 static std::string ServerFileSocket;
137 static const std::string& GetServerPrimaryIPv4();
138 static const std::string& GetServerPrimaryIPv6();
139 static int ServerPort;
140 static int ServerPortFd;
141 static int ServerBacklog;
142 static int ServerConnectionLimit;
143 static int ServerThreadCount;
144 // Number of worker threads with stack partially on huge pages.
145 static int ServerHugeThreadCount;
146 static int QueuedJobsReleaseRate;
147 static int ServerWarmupThrottleRequestCount;
148 static int ServerThreadDropCacheTimeoutSeconds;
149 static int ServerThreadJobLIFOSwitchThreshold;
150 static int ServerThreadJobMaxQueuingMilliSeconds;
151 static bool AlwaysDecodePostDataDefault;
152 static bool ServerThreadDropStack;
153 static bool ServerHttpSafeMode;
154 static bool ServerStatCache;
155 static bool ServerFixPathInfo;
156 static bool ServerAddVaryEncoding;
157 static bool ServerLogSettingsOnStartup;
158 static std::vector<std::string> ServerWarmupRequests;
159 static std::string ServerCleanupRequest;
160 static int ServerInternalWarmupThreads;
161 static boost::container::flat_set<std::string> ServerHighPriorityEndPoints;
162 static bool ServerExitOnBindFail;
163 static int PageletServerThreadCount;
164 static int PageletServerHugeThreadCount;
165 static int PageletServerThreadDropCacheTimeoutSeconds;
166 static int PageletServerQueueLimit;
167 static bool PageletServerThreadDropStack;
169 static int RequestTimeoutSeconds;
170 static int PspTimeoutSeconds;
171 static int PspCpuTimeoutSeconds;
172 static int64_t MaxRequestAgeFactor;
173 static int64_t RequestMemoryMaxBytes;
174 // Threshold for aborting when host is low on memory.
175 static int64_t RequestMemoryOOMKillBytes;
176 // Approximate upper bound for thread heap that is backed by huge pages. This
177 // doesn't include the first slab colocated with thread stack, if any.
178 static int64_t RequestHugeMaxBytes;
179 static int64_t ImageMemoryMaxBytes;
180 static int ServerGracefulShutdownWait;
181 static bool ServerHarshShutdown;
182 static bool ServerEvilShutdown;
183 static bool ServerKillOnSIGTERM;
184 static bool ServerKillOnTimeout;
185 static int ServerPreShutdownWait;
186 static int ServerShutdownListenWait;
187 static int ServerShutdownEOMWait;
188 static int ServerPrepareToStopTimeout;
189 static int ServerPartialPostStatusCode;
190 // If `StopOldServer` is set, we try to stop the old server running
191 // on the local host earlier when we initialize, and we do not start
192 // serving requests until we are confident that the system can give
193 // the new server `ServerRSSNeededMb` resident memory, or till
194 // `OldServerWait` seconds passes after an effort to stop the old
195 // server is made.
196 static bool StopOldServer;
197 static int64_t ServerRSSNeededMb;
198 // Threshold of free memory below which the old server is shutdown immediately
199 // upon a memory pressure check.
200 static int64_t ServerCriticalFreeMb;
201 static int OldServerWait;
202 // The percentage of page caches that can be considered as free (0 -
203 // 100). This is experimental.
204 static int CacheFreeFactor;
205 static std::vector<std::string> ServerNextProtocols;
206 static bool ServerEnableH2C;
207 static int BrotliCompressionEnabled;
208 static int BrotliChunkedCompressionEnabled;
209 static int BrotliCompressionMode;
210 // Base 2 logarithm of the sliding window size. Range is 10-24.
211 static int BrotliCompressionLgWindowSize;
212 static int BrotliCompressionQuality;
213 static int GzipCompressionLevel;
214 static int GzipMaxCompressionLevel;
215 static std::string ForceCompressionURL;
216 static std::string ForceCompressionCookie;
217 static std::string ForceCompressionParam;
218 static bool EnableKeepAlive;
219 static bool ExposeHPHP;
220 static bool ExposeXFBServer;
221 static bool ExposeXFBDebug;
222 static std::string XFBDebugSSLKey;
223 static int ConnectionTimeoutSeconds;
224 static bool EnableOutputBuffering;
225 static std::string OutputHandler;
226 static bool ImplicitFlush;
227 static bool EnableEarlyFlush;
228 static bool ForceChunkedEncoding;
229 static int64_t MaxPostSize;
230 static int64_t LowestMaxPostSize;
231 static bool AlwaysPopulateRawPostData;
232 static int64_t UploadMaxFileSize;
233 static std::string UploadTmpDir;
234 static bool EnableFileUploads;
235 static bool EnableUploadProgress;
236 static int64_t MaxFileUploads;
237 static int Rfc1867Freq;
238 static std::string Rfc1867Prefix;
239 static std::string Rfc1867Name;
240 static bool ExpiresActive;
241 static int ExpiresDefault;
242 static std::string DefaultCharsetName;
243 static bool ForceServerNameToHeader;
244 static bool PathDebug;
245 static std::vector<std::shared_ptr<VirtualHost>> VirtualHosts;
246 static std::shared_ptr<IpBlockMap> IpBlocks;
247 static std::vector<std::shared_ptr<SatelliteServerInfo>>
248 SatelliteServerInfos;
250 // If a request has a body over this limit, switch to on-demand reading.
251 // -1 for no limit.
252 static int64_t RequestBodyReadLimit;
254 static bool EnableSSL;
255 static int SSLPort;
256 static int SSLPortFd;
257 static std::string SSLCertificateFile;
258 static std::string SSLCertificateKeyFile;
259 static std::string SSLCertificateDir;
260 static std::string SSLTicketSeedFile;
261 static bool TLSDisableTLS1_2;
262 static std::string TLSClientCipherSpec;
263 static bool EnableSSLWithPlainText;
265 static int XboxServerThreadCount;
266 static int XboxServerMaxQueueLength;
267 static int XboxServerPort;
268 static int XboxDefaultLocalTimeoutMilliSeconds;
269 static int XboxDefaultRemoteTimeoutSeconds;
270 static int XboxServerInfoMaxRequest;
271 static int XboxServerInfoDuration;
272 static std::string XboxServerInfoWarmupDoc;
273 static std::string XboxServerInfoReqInitFunc;
274 static std::string XboxServerInfoReqInitDoc;
275 static bool XboxServerInfoAlwaysReset;
276 static bool XboxServerLogInfo;
277 static std::string XboxProcessMessageFunc;
278 static std::string XboxPassword;
279 static std::set<std::string> XboxPasswords;
281 static std::string SourceRoot;
282 static std::vector<std::string> IncludeSearchPaths;
285 * Legal root directory expressions in an include expression. For example,
287 * include_once $PHP_ROOT . '/lib.php';
289 * Here, "$PHP_ROOT" is a legal include root. Stores what it resolves to.
291 * RuntimeOption::IncludeRoots["$PHP_ROOT"] = "";
292 * RuntimeOption::IncludeRoots["$LIB_ROOT"] = "lib";
294 static std::map<std::string, std::string> IncludeRoots;
295 static std::map<std::string, std::string> AutoloadRoots;
297 static std::string FileCache;
298 static std::string DefaultDocument;
299 static std::string ErrorDocument404;
300 static bool ForbiddenAs404;
301 static std::string ErrorDocument500;
302 static std::string FatalErrorMessage;
303 static std::string FontPath;
304 static bool EnableStaticContentFromDisk;
305 static bool EnableOnDemandUncompress;
306 static bool EnableStaticContentMMap;
308 static bool Utf8izeReplace;
310 static std::string RequestInitFunction;
311 static std::string RequestInitDocument;
312 static std::string AutoPrependFile;
313 static std::string AutoAppendFile;
315 static bool SafeFileAccess;
316 static std::vector<std::string> AllowedDirectories;
317 static std::set<std::string> AllowedFiles;
318 static hphp_string_imap<std::string> StaticFileExtensions;
319 static hphp_string_imap<std::string> PhpFileExtensions;
320 static std::set<std::string> ForbiddenFileExtensions;
321 static std::set<std::string> StaticFileGenerators;
322 static std::vector<std::shared_ptr<FilesMatch>> FilesMatches;
324 static bool WhitelistExec;
325 static bool WhitelistExecWarningOnly;
326 static std::vector<std::string> AllowedExecCmds;
328 static bool UnserializationWhitelistCheck;
329 static bool UnserializationWhitelistCheckWarningOnly;
330 static int64_t UnserializationBigMapThreshold;
332 static std::string TakeoverFilename;
333 static std::string AdminServerIP;
334 static int AdminServerPort;
335 static int AdminThreadCount;
336 static int AdminServerQueueToWorkerRatio;
337 static std::string AdminPassword;
338 static std::set<std::string> AdminPasswords;
339 static std::set<std::string> HashedAdminPasswords;
342 * Options related to reverse proxying. ProxyOriginRaw and ProxyPercentageRaw
343 * may be mutated by background threads and should only be read or written
344 * using the helper functions defined with HttpRequestHandler.
346 static std::string ProxyOriginRaw;
347 static int ProxyPercentageRaw;
348 static int ProxyRetry;
349 static bool UseServeURLs;
350 static std::set<std::string> ServeURLs;
351 static bool UseProxyURLs;
352 static std::set<std::string> ProxyURLs;
353 static std::vector<std::string> ProxyPatterns;
354 static bool AlwaysUseRelativePath;
356 static int HttpDefaultTimeout;
357 static int HttpSlowQueryThreshold;
359 static bool NativeStackTrace;
360 static bool ServerErrorMessage;
361 static bool RecordInput;
362 static bool ClearInputOnSuccess;
363 static std::string ProfilerOutputDir;
364 static std::string CoreDumpEmail;
365 static bool CoreDumpReport;
366 static std::string CoreDumpReportDirectory;
367 static std::string StackTraceFilename;
368 static int StackTraceTimeout;
369 static std::string RemoteTraceOutputDir;
370 static std::set<std::string, stdltistr> TraceFunctions;
372 static bool EnableStats;
373 static bool EnableAPCStats;
374 static bool EnableWebStats;
375 static bool EnableMemoryStats;
376 static bool EnableSQLStats;
377 static bool EnableSQLTableStats;
378 static bool EnableNetworkIOStatus;
379 static std::string StatsXSL;
380 static std::string StatsXSLProxy;
381 static int StatsSlotDuration;
382 static int StatsMaxSlot;
384 static bool EnableHotProfiler;
385 static int32_t ProfilerTraceBuffer;
386 static double ProfilerTraceExpansion;
387 static int32_t ProfilerMaxTraceBuffer;
389 static int64_t MaxRSS;
390 static int64_t MaxRSSPollingCycle;
391 static int64_t DropCacheCycle;
392 static int64_t MaxSQLRowCount;
393 static int64_t SocketDefaultTimeout;
394 static bool LockCodeMemory;
395 static int MaxArrayChain;
396 static bool WarnOnCollectionToArray;
397 static bool UseDirectCopy;
399 static bool DisableSmallAllocator;
401 static int PerAllocSampleF;
402 static int TotalAllocSampleF;
404 static std::map<std::string, std::string> ServerVariables;
406 static std::map<std::string, std::string> EnvVariables;
408 // The file name that is used by LightProcess to bind the socket
409 // is the following prefix followed by the pid of the hphp process.
410 static std::string LightProcessFilePrefix;
411 static int LightProcessCount;
413 // Eval options
414 static bool EnableHipHopSyntax;
415 static bool EnableHipHopExperimentalSyntax;
416 static bool EnableShortTags;
417 static bool EnableAspTags;
418 static bool EnableXHP;
419 static bool CheckParamTypeInvariance;
420 static bool EnableObjDestructCall;
421 static bool EnableEmitterStats;
422 static bool EnableIntrinsicsExtension;
423 static bool CheckSymLink;
424 static bool EnableArgsInBacktraces;
425 static bool EnableContextInErrorHandler;
426 static bool EnableZendSorting;
427 static bool EnableZendIniCompat;
428 static bool TimeoutsUseWallTime;
429 static bool CheckFlushOnUserClose;
430 static bool EvalAuthoritativeMode;
431 static bool IntsOverflowToInts;
432 static HackStrictOption StrictArrayFillKeys;
433 static HackStrictOption DisallowDynamicVarEnvFuncs;
434 static HackStrictOption IconvIgnoreCorrect;
435 static HackStrictOption MinMaxAllowDegenerate;
436 static bool LookForTypechecker;
437 static bool AutoTypecheck;
438 static bool AutoprimeGenerators;
439 static bool EnableHackcOnlyFeature;
440 static uint32_t EvalInitialStaticStringTableSize;
441 static uint32_t EvalInitialNamedEntityTableSize;
443 // ENABLED (1) selects PHP7 behavior.
444 static bool PHP7_DeprecationWarnings;
445 static bool PHP7_IntSemantics;
446 static bool PHP7_LTR_assign;
447 static bool PHP7_NoHexNumerics;
448 static bool PHP7_Builtins;
449 static bool PHP7_ScalarTypes;
450 static bool PHP7_EngineExceptions;
451 static bool PHP7_Substr;
452 static bool PHP7_UVS;
453 static bool PHP7_DisallowUnsafeCurlUploads;
455 static int64_t HeapSizeMB;
456 static int64_t HeapResetCountBase;
457 static int64_t HeapResetCountMultiple;
458 static int64_t HeapLowWaterMark;
459 static int64_t HeapHighWaterMark;
461 static int GetScannerType();
463 static std::set<std::string, stdltistr> DynamicInvokeFunctions;
464 static hphp_string_imap<Cell> ConstantFunctions;
466 static const uint32_t kPCREInitialTableSize = 96 * 1024;
468 static std::string ExtensionDir;
469 static std::vector<std::string> Extensions;
470 static std::string DynamicExtensionPath;
471 static std::vector<std::string> DynamicExtensions;
473 // Namespace aliases for the compiler
474 static std::map<std::string, std::string> AliasedNamespaces;
476 static std::vector<std::string> TzdataSearchPaths;
478 #define EVALFLAGS() \
479 /* F(type, name, defaultVal) */ \
480 /* \
481 * Maximum number of elements on the VM execution stack. \
482 */ \
483 F(uint64_t, VMStackElms, kEvalVMStackElmsDefault) \
484 /* \
485 * Initial space reserved for the global variable environment (in \
486 * number of global variables). \
487 */ \
488 F(uint32_t, VMInitialGlobalTableSize, \
489 kEvalVMInitialGlobalTableSizeDefault) \
490 F(bool, Jit, evalJitDefault()) \
491 F(bool, JitEvaledCode, true) \
492 F(bool, JitRequireWriteLease, false) \
493 F(uint64_t, JitRelocationSize, kJitRelocationSizeDefault) \
494 F(uint64_t, JitMatureSize, 125 << 20) \
495 F(bool, JitMatureAfterWarmup, true) \
496 F(double, JitMaturityExponent, 1.) \
497 F(bool, JitTimer, kJitTimerDefault) \
498 F(int, JitConcurrently, 1) \
499 F(int, JitThreads, 4) \
500 F(int, JitWorkerThreads, Process::GetCPUCount() / 2) \
501 F(int, JitLdimmqSpan, 8) \
502 /* Serialize the profile data to this file before retranslateAll */ \
503 F(string, JitSerializeTo, "") \
504 /* Deserialize the profile data from this file during process_init
505 and run retranslateAll if successful. Prepending the name with
506 a '+' char will cause hhvm to fail to start up if this is
507 unsuccessful. */ \
508 F(string, JitDeserializeFrom, "") \
509 F(bool, RecordSubprocessTimes, false) \
510 F(bool, AllowHhas, false) \
511 F(bool, DisassemblerSourceMapping, true) \
512 F(bool, DisassemblerDocComments, true) \
513 F(bool, DisassemblerPropDocComments, true) \
514 F(bool, LoadFilepathFromUnitCache, false) \
515 F(bool, ThrowOnCallByRefAnnotationMismatch, false) \
516 F(bool, WarnOnCallByRefAnnotationMismatch, false) \
517 /* Whether to use the embedded hackc binary */ \
518 F(bool, HackCompilerUseEmbedded, facebook) \
519 /* Whether to trust existing versions of the extracted compiler */ \
520 F(bool, HackCompilerTrustExtract, true) \
521 /* When using an embedded hackc, extract it to the ExtractPath or the
522 ExtractFallback. */ \
523 F(string, HackCompilerExtractPath, "/var/run/hackc_%{schema}") \
524 F(string, HackCompilerFallbackPath, "/tmp/hackc_%{schema}_XXXXXX") \
525 /* Arguments to run embedded hackc binary with */ \
526 F(string, HackCompilerArgs, hackCompilerArgsDefault()) \
527 /* Whether to use hh_single_compile by default if available. */ \
528 F(bool, HackCompilerDefault, hackCompilerEnableDefault()) \
529 /* The command to invoke to spawn hh_single_compile in server mode. */\
530 F(string, HackCompilerCommand, "") \
531 /* The number of hh_single_compile daemons to keep alive. */ \
532 F(uint64_t, HackCompilerWorkers, Process::GetCPUCount()) \
533 /* The number of times to retry after an infra failure communicating
534 with a compiler process. */ \
535 F(uint64_t, HackCompilerMaxRetries, 0) \
536 /* The number of times to reuse a single hh_single_compile daemons
537 before forcing a restart */ \
538 F(uint32_t, HackCompilerReset, 0) \
539 /* Whether to use an extern compiler to build systemlib */ \
540 F(bool, UseExternCompilerForSystemLib, true) \
541 /* Whether or not to fallback to hphpc if hh_single_compile fails for
542 any reason. */ \
543 F(bool, HackCompilerFallback, false) \
544 /* Whether to write verbose log messages to the error log and include
545 the hhas from failing units in the fatal error messages produced by
546 bad hh_single_compile units. */ \
547 F(bool, HackCompilerVerboseErrors, true) \
548 /* Whether the HackC compiler should inherit the compiler config of the
549 HHVM process that launches it. */ \
550 F(bool, HackCompilerInheritConfig, true) \
551 F(bool, EmitSwitch, true) \
552 F(bool, LogThreadCreateBacktraces, false) \
553 F(bool, FailJitPrologs, false) \
554 F(bool, UseHHBBC, !getenv("HHVM_DISABLE_HHBBC")) \
555 /* The following option enables the runtime checks for `this` typehints.
556 * There are 4 possible options:
557 * 0 - No checking of `this` typehints.
558 * 1 - Check `this` as hard `self` typehints.
559 * 2 - Check `this` typehints as soft `this` typehints
560 * 3 - Check `this` typehints as hard `this` typehints (unless explicitly
561 * soft). This is the only option which enable optimization in HHBBC.
562 */ \
563 F(int32_t, ThisTypeHintLevel, 0) \
564 /* CheckReturnTypeHints:
565 0 - No checks or enforcement for return type hints.
566 1 - Raises E_WARNING if a return type hint fails.
567 2 - Raises E_RECOVERABLE_ERROR if regular return type hint fails,
568 raises E_WARNING if soft return type hint fails. If a regular
569 return type hint fails, it's possible for execution to resume
570 normally if the user error handler doesn't throw and returns
571 something other than boolean false.
572 3 - Same as 2, except if a regular type hint fails the runtime
573 will not allow execution to resume normally; if the user
574 error handler returns something other than boolean false,
575 the runtime will throw a fatal error. */ \
576 F(int32_t, CheckReturnTypeHints, 2) \
577 /* Whether or not to assume that VerifyParamType instructions must
578 throw if the parameter does not match the associated type
579 constraint. This changes program behavior because parameter type
580 hint validation is normally a recoverable fatal. When this option
581 is on, hhvm will fatal if the error handler tries to recover in
582 this situation.
583 1) In repo-mode, we only set this option to hphpc, and serialize
584 it in Repo::GlobalData::HardTypeHints. Subsequent invocations
585 to hhbbc/hhvm runtime will only load it from the GlobalData.
586 2) In non-repo mode, we set this option to the runtime as usual.
587 3) Both HHBBC and the runtime should query only this option
588 instead of the GlobalData. */ \
589 F(bool, HardTypeHints, RepoAuthoritative) \
590 F(bool, PromoteEmptyObject, !EnableHipHopSyntax) \
591 F(bool, AllowObjectDestructors, !one_bit_refcount) \
592 F(bool, AllDestructorsOptional, false) \
593 F(bool, AllowScopeBinding, true) \
594 F(bool, JitNoGdb, true) \
595 F(bool, SpinOnCrash, false) \
596 F(uint32_t, DumpRingBufferOnCrash, 0) \
597 F(bool, PerfPidMap, true) \
598 F(bool, PerfPidMapIncludeFilePath, true) \
599 F(bool, PerfJitDump, false) \
600 F(string, PerfJitDumpDir, "/tmp") \
601 F(bool, PerfDataMap, false) \
602 F(bool, KeepPerfPidMap, false) \
603 F(int32_t, PerfRelocate, 0) \
604 F(uint32_t, ThreadTCMainBufferSize, 6 << 20) \
605 F(uint32_t, ThreadTCColdBufferSize, 6 << 20) \
606 F(uint32_t, ThreadTCFrozenBufferSize,4 << 20) \
607 F(uint32_t, ThreadTCDataBufferSize, 256 << 10) \
608 F(uint32_t, JitTargetCacheSize, 64 << 20) \
609 F(uint32_t, HHBCArenaChunkSize, 10 << 20) \
610 F(bool, ProfileBC, false) \
611 F(bool, ProfileHeapAcrossRequests, false) \
612 F(bool, ProfileHWEnable, true) \
613 F(string, ProfileHWEvents, std::string("")) \
614 F(bool, ProfileHWExcludeKernel, false) \
615 F(bool, ProfileHWStructLog, false) \
616 F(int32_t, ProfileHWExportInterval, 30) \
617 F(bool, JitAlwaysInterpOne, false) \
618 F(int32_t, JitNopInterval, 0) \
619 F(uint32_t, JitMaxTranslations, 10) \
620 F(uint32_t, JitMaxProfileTranslations, 30) \
621 F(uint32_t, JitTraceletGuardsLimit, 5) \
622 F(uint64_t, JitGlobalTranslationLimit, -1) \
623 F(int64_t, JitMaxRequestTranslationTime, -1) \
624 F(uint32_t, JitMaxRegionInstrs, 1347) \
625 F(uint32_t, JitProfileInterpRequests, kDefaultProfileInterpRequests) \
626 F(uint32_t, JitMaxAwaitAllUnroll, 8) \
627 F(bool, JitProfileWarmupRequests, false) \
628 F(uint32_t, NumSingleJitRequests, nsjrDefault()) \
629 F(uint32_t, JitProfileRequests, profileRequestsDefault()) \
630 F(uint32_t, JitProfileBCSize, profileBCSizeDefault()) \
631 F(uint32_t, JitResetProfCountersRequest, resetProfCountersDefault()) \
632 F(uint32_t, JitRetranslateAllRequest, retranslateAllRequestDefault()) \
633 F(uint32_t, JitRetranslateAllSeconds, retranslateAllSecondsDefault()) \
634 F(double, JitLayoutHotThreshold, 0.05) \
635 F(int32_t, JitLayoutMainFactor, 1000) \
636 F(int32_t, JitLayoutColdFactor, 5) \
637 F(bool, JitProfileRecord, false) \
638 F(uint32_t, GdbSyncChunks, 128) \
639 F(bool, JitKeepDbgFiles, false) \
640 /* despite the unfortunate name, this enables function renaming and
641 * interception in the interpreter as well as the jit, and also
642 * implies all functions may be used with fb_intercept */ \
643 F(bool, JitEnableRenameFunction, EvalJitEnableRenameFunction) \
644 F(bool, JitUseVtuneAPI, false) \
646 F(bool, JitDisabledByHphpd, false) \
647 F(bool, JitPseudomain, true) \
648 F(uint32_t, JitWarmupStatusBytes, ((25 << 10) + 1)) \
649 F(uint32_t, JitWarmupMaxCodeGenRate, 20000) \
650 F(uint32_t, JitWarmupRateSeconds, 64) \
651 F(uint32_t, JitWriteLeaseExpiration, 1500) /* in microseconds */ \
652 F(int, JitRetargetJumps, 1) \
653 F(bool, HHIRLICM, false) \
654 F(bool, HHIRSimplification, true) \
655 F(bool, HHIRGenOpts, true) \
656 F(bool, HHIRRefcountOpts, true) \
657 F(bool, HHIREnableGenTimeInlining, true) \
658 F(uint32_t, HHIRInliningVasmCostLimit, 175) \
659 F(uint32_t, HHIRInliningMinVasmCostLimit, 100) \
660 F(uint32_t, HHIRInliningMaxVasmCostLimit, 400) \
661 F(double, HHIRInliningVasmCallerExp, .5) \
662 F(double, HHIRInliningVasmCalleeExp, .5) \
663 F(uint32_t, HHIRInliningMaxReturnDecRefs, 12) \
664 F(uint32_t, HHIRInliningMaxReturnLocals, 20) \
665 F(bool, HHIRInlineFrameOpts, true) \
666 F(bool, HHIRPartialInlineFrameOpts, true) \
667 F(bool, HHIRInlineSingletons, true) \
668 F(std::string, InlineRegionMode, "both") \
669 F(bool, HHIRGenerateAsserts, false) \
670 F(bool, HHIRDeadCodeElim, true) \
671 F(bool, HHIRGlobalValueNumbering, true) \
672 F(bool, HHIRPredictionOpts, true) \
673 F(bool, HHIRMemoryOpts, true) \
674 F(bool, AssemblerFoldDefaultValues, true) \
675 F(uint32_t, HHIRLoadElimMaxIters, 10) \
676 F(bool, HHIRStorePRE, true) \
677 F(bool, HHIROutlineGenericIncDecRef, true) \
678 F(double, HHIRMixedArrayProfileThreshold, 0.8554) \
679 /* Register allocation flags */ \
680 F(bool, HHIREnablePreColoring, true) \
681 F(bool, HHIREnableCoalescing, true) \
682 F(bool, HHIRAllocSIMDRegs, true) \
683 F(bool, HHIRStressSpill, false) \
684 /* Region compiler flags */ \
685 F(string, JitRegionSelector, regionSelectorDefault()) \
686 F(bool, JitPGO, pgoDefault()) \
687 F(string, JitPGORegionSelector, "hotcfg") \
688 F(uint64_t, JitPGOThreshold, pgoThresholdDefault()) \
689 F(bool, JitPGOOnly, false) \
690 F(bool, JitPGOHotOnly, false) \
691 F(bool, JitPGOUsePostConditions, true) \
692 F(uint32_t, JitPGOUnlikelyIncRefCountedPercent, 2) \
693 F(uint32_t, JitPGOUnlikelyIncRefIncrementPercent, 5) \
694 F(uint32_t, JitPGOUnlikelyDecRefReleasePercent, 5) \
695 F(uint32_t, JitPGOUnlikelyDecRefCountedPercent, 2) \
696 F(uint32_t, JitPGOUnlikelyDecRefPersistPercent, 5) \
697 F(uint32_t, JitPGOUnlikelyDecRefSurvivePercent, 5) \
698 F(uint32_t, JitPGOReleaseVVMinPercent, 8) \
699 F(bool, JitPGOArrayGetStress, false) \
700 F(uint32_t, JitPGOMinBlockCountPercent, 0) \
701 F(double, JitPGOMinArcProbability, 0.0) \
702 F(uint32_t, JitPGOMaxFuncSizeDupBody, 80) \
703 F(uint32_t, JitPGORelaxPercent, 100) \
704 F(uint32_t, JitPGORelaxUncountedToGenPercent, 20) \
705 F(uint32_t, JitPGORelaxCountedToGenPercent, 75) \
706 F(bool, JitPGODumpCallGraph, false) \
707 F(bool, JitPGORacyProfiling, false) \
708 F(uint64_t, FuncCountHint, 10000) \
709 F(uint64_t, PGOFuncCountHint, 1000) \
710 F(uint32_t, HotFuncCount, 4100) \
711 F(bool, RegionRelaxGuards, true) \
712 /* DumpBytecode =1 dumps user php, =2 dumps systemlib & user php */ \
713 F(int32_t, DumpBytecode, 0) \
714 /* DumpHhas =1 dumps user php, =2 dumps systemlib & user php */ \
715 F(int32_t, DumpHhas, 0) \
716 F(string, DumpHhasToFile, "") \
717 F(bool, DisableHphpcOpts, false) \
718 F(bool, DisableErrorHandler, false) \
719 F(bool, DumpTC, false) \
720 F(string, DumpTCPath, "/tmp") \
721 F(bool, DumpTCAnchors, false) \
722 F(uint32_t, DumpIR, 0) \
723 F(bool, DumpTCAnnotationsForAllTrans,debug) \
724 F(uint32_t, DumpRegion, 0) \
725 F(bool, DumpAst, false) \
726 F(bool, DumpTargetProfiles, false) \
727 F(bool, MapTgtCacheHuge, false) \
728 F(uint32_t, MaxHotTextHugePages, hugePagesSoundNice() ? 8 : 0) \
729 F(int32_t, MaxLowMemHugePages, hugePagesSoundNice() ? 8 : 0) \
730 F(uint32_t, Num1GPagesForSlabs, 0) \
731 F(uint32_t, Num2MPagesForSlabs, 0) \
732 F(bool, LowStaticArrays, true) \
733 F(bool, UncountedMixedArrayHuge, true) \
734 F(bool, UncountedStringHuge, true) \
735 F(int64_t, HeapPurgeWindowSize, 5 * 1000000) \
736 F(uint64_t, HeapPurgeThreshold, 128 * 1024 * 1024) \
737 /* GC Options: See heap-collect.cpp for more details */ \
738 F(bool, EagerGC, eagerGcDefault()) \
739 F(bool, FilterGCPoints, true) \
740 F(bool, Quarantine, eagerGcDefault()) \
741 F(uint32_t, GCSampleRate, 0) \
742 F(int64_t, GCMinTrigger, 64L<<20) \
743 F(double, GCTriggerPct, 0.5) \
744 F(bool, GCForAPC, false) \
745 F(int64_t, GCForAPCTrigger, 1024*1024*1024) \
746 F(bool, TwoPhaseGC, false) \
747 F(bool, EnableGC, enableGcDefault()) \
748 /* End of GC Options */ \
749 F(bool, RaiseMissingThis, !EnableHipHopSyntax) \
750 F(bool, QuoteEmptyShellArg, !EnableHipHopSyntax) \
751 F(bool, Verify, (getenv("HHVM_VERIFY") || \
752 !EvalHackCompilerCommand.empty())) \
753 F(bool, VerifyOnly, false) \
754 F(uint32_t, StaticContentsLogRate, 100) \
755 F(uint32_t, LogUnitLoadRate, 0) \
756 F(uint32_t, MaxDeferredErrors, 50) \
757 F(bool, JitAlignMacroFusionPairs, alignMacroFusionPairs()) \
758 F(uint32_t, SerDesSampleRate, 0) \
759 F(int, SimpleJsonMaxLength, 2 << 20) \
760 F(uint32_t, JitSampleRate, 0) \
761 /* Log the sizes and metadata for all translations in the TC broken
762 * down by function and inclusive/exclusive size for inlined regions.
763 * When set to "" TC size data will be sampled on a per function basis
764 * as determined by JitSampleRate. When set to a non-empty string all
765 * translations will be logged, and run_key column will be logged with
766 * the value of this option. */ \
767 F(string, JitLogAllInlineRegions, "") \
768 F(uint32_t, JitFilterLease, 1) \
769 F(bool, DisableSomeRepoAuthNotices, true) \
770 F(uint32_t, PCRETableSize, kPCREInitialTableSize) \
771 F(uint64_t, PCREExpireInterval, 2 * 60 * 60) \
772 F(string, PCRECacheType, std::string("static")) \
773 F(bool, EnableCompactBacktrace, true) \
774 F(bool, EnableNuma, ServerExecutionMode()) \
775 F(bool, EnableNumaLocal, ServerExecutionMode()) \
776 /* Use 1G pages for jemalloc metadata. */ \
777 F(bool, EnableArenaMetadata1GPage, false) \
778 /* Use 1G pages for jemalloc metadata (NUMA arenas if applicable). */ \
779 F(bool, EnableNumaArenaMetadata1GPage, false) \
780 /* Reserved space on 1G pages for jemalloc metadata (arena0). */ \
781 F(uint64_t, ArenaMetadataReservedSize, 216 << 20) \
782 F(bool, EnableCallBuiltin, true) \
783 F(bool, EnableReusableTC, reuseTCDefault()) \
784 F(bool, LogServerRestartStats, false) \
785 F(uint32_t, ReusableTCPadding, 128) \
786 F(int64_t, StressUnitCacheFreq, 0) \
787 F(int64_t, PerfWarningSampleRate, 1) \
788 F(int64_t, FunctionCallSampleRate, 0) \
789 F(double, InitialLoadFactor, 1.0) \
790 /* Raise notices on various array operations which may present \
791 * compatibility issues with Hack arrays. \
793 * The various *Notices options independently control separate \
794 * subsets of notices. The Check* options are subordinate to the \
795 * HackArrCompatNotices option, and control whether various runtime
796 * checks are made; they do not affect any optimizations. */ \
797 F(bool, HackArrCompatNotices, false) \
798 F(bool, HackArrCompatCheckIntishCast, false) \
799 F(bool, HackArrCompatCheckRefBind, false) \
800 F(bool, HackArrCompatCheckFalseyPromote, false) \
801 F(bool, HackArrCompatCheckCompare, false) \
802 F(bool, HackArrCompatCheckMisc, false) \
803 F(bool, HackArrCompatIsArrayNotices, false) \
804 F(bool, HackArrCompatPromoteNotices, false) \
805 F(bool, HackArrCompatTypeHintNotices, false) \
806 F(bool, HackArrCompatDVCmpNotices, false) \
807 F(bool, HackArrCompatSerializeNotices, false) \
808 F(bool, HackArrDVArrs, false) \
809 /* Switches on miscellaneous junk. */ \
810 F(bool, CreateInOutWrapperFunctions, true) \
811 F(bool, ReffinessInvariance, false) \
812 F(bool, NoticeOnBuiltinDynamicCalls, false) \
813 /* \
814 * Control dynamic calls to functions which haven't opted into being called \
815 * that way. \
817 * 0 - Nothing \
818 * 1 - Warn \
819 * 2 - Throw exception \
821 */ \
822 F(int32_t, ForbidDynamicCalls, 0) \
823 F(std::string, PreludePath, "") \
824 /* Use the CallM/RetM ABI to return multiple values via the stack for \
825 inout functions */ \
826 F(bool, UseMSRVForInOut, true) \
827 F(bool, HHIRGenerateCallM, true) \
828 F(bool, HHIRGenerateRetM, true) \
829 F(std::vector<std::string>, IniGetHide, std::vector<std::string>()) \
830 F(std::string, UseRemoteUnixServer, "no") \
831 F(std::string, UnixServerPath, "") \
832 F(uint32_t, UnixServerWorkers, Process::GetCPUCount()) \
833 F(bool, UnixServerQuarantineApc, false) \
834 F(bool, UnixServerQuarantineUnits, false) \
835 F(bool, UnixServerVerifyExeAccess, false) \
836 F(bool, UnixServerFailWhenBusy, false) \
837 F(std::vector<std::string>, UnixServerAllowedUsers, \
838 std::vector<std::string>()) \
839 F(std::vector<std::string>, UnixServerAllowedGroups, \
840 std::vector<std::string>()) \
841 /* Options for testing */ \
842 F(bool, TrashFillOnRequestExit, false) \
843 /****************** \
844 | ARM Options. | \
845 *****************/ \
846 F(bool, JitArmLse, armLseDefault()) \
847 /****************** \
848 | PPC64 Options. | \
849 *****************/ \
850 /* Minimum immediate size to use TOC */ \
851 F(uint16_t, PPC64MinTOCImmSize, 64) \
852 /* Relocation features. Use with care on production */ \
853 /* Allow a Far branch be converted to a Near branch. */ \
854 F(bool, PPC64RelocationShrinkFarBranches, false) \
855 /* Remove nops from a Far branch. */ \
856 F(bool, PPC64RelocationRemoveFarBranchesNops, true) \
857 /******************** \
858 | Profiling flags. | \
859 ********************/ \
860 /* Whether to maintain the address-to-VM-object mapping. */ \
861 F(bool, EnableReverseDataMap, true) \
862 /* Turn on perf-mem-event sampling roughly every this many requests. \
863 * To maintain the same overall sampling rate, the ratio between the \
864 * request and sample frequencies should be kept constant. */ \
865 F(uint32_t, PerfMemEventRequestFreq, 0) \
866 /* Sample this many memory instructions per second. This should be \
867 * kept low to avoid the risk of collecting a sample while we're \
868 * processing a previous sample. */ \
869 F(uint32_t, PerfMemEventSampleFreq, 80) \
870 /* Sampling frequency for TC branch profiling. */ \
871 F(uint32_t, ProfBranchSampleFreq, 0) \
872 /* Sampling frequency for profiling packed array accesses. */ \
873 F(uint32_t, ProfPackedArraySampleFreq, 0) \
874 /* */
876 private:
877 using string = std::string;
879 // Custom settings. This should be accessed via the GetServerCustomSetting
880 // APIs.
881 static std::map<std::string, std::string> CustomSettings;
883 public:
884 #define F(type, name, unused) \
885 static type Eval ## name;
886 EVALFLAGS()
887 #undef F
889 static bool RecordCodeCoverage;
890 static std::string CodeCoverageOutputFile;
892 // Repo (hhvm bytecode repository) options
893 static std::string RepoLocalMode;
894 static std::string RepoLocalPath;
895 static std::string RepoCentralPath;
896 static int32_t RepoCentralFileMode;
897 static std::string RepoCentralFileUser;
898 static std::string RepoCentralFileGroup;
899 static bool RepoAllowFallbackPath;
900 static std::string RepoEvalMode;
901 static std::string RepoJournal;
902 static bool RepoCommit;
903 static bool RepoDebugInfo;
904 static bool RepoAuthoritative;
905 static bool RepoPreload;
906 static int64_t RepoLocalReadaheadRate;
907 static bool RepoLocalReadaheadConcurrent;
909 // pprof/hhprof options
910 static bool HHProfEnabled;
911 static bool HHProfActive;
912 static bool HHProfAccum;
913 static bool HHProfRequest;
914 static bool TrackPerUnitMemory;
916 // Sandbox options
917 static bool SandboxMode;
918 static std::string SandboxPattern;
919 static std::string SandboxHome;
920 static std::string SandboxFallback;
921 static std::string SandboxConfFile;
922 static std::map<std::string, std::string> SandboxServerVariables;
923 static bool SandboxFromCommonRoot;
924 static std::string SandboxDirectoriesRoot;
925 static std::string SandboxLogsRoot;
927 // Debugger options
928 static bool EnableHphpdDebugger;
929 static bool EnableVSDebugger;
930 static int VSDebuggerListenPort;
931 static bool VSDebuggerNoWait;
932 static bool EnableDebuggerColor;
933 static bool EnableDebuggerPrompt;
934 static bool EnableDebuggerServer;
935 static bool EnableDebuggerUsageLog;
936 static bool DebuggerDisableIPv6;
937 static std::string DebuggerServerIP;
938 static int DebuggerServerPort;
939 static int DebuggerDefaultRpcPort;
940 static std::string DebuggerDefaultRpcAuth;
941 static std::string DebuggerRpcHostDomain;
942 static int DebuggerDefaultRpcTimeout;
943 static std::string DebuggerDefaultSandboxPath;
944 static std::string DebuggerStartupDocument;
945 static int DebuggerSignalTimeout;
946 static std::string DebuggerAuthTokenScriptBin;
948 // Mail options
949 static std::string SendmailPath;
950 static std::string MailForceExtraParameters;
952 // preg stack depth and debug support options
953 static int64_t PregBacktraceLimit;
954 static int64_t PregRecursionLimit;
955 static bool EnablePregErrorLog;
957 // SimpleXML options
958 static bool SimpleXMLEmptyNamespaceMatchesAll;
960 // Cookie options
961 static bool AllowDuplicateCookies;
963 #ifdef FACEBOOK
964 // fb303 server
965 static bool EnableFb303Server;
966 static int Fb303ServerPort;
967 static int Fb303ServerThreadStackSizeMb;
968 static int Fb303ServerWorkerThreads;
969 static int Fb303ServerPoolThreads;
970 #endif
972 // Xenon options
973 static double XenonPeriodSeconds;
974 static bool XenonForceAlwaysOn;
975 static bool XenonTraceUnitLoad;
976 static std::string XenonStructLogDest;
978 static_assert(sizeof(RuntimeOption) == 1, "no instance variables");
980 ///////////////////////////////////////////////////////////////////////////////
983 #endif // incl_HPHP_RUNTIME_OPTION_H_