2 * Copyright (C) 2011-2017 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #include "AssemblerCommon.h"
30 #include "LLIntCommon.h"
31 #include "LLIntData.h"
32 #include "SigillCrashAnalyzer.h"
39 #include <wtf/ASCIICType.h>
40 #include <wtf/Compiler.h>
41 #include <wtf/DataLog.h>
42 #include <wtf/NumberOfCores.h>
43 #include <wtf/StdLibExtras.h>
44 #include <wtf/StringExtras.h>
45 #include <wtf/text/StringBuilder.h>
48 #include <crt_externs.h>
52 #include "MacroAssemblerX86.h"
59 bool restrictedOptionsEnabled = false;
61 bool restrictedOptionsEnabled = true;
65 void Options::enableRestrictedOptions(bool enableOrNot)
67 restrictedOptionsEnabled = enableOrNot;
70 static bool parse(const char* string, bool& value)
72 if (!strcasecmp(string, "true") || !strcasecmp(string, "yes") || !strcmp(string, "1")) {
76 if (!strcasecmp(string, "false") || !strcasecmp(string, "no") || !strcmp(string, "0")) {
83 static bool parse(const char* string, int32_t& value)
85 return sscanf(string, "%d", &value) == 1;
88 static bool parse(const char* string, unsigned& value)
90 return sscanf(string, "%u", &value) == 1;
93 static bool parse(const char* string, unsigned long& value)
95 return sscanf(string, "%lu", &value);
98 static bool UNUSED_FUNCTION parse(const char* string, unsigned long long& value)
100 return sscanf(string, "%llu", &value);
103 static bool parse(const char* string, double& value)
105 return sscanf(string, "%lf", &value) == 1;
108 static bool parse(const char* string, OptionRange& value)
110 return value.init(string);
113 static bool parse(const char* string, const char*& value)
115 if (!strlen(string)) {
120 // FIXME <https://webkit.org/b/169057>: This could leak if this option is set more than once.
121 // Given that Options are typically used for testing, this isn't considered to be a problem.
122 value = WTF::fastStrDup(string);
126 static bool parse(const char* string, GCLogging::Level& value)
128 if (!strcasecmp(string, "none") || !strcasecmp(string, "no") || !strcasecmp(string, "false") || !strcmp(string, "0")) {
129 value = GCLogging::None;
133 if (!strcasecmp(string, "basic") || !strcasecmp(string, "yes") || !strcasecmp(string, "true") || !strcmp(string, "1")) {
134 value = GCLogging::Basic;
138 if (!strcasecmp(string, "verbose") || !strcmp(string, "2")) {
139 value = GCLogging::Verbose;
146 bool Options::isAvailable(Options::ID id, Options::Availability availability)
148 if (availability == Availability::Restricted)
149 return restrictedOptionsEnabled;
150 ASSERT(availability == Availability::Configurable);
153 #if ENABLE(LLINT_STATS)
154 if (id == reportLLIntStatsID || id == llintStatsFileID)
158 if (id == maxSingleAllocationSizeID)
162 if (id == useSigillCrashAnalyzerID)
169 bool overrideOptionWithHeuristic(T& variable, Options::ID id, const char* name, Options::Availability availability)
171 bool available = (availability == Options::Availability::Normal)
172 || Options::isAvailable(id, availability);
174 const char* stringValue = getenv(name);
178 if (available && parse(stringValue, variable))
181 fprintf(stderr, "WARNING: failed to parse %s=%s\n", name, stringValue);
185 bool Options::overrideAliasedOptionWithHeuristic(const char* name)
187 const char* stringValue = getenv(name);
191 String aliasedOption;
192 aliasedOption = String(&name[4]) + "=" + stringValue;
193 if (Options::setOption(aliasedOption.utf8().data()))
196 fprintf(stderr, "WARNING: failed to parse %s=%s\n", name, stringValue);
200 static unsigned computeNumberOfWorkerThreads(int maxNumberOfWorkerThreads, int minimum = 1)
202 int cpusToUse = std::min(WTF::numberOfProcessorCores(), maxNumberOfWorkerThreads);
204 // Be paranoid, it is the OS we're dealing with, after all.
205 ASSERT(cpusToUse >= 1);
206 return std::max(cpusToUse, minimum);
209 static int32_t computePriorityDeltaOfWorkerThreads(int32_t twoCorePriorityDelta, int32_t multiCorePriorityDelta)
211 if (WTF::numberOfProcessorCores() <= 2)
212 return twoCorePriorityDelta;
214 return multiCorePriorityDelta;
217 static unsigned computeNumberOfGCMarkers(unsigned maxNumberOfGCMarkers)
219 return computeNumberOfWorkerThreads(maxNumberOfGCMarkers);
222 const char* const OptionRange::s_nullRangeStr = "<null>";
224 bool OptionRange::init(const char* rangeString)
226 // rangeString should be in the form of [!]<low>[:<high>]
227 // where low and high are unsigned
236 if (!strcmp(rangeString, s_nullRangeStr)) {
237 m_state = Uninitialized;
241 const char* p = rangeString;
248 int scanResult = sscanf(p, " %u:%u", &m_lowLimit, &m_highLimit);
250 if (!scanResult || scanResult == EOF) {
256 m_highLimit = m_lowLimit;
258 if (m_lowLimit > m_highLimit) {
263 // FIXME <https://webkit.org/b/169057>: This could leak if this particular option is set more than once.
264 // Given that these options are used for testing, this isn't considered to be problem.
265 m_rangeString = WTF::fastStrDup(rangeString);
266 m_state = invert ? Inverted : Normal;
271 bool OptionRange::isInRange(unsigned count)
273 if (m_state < Normal)
276 if ((m_lowLimit <= count) && (count <= m_highLimit))
277 return m_state == Normal ? true : false;
279 return m_state == Normal ? false : true;
282 void OptionRange::dump(PrintStream& out) const
284 out.print(m_rangeString);
287 Options::Entry Options::s_options[Options::numberOfOptions];
288 Options::Entry Options::s_defaultOptions[Options::numberOfOptions];
290 // Realize the names for each of the options:
291 const Options::EntryInfo Options::s_optionsInfo[Options::numberOfOptions] = {
292 #define FOR_EACH_OPTION(type_, name_, defaultValue_, availability_, description_) \
293 { #name_, description_, Options::Type::type_##Type, Availability::availability_ },
294 JSC_OPTIONS(FOR_EACH_OPTION)
295 #undef FOR_EACH_OPTION
298 static void scaleJITPolicy()
300 auto& scaleFactor = Options::jitPolicyScale();
301 if (scaleFactor > 1.0)
303 else if (scaleFactor < 0.0)
306 struct OptionToScale {
311 static const OptionToScale optionsToScale[] = {
312 { Options::thresholdForJITAfterWarmUpID, 0 },
313 { Options::thresholdForJITSoonID, 0 },
314 { Options::thresholdForOptimizeAfterWarmUpID, 1 },
315 { Options::thresholdForOptimizeAfterLongWarmUpID, 1 },
316 { Options::thresholdForOptimizeSoonID, 1 },
317 { Options::thresholdForFTLOptimizeSoonID, 2 },
318 { Options::thresholdForFTLOptimizeAfterWarmUpID, 2 }
321 const int numberOfOptionsToScale = sizeof(optionsToScale) / sizeof(OptionToScale);
322 for (int i = 0; i < numberOfOptionsToScale; i++) {
323 Option option(optionsToScale[i].id);
324 ASSERT(option.type() == Options::Type::int32Type);
325 option.int32Val() *= scaleFactor;
326 option.int32Val() = std::max(option.int32Val(), optionsToScale[i].minVal);
330 static void overrideDefaults()
333 if (WTF::numberOfProcessorCores() < 4)
336 Options::maximumMutatorUtilization() = 0.6;
337 Options::concurrentGCMaxHeadroom() = 1.4;
338 Options::minimumGCPauseMS() = 1;
339 Options::useStochasticMutatorScheduler() = false;
340 if (WTF::numberOfProcessorCores() <= 1)
341 Options::gcIncrementScale() = 1;
343 Options::gcIncrementScale() = 0;
347 // On iOS, we control heap growth using process memory footprint. Therefore these values can be agressive.
348 Options::smallHeapRAMFraction() = 0.8;
349 Options::mediumHeapRAMFraction() = 0.9;
351 Options::useSigillCrashAnalyzer() = true;
354 #if !ENABLE(SIGNAL_BASED_VM_TRAPS)
355 Options::usePollingTraps() = true;
358 #if !ENABLE(WEBASSEMBLY_FAST_MEMORY)
359 Options::useWebAssemblyFastMemory() = false;
363 static void recomputeDependentOptions()
366 Options::validateDFGExceptionHandling() = true;
369 Options::useLLInt() = true;
370 Options::useJIT() = false;
371 Options::useDFGJIT() = false;
372 Options::useFTLJIT() = false;
373 Options::useDOMJIT() = false;
375 #if !ENABLE(YARR_JIT)
376 Options::useRegExpJIT() = false;
378 #if !ENABLE(CONCURRENT_JS)
379 Options::useConcurrentJIT() = false;
382 Options::useDFGJIT() = false;
383 Options::useFTLJIT() = false;
386 Options::useFTLJIT() = false;
389 #if !CPU(X86_64) && !CPU(ARM64)
390 Options::useConcurrentGC() = false;
393 #if OS(WINDOWS) && CPU(X86)
394 // Disable JIT on Windows if SSE2 is not present
395 if (!MacroAssemblerX86::supportsFloatingPoint())
396 Options::useJIT() = false;
399 if (!Options::useJIT())
400 Options::useWebAssembly() = false;
402 if (!Options::useWebAssembly()) {
403 Options::webAssemblyFastMemoryPreallocateCount() = 0;
404 Options::useWebAssemblyFastTLS() = false;
407 if (Options::dumpDisassembly()
408 || Options::dumpDFGDisassembly()
409 || Options::dumpFTLDisassembly()
410 || Options::dumpBytecodeAtDFGTime()
411 || Options::dumpGraphAtEachPhase()
412 || Options::dumpDFGGraphAtEachPhase()
413 || Options::dumpDFGFTLGraphAtEachPhase()
414 || Options::dumpB3GraphAtEachPhase()
415 || Options::dumpAirGraphAtEachPhase()
416 || Options::verboseCompilation()
417 || Options::verboseFTLCompilation()
418 || Options::logCompilationChanges()
419 || Options::validateGraph()
420 || Options::validateGraphAtEachPhase()
421 || Options::verboseOSR()
422 || Options::verboseCompilationQueue()
423 || Options::reportCompileTimes()
424 || Options::reportBaselineCompileTimes()
425 || Options::reportDFGCompileTimes()
426 || Options::reportFTLCompileTimes()
427 || Options::reportDFGPhaseTimes()
428 || Options::verboseCFA()
429 || Options::verboseFTLFailure())
430 Options::alwaysComputeHash() = true;
432 if (!Options::useConcurrentGC())
433 Options::collectContinuously() = false;
435 if (Option(Options::jitPolicyScaleID).isOverridden())
438 if (Options::forceEagerCompilation()) {
439 Options::thresholdForJITAfterWarmUp() = 10;
440 Options::thresholdForJITSoon() = 10;
441 Options::thresholdForOptimizeAfterWarmUp() = 20;
442 Options::thresholdForOptimizeAfterLongWarmUp() = 20;
443 Options::thresholdForOptimizeSoon() = 20;
444 Options::thresholdForFTLOptimizeAfterWarmUp() = 20;
445 Options::thresholdForFTLOptimizeSoon() = 20;
446 Options::maximumEvalCacheableSourceLength() = 150000;
447 Options::useConcurrentJIT() = false;
449 if (Options::useMaximalFlushInsertionPhase()) {
450 Options::useOSREntryToDFG() = false;
451 Options::useOSREntryToFTL() = false;
454 #if PLATFORM(IOS) && !PLATFORM(IOS_SIMULATOR) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000
455 // Override globally for now. Longer term we'll just make the default
456 // be to have this option enabled, and have platforms that don't support
457 // it just silently use a single mapping.
458 Options::useSeparatedWXHeap() = true;
461 if (Options::alwaysUseShadowChicken())
462 Options::maximumInliningDepth() = 1;
464 // Compute the maximum value of the reoptimization retry counter. This is simply
465 // the largest value at which we don't overflow the execute counter, when using it
466 // to left-shift the execution counter by this amount. Currently the value ends
467 // up being 18, so this loop is not so terrible; it probably takes up ~100 cycles
468 // total on a 32-bit processor.
469 Options::reoptimizationRetryCounterMax() = 0;
470 while ((static_cast<int64_t>(Options::thresholdForOptimizeAfterLongWarmUp()) << (Options::reoptimizationRetryCounterMax() + 1)) <= static_cast<int64_t>(std::numeric_limits<int32_t>::max()))
471 Options::reoptimizationRetryCounterMax()++;
473 ASSERT((static_cast<int64_t>(Options::thresholdForOptimizeAfterLongWarmUp()) << Options::reoptimizationRetryCounterMax()) > 0);
474 ASSERT((static_cast<int64_t>(Options::thresholdForOptimizeAfterLongWarmUp()) << Options::reoptimizationRetryCounterMax()) <= static_cast<int64_t>(std::numeric_limits<int32_t>::max()));
476 #if ENABLE(LLINT_STATS)
477 LLInt::Data::loadStats();
480 if (Options::maxSingleAllocationSize())
481 fastSetMaxSingleAllocationSize(Options::maxSingleAllocationSize());
483 fastSetMaxSingleAllocationSize(std::numeric_limits<size_t>::max());
486 if (Options::useZombieMode()) {
487 Options::sweepSynchronously() = true;
488 Options::scribbleFreeCells() = true;
491 if (Options::useSigillCrashAnalyzer())
492 enableSigillCrashAnalyzer();
495 void Options::initialize()
497 static std::once_flag initializeOptionsOnceFlag;
500 initializeOptionsOnceFlag,
502 // Initialize each of the options with their default values:
503 #define FOR_EACH_OPTION(type_, name_, defaultValue_, availability_, description_) \
504 name_() = defaultValue_; \
505 name_##Default() = defaultValue_;
506 JSC_OPTIONS(FOR_EACH_OPTION)
507 #undef FOR_EACH_OPTION
511 // Allow environment vars to override options if applicable.
512 // The evn var should be the name of the option prefixed with
515 bool hasBadOptions = false;
516 for (char** envp = *_NSGetEnviron(); *envp; envp++) {
517 const char* env = *envp;
518 if (!strncmp("JSC_", env, 4)) {
519 if (!Options::setOption(&env[4])) {
520 dataLog("ERROR: invalid option: ", *envp, "\n");
521 hasBadOptions = true;
525 if (hasBadOptions && Options::validateOptions())
527 #else // PLATFORM(COCOA)
528 #define FOR_EACH_OPTION(type_, name_, defaultValue_, availability_, description_) \
529 overrideOptionWithHeuristic(name_(), name_##ID, "JSC_" #name_, Availability::availability_);
530 JSC_OPTIONS(FOR_EACH_OPTION)
531 #undef FOR_EACH_OPTION
532 #endif // PLATFORM(COCOA)
534 #define FOR_EACH_OPTION(aliasedName_, unaliasedName_, equivalence_) \
535 overrideAliasedOptionWithHeuristic("JSC_" #aliasedName_);
536 JSC_ALIASED_OPTIONS(FOR_EACH_OPTION)
537 #undef FOR_EACH_OPTION
540 ; // Deconfuse editors that do auto indentation
543 recomputeDependentOptions();
545 // Do range checks where needed and make corrections to the options:
546 ASSERT(Options::thresholdForOptimizeAfterLongWarmUp() >= Options::thresholdForOptimizeAfterWarmUp());
547 ASSERT(Options::thresholdForOptimizeAfterWarmUp() >= Options::thresholdForOptimizeSoon());
548 ASSERT(Options::thresholdForOptimizeAfterWarmUp() >= 0);
549 ASSERT(Options::criticalGCMemoryThreshold() > 0.0 && Options::criticalGCMemoryThreshold() < 1.0);
551 dumpOptionsIfNeeded();
552 ensureOptionsAreCoherent();
556 void Options::dumpOptionsIfNeeded()
558 if (Options::dumpOptions()) {
559 DumpLevel level = static_cast<DumpLevel>(Options::dumpOptions());
560 if (level > DumpLevel::Verbose)
561 level = DumpLevel::Verbose;
563 const char* title = nullptr;
565 case DumpLevel::None:
567 case DumpLevel::Overridden:
568 title = "Overridden JSC options:";
571 title = "All JSC options:";
573 case DumpLevel::Verbose:
574 title = "All JSC options with descriptions:";
578 StringBuilder builder;
579 dumpAllOptions(builder, level, title, nullptr, " ", "\n", DumpDefaults);
580 dataLog(builder.toString());
584 bool Options::setOptions(const char* optionsStr)
586 Vector<char*> options;
588 size_t length = strlen(optionsStr);
589 char* optionsStrCopy = WTF::fastStrDup(optionsStr);
590 char* end = optionsStrCopy + length;
591 char* p = optionsStrCopy;
595 while (p < end && isASCIISpace(*p))
600 char* optionStart = p;
603 dataLogF("'=' not found in option string: %p\n", optionStart);
604 WTF::fastFree(optionsStrCopy);
609 char* valueBegin = p;
610 bool hasStringValue = false;
611 const int minStringLength = 2; // The min is an empty string i.e. 2 double quotes.
612 if ((p + minStringLength < end) && (*p == '"')) {
613 p = strstr(p + 1, "\"");
615 dataLogF("Missing trailing '\"' in option string: %p\n", optionStart);
616 WTF::fastFree(optionsStrCopy);
617 return false; // End of string not found.
619 hasStringValue = true;
622 // Find next white space.
623 while (p < end && !isASCIISpace(*p))
626 p = end; // No more " " separator. Hence, this is the last arg.
628 // If we have a well-formed string value, strip the quotes.
629 if (hasStringValue) {
631 ASSERT((*valueBegin == '"') && ((valueEnd - valueBegin) >= minStringLength) && (valueEnd[-1] == '"'));
632 memmove(valueBegin, valueBegin + 1, valueEnd - valueBegin - minStringLength);
633 valueEnd[-minStringLength] = '\0';
636 // Strip leading -- if present.
637 if ((p - optionStart > 2) && optionStart[0] == '-' && optionStart[1] == '-')
641 options.append(optionStart);
645 for (auto& option : options) {
646 bool optionSuccess = setOption(option);
647 if (!optionSuccess) {
648 dataLogF("Failed to set option : %s\n", option);
653 recomputeDependentOptions();
655 dumpOptionsIfNeeded();
657 ensureOptionsAreCoherent();
659 WTF::fastFree(optionsStrCopy);
664 // Parses a single command line option in the format "<optionName>=<value>"
665 // (no spaces allowed) and set the specified option if appropriate.
666 bool Options::setOptionWithoutAlias(const char* arg)
668 // arg should look like this:
669 // <jscOptionName>=<appropriate value>
670 const char* equalStr = strchr(arg, '=');
674 const char* valueStr = equalStr + 1;
676 // For each option, check if the specify arg is a match. If so, set the arg
677 // if the value makes sense. Otherwise, move on to checking the next option.
678 #define FOR_EACH_OPTION(type_, name_, defaultValue_, availability_, description_) \
679 if (strlen(#name_) == static_cast<size_t>(equalStr - arg) \
680 && !strncmp(arg, #name_, equalStr - arg)) { \
681 if (Availability::availability_ != Availability::Normal \
682 && !isAvailable(name_##ID, Availability::availability_)) \
685 value = (defaultValue_); \
686 bool success = parse(valueStr, value); \
689 recomputeDependentOptions(); \
695 JSC_OPTIONS(FOR_EACH_OPTION)
696 #undef FOR_EACH_OPTION
698 return false; // No option matched.
701 static bool invertBoolOptionValue(const char* valueStr, const char*& invertedValueStr)
704 if (!parse(valueStr, boolValue))
706 invertedValueStr = boolValue ? "false" : "true";
711 bool Options::setAliasedOption(const char* arg)
713 // arg should look like this:
714 // <jscOptionName>=<appropriate value>
715 const char* equalStr = strchr(arg, '=');
720 #if __has_warning("-Wtautological-compare")
721 #pragma clang diagnostic push
722 #pragma clang diagnostic ignored "-Wtautological-compare"
726 // For each option, check if the specify arg is a match. If so, set the arg
727 // if the value makes sense. Otherwise, move on to checking the next option.
728 #define FOR_EACH_OPTION(aliasedName_, unaliasedName_, equivalence) \
729 if (strlen(#aliasedName_) == static_cast<size_t>(equalStr - arg) \
730 && !strncmp(arg, #aliasedName_, equalStr - arg)) { \
731 String unaliasedOption(#unaliasedName_); \
732 if (equivalence == SameOption) \
733 unaliasedOption = unaliasedOption + equalStr; \
735 ASSERT(equivalence == InvertedOption); \
736 const char* invertedValueStr = nullptr; \
737 if (!invertBoolOptionValue(equalStr + 1, invertedValueStr)) \
739 unaliasedOption = unaliasedOption + "=" + invertedValueStr; \
741 return setOptionWithoutAlias(unaliasedOption.utf8().data()); \
744 JSC_ALIASED_OPTIONS(FOR_EACH_OPTION)
745 #undef FOR_EACH_OPTION
748 #if __has_warning("-Wtautological-compare")
749 #pragma clang diagnostic pop
753 return false; // No option matched.
756 bool Options::setOption(const char* arg)
758 bool success = setOptionWithoutAlias(arg);
761 return setAliasedOption(arg);
765 void Options::dumpAllOptions(StringBuilder& builder, DumpLevel level, const char* title,
766 const char* separator, const char* optionHeader, const char* optionFooter, DumpDefaultsOption dumpDefaultsOption)
769 builder.append(title);
770 builder.append('\n');
773 for (int id = 0; id < numberOfOptions; id++) {
775 builder.append(separator);
776 dumpOption(builder, level, static_cast<ID>(id), optionHeader, optionFooter, dumpDefaultsOption);
780 void Options::dumpAllOptionsInALine(StringBuilder& builder)
782 dumpAllOptions(builder, DumpLevel::All, nullptr, " ", nullptr, nullptr, DontDumpDefaults);
785 void Options::dumpAllOptions(FILE* stream, DumpLevel level, const char* title)
787 StringBuilder builder;
788 dumpAllOptions(builder, level, title, nullptr, " ", "\n", DumpDefaults);
789 fprintf(stream, "%s", builder.toString().utf8().data());
792 void Options::dumpOption(StringBuilder& builder, DumpLevel level, Options::ID id,
793 const char* header, const char* footer, DumpDefaultsOption dumpDefaultsOption)
795 if (id >= numberOfOptions)
796 return; // Illegal option.
799 Availability availability = option.availability();
800 if (availability != Availability::Normal && !isAvailable(id, availability))
803 bool wasOverridden = option.isOverridden();
804 bool needsDescription = (level == DumpLevel::Verbose && option.description());
806 if (level == DumpLevel::Overridden && !wasOverridden)
810 builder.append(header);
811 builder.append(option.name());
813 option.dump(builder);
815 if (wasOverridden && (dumpDefaultsOption == DumpDefaults)) {
816 builder.appendLiteral(" (default: ");
817 option.defaultOption().dump(builder);
818 builder.appendLiteral(")");
821 if (needsDescription) {
822 builder.appendLiteral(" ... ");
823 builder.append(option.description());
826 builder.append(footer);
829 void Options::ensureOptionsAreCoherent()
831 bool coherent = true;
832 if (!(useLLInt() || useJIT())) {
834 dataLog("INCOHERENT OPTIONS: at least one of useLLInt or useJIT must be true\n");
840 void Option::dump(StringBuilder& builder) const
843 case Options::Type::boolType:
844 builder.append(m_entry.boolVal ? "true" : "false");
846 case Options::Type::unsignedType:
847 builder.appendNumber(m_entry.unsignedVal);
849 case Options::Type::sizeType:
850 builder.appendNumber(m_entry.sizeVal);
852 case Options::Type::doubleType:
853 builder.appendNumber(m_entry.doubleVal);
855 case Options::Type::int32Type:
856 builder.appendNumber(m_entry.int32Val);
858 case Options::Type::optionRangeType:
859 builder.append(m_entry.optionRangeVal.rangeString());
861 case Options::Type::optionStringType: {
862 const char* option = m_entry.optionStringVal;
866 builder.append(option);
870 case Options::Type::gcLogLevelType: {
871 builder.append(GCLogging::levelAsString(m_entry.gcLogLevelVal));
877 bool Option::operator==(const Option& other) const
880 case Options::Type::boolType:
881 return m_entry.boolVal == other.m_entry.boolVal;
882 case Options::Type::unsignedType:
883 return m_entry.unsignedVal == other.m_entry.unsignedVal;
884 case Options::Type::sizeType:
885 return m_entry.sizeVal == other.m_entry.sizeVal;
886 case Options::Type::doubleType:
887 return (m_entry.doubleVal == other.m_entry.doubleVal) || (std::isnan(m_entry.doubleVal) && std::isnan(other.m_entry.doubleVal));
888 case Options::Type::int32Type:
889 return m_entry.int32Val == other.m_entry.int32Val;
890 case Options::Type::optionRangeType:
891 return m_entry.optionRangeVal.rangeString() == other.m_entry.optionRangeVal.rangeString();
892 case Options::Type::optionStringType:
893 return (m_entry.optionStringVal == other.m_entry.optionStringVal)
894 || (m_entry.optionStringVal && other.m_entry.optionStringVal && !strcmp(m_entry.optionStringVal, other.m_entry.optionStringVal));
895 case Options::Type::gcLogLevelType:
896 return m_entry.gcLogLevelVal == other.m_entry.gcLogLevelVal;