summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/runtime/Options.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/JavaScriptCore/runtime/Options.cpp')
-rw-r--r--Source/JavaScriptCore/runtime/Options.cpp63
1 files changed, 62 insertions, 1 deletions
diff --git a/Source/JavaScriptCore/runtime/Options.cpp b/Source/JavaScriptCore/runtime/Options.cpp
index 386eb4fcf..40711bfa3 100644
--- a/Source/JavaScriptCore/runtime/Options.cpp
+++ b/Source/JavaScriptCore/runtime/Options.cpp
@@ -36,7 +36,6 @@
#include <wtf/PageBlock.h>
#include <wtf/StdLibExtras.h>
#include <wtf/StringExtras.h>
-#include <wtf/UnusedParam.h>
#if OS(DARWIN) && ENABLE(PARALLEL_GC)
#include <sys/sysctl.h>
@@ -72,6 +71,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 +109,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:
@@ -187,6 +244,7 @@ bool Options::setOption(const char* arg)
#define FOR_EACH_OPTION(type_, name_, defaultValue_) \
if (!strncmp(arg, #name_, equalStr - arg)) { \
type_ value; \
+ value = 0; \
bool success = parse(valueStr, value); \
if (success) { \
name_() = value; \
@@ -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);
}