Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (183976 => 183977)
--- trunk/Source/_javascript_Core/ChangeLog 2015-05-08 02:59:37 UTC (rev 183976)
+++ trunk/Source/_javascript_Core/ChangeLog 2015-05-08 03:27:11 UTC (rev 183977)
@@ -1,3 +1,17 @@
+2015-05-07 Commit Queue <commit-qu...@webkit.org>
+
+ Unreviewed, rolling out r183961.
+ https://bugs.webkit.org/show_bug.cgi?id=144784
+
+ Broke js/dom/JSON-stringify.html (Requested by kling on
+ #webkit).
+
+ Reverted changeset:
+
+ "Optimize serialization of quoted JSON strings."
+ https://bugs.webkit.org/show_bug.cgi?id=144754
+ http://trac.webkit.org/changeset/183961
+
2015-05-07 Filip Pizlo <fpi...@apple.com>
GC has trouble with pathologically large array allocations
Modified: trunk/Source/_javascript_Core/bytecompiler/NodesCodegen.cpp (183976 => 183977)
--- trunk/Source/_javascript_Core/bytecompiler/NodesCodegen.cpp 2015-05-08 02:59:37 UTC (rev 183976)
+++ trunk/Source/_javascript_Core/bytecompiler/NodesCodegen.cpp 2015-05-08 03:27:11 UTC (rev 183977)
@@ -3087,7 +3087,7 @@
builder.append('{');
for (size_t i = 0; i < m_targetPatterns.size(); i++) {
if (m_targetPatterns[i].wasString)
- builder.appendQuotedJSONString(m_targetPatterns[i].propertyName.string());
+ appendQuotedJSONStringToBuilder(builder, m_targetPatterns[i].propertyName.string());
else
builder.append(m_targetPatterns[i].propertyName.string());
builder.append(':');
Modified: trunk/Source/_javascript_Core/runtime/JSONObject.cpp (183976 => 183977)
--- trunk/Source/_javascript_Core/runtime/JSONObject.cpp 2015-05-08 02:59:37 UTC (rev 183976)
+++ trunk/Source/_javascript_Core/runtime/JSONObject.cpp 2015-05-08 03:27:11 UTC (rev 183977)
@@ -107,6 +107,8 @@
friend class Holder;
+ static void appendQuotedString(StringBuilder&, const String&);
+
JSValue toJSON(JSValue, const PropertyNameForFunctionCall&);
enum StringifyResult { StringifyFailed, StringifySucceeded, StringifyFailedDueToUndefinedValue };
@@ -253,6 +255,72 @@
return Local<Unknown>(m_exec->vm(), jsString(m_exec, result.toString()));
}
+template <typename CharType>
+static void appendStringToStringBuilder(StringBuilder& builder, const CharType* data, int length)
+{
+ for (int i = 0; i < length; ++i) {
+ int start = i;
+ while (i < length && (data[i] > 0x1F && data[i] != '"' && data[i] != '\\'))
+ ++i;
+ builder.append(data + start, i - start);
+ if (i >= length)
+ break;
+ switch (data[i]) {
+ case '\t':
+ builder.append('\\');
+ builder.append('t');
+ break;
+ case '\r':
+ builder.append('\\');
+ builder.append('r');
+ break;
+ case '\n':
+ builder.append('\\');
+ builder.append('n');
+ break;
+ case '\f':
+ builder.append('\\');
+ builder.append('f');
+ break;
+ case '\b':
+ builder.append('\\');
+ builder.append('b');
+ break;
+ case '"':
+ builder.append('\\');
+ builder.append('"');
+ break;
+ case '\\':
+ builder.append('\\');
+ builder.append('\\');
+ break;
+ default:
+ static const char hexDigits[] = "0123456789abcdef";
+ UChar ch = data[i];
+ LChar hex[] = { '\\', 'u', static_cast<LChar>(hexDigits[(ch >> 12) & 0xF]), static_cast<LChar>(hexDigits[(ch >> 8) & 0xF]), static_cast<LChar>(hexDigits[(ch >> 4) & 0xF]), static_cast<LChar>(hexDigits[ch & 0xF]) };
+ builder.append(hex, WTF_ARRAY_LENGTH(hex));
+ break;
+ }
+ }
+}
+
+void appendQuotedJSONStringToBuilder(StringBuilder& builder, const String& message)
+{
+ builder.append('"');
+
+ if (message.is8Bit())
+ appendStringToStringBuilder(builder, message.characters8(), message.length());
+ else
+ appendStringToStringBuilder(builder, message.characters16(), message.length());
+
+ builder.append('"');
+}
+
+void Stringifier::appendQuotedString(StringBuilder& builder, const String& value)
+{
+ appendQuotedJSONStringToBuilder(builder, value);
+}
+
inline JSValue Stringifier::toJSON(JSValue value, const PropertyNameForFunctionCall& propertyName)
{
ASSERT(!m_exec->hadException());
@@ -317,7 +385,7 @@
String stringValue;
if (value.getString(m_exec, stringValue)) {
- builder.appendQuotedJSONString(stringValue);
+ appendQuotedString(builder, stringValue);
return StringifySucceeded;
}
@@ -488,7 +556,7 @@
stringifier.startNewLine(builder);
// Append the property name.
- builder.appendQuotedJSONString(propertyName.string());
+ appendQuotedString(builder, propertyName.string());
builder.append(':');
if (stringifier.willIndent())
builder.append(' ');
Modified: trunk/Source/_javascript_Core/runtime/JSONObject.h (183976 => 183977)
--- trunk/Source/_javascript_Core/runtime/JSONObject.h 2015-05-08 02:59:37 UTC (rev 183976)
+++ trunk/Source/_javascript_Core/runtime/JSONObject.h 2015-05-08 03:27:11 UTC (rev 183977)
@@ -62,6 +62,8 @@
JS_EXPORT_PRIVATE JSValue JSONParse(ExecState*, const String&);
JS_EXPORT_PRIVATE String JSONStringify(ExecState*, JSValue, unsigned indent);
+JS_EXPORT_PRIVATE void appendQuotedJSONStringToBuilder(StringBuilder&, const String&);
+
} // namespace JSC
Modified: trunk/Source/WTF/ChangeLog (183976 => 183977)
--- trunk/Source/WTF/ChangeLog 2015-05-08 02:59:37 UTC (rev 183976)
+++ trunk/Source/WTF/ChangeLog 2015-05-08 03:27:11 UTC (rev 183977)
@@ -1,3 +1,17 @@
+2015-05-07 Commit Queue <commit-qu...@webkit.org>
+
+ Unreviewed, rolling out r183961.
+ https://bugs.webkit.org/show_bug.cgi?id=144784
+
+ Broke js/dom/JSON-stringify.html (Requested by kling on
+ #webkit).
+
+ Reverted changeset:
+
+ "Optimize serialization of quoted JSON strings."
+ https://bugs.webkit.org/show_bug.cgi?id=144754
+ http://trac.webkit.org/changeset/183961
+
2015-05-07 Andreas Kling <akl...@apple.com>
Optimize serialization of quoted JSON strings.
Modified: trunk/Source/WTF/wtf/text/StringBuilder.cpp (183976 => 183977)
--- trunk/Source/WTF/wtf/text/StringBuilder.cpp 2015-05-08 02:59:37 UTC (rev 183976)
+++ trunk/Source/WTF/wtf/text/StringBuilder.cpp 2015-05-08 03:27:11 UTC (rev 183977)
@@ -27,9 +27,7 @@
#include "config.h"
#include "StringBuilder.h"
-#include "ASCIICType.h"
#include "IntegerToStringConversion.h"
-#include "MathExtras.h"
#include "WTFString.h"
#include <wtf/dtoa.h>
@@ -362,89 +360,4 @@
}
}
-template <typename OutputCharacterType, typename InputCharacterType>
-static void appendQuotedJSONStringInternal(OutputCharacterType*& output, const InputCharacterType* input, unsigned length)
-{
- for (const InputCharacterType* end = input + length; input != end; ++input) {
- if (*input > 0x1F && *input != '"' && *input != '\\') {
- *output++ = *input;
- continue;
- }
- switch (*input) {
- case '\t':
- *output++ = '\\';
- *output++ = 't';
- break;
- case '\r':
- *output++ = '\\';
- *output++ = 'r';
- break;
- case '\n':
- *output++ = '\\';
- *output++ = 'n';
- break;
- case '\f':
- *output++ = '\\';
- *output++ = 'f';
- break;
- case '\b':
- *output++ = '\\';
- *output++ = 'b';
- break;
- case '"':
- *output++ = '\\';
- *output++ = '"';
- break;
- case '\\':
- *output++ = '\\';
- *output++ = '\\';
- break;
- default:
- ASSERT((*input & 0xFF00) == 0);
- *output++ = '\\';
- *output++ = 'u';
- *output++ = '0';
- *output++ = '0';
- *output++ = upperNibbleToASCIIHexDigit(*input);
- *output++ = lowerNibbleToASCIIHexDigit(*input);
- break;
- }
- }
-}
-
-void StringBuilder::appendQuotedJSONString(const String& string)
-{
- // Make sure we have enough buffer space to append this string without having
- // to worry about reallocating in the middle.
- // The 2 is for the '"' quotes on each end.
- // The 'maximumOutputCharactersPerInputCharacter' is 6 for 16-bit characters
- // since they may need \uNNNN-style representation. 2 for 8-bit strings.
- unsigned maximumOutputCharactersPerInputCharacter = string.is8Bit() ? 2 : 6;
- size_t maximumCapacityRequired = length() + 2 + (string.length() * maximumOutputCharactersPerInputCharacter);
- RELEASE_ASSERT(maximumCapacityRequired < std::numeric_limits<unsigned>::max());
-
- if (is8Bit() && !string.is8Bit())
- allocateBufferUpConvert(m_bufferCharacters8, roundUpToPowerOfTwo(maximumCapacityRequired));
- else
- reserveCapacity(roundUpToPowerOfTwo(maximumCapacityRequired));
-
- if (is8Bit()) {
- ASSERT(string.is8Bit());
- LChar* output = m_bufferCharacters8 + m_length;
- *output++ = '"';
- appendQuotedJSONStringInternal(output, string.characters8(), string.length());
- *output++ = '"';
- m_length = output - m_bufferCharacters8;
- } else {
- UChar* output = m_bufferCharacters16 + m_length;
- *output++ = '"';
- if (string.is8Bit())
- appendQuotedJSONStringInternal(output, string.characters8(), string.length());
- else
- appendQuotedJSONStringInternal(output, string.characters16(), string.length());
- *output++ = '"';
- m_length = output - m_bufferCharacters16;
- }
-}
-
} // namespace WTF
Modified: trunk/Source/WTF/wtf/text/StringBuilder.h (183976 => 183977)
--- trunk/Source/WTF/wtf/text/StringBuilder.h 2015-05-08 02:59:37 UTC (rev 183976)
+++ trunk/Source/WTF/wtf/text/StringBuilder.h 2015-05-08 03:27:11 UTC (rev 183977)
@@ -159,8 +159,6 @@
append(U16_TRAIL(c));
}
- WTF_EXPORT_PRIVATE void appendQuotedJSONString(const String&);
-
template<unsigned charactersCount>
ALWAYS_INLINE void appendLiteral(const char (&characters)[charactersCount]) { append(characters, charactersCount - 1); }
Modified: trunk/Source/WebKit2/ChangeLog (183976 => 183977)
--- trunk/Source/WebKit2/ChangeLog 2015-05-08 02:59:37 UTC (rev 183976)
+++ trunk/Source/WebKit2/ChangeLog 2015-05-08 03:27:11 UTC (rev 183977)
@@ -1,3 +1,17 @@
+2015-05-07 Commit Queue <commit-qu...@webkit.org>
+
+ Unreviewed, rolling out r183961.
+ https://bugs.webkit.org/show_bug.cgi?id=144784
+
+ Broke js/dom/JSON-stringify.html (Requested by kling on
+ #webkit).
+
+ Reverted changeset:
+
+ "Optimize serialization of quoted JSON strings."
+ https://bugs.webkit.org/show_bug.cgi?id=144754
+ http://trac.webkit.org/changeset/183961
+
2015-05-07 Anders Carlsson <ander...@apple.com>
Build fixes.
Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheEntry.cpp (183976 => 183977)
--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheEntry.cpp 2015-05-08 02:59:37 UTC (rev 183976)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheEntry.cpp 2015-05-08 03:27:11 UTC (rev 183977)
@@ -30,6 +30,7 @@
#include "NetworkCacheCoders.h"
#include "NetworkCacheDecoder.h"
#include "NetworkCacheEncoder.h"
+#include <_javascript_Core/JSONObject.h>
#include <WebCore/ResourceRequest.h>
#include <WebCore/SharedBuffer.h>
#include <wtf/text/StringBuilder.h>
@@ -158,7 +159,7 @@
{
json.appendLiteral("{\n");
json.appendLiteral("\"hash\": ");
- json.appendQuotedJSONString(m_key.hashAsString());
+ JSC::appendQuotedJSONStringToBuilder(json, m_key.hashAsString());
json.appendLiteral(",\n");
json.appendLiteral("\"bodySize\": ");
json.appendNumber(info.bodySize);
@@ -167,16 +168,16 @@
json.appendNumber(info.worth);
json.appendLiteral(",\n");
json.appendLiteral("\"partition\": ");
- json.appendQuotedJSONString(m_key.partition());
+ JSC::appendQuotedJSONStringToBuilder(json, m_key.partition());
json.appendLiteral(",\n");
json.appendLiteral("\"timestamp\": ");
json.appendNumber(std::chrono::duration_cast<std::chrono::milliseconds>(m_timeStamp.time_since_epoch()).count());
json.appendLiteral(",\n");
json.appendLiteral("\"URL\": ");
- json.appendQuotedJSONString(m_response.url().string());
+ JSC::appendQuotedJSONStringToBuilder(json, m_response.url().string());
json.appendLiteral(",\n");
json.appendLiteral("\"bodyHash\": ");
- json.appendQuotedJSONString(info.bodyHash);
+ JSC::appendQuotedJSONStringToBuilder(json, info.bodyHash);
json.appendLiteral(",\n");
json.appendLiteral("\"bodyShareCount\": ");
json.appendNumber(info.bodyShareCount);
@@ -188,9 +189,9 @@
json.appendLiteral(",\n");
firstHeader = false;
json.appendLiteral(" ");
- json.appendQuotedJSONString(header.key);
+ JSC::appendQuotedJSONStringToBuilder(json, header.key);
json.appendLiteral(": ");
- json.appendQuotedJSONString(header.value);
+ JSC::appendQuotedJSONStringToBuilder(json, header.value);
}
json.appendLiteral("\n}\n");
json.appendLiteral("}");