/*
- * Copyright (C) 2011, 2012, 2013, 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2011-2015 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
#include "JSExportMacros.h"
#include <stdint.h>
#include <stdio.h>
+#include <wtf/PrintStream.h>
#include <wtf/StdLibExtras.h>
namespace JSC {
bool init(const char*);
bool isInRange(unsigned);
- const char* rangeString() { return (m_state > InitError) ? m_rangeString : "<null>"; }
+ const char* rangeString() const { return (m_state > InitError) ? m_rangeString : "<null>"; }
+
+ void dump(PrintStream& out) const;
private:
RangeState m_state;
typedef const char* optionString;
#define JSC_OPTIONS(v) \
- v(bool, useLLInt, true) \
- v(bool, useJIT, true) \
- v(bool, useDFGJIT, true) \
- v(bool, useRegExpJIT, true) \
+ v(unsigned, showOptions, 0, "shows JSC options (0 = None, 1 = Overridden only, 2 = All, 3 = Verbose)") \
\
- v(unsigned, maxPerThreadStackUsage, 4 * MB) \
- v(unsigned, reservedZoneSize, 128 * KB) \
- v(unsigned, errorModeReservedZoneSize, 64 * KB) \
+ v(bool, useLLInt, true, "allows the LLINT to be used if true") \
+ v(bool, useJIT, true, "allows the baseline JIT to be used if true") \
+ v(bool, useDFGJIT, true, "allows the DFG JIT to be used if true") \
+ v(bool, useRegExpJIT, true, "allows the RegExp JIT to be used if true") \
\
- v(bool, crashIfCantAllocateJITMemory, false) \
+ v(bool, reportMustSucceedExecutableAllocations, false, nullptr) \
\
- v(bool, forceDFGCodeBlockLiveness, false) \
- v(bool, forceICFailure, false) \
+ v(unsigned, maxPerThreadStackUsage, 4 * MB, nullptr) \
+ v(unsigned, reservedZoneSize, 128 * KB, nullptr) \
+ v(unsigned, errorModeReservedZoneSize, 64 * KB, nullptr) \
\
- v(bool, dumpGeneratedBytecodes, false) \
- v(bool, dumpBytecodeLivenessResults, false) \
- v(bool, validateBytecode, false) \
- v(bool, forceDebuggerBytecodeGeneration, false) \
- v(bool, forceProfilerBytecodeGeneration, false) \
+ v(bool, crashIfCantAllocateJITMemory, false, nullptr) \
+ v(unsigned, jitMemoryReservationSize, 0, nullptr) \
\
- /* showDisassembly implies showDFGDisassembly. */ \
- v(bool, showDisassembly, false) \
- v(bool, showDFGDisassembly, false) \
- v(bool, showFTLDisassembly, false) \
- v(bool, showAllDFGNodes, false) \
- v(optionRange, bytecodeRangeToDFGCompile, 0) \
- v(optionString, dfgFunctionWhitelistFile, nullptr) \
- v(bool, dumpBytecodeAtDFGTime, false) \
- v(bool, dumpGraphAtEachPhase, false) \
- v(bool, verboseDFGByteCodeParsing, false) \
- v(bool, verboseCompilation, false) \
- v(bool, verboseFTLCompilation, false) \
- v(bool, logCompilationChanges, false) \
- v(bool, printEachOSRExit, false) \
- v(bool, validateGraph, false) \
- v(bool, validateGraphAtEachPhase, false) \
- v(bool, verboseOSR, false) \
- v(bool, verboseFTLOSRExit, false) \
- v(bool, verboseCallLink, false) \
- v(bool, verboseCompilationQueue, false) \
- v(bool, reportCompileTimes, false) \
- v(bool, reportFTLCompileTimes, false) \
- v(bool, verboseCFA, false) \
- v(bool, verboseFTLToJSThunk, false) \
- v(bool, verboseFTLFailure, false) \
- v(bool, alwaysComputeHash, false) \
- v(bool, testTheFTL, false) \
- v(bool, verboseSanitizeStack, false) \
- v(bool, alwaysDoFullCollection, false) \
- v(bool, eagerlyUpdateTopCallFrame, false) \
- \
- v(bool, enableOSREntryToDFG, true) \
- v(bool, enableOSREntryToFTL, true) \
- \
- v(bool, useFTLJIT, true) \
- v(bool, enableExperimentalFTLCoverage, false) \
- v(bool, useFTLTBAA, true) \
- v(bool, enableLLVMFastISel, false) \
- v(bool, useLLVMSmallCodeModel, false) \
- v(bool, dumpLLVMIR, false) \
- v(bool, validateFTLOSRExitLiveness, false) \
- v(bool, llvmAlwaysFailsBeforeCompile, false) \
- v(bool, llvmAlwaysFailsBeforeLink, false) \
- v(bool, llvmSimpleOpt, true) \
- v(unsigned, llvmBackendOptimizationLevel, 2) \
- v(unsigned, llvmOptimizationLevel, 2) \
- v(unsigned, llvmSizeLevel, 0) \
- v(unsigned, llvmMaxStackSize, 128 * KB) \
- v(bool, llvmDisallowAVX, true) \
- v(bool, ftlCrashes, false) /* fool-proof way of checking that you ended up in the FTL. ;-) */\
- v(bool, clobberAllRegsInFTLICSlowPath, !ASSERT_DISABLED) \
- v(bool, assumeAllRegsInFTLICAreLive, false) \
- v(bool, enableAccessInlining, true) \
- v(bool, enablePolyvariantDevirtualization, true) \
- v(bool, enablePolymorphicAccessInlining, true) \
- \
- v(bool, enableConcurrentJIT, true) \
- v(unsigned, numberOfDFGCompilerThreads, computeNumberOfWorkerThreads(2, 2) - 1) \
- v(unsigned, numberOfFTLCompilerThreads, computeNumberOfWorkerThreads(8, 2) - 1) \
- v(int32, priorityDeltaOfDFGCompilerThreads, computePriorityDeltaOfWorkerThreads(-1, 0)) \
- v(int32, priorityDeltaOfFTLCompilerThreads, computePriorityDeltaOfWorkerThreads(-2, 0)) \
- \
- v(bool, enableProfiler, false) \
- \
- v(bool, forceUDis86Disassembler, false) \
- v(bool, forceLLVMDisassembler, false) \
- \
- v(bool, enableArchitectureSpecificOptimizations, true) \
- \
- v(bool, breakOnThrow, false) \
- \
- v(unsigned, maximumOptimizationCandidateInstructionCount, 100000) \
- \
- v(unsigned, maximumFunctionForCallInlineCandidateInstructionCount, 180) \
- v(unsigned, maximumFunctionForClosureCallInlineCandidateInstructionCount, 100) \
- v(unsigned, maximumFunctionForConstructInlineCandidateInstructionCount, 100) \
- \
- v(unsigned, maximumFTLCandidateInstructionCount, 20000) \
- \
- /* Depth of inline stack, so 1 = no inlining, 2 = one level, etc. */ \
- v(unsigned, maximumInliningDepth, 5) \
- v(unsigned, maximumInliningRecursion, 2) \
- v(unsigned, maximumInliningDepthForMustInline, 7) \
- v(unsigned, maximumInliningRecursionForMustInline, 3) \
- \
- /* Maximum size of a caller for enabling inlining. This is purely to protect us */\
- /* from super long compiles that take a lot of memory. */\
- v(unsigned, maximumInliningCallerSize, 10000) \
- \
- v(bool, enablePolyvariantCallInlining, true) \
- v(bool, enablePolyvariantByIdInlining, true) \
- \
- v(unsigned, maximumBinaryStringSwitchCaseLength, 50) \
- v(unsigned, maximumBinaryStringSwitchTotalLength, 2000) \
- \
- v(int32, thresholdForJITAfterWarmUp, 500) \
- v(int32, thresholdForJITSoon, 100) \
- \
- v(int32, thresholdForOptimizeAfterWarmUp, 1000) \
- v(int32, thresholdForOptimizeAfterLongWarmUp, 1000) \
- v(int32, thresholdForOptimizeSoon, 1000) \
- v(int32, executionCounterIncrementForLoop, 1) \
- v(int32, executionCounterIncrementForEntry, 15) \
- \
- v(int32, thresholdForFTLOptimizeAfterWarmUp, 100000) \
- v(int32, thresholdForFTLOptimizeSoon, 1000) \
- v(int32, ftlTierUpCounterIncrementForLoop, 1) \
- v(int32, ftlTierUpCounterIncrementForReturn, 15) \
- v(unsigned, ftlOSREntryFailureCountForReoptimization, 15) \
- v(unsigned, ftlOSREntryRetryThreshold, 100) \
- \
- v(int32, evalThresholdMultiplier, 10) \
- \
- v(bool, randomizeExecutionCountsBetweenCheckpoints, false) \
- v(int32, maximumExecutionCountsBetweenCheckpointsForBaseline, 1000) \
- v(int32, maximumExecutionCountsBetweenCheckpointsForUpperTiers, 50000) \
- \
- v(unsigned, likelyToTakeSlowCaseMinimumCount, 100) \
- v(unsigned, couldTakeSlowCaseMinimumCount, 10) \
- \
- v(unsigned, osrExitCountForReoptimization, 100) \
- v(unsigned, osrExitCountForReoptimizationFromLoop, 5) \
- \
- v(unsigned, reoptimizationRetryCounterMax, 0) \
- v(unsigned, reoptimizationRetryCounterStep, 1) \
+ v(bool, forceDFGCodeBlockLiveness, false, nullptr) \
+ v(bool, forceICFailure, false, nullptr) \
\
- v(unsigned, minimumOptimizationDelay, 1) \
- v(unsigned, maximumOptimizationDelay, 5) \
- v(double, desiredProfileLivenessRate, 0.75) \
- v(double, desiredProfileFullnessRate, 0.35) \
+ v(bool, dumpGeneratedBytecodes, false, nullptr) \
+ v(bool, dumpBytecodeLivenessResults, false, nullptr) \
+ v(bool, validateBytecode, false, nullptr) \
+ v(bool, forceDebuggerBytecodeGeneration, false, nullptr) \
+ v(bool, forceProfilerBytecodeGeneration, false, nullptr) \
\
- v(double, doubleVoteRatioForDoubleFormat, 2) \
- v(double, structureCheckVoteRatioForHoisting, 1) \
- v(double, checkArrayVoteRatioForHoisting, 1) \
+ v(bool, enableFunctionDotArguments, true, nullptr) \
\
- v(unsigned, minimumNumberOfScansBetweenRebalance, 100) \
- v(unsigned, numberOfGCMarkers, computeNumberOfGCMarkers(7)) \
- v(unsigned, opaqueRootMergeThreshold, 1000) \
- v(double, minHeapUtilization, 0.8) \
- v(double, minCopiedBlockUtilization, 0.9) \
- v(double, minMarkedBlockUtilization, 0.9) \
- v(unsigned, slowPathAllocsBetweenGCs, 0) \
- \
- v(double, percentCPUPerMBForFullTimer, 0.0003125) \
- v(double, percentCPUPerMBForEdenTimer, 0.0025) \
- v(double, collectionTimerMaxPercentCPU, 0.05) \
- \
- v(bool, forceWeakRandomSeed, false) \
- v(unsigned, forcedWeakRandomSeed, 0) \
+ /* showDisassembly implies showDFGDisassembly. */ \
+ v(bool, showDisassembly, false, "dumps disassembly of all JIT compiled code upon compilation") \
+ v(bool, asyncDisassembly, false, nullptr) \
+ v(bool, showDFGDisassembly, false, "dumps disassembly of DFG function upon compilation") \
+ v(bool, showFTLDisassembly, false, "dumps disassembly of FTL function upon compilation") \
+ v(bool, showAllDFGNodes, false, nullptr) \
+ v(optionRange, bytecodeRangeToDFGCompile, 0, "bytecode size range to allow DFG compilation on, e.g. 1:100") \
+ v(optionString, dfgWhitelist, nullptr, "file with list of function signatures to allow DFG compilation on") \
+ v(bool, dumpSourceAtDFGTime, false, "dumps source code of JS function being DFG compiled") \
+ v(bool, dumpBytecodeAtDFGTime, false, "dumps bytecode of JS function being DFG compiled") \
+ v(bool, dumpGraphAfterParsing, false, nullptr) \
+ v(bool, dumpGraphAtEachPhase, false, nullptr) \
+ v(bool, verboseDFGByteCodeParsing, false, nullptr) \
+ v(bool, verboseCompilation, false, nullptr) \
+ v(bool, verboseFTLCompilation, false, nullptr) \
+ v(bool, logCompilationChanges, false, nullptr) \
+ v(bool, printEachOSRExit, false, nullptr) \
+ v(bool, validateGraph, false, nullptr) \
+ v(bool, validateGraphAtEachPhase, false, nullptr) \
+ v(bool, verboseValidationFailure, false, nullptr) \
+ v(bool, verboseOSR, false, nullptr) \
+ v(bool, verboseFTLOSRExit, false, nullptr) \
+ v(bool, verboseCallLink, false, nullptr) \
+ v(bool, verboseCompilationQueue, false, nullptr) \
+ v(bool, reportCompileTimes, false, "dumps JS function signature and the time it took to compile") \
+ v(bool, reportFTLCompileTimes, false, "dumps JS function signature and the time it took to FTL compile") \
+ v(bool, verboseCFA, false, nullptr) \
+ v(bool, verboseFTLToJSThunk, false, nullptr) \
+ v(bool, verboseFTLFailure, false, nullptr) \
+ v(bool, alwaysComputeHash, false, nullptr) \
+ v(bool, testTheFTL, false, nullptr) \
+ v(bool, verboseSanitizeStack, false, nullptr) \
+ v(bool, alwaysDoFullCollection, false, nullptr) \
+ v(bool, eagerlyUpdateTopCallFrame, false, nullptr) \
+ \
+ v(bool, enableOSREntryToDFG, true, nullptr) \
+ v(bool, enableOSREntryToFTL, true, nullptr) \
+ \
+ v(bool, useFTLJIT, true, "allows the FTL JIT to be used if true") \
+ v(bool, useFTLTBAA, true, nullptr) \
+ v(bool, enableLLVMFastISel, false, nullptr) \
+ v(bool, useLLVMSmallCodeModel, false, nullptr) \
+ v(bool, dumpLLVMIR, false, nullptr) \
+ v(bool, validateFTLOSRExitLiveness, false, nullptr) \
+ v(bool, llvmAlwaysFailsBeforeCompile, false, nullptr) \
+ v(bool, llvmAlwaysFailsBeforeLink, false, nullptr) \
+ v(bool, llvmSimpleOpt, true, nullptr) \
+ v(unsigned, llvmBackendOptimizationLevel, 2, nullptr) \
+ v(unsigned, llvmOptimizationLevel, 2, nullptr) \
+ v(unsigned, llvmSizeLevel, 0, nullptr) \
+ v(unsigned, llvmMaxStackSize, 128 * KB, nullptr) \
+ v(bool, llvmDisallowAVX, true, nullptr) \
+ v(bool, ftlCrashes, false, nullptr) /* fool-proof way of checking that you ended up in the FTL. ;-) */\
+ v(bool, ftlCrashesIfCantInitializeLLVM, false, nullptr) \
+ v(bool, clobberAllRegsInFTLICSlowPath, !ASSERT_DISABLED, nullptr) \
+ v(bool, assumeAllRegsInFTLICAreLive, false, nullptr) \
+ v(bool, enableAccessInlining, true, nullptr) \
+ v(bool, enablePolyvariantDevirtualization, true, nullptr) \
+ v(bool, enablePolymorphicAccessInlining, true, nullptr) \
+ v(bool, enablePolymorphicCallInlining, true, nullptr) \
+ v(unsigned, maxPolymorphicCallVariantListSize, 15, nullptr) \
+ v(unsigned, maxPolymorphicCallVariantListSizeForTopTier, 5, nullptr) \
+ v(unsigned, maxPolymorphicCallVariantsForInlining, 5, nullptr) \
+ v(unsigned, frequentCallThreshold, 2, nullptr) \
+ v(double, minimumCallToKnownRate, 0.51, nullptr) \
+ v(bool, optimizeNativeCalls, false, nullptr) \
+ v(bool, enableMovHintRemoval, true, nullptr) \
+ v(bool, enableObjectAllocationSinking, true, nullptr) \
+ \
+ v(bool, enableConcurrentJIT, true, "allows the DFG / FTL compilation in threads other than the executing JS thread") \
+ v(unsigned, numberOfDFGCompilerThreads, computeNumberOfWorkerThreads(2, 2) - 1, nullptr) \
+ v(unsigned, numberOfFTLCompilerThreads, computeNumberOfWorkerThreads(8, 2) - 1, nullptr) \
+ v(int32, priorityDeltaOfDFGCompilerThreads, computePriorityDeltaOfWorkerThreads(-1, 0), nullptr) \
+ v(int32, priorityDeltaOfFTLCompilerThreads, computePriorityDeltaOfWorkerThreads(-2, 0), nullptr) \
+ \
+ v(bool, enableProfiler, false, nullptr) \
+ \
+ v(bool, forceUDis86Disassembler, false, nullptr) \
+ v(bool, forceLLVMDisassembler, false, nullptr) \
+ \
+ v(bool, enableArchitectureSpecificOptimizations, true, nullptr) \
+ \
+ v(bool, breakOnThrow, false, nullptr) \
+ \
+ v(unsigned, maximumOptimizationCandidateInstructionCount, 100000, nullptr) \
+ \
+ v(unsigned, maximumFunctionForCallInlineCandidateInstructionCount, 180, nullptr) \
+ v(unsigned, maximumFunctionForClosureCallInlineCandidateInstructionCount, 100, nullptr) \
+ v(unsigned, maximumFunctionForConstructInlineCandidateInstructionCount, 100, nullptr) \
+ \
+ v(unsigned, maximumFTLCandidateInstructionCount, 20000, nullptr) \
\
- v(bool, useZombieMode, false) \
- v(bool, objectsAreImmortal, false) \
- v(bool, showObjectStatistics, false) \
+ /* Depth of inline stack, so 1 = no inlining, 2 = one level, etc. */ \
+ v(unsigned, maximumInliningDepth, 5, "maximum allowed inlining depth. Depth of 1 means no inlining") \
+ v(unsigned, maximumInliningRecursion, 2, nullptr) \
\
- v(gcLogLevel, logGC, GCLogging::None) \
- v(bool, disableGC, false) \
- v(unsigned, gcMaxHeapSize, 0) \
- v(bool, recordGCPauseTimes, false) \
- v(bool, logHeapStatisticsAtExit, false) \
+ v(unsigned, maximumLLVMInstructionCountForNativeInlining, 80, nullptr) \
\
- v(bool, enableExceptionFuzz, false) \
- v(unsigned, fireExceptionFuzzAt, 0)
+ /* Maximum size of a caller for enabling inlining. This is purely to protect us */\
+ /* from super long compiles that take a lot of memory. */\
+ v(unsigned, maximumInliningCallerSize, 10000, nullptr) \
+ \
+ v(unsigned, maximumVarargsForInlining, 100, nullptr) \
+ \
+ v(bool, enablePolyvariantCallInlining, true, nullptr) \
+ v(bool, enablePolyvariantByIdInlining, true, nullptr) \
+ \
+ v(unsigned, maximumBinaryStringSwitchCaseLength, 50, nullptr) \
+ v(unsigned, maximumBinaryStringSwitchTotalLength, 2000, nullptr) \
+ \
+ v(double, jitPolicyScale, 1.0, "scale JIT thresholds to this specified ratio between 0.0 (compile ASAP) and 1.0 (compile like normal).") \
+ v(bool, forceEagerCompilation, false, nullptr) \
+ v(int32, thresholdForJITAfterWarmUp, 500, nullptr) \
+ v(int32, thresholdForJITSoon, 100, nullptr) \
+ \
+ v(int32, thresholdForOptimizeAfterWarmUp, 1000, nullptr) \
+ v(int32, thresholdForOptimizeAfterLongWarmUp, 1000, nullptr) \
+ v(int32, thresholdForOptimizeSoon, 1000, nullptr) \
+ v(int32, executionCounterIncrementForLoop, 1, nullptr) \
+ v(int32, executionCounterIncrementForEntry, 15, nullptr) \
+ \
+ v(int32, thresholdForFTLOptimizeAfterWarmUp, 100000, nullptr) \
+ v(int32, thresholdForFTLOptimizeSoon, 1000, nullptr) \
+ v(int32, ftlTierUpCounterIncrementForLoop, 1, nullptr) \
+ v(int32, ftlTierUpCounterIncrementForReturn, 15, nullptr) \
+ v(unsigned, ftlOSREntryFailureCountForReoptimization, 15, nullptr) \
+ v(unsigned, ftlOSREntryRetryThreshold, 100, nullptr) \
+ \
+ v(int32, evalThresholdMultiplier, 10, nullptr) \
+ v(unsigned, maximumEvalCacheableSourceLength, 256, nullptr) \
+ \
+ v(bool, randomizeExecutionCountsBetweenCheckpoints, false, nullptr) \
+ v(int32, maximumExecutionCountsBetweenCheckpointsForBaseline, 1000, nullptr) \
+ v(int32, maximumExecutionCountsBetweenCheckpointsForUpperTiers, 50000, nullptr) \
+ \
+ v(unsigned, likelyToTakeSlowCaseMinimumCount, 20, nullptr) \
+ v(unsigned, couldTakeSlowCaseMinimumCount, 10, nullptr) \
+ \
+ v(unsigned, osrExitCountForReoptimization, 100, nullptr) \
+ v(unsigned, osrExitCountForReoptimizationFromLoop, 5, nullptr) \
+ \
+ v(unsigned, reoptimizationRetryCounterMax, 0, nullptr) \
+ \
+ v(unsigned, minimumOptimizationDelay, 1, nullptr) \
+ v(unsigned, maximumOptimizationDelay, 5, nullptr) \
+ v(double, desiredProfileLivenessRate, 0.75, nullptr) \
+ v(double, desiredProfileFullnessRate, 0.35, nullptr) \
+ \
+ v(double, doubleVoteRatioForDoubleFormat, 2, nullptr) \
+ v(double, structureCheckVoteRatioForHoisting, 1, nullptr) \
+ v(double, checkArrayVoteRatioForHoisting, 1, nullptr) \
+ \
+ v(unsigned, minimumNumberOfScansBetweenRebalance, 100, nullptr) \
+ v(unsigned, numberOfGCMarkers, computeNumberOfGCMarkers(7), nullptr) \
+ v(unsigned, opaqueRootMergeThreshold, 1000, nullptr) \
+ v(double, minHeapUtilization, 0.8, nullptr) \
+ v(double, minCopiedBlockUtilization, 0.9, nullptr) \
+ v(double, minMarkedBlockUtilization, 0.9, nullptr) \
+ v(unsigned, slowPathAllocsBetweenGCs, 0, "force a GC on every Nth slow path alloc, where N is specified by this option") \
+ \
+ v(double, percentCPUPerMBForFullTimer, 0.0003125, nullptr) \
+ v(double, percentCPUPerMBForEdenTimer, 0.0025, nullptr) \
+ v(double, collectionTimerMaxPercentCPU, 0.05, nullptr) \
+ \
+ v(bool, forceWeakRandomSeed, false, nullptr) \
+ v(unsigned, forcedWeakRandomSeed, 0, nullptr) \
+ \
+ v(bool, useZombieMode, false, "debugging option to scribble over dead objects with 0xdeadbeef") \
+ v(bool, objectsAreImmortal, false, "debugging option to keep all objects alive forever") \
+ v(bool, showObjectStatistics, false, nullptr) \
+ \
+ v(gcLogLevel, logGC, GCLogging::None, "debugging option to log GC activity (0 = None, 1 = Basic, 2 = Verbose)") \
+ v(bool, disableGC, false, nullptr) \
+ v(unsigned, gcMaxHeapSize, 0, nullptr) \
+ v(unsigned, forceRAMSize, 0, nullptr) \
+ v(bool, recordGCPauseTimes, false, nullptr) \
+ v(bool, logHeapStatisticsAtExit, false, nullptr) \
+ v(bool, enableTypeProfiler, false, nullptr) \
+ v(bool, enableControlFlowProfiler, false, nullptr) \
+ \
+ v(bool, verifyHeap, false, nullptr) \
+ v(unsigned, numberOfGCCyclesToRecordForVerification, 3, nullptr) \
+ \
+ v(bool, enableExceptionFuzz, false, nullptr) \
+ v(unsigned, fireExceptionFuzzAt, 0, nullptr) \
+ \
+ v(bool, enableExecutableAllocationFuzz, false, nullptr) \
+ v(unsigned, fireExecutableAllocationFuzzAt, 0, nullptr) \
+ v(unsigned, fireExecutableAllocationFuzzAtOrAfter, 0, nullptr) \
+ v(bool, verboseExecutableAllocationFuzz, false, nullptr) \
+ \
+ v(bool, enableOSRExitFuzz, false, nullptr) \
+ v(unsigned, fireOSRExitFuzzAtStatic, 0, nullptr) \
+ v(unsigned, fireOSRExitFuzzAt, 0, nullptr) \
+ v(unsigned, fireOSRExitFuzzAtOrAfter, 0, nullptr) \
+ \
+ v(bool, enableDollarVM, false, "installs the $vm debugging tool in global objects") \
+ v(optionString, functionOverrides, nullptr, "file with debugging overrides for function bodies") \
class Options {
public:
+ enum class DumpLevel {
+ None = 0,
+ Overridden,
+ All,
+ Verbose
+ };
+
// This typedef is to allow us to eliminate the '_' in the field name in
// union inside Entry. This is needed to keep the style checker happy.
typedef int32_t int32;
// Declare the option IDs:
enum OptionID {
-#define FOR_EACH_OPTION(type_, name_, defaultValue_) \
- OPT_##name_,
+#define FOR_EACH_OPTION(type_, name_, defaultValue_, description_) \
+ name_##ID,
JSC_OPTIONS(FOR_EACH_OPTION)
#undef FOR_EACH_OPTION
numberOfOptions
};
+ enum class Type {
+ boolType,
+ unsignedType,
+ doubleType,
+ int32Type,
+ optionRangeType,
+ optionStringType,
+ gcLogLevelType,
+ };
- static void initialize();
+ JS_EXPORT_PRIVATE static void initialize();
// Parses a single command line option in the format "<optionName>=<value>"
// (no spaces allowed) and set the specified option if appropriate.
JS_EXPORT_PRIVATE static bool setOption(const char* arg);
- JS_EXPORT_PRIVATE static void dumpAllOptions(FILE* stream = stdout);
- static void dumpOption(OptionID id, FILE* stream = stdout, const char* header = "", const char* footer = "");
+ JS_EXPORT_PRIVATE static void dumpAllOptions(DumpLevel, const char* title = nullptr, FILE* stream = stdout);
+ static void dumpOption(DumpLevel, OptionID, FILE* stream = stdout, const char* header = "", const char* footer = "");
+ JS_EXPORT_PRIVATE static void ensureOptionsAreCoherent();
// Declare accessors for each option:
-#define FOR_EACH_OPTION(type_, name_, defaultValue_) \
- ALWAYS_INLINE static type_& name_() { return s_options[OPT_##name_].u.type_##Val; } \
- static bool name_##WasOverridden() { return s_options[OPT_##name_].didOverride; }
+#define FOR_EACH_OPTION(type_, name_, defaultValue_, description_) \
+ ALWAYS_INLINE static type_& name_() { return s_options[name_##ID].type_##Val; } \
+ ALWAYS_INLINE static type_& name_##Default() { return s_defaultOptions[name_##ID].type_##Val; }
JSC_OPTIONS(FOR_EACH_OPTION)
#undef FOR_EACH_OPTION
private:
- enum EntryType {
- boolType,
- unsignedType,
- doubleType,
- int32Type,
- optionRangeType,
- optionStringType,
- gcLogLevelType,
- };
-
// For storing for an option value:
- struct Entry {
- union {
- bool boolVal;
- unsigned unsignedVal;
- double doubleVal;
- int32 int32Val;
- OptionRange optionRangeVal;
- const char* optionStringVal;
- GCLogging::Level gcLogLevelVal;
- } u;
- bool didOverride;
+ union Entry {
+ bool boolVal;
+ unsigned unsignedVal;
+ double doubleVal;
+ int32 int32Val;
+ OptionRange optionRangeVal;
+ const char* optionStringVal;
+ GCLogging::Level gcLogLevelVal;
};
// For storing constant meta data about each option:
struct EntryInfo {
const char* name;
- EntryType type;
+ const char* description;
+ Type type;
};
Options();
- // Declare the options:
-#define FOR_EACH_OPTION(type_, name_, defaultValue_) \
- type_ m_##name_;
- JSC_OPTIONS(FOR_EACH_OPTION)
-#undef FOR_EACH_OPTION
-
// Declare the singleton instance of the options store:
JS_EXPORTDATA static Entry s_options[numberOfOptions];
+ static Entry s_defaultOptions[numberOfOptions];
static const EntryInfo s_optionsInfo[numberOfOptions];
+
+ friend class Option;
};
+class Option {
+public:
+ Option(Options::OptionID id)
+ : m_id(id)
+ , m_entry(Options::s_options[m_id])
+ {
+ }
+
+ void dump(FILE*) const;
+ bool operator==(const Option& other) const;
+ bool operator!=(const Option& other) const { return !(*this == other); }
+
+ const char* name() const;
+ const char* description() const;
+ Options::Type type() const;
+ bool isOverridden() const;
+ const Option defaultOption() const;
+
+ bool& boolVal();
+ unsigned& unsignedVal();
+ double& doubleVal();
+ int32_t& int32Val();
+ OptionRange optionRangeVal();
+ const char* optionStringVal();
+ GCLogging::Level& gcLogLevelVal();
+
+private:
+ // Only used for constructing default Options.
+ Option(Options::OptionID id, Options::Entry& entry)
+ : m_id(id)
+ , m_entry(entry)
+ {
+ }
+
+ Options::OptionID m_id;
+ Options::Entry& m_entry;
+};
+
+inline const char* Option::name() const
+{
+ return Options::s_optionsInfo[m_id].name;
+}
+
+inline const char* Option::description() const
+{
+ return Options::s_optionsInfo[m_id].description;
+}
+
+inline Options::Type Option::type() const
+{
+ return Options::s_optionsInfo[m_id].type;
+}
+
+inline bool Option::isOverridden() const
+{
+ return *this != defaultOption();
+}
+
+inline const Option Option::defaultOption() const
+{
+ return Option(m_id, Options::s_defaultOptions[m_id]);
+}
+
+inline bool& Option::boolVal()
+{
+ return m_entry.boolVal;
+}
+
+inline unsigned& Option::unsignedVal()
+{
+ return m_entry.unsignedVal;
+}
+
+inline double& Option::doubleVal()
+{
+ return m_entry.doubleVal;
+}
+
+inline int32_t& Option::int32Val()
+{
+ return m_entry.int32Val;
+}
+
+inline OptionRange Option::optionRangeVal()
+{
+ return m_entry.optionRangeVal;
+}
+
+inline const char* Option::optionStringVal()
+{
+ return m_entry.optionStringVal;
+}
+
+inline GCLogging::Level& Option::gcLogLevelVal()
+{
+ return m_entry.gcLogLevelVal;
+}
+
} // namespace JSC
#endif // Options_h