Commit 7b4d2076 authored by msaboff@apple.com's avatar msaboff@apple.com

There should be a runtime option to constrain what functions get DFG compiled

https://bugs.webkit.org/show_bug.cgi?id=115576

Reviewed by Mark Hahnenberg.

Added OptionRange to Options to allow checking that something is within an option
or not.  The new OptionClass supports range strings in the form of [!]<low>[:<high>].
If only one value is given, then it will be used for both low and high.  A leading
'!' inverts the check.  If no range is given, then checking for a value within a range
will always return true.  Added the option "bytecodeRangeToDFGCompile" that takes an
OptionRange string to select the bytecode range of code blocks to DFG compile.

* dfg/DFGDriver.cpp:
(JSC::DFG::compile): Added new check for bytecode count within bytecodeRangeToDFGCompile
range.
* runtime/Options.cpp:
(JSC::parse): Added overloaded parse() for OptionRange.
(JSC::OptionRange::init): Parse range string and then initialize the range.
(JSC::OptionRange::isInRange): Function used by consumer to check if a value is within
the specified range.
(JSC::Options::dumpOption): Added code to dump OptionRange options.
* runtime/Options.h:
(OptionRange): New class.
(JSC::OptionRange::operator= ): This is really used as a default ctor for use within
the Option static array initialization.
(JSC::OptionRange::rangeString): This is used for debug.  It assumes that the char*
passed into OptionRange::init is valid when this function is called.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@149552 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d1563c25
2013-05-03 Michael Saboff <msaboff@apple.com>
There should be a runtime option to constrain what functions get DFG compiled
https://bugs.webkit.org/show_bug.cgi?id=115576
Reviewed by Mark Hahnenberg.
Added OptionRange to Options to allow checking that something is within an option
or not. The new OptionClass supports range strings in the form of [!]<low>[:<high>].
If only one value is given, then it will be used for both low and high. A leading
'!' inverts the check. If no range is given, then checking for a value within a range
will always return true. Added the option "bytecodeRangeToDFGCompile" that takes an
OptionRange string to select the bytecode range of code blocks to DFG compile.
* dfg/DFGDriver.cpp:
(JSC::DFG::compile): Added new check for bytecode count within bytecodeRangeToDFGCompile
range.
* runtime/Options.cpp:
(JSC::parse): Added overloaded parse() for OptionRange.
(JSC::OptionRange::init): Parse range string and then initialize the range.
(JSC::OptionRange::isInRange): Function used by consumer to check if a value is within
the specified range.
(JSC::Options::dumpOption): Added code to dump OptionRange options.
* runtime/Options.h:
(OptionRange): New class.
(JSC::OptionRange::operator= ): This is really used as a default ctor for use within
the Option static array initialization.
(JSC::OptionRange::rangeString): This is used for debug. It assumes that the char*
passed into OptionRange::init is valid when this function is called.
2013-05-02 Oliver Hunt <oliver@apple.com>
Fix potential bug in lookup logic
......
......@@ -76,7 +76,10 @@ inline bool compile(CompileMode compileMode, ExecState* exec, CodeBlock* codeBlo
if (!Options::useDFGJIT())
return false;
if (!Options::bytecodeRangeToDFGCompile().isInRange(codeBlock->instructionCount()))
return false;
if (logCompilationChanges())
dataLog("DFG compiling ", *codeBlock, ", number of instructions = ", codeBlock->instructionCount(), "\n");
......
......@@ -72,6 +72,11 @@ static bool parse(const char* string, double& value)
return sscanf(string, "%lf", &value) == 1;
}
static bool parse(const char* string, OptionRange& value)
{
return value.init(string);
}
template<typename T>
void overrideOptionWithHeuristic(T& variable, const char* name)
{
......@@ -105,6 +110,59 @@ static unsigned computeNumberOfGCMarkers(int maxNumberOfGCMarkers)
return cpusToUse;
}
bool OptionRange::init(const char* rangeString)
{
// rangeString should be in the form of [!]<low>[:<high>]
// where low and high are unsigned
bool invert = false;
if (m_state > Uninitialized)
return true;
if (!rangeString) {
m_state = InitError;
return false;
}
m_rangeString = rangeString;
if (*rangeString == '!') {
invert = true;
rangeString++;
}
int scanResult = sscanf(rangeString, " %u:%u", &m_lowLimit, &m_highLimit);
if (!scanResult || scanResult == EOF) {
m_state = InitError;
return false;
}
if (scanResult == 1)
m_highLimit = m_lowLimit;
if (m_lowLimit > m_highLimit) {
m_state = InitError;
return false;
}
m_state = invert ? Inverted : Normal;
return true;
}
bool OptionRange::isInRange(unsigned count)
{
if (m_state < Normal)
return true;
if ((m_lowLimit <= count) && (count <= m_highLimit))
return m_state == Normal ? true : false;
return m_state == Normal ? false : true;
}
Options::Entry Options::s_options[Options::numberOfOptions];
// Realize the names for each of the options:
......@@ -227,6 +285,9 @@ void Options::dumpOption(OptionID id, FILE* stream, const char* header, const ch
case int32Type:
fprintf(stream, "%d", s_options[id].u.int32Val);
break;
case optionRangeType:
fprintf(stream, "%s", s_options[id].u.optionRangeVal.rangeString());
break;
}
fprintf(stream, "%s", footer);
}
......
......@@ -60,6 +60,33 @@ namespace JSC {
// values after the sanity checks (for your own testing), then you're liable to
// ensure that the new values set are sane and reasonable for your own run.
class OptionRange {
private:
enum RangeState { Uninitialized, InitError, Normal, Inverted };
public:
OptionRange& operator= (const int& rhs)
{ // Only needed for initialization
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) \
......@@ -74,6 +101,7 @@ namespace JSC {
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) \
......@@ -179,6 +207,7 @@ private:
unsignedType,
doubleType,
int32Type,
optionRangeType,
};
// For storing for an option value:
......@@ -188,6 +217,7 @@ private:
unsigned unsignedVal;
double doubleVal;
int32 int32Val;
OptionRange optionRangeVal;
} u;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment