forked from facebook/hhvm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathruntime-option.cpp
2816 lines (2559 loc) · 111 KB
/
runtime-option.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| [email protected] so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
#include "hphp/runtime/base/runtime-option.h"
#include "hphp/parser/scanner.h"
#include "hphp/runtime/base/apc-file-storage.h"
#include "hphp/runtime/base/autoload-handler.h"
#include "hphp/runtime/base/builtin-functions.h"
#include "hphp/runtime/base/config.h"
#include "hphp/runtime/base/crash-reporter.h"
#include "hphp/runtime/base/execution-context.h"
#include "hphp/runtime/base/extended-logger.h"
#include "hphp/runtime/base/file-util-defs.h"
#include "hphp/runtime/base/file-util.h"
#include "hphp/runtime/base/hphp-system.h"
#include "hphp/runtime/base/ini-setting.h"
#include "hphp/runtime/base/init-fini-node.h"
#include "hphp/runtime/base/memory-manager.h"
#include "hphp/runtime/base/preg.h"
#include "hphp/runtime/base/request-info.h"
#include "hphp/runtime/base/static-string-table.h"
#include "hphp/runtime/base/zend-url.h"
#include "hphp/runtime/ext/extension-registry.h"
#include "hphp/runtime/server/access-log.h"
#include "hphp/runtime/server/cli-server.h"
#include "hphp/runtime/server/files-match.h"
#include "hphp/runtime/server/satellite-server.h"
#include "hphp/runtime/server/virtual-host.h"
#include "hphp/runtime/vm/jit/code-cache.h"
#include "hphp/runtime/vm/jit/mcgen-translate.h"
#include "hphp/runtime/vm/treadmill.h"
#include "hphp/util/arch.h"
#include "hphp/util/atomic-vector.h"
#include "hphp/util/build-info.h"
#include "hphp/util/cpuid.h"
#include "hphp/util/current-executable.h" // @donotremove
#include "hphp/util/file-cache.h"
#include "hphp/util/gzip.h"
#include "hphp/util/hardware-counter.h"
#include "hphp/util/hdf.h"
#include "hphp/util/hphp-config.h"
#include "hphp/util/hugetlb.h"
#include "hphp/util/log-file-flusher.h"
#include "hphp/util/logger.h"
#include "hphp/util/network.h"
#include "hphp/util/numa.h"
#include "hphp/util/process.h"
#include "hphp/util/service-data.h"
#include "hphp/util/stack-trace.h"
#include "hphp/util/text-util.h"
#include "hphp/util/zstd.h"
#include "hphp/zend/zend-string.h"
#include <cstdint>
#include <libgen.h>
#include <limits>
#include <map>
#include <memory>
#include <set>
#include <stdexcept>
#include <vector>
#include <boost/algorithm/string/predicate.hpp>
#include <folly/CPortability.h>
#include <folly/FileUtil.h>
#include <folly/String.h>
#include <folly/portability/SysResource.h>
#include <folly/portability/SysTime.h>
#include <folly/portability/Unistd.h>
#if defined (__linux__) && defined (__aarch64__)
#include <sys/auxv.h>
#include <asm/hwcap.h>
#endif
#ifdef __APPLE__
#define st_mtim st_mtimespec
#define st_ctim st_ctimespec
#endif
namespace HPHP {
///////////////////////////////////////////////////////////////////////////////
bool RepoOptions::s_init{false};
RepoOptions RepoOptions::s_defaults;
namespace {
#ifdef FACEBOOK
const static bool s_PHP7_default = false;
#else
const static bool s_PHP7_default = true;
#endif
// PHP7 is off by default (false). s_PHP7_master is not a static member of
// RuntimeOption so that it's private to this file and not exposed -- it's a
// master switch only, and not to be used for any actual gating, use the more
// granular options instead. (It can't be a local since Config::Bind will take
// and store a pointer to it.)
static bool s_PHP7_master = s_PHP7_default;
std::vector<std::string> s_RelativeConfigs;
////////////////////////////////////////////////////////////////////////////////
char mangleForKey(bool b) { return b ? '1' : '0'; }
std::string mangleForKey(const RepoOptions::StringMap& map) {
std::string s;
s += folly::to<std::string>(map.size());
s += '\0';
for (auto& par : map) {
s += par.first + '\0' + par.second + '\0';
}
return s;
}
std::string mangleForKey(std::string s) { return s; }
void hdfExtract(const Hdf& hdf, const char* name, bool& val, bool dv) {
val = hdf[name].configGetBool(dv);
}
void hdfExtract(
const Hdf& hdf,
const char* name,
RepoOptions::StringMap& map,
const RepoOptions::StringMap& dv
) {
Hdf config = hdf[name];
if (config.exists() && !config.isEmpty()) config.configGet(map);
else map = dv;
}
void hdfExtract(
const Hdf& hdf,
const char* name,
std::string& val,
std::string dv
) {
val = hdf[name].configGetString(dv);
}
folly::dynamic toIniValue(bool b) {
return b ? "1" : "0";
}
folly::dynamic toIniValue(const RepoOptions::StringMap& map) {
folly::dynamic obj = folly::dynamic::object();
for (auto& kv : map) {
obj[kv.first] = kv.second;
}
return obj;
}
folly::dynamic toIniValue(const std::string& str) {
return str;
}
struct CachedRepoOptions {
CachedRepoOptions() = default;
explicit CachedRepoOptions(RepoOptions&& opts)
: options(new RepoOptions(std::move(opts)))
{}
CachedRepoOptions(const CachedRepoOptions& opts)
: options(nullptr)
{
if (auto o = opts.options.load(std::memory_order_relaxed)) {
options.store(new RepoOptions(*o), std::memory_order_relaxed);
}
}
~CachedRepoOptions() {
Treadmill::enqueue([opt = options.exchange(nullptr)] { delete opt; });
}
CachedRepoOptions& operator=(const CachedRepoOptions& opts) {
auto const o = opts.options.load(std::memory_order_relaxed);
auto const old = options.exchange(o ? new RepoOptions(*o) : nullptr);
if (old) Treadmill::enqueue([old] { delete old; });
return *this;
}
static bool isChanged(const RepoOptions* opts, struct stat s) {
auto const o = opts->stat();
return
s.st_mtim.tv_sec != o.st_mtim.tv_sec ||
s.st_mtim.tv_nsec != o.st_mtim.tv_nsec ||
s.st_ctim.tv_sec != o.st_ctim.tv_sec ||
s.st_ctim.tv_nsec != o.st_ctim.tv_nsec ||
s.st_dev != o.st_dev ||
s.st_ino != o.st_ino;
}
const RepoOptions* update(RepoOptions&& opts) const {
auto const val = new RepoOptions(std::move(opts));
auto const old = options.exchange(val);
if (old) Treadmill::enqueue([old] { delete old; });
return val;
}
const RepoOptions* fetch(struct stat st) const {
auto const opts = options.load(std::memory_order_relaxed);
return opts && !isChanged(opts, st) ? opts : nullptr;
}
mutable std::atomic<RepoOptions*> options{nullptr};
};
using RepoOptionCache = tbb::concurrent_hash_map<
std::string,
CachedRepoOptions,
stringHashCompare
>;
RepoOptionCache s_repoOptionCache;
template<class F>
bool walkDirTree(std::string fpath, F func) {
const char* filename = ".hhvmconfig.hdf";
do {
auto const off = fpath.rfind('/');
if (off == std::string::npos) return false;
fpath.resize(off);
fpath += '/';
fpath += filename;
if (func(fpath)) return true;
fpath.resize(off);
} while (!fpath.empty() && fpath != "/");
return false;
}
RDS_LOCAL(std::string, s_lastSeenRepoConfig);
}
const RepoOptions& RepoOptions::forFile(const char* path) {
if (!RuntimeOption::EvalEnablePerRepoOptions) return defaults();
std::string fpath{path};
if (boost::starts_with(fpath, "/:")) return defaults();
// Fast path: we have an active request and it has cached a RepoOptions
// which has not been modified. This only works when the runtime option
// Eval.FatalOnParserOptionMismatch is set. It can cause us to miss out on
// configs that were added between the current directory and the source file.
// (Loading these configs would result in a fatal anyway with this option)
if (!g_context.isNull()) {
if (auto const opts = g_context->getRepoOptionsForRequest()) {
// If path() is empty we have the default() options, which means we have
// negatively cached the existance of a .hhvmconfig.hdf for this request.
if (opts->path().empty()) return *opts;
if (boost::starts_with(fpath, opts->path())) {
struct stat st;
if (lstat(opts->path().data(), &st) == 0) {
if (!CachedRepoOptions::isChanged(opts, st)) return *opts;
}
}
}
}
auto const set = [&] (
RepoOptionCache::const_accessor& rpathAcc,
const std::string& path,
const struct stat& st
) -> const RepoOptions* {
*s_lastSeenRepoConfig = path;
if (auto const opts = rpathAcc->second.fetch(st)) {
return opts;
}
RepoOptions newOpts{path.data()};
newOpts.m_stat = st;
return rpathAcc->second.update(std::move(newOpts));
};
auto const test = [&] (const std::string& path) -> const RepoOptions* {
struct stat st;
RepoOptionCache::const_accessor rpathAcc;
if (!s_repoOptionCache.find(rpathAcc, path)) return nullptr;
if (lstat(path.data(), &st) != 0) {
s_repoOptionCache.erase(rpathAcc);
return nullptr;
}
return set(rpathAcc, path, st);
};
const RepoOptions* ret{nullptr};
// WARNING: when Eval.CachePerRepoOptionsPath we cache the last used path for
// RepoOptions per thread, and while we will detect changes to this
// file, and do a rescan in the event that it is deleted or doesn't
// match the current file being loaded, we will miss out on new
// configs that may be added. Since we expect to see a single config
// per repository we expect that this will be a reasonably safe,
// optimization.
if (RuntimeOption::EvalCachePerRepoOptionsPath) {
if (!s_lastSeenRepoConfig->empty() &&
boost::starts_with(fpath, *s_lastSeenRepoConfig)) {
if (auto const r = test(*s_lastSeenRepoConfig)) return *r;
s_lastSeenRepoConfig->clear();
}
// If the last seen path isn't set yet or is no longer accurate try checking
// other cached paths before falling back to the filesystem.
walkDirTree(fpath, [&] (const std::string& path) {
return (ret = test(path)) != nullptr;
});
}
if (ret) return *ret;
walkDirTree(fpath, [&] (const std::string& path) {
struct stat st;
if (lstat(path.data(), &st) != 0) return false;
RepoOptionCache::const_accessor rpathAcc;
s_repoOptionCache.insert(rpathAcc, path);
ret = set(rpathAcc, path, st);
return true;
});
return ret ? *ret : defaults();
}
std::string RepoOptions::cacheKeyRaw() const {
return std::string("")
#define N(_, n, ...) + mangleForKey(n)
#define P(_, n, ...) + mangleForKey(n)
#define H(_, n, ...) + mangleForKey(n)
#define E(_, n, ...) + mangleForKey(n)
PARSERFLAGS()
AUTOLOADFLAGS();
#undef N
#undef P
#undef H
#undef E
}
std::string RepoOptions::cacheKeySha1() const {
return string_sha1(cacheKeyRaw());
}
std::string RepoOptions::toJSON() const {
return folly::toJson(toDynamic());
}
folly::dynamic RepoOptions::toDynamic() const {
folly::dynamic json = folly::dynamic::object();
#define OUT(key, var) \
{ \
auto const ini_name = Config::IniName(key); \
auto const ini_value = toIniValue(var); \
folly::dynamic entry = folly::dynamic::object(); \
entry["global_value"] = ini_value; \
entry["local_value"] = ini_value; \
entry["access"] = 4; \
json[ini_name] = entry; \
}
#define N(_, n, ...) OUT(#n, n)
#define P(_, n, ...) OUT("PHP7." #n, n)
#define H(_, n, ...) OUT("Hack.Lang." #n, n)
#define E(_, n, ...) OUT("Eval." #n, n)
PARSERFLAGS()
AUTOLOADFLAGS();
#undef N
#undef P
#undef H
#undef E
#undef OUT
return json;
}
bool RepoOptions::operator==(const RepoOptions& o) const {
#define N(_, n, ...) if (n != o.n) return false;
#define P(_, n, ...) if (n != o.n) return false;
#define H(_, n, ...) if (n != o.n) return false;
#define E(_, n, ...) if (n != o.n) return false;
PARSERFLAGS()
AUTOLOADFLAGS();
#undef N
#undef P
#undef H
#undef E
return true;
}
const RepoOptions& RepoOptions::defaults() {
always_assert(s_init);
return s_defaults;
}
void RepoOptions::filterNamespaces() {
for (auto it = AliasedNamespaces.begin(); it != AliasedNamespaces.end(); ) {
if (!is_valid_class_name(it->second)) {
Logger::Warning("Skipping invalid AliasedNamespace %s\n",
it->second.c_str());
it = AliasedNamespaces.erase(it);
continue;
}
while (it->second.size() && it->second[0] == '\\') {
it->second = it->second.substr(1);
}
++it;
}
}
RepoOptions::RepoOptions(const char* file) : m_path(file) {
always_assert(s_init);
Hdf config{file};
Hdf parserConfig = config["Parser"];
#define N(_, n, ...) hdfExtract(parserConfig, #n, n, s_defaults.n);
#define P(_, n, ...) hdfExtract(parserConfig, "PHP7." #n, n, s_defaults.n);
#define H(_, n, ...) hdfExtract(parserConfig, "Hack.Lang." #n, n, s_defaults.n);
#define E(_, n, ...) hdfExtract(parserConfig, "Eval." #n, n, s_defaults.n);
PARSERFLAGS();
#undef N
#undef P
#undef H
#undef E
Hdf autoloadConfig = config["Autoload"];
#define N(_, n, ...) hdfExtract(autoloadConfig, #n, n, s_defaults.n);
#define P(_, n, ...) hdfExtract(autoloadConfig, "PHP7." #n, n, s_defaults.n);
#define H(_, n, ...) hdfExtract(autoloadConfig, "Hack.Lang." #n, n, \
s_defaults.n);
#define E(_, n, ...) hdfExtract(autoloadConfig, "Eval." #n, n, s_defaults.n);
AUTOLOADFLAGS();
#undef N
#undef P
#undef H
#undef E
filterNamespaces();
}
void RepoOptions::initDefaults(const Hdf& hdf, const IniSettingMap& ini) {
#define N(_, n, dv) Config::Bind(n, ini, hdf, #n, dv);
#define P(_, n, dv) Config::Bind(n, ini, hdf, "PHP7." #n, dv);
#define H(_, n, dv) Config::Bind(n, ini, hdf, "Hack.Lang." #n, dv);
#define E(_, n, dv) Config::Bind(n, ini, hdf, "Eval." #n, dv);
PARSERFLAGS()
AUTOLOADFLAGS()
#undef N
#undef P
#undef H
#undef E
filterNamespaces();
m_path.clear();
}
void RepoOptions::setDefaults(const Hdf& hdf, const IniSettingMap& ini) {
always_assert(!s_init);
s_defaults.initDefaults(hdf, ini);
s_init = true;
}
///////////////////////////////////////////////////////////////////////////////
std::string RuntimeOption::BuildId;
std::string RuntimeOption::InstanceId;
std::string RuntimeOption::DeploymentId;
int64_t RuntimeOption::ConfigId = 0;
std::string RuntimeOption::PidFile = "www.pid";
bool RuntimeOption::ServerMode = false;
bool RuntimeOption::EnableHipHopSyntax = true;
bool RuntimeOption::EnableShortTags = true;
bool RuntimeOption::EnableXHP = true;
bool RuntimeOption::EnableIntrinsicsExtension = false;
bool RuntimeOption::CheckSymLink = true;
bool RuntimeOption::TrustAutoloaderPath = false;
bool RuntimeOption::EnableArgsInBacktraces = true;
bool RuntimeOption::EnableZendIniCompat = true;
bool RuntimeOption::TimeoutsUseWallTime = true;
bool RuntimeOption::CheckFlushOnUserClose = true;
bool RuntimeOption::EvalAuthoritativeMode = false;
bool RuntimeOption::DumpPreciseProfData = true;
bool RuntimeOption::EnablePocketUniverses = false;
uint32_t RuntimeOption::EvalInitialStaticStringTableSize =
kDefaultInitialStaticStringTableSize;
uint32_t RuntimeOption::EvalInitialNamedEntityTableSize = 30000;
JitSerdesMode RuntimeOption::EvalJitSerdesMode{};
int RuntimeOption::ProfDataTTLHours = 24;
std::string RuntimeOption::ProfDataTag;
std::string RuntimeOption::EvalJitSerdesFile;
std::map<std::string, ErrorLogFileData> RuntimeOption::ErrorLogs = {
{Logger::DEFAULT, ErrorLogFileData()},
};
// these hold the DEFAULT logger
std::string RuntimeOption::LogFile;
std::string RuntimeOption::LogFileSymLink;
uint16_t RuntimeOption::LogFilePeriodMultiplier;
int RuntimeOption::LogHeaderMangle = 0;
bool RuntimeOption::AlwaysLogUnhandledExceptions = true;
bool RuntimeOption::AlwaysEscapeLog = true;
bool RuntimeOption::NoSilencer = false;
int RuntimeOption::ErrorUpgradeLevel = 0;
bool RuntimeOption::CallUserHandlerOnFatals = false;
bool RuntimeOption::ThrowExceptionOnBadMethodCall = true;
bool RuntimeOption::LogNativeStackOnOOM = true;
int RuntimeOption::RuntimeErrorReportingLevel =
static_cast<int>(ErrorMode::HPHP_ALL);
int RuntimeOption::ForceErrorReportingLevel = 0;
std::string RuntimeOption::ServerUser;
std::vector<std::string> RuntimeOption::TzdataSearchPaths;
int RuntimeOption::MaxSerializedStringSize = 64 * 1024 * 1024; // 64MB
bool RuntimeOption::NoInfiniteRecursionDetection = false;
bool RuntimeOption::AssertEmitted = true;
int64_t RuntimeOption::NoticeFrequency = 1;
int64_t RuntimeOption::WarningFrequency = 1;
int RuntimeOption::RaiseDebuggingFrequency = 1;
int64_t RuntimeOption::SerializationSizeLimit = StringData::MaxSize;
std::string RuntimeOption::AccessLogDefaultFormat = "%h %l %u %t \"%r\" %>s %b";
std::map<std::string, AccessLogFileData> RuntimeOption::AccessLogs;
std::string RuntimeOption::AdminLogFormat = "%h %t %s %U";
std::string RuntimeOption::AdminLogFile;
std::string RuntimeOption::AdminLogSymLink;
std::map<std::string, AccessLogFileData> RuntimeOption::RPCLogs;
std::string RuntimeOption::Host;
std::string RuntimeOption::DefaultServerNameSuffix;
std::string RuntimeOption::ServerType = "proxygen";
std::string RuntimeOption::ServerIP;
std::string RuntimeOption::ServerFileSocket;
int RuntimeOption::ServerPort = 80;
int RuntimeOption::ServerPortFd = -1;
int RuntimeOption::ServerBacklog = 128;
int RuntimeOption::ServerConnectionLimit = 0;
int RuntimeOption::ServerThreadCount = 50;
int RuntimeOption::ServerQueueCount = 50;
int RuntimeOption::ServerHugeThreadCount = 0;
int RuntimeOption::ServerHugeStackKb = 384;
uint32_t RuntimeOption::ServerLoopSampleRate = 0;
int RuntimeOption::ServerWarmupThrottleRequestCount = 0;
int RuntimeOption::ServerWarmupThrottleThreadCount = 0;
int RuntimeOption::ServerThreadDropCacheTimeoutSeconds = 0;
int RuntimeOption::ServerThreadJobLIFOSwitchThreshold = INT_MAX;
int RuntimeOption::ServerThreadJobMaxQueuingMilliSeconds = -1;
bool RuntimeOption::AlwaysDecodePostDataDefault = true;
bool RuntimeOption::ServerThreadDropStack = false;
bool RuntimeOption::ServerHttpSafeMode = false;
bool RuntimeOption::ServerStatCache = false;
bool RuntimeOption::ServerFixPathInfo = false;
bool RuntimeOption::ServerAddVaryEncoding = true;
bool RuntimeOption::ServerLogSettingsOnStartup = false;
bool RuntimeOption::ServerLogReorderProps = false;
bool RuntimeOption::ServerForkEnabled = true;
bool RuntimeOption::ServerForkLogging = false;
bool RuntimeOption::ServerWarmupConcurrently = false;
int RuntimeOption::ServerWarmupThreadCount = 1;
int RuntimeOption::ServerExtendedWarmupThreadCount = 1;
unsigned RuntimeOption::ServerExtendedWarmupRepeat = 1;
unsigned RuntimeOption::ServerExtendedWarmupDelaySeconds = 60;
std::vector<std::string> RuntimeOption::ServerWarmupRequests;
std::vector<std::string> RuntimeOption::ServerExtendedWarmupRequests;
std::string RuntimeOption::ServerCleanupRequest;
int RuntimeOption::ServerInternalWarmupThreads = 0;
boost::container::flat_set<std::string>
RuntimeOption::ServerHighPriorityEndPoints;
bool RuntimeOption::ServerExitOnBindFail;
int RuntimeOption::PageletServerThreadCount = 0;
int RuntimeOption::PageletServerHugeThreadCount = 0;
int RuntimeOption::PageletServerThreadDropCacheTimeoutSeconds = 0;
int RuntimeOption::PageletServerQueueLimit = 0;
bool RuntimeOption::PageletServerThreadDropStack = false;
int RuntimeOption::RequestTimeoutSeconds = 0;
int RuntimeOption::PspTimeoutSeconds = 0;
int RuntimeOption::PspCpuTimeoutSeconds = 0;
int64_t RuntimeOption::MaxRequestAgeFactor = 0;
int64_t RuntimeOption::RequestMemoryMaxBytes =
std::numeric_limits<int64_t>::max();
int64_t RuntimeOption::RequestMemoryOOMKillBytes =
std::numeric_limits<int64_t>::max();
int64_t RuntimeOption::RequestHugeMaxBytes = 0;
int64_t RuntimeOption::ImageMemoryMaxBytes = 0;
int RuntimeOption::ServerGracefulShutdownWait = 0;
bool RuntimeOption::ServerHarshShutdown = true;
bool RuntimeOption::ServerEvilShutdown = true;
bool RuntimeOption::ServerKillOnTimeout = true;
bool RuntimeOption::Server503OnShutdownAbort = false;
int RuntimeOption::ServerPreShutdownWait = 0;
int RuntimeOption::ServerShutdownListenWait = 0;
int RuntimeOption::ServerShutdownEOMWait = 0;
int RuntimeOption::ServerPrepareToStopTimeout = 0;
int RuntimeOption::ServerPartialPostStatusCode = -1;
bool RuntimeOption::StopOldServer = false;
int RuntimeOption::OldServerWait = 30;
int RuntimeOption::CacheFreeFactor = 50;
int64_t RuntimeOption::ServerRSSNeededMb = 4096;
int64_t RuntimeOption::ServerCriticalFreeMb = 512;
std::vector<std::string> RuntimeOption::ServerNextProtocols;
bool RuntimeOption::ServerEnableH2C = false;
int RuntimeOption::BrotliCompressionEnabled = -1;
int RuntimeOption::BrotliChunkedCompressionEnabled = -1;
int RuntimeOption::BrotliCompressionMode = 0;
int RuntimeOption::BrotliCompressionQuality = 6;
int RuntimeOption::BrotliCompressionLgWindowSize = 20;
int RuntimeOption::ZstdCompressionEnabled = -1;
int RuntimeOption::ZstdCompressionLevel = 3;
int RuntimeOption::ZstdChecksumRate = 0;
int RuntimeOption::GzipCompressionLevel = 3;
int RuntimeOption::GzipMaxCompressionLevel = 9;
bool RuntimeOption::EnableKeepAlive = true;
bool RuntimeOption::ExposeHPHP = true;
bool RuntimeOption::ExposeXFBServer = false;
bool RuntimeOption::ExposeXFBDebug = false;
std::string RuntimeOption::XFBDebugSSLKey;
int RuntimeOption::ConnectionTimeoutSeconds = -1;
bool RuntimeOption::EnableOutputBuffering = false;
std::string RuntimeOption::OutputHandler;
bool RuntimeOption::ImplicitFlush = false;
bool RuntimeOption::EnableEarlyFlush = true;
bool RuntimeOption::ForceChunkedEncoding = false;
int64_t RuntimeOption::MaxPostSize = 100;
int64_t RuntimeOption::LowestMaxPostSize = LLONG_MAX;
bool RuntimeOption::AlwaysPopulateRawPostData = false;
int64_t RuntimeOption::UploadMaxFileSize = 100;
std::string RuntimeOption::UploadTmpDir = "/tmp";
bool RuntimeOption::EnableFileUploads = true;
bool RuntimeOption::EnableUploadProgress = false;
int64_t RuntimeOption::MaxFileUploads = 20;
int RuntimeOption::Rfc1867Freq = 256 * 1024;
std::string RuntimeOption::Rfc1867Prefix = "vupload_";
std::string RuntimeOption::Rfc1867Name = "video_ptoken";
bool RuntimeOption::ExpiresActive = true;
int RuntimeOption::ExpiresDefault = 2592000;
std::string RuntimeOption::DefaultCharsetName = "";
bool RuntimeOption::ForceServerNameToHeader = false;
bool RuntimeOption::PathDebug = false;
int64_t RuntimeOption::RequestBodyReadLimit = -1;
bool RuntimeOption::EnableSSL = false;
int RuntimeOption::SSLPort = 443;
int RuntimeOption::SSLPortFd = -1;
std::string RuntimeOption::SSLCertificateFile;
std::string RuntimeOption::SSLCertificateKeyFile;
std::string RuntimeOption::SSLCertificateDir;
std::string RuntimeOption::SSLTicketSeedFile;
bool RuntimeOption::TLSDisableTLS1_2 = false;
std::string RuntimeOption::TLSClientCipherSpec;
bool RuntimeOption::EnableSSLWithPlainText = false;
int RuntimeOption::SSLClientAuthLevel = 0;
std::string RuntimeOption::SSLClientCAFile = "";
std::string RuntimeOption::ClientAuthAclIdentity;
std::string RuntimeOption::ClientAuthAclAction;
bool RuntimeOption::ClientAuthFailClose = false;
uint32_t RuntimeOption::SSLClientAuthLoggingSampleRatio = 0;
uint32_t RuntimeOption::ClientAuthSuccessLogSampleRatio = 0;
uint32_t RuntimeOption::ClientAuthFailureLogSampleRatio = 0;
uint32_t RuntimeOption::ClientAuthLogSampleBase = 100;
std::vector<std::shared_ptr<VirtualHost>> RuntimeOption::VirtualHosts;
std::shared_ptr<IpBlockMap> RuntimeOption::IpBlocks;
std::vector<std::shared_ptr<SatelliteServerInfo>>
RuntimeOption::SatelliteServerInfos;
bool RuntimeOption::AllowRunAsRoot = false; // Allow running hhvm as root.
int RuntimeOption::XboxServerThreadCount = 10;
int RuntimeOption::XboxServerMaxQueueLength = INT_MAX;
int RuntimeOption::XboxServerPort = 0;
int RuntimeOption::XboxDefaultLocalTimeoutMilliSeconds = 500;
int RuntimeOption::XboxDefaultRemoteTimeoutSeconds = 5;
int RuntimeOption::XboxServerInfoMaxRequest = 500;
int RuntimeOption::XboxServerInfoDuration = 120;
std::string RuntimeOption::XboxServerInfoReqInitFunc;
std::string RuntimeOption::XboxServerInfoReqInitDoc;
bool RuntimeOption::XboxServerInfoAlwaysReset = false;
bool RuntimeOption::XboxServerLogInfo = false;
std::string RuntimeOption::XboxProcessMessageFunc = "xbox_process_message";
std::string RuntimeOption::XboxPassword;
std::set<std::string> RuntimeOption::XboxPasswords;
std::string RuntimeOption::SourceRoot = Process::GetCurrentDirectory() + '/';
std::vector<std::string> RuntimeOption::IncludeSearchPaths;
std::map<std::string, std::string> RuntimeOption::IncludeRoots;
std::map<std::string, std::string> RuntimeOption::AutoloadRoots;
bool RuntimeOption::AutoloadEnabled;
std::string RuntimeOption::AutoloadDBPath;
std::string RuntimeOption::FileCache;
std::string RuntimeOption::DefaultDocument;
std::string RuntimeOption::GlobalDocument;
std::string RuntimeOption::ErrorDocument404;
bool RuntimeOption::ForbiddenAs404 = false;
std::string RuntimeOption::ErrorDocument500;
std::string RuntimeOption::FatalErrorMessage;
std::string RuntimeOption::FontPath;
bool RuntimeOption::EnableStaticContentFromDisk = true;
bool RuntimeOption::EnableOnDemandUncompress = true;
bool RuntimeOption::EnableStaticContentMMap = true;
bool RuntimeOption::Utf8izeReplace = true;
std::string RuntimeOption::RequestInitFunction;
std::string RuntimeOption::RequestInitDocument;
std::string RuntimeOption::AutoPrependFile;
std::string RuntimeOption::AutoAppendFile;
bool RuntimeOption::SafeFileAccess = false;
std::vector<std::string> RuntimeOption::AllowedDirectories;
std::set<std::string> RuntimeOption::AllowedFiles;
hphp_string_imap<std::string> RuntimeOption::StaticFileExtensions;
hphp_string_imap<std::string> RuntimeOption::PhpFileExtensions;
std::set<std::string> RuntimeOption::ForbiddenFileExtensions;
std::vector<std::shared_ptr<FilesMatch>> RuntimeOption::FilesMatches;
bool RuntimeOption::WhitelistExec = false;
bool RuntimeOption::WhitelistExecWarningOnly = false;
std::vector<std::string> RuntimeOption::AllowedExecCmds;
bool RuntimeOption::UnserializationWhitelistCheck = false;
bool RuntimeOption::UnserializationWhitelistCheckWarningOnly = true;
int64_t RuntimeOption::UnserializationBigMapThreshold = 1 << 16;
std::string RuntimeOption::TakeoverFilename;
std::string RuntimeOption::AdminServerIP;
int RuntimeOption::AdminServerPort = 0;
int RuntimeOption::AdminThreadCount = 1;
bool RuntimeOption::AdminServerEnableSSLWithPlainText = false;
bool RuntimeOption::AdminServerStatsNeedPassword = true;
std::string RuntimeOption::AdminPassword;
std::set<std::string> RuntimeOption::AdminPasswords;
std::set<std::string> RuntimeOption::HashedAdminPasswords;
std::string RuntimeOption::ProxyOriginRaw;
int RuntimeOption::ProxyPercentageRaw = 0;
int RuntimeOption::ProxyRetry = 3;
bool RuntimeOption::UseServeURLs;
std::set<std::string> RuntimeOption::ServeURLs;
bool RuntimeOption::UseProxyURLs;
std::set<std::string> RuntimeOption::ProxyURLs;
std::vector<std::string> RuntimeOption::ProxyPatterns;
bool RuntimeOption::AlwaysUseRelativePath = false;
int RuntimeOption::HttpDefaultTimeout = 30;
int RuntimeOption::HttpSlowQueryThreshold = 5000; // ms
bool RuntimeOption::NativeStackTrace = false;
bool RuntimeOption::ServerErrorMessage = false;
bool RuntimeOption::RecordInput = false;
bool RuntimeOption::ClearInputOnSuccess = true;
std::string RuntimeOption::ProfilerOutputDir = "/tmp";
std::string RuntimeOption::CoreDumpEmail;
bool RuntimeOption::CoreDumpReport = true;
std::string RuntimeOption::CoreDumpReportDirectory =
#if defined(HPHP_OSS)
"/tmp";
#else
"/var/tmp/cores";
#endif
std::string RuntimeOption::StackTraceFilename;
int RuntimeOption::StackTraceTimeout = 0; // seconds; 0 means unlimited
std::string RuntimeOption::RemoteTraceOutputDir = "/tmp";
std::set<std::string, stdltistr> RuntimeOption::TraceFunctions;
uint32_t RuntimeOption::TraceFuncId = InvalidFuncId;
bool RuntimeOption::EnableStats = false;
bool RuntimeOption::EnableAPCStats = false;
bool RuntimeOption::EnableWebStats = false;
bool RuntimeOption::EnableMemoryStats = false;
bool RuntimeOption::EnableSQLStats = false;
bool RuntimeOption::EnableSQLTableStats = false;
bool RuntimeOption::EnableNetworkIOStatus = false;
std::string RuntimeOption::StatsXSL;
std::string RuntimeOption::StatsXSLProxy;
uint32_t RuntimeOption::StatsSlotDuration = 10 * 60; // 10 minutes
uint32_t RuntimeOption::StatsMaxSlot = 12 * 6; // 12 hours
int64_t RuntimeOption::MaxSQLRowCount = 0;
int64_t RuntimeOption::SocketDefaultTimeout = 60;
bool RuntimeOption::LockCodeMemory = false;
int RuntimeOption::MaxArrayChain = INT_MAX;
bool RuntimeOption::WarnOnCollectionToArray = false;
bool RuntimeOption::UseDirectCopy = false;
#if FOLLY_SANITIZE
bool RuntimeOption::DisableSmallAllocator = true;
#else
bool RuntimeOption::DisableSmallAllocator = false;
#endif
std::map<std::string, std::string> RuntimeOption::ServerVariables;
std::map<std::string, std::string> RuntimeOption::EnvVariables;
std::string RuntimeOption::LightProcessFilePrefix = "./lightprocess";
int RuntimeOption::LightProcessCount = 0;
int64_t RuntimeOption::HeapSizeMB = 4096; // 4gb
int64_t RuntimeOption::HeapResetCountBase = 1;
int64_t RuntimeOption::HeapResetCountMultiple = 2;
int64_t RuntimeOption::HeapLowWaterMark = 16;
int64_t RuntimeOption::HeapHighWaterMark = 1024;
uint64_t RuntimeOption::DisableCallUserFunc = 0;
uint64_t RuntimeOption::DisableCallUserFuncArray = 0;
uint64_t RuntimeOption::DisableParseStrSingleArg = 0;
uint64_t RuntimeOption::DisableAssert = 0;
bool RuntimeOption::DisallowExecutionOperator = true;
bool RuntimeOption::DisableReservedVariables = true;
uint64_t RuntimeOption::DisableConstant = 0;
bool RuntimeOption::DisableNontoplevelDeclarations = false;
bool RuntimeOption::DisableStaticClosures = false;
bool RuntimeOption::DisableHaltCompiler = false;
bool RuntimeOption::EnableClassLevelWhereClauses = false;
#ifdef HHVM_DYNAMIC_EXTENSION_DIR
std::string RuntimeOption::ExtensionDir = HHVM_DYNAMIC_EXTENSION_DIR;
#else
std::string RuntimeOption::ExtensionDir = "";
#endif
std::vector<std::string> RuntimeOption::Extensions;
std::vector<std::string> RuntimeOption::DynamicExtensions;
std::string RuntimeOption::DynamicExtensionPath = ".";
int RuntimeOption::CheckIntOverflow = 0;
HackStrictOption
RuntimeOption::StrictArrayFillKeys = HackStrictOption::OFF;
// defaults set when the INI option is bound - values below are irrelevant.
bool RuntimeOption::LookForTypechecker = false;
bool RuntimeOption::AutoTypecheck = false;
bool RuntimeOption::PHP7_EngineExceptions = false;
bool RuntimeOption::PHP7_IntSemantics = false;
bool RuntimeOption::PHP7_NoHexNumerics = false;
bool RuntimeOption::PHP7_Builtins = false;
bool RuntimeOption::PHP7_Substr = false;
bool RuntimeOption::PHP7_DisallowUnsafeCurlUploads = false;
int RuntimeOption::GetScannerType() {
int type = 0;
if (EnableShortTags) type |= Scanner::AllowShortTags;
return type;
}
const std::string& RuntimeOption::GetServerPrimaryIPv4() {
static std::string serverPrimaryIPv4 = GetPrimaryIPv4();
return serverPrimaryIPv4;
}
const std::string& RuntimeOption::GetServerPrimaryIPv6() {
static std::string serverPrimaryIPv6 = GetPrimaryIPv6();
return serverPrimaryIPv6;
}
static inline std::string regionSelectorDefault() {
return "tracelet";
}
static inline bool pgoDefault() {
#ifdef HHVM_NO_DEFAULT_PGO
return false;
#else
return true;
#endif
}
static inline bool eagerGcDefault() {
#ifdef HHVM_EAGER_GC
return true;
#else
return false;
#endif
}
static inline std::string hackCompilerArgsDefault() {
return RuntimeOption::RepoAuthoritative
? "-v Hack.Compiler.SourceMapping=1 --daemon --dump-symbol-refs"
: "-v Hack.Compiler.SourceMapping=1 --daemon";
}
static inline std::string hackCompilerCommandDefault() {
#ifdef FACEBOOK
return "";
#else
std::string hackc = folly::sformat(
"{}/hh_single_compile",
current_executable_directory()
);
if (::access(hackc.data(), X_OK) != 0) {
#ifndef HACKC_FALLBACK_PATH
return "";
#else
hackc = HACKC_FALLBACK_PATH;
if (::access(hackc.data(), X_OK) != 0) {
return "";
}
#endif
}
return folly::sformat(
"{} {}",
hackc,
hackCompilerArgsDefault()
);
#endif
}
static inline bool enableGcDefault() {
return RuntimeOption::EvalEagerGC || one_bit_refcount;
}
static inline uint64_t pgoThresholdDefault() {
return debug ? 2 : 2000;
}
static inline bool alignMacroFusionPairs() {
switch (getProcessorFamily()) {
case ProcessorFamily::Intel_SandyBridge:
case ProcessorFamily::Intel_IvyBridge:
case ProcessorFamily::Intel_Haswell:
case ProcessorFamily::Intel_Broadwell:
case ProcessorFamily::Intel_Skylake:
return true;
case ProcessorFamily::Unknown:
return false;
}
return false;
}
static inline bool armLseDefault() {
#if defined (__linux__) && defined (__aarch64__) && defined (HWCAP_ATOMICS)
return (getauxval(AT_HWCAP) & HWCAP_ATOMICS) != 0;
#else
return false;
#endif
}
static inline bool evalJitDefault() {
#ifdef _MSC_VER
return false;
#else
return true;
#endif
}
static inline bool reuseTCDefault() {
return hhvm_reuse_tc && !RuntimeOption::RepoAuthoritative;
}
static inline bool hugePagesSoundNice() {
return RuntimeOption::ServerExecutionMode();
}
static inline uint32_t hotTextHugePagesDefault() {
if (!hugePagesSoundNice()) return 0;
return arch() == Arch::ARM ? 12 : 8;
}
static inline uint32_t arrayIterDefaultCount() {
return debug ? 0 : 10000;
}
static inline double arrayIterDefaultRate() {
return 0.99;
}
static inline std::string reorderPropsDefault() {
if (isJitDeserializing()) {
return "countedness-hotness";
}
return debug ? "alphabetical" : "countedness";
}
static inline uint32_t profileRequestsDefault() {
return debug ? std::numeric_limits<uint32_t>::max() : 2500;
}
static inline uint32_t profileBCSizeDefault() {
return debug ? std::numeric_limits<uint32_t>::max()
: RuntimeOption::EvalJitConcurrently ? 3750000
: 4300000;
}
static inline uint32_t resetProfCountersDefault() {
return RuntimeOption::EvalJitPGORacyProfiling