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/testRegExp.cpp

    r121381 r127191  
    2525#include "InitializeThreading.h"
    2626#include "JSGlobalObject.h"
    27 #include "UStringBuilder.h"
    2827#include <errno.h>
    2928#include <stdio.h>
    3029#include <stdlib.h>
    3130#include <string.h>
     31#include <wtf/text/StringBuilder.h>
    3232
    3333#if !OS(WINDOWS)
     
    6464    bool interactive;
    6565    bool verbose;
    66     Vector<UString> arguments;
    67     Vector<UString> files;
     66    Vector<String> arguments;
     67    Vector<String> files;
    6868};
    6969
     
    101101    }
    102102
    103     UString subject;
     103    String subject;
    104104    int offset;
    105105    int result;
     
    109109class GlobalObject : public JSGlobalObject {
    110110private:
    111     GlobalObject(JSGlobalData&, Structure*, const Vector<UString>& arguments);
     111    GlobalObject(JSGlobalData&, Structure*, const Vector<String>& arguments);
    112112
    113113public:
    114114    typedef JSGlobalObject Base;
    115115
    116     static GlobalObject* create(JSGlobalData& globalData, Structure* structure, const Vector<UString>& arguments)
     116    static GlobalObject* create(JSGlobalData& globalData, Structure* structure, const Vector<String>& arguments)
    117117    {
    118118        return new (NotNull, allocateCell<GlobalObject>(globalData.heap)) GlobalObject(globalData, structure, arguments);
     
    127127
    128128protected:
    129     void finishCreation(JSGlobalData& globalData, const Vector<UString>& arguments)
     129    void finishCreation(JSGlobalData& globalData, const Vector<String>& arguments)
    130130    {
    131131        Base::finishCreation(globalData);
     
    139139const ClassInfo GlobalObject::s_info = { "global", &JSGlobalObject::s_info, 0, ExecState::globalObjectTable, CREATE_METHOD_TABLE(GlobalObject) };
    140140
    141 GlobalObject::GlobalObject(JSGlobalData& globalData, Structure* structure, const Vector<UString>& arguments)
     141GlobalObject::GlobalObject(JSGlobalData& globalData, Structure* structure, const Vector<String>& arguments)
    142142    : JSGlobalObject(globalData, structure)
    143143{
     
    240240}
    241241
    242 static int scanString(char* buffer, int bufferLength, UStringBuilder& builder, char termChar)
     242static int scanString(char* buffer, int bufferLength, StringBuilder& builder, char termChar)
    243243{
    244244    bool escape = false;
     
    308308static RegExp* parseRegExpLine(JSGlobalData& globalData, char* line, int lineLength)
    309309{
    310     UStringBuilder pattern;
     310    StringBuilder pattern;
    311311   
    312312    if (line[0] != '/')
     
    320320    ++i;
    321321
    322     return RegExp::create(globalData, pattern.toUString(), regExpFlags(line + i));
     322    return RegExp::create(globalData, pattern.toString(), regExpFlags(line + i));
    323323}
    324324
    325325static RegExpTest* parseTestLine(char* line, int lineLength)
    326326{
    327     UStringBuilder subjectString;
     327    StringBuilder subjectString;
    328328   
    329329    if ((line[0] != ' ') || (line[1] != '"'))
     
    364364    RegExpTest* result = new RegExpTest();
    365365   
    366     result->subject = subjectString.toUString();
     366    result->subject = subjectString.toString();
    367367    result->offset = offset;
    368368    result->result = matchResult;
     
    395395}
    396396
    397 static bool runFromFiles(GlobalObject* globalObject, const Vector<UString>& files, bool verbose)
    398 {
    399     UString script;
    400     UString fileName;
     397static bool runFromFiles(GlobalObject* globalObject, const Vector<String>& files, bool verbose)
     398{
     399    String script;
     400    String fileName;
    401401    Vector<char> scriptBuffer;
    402402    unsigned tests = 0;
Note: See TracChangeset for help on using the changeset viewer.