- Revision
- 149552
- Author
- [email protected]
- Date
- 2013-05-04 00:30:35 -0700 (Sat, 04 May 2013)
Log Message
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.
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (149551 => 149552)
--- trunk/Source/_javascript_Core/ChangeLog 2013-05-04 07:23:13 UTC (rev 149551)
+++ trunk/Source/_javascript_Core/ChangeLog 2013-05-04 07:30:35 UTC (rev 149552)
@@ -1,3 +1,33 @@
+2013-05-03 Michael Saboff <[email protected]>
+
+ 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 <[email protected]>
Fix potential bug in lookup logic
Modified: trunk/Source/_javascript_Core/dfg/DFGDriver.cpp (149551 => 149552)
--- trunk/Source/_javascript_Core/dfg/DFGDriver.cpp 2013-05-04 07:23:13 UTC (rev 149551)
+++ trunk/Source/_javascript_Core/dfg/DFGDriver.cpp 2013-05-04 07:30:35 UTC (rev 149552)
@@ -76,7 +76,10 @@
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");
Modified: trunk/Source/_javascript_Core/runtime/Options.cpp (149551 => 149552)
--- trunk/Source/_javascript_Core/runtime/Options.cpp 2013-05-04 07:23:13 UTC (rev 149551)
+++ trunk/Source/_javascript_Core/runtime/Options.cpp 2013-05-04 07:30:35 UTC (rev 149552)
@@ -72,6 +72,11 @@
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 @@
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 @@
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);
}
Modified: trunk/Source/_javascript_Core/runtime/Options.h (149551 => 149552)
--- trunk/Source/_javascript_Core/runtime/Options.h 2013-05-04 07:23:13 UTC (rev 149551)
+++ trunk/Source/_javascript_Core/runtime/Options.h 2013-05-04 07:30:35 UTC (rev 149552)
@@ -60,7 +60,34 @@
// 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) \
v(bool, useDFGJIT, true) \
@@ -74,6 +101,7 @@
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 @@
unsignedType,
doubleType,
int32Type,
+ optionRangeType,
};
// For storing for an option value:
@@ -188,6 +217,7 @@
unsigned unsignedVal;
double doubleVal;
int32 int32Val;
+ OptionRange optionRangeVal;
} u;
};