WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-130304-20140316103336.patch (text/plain), 27.26 KB, created by
Darin Adler
on 2014-03-16 10:33:50 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Darin Adler
Created:
2014-03-16 10:33:50 PDT
Size:
27.26 KB
patch
obsolete
>Subversion Revision: 165700 >diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index 4312e2bf074aebb08bf272234f5f067b7da6f398..43cdaa3090599637b491e5584c546f87b9a3bbfa 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,66 @@ >+2014-03-16 Darin Adler <darin@apple.com> >+ >+ Remove all uses of deprecatedCharacters from JavaScriptCore >+ https://bugs.webkit.org/show_bug.cgi?id=130304 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * API/JSValueRef.cpp: >+ (JSValueMakeFromJSONString): Use characters16 in the 16-bit code path. >+ * API/OpaqueJSString.cpp: >+ (OpaqueJSString::~OpaqueJSString): Use characters 16 in the 16-bit code path. >+ (OpaqueJSString::identifier): Get rid of custom Identifier constructor, and >+ juse use the standard one that takes a String. >+ (OpaqueJSString::characters): Use getCharactersWithUpconvert instead of a >+ hand-written alternative. >+ >+ * bindings/ScriptValue.cpp: >+ (Deprecated::jsToInspectorValue): Create InspectorString from String directly >+ instead of involving a character pointer. Use the String from Identifier >+ directly instead of making a new String. >+ >+ * inspector/ContentSearchUtilities.cpp: >+ (Inspector::ContentSearchUtilities::createSearchRegexSource): Use StringBuilder >+ instead of building a String a character at a time. This is still a very slow >+ way to do this. Also use strchr to search for a character instead of building >+ a String every time just to use find on it. >+ >+ * inspector/InspectorValues.cpp: >+ (Inspector::doubleQuoteString): Remove unnecessary trip through a >+ character pointer. This is still a really slow way to do this. >+ (Inspector::InspectorValue::parseJSON): Use StringView::upconvertedCharacters >+ instead of String::deprecatedCharacters. Still slow to always upconvert. >+ >+ * runtime/DateConstructor.cpp: Removed unneeded include. >+ * runtime/DatePrototype.cpp: Ditto. >+ >+ * runtime/Identifier.h: Removed deprecatedCharacters function. >+ >+ * runtime/JSGlobalObjectFunctions.cpp: >+ (JSC::encode): Added a type cast to avoid ambiguity with the two character- >+ appending functions from JSStringBuilder. Removed unneeded code duplicating >+ what JSStringBuilder already does in its character append function. >+ (JSC::decode): Deleted code that creates a JSStringBuilder that is never used. >+ (JSC::parseIntOverflow): Changed lengths to unsigned. Made only the overload that >+ is used outside this file have external linkage. Added a new overload that takes >+ a StringView. >+ (JSC::parseInt): Use StringView::substring to call parseIntOverflow. >+ (JSC::globalFuncEscape): Use JSBuilder::append in a more efficient way for a >+ single character. >+ >+ * runtime/JSGlobalObjectFunctions.h: Removed unused overloads of parseIntOverflow. >+ >+ * runtime/JSStringBuilder.h: Marked this "lightly deprecated". >+ (JSC::JSStringBuilder::append): Overloaded for better speed with 8-bit characters. >+ Made one overload private. Fixed a performance bug where we would reserve capacity >+ in the 8-bit buffer but then append to the 16-bit buffer. >+ >+ * runtime/ObjectPrototype.cpp: Removed unneeded include. >+ >+ * runtime/StringPrototype.cpp: >+ (JSC::stringProtoFuncFontsize): Use StringView::getCharactersWithUpconvert. >+ (JSC::stringProtoFuncLink): Ditto. >+ > 2014-03-15 Filip Pizlo <fpizlo@apple.com> > > FTL ArrayifyToStructure shouldn't fail every time that it actually arrayifies >diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog >index d77b772d26687788c2add19bb2c5413b31f02417..cfb7365423c4f811817c07f903af9f158d918c48 100644 >--- a/Source/WTF/ChangeLog >+++ b/Source/WTF/ChangeLog >@@ -1,3 +1,13 @@ >+2014-03-16 Darin Adler <darin@apple.com> >+ >+ Remove all uses of deprecatedCharacters from JavaScriptCore >+ https://bugs.webkit.org/show_bug.cgi?id=130304 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * wtf/dtoa.h: >+ (WTF::parseDouble): Added an overload that takes a StringView. >+ > 2014-03-15 Darin Adler <darin@apple.com> > > Remove all uses of deprecatedCharacters from WebKit2 >diff --git a/Source/JavaScriptCore/API/JSValueRef.cpp b/Source/JavaScriptCore/API/JSValueRef.cpp >index 20fd36b431f509349e7d94192758c4aa60622f00..70df93447ef94ed3bd149f37daa2c1961f067f6c 100644 >--- a/Source/JavaScriptCore/API/JSValueRef.cpp >+++ b/Source/JavaScriptCore/API/JSValueRef.cpp >@@ -334,11 +334,11 @@ JSValueRef JSValueMakeFromJSONString(JSContextRef ctx, JSStringRef string) > JSLockHolder locker(exec); > String str = string->string(); > unsigned length = str.length(); >- if (length && str.is8Bit()) { >+ if (!length || str.is8Bit()) { > LiteralParser<LChar> parser(exec, str.characters8(), length, StrictJSON); > return toRef(exec, parser.tryLiteralParse()); > } >- LiteralParser<UChar> parser(exec, str.deprecatedCharacters(), length, StrictJSON); >+ LiteralParser<UChar> parser(exec, str.characters16(), length, StrictJSON); > return toRef(exec, parser.tryLiteralParse()); > } > >diff --git a/Source/JavaScriptCore/API/OpaqueJSString.cpp b/Source/JavaScriptCore/API/OpaqueJSString.cpp >index 68f0f5c11405351c5e2a93e98f638f5c69dc5f5f..949c47c1235450f94ae131ff5e525242e00e830b 100644 >--- a/Source/JavaScriptCore/API/OpaqueJSString.cpp >+++ b/Source/JavaScriptCore/API/OpaqueJSString.cpp >@@ -29,6 +29,7 @@ > #include "CallFrame.h" > #include "Identifier.h" > #include "JSGlobalObject.h" >+#include <wtf/text/StringView.h> > > using namespace JSC; > >@@ -47,7 +48,7 @@ OpaqueJSString::~OpaqueJSString() > if (!characters) > return; > >- if (!m_string.is8Bit() && m_string.deprecatedCharacters() == characters) >+ if (!m_string.is8Bit() && m_string.characters16() == characters) > return; > > fastFree(characters); >@@ -70,10 +71,7 @@ Identifier OpaqueJSString::identifier(VM* vm) const > if (m_string.isEmpty()) > return Identifier(Identifier::EmptyIdentifier); > >- if (m_string.is8Bit()) >- return Identifier(vm, m_string.characters8(), m_string.length()); >- >- return Identifier(vm, m_string.characters16(), m_string.length()); >+ return Identifier(vm, m_string); > } > > const UChar* OpaqueJSString::characters() >@@ -91,12 +89,7 @@ const UChar* OpaqueJSString::characters() > > unsigned length = m_string.length(); > UChar* newCharacters = static_cast<UChar*>(fastMalloc(length * sizeof(UChar))); >- >- if (m_string.is8Bit()) { >- for (size_t i = 0; i < length; ++i) >- newCharacters[i] = m_string.characters8()[i]; >- } else >- memcpy(newCharacters, m_string.characters16(), length * sizeof(UChar)); >+ StringView(m_string).getCharactersWithUpconvert(newCharacters); > > if (!m_characters.compare_exchange_strong(characters, newCharacters)) { > fastFree(newCharacters); >diff --git a/Source/JavaScriptCore/bindings/ScriptValue.cpp b/Source/JavaScriptCore/bindings/ScriptValue.cpp >index 4df9cc88feedc95886bf8c0914882c36d1b59a33..c08a2f63e3842d865bf9eaf7966c08ce66ec09bc 100644 >--- a/Source/JavaScriptCore/bindings/ScriptValue.cpp >+++ b/Source/JavaScriptCore/bindings/ScriptValue.cpp >@@ -115,10 +115,8 @@ static PassRefPtr<InspectorValue> jsToInspectorValue(ExecState* scriptState, JSV > return InspectorBasicValue::create(value.asBoolean()); > if (value.isNumber()) > return InspectorBasicValue::create(value.asNumber()); >- if (value.isString()) { >- String s = value.getString(scriptState); >- return InspectorString::create(String(s.deprecatedCharacters(), s.length())); >- } >+ if (value.isString()) >+ return InspectorString::create(value.getString(scriptState)); > > if (value.isObject()) { > if (isJSArray(value)) { >@@ -139,12 +137,12 @@ static PassRefPtr<InspectorValue> jsToInspectorValue(ExecState* scriptState, JSV > PropertyNameArray propertyNames(scriptState); > object->methodTable()->getOwnPropertyNames(object, scriptState, propertyNames, ExcludeDontEnumProperties); > for (size_t i = 0; i < propertyNames.size(); i++) { >- const Identifier& name = propertyNames[i]; >+ const Identifier& name = propertyNames[i]; > JSValue propertyValue = object->get(scriptState, name); > RefPtr<InspectorValue> inspectorValue = jsToInspectorValue(scriptState, propertyValue, maxDepth); > if (!inspectorValue) > return nullptr; >- inspectorObject->setValue(String(name.deprecatedCharacters(), name.length()), inspectorValue); >+ inspectorObject->setValue(name.string(), inspectorValue); > } > return inspectorObject; > } >diff --git a/Source/JavaScriptCore/inspector/ContentSearchUtilities.cpp b/Source/JavaScriptCore/inspector/ContentSearchUtilities.cpp >index 0cd4edc65cdcfbffaea910e03732541bb3f13ac0..bcd691bb1e36bbf62e261c199cb884a93cf5346e 100644 >--- a/Source/JavaScriptCore/inspector/ContentSearchUtilities.cpp >+++ b/Source/JavaScriptCore/inspector/ContentSearchUtilities.cpp >@@ -37,6 +37,7 @@ > #include "Yarr.h" > #include <wtf/BumpPointerAllocator.h> > #include <wtf/StdLibExtras.h> >+#include <wtf/text/StringBuilder.h> > > using namespace JSC::Yarr; > >@@ -47,17 +48,16 @@ static const char regexSpecialCharacters[] = "[](){}+-*.,?\\^$|"; > > static String createSearchRegexSource(const String& text) > { >- String result; >- const UChar* characters = text.deprecatedCharacters(); >- String specials(regexSpecialCharacters); >+ StringBuilder result; > > for (unsigned i = 0; i < text.length(); i++) { >- if (specials.find(characters[i]) != notFound) >- result.append("\\"); >- result.append(characters[i]); >+ UChar character = text[i]; >+ if (isASCII(character) && strchr(regexSpecialCharacters, character)) >+ result.append('\\'); >+ result.append(character); > } > >- return result; >+ return result.toString(); > } > > static inline size_t sizetExtractor(const size_t* value) >diff --git a/Source/JavaScriptCore/inspector/InspectorValues.cpp b/Source/JavaScriptCore/inspector/InspectorValues.cpp >index 0849213ed9c500ca2aff986037d3c7a52f2c8a96..192fb6c9d90924e617c5d32c5d2e3bb9fccd3e1a 100644 >--- a/Source/JavaScriptCore/inspector/InspectorValues.cpp >+++ b/Source/JavaScriptCore/inspector/InspectorValues.cpp >@@ -470,9 +470,7 @@ inline void doubleQuoteString(const String& str, StringBuilder* dst) > // 1. Escaping <, > to prevent script execution. > // 2. Technically, we could also pass through c > 126 as UTF8, but this > // is also optional. It would also be a pain to implement here. >- unsigned int symbol = static_cast<unsigned int>(c); >- String symbolCode = String::format("\\u%04X", symbol); >- dst->append(symbolCode.deprecatedCharacters(), symbolCode.length()); >+ dst->append(String::format("\\u%04X", c)); > } else > dst->append(c); > } >@@ -560,9 +558,11 @@ PassRefPtr<InspectorArray> InspectorValue::asArray() > > PassRefPtr<InspectorValue> InspectorValue::parseJSON(const String& json) > { >- const UChar* start = json.deprecatedCharacters(); >- const UChar* end = json.deprecatedCharacters() + json.length(); >- const UChar *tokenEnd; >+ // FIXME: This whole file should just use StringView instead of UChar/length and avoid upconverting. >+ auto characters = StringView(json).upconvertedCharacters(); >+ const UChar* start = characters; >+ const UChar* end = start + json.length(); >+ const UChar* tokenEnd; > RefPtr<InspectorValue> value = buildValue(start, end, &tokenEnd, 0); > if (!value || tokenEnd != end) > return nullptr; >diff --git a/Source/JavaScriptCore/runtime/DateConstructor.cpp b/Source/JavaScriptCore/runtime/DateConstructor.cpp >index e3896525079525d5a14dd95ece5b371ce687bb6f..18b9dcd988a0230aa5a818f95da68803ed0f1fad 100644 >--- a/Source/JavaScriptCore/runtime/DateConstructor.cpp >+++ b/Source/JavaScriptCore/runtime/DateConstructor.cpp >@@ -29,7 +29,6 @@ > #include "JSFunction.h" > #include "JSGlobalObject.h" > #include "JSString.h" >-#include "JSStringBuilder.h" > #include "ObjectPrototype.h" > #include "JSCInlines.h" > #include <math.h> >diff --git a/Source/JavaScriptCore/runtime/DatePrototype.cpp b/Source/JavaScriptCore/runtime/DatePrototype.cpp >index c5695f8b62a9a299e7b8f78f532b3fe43b9831c5..7ccbcc4452dbc733d016682faeb724e629ecfcbc 100644 >--- a/Source/JavaScriptCore/runtime/DatePrototype.cpp >+++ b/Source/JavaScriptCore/runtime/DatePrototype.cpp >@@ -30,7 +30,6 @@ > #include "JSDateMath.h" > #include "JSGlobalObject.h" > #include "JSString.h" >-#include "JSStringBuilder.h" > #include "Lookup.h" > #include "ObjectPrototype.h" > #include "JSCInlines.h" >diff --git a/Source/JavaScriptCore/runtime/Identifier.h b/Source/JavaScriptCore/runtime/Identifier.h >index 003ede32906709abdcc11c55f33464d19f6778dc..1077997fc40537eeffe5893737f0a13816d72302 100644 >--- a/Source/JavaScriptCore/runtime/Identifier.h >+++ b/Source/JavaScriptCore/runtime/Identifier.h >@@ -55,7 +55,6 @@ namespace JSC { > const String& string() const { return m_string; } > StringImpl* impl() const { return m_string.impl(); } > >- const UChar* deprecatedCharacters() const { return m_string.deprecatedCharacters(); } > int length() const { return m_string.length(); } > > CString ascii() const { return m_string.ascii(); } >diff --git a/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp b/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp >index 91f2cbf95354f5fa8f3d91123cc326459f42c2b1..8c02f342faf57b2e46b5949599e167f6aeccee28 100644 >--- a/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp >+++ b/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp >@@ -63,7 +63,7 @@ static JSValue encode(ExecState* exec, const char* doNotEscape) > for (size_t k = 0; k < cstr.length(); k++, p++) { > char c = *p; > if (c && strchr(doNotEscape, c)) >- builder.append(c); >+ builder.append(static_cast<LChar>(c)); > else { > char tmp[4]; > snprintf(tmp, sizeof(tmp), "%%%02X", static_cast<unsigned char>(c)); >@@ -128,10 +128,7 @@ static JSValue decode(ExecState* exec, const CharType* characters, int length, c > } > } > if (charLen && (u == 0 || u >= 128 || !strchr(doNotUnescape, u))) { >- if (u < 256) >- builder.append(static_cast<LChar>(u)); >- else >- builder.append(u); >+ builder.append(u); > k += charLen; > continue; > } >@@ -144,7 +141,6 @@ static JSValue decode(ExecState* exec, const CharType* characters, int length, c > > static JSValue decode(ExecState* exec, const char* doNotUnescape, bool strict) > { >- JSStringBuilder builder; > String str = exec->argument(0).toString(exec)->value(exec); > > if (str.is8Bit()) >@@ -189,7 +185,7 @@ static int parseDigit(unsigned short c, int radix) > return digit; > } > >-double parseIntOverflow(const LChar* s, int length, int radix) >+double parseIntOverflow(const LChar* s, unsigned length, int radix) > { > double number = 0.0; > double radixMultiplier = 1.0; >@@ -211,7 +207,7 @@ double parseIntOverflow(const LChar* s, int length, int radix) > return number; > } > >-double parseIntOverflow(const UChar* s, int length, int radix) >+static double parseIntOverflow(const UChar* s, unsigned length, int radix) > { > double number = 0.0; > double radixMultiplier = 1.0; >@@ -233,6 +229,13 @@ double parseIntOverflow(const UChar* s, int length, int radix) > return number; > } > >+static double parseIntOverflow(StringView string, int radix) >+{ >+ if (string.is8Bit()) >+ return parseIntOverflow(string.characters8(), string.length(), radix); >+ return parseIntOverflow(string.characters16(), string.length(), radix); >+} >+ > // ES5.1 15.1.2.2 > template <typename CharType> > ALWAYS_INLINE >@@ -308,9 +311,9 @@ static double parseInt(const String& s, const CharType* data, int radix) > if (number >= mantissaOverflowLowerBound) { > if (radix == 10) { > size_t parsedLength; >- number = parseDouble(s.deprecatedCharacters() + firstDigitPosition, p - firstDigitPosition, parsedLength); >+ number = parseDouble(StringView(s).substring(firstDigitPosition, p - firstDigitPosition), parsedLength); > } else if (radix == 2 || radix == 4 || radix == 8 || radix == 16 || radix == 32) >- number = parseIntOverflow(s.substringSharingImpl(firstDigitPosition, p - firstDigitPosition).utf8().data(), p - firstDigitPosition, radix); >+ number = parseIntOverflow(StringView(s).substring(firstDigitPosition, p - firstDigitPosition), radix); > } > > // 15. Return sign x number. >@@ -620,7 +623,7 @@ EncodedJSValue JSC_HOST_CALL globalFuncEscape(ExecState* exec) > for (unsigned k = 0; k < str.length(); k++, c++) { > int u = c[0]; > if (u && strchr(do_not_escape, static_cast<char>(u))) >- builder.append(c, 1); >+ builder.append(*c); > else { > char tmp[4]; > snprintf(tmp, sizeof(tmp), "%%%02X", u); >@@ -639,7 +642,7 @@ EncodedJSValue JSC_HOST_CALL globalFuncEscape(ExecState* exec) > snprintf(tmp, sizeof(tmp), "%%u%04X", u); > builder.append(tmp); > } else if (u != 0 && strchr(do_not_escape, static_cast<char>(u))) >- builder.append(c, 1); >+ builder.append(*c); > else { > char tmp[4]; > snprintf(tmp, sizeof(tmp), "%%%02X", u); >diff --git a/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.h b/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.h >index 84a6998791181c1d313075d68d647f9cdd90ac75..935032f4f949f9286b5f7b798843983caddeab39 100644 >--- a/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.h >+++ b/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.h >@@ -53,9 +53,7 @@ EncodedJSValue JSC_HOST_CALL globalFuncProtoGetter(ExecState*); > EncodedJSValue JSC_HOST_CALL globalFuncProtoSetter(ExecState*); > > static const double mantissaOverflowLowerBound = 9007199254740992.0; >-double parseIntOverflow(const LChar*, int length, int radix); >-ALWAYS_INLINE double parseIntOverflow(const char* s, int length, int radix) { return parseIntOverflow(reinterpret_cast<const LChar*>(s), length, radix); } >-double parseIntOverflow(const UChar*, int length, int radix); >+double parseIntOverflow(const LChar*, unsigned length, int radix); > bool isStrWhiteSpace(UChar); > double jsToNumber(const WTF::String&); > >diff --git a/Source/JavaScriptCore/runtime/JSStringBuilder.h b/Source/JavaScriptCore/runtime/JSStringBuilder.h >index 7b1c1a5056daa0e7b466bcdf0534884559e2b7c1..63e51a3ce29febc80860f9da357217c161a68d1f 100644 >--- a/Source/JavaScriptCore/runtime/JSStringBuilder.h >+++ b/Source/JavaScriptCore/runtime/JSStringBuilder.h >@@ -32,6 +32,7 @@ > > namespace JSC { > >+// FIXME: Should move the last few callers over from this to WTF::StringBuilder. > class JSStringBuilder { > public: > JSStringBuilder() >@@ -40,72 +41,63 @@ public: > { > } > >- void append(const UChar u) >+ void append(LChar character) > { > if (m_is8Bit) { >- if (u < 0xff) { >- LChar c = u; >- m_okay &= buffer8.tryAppend(&c, 1); >+ m_okay &= buffer8.tryAppend(&character, 1); >+ return; >+ } >+ UChar upconvertedCharacter = character; >+ m_okay &= buffer16.tryAppend(&upconvertedCharacter, 1); >+ } >+ >+ void append(UChar character) >+ { >+ if (m_is8Bit) { >+ if (character < 0x100) { >+ LChar narrowedCharacter = character; >+ m_okay &= buffer8.tryAppend(&narrowedCharacter, 1); > return; > } > upConvert(); > } >- m_okay &= buffer16.tryAppend(&u, 1); >+ m_okay &= buffer16.tryAppend(&character, 1); > } > > void append(const char* str) > { >- append(str, strlen(str)); >+ append(reinterpret_cast<const LChar*>(str), strlen(str)); > } > >- void append(const char* str, size_t len) >+ JSValue build(ExecState* exec) > { >+ if (!m_okay) >+ return throwOutOfMemoryError(exec); > if (m_is8Bit) { >- m_okay &= buffer8.tryAppend(reinterpret_cast<const LChar*>(str), len); >- return; >- } >- m_okay &= buffer8.tryReserveCapacity(buffer16.size() + len); >- for (size_t i = 0; i < len; i++) { >- UChar u = static_cast<unsigned char>(str[i]); >- m_okay &= buffer16.tryAppend(&u, 1); >+ buffer8.shrinkToFit(); >+ if (!buffer8.data()) >+ return throwOutOfMemoryError(exec); >+ return jsString(exec, String::adopt(buffer8)); > } >+ buffer16.shrinkToFit(); >+ if (!buffer16.data()) >+ return throwOutOfMemoryError(exec); >+ return jsString(exec, String::adopt(buffer16)); > } > >- void append(const LChar* str, size_t len) >+private: >+ void append(const LChar* characters, size_t length) > { > if (m_is8Bit) { >- m_okay &= buffer8.tryAppend(str, len); >+ m_okay &= buffer8.tryAppend(characters, length); > return; > } >- m_okay &= buffer8.tryReserveCapacity(buffer16.size() + len); >- for (size_t i = 0; i < len; i++) { >- UChar u = str[i]; >- m_okay &= buffer16.tryAppend(&u, 1); >- } >- } >- >- void append(const UChar* str, size_t len) >- { >- if (m_is8Bit) >- upConvert(); // FIXME: We could check character by character its size. >- m_okay &= buffer16.tryAppend(str, len); >- } >- >- void append(const String& str) >- { >- unsigned length = str.length(); >- >- if (!length) >- return; >- >- if (m_is8Bit) { >- if (str.is8Bit()) { >- m_okay &= buffer8.tryAppend(str.characters8(), length); >- return; >- } >- upConvert(); >+ // FIXME: There must be a more efficient way of doing this. >+ m_okay &= buffer16.tryReserveCapacity(buffer16.size() + length); >+ for (size_t i = 0; i < length; i++) { >+ UChar upconvertedCharacter = characters[i]; >+ m_okay &= buffer16.tryAppend(&upconvertedCharacter, 1); > } >- m_okay &= buffer16.tryAppend(str.deprecatedCharacters(), length); > } > > void upConvert() >@@ -120,23 +112,6 @@ public: > m_is8Bit = false; > } > >- JSValue build(ExecState* exec) >- { >- if (!m_okay) >- return throwOutOfMemoryError(exec); >- if (m_is8Bit) { >- buffer8.shrinkToFit(); >- if (!buffer8.data()) >- return throwOutOfMemoryError(exec); >- return jsString(exec, String::adopt(buffer8)); >- } >- buffer16.shrinkToFit(); >- if (!buffer16.data()) >- return throwOutOfMemoryError(exec); >- return jsString(exec, String::adopt(buffer16)); >- } >- >-protected: > Vector<LChar, 64, UnsafeVectorOverflow> buffer8; > Vector<UChar, 64, UnsafeVectorOverflow> buffer16; > bool m_okay; >diff --git a/Source/JavaScriptCore/runtime/ObjectPrototype.cpp b/Source/JavaScriptCore/runtime/ObjectPrototype.cpp >index 40b4df7e8dd907d235b3ab54c856043673974e36..69c9f9483785579d5422abd9615b34cd09c88285 100644 >--- a/Source/JavaScriptCore/runtime/ObjectPrototype.cpp >+++ b/Source/JavaScriptCore/runtime/ObjectPrototype.cpp >@@ -25,7 +25,6 @@ > #include "GetterSetter.h" > #include "JSFunction.h" > #include "JSString.h" >-#include "JSStringBuilder.h" > #include "JSCInlines.h" > #include "StructureRareDataInlines.h" > >diff --git a/Source/JavaScriptCore/runtime/StringPrototype.cpp b/Source/JavaScriptCore/runtime/StringPrototype.cpp >index 669feefff715ba850e4c986d8710cd53c5dc2706..02d6373c5c6b768ac9161e01b250575727faef7c 100644 >--- a/Source/JavaScriptCore/runtime/StringPrototype.cpp >+++ b/Source/JavaScriptCore/runtime/StringPrototype.cpp >@@ -1408,6 +1408,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncFontsize(ExecState* exec) > if (a0.getUInt32(smallInteger) && smallInteger <= 9) { > unsigned stringSize = s.length(); > unsigned bufferSize = 22 + stringSize; >+ // FIXME: Should we have an 8-bit version of this code path too? Or maybe only an 8-bit version? > UChar* buffer; > PassRefPtr<StringImpl> impl = StringImpl::tryCreateUninitialized(bufferSize, buffer); > if (!impl) >@@ -1427,7 +1428,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncFontsize(ExecState* exec) > buffer[12] = '0' + smallInteger; > buffer[13] = '"'; > buffer[14] = '>'; >- memcpy(&buffer[15], s.deprecatedCharacters(), stringSize * sizeof(UChar)); >+ StringView(s).getCharactersWithUpconvert(&buffer[15]); > buffer[15 + stringSize] = '<'; > buffer[16 + stringSize] = '/'; > buffer[17 + stringSize] = 'f'; >@@ -1470,6 +1471,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncLink(ExecState* exec) > unsigned linkTextSize = linkText.length(); > unsigned stringSize = s.length(); > unsigned bufferSize = 15 + linkTextSize + stringSize; >+ // FIXME: Should we have an 8-bit version of this code path too? Or maybe only an 8-bit version? > UChar* buffer; > PassRefPtr<StringImpl> impl = StringImpl::tryCreateUninitialized(bufferSize, buffer); > if (!impl) >@@ -1483,10 +1485,10 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncLink(ExecState* exec) > buffer[6] = 'f'; > buffer[7] = '='; > buffer[8] = '"'; >- memcpy(&buffer[9], linkText.deprecatedCharacters(), linkTextSize * sizeof(UChar)); >+ StringView(linkText).getCharactersWithUpconvert(&buffer[9]); > buffer[9 + linkTextSize] = '"'; > buffer[10 + linkTextSize] = '>'; >- memcpy(&buffer[11 + linkTextSize], s.deprecatedCharacters(), stringSize * sizeof(UChar)); >+ StringView(s).getCharactersWithUpconvert(&buffer[11 + linkTextSize]); > buffer[11 + linkTextSize + stringSize] = '<'; > buffer[12 + linkTextSize + stringSize] = '/'; > buffer[13 + linkTextSize + stringSize] = 'a'; >diff --git a/Source/WTF/wtf/dtoa.h b/Source/WTF/wtf/dtoa.h >index 85273a4a202707220ab7bc461f4168f35935d936..fab840e5f068696d2c076f8a1744749cb588b2fc 100644 >--- a/Source/WTF/wtf/dtoa.h >+++ b/Source/WTF/wtf/dtoa.h >@@ -24,7 +24,7 @@ > #include <unicode/utypes.h> > #include <wtf/ASCIICType.h> > #include <wtf/dtoa/double-conversion.h> >-#include <wtf/text/LChar.h> >+#include <wtf/text/StringView.h> > > namespace WTF { > >@@ -49,6 +49,7 @@ WTF_EXPORT_PRIVATE const char* numberToFixedWidthString(double, unsigned decimal > > double parseDouble(const LChar* string, size_t length, size_t& parsedLength); > double parseDouble(const UChar* string, size_t length, size_t& parsedLength); >+double parseDouble(StringView, size_t& parsedLength); > > namespace Internal { > WTF_EXPORT_PRIVATE double parseDoubleFromLongString(const UChar* string, size_t length, size_t& parsedLength); >@@ -69,6 +70,13 @@ inline double parseDouble(const UChar* string, size_t length, size_t& parsedLeng > conversionBuffer[i] = isASCII(string[i]) ? string[i] : 0; > return parseDouble(conversionBuffer, length, parsedLength); > } >+ >+inline double parseDouble(StringView string, size_t& parsedLength) >+{ >+ if (string.is8Bit()) >+ return parseDouble(string.characters8(), string.length(), parsedLength); >+ return parseDouble(string.characters16(), string.length(), parsedLength); >+} > > } // namespace WTF >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
andersca
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 130304
:
226842
| 226843