Ignore:
Timestamp:
Dec 13, 2016, 11:02:45 PM (8 years ago)
Author:
Yusuke Suzuki
Message:

Use JSValue::toWTFString instead of calling toString(exec) and value(exec)
https://bugs.webkit.org/show_bug.cgi?id=165795

Reviewed by Saam Barati.

Source/JavaScriptCore:

In old days, we frequently use the idiom like, value.toString(exec)->value(exec) to
get WTFString from the given JSValue. But now, we have better function, toWTFString.
toWTFString does not create intermediate JSString objects, then reduce unnecessary
allocations.

This patch mechanically replaces value.toString(exec)->value(exec) with toWTFString(exec).

  • API/JSValueRef.cpp:

(JSValueToStringCopy):

  • bindings/ScriptValue.cpp:

(Deprecated::ScriptValue::toString):

  • inspector/JSGlobalObjectInspectorController.cpp:

(Inspector::JSGlobalObjectInspectorController::reportAPIException):

  • inspector/JSInjectedScriptHost.cpp:

(Inspector::JSInjectedScriptHost::evaluateWithScopeExtension):

  • inspector/JSJavaScriptCallFrame.cpp:

(Inspector::JSJavaScriptCallFrame::evaluateWithScopeExtension):

  • inspector/ScriptCallStackFactory.cpp:

(Inspector::extractSourceInformationFromException):

  • runtime/ConsoleObject.cpp:

(JSC::valueToStringWithUndefinedOrNullCheck):
(JSC::valueOrDefaultLabelString):

  • runtime/DateConstructor.cpp:

(JSC::dateParse):

  • runtime/DatePrototype.cpp:

(JSC::formatLocaleDate):

  • runtime/ErrorInstance.cpp:

(JSC::ErrorInstance::sanitizedToString):

  • runtime/ErrorPrototype.cpp:

(JSC::errorProtoFuncToString):

  • runtime/InspectorInstrumentationObject.cpp:

(JSC::inspectorInstrumentationObjectLog):

  • runtime/JSCJSValue.cpp:

(JSC::JSValue::toWTFStringSlowCase):

  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::globalFuncEval):

  • runtime/JSModuleLoader.cpp:

(JSC::JSModuleLoader::fetch):

  • runtime/ModuleLoaderPrototype.cpp:

(JSC::moduleLoaderPrototypeParseModule):

  • runtime/RegExpConstructor.cpp:

(JSC::regExpCreate):

  • runtime/RegExpPrototype.cpp:

(JSC::regExpProtoFuncCompile):
(JSC::regExpProtoFuncToString):

  • runtime/StringPrototype.cpp:

(JSC::replaceUsingRegExpSearch):
(JSC::replaceUsingStringSearch):
(JSC::stringProtoFuncSlice):
(JSC::stringProtoFuncSplitFast):
(JSC::stringProtoFuncSubstr):
(JSC::stringProtoFuncLocaleCompare):
(JSC::stringProtoFuncBig):
(JSC::stringProtoFuncSmall):
(JSC::stringProtoFuncBlink):
(JSC::stringProtoFuncBold):
(JSC::stringProtoFuncFixed):
(JSC::stringProtoFuncItalics):
(JSC::stringProtoFuncStrike):
(JSC::stringProtoFuncSub):
(JSC::stringProtoFuncSup):
(JSC::stringProtoFuncFontcolor):
(JSC::stringProtoFuncFontsize):
(JSC::stringProtoFuncAnchor):
(JSC::stringProtoFuncLink):
(JSC::trimString):
(JSC::stringProtoFuncStartsWith):
(JSC::stringProtoFuncEndsWith):
(JSC::stringProtoFuncIncludes):
(JSC::builtinStringIncludesInternal):
(JSC::stringProtoFuncNormalize):

  • tools/JSDollarVMPrototype.cpp:

(JSC::functionPrint):

  • wasm/js/JSWebAssemblyCompileError.h:

(JSC::JSWebAssemblyCompileError::create):

  • wasm/js/JSWebAssemblyRuntimeError.h:

(JSC::JSWebAssemblyRuntimeError::create):

Source/WebCore:

  • bindings/js/IDBBindingUtilities.cpp:

(WebCore::createIDBKeyFromValue):
(WebCore::getNthValueOnKeyPath): Deleted.
(WebCore::internalCreateIDBKeyFromScriptValueAndKeyPath): Deleted.
(WebCore::ensureNthValueOnKeyPath): Deleted.
(WebCore::canInjectNthValueOnKeyPath): Deleted.
(WebCore::injectIDBKeyIntoScriptValue): Deleted.
(WebCore::maybeCreateIDBKeyFromScriptValueAndKeyPath): Deleted.
(WebCore::canInjectIDBKeyIntoScriptValue): Deleted.
(WebCore::deserializeIDBValueToJSValue): Deleted.
(WebCore::scriptValueToIDBKey): Deleted.
(WebCore::idbKeyDataToScriptValue): Deleted.
(WebCore::createKeyPathArray): Deleted.
(WebCore::generateIndexKeyForValue): Deleted.

  • bindings/js/JSAudioTrackCustom.cpp:

(WebCore::JSAudioTrack::setKind):
(WebCore::JSAudioTrack::setLanguage):

  • bindings/js/JSCryptoAlgorithmDictionary.cpp:

(WebCore::JSCryptoAlgorithmDictionary::getAlgorithmIdentifier):

  • bindings/js/JSCustomXPathNSResolver.cpp:

(WebCore::JSCustomXPathNSResolver::lookupNamespaceURI):

  • bindings/js/JSDOMWindowCustom.cpp:

(WebCore::JSDOMWindow::setLocation):

  • bindings/js/JSDeviceMotionEventCustom.cpp:

(WebCore::JSDeviceMotionEvent::initDeviceMotionEvent):

  • bindings/js/JSDeviceOrientationEventCustom.cpp:

(WebCore::JSDeviceOrientationEvent::initDeviceOrientationEvent):

  • bindings/js/JSEventListener.cpp:

(WebCore::JSEventListener::handleEvent):
(WebCore::JSEventListener::virtualisAttribute): Deleted.
(WebCore::JSEventListener::operator==): Deleted.
(WebCore::eventHandlerAttribute): Deleted.
(WebCore::createEventListenerForEventHandlerAttribute): Deleted.
(WebCore::setEventHandlerAttribute): Deleted.
(WebCore::windowEventHandlerAttribute): Deleted.
(WebCore::setWindowEventHandlerAttribute): Deleted.
(WebCore::documentEventHandlerAttribute): Deleted.
(WebCore::setDocumentEventHandlerAttribute): Deleted.

  • bindings/js/JSHTMLAllCollectionCustom.cpp:

(WebCore::callHTMLAllCollection):
(WebCore::JSHTMLAllCollection::namedItem):

  • bindings/js/JSHTMLFormControlsCollectionCustom.cpp:

(WebCore::JSHTMLFormControlsCollection::namedItem):

  • bindings/js/JSHTMLInputElementCustom.cpp:

(WebCore::JSHTMLInputElement::setSelectionDirection):
(WebCore::JSHTMLInputElement::setSelectionRange): Deleted.

  • bindings/js/JSInspectorFrontendHostCustom.cpp:

(WebCore::populateContextMenuItems):
(WebCore::JSInspectorFrontendHost::showContextMenu): Deleted.

  • bindings/js/JSMessageEventCustom.cpp:

(WebCore::handleInitMessageEvent):

  • bindings/js/JSSQLTransactionCustom.cpp:

(WebCore::JSSQLTransaction::executeSql):

  • bindings/js/JSTextTrackCustom.cpp:

(WebCore::JSTextTrack::setLanguage):

  • bindings/js/JSVideoTrackCustom.cpp:

(WebCore::JSVideoTrack::setKind):
(WebCore::JSVideoTrack::setLanguage):

  • bindings/js/JSWebKitSubtleCryptoCustom.cpp:

(WebCore::cryptoKeyFormatFromJSValue):
(WebCore::cryptoKeyUsagesFromJSValue):

  • bindings/js/JSXMLHttpRequestCustom.cpp:

(WebCore::JSXMLHttpRequest::send):
(WebCore::JSXMLHttpRequest::responseText): Deleted.
(WebCore::JSXMLHttpRequest::retrieveResponse): Deleted.

  • bindings/js/JSXSLTProcessorCustom.cpp:

(WebCore::JSXSLTProcessor::setParameter):
(WebCore::JSXSLTProcessor::getParameter):
(WebCore::JSXSLTProcessor::removeParameter):

  • bindings/js/ScheduledAction.cpp:

(WebCore::ScheduledAction::create):

  • bridge/c/c_utility.cpp:

(JSC::Bindings::convertValueToNPVariant):

  • bridge/testbindings.cpp:

(main):

  • inspector/InspectorDOMAgent.cpp:

(WebCore::InspectorDOMAgent::buildObjectForEventListener):

Source/WebKit2:

  • WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp:

(WebKit::NPRuntimeObjectMap::convertJSValueToNPVariant):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/JSValueRef.cpp

    r202242 r209792  
    402402    JSValue jsValue = toJS(exec, value);
    403403   
    404     auto stringRef(OpaqueJSString::create(jsValue.toString(exec)->value(exec)));
     404    auto stringRef(OpaqueJSString::create(jsValue.toWTFString(exec)));
    405405    if (handleExceptionIfNeeded(exec, exception) == ExceptionStatus::DidThrow)
    406406        stringRef = nullptr;
Note: See TracChangeset for help on using the changeset viewer.