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

    r123417 r127191  
    8181using namespace WTF;
    8282
    83 static bool fillBufferWithContentsOfFile(const UString& fileName, Vector<char>& buffer);
     83static bool fillBufferWithContentsOfFile(const String& fileName, Vector<char>& buffer);
    8484
    8585static EncodedJSValue JSC_HOST_CALL functionPrint(ExecState*);
     
    130130    bool m_exitCode;
    131131    Vector<Script> m_scripts;
    132     Vector<UString> m_arguments;
     132    Vector<String> m_arguments;
    133133
    134134    void parseArguments(int, char**);
     
    170170    typedef JSGlobalObject Base;
    171171
    172     static GlobalObject* create(JSGlobalData& globalData, Structure* structure, const Vector<UString>& arguments)
     172    static GlobalObject* create(JSGlobalData& globalData, Structure* structure, const Vector<String>& arguments)
    173173    {
    174174        GlobalObject* object = new (NotNull, allocateCell<GlobalObject>(globalData.heap)) GlobalObject(globalData, structure);
     
    188188
    189189protected:
    190     void finishCreation(JSGlobalData& globalData, const Vector<UString>& arguments)
     190    void finishCreation(JSGlobalData& globalData, const Vector<String>& arguments)
    191191    {
    192192        Base::finishCreation(globalData);
     
    253253}
    254254
    255 static inline SourceCode jscSource(const char* utf8, const UString& filename)
     255static inline SourceCode jscSource(const char* utf8, const String& filename)
    256256{
    257257    // Find the the first non-ascii character, or nul.
     
    263263    // Fast case - string is all ascii.
    264264    if (!*pos)
    265         return makeSource(UString(utf8, asciiLength), filename);
     265        return makeSource(String(utf8, asciiLength), filename);
    266266
    267267    // Slow case - contains non-ascii characters, use fromUTF8WithLatin1Fallback.
     
    348348EncodedJSValue JSC_HOST_CALL functionRun(ExecState* exec)
    349349{
    350     UString fileName = exec->argument(0).toString(exec)->value(exec);
     350    String fileName = exec->argument(0).toString(exec)->value(exec);
    351351    Vector<char> script;
    352352    if (!fillBufferWithContentsOfFile(fileName, script))
    353353        return JSValue::encode(throwError(exec, createError(exec, "Could not open file.")));
    354354
    355     GlobalObject* globalObject = GlobalObject::create(exec->globalData(), GlobalObject::createStructure(exec->globalData(), jsNull()), Vector<UString>());
     355    GlobalObject* globalObject = GlobalObject::create(exec->globalData(), GlobalObject::createStructure(exec->globalData(), jsNull()), Vector<String>());
    356356
    357357    JSValue exception;
     
    371371EncodedJSValue JSC_HOST_CALL functionLoad(ExecState* exec)
    372372{
    373     UString fileName = exec->argument(0).toString(exec)->value(exec);
     373    String fileName = exec->argument(0).toString(exec)->value(exec);
    374374    Vector<char> script;
    375375    if (!fillBufferWithContentsOfFile(fileName, script))
     
    387387EncodedJSValue JSC_HOST_CALL functionCheckSyntax(ExecState* exec)
    388388{
    389     UString fileName = exec->argument(0).toString(exec)->value(exec);
     389    String fileName = exec->argument(0).toString(exec)->value(exec);
    390390    Vector<char> script;
    391391    if (!fillBufferWithContentsOfFile(fileName, script))
     
    524524{
    525525    const char* script;
    526     UString fileName;
     526    String fileName;
    527527    Vector<char> scriptBuffer;
    528528
     
    587587static void runInteractive(GlobalObject* globalObject)
    588588{
    589     UString interpreterName("Interpreter");
     589    String interpreterName("Interpreter");
    590590
    591591    while (true) {
     
    751751}
    752752
    753 static bool fillBufferWithContentsOfFile(const UString& fileName, Vector<char>& buffer)
     753static bool fillBufferWithContentsOfFile(const String& fileName, Vector<char>& buffer)
    754754{
    755755    FILE* f = fopen(fileName.utf8().data(), "r");
Note: See TracChangeset for help on using the changeset viewer.