#ifndef Options_h
#define Options_h
#include "JSExportMacros.h"
#include <stdint.h>
#include <stdio.h>
namespace JSC {
class OptionRange {
private:
enum RangeState { Uninitialized, InitError, Normal, Inverted };
public:
OptionRange& operator= (const int& rhs)
{ if (!rhs) {
m_state = Uninitialized;
m_rangeString = 0;
m_lowLimit = 0;
m_highLimit = 0;
}
return *this;
}
bool init(const char*);
bool isInRange(unsigned);
const char* rangeString() { return (m_state > InitError) ? m_rangeString : "<null>"; }
private:
RangeState m_state;
const char* m_rangeString;
unsigned m_lowLimit;
unsigned m_highLimit;
};
typedef OptionRange optionRange;
#define JSC_OPTIONS(v) \
v(bool, useJIT, true) \
v(bool, useDFGJIT, true) \
v(bool, useRegExpJIT, true) \
\
v(bool, forceDFGCodeBlockLiveness, false) \
\
v(bool, dumpGeneratedBytecodes, false) \
\
\
v(bool, showDisassembly, false) \
v(bool, showDFGDisassembly, false) \
v(bool, showAllDFGNodes, false) \
v(optionRange, bytecodeRangeToDFGCompile, 0) \
v(bool, dumpBytecodeAtDFGTime, false) \
v(bool, dumpGraphAtEachPhase, false) \
v(bool, verboseCompilation, false) \
v(bool, logCompilationChanges, false) \
v(bool, printEachOSRExit, false) \
v(bool, validateGraph, false) \
v(bool, validateGraphAtEachPhase, false) \
\
v(bool, enableProfiler, false) \
\
v(unsigned, maximumOptimizationCandidateInstructionCount, 10000) \
\
v(unsigned, maximumFunctionForCallInlineCandidateInstructionCount, 180) \
v(unsigned, maximumFunctionForClosureCallInlineCandidateInstructionCount, 100) \
v(unsigned, maximumFunctionForConstructInlineCandidateInstructionCount, 100) \
\
\
v(unsigned, maximumInliningDepth, 5) \
\
v(int32, thresholdForJITAfterWarmUp, 100) \
v(int32, thresholdForJITSoon, 100) \
\
v(int32, thresholdForOptimizeAfterWarmUp, 1000) \
v(int32, thresholdForOptimizeAfterLongWarmUp, 1000) \
v(int32, thresholdForOptimizeSoon, 1000) \
\
v(int32, executionCounterIncrementForLoop, 1) \
v(int32, executionCounterIncrementForReturn, 15) \
\
v(int32, evalThresholdMultiplier, 10) \
\
v(bool, randomizeExecutionCountsBetweenCheckpoints, false) \
v(int32, maximumExecutionCountsBetweenCheckpoints, 1000) \
\
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(unsigned, minimumOptimizationDelay, 1) \
v(unsigned, maximumOptimizationDelay, 5) \
v(double, desiredProfileLivenessRate, 0.75) \
v(double, desiredProfileFullnessRate, 0.35) \
\
v(double, doubleVoteRatioForDoubleFormat, 2) \
v(double, structureCheckVoteRatioForHoisting, 1) \
\
v(unsigned, minimumNumberOfScansBetweenRebalance, 100) \
v(unsigned, numberOfGCMarkers, computeNumberOfGCMarkers(7)) \
v(unsigned, opaqueRootMergeThreshold, 1000) \
v(double, minHeapUtilization, 0.8) \
v(double, minCopiedBlockUtilization, 0.9) \
\
v(bool, forceWeakRandomSeed, false) \
v(unsigned, forcedWeakRandomSeed, 0) \
\
v(bool, useZombieMode, false) \
v(bool, objectsAreImmortal, false) \
v(bool, showObjectStatistics, false) \
\
v(unsigned, gcMaxHeapSize, 0) \
v(bool, recordGCPauseTimes, false) \
v(bool, logHeapStatisticsAtExit, false)
class Options {
public:
typedef int32_t int32;
enum OptionID {
#define FOR_EACH_OPTION(type_, name_, defaultValue_) \
OPT_##name_,
JSC_OPTIONS(FOR_EACH_OPTION)
#undef FOR_EACH_OPTION
numberOfOptions
};
static void initialize();
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 = "");
#define FOR_EACH_OPTION(type_, name_, defaultValue_) \
ALWAYS_INLINE static type_& name_() { return s_options[OPT_##name_].u.type_##Val; }
JSC_OPTIONS(FOR_EACH_OPTION)
#undef FOR_EACH_OPTION
private:
enum EntryType {
boolType,
unsignedType,
doubleType,
int32Type,
optionRangeType,
};
struct Entry {
union {
bool boolVal;
unsigned unsignedVal;
double doubleVal;
int32 int32Val;
OptionRange optionRangeVal;
} u;
};
struct EntryInfo {
const char* name;
EntryType type;
};
Options();
#define FOR_EACH_OPTION(type_, name_, defaultValue_) \
type_ m_##name_;
JSC_OPTIONS(FOR_EACH_OPTION)
#undef FOR_EACH_OPTION
JS_EXPORTDATA static Entry s_options[numberOfOptions];
static const EntryInfo s_optionsInfo[numberOfOptions];
};
}
#endif // Options_h