Diff
Modified: releases/WebKitGTK/webkit-2.10/Source/_javascript_Core/API/tests/ExecutionTimeLimitTest.cpp (189710 => 189711)
--- releases/WebKitGTK/webkit-2.10/Source/_javascript_Core/API/tests/ExecutionTimeLimitTest.cpp 2015-09-14 11:11:43 UTC (rev 189710)
+++ releases/WebKitGTK/webkit-2.10/Source/_javascript_Core/API/tests/ExecutionTimeLimitTest.cpp 2015-09-14 12:00:47 UTC (rev 189711)
@@ -26,12 +26,16 @@
#include "config.h"
#include "ExecutionTimeLimitTest.h"
+#include "InitializeThreading.h"
#include "JSContextRefPrivate.h"
#include "_javascript_Core.h"
+#include "Options.h"
#include <chrono>
#include <wtf/CurrentTime.h>
+#include <wtf/text/StringBuilder.h>
using namespace std::chrono;
+using JSC::Options;
static JSGlobalContextRef context = nullptr;
@@ -48,27 +52,22 @@
}
bool shouldTerminateCallbackWasCalled = false;
-static bool shouldTerminateCallback(JSContextRef ctx, void* context)
+static bool shouldTerminateCallback(JSContextRef, void*)
{
- UNUSED_PARAM(ctx);
- UNUSED_PARAM(context);
shouldTerminateCallbackWasCalled = true;
return true;
}
bool cancelTerminateCallbackWasCalled = false;
-static bool cancelTerminateCallback(JSContextRef ctx, void* context)
+static bool cancelTerminateCallback(JSContextRef, void*)
{
- UNUSED_PARAM(ctx);
- UNUSED_PARAM(context);
cancelTerminateCallbackWasCalled = true;
return false;
}
int extendTerminateCallbackCalled = 0;
-static bool extendTerminateCallback(JSContextRef ctx, void* context)
+static bool extendTerminateCallback(JSContextRef ctx, void*)
{
- UNUSED_PARAM(context);
extendTerminateCallbackCalled++;
if (extendTerminateCallbackCalled == 1) {
JSContextGroupRef contextGroup = JSContextGetGroup(ctx);
@@ -78,159 +77,234 @@
return true;
}
+struct TierOptions {
+ const char* tier;
+ unsigned timeLimitAdjustmentMillis;
+ const char* optionsStr;
+};
int testExecutionTimeLimit()
{
- context = JSGlobalContextCreateInGroup(nullptr, nullptr);
+ static const TierOptions tierOptionsList[] = {
+ { "LLINT", 0, "--enableConcurrentJIT=false --useLLInt=true --useJIT=false" },
+ { "Baseline", 0, "--enableConcurrentJIT=false --useLLInt=true --useJIT=true --useDFGJIT=false" },
+ { "DFG", 0, "--enableConcurrentJIT=false --useLLInt=true --useJIT=true --useDFGJIT=true --useFTLJIT=false" },
+ { "FTL", 200, "--enableConcurrentJIT=false --useLLInt=true --useJIT=true --useDFGJIT=true --useFTLJIT=true" },
+ };
+
+ bool failed = false;
- JSContextGroupRef contextGroup = JSContextGetGroup(context);
- JSObjectRef globalObject = JSContextGetGlobalObject(context);
- ASSERT(JSValueIsObject(context, globalObject));
+ JSC::initializeThreading();
+ Options::initialize(); // Ensure options is initialized first.
- JSValueRef v = nullptr;
- JSValueRef exception = nullptr;
- bool failed = false;
+ for (auto tierOptions : tierOptionsList) {
+ StringBuilder savedOptionsBuilder;
+ Options::dumpAllOptionsInALine(savedOptionsBuilder);
- JSStringRef currentCPUTimeStr = JSStringCreateWithUTF8CString("currentCPUTime");
- JSObjectRef currentCPUTimeFunction = JSObjectMakeFunctionWithCallback(context, currentCPUTimeStr, currentCPUTimeAsJSFunctionCallback);
- JSObjectSetProperty(context, globalObject, currentCPUTimeStr, currentCPUTimeFunction, kJSPropertyAttributeNone, nullptr);
- JSStringRelease(currentCPUTimeStr);
-
- /* Test script timeout: */
- JSContextGroupSetExecutionTimeLimit(contextGroup, .10f, shouldTerminateCallback, 0);
- {
- const char* loopForeverScript = "var startTime = currentCPUTime(); while (true) { if (currentCPUTime() - startTime > .150) break; } ";
- JSStringRef script = JSStringCreateWithUTF8CString(loopForeverScript);
- exception = nullptr;
- shouldTerminateCallbackWasCalled = false;
- auto startTime = currentCPUTime();
- v = JSEvaluateScript(context, script, nullptr, nullptr, 1, &exception);
- auto endTime = currentCPUTime();
+ Options::setOptions(tierOptions.optionsStr);
- if (((endTime - startTime) < milliseconds(150)) && shouldTerminateCallbackWasCalled)
- printf("PASS: script timed out as expected.\n");
- else {
- if (!((endTime - startTime) < milliseconds(150)))
- printf("FAIL: script did not time out as expected.\n");
- if (!shouldTerminateCallbackWasCalled)
- printf("FAIL: script timeout callback was not called.\n");
- failed = true;
- }
+ unsigned tierAdjustmentMillis = tierOptions.timeLimitAdjustmentMillis;
+ double timeLimit;
+
+ context = JSGlobalContextCreateInGroup(nullptr, nullptr);
+
+ JSContextGroupRef contextGroup = JSContextGetGroup(context);
+ JSObjectRef globalObject = JSContextGetGlobalObject(context);
+ ASSERT(JSValueIsObject(context, globalObject));
+
+ JSValueRef scriptResult = nullptr;
+ JSValueRef exception = nullptr;
+
+ JSStringRef currentCPUTimeStr = JSStringCreateWithUTF8CString("currentCPUTime");
+ JSObjectRef currentCPUTimeFunction = JSObjectMakeFunctionWithCallback(context, currentCPUTimeStr, currentCPUTimeAsJSFunctionCallback);
+ JSObjectSetProperty(context, globalObject, currentCPUTimeStr, currentCPUTimeFunction, kJSPropertyAttributeNone, nullptr);
+ JSStringRelease(currentCPUTimeStr);
- if (!exception) {
- printf("FAIL: TerminatedExecutionException was not thrown.\n");
- failed = true;
+ /* Test script timeout: */
+ timeLimit = (100 + tierAdjustmentMillis) / 1000.0;
+ JSContextGroupSetExecutionTimeLimit(contextGroup, timeLimit, shouldTerminateCallback, 0);
+ {
+ unsigned timeAfterWatchdogShouldHaveFired = 150 + tierAdjustmentMillis;
+
+ StringBuilder scriptBuilder;
+ scriptBuilder.append("function foo() { var startTime = currentCPUTime(); while (true) { for (var i = 0; i < 1000; i++); if (currentCPUTime() - startTime > ");
+ scriptBuilder.appendNumber(timeAfterWatchdogShouldHaveFired / 1000.0);
+ scriptBuilder.append(") break; } } foo();");
+
+ JSStringRef script = JSStringCreateWithUTF8CString(scriptBuilder.toString().utf8().data());
+ exception = nullptr;
+ shouldTerminateCallbackWasCalled = false;
+ auto startTime = currentCPUTime();
+ scriptResult = JSEvaluateScript(context, script, nullptr, nullptr, 1, &exception);
+ auto endTime = currentCPUTime();
+
+ if (((endTime - startTime) < milliseconds(timeAfterWatchdogShouldHaveFired)) && shouldTerminateCallbackWasCalled)
+ printf("PASS: %s script timed out as expected.\n", tierOptions.tier);
+ else {
+ if ((endTime - startTime) >= milliseconds(timeAfterWatchdogShouldHaveFired))
+ printf("FAIL: %s script did not time out as expected.\n", tierOptions.tier);
+ if (!shouldTerminateCallbackWasCalled)
+ printf("FAIL: %s script timeout callback was not called.\n", tierOptions.tier);
+ failed = true;
+ }
+
+ if (!exception) {
+ printf("FAIL: %s TerminatedExecutionException was not thrown.\n", tierOptions.tier);
+ failed = true;
+ }
}
- }
-
- /* Test the script timeout's TerminatedExecutionException should NOT be catchable: */
- JSContextGroupSetExecutionTimeLimit(contextGroup, 0.10f, shouldTerminateCallback, 0);
- {
- const char* loopForeverScript = "var startTime = currentCPUTime(); try { while (true) { if (currentCPUTime() - startTime > .150) break; } } catch(e) { }";
- JSStringRef script = JSStringCreateWithUTF8CString(loopForeverScript);
- exception = nullptr;
- shouldTerminateCallbackWasCalled = false;
- auto startTime = currentCPUTime();
- v = JSEvaluateScript(context, script, nullptr, nullptr, 1, &exception);
- auto endTime = currentCPUTime();
-
- if (((endTime - startTime) >= milliseconds(150)) || !shouldTerminateCallbackWasCalled) {
- if (!((endTime - startTime) < milliseconds(150)))
- printf("FAIL: script did not time out as expected.\n");
- if (!shouldTerminateCallbackWasCalled)
- printf("FAIL: script timeout callback was not called.\n");
- failed = true;
+
+ /* Test the script timeout's TerminatedExecutionException should NOT be catchable: */
+ timeLimit = (100 + tierAdjustmentMillis) / 1000.0;
+ JSContextGroupSetExecutionTimeLimit(contextGroup, timeLimit, shouldTerminateCallback, 0);
+ {
+ unsigned timeAfterWatchdogShouldHaveFired = 150 + tierAdjustmentMillis;
+
+ StringBuilder scriptBuilder;
+ scriptBuilder.append("function foo() { var startTime = currentCPUTime(); try { while (true) { for (var i = 0; i < 1000; i++); if (currentCPUTime() - startTime > ");
+ scriptBuilder.appendNumber(timeAfterWatchdogShouldHaveFired / 1000.0);
+ scriptBuilder.append(") break; } } catch(e) { } } foo();");
+
+ JSStringRef script = JSStringCreateWithUTF8CString(scriptBuilder.toString().utf8().data());
+ exception = nullptr;
+ shouldTerminateCallbackWasCalled = false;
+
+ auto startTime = currentCPUTime();
+ scriptResult = JSEvaluateScript(context, script, nullptr, nullptr, 1, &exception);
+ auto endTime = currentCPUTime();
+
+ if (((endTime - startTime) >= milliseconds(timeAfterWatchdogShouldHaveFired)) || !shouldTerminateCallbackWasCalled) {
+ if (!((endTime - startTime) < milliseconds(timeAfterWatchdogShouldHaveFired)))
+ printf("FAIL: %s script did not time out as expected.\n", tierOptions.tier);
+ if (!shouldTerminateCallbackWasCalled)
+ printf("FAIL: %s script timeout callback was not called.\n", tierOptions.tier);
+ failed = true;
+ }
+
+ if (exception)
+ printf("PASS: %s TerminatedExecutionException was not catchable as expected.\n", tierOptions.tier);
+ else {
+ printf("FAIL: %s TerminatedExecutionException was caught.\n", tierOptions.tier);
+ failed = true;
+ }
}
- if (exception)
- printf("PASS: TerminatedExecutionException was not catchable as expected.\n");
- else {
- printf("FAIL: TerminatedExecutionException was caught.\n");
- failed = true;
+ /* Test script timeout with no callback: */
+ timeLimit = (100 + tierAdjustmentMillis) / 1000.0;
+ JSContextGroupSetExecutionTimeLimit(contextGroup, timeLimit, 0, 0);
+ {
+ unsigned timeAfterWatchdogShouldHaveFired = 150 + tierAdjustmentMillis;
+
+ StringBuilder scriptBuilder;
+ scriptBuilder.append("function foo() { var startTime = currentCPUTime(); while (true) { for (var i = 0; i < 1000; i++); if (currentCPUTime() - startTime > ");
+ scriptBuilder.appendNumber(timeAfterWatchdogShouldHaveFired / 1000.0);
+ scriptBuilder.append(") break; } } foo();");
+
+ JSStringRef script = JSStringCreateWithUTF8CString(scriptBuilder.toString().utf8().data());
+ exception = nullptr;
+ shouldTerminateCallbackWasCalled = false;
+
+ auto startTime = currentCPUTime();
+ scriptResult = JSEvaluateScript(context, script, nullptr, nullptr, 1, &exception);
+ auto endTime = currentCPUTime();
+
+ if (((endTime - startTime) < milliseconds(timeAfterWatchdogShouldHaveFired)) && !shouldTerminateCallbackWasCalled)
+ printf("PASS: %s script timed out as expected when no callback is specified.\n", tierOptions.tier);
+ else {
+ if ((endTime - startTime) >= milliseconds(timeAfterWatchdogShouldHaveFired))
+ printf("FAIL: %s script did not time out as expected when no callback is specified.\n", tierOptions.tier);
+ else
+ printf("FAIL: %s script called stale callback function.\n", tierOptions.tier);
+ failed = true;
+ }
+
+ if (!exception) {
+ printf("FAIL: %s TerminatedExecutionException was not thrown.\n", tierOptions.tier);
+ failed = true;
+ }
}
- }
-
- /* Test script timeout with no callback: */
- JSContextGroupSetExecutionTimeLimit(contextGroup, .10f, 0, 0);
- {
- const char* loopForeverScript = "var startTime = currentCPUTime(); while (true) { if (currentCPUTime() - startTime > .150) break; } ";
- JSStringRef script = JSStringCreateWithUTF8CString(loopForeverScript);
- exception = nullptr;
- auto startTime = currentCPUTime();
- v = JSEvaluateScript(context, script, nullptr, nullptr, 1, &exception);
- auto endTime = currentCPUTime();
- if (((endTime - startTime) < milliseconds(150)) && shouldTerminateCallbackWasCalled)
- printf("PASS: script timed out as expected when no callback is specified.\n");
- else {
- if (!((endTime - startTime) < milliseconds(150)))
- printf("FAIL: script did not time out as expected when no callback is specified.\n");
- failed = true;
+ /* Test script timeout cancellation: */
+ timeLimit = (100 + tierAdjustmentMillis) / 1000.0;
+ JSContextGroupSetExecutionTimeLimit(contextGroup, timeLimit, cancelTerminateCallback, 0);
+ {
+ unsigned timeAfterWatchdogShouldHaveFired = 150 + tierAdjustmentMillis;
+
+ StringBuilder scriptBuilder;
+ scriptBuilder.append("function foo() { var startTime = currentCPUTime(); while (true) { for (var i = 0; i < 1000; i++); if (currentCPUTime() - startTime > ");
+ scriptBuilder.appendNumber(timeAfterWatchdogShouldHaveFired / 1000.0);
+ scriptBuilder.append(") break; } } foo();");
+
+ JSStringRef script = JSStringCreateWithUTF8CString(scriptBuilder.toString().utf8().data());
+ exception = nullptr;
+ cancelTerminateCallbackWasCalled = false;
+
+ auto startTime = currentCPUTime();
+ scriptResult = JSEvaluateScript(context, script, nullptr, nullptr, 1, &exception);
+ auto endTime = currentCPUTime();
+
+ if (((endTime - startTime) >= milliseconds(timeAfterWatchdogShouldHaveFired)) && cancelTerminateCallbackWasCalled && !exception)
+ printf("PASS: %s script timeout was cancelled as expected.\n", tierOptions.tier);
+ else {
+ if (((endTime - startTime) < milliseconds(timeAfterWatchdogShouldHaveFired)) || exception)
+ printf("FAIL: %s script timeout was not cancelled.\n", tierOptions.tier);
+ if (!cancelTerminateCallbackWasCalled)
+ printf("FAIL: %s script timeout callback was not called.\n", tierOptions.tier);
+ failed = true;
+ }
+
+ if (exception) {
+ printf("FAIL: %s Unexpected TerminatedExecutionException thrown.\n", tierOptions.tier);
+ failed = true;
+ }
}
- if (!exception) {
- printf("FAIL: TerminatedExecutionException was not thrown.\n");
- failed = true;
+ /* Test script timeout extension: */
+ timeLimit = (100 + tierAdjustmentMillis) / 1000.0;
+ JSContextGroupSetExecutionTimeLimit(contextGroup, timeLimit, extendTerminateCallback, 0);
+ {
+ unsigned timeBeforeExtendedDeadline = 200 + tierAdjustmentMillis;
+ unsigned timeAfterExtendedDeadline = 400 + tierAdjustmentMillis;
+ unsigned maxBusyLoopTime = 600 + tierAdjustmentMillis;
+
+ StringBuilder scriptBuilder;
+ scriptBuilder.append("function foo() { var startTime = currentCPUTime(); while (true) { for (var i = 0; i < 1000; i++); if (currentCPUTime() - startTime > ");
+ scriptBuilder.appendNumber(maxBusyLoopTime / 1000.0); // in seconds.
+ scriptBuilder.append(") break; } } foo();");
+
+ JSStringRef script = JSStringCreateWithUTF8CString(scriptBuilder.toString().utf8().data());
+ exception = nullptr;
+ extendTerminateCallbackCalled = 0;
+
+ auto startTime = currentCPUTime();
+ scriptResult = JSEvaluateScript(context, script, nullptr, nullptr, 1, &exception);
+ auto endTime = currentCPUTime();
+ auto deltaTime = endTime - startTime;
+
+ if ((deltaTime >= milliseconds(timeBeforeExtendedDeadline)) && (deltaTime < milliseconds(timeAfterExtendedDeadline)) && (extendTerminateCallbackCalled == 2) && exception)
+ printf("PASS: %s script timeout was extended as expected.\n", tierOptions.tier);
+ else {
+ if (deltaTime < milliseconds(timeBeforeExtendedDeadline))
+ printf("FAIL: %s script timeout was not extended as expected.\n", tierOptions.tier);
+ else if (deltaTime >= milliseconds(timeAfterExtendedDeadline))
+ printf("FAIL: %s script did not timeout.\n", tierOptions.tier);
+
+ if (extendTerminateCallbackCalled < 1)
+ printf("FAIL: %s script timeout callback was not called.\n", tierOptions.tier);
+ if (extendTerminateCallbackCalled < 2)
+ printf("FAIL: %s script timeout callback was not called after timeout extension.\n", tierOptions.tier);
+
+ if (!exception)
+ printf("FAIL: %s TerminatedExecutionException was not thrown during timeout extension test.\n", tierOptions.tier);
+
+ failed = true;
+ }
}
+
+ JSGlobalContextRelease(context);
+
+ Options::setOptions(savedOptionsBuilder.toString().ascii().data());
}
- /* Test script timeout cancellation: */
- JSContextGroupSetExecutionTimeLimit(contextGroup, 0.10f, cancelTerminateCallback, 0);
- {
- const char* loopForeverScript = "var startTime = currentCPUTime(); while (true) { if (currentCPUTime() - startTime > .150) break; } ";
- JSStringRef script = JSStringCreateWithUTF8CString(loopForeverScript);
- exception = nullptr;
- auto startTime = currentCPUTime();
- v = JSEvaluateScript(context, script, nullptr, nullptr, 1, &exception);
- auto endTime = currentCPUTime();
-
- if (((endTime - startTime) >= milliseconds(150)) && cancelTerminateCallbackWasCalled && !exception)
- printf("PASS: script timeout was cancelled as expected.\n");
- else {
- if (((endTime - startTime) < milliseconds(150)) || exception)
- printf("FAIL: script timeout was not cancelled.\n");
- if (!cancelTerminateCallbackWasCalled)
- printf("FAIL: script timeout callback was not called.\n");
- failed = true;
- }
-
- if (exception) {
- printf("FAIL: Unexpected TerminatedExecutionException thrown.\n");
- failed = true;
- }
- }
-
- /* Test script timeout extension: */
- JSContextGroupSetExecutionTimeLimit(contextGroup, 0.100f, extendTerminateCallback, 0);
- {
- const char* loopForeverScript = "var startTime = currentCPUTime(); while (true) { if (currentCPUTime() - startTime > .500) break; } ";
- JSStringRef script = JSStringCreateWithUTF8CString(loopForeverScript);
- exception = nullptr;
- auto startTime = currentCPUTime();
- v = JSEvaluateScript(context, script, nullptr, nullptr, 1, &exception);
- auto endTime = currentCPUTime();
- auto deltaTime = endTime - startTime;
-
- if ((deltaTime >= milliseconds(300)) && (deltaTime < milliseconds(500)) && (extendTerminateCallbackCalled == 2) && exception)
- printf("PASS: script timeout was extended as expected.\n");
- else {
- if (deltaTime < milliseconds(200))
- printf("FAIL: script timeout was not extended as expected.\n");
- else if (deltaTime >= milliseconds(500))
- printf("FAIL: script did not timeout.\n");
-
- if (extendTerminateCallbackCalled < 1)
- printf("FAIL: script timeout callback was not called.\n");
- if (extendTerminateCallbackCalled < 2)
- printf("FAIL: script timeout callback was not called after timeout extension.\n");
-
- if (!exception)
- printf("FAIL: TerminatedExecutionException was not thrown during timeout extension test.\n");
-
- failed = true;
- }
- }
-
- JSGlobalContextRelease(context);
return failed;
}
Modified: releases/WebKitGTK/webkit-2.10/Source/_javascript_Core/ChangeLog (189710 => 189711)
--- releases/WebKitGTK/webkit-2.10/Source/_javascript_Core/ChangeLog 2015-09-14 11:11:43 UTC (rev 189710)
+++ releases/WebKitGTK/webkit-2.10/Source/_javascript_Core/ChangeLog 2015-09-14 12:00:47 UTC (rev 189711)
@@ -1,3 +1,78 @@
+2015-08-20 Mark Lam <mark....@apple.com>
+
+ A watchdog tests is failing on Windows.
+ https://bugs.webkit.org/show_bug.cgi?id=148228
+
+ Reviewed by Brent Fulgham.
+
+ The test just needed a little more time because Windows' timer resolution is low.
+ After increasing the test deadlines, the test started passing.
+
+ * API/tests/ExecutionTimeLimitTest.cpp:
+ (testExecutionTimeLimit):
+
+2015-08-20 Mark Lam <mark....@apple.com>
+
+ Fixed some warnings on Windows.
+ https://bugs.webkit.org/show_bug.cgi?id=148224
+
+ Reviewed by Brent Fulgham.
+
+ The Windows build was complaining that function params were hiding a global variable.
+ Since the function params were unused, I resolved this by removing the param names.
+
+ * API/tests/ExecutionTimeLimitTest.cpp:
+ (currentCPUTimeAsJSFunctionCallback):
+ (shouldTerminateCallback):
+ (cancelTerminateCallback):
+ (extendTerminateCallback):
+
+2015-08-19 Mark Lam <mark....@apple.com>
+
+ Add ability to save and restore JSC options.
+ https://bugs.webkit.org/show_bug.cgi?id=148125
+
+ Reviewed by Saam Barati.
+
+ * API/tests/ExecutionTimeLimitTest.cpp:
+ (testExecutionTimeLimit):
+ - Employ the new options getter/setter to run watchdog tests for each of the
+ execution engine tiers.
+ - Also altered the test scripts to be in a function instead of global code.
+ This is one of 2 changes needed to give them an opportunity to be FTL compiled.
+ The other is to add support for compiling CheckWatchdogTimer in the FTL (which
+ will be addressed in a separate patch).
+
+ * jsc.cpp:
+ (CommandLine::parseArguments):
+ * runtime/Options.cpp:
+ (JSC::parse):
+ - Add the ability to clear a string option with a nullptr value.
+ This is needed to restore a default string option value which may be null.
+
+ (JSC::OptionRange::init):
+ - Add the ability to clear a range option with a null value.
+ This is needed to restore a default range option value which may be null.
+
+ (JSC::Options::initialize):
+ (JSC::Options::dumpOptionsIfNeeded):
+ - Factor code to dump options out to dumpOptionsIfNeeded() since we will need
+ that logic elsewhere.
+
+ (JSC::Options::setOptions):
+ - Parse an options string and set each of the specified options.
+
+ (JSC::Options::dumpAllOptions):
+ (JSC::Options::dumpAllOptionsInALine):
+ (JSC::Options::dumpOption):
+ (JSC::Option::dump):
+ - Refactored so that the underlying dumper dumps to a StringBuilder instead of
+ stderr. This lets us reuse this code to serialize all the options into a
+ single string for dumpAllOptionsInALine().
+
+ * runtime/Options.h:
+ (JSC::OptionRange::rangeString):
+
2015-08-26 Andreas Kling <akl...@apple.com>
[JSC] StructureTransitionTable should eagerly deallocate single-transition WeakImpls.
Modified: releases/WebKitGTK/webkit-2.10/Source/_javascript_Core/jsc.cpp (189710 => 189711)
--- releases/WebKitGTK/webkit-2.10/Source/_javascript_Core/jsc.cpp 2015-09-14 11:11:43 UTC (rev 189710)
+++ releases/WebKitGTK/webkit-2.10/Source/_javascript_Core/jsc.cpp 2015-09-14 12:00:47 UTC (rev 189711)
@@ -1545,7 +1545,7 @@
m_arguments.append(argv[i]);
if (needToDumpOptions)
- JSC::Options::dumpAllOptions(JSC::Options::DumpLevel::Verbose, "All JSC runtime options:", stderr);
+ JSC::Options::dumpAllOptions(stderr, JSC::Options::DumpLevel::Verbose, "All JSC runtime options:");
JSC::Options::ensureOptionsAreCoherent();
if (needToExit)
jscExit(EXIT_SUCCESS);
Modified: releases/WebKitGTK/webkit-2.10/Source/_javascript_Core/runtime/Options.cpp (189710 => 189711)
--- releases/WebKitGTK/webkit-2.10/Source/_javascript_Core/runtime/Options.cpp 2015-09-14 11:11:43 UTC (rev 189710)
+++ releases/WebKitGTK/webkit-2.10/Source/_javascript_Core/runtime/Options.cpp 2015-09-14 12:00:47 UTC (rev 189711)
@@ -38,6 +38,7 @@
#include <wtf/PageBlock.h>
#include <wtf/StdLibExtras.h>
#include <wtf/StringExtras.h>
+#include <wtf/text/StringBuilder.h>
#if OS(DARWIN) && ENABLE(PARALLEL_GC)
#include <sys/sysctl.h>
@@ -84,6 +85,8 @@
static bool parse(const char* string, const char*& value)
{
+ if (!strlen(string))
+ string = nullptr;
value = string;
return true;
}
@@ -149,6 +152,8 @@
#endif
}
+const char* const OptionRange::s_nullRangeStr = "<null>";
+
bool OptionRange::init(const char* rangeString)
{
// rangeString should be in the form of [!]<low>[:<high>]
@@ -156,14 +161,16 @@
bool invert = false;
- if (m_state > Uninitialized)
- return true;
-
if (!rangeString) {
m_state = InitError;
return false;
}
+ if (!strcmp(rangeString, s_nullRangeStr)) {
+ m_state = Uninitialized;
+ return true;
+ }
+
m_rangeString = rangeString;
if (*rangeString == '!') {
@@ -360,30 +367,100 @@
ASSERT(Options::thresholdForOptimizeAfterWarmUp() >= Options::thresholdForOptimizeSoon());
ASSERT(Options::thresholdForOptimizeAfterWarmUp() >= 0);
- if (Options::showOptions()) {
- DumpLevel level = static_cast<DumpLevel>(Options::showOptions());
- if (level > DumpLevel::Verbose)
- level = DumpLevel::Verbose;
+ dumpOptionsIfNeeded();
+ ensureOptionsAreCoherent();
+ });
+}
- const char* title = nullptr;
- switch (level) {
- case DumpLevel::None:
- break;
- case DumpLevel::Overridden:
- title = "Overridden JSC options:";
- break;
- case DumpLevel::All:
- title = "All JSC options:";
- break;
- case DumpLevel::Verbose:
- title = "All JSC options with descriptions:";
- break;
- }
- dumpAllOptions(level, title);
+void Options::dumpOptionsIfNeeded()
+{
+ if (Options::showOptions()) {
+ DumpLevel level = static_cast<DumpLevel>(Options::showOptions());
+ if (level > DumpLevel::Verbose)
+ level = DumpLevel::Verbose;
+
+ const char* title = nullptr;
+ switch (level) {
+ case DumpLevel::None:
+ break;
+ case DumpLevel::Overridden:
+ title = "Overridden JSC options:";
+ break;
+ case DumpLevel::All:
+ title = "All JSC options:";
+ break;
+ case DumpLevel::Verbose:
+ title = "All JSC options with descriptions:";
+ break;
+ }
+
+ StringBuilder builder;
+ dumpAllOptions(builder, level, title, nullptr, " ", "\n", ShowDefaults);
+ dataLog(builder.toString());
+ }
+}
+
+bool Options::setOptions(const char* optionsStr)
+{
+ Vector<char*> options;
+
+ size_t length = strlen(optionsStr);
+ char* optionsStrCopy = WTF::fastStrDup(optionsStr);
+ char* end = optionsStrCopy + length;
+ char* p = optionsStrCopy;
+
+ while (p < end) {
+ char* optionStart = p;
+ p = strstr(p, "=");
+ if (!p) {
+ dataLogF("'=' not found in option string: %p\n", optionStart);
+ return false;
+ }
+ p++;
+
+ char* valueBegin = p;
+ bool hasStringValue = false;
+ const int minStringLength = 2; // The min is an empty string i.e. 2 double quotes.
+ if ((p + minStringLength < end) && (*p == '"')) {
+ p = strstr(p + 1, "\"");
+ if (!p) {
+ dataLogF("Missing trailing '\"' in option string: %p\n", optionStart);
+ return false; // End of string not found.
}
+ hasStringValue = true;
+ }
- ensureOptionsAreCoherent();
- });
+ p = strstr(p, " ");
+ if (!p)
+ p = end; // No more " " separator. Hence, this is the last arg.
+
+ // If we have a well-formed string value, strip the quotes.
+ if (hasStringValue) {
+ char* valueEnd = p;
+ ASSERT((*valueBegin == '"') && ((valueEnd - valueBegin) >= minStringLength) && (valueEnd[-1] == '"'));
+ memmove(valueBegin, valueBegin + 1, valueEnd - valueBegin - minStringLength);
+ valueEnd[-minStringLength] = '\0';
+ }
+
+ // Strip leading -- if present.
+ if ((p - optionStart > 2) && optionStart[0] == '-' && optionStart[1] == '-')
+ optionStart += 2;
+
+ *p++ = '\0';
+ options.append(optionStart);
+ }
+
+ bool success = true;
+ for (auto& option : options) {
+ bool optionSuccess = setOption(option);
+ if (!optionSuccess) {
+ dataLogF("Failed to set option : %s\n", option);
+ success = false;
+ }
+ }
+
+ dumpOptionsIfNeeded();
+ return success;
}
// Parses a single command line option in the format "<optionName>=<value>"
@@ -420,16 +497,36 @@
return false; // No option matched.
}
-void Options::dumpAllOptions(DumpLevel level, const char* title, FILE* stream)
+void Options::dumpAllOptions(StringBuilder& builder, DumpLevel level, const char* title,
+ const char* separator, const char* optionHeader, const char* optionFooter, ShowDefaultsOption showDefaultsOption)
{
- if (title)
- fprintf(stream, "%s\n", title);
- for (int id = 0; id < numberOfOptions; id++)
- dumpOption(level, static_cast<OptionID>(id), stream, " ", "\n");
+ if (title) {
+ builder.append(title);
+ builder.append('\n');
+ }
+
+ for (int id = 0; id < numberOfOptions; id++) {
+ if (separator && id)
+ builder.append(separator);
+ dumpOption(builder, level, static_cast<OptionID>(id), optionHeader, optionFooter, showDefaultsOption);
+ }
}
-void Options::dumpOption(DumpLevel level, OptionID id, FILE* stream, const char* header, const char* footer)
+void Options::dumpAllOptionsInALine(StringBuilder& builder)
{
+ dumpAllOptions(builder, DumpLevel::All, nullptr, " ", nullptr, nullptr, DontShowDefaults);
+}
+
+void Options::dumpAllOptions(FILE* stream, DumpLevel level, const char* title)
+{
+ StringBuilder builder;
+ dumpAllOptions(builder, level, title, nullptr, " ", "\n", ShowDefaults);
+ fprintf(stream, "%s", builder.toString().ascii().data());
+}
+
+void Options::dumpOption(StringBuilder& builder, DumpLevel level, OptionID id,
+ const char* header, const char* footer, ShowDefaultsOption showDefaultsOption)
+{
if (id >= numberOfOptions)
return; // Illegal option.
@@ -440,19 +537,24 @@
if (level == DumpLevel::Overridden && !wasOverridden)
return;
- fprintf(stream, "%s%s: ", header, option.name());
- option.dump(stream);
+ if (header)
+ builder.append(header);
+ builder.append(option.name());
+ builder.append('=');
+ option.dump(builder);
- if (wasOverridden) {
- fprintf(stream, " (default: ");
- option.defaultOption().dump(stream);
- fprintf(stream, ")");
+ if (wasOverridden && (showDefaultsOption == ShowDefaults)) {
+ builder.append(" (default: ");
+ option.defaultOption().dump(builder);
+ builder.append(")");
}
- if (needsDescription)
- fprintf(stream, " ... %s", option.description());
+ if (needsDescription) {
+ builder.append(" ... ");
+ builder.append(option.description());
+ }
- fprintf(stream, "%s", footer);
+ builder.append(footer);
}
void Options::ensureOptionsAreCoherent()
@@ -466,33 +568,35 @@
CRASH();
}
-void Option::dump(FILE* stream) const
+void Option::dump(StringBuilder& builder) const
{
switch (type()) {
case Options::Type::boolType:
- fprintf(stream, "%s", m_entry.boolVal ? "true" : "false");
+ builder.append(m_entry.boolVal ? "true" : "false");
break;
case Options::Type::unsignedType:
- fprintf(stream, "%u", m_entry.unsignedVal);
+ builder.appendNumber(m_entry.unsignedVal);
break;
case Options::Type::doubleType:
- fprintf(stream, "%lf", m_entry.doubleVal);
+ builder.appendNumber(m_entry.doubleVal);
break;
case Options::Type::int32Type:
- fprintf(stream, "%d", m_entry.int32Val);
+ builder.appendNumber(m_entry.int32Val);
break;
case Options::Type::optionRangeType:
- fprintf(stream, "%s", m_entry.optionRangeVal.rangeString());
+ builder.append(m_entry.optionRangeVal.rangeString());
break;
case Options::Type::optionStringType: {
const char* option = m_entry.optionStringVal;
if (!option)
option = "";
- fprintf(stream, "%s", option);
+ builder.append('"');
+ builder.append(option);
+ builder.append('"');
break;
}
case Options::Type::gcLogLevelType: {
- fprintf(stream, "%s", GCLogging::levelAsString(m_entry.gcLogLevelVal));
+ builder.append(GCLogging::levelAsString(m_entry.gcLogLevelVal));
break;
}
}
Modified: releases/WebKitGTK/webkit-2.10/Source/_javascript_Core/runtime/Options.h (189710 => 189711)
--- releases/WebKitGTK/webkit-2.10/Source/_javascript_Core/runtime/Options.h 2015-09-14 11:11:43 UTC (rev 189710)
+++ releases/WebKitGTK/webkit-2.10/Source/_javascript_Core/runtime/Options.h 2015-09-14 12:00:47 UTC (rev 189711)
@@ -33,6 +33,11 @@
#include <wtf/PrintStream.h>
#include <wtf/StdLibExtras.h>
+namespace WTF {
+class StringBuilder;
+}
+using WTF::StringBuilder;
+
namespace JSC {
// How do JSC VM options work?
@@ -80,11 +85,13 @@
bool init(const char*);
bool isInRange(unsigned);
- const char* rangeString() const { return (m_state > InitError) ? m_rangeString : "<null>"; }
+ const char* rangeString() const { return (m_state > InitError) ? m_rangeString : s_nullRangeStr; }
void dump(PrintStream& out) const;
private:
+ static const char* const s_nullRangeStr;
+
RangeState m_state;
const char* m_rangeString;
unsigned m_lowLimit;
@@ -359,11 +366,17 @@
JS_EXPORT_PRIVATE static void initialize();
+ // Parses a string of options where each option is of the format "--<optionName>=<value>"
+ // and are separated by a space. The leading "--" is optional and will be ignored.
+ JS_EXPORT_PRIVATE static bool setOptions(const char* optionsList);
+
// 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(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 dumpAllOptions(FILE*, DumpLevel, const char* title = nullptr);
+ JS_EXPORT_PRIVATE static void dumpAllOptionsInALine(StringBuilder&);
+
JS_EXPORT_PRIVATE static void ensureOptionsAreCoherent();
// Declare accessors for each option:
@@ -395,6 +408,16 @@
Options();
+ enum ShowDefaultsOption {
+ DontShowDefaults,
+ ShowDefaults
+ };
+ static void dumpOptionsIfNeeded();
+ static void dumpAllOptions(StringBuilder&, DumpLevel, const char* title,
+ const char* separator, const char* optionHeader, const char* optionFooter, ShowDefaultsOption);
+ static void dumpOption(StringBuilder&, DumpLevel, OptionID,
+ const char* optionHeader, const char* optionFooter, ShowDefaultsOption);
+
// Declare the singleton instance of the options store:
JS_EXPORTDATA static Entry s_options[numberOfOptions];
static Entry s_defaultOptions[numberOfOptions];
@@ -411,7 +434,8 @@
{
}
- void dump(FILE*) const;
+ void dump(StringBuilder&) const;
+
bool operator==(const Option& other) const;
bool operator!=(const Option& other) const { return !(*this == other); }