Diff
Modified: trunk/LayoutTests/ChangeLog (187536 => 187537)
--- trunk/LayoutTests/ChangeLog 2015-07-29 02:08:36 UTC (rev 187536)
+++ trunk/LayoutTests/ChangeLog 2015-07-29 02:15:41 UTC (rev 187537)
@@ -1,3 +1,19 @@
+2015-07-28 Benjamin Poulain <bpoul...@apple.com>
+
+ Speed up the Stringifier::toJSON() fast case
+ https://bugs.webkit.org/show_bug.cgi?id=147383
+
+ Reviewed by Andreas Kling.
+
+ Make the fast case of Stringifier::toJSON() inline and the uncommon
+ case out-of-line.
+
+ * js/dom/JSON-stringify-string-object-with-tojson-expected.txt: Added.
+ * js/dom/JSON-stringify-string-object-with-tojson.html: Added.
+ * js/resources/JSON-stringify-string-object-with-tojson.js: Added.
+ (stringObject.toJSON):
+ (String.prototype.toJSON):
+
2015-07-28 Simon Fraser <simon.fra...@apple.com>
Animations sometimes fail to start
Added: trunk/LayoutTests/js/dom/JSON-stringify-string-object-with-tojson-expected.txt (0 => 187537)
--- trunk/LayoutTests/js/dom/JSON-stringify-string-object-with-tojson-expected.txt (rev 0)
+++ trunk/LayoutTests/js/dom/JSON-stringify-string-object-with-tojson-expected.txt 2015-07-29 02:15:41 UTC (rev 187537)
@@ -0,0 +1,12 @@
+PASS nativeJSON.stringify(stringObject) is "\"Foo\""
+PASS nativeJSON.stringify(stringObject) is JSON.stringify(stringObject)
+PASS nativeJSON.stringify(stringObject) is "\"Weird Case 1\""
+PASS nativeJSON.stringify(stringObject) is JSON.stringify(stringObject)
+PASS nativeJSON.stringify(stringObject) is "\"Bar\""
+PASS nativeJSON.stringify(stringObject) is JSON.stringify(stringObject)
+PASS nativeJSON.stringify(stringObject) is "\"Weird Case 2\""
+PASS nativeJSON.stringify(stringObject) is JSON.stringify(stringObject)
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/js/dom/JSON-stringify-string-object-with-tojson.html (0 => 187537)
--- trunk/LayoutTests/js/dom/JSON-stringify-string-object-with-tojson.html (rev 0)
+++ trunk/LayoutTests/js/dom/JSON-stringify-string-object-with-tojson.html 2015-07-29 02:15:41 UTC (rev 187537)
@@ -0,0 +1,15 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script>
+var nativeJSON = this.JSON;
+this.JSON = null;
+</script>
+<script src=""
+<script src=""
+<script src=""
+</body>
+</html>
\ No newline at end of file
Added: trunk/LayoutTests/js/resources/JSON-stringify-string-object-with-tojson.js (0 => 187537)
--- trunk/LayoutTests/js/resources/JSON-stringify-string-object-with-tojson.js (rev 0)
+++ trunk/LayoutTests/js/resources/JSON-stringify-string-object-with-tojson.js 2015-07-29 02:15:41 UTC (rev 187537)
@@ -0,0 +1,15 @@
+var stringObject = new String("Foo");
+shouldBeEqualToString('nativeJSON.stringify(stringObject)', '"Foo"');
+shouldBe('nativeJSON.stringify(stringObject)', 'JSON.stringify(stringObject)');
+
+stringObject.toJSON = function() { return "Weird Case 1"; }
+shouldBeEqualToString('nativeJSON.stringify(stringObject)', '"Weird Case 1"');
+shouldBe('nativeJSON.stringify(stringObject)', 'JSON.stringify(stringObject)');
+
+var stringObject = new String("Bar");
+shouldBeEqualToString('nativeJSON.stringify(stringObject)', '"Bar"');
+shouldBe('nativeJSON.stringify(stringObject)', 'JSON.stringify(stringObject)');
+
+String.prototype.toJSON = function() { return "Weird Case 2"; }
+shouldBeEqualToString('nativeJSON.stringify(stringObject)', '"Weird Case 2"');
+shouldBe('nativeJSON.stringify(stringObject)', 'JSON.stringify(stringObject)');
\ No newline at end of file
Modified: trunk/Source/_javascript_Core/ChangeLog (187536 => 187537)
--- trunk/Source/_javascript_Core/ChangeLog 2015-07-29 02:08:36 UTC (rev 187536)
+++ trunk/Source/_javascript_Core/ChangeLog 2015-07-29 02:15:41 UTC (rev 187537)
@@ -1,3 +1,14 @@
+2015-07-28 Benjamin Poulain <bpoul...@apple.com>
+
+ Speed up the Stringifier::toJSON() fast case
+ https://bugs.webkit.org/show_bug.cgi?id=147383
+
+ Reviewed by Andreas Kling.
+
+ * runtime/JSONObject.cpp:
+ (JSC::Stringifier::toJSON):
+ (JSC::Stringifier::toJSONImpl):
+
2015-07-28 Sukolsak Sakshuwong <sukol...@gmail.com>
Implement WebAssembly module parser
Modified: trunk/Source/_javascript_Core/runtime/JSONObject.cpp (187536 => 187537)
--- trunk/Source/_javascript_Core/runtime/JSONObject.cpp 2015-07-29 02:08:36 UTC (rev 187536)
+++ trunk/Source/_javascript_Core/runtime/JSONObject.cpp 2015-07-29 02:15:41 UTC (rev 187537)
@@ -108,6 +108,7 @@
friend class Holder;
JSValue toJSON(JSValue, const PropertyNameForFunctionCall&);
+ JSValue toJSONImpl(JSValue, const PropertyNameForFunctionCall&);
enum StringifyResult { StringifyFailed, StringifySucceeded, StringifyFailedDueToUndefinedValue };
StringifyResult appendStringifiedValue(StringBuilder&, JSValue, JSObject* holder, const PropertyNameForFunctionCall&);
@@ -253,12 +254,16 @@
return Local<Unknown>(m_exec->vm(), jsString(m_exec, result.toString()));
}
-inline JSValue Stringifier::toJSON(JSValue value, const PropertyNameForFunctionCall& propertyName)
+ALWAYS_INLINE JSValue Stringifier::toJSON(JSValue value, const PropertyNameForFunctionCall& propertyName)
{
ASSERT(!m_exec->hadException());
if (!value.isObject() || !asObject(value)->hasProperty(m_exec, m_exec->vm().propertyNames->toJSON))
return value;
+ return toJSONImpl(value, propertyName);
+}
+JSValue Stringifier::toJSONImpl(JSValue value, const PropertyNameForFunctionCall& propertyName)
+{
JSValue toJSONFunction = asObject(value)->get(m_exec, m_exec->vm().propertyNames->toJSON);
if (m_exec->hadException())
return jsNull();