Ignore:
Timestamp:
Aug 30, 2012, 2:23:51 PM (13 years ago)
Author:
[email protected]
Message:

Replace JSC::UString by WTF::String
https://bugs.webkit.org/show_bug.cgi?id=95271

Patch by Benjamin Poulain <[email protected]> on 2012-08-30
Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

Having JSC::UString and WTF::String increase the complexity of working on WebKit, and
add useless conversions in the bindings. It also cause some code bloat.

The performance advantages of UString have been ported over in previous patches. This patch
is the last step: getting rid of UString.

In addition to the simplified code, this also reduce the binary size by 15kb on x86_64.

  • API/OpaqueJSString.cpp:

(OpaqueJSString::ustring):

  • runtime/Identifier.h:

(JSC::Identifier::ustring):
To avoid changing everything at once, the function named ustring() were kept as is. They
will be renamed in a follow up patch.

  • runtime/JSString.h:

(JSC::JSString::string):
(JSC::JSValue::toWTFString):
(JSC::inlineJSValueNotStringtoString):
(JSC::JSValue::toWTFStringInline):
Since JSValue::toString() already exist (and return the JSString), the direct accessor is renamed
to ::toWTFString(). We may change ::string() to ::jsString() and ::toWTFString() to ::toString()
in the future.

  • runtime/StringPrototype.cpp:

(JSC::substituteBackreferencesSlow): Replace the use of UString::getCharacters<>() by String::getCharactersWithUpconvert<>().

Source/WebCore:

Update the code to use String instead of UString.

On x86_64, this reduces the binary size by 22kb.

Since it is no longer possible to differenciate JSC::jsString() and WebCore::jsString() by the input
types, WebCore::jsString() is renated to WebCore::jsStringWithCache().

Since the cache is using a PtrHash, JSC::jsString() is used in place of the old WebCore::jsString() when
the string is generated locally. This is because the cache can never match in those cases.

Source/WebKit/blackberry:

Replace UString by String.

  • WebCoreSupport/ClientExtension.cpp:
  • WebCoreSupport/PagePopupBlackBerry.cpp:

(WebCore::PagePopupBlackBerry::installDomFunction):

Source/WebKit/efl:

Replace UString by String.

  • WebCoreSupport/DumpRenderTreeSupportEfl.cpp:

(DumpRenderTreeSupportEfl::sendWebIntentResponse):

  • ewk/ewk_frame.cpp:

(ewk_frame_script_execute):

Source/WebKit/gtk:

Replace UString by String.

  • gdom/ConvertToGCharPrivate.h:

(copyAsGchar):

Source/WebKit/mac:

Get rid of UString, replace it by String, and simplify the code when possible.

On x86_64, this reduces the binary size by 7kb.

  • Plugins/Hosted/NetscapePluginHostProxy.mm:

(identifierFromIdentifierRep):

  • Plugins/Hosted/NetscapePluginInstanceProxy.mm:

(WebKit::NetscapePluginInstanceProxy::addValueToArray):
(WebKit::NetscapePluginInstanceProxy::moveGlobalExceptionToExecState):

  • Plugins/Hosted/ProxyInstance.mm:

(WebKit::ProxyRuntimeMethod::create):
(WebKit::ProxyRuntimeMethod::finishCreation):
(WebKit::ProxyInstance::getPropertyNames):
(WebKit::ProxyInstance::methodsNamed):
(WebKit::ProxyInstance::fieldNamed):

  • WebView/WebFrame.mm:

(-[WebFrame _stringByEvaluatingJavaScriptFromString:forceUserGesture:]):
(-[WebFrame _stringByEvaluatingJavaScriptFromString:withGlobalObject:inScriptWorld:]):

  • WebView/WebScriptDebugDelegate.mm:

(-[WebScriptCallFrame functionName]):
(-[WebScriptCallFrame evaluateWebScript:]):

  • WebView/WebScriptDebugger.h:

(WTF):
(JSC):
(WebScriptDebugger):

  • WebView/WebScriptDebugger.mm:

(toNSURL):
(WebScriptDebugger::sourceParsed):

  • WebView/WebView.mm:

(aeDescFromJSValue):

Source/WebKit/qt:

Replace UString by String.

  • Api/qwebelement.cpp:

(QWebElement::evaluateJavaScript):

Source/WebKit/win:

Replace UString by String.

  • WebFrame.cpp:

(WebFrame::stringByEvaluatingJavaScriptInScriptWorld):

  • WebView.cpp:

(WebView::stringByEvaluatingJavaScriptFromString):

Source/WebKit/wx:

Update the #includes to use the correct types.

  • WebFrame.cpp:
  • WebView.cpp:

Source/WebKit2:

Update to code to switch from UString to String.

  • WebProcess/Plugins/Netscape/JSNPMethod.cpp:

(WebKit::JSNPMethod::finishCreation):

  • WebProcess/Plugins/Netscape/JSNPMethod.h:

(WebKit::JSNPMethod::create):
(JSNPMethod):

  • WebProcess/Plugins/Netscape/JSNPObject.cpp:

(WebKit::npIdentifierFromIdentifier):

  • WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp:

(WebKit::NPRuntimeObjectMap::evaluate):
(WebKit::NPRuntimeObjectMap::moveGlobalExceptionToExecState):

Source/WTF:

  • wtf/Platform.h: Useless edit to force a full build. This is needed for some bots for some reason.
  • wtf/text/WTFString.h: Export a symbol that was exported on UString and needed in WebCore.

Add String::getCharactersWithUpconvert<>(), which is similar to String::getCharacters<>() but with the same
behaviors as UString::getCharacters<>().

String::getCharactersWithUpconvert<>() is useful when manipulating multiple strings, it allow writting code
using 16bits characters if any of the input String is not 8bit.

Tools:

Get rid of UString.

  • DumpRenderTree/efl/WorkQueueItemEfl.cpp:
  • gdb/webkit.py:

(WTFStringPrinter.to_string):
(JSCIdentifierPrinter.to_string):
(JSCJSStringPrinter.to_string):
(add_pretty_printers):

Websites/webkit.org:

Update the coding style to avoid mentioning a class that no longer exist.

  • coding/coding-style.html:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/JSString.h

    r126494 r127191  
    3838    JSString* jsEmptyString(JSGlobalData*);
    3939    JSString* jsEmptyString(ExecState*);
    40     JSString* jsString(JSGlobalData*, const UString&); // returns empty string if passed null string
    41     JSString* jsString(ExecState*, const UString&); // returns empty string if passed null string
     40    JSString* jsString(JSGlobalData*, const String&); // returns empty string if passed null string
     41    JSString* jsString(ExecState*, const String&); // returns empty string if passed null string
    4242
    4343    JSString* jsSingleCharacterString(JSGlobalData*, UChar);
    4444    JSString* jsSingleCharacterString(ExecState*, UChar);
    45     JSString* jsSingleCharacterSubstring(ExecState*, const UString&, unsigned offset);
    46     JSString* jsSubstring(JSGlobalData*, const UString&, unsigned offset, unsigned length);
    47     JSString* jsSubstring(ExecState*, const UString&, unsigned offset, unsigned length);
     45    JSString* jsSingleCharacterSubstring(ExecState*, const String&, unsigned offset);
     46    JSString* jsSubstring(JSGlobalData*, const String&, unsigned offset, unsigned length);
     47    JSString* jsSubstring(ExecState*, const String&, unsigned offset, unsigned length);
    4848
    4949    // Non-trivial strings are two or more characters long.
    5050    // These functions are faster than just calling jsString.
    51     JSString* jsNontrivialString(JSGlobalData*, const UString&);
    52     JSString* jsNontrivialString(ExecState*, const UString&);
     51    JSString* jsNontrivialString(JSGlobalData*, const String&);
     52    JSString* jsNontrivialString(ExecState*, const String&);
    5353    JSString* jsNontrivialString(JSGlobalData*, const char*);
    5454    JSString* jsNontrivialString(ExecState*, const char*);
     
    5656    // Should be used for strings that are owned by an object that will
    5757    // likely outlive the JSValue this makes, such as the parse tree or a
    58     // DOM object that contains a UString
    59     JSString* jsOwnedString(JSGlobalData*, const UString&);
    60     JSString* jsOwnedString(ExecState*, const UString&);
     58    // DOM object that contains a String
     59    JSString* jsOwnedString(JSGlobalData*, const String&);
     60    JSString* jsOwnedString(ExecState*, const String&);
    6161
    6262    JSRopeString* jsStringBuilder(JSGlobalData*);
     
    137137        }
    138138
    139         const UString& value(ExecState*) const;
    140         const UString& tryGetValue() const;
     139        const String& value(ExecState*) const;
     140        const String& tryGetValue() const;
    141141        unsigned length() { return m_length; }
    142142
     
    191191        };
    192192
    193         // A string is represented either by a UString or a rope of fibers.
     193        // A string is represented either by a String or a rope of fibers.
    194194        unsigned m_length;
    195         mutable UString m_value;
     195        mutable String m_value;
    196196
    197197    private:
     
    204204        static bool getOwnPropertySlotByIndex(JSCell*, ExecState*, unsigned propertyName, PropertySlot&);
    205205
    206         UString& string() { ASSERT(!isRope()); return m_value; }
     206        String& string() { ASSERT(!isRope()); return m_value; }
    207207
    208208        friend JSValue jsString(ExecState*, JSString*, JSString*);
     
    341341        if (c <= maxSingleCharacterString)
    342342            return globalData->smallStrings.singleCharacterString(globalData, c);
    343         return JSString::create(*globalData, UString(&c, 1).impl());
    344     }
    345 
    346     ALWAYS_INLINE JSString* jsSingleCharacterSubstring(ExecState* exec, const UString& s, unsigned offset)
     343        return JSString::create(*globalData, String(&c, 1).impl());
     344    }
     345
     346    ALWAYS_INLINE JSString* jsSingleCharacterSubstring(ExecState* exec, const String& s, unsigned offset)
    347347    {
    348348        JSGlobalData* globalData = &exec->globalData();
     
    359359        ASSERT(s[0]);
    360360        ASSERT(s[1]);
    361         return JSString::create(*globalData, UString(s).impl());
    362     }
    363 
    364     inline JSString* jsNontrivialString(JSGlobalData* globalData, const UString& s)
     361        return JSString::create(*globalData, String(s).impl());
     362    }
     363
     364    inline JSString* jsNontrivialString(JSGlobalData* globalData, const String& s)
    365365    {
    366366        ASSERT(s.length() > 1);
     
    368368    }
    369369
    370     inline const UString& JSString::value(ExecState* exec) const
     370    inline const String& JSString::value(ExecState* exec) const
    371371    {
    372372        if (isRope())
     
    375375    }
    376376
    377     inline const UString& JSString::tryGetValue() const
     377    inline const String& JSString::tryGetValue() const
    378378    {
    379379        if (isRope())
     
    391391    }
    392392
    393     inline JSString* jsString(JSGlobalData* globalData, const UString& s)
     393    inline JSString* jsString(JSGlobalData* globalData, const String& s)
    394394    {
    395395        int size = s.length();
     
    415415    }
    416416
    417     inline JSString* jsSubstring8(JSGlobalData* globalData, const UString& s, unsigned offset, unsigned length)
     417    inline JSString* jsSubstring8(JSGlobalData* globalData, const String& s, unsigned offset, unsigned length)
    418418    {
    419419        ASSERT(offset <= static_cast<unsigned>(s.length()));
     
    430430    }
    431431
    432     inline JSString* jsSubstring(JSGlobalData* globalData, const UString& s, unsigned offset, unsigned length)
     432    inline JSString* jsSubstring(JSGlobalData* globalData, const String& s, unsigned offset, unsigned length)
    433433    {
    434434        ASSERT(offset <= static_cast<unsigned>(s.length()));
     
    445445    }
    446446
    447     inline JSString* jsOwnedString(JSGlobalData* globalData, const UString& s)
     447    inline JSString* jsOwnedString(JSGlobalData* globalData, const String& s)
    448448    {
    449449        int size = s.length();
     
    464464
    465465    inline JSString* jsEmptyString(ExecState* exec) { return jsEmptyString(&exec->globalData()); }
    466     inline JSString* jsString(ExecState* exec, const UString& s) { return jsString(&exec->globalData(), s); }
     466    inline JSString* jsString(ExecState* exec, const String& s) { return jsString(&exec->globalData(), s); }
    467467    inline JSString* jsSingleCharacterString(ExecState* exec, UChar c) { return jsSingleCharacterString(&exec->globalData(), c); }
    468     inline JSString* jsSubstring8(ExecState* exec, const UString& s, unsigned offset, unsigned length) { return jsSubstring8(&exec->globalData(), s, offset, length); }
    469     inline JSString* jsSubstring(ExecState* exec, const UString& s, unsigned offset, unsigned length) { return jsSubstring(&exec->globalData(), s, offset, length); }
    470     inline JSString* jsNontrivialString(ExecState* exec, const UString& s) { return jsNontrivialString(&exec->globalData(), s); }
     468    inline JSString* jsSubstring8(ExecState* exec, const String& s, unsigned offset, unsigned length) { return jsSubstring8(&exec->globalData(), s, offset, length); }
     469    inline JSString* jsSubstring(ExecState* exec, const String& s, unsigned offset, unsigned length) { return jsSubstring(&exec->globalData(), s, offset, length); }
     470    inline JSString* jsNontrivialString(ExecState* exec, const String& s) { return jsNontrivialString(&exec->globalData(), s); }
    471471    inline JSString* jsNontrivialString(ExecState* exec, const char* s) { return jsNontrivialString(&exec->globalData(), s); }
    472     inline JSString* jsOwnedString(ExecState* exec, const UString& s) { return jsOwnedString(&exec->globalData(), s); }
     472    inline JSString* jsOwnedString(ExecState* exec, const String& s) { return jsOwnedString(&exec->globalData(), s); }
    473473
    474474    ALWAYS_INLINE bool JSString::getStringPropertySlot(ExecState* exec, PropertyName propertyName, PropertySlot& slot)
     
    528528    }
    529529
    530     inline UString JSValue::toUString(ExecState* exec) const
     530    inline String JSValue::toWTFString(ExecState* exec) const
    531531    {
    532532        if (isString())
    533533            return static_cast<JSString*>(asCell())->value(exec);
    534         return toUStringSlowCase(exec);
    535     }
    536 
    537     ALWAYS_INLINE UString inlineJSValueNotStringtoUString(const JSValue& value, ExecState* exec)
     534        return toWTFStringSlowCase(exec);
     535    }
     536
     537    ALWAYS_INLINE String inlineJSValueNotStringtoString(const JSValue& value, ExecState* exec)
    538538    {
    539539        JSGlobalData& globalData = exec->globalData();
     
    553553    }
    554554
    555     ALWAYS_INLINE UString JSValue::toUStringInline(ExecState* exec) const
     555    ALWAYS_INLINE String JSValue::toWTFStringInline(ExecState* exec) const
    556556    {
    557557        if (isString())
    558558            return static_cast<JSString*>(asCell())->value(exec);
    559559
    560         return inlineJSValueNotStringtoUString(*this, exec);
     560        return inlineJSValueNotStringtoString(*this, exec);
    561561    }
    562562
Note: See TracChangeset for help on using the changeset viewer.