Use JSValue::toWTFString instead of calling toString(exec) and value(exec)
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Dec 2016 16:04:30 +0000 (16:04 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Dec 2016 16:04:30 +0000 (16:04 +0000)
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/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):
* 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):
* bindings/js/JSHTMLAllCollectionCustom.cpp:
(WebCore::callHTMLAllCollection):
(WebCore::JSHTMLAllCollection::namedItem):
* bindings/js/JSHTMLFormControlsCollectionCustom.cpp:
(WebCore::JSHTMLFormControlsCollection::namedItem):
* bindings/js/JSHTMLInputElementCustom.cpp:
(WebCore::JSHTMLInputElement::setSelectionDirection):
* bindings/js/JSInspectorFrontendHostCustom.cpp:
(WebCore::populateContextMenuItems):
* 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):
* 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):

Source/WebKit2:

* WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp:
(WebKit::NPRuntimeObjectMap::convertJSValueToNPVariant):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@209801 268f45cc-cd09-0410-ab3c-d52691b4dbfc

47 files changed:
Source/JavaScriptCore/API/JSValueRef.cpp
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/bindings/ScriptValue.cpp
Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.cpp
Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp
Source/JavaScriptCore/inspector/JSJavaScriptCallFrame.cpp
Source/JavaScriptCore/inspector/ScriptCallStackFactory.cpp
Source/JavaScriptCore/runtime/ConsoleObject.cpp
Source/JavaScriptCore/runtime/DateConstructor.cpp
Source/JavaScriptCore/runtime/DatePrototype.cpp
Source/JavaScriptCore/runtime/ErrorInstance.cpp
Source/JavaScriptCore/runtime/ErrorPrototype.cpp
Source/JavaScriptCore/runtime/InspectorInstrumentationObject.cpp
Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp
Source/JavaScriptCore/runtime/JSModuleLoader.cpp
Source/JavaScriptCore/runtime/ModuleLoaderPrototype.cpp
Source/JavaScriptCore/runtime/RegExpConstructor.cpp
Source/JavaScriptCore/runtime/RegExpPrototype.cpp
Source/JavaScriptCore/runtime/StringPrototype.cpp
Source/JavaScriptCore/tools/JSDollarVMPrototype.cpp
Source/JavaScriptCore/wasm/js/JSWebAssemblyCompileError.h
Source/JavaScriptCore/wasm/js/JSWebAssemblyRuntimeError.h
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/IDBBindingUtilities.cpp
Source/WebCore/bindings/js/JSAudioTrackCustom.cpp
Source/WebCore/bindings/js/JSCryptoAlgorithmDictionary.cpp
Source/WebCore/bindings/js/JSCustomXPathNSResolver.cpp
Source/WebCore/bindings/js/JSDOMWindowCustom.cpp
Source/WebCore/bindings/js/JSDeviceMotionEventCustom.cpp
Source/WebCore/bindings/js/JSDeviceOrientationEventCustom.cpp
Source/WebCore/bindings/js/JSEventListener.cpp
Source/WebCore/bindings/js/JSHTMLAllCollectionCustom.cpp
Source/WebCore/bindings/js/JSHTMLFormControlsCollectionCustom.cpp
Source/WebCore/bindings/js/JSHTMLInputElementCustom.cpp
Source/WebCore/bindings/js/JSInspectorFrontendHostCustom.cpp
Source/WebCore/bindings/js/JSMessageEventCustom.cpp
Source/WebCore/bindings/js/JSSQLTransactionCustom.cpp
Source/WebCore/bindings/js/JSTextTrackCustom.cpp
Source/WebCore/bindings/js/JSVideoTrackCustom.cpp
Source/WebCore/bindings/js/JSWebKitSubtleCryptoCustom.cpp
Source/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp
Source/WebCore/bindings/js/JSXSLTProcessorCustom.cpp
Source/WebCore/bindings/js/ScheduledAction.cpp
Source/WebCore/bridge/c/c_utility.cpp
Source/WebCore/bridge/testbindings.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp

index 4284350..c27b7c3 100644 (file)
@@ -401,7 +401,7 @@ JSStringRef JSValueToStringCopy(JSContextRef ctx, JSValueRef value, JSValueRef*
 
     JSValue jsValue = toJS(exec, value);
     
-    auto stringRef(OpaqueJSString::create(jsValue.toString(exec)->value(exec)));
+    auto stringRef(OpaqueJSString::create(jsValue.toWTFString(exec)));
     if (handleExceptionIfNeeded(exec, exception) == ExceptionStatus::DidThrow)
         stringRef = nullptr;
     return stringRef.leakRef();
index 2a58db8..2e6730f 100644 (file)
@@ -1,3 +1,86 @@
+2016-12-13  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        Use JSValue::toWTFString instead of calling toString(exec) and value(exec)
+        https://bugs.webkit.org/show_bug.cgi?id=165795
+
+        Reviewed by Saam Barati.
+
+        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/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):
+
 2016-12-14  Gavin Barraclough  <barraclough@apple.com>
 
         MarkedBlock::marksConveyLivenessDuringMarking should take into account collection scope
index 9f7a216..25568a3 100644 (file)
@@ -124,7 +124,7 @@ String ScriptValue::toString(ExecState* scriptState) const
     VM& vm = scriptState->vm();
     auto scope = DECLARE_CATCH_SCOPE(vm);
 
-    String result = m_value.get().toString(scriptState)->value(scriptState);
+    String result = m_value.get().toWTFString(scriptState);
     // Handle the case where an exception is thrown as part of invoking toString on the object.
     if (UNLIKELY(scope.exception()))
         scope.clearException();
index b58c888..4fb7d79 100644 (file)
@@ -233,7 +233,7 @@ void JSGlobalObjectInspectorController::reportAPIException(ExecState* exec, Exce
 
     // FIXME: <http://webkit.org/b/115087> Web Inspector: Should not evaluate JavaScript handling exceptions
     // If this is a custom exception object, call toString on it to try and get a nice string representation for the exception.
-    String errorMessage = exception->value().toString(exec)->value(exec);
+    String errorMessage = exception->value().toWTFString(exec);
     scope.clearException();
 
     if (JSGlobalObjectConsoleClient::logToSystemConsole()) {
index 7586d7f..3f26fe6 100644 (file)
@@ -102,7 +102,7 @@ JSValue JSInjectedScriptHost::evaluateWithScopeExtension(ExecState* exec)
     if (!scriptValue.isString())
         return throwTypeError(exec, scope, ASCIILiteral("InjectedScriptHost.evaluateWithScopeExtension first argument must be a string."));
 
-    String program = scriptValue.toString(exec)->value(exec);
+    String program = scriptValue.toWTFString(exec);
     RETURN_IF_EXCEPTION(scope, JSValue());
 
     NakedPtr<Exception> exception;
index 38f076f..c6aa4a7 100644 (file)
@@ -82,7 +82,7 @@ JSValue JSJavaScriptCallFrame::evaluateWithScopeExtension(ExecState* exec)
     if (!scriptValue.isString())
         return throwTypeError(exec, scope, ASCIILiteral("JSJavaScriptCallFrame.evaluateWithScopeExtension first argument must be a string."));
 
-    String script = scriptValue.toString(exec)->value(exec);
+    String script = scriptValue.toWTFString(exec);
     RETURN_IF_EXCEPTION(scope, JSValue());
 
     NakedPtr<Exception> exception;
index c4496d3..c47758f 100644 (file)
@@ -128,7 +128,7 @@ static void extractSourceInformationFromException(JSC::ExecState* exec, JSObject
     JSValue columnValue = exceptionObject->getDirect(exec->vm(), Identifier::fromString(exec, "column"));
     *columnNumber = columnValue && columnValue.isNumber() ? int(columnValue.toNumber(exec)) : 0;
     JSValue sourceURLValue = exceptionObject->getDirect(exec->vm(), Identifier::fromString(exec, "sourceURL"));
-    *sourceURL = sourceURLValue && sourceURLValue.isString() ? sourceURLValue.toString(exec)->value(exec) : ASCIILiteral("undefined");
+    *sourceURL = sourceURLValue && sourceURLValue.isString() ? sourceURLValue.toWTFString(exec) : ASCIILiteral("undefined");
     scope.clearException();
 }
 
index 30a9bbd..19bd5bd 100644 (file)
@@ -101,7 +101,7 @@ static String valueToStringWithUndefinedOrNullCheck(ExecState* exec, JSValue val
 {
     if (value.isUndefinedOrNull())
         return String();
-    return value.toString(exec)->value(exec);
+    return value.toWTFString(exec);
 }
 
 static EncodedJSValue consoleLogWithLevel(ExecState* exec, MessageLevel level)
@@ -291,7 +291,7 @@ static String valueOrDefaultLabelString(ExecState* exec, JSValue value)
 {
     if (value.isUndefined())
         return ASCIILiteral("default");
-    return value.toString(exec)->value(exec);
+    return value.toWTFString(exec);
 }
 
 static EncodedJSValue JSC_HOST_CALL consoleProtoFuncTime(ExecState* exec)
index 0dfadaf..a825017 100644 (file)
@@ -205,7 +205,7 @@ EncodedJSValue JSC_HOST_CALL dateParse(ExecState* exec)
 {
     VM& vm = exec->vm();
     auto scope = DECLARE_THROW_SCOPE(vm);
-    String dateStr = exec->argument(0).toString(exec)->value(exec);
+    String dateStr = exec->argument(0).toWTFString(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
     return JSValue::encode(jsNumber(parseDate(vm, dateStr)));
 }
index 78886db..e349a71 100644 (file)
@@ -151,13 +151,13 @@ static JSCell* formatLocaleDate(ExecState* exec, DateInstance*, double timeInMil
     bool useCustomFormat = false;
     String customFormatString;
 
-    String arg0String = exec->argument(0).toString(exec)->value(exec);
+    String arg0String = exec->argument(0).toWTFString(exec);
     if (arg0String == "custom" && !exec->argument(1).isUndefined()) {
         useCustomFormat = true;
-        customFormatString = exec->argument(1).toString(exec)->value(exec);
+        customFormatString = exec->argument(1).toWTFString(exec);
     } else if (format == LocaleDateAndTime && !exec->argument(1).isUndefined()) {
         dateStyle = styleFromArgString(arg0String, dateStyle);
-        timeStyle = styleFromArgString(exec->argument(1).toString(exec)->value(exec), timeStyle);
+        timeStyle = styleFromArgString(exec->argument(1).toWTFString(exec), timeStyle);
     } else if (format != LocaleTime && !exec->argument(0).isUndefined())
         dateStyle = styleFromArgString(arg0String, dateStyle);
     else if (format != LocaleDate && !exec->argument(0).isUndefined())
index 45c1c0e..ed8f2d7 100644 (file)
@@ -193,7 +193,7 @@ String ErrorInstance::sanitizedToString(ExecState* exec)
     if (!nameValue)
         nameString = ASCIILiteral("Error");
     else {
-        nameString = nameValue.toString(exec)->value(exec);
+        nameString = nameValue.toWTFString(exec);
         RETURN_IF_EXCEPTION(scope, String());
     }
 
@@ -208,7 +208,7 @@ String ErrorInstance::sanitizedToString(ExecState* exec)
     if (!messageValue)
         messageString = String();
     else {
-        messageString = messageValue.toString(exec)->value(exec);
+        messageString = messageValue.toWTFString(exec);
         RETURN_IF_EXCEPTION(scope, String());
     }
 
index 5068644..b66a14d 100644 (file)
@@ -93,7 +93,7 @@ EncodedJSValue JSC_HOST_CALL errorProtoFuncToString(ExecState* exec)
     if (name.isUndefined())
         nameString = ASCIILiteral("Error");
     else {
-        nameString = name.toString(exec)->value(exec);
+        nameString = name.toWTFString(exec);
         RETURN_IF_EXCEPTION(scope, encodedJSValue());
     }
 
@@ -108,7 +108,7 @@ EncodedJSValue JSC_HOST_CALL errorProtoFuncToString(ExecState* exec)
     if (message.isUndefined())
         messageString = String();
     else {
-        messageString = message.toString(exec)->value(exec);
+        messageString = message.toWTFString(exec);
         RETURN_IF_EXCEPTION(scope, encodedJSValue());
     }
 
index dc797ca..f69f831 100644 (file)
@@ -86,7 +86,7 @@ EncodedJSValue JSC_HOST_CALL inspectorInstrumentationObjectLog(ExecState* exec)
     VM& vm = exec->vm();
     auto scope = DECLARE_THROW_SCOPE(vm);
     JSValue target = exec->argument(0);
-    String value = target.toString(exec)->value(exec);
+    String value = target.toWTFString(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
     dataLog(value, "\n");
     return JSValue::encode(jsUndefined());
index 422d7ef..c62e4f7 100644 (file)
@@ -666,7 +666,7 @@ EncodedJSValue JSC_HOST_CALL globalFuncEval(ExecState* exec)
         return JSValue::encode(jsUndefined());
     }
 
-    String s = x.toString(exec)->value(exec);
+    String s = x.toWTFString(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
 
     if (s.is8Bit()) {
index ef85b37..bfd8f49 100644 (file)
@@ -158,7 +158,7 @@ JSInternalPromise* JSModuleLoader::fetch(ExecState* exec, JSValue key, JSValue i
     if (globalObject->globalObjectMethodTable()->moduleLoaderFetch)
         return globalObject->globalObjectMethodTable()->moduleLoaderFetch(globalObject, exec, this, key, initiator);
     JSInternalPromiseDeferred* deferred = JSInternalPromiseDeferred::create(exec, globalObject);
-    String moduleKey = key.toString(exec)->value(exec);
+    String moduleKey = key.toWTFString(exec);
     if (UNLIKELY(scope.exception())) {
         JSValue exception = scope.exception()->value();
         scope.clearException();
index 7dcd7d5..3fccda7 100644 (file)
@@ -110,7 +110,7 @@ EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeParseModule(ExecState* exec)
     const Identifier moduleKey = exec->argument(0).toPropertyKey(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
 
-    String source = exec->argument(1).toString(exec)->value(exec);
+    String source = exec->argument(1).toWTFString(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
 
     SourceCode sourceCode = makeSource(source, moduleKey.impl(), TextPosition(), SourceProviderSourceType::Module);
index fbad49b..b886cfc 100644 (file)
@@ -231,7 +231,7 @@ static JSObject* regExpCreate(ExecState* exec, JSGlobalObject* globalObject, JSV
     VM& vm = exec->vm();
     auto scope = DECLARE_THROW_SCOPE(vm);
 
-    String pattern = patternArg.isUndefined() ? emptyString() : patternArg.toString(exec)->value(exec);
+    String pattern = patternArg.isUndefined() ? emptyString() : patternArg.toWTFString(exec);
     RETURN_IF_EXCEPTION(scope, nullptr);
 
     RegExpFlags flags = toFlags(exec, flagsArg);
index 8824082..f03b9b4 100644 (file)
@@ -166,12 +166,12 @@ EncodedJSValue JSC_HOST_CALL regExpProtoFuncCompile(ExecState* exec)
             return throwVMTypeError(exec, scope, ASCIILiteral("Cannot supply flags when constructing one RegExp from another."));
         regExp = asRegExpObject(arg0)->regExp();
     } else {
-        String pattern = arg0.isUndefined() ? emptyString() : arg0.toString(exec)->value(exec);
+        String pattern = arg0.isUndefined() ? emptyString() : arg0.toWTFString(exec);
         RETURN_IF_EXCEPTION(scope, encodedJSValue());
 
         RegExpFlags flags = NoFlags;
         if (!arg1.isUndefined()) {
-            flags = regExpFlags(arg1.toString(exec)->value(exec));
+            flags = regExpFlags(arg1.toWTFString(exec));
             RETURN_IF_EXCEPTION(scope, encodedJSValue());
             if (flags == InvalidFlags)
                 return throwVMError(exec, scope, createSyntaxError(exec, ASCIILiteral("Invalid flags supplied to RegExp constructor.")));
@@ -243,12 +243,12 @@ EncodedJSValue JSC_HOST_CALL regExpProtoFuncToString(ExecState* exec)
 
     JSValue sourceValue = thisObject->get(exec, vm.propertyNames->source);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
-    String source = sourceValue.toString(exec)->value(exec);
+    String source = sourceValue.toWTFString(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
 
     JSValue flagsValue = thisObject->get(exec, vm.propertyNames->flags);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
-    String flags = flagsValue.toString(exec)->value(exec);
+    String flags = flagsValue.toWTFString(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
 
     scope.release();
index e160b23..aeee4bc 100644 (file)
@@ -554,7 +554,7 @@ static ALWAYS_INLINE EncodedJSValue replaceUsingRegExpSearch(
 
                 cachedCall.setThis(jsUndefined());
                 JSValue jsResult = cachedCall.call();
-                replacements.append(jsResult.toString(exec)->value(exec));
+                replacements.append(jsResult.toWTFString(exec));
                 RETURN_IF_EXCEPTION(scope, encodedJSValue());
 
                 lastIndex = result.end;
@@ -593,7 +593,7 @@ static ALWAYS_INLINE EncodedJSValue replaceUsingRegExpSearch(
 
                 cachedCall.setThis(jsUndefined());
                 JSValue jsResult = cachedCall.call();
-                replacements.append(jsResult.toString(exec)->value(exec));
+                replacements.append(jsResult.toWTFString(exec));
                 RETURN_IF_EXCEPTION(scope, encodedJSValue());
 
                 lastIndex = result.end;
@@ -635,7 +635,7 @@ static ALWAYS_INLINE EncodedJSValue replaceUsingRegExpSearch(
 
                 JSValue replacement = call(exec, replaceValue, callType, callData, jsUndefined(), args);
                 RETURN_IF_EXCEPTION(scope, encodedJSValue());
-                String replacementString = replacement.toString(exec)->value(exec);
+                String replacementString = replacement.toWTFString(exec);
                 RETURN_IF_EXCEPTION(scope, encodedJSValue());
                 replacements.append(replacementString);
                 RETURN_IF_EXCEPTION(scope, encodedJSValue());
@@ -718,7 +718,7 @@ static ALWAYS_INLINE EncodedJSValue replaceUsingRegExpSearch(VM& vm, ExecState*
     CallData callData;
     CallType callType = getCallData(replaceValue, callData);
     if (callType == CallType::None) {
-        replacementString = replaceValue.toString(exec)->value(exec);
+        replacementString = replaceValue.toWTFString(exec);
         RETURN_IF_EXCEPTION(scope, encodedJSValue());
     }
 
@@ -732,7 +732,7 @@ static ALWAYS_INLINE EncodedJSValue replaceUsingStringSearch(VM& vm, ExecState*
     auto scope = DECLARE_THROW_SCOPE(vm);
 
     const String& string = jsString->value(exec);
-    String searchString = searchValue.toString(exec)->value(exec);
+    String searchString = searchValue.toWTFString(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
 
     size_t matchStart = string.find(searchString);
@@ -751,7 +751,7 @@ static ALWAYS_INLINE EncodedJSValue replaceUsingStringSearch(VM& vm, ExecState*
         RETURN_IF_EXCEPTION(scope, encodedJSValue());
     }
 
-    String replaceString = replaceValue.toString(exec)->value(exec);
+    String replaceString = replaceValue.toWTFString(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
 
     StringImpl* stringImpl = string.impl();
@@ -1115,7 +1115,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncSlice(ExecState* exec)
     JSValue thisValue = exec->thisValue();
     if (!checkObjectCoercible(thisValue))
         return throwVMTypeError(exec, scope);
-    String s = thisValue.toString(exec)->value(exec);
+    String s = thisValue.toWTFString(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
 
     int len = s.length();
@@ -1183,7 +1183,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncSplitFast(ExecState* exec)
 
     // 3. Let S be the result of calling ToString, giving it the this value as its argument.
     // 7. Let s be the number of characters in S.
-    String input = thisValue.toString(exec)->value(exec);
+    String input = thisValue.toWTFString(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
     ASSERT(!input.isNull());
 
@@ -1205,7 +1205,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncSplitFast(ExecState* exec)
     // 9. If separator is a RegExp object (its [[Class]] is "RegExp"), let R = separator;
     //    otherwise let R = ToString(separator).
     JSValue separatorValue = exec->uncheckedArgument(0);
-    String separator = separatorValue.toString(exec)->value(exec);
+    String separator = separatorValue.toWTFString(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
 
     // 10. If lim == 0, return A.
@@ -1324,7 +1324,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncSubstr(ExecState* exec)
         jsString = jsCast<JSString*>(thisValue.asCell());
         len = jsString->length();
     } else {
-        uString = thisValue.toString(exec)->value(exec);
+        uString = thisValue.toWTFString(exec);
         RETURN_IF_EXCEPTION(scope, encodedJSValue());
         len = uString.length();
     }
@@ -1455,11 +1455,11 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncLocaleCompare(ExecState* exec)
     JSValue thisValue = exec->thisValue();
     if (!checkObjectCoercible(thisValue))
         return throwVMTypeError(exec, scope);
-    String s = thisValue.toString(exec)->value(exec);
+    String s = thisValue.toWTFString(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
 
     JSValue a0 = exec->argument(0);
-    String str = a0.toString(exec)->value(exec);
+    String str = a0.toWTFString(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
     return JSValue::encode(jsNumber(Collator().collate(s, str)));
 }
@@ -1574,7 +1574,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncBig(ExecState* exec)
     JSValue thisValue = exec->thisValue();
     if (!checkObjectCoercible(thisValue))
         return throwVMTypeError(exec, scope);
-    String s = thisValue.toString(exec)->value(exec);
+    String s = thisValue.toWTFString(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
     scope.release();
     return JSValue::encode(jsMakeNontrivialString(exec, "<big>", s, "</big>"));
@@ -1588,7 +1588,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncSmall(ExecState* exec)
     JSValue thisValue = exec->thisValue();
     if (!checkObjectCoercible(thisValue))
         return throwVMTypeError(exec, scope);
-    String s = thisValue.toString(exec)->value(exec);
+    String s = thisValue.toWTFString(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
     scope.release();
     return JSValue::encode(jsMakeNontrivialString(exec, "<small>", s, "</small>"));
@@ -1602,7 +1602,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncBlink(ExecState* exec)
     JSValue thisValue = exec->thisValue();
     if (!checkObjectCoercible(thisValue))
         return throwVMTypeError(exec, scope);
-    String s = thisValue.toString(exec)->value(exec);
+    String s = thisValue.toWTFString(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
     scope.release();
     return JSValue::encode(jsMakeNontrivialString(exec, "<blink>", s, "</blink>"));
@@ -1616,7 +1616,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncBold(ExecState* exec)
     JSValue thisValue = exec->thisValue();
     if (!checkObjectCoercible(thisValue))
         return throwVMTypeError(exec, scope);
-    String s = thisValue.toString(exec)->value(exec);
+    String s = thisValue.toWTFString(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
     scope.release();
     return JSValue::encode(jsMakeNontrivialString(exec, "<b>", s, "</b>"));
@@ -1630,7 +1630,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncFixed(ExecState* exec)
     JSValue thisValue = exec->thisValue();
     if (!checkObjectCoercible(thisValue))
         return throwVMTypeError(exec, scope);
-    String s = thisValue.toString(exec)->value(exec);
+    String s = thisValue.toWTFString(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
     scope.release();
     return JSValue::encode(jsMakeNontrivialString(exec, "<tt>", s, "</tt>"));
@@ -1644,7 +1644,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncItalics(ExecState* exec)
     JSValue thisValue = exec->thisValue();
     if (!checkObjectCoercible(thisValue))
         return throwVMTypeError(exec, scope);
-    String s = thisValue.toString(exec)->value(exec);
+    String s = thisValue.toWTFString(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
     scope.release();
     return JSValue::encode(jsMakeNontrivialString(exec, "<i>", s, "</i>"));
@@ -1658,7 +1658,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncStrike(ExecState* exec)
     JSValue thisValue = exec->thisValue();
     if (!checkObjectCoercible(thisValue))
         return throwVMTypeError(exec, scope);
-    String s = thisValue.toString(exec)->value(exec);
+    String s = thisValue.toWTFString(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
     scope.release();
     return JSValue::encode(jsMakeNontrivialString(exec, "<strike>", s, "</strike>"));
@@ -1672,7 +1672,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncSub(ExecState* exec)
     JSValue thisValue = exec->thisValue();
     if (!checkObjectCoercible(thisValue))
         return throwVMTypeError(exec, scope);
-    String s = thisValue.toString(exec)->value(exec);
+    String s = thisValue.toWTFString(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
     scope.release();
     return JSValue::encode(jsMakeNontrivialString(exec, "<sub>", s, "</sub>"));
@@ -1686,7 +1686,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncSup(ExecState* exec)
     JSValue thisValue = exec->thisValue();
     if (!checkObjectCoercible(thisValue))
         return throwVMTypeError(exec, scope);
-    String s = thisValue.toString(exec)->value(exec);
+    String s = thisValue.toWTFString(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
     scope.release();
     return JSValue::encode(jsMakeNontrivialString(exec, "<sup>", s, "</sup>"));
@@ -1700,7 +1700,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncFontcolor(ExecState* exec)
     JSValue thisValue = exec->thisValue();
     if (!checkObjectCoercible(thisValue))
         return throwVMTypeError(exec, scope);
-    String s = thisValue.toString(exec)->value(exec);
+    String s = thisValue.toWTFString(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
 
     JSValue a0 = exec->argument(0);
@@ -1719,7 +1719,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncFontsize(ExecState* exec)
     JSValue thisValue = exec->thisValue();
     if (!checkObjectCoercible(thisValue))
         return throwVMTypeError(exec, scope);
-    String s = thisValue.toString(exec)->value(exec);
+    String s = thisValue.toWTFString(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
 
     JSValue a0 = exec->argument(0);
@@ -1774,7 +1774,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncAnchor(ExecState* exec)
     JSValue thisValue = exec->thisValue();
     if (!checkObjectCoercible(thisValue))
         return throwVMTypeError(exec, scope);
-    String s = thisValue.toString(exec)->value(exec);
+    String s = thisValue.toWTFString(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
 
     JSValue a0 = exec->argument(0);
@@ -1793,7 +1793,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncLink(ExecState* exec)
     JSValue thisValue = exec->thisValue();
     if (!checkObjectCoercible(thisValue))
         return throwVMTypeError(exec, scope);
-    String s = thisValue.toString(exec)->value(exec);
+    String s = thisValue.toWTFString(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
 
     JSValue a0 = exec->argument(0);
@@ -1840,7 +1840,7 @@ static inline JSValue trimString(ExecState* exec, JSValue thisValue, int trimKin
 
     if (!checkObjectCoercible(thisValue))
         return throwTypeError(exec, scope);
-    String str = thisValue.toString(exec)->value(exec);
+    String str = thisValue.toWTFString(exec);
     RETURN_IF_EXCEPTION(scope, { });
 
     unsigned left = 0;
@@ -1898,7 +1898,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncStartsWith(ExecState* exec)
     if (!checkObjectCoercible(thisValue))
         return throwVMTypeError(exec, scope);
 
-    String stringToSearchIn = thisValue.toString(exec)->value(exec);
+    String stringToSearchIn = thisValue.toWTFString(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
 
     JSValue a0 = exec->argument(0);
@@ -1907,7 +1907,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncStartsWith(ExecState* exec)
     if (isRegularExpression)
         return throwVMTypeError(exec, scope, "Argument to String.prototype.startsWith cannot be a RegExp");
 
-    String searchString = a0.toString(exec)->value(exec);
+    String searchString = a0.toWTFString(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
 
     JSValue positionArg = exec->argument(1);
@@ -1932,7 +1932,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncEndsWith(ExecState* exec)
     if (!checkObjectCoercible(thisValue))
         return throwVMTypeError(exec, scope);
 
-    String stringToSearchIn = thisValue.toString(exec)->value(exec);
+    String stringToSearchIn = thisValue.toWTFString(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
 
     JSValue a0 = exec->argument(0);
@@ -1941,7 +1941,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncEndsWith(ExecState* exec)
     if (isRegularExpression)
         return throwVMTypeError(exec, scope, "Argument to String.prototype.endsWith cannot be a RegExp");
 
-    String searchString = a0.toString(exec)->value(exec);
+    String searchString = a0.toWTFString(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
 
     unsigned length = stringToSearchIn.length();
@@ -1982,7 +1982,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncIncludes(ExecState* exec)
     if (!checkObjectCoercible(thisValue))
         return throwVMTypeError(exec, scope);
 
-    String stringToSearchIn = thisValue.toString(exec)->value(exec);
+    String stringToSearchIn = thisValue.toWTFString(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
 
     JSValue a0 = exec->argument(0);
@@ -1991,7 +1991,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncIncludes(ExecState* exec)
     if (isRegularExpression)
         return throwVMTypeError(exec, scope, "Argument to String.prototype.includes cannot be a RegExp");
 
-    String searchString = a0.toString(exec)->value(exec);
+    String searchString = a0.toWTFString(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
 
     JSValue positionArg = exec->argument(1);
@@ -2008,11 +2008,11 @@ EncodedJSValue JSC_HOST_CALL builtinStringIncludesInternal(ExecState* exec)
     JSValue thisValue = exec->thisValue();
     ASSERT(checkObjectCoercible(thisValue));
 
-    String stringToSearchIn = thisValue.toString(exec)->value(exec);
+    String stringToSearchIn = thisValue.toWTFString(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
 
     JSValue a0 = exec->uncheckedArgument(0);
-    String searchString = a0.toString(exec)->value(exec);
+    String searchString = a0.toWTFString(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
 
     JSValue positionArg = exec->argument(1);
@@ -2077,7 +2077,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncNormalize(ExecState* exec)
     UNormalizationMode form = UNORM_NFC;
     // Verify that the argument is provided and is not undefined.
     if (!exec->argument(0).isUndefined()) {
-        String formString = exec->uncheckedArgument(0).toString(exec)->value(exec);
+        String formString = exec->uncheckedArgument(0).toWTFString(exec);
         RETURN_IF_EXCEPTION(scope, encodedJSValue());
 
         if (formString == "NFC")
index 25a5bd0..b8364b8 100644 (file)
@@ -337,7 +337,7 @@ static EncodedJSValue JSC_HOST_CALL functionPrint(ExecState* exec)
 {
     auto scope = DECLARE_THROW_SCOPE(exec->vm());
     for (unsigned i = 0; i < exec->argumentCount(); ++i) {
-        String argStr = exec->uncheckedArgument(i).toString(exec)->value(exec);
+        String argStr = exec->uncheckedArgument(i).toWTFString(exec);
         RETURN_IF_EXCEPTION(scope, encodedJSValue());
         dataLog(argStr);
     }
index c14a379..6f05f3e 100644 (file)
@@ -38,7 +38,7 @@ public:
     static JSWebAssemblyCompileError* create(ExecState*, Structure*, const String&, bool);
     static JSWebAssemblyCompileError* create(ExecState* exec, Structure* structure, JSValue message, bool useCurrentFrame)
     {
-        return create(exec, structure, message.isUndefined() ? String() : message.toString(exec)->value(exec), useCurrentFrame);
+        return create(exec, structure, message.isUndefined() ? String() : message.toWTFString(exec), useCurrentFrame);
     }
 
     DECLARE_INFO;
index 935930a..3c7879e 100644 (file)
@@ -38,7 +38,7 @@ public:
     static JSWebAssemblyRuntimeError* create(ExecState*, Structure*, const String&, bool useCurrentFrame = true);
     static JSWebAssemblyRuntimeError* create(ExecState* exec, Structure* structure, JSValue message, bool useCurrentFrame)
     {
-        return create(exec, structure, message.isUndefined() ? String() : message.toString(exec)->value(exec), useCurrentFrame);
+        return create(exec, structure, message.isUndefined() ? String() : message.toWTFString(exec), useCurrentFrame);
     }
 
     DECLARE_INFO;
index da1cce9..aa92250 100644 (file)
@@ -1,3 +1,61 @@
+2016-12-13  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        Use JSValue::toWTFString instead of calling toString(exec) and value(exec)
+        https://bugs.webkit.org/show_bug.cgi?id=165795
+
+        Reviewed by Saam Barati.
+
+        * bindings/js/IDBBindingUtilities.cpp:
+        (WebCore::createIDBKeyFromValue):
+        * 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):
+        * bindings/js/JSHTMLAllCollectionCustom.cpp:
+        (WebCore::callHTMLAllCollection):
+        (WebCore::JSHTMLAllCollection::namedItem):
+        * bindings/js/JSHTMLFormControlsCollectionCustom.cpp:
+        (WebCore::JSHTMLFormControlsCollection::namedItem):
+        * bindings/js/JSHTMLInputElementCustom.cpp:
+        (WebCore::JSHTMLInputElement::setSelectionDirection):
+        * bindings/js/JSInspectorFrontendHostCustom.cpp:
+        (WebCore::populateContextMenuItems):
+        * 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):
+        * 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):
+
 2016-12-14  Joonghun Park  <jh718.park@samsung.com>
 
         [EFL] Fix debug build break since r207192. Unreviewed.
index 12f57ba..0a061a2 100644 (file)
@@ -148,7 +148,7 @@ static RefPtr<IDBKey> createIDBKeyFromValue(ExecState& exec, JSValue value, Vect
         return IDBKey::createNumber(value.toNumber(&exec));
 
     if (value.isString())
-        return IDBKey::createString(value.toString(&exec)->value(&exec));
+        return IDBKey::createString(value.toWTFString(&exec));
 
     if (value.inherits(DateInstance::info()) && !std::isnan(valueToDate(&exec, value)))
         return IDBKey::createDate(valueToDate(&exec, value));
index bf004d0..732341e 100644 (file)
@@ -46,7 +46,7 @@ void JSAudioTrack::setKind(ExecState& state, JSValue value)
     VM& vm = state.vm();
     auto scope = DECLARE_THROW_SCOPE(vm);
 
-    auto& string = value.toString(&state)->value(&state);
+    auto string = value.toWTFString(&state);
     RETURN_IF_EXCEPTION(scope, void());
     wrapped().setKind(string);
 #else
@@ -61,7 +61,7 @@ void JSAudioTrack::setLanguage(ExecState& state, JSValue value)
     VM& vm = state.vm();
     auto scope = DECLARE_THROW_SCOPE(vm);
 
-    auto& string = value.toString(&state)->value(&state);
+    auto string = value.toWTFString(&state);
     RETURN_IF_EXCEPTION(scope, void());
     wrapped().setLanguage(string);
 #else
index 7f6f968..23380b6 100644 (file)
@@ -62,7 +62,7 @@ bool JSCryptoAlgorithmDictionary::getAlgorithmIdentifier(ExecState* exec, JSValu
     String algorithmName;
 
     if (value.isString())
-        algorithmName = value.toString(exec)->value(exec);
+        algorithmName = value.toWTFString(exec);
     else if (value.isObject()) {
         if (value.getObject()->inherits(StringObject::info()))
             algorithmName = asString(asStringObject(value)->internalValue())->value(exec);
index 8038977..c6cf031 100644 (file)
@@ -100,7 +100,7 @@ String JSCustomXPathNSResolver::lookupNamespaceURI(const String& prefix)
         reportException(exec, exception);
     else {
         if (!retval.isUndefinedOrNull())
-            result = retval.toString(exec)->value(exec);
+            result = retval.toWTFString(exec);
     }
 
     return result;
index 95fab5a..508b23e 100644 (file)
@@ -389,7 +389,7 @@ void JSDOMWindow::setLocation(ExecState& state, JSValue value)
     }
 #endif
 
-    String locationString = value.toString(&state)->value(&state);
+    String locationString = value.toWTFString(&state);
     RETURN_IF_EXCEPTION(scope, void());
 
     if (Location* location = wrapped().location())
index 8eea95d..ba8faf3 100644 (file)
@@ -170,7 +170,7 @@ JSValue JSDeviceMotionEvent::initDeviceMotionEvent(ExecState& state)
     VM& vm = state.vm();
     auto scope = DECLARE_THROW_SCOPE(vm);
 
-    const String type = state.argument(0).toString(&state)->value(&state);
+    const String type = state.argument(0).toWTFString(&state);
     bool bubbles = state.argument(1).toBoolean(&state);
     bool cancelable = state.argument(2).toBoolean(&state);
 
index 9d954f5..77e3415 100644 (file)
@@ -93,7 +93,7 @@ JSValue JSDeviceOrientationEvent::absolute(ExecState&) const
 
 JSValue JSDeviceOrientationEvent::initDeviceOrientationEvent(ExecState& state)
 {
-    const String type = state.argument(0).toString(&state)->value(&state);
+    const String type = state.argument(0).toWTFString(&state);
     bool bubbles = state.argument(1).toBoolean(&state);
     bool cancelable = state.argument(2).toBoolean(&state);
     // If alpha, beta or gamma are null or undefined, mark them as not provided.
index 6a14914..7915692 100644 (file)
@@ -160,7 +160,7 @@ void JSEventListener::handleEvent(ScriptExecutionContext* scriptExecutionContext
             reportException(exec, exception);
         } else {
             if (!retval.isUndefinedOrNull() && is<BeforeUnloadEvent>(*event))
-                downcast<BeforeUnloadEvent>(*event).setReturnValue(retval.toString(exec)->value(exec));
+                downcast<BeforeUnloadEvent>(*event).setReturnValue(retval.toWTFString(exec));
             if (m_isAttribute) {
                 if (retval.isFalse())
                     event->preventDefault();
index e3932c9..d8286a5 100644 (file)
@@ -67,7 +67,7 @@ static EncodedJSValue JSC_HOST_CALL callHTMLAllCollection(ExecState* exec)
 
     if (exec->argumentCount() == 1) {
         // Support for document.all(<index>) etc.
-        String string = exec->argument(0).toString(exec)->value(exec);
+        String string = exec->argument(0).toWTFString(exec);
         RETURN_IF_EXCEPTION(scope, encodedJSValue());
         if (std::optional<uint32_t> index = parseIndex(*string.impl()))
             return JSValue::encode(toJS(exec, jsCollection->globalObject(), collection.item(index.value())));
@@ -77,7 +77,7 @@ static EncodedJSValue JSC_HOST_CALL callHTMLAllCollection(ExecState* exec)
     }
 
     // The second arg, if set, is the index of the item we want
-    String string = exec->argument(0).toString(exec)->value(exec);
+    String string = exec->argument(0).toWTFString(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
     if (std::optional<uint32_t> index = parseIndex(*exec->argument(1).toWTFString(exec).impl())) {
         if (auto* item = collection.namedItemWithIndex(string, index.value()))
@@ -119,7 +119,7 @@ JSValue JSHTMLAllCollection::item(ExecState& state)
 
 JSValue JSHTMLAllCollection::namedItem(ExecState& state)
 {
-    JSValue value = namedItems(state, this, Identifier::fromString(&state, state.argument(0).toString(&state)->value(&state)));
+    JSValue value = namedItems(state, this, Identifier::fromString(&state, state.argument(0).toWTFString(&state)));
     return value.isUndefined() ? jsNull() : value;
 }
 
index 941c692..58d9b67 100644 (file)
@@ -62,7 +62,7 @@ JSValue JSHTMLFormControlsCollection::namedItem(ExecState& state)
     if (UNLIKELY(state.argumentCount() < 1))
         return throwException(&state, scope, createNotEnoughArgumentsError(&state));
 
-    JSValue value = namedItems(state, this, Identifier::fromString(&state, state.uncheckedArgument(0).toString(&state)->value(&state)));
+    JSValue value = namedItems(state, this, Identifier::fromString(&state, state.uncheckedArgument(0).toWTFString(&state)));
     return value.isUndefined() ? jsNull() : value;
 }
 
index ee9030f..1e2f33f 100644 (file)
@@ -104,7 +104,7 @@ void JSHTMLInputElement::setSelectionDirection(ExecState& state, JSValue value)
         return;
     }
 
-    input.setSelectionDirection(value.toString(&state)->value(&state));
+    input.setSelectionDirection(value.toWTFString(&state));
 }
 
 JSValue JSHTMLInputElement::setSelectionRange(ExecState& state)
index f4064e6..42b432f 100644 (file)
@@ -62,7 +62,7 @@ static void populateContextMenuItems(ExecState* exec, JSArray* array, ContextMen
         if (!type.isString())
             continue;
 
-        String typeString = type.toString(exec)->value(exec);
+        String typeString = type.toWTFString(exec);
         if (typeString == "separator") {
             ContextMenuItem item(SeparatorType, ContextMenuItemTagNoAction, String());
             menu.appendItem(item);
@@ -70,11 +70,11 @@ static void populateContextMenuItems(ExecState* exec, JSArray* array, ContextMen
             ContextMenu subMenu;
             JSArray* subItemsArray = asArray(subItems);
             populateContextMenuItems(exec, subItemsArray, subMenu);
-            ContextMenuItem item(SubmenuType, ContextMenuItemTagNoAction, label.toString(exec)->value(exec), &subMenu);
+            ContextMenuItem item(SubmenuType, ContextMenuItemTagNoAction, label.toWTFString(exec), &subMenu);
             menu.appendItem(item);
         } else {
             ContextMenuAction typedId = static_cast<ContextMenuAction>(ContextMenuItemBaseCustomTag + id.toInt32(exec));
-            ContextMenuItem menuItem((typeString == "checkbox" ? CheckableActionType : ActionType), typedId, label.toString(exec)->value(exec));
+            ContextMenuItem menuItem((typeString == "checkbox" ? CheckableActionType : ActionType), typedId, label.toWTFString(exec));
             if (!enabled.isUndefined())
                 menuItem.setEnabled(enabled.toBoolean(exec));
             if (!checked.isUndefined())
index 2714297..f8b7e01 100644 (file)
@@ -108,7 +108,7 @@ static JSC::JSValue handleInitMessageEvent(JSMessageEvent* jsEvent, JSC::ExecSta
     VM& vm = state.vm();
     auto scope = DECLARE_THROW_SCOPE(vm);
 
-    const String& typeArg = state.argument(0).toString(&state)->value(&state);
+    const String& typeArg = state.argument(0).toWTFString(&state);
     RETURN_IF_EXCEPTION(scope, JSValue());
 
     bool canBubbleArg = state.argument(1).toBoolean(&state);
@@ -122,7 +122,7 @@ static JSC::JSValue handleInitMessageEvent(JSMessageEvent* jsEvent, JSC::ExecSta
     const String originArg = convert<IDLUSVString>(state, state.argument(4));
     RETURN_IF_EXCEPTION(scope, JSValue());
 
-    const String lastEventIdArg = state.argument(5).toString(&state)->value(&state);
+    const String lastEventIdArg = state.argument(5).toWTFString(&state);
     RETURN_IF_EXCEPTION(scope, JSValue());
 
     auto sourceArg = convert<IDLNullable<IDLUnion<IDLInterface<DOMWindow>, IDLInterface<MessagePort>>>>(state, state.argument(6));
index 917d637..5b713a9 100644 (file)
@@ -52,7 +52,7 @@ JSValue JSSQLTransaction::executeSql(ExecState& state)
         return jsUndefined();
     }
 
-    String sqlStatement = state.argument(0).toString(&state)->value(&state);
+    String sqlStatement = state.argument(0).toWTFString(&state);
     RETURN_IF_EXCEPTION(scope, JSValue());
 
     // Now assemble the list of SQL arguments
@@ -79,7 +79,7 @@ JSValue JSSQLTransaction::executeSql(ExecState& state)
                 sqlValues.append(value.asNumber());
             else {
                 // Convert the argument to a string and append it
-                sqlValues.append(value.toString(&state)->value(&state));
+                sqlValues.append(value.toWTFString(&state));
                 RETURN_IF_EXCEPTION(scope, JSValue());
             }
         }
index 81594b2..793b6ea 100644 (file)
@@ -47,7 +47,7 @@ void JSTextTrack::setLanguage(ExecState& state, JSValue value)
     VM& vm = state.vm();
     auto scope = DECLARE_THROW_SCOPE(vm);
 
-    auto& string = value.toString(&state)->value(&state);
+    auto string = value.toWTFString(&state);
     RETURN_IF_EXCEPTION(scope, void());
     wrapped().setLanguage(string);
 #else
index 7ed2ab7..f79a334 100644 (file)
@@ -46,7 +46,7 @@ void JSVideoTrack::setKind(ExecState& state, JSValue value)
     VM& vm = state.vm();
     auto scope = DECLARE_THROW_SCOPE(vm);
 
-    auto& string = value.toString(&state)->value(&state);
+    auto string = value.toWTFString(&state);
     RETURN_IF_EXCEPTION(scope, void());
     wrapped().setKind(string);
 #else
@@ -61,7 +61,7 @@ void JSVideoTrack::setLanguage(ExecState& state, JSValue value)
     VM& vm = state.vm();
     auto scope = DECLARE_THROW_SCOPE(vm);
 
-    auto& string = value.toString(&state)->value(&state);
+    auto string = value.toWTFString(&state);
     RETURN_IF_EXCEPTION(scope, void());
     wrapped().setLanguage(string);
 #else
index 544a982..0742c38 100644 (file)
@@ -84,7 +84,7 @@ static bool cryptoKeyFormatFromJSValue(ExecState& state, JSValue value, CryptoKe
     VM& vm = state.vm();
     auto scope = DECLARE_THROW_SCOPE(vm);
 
-    String keyFormatString = value.toString(&state)->value(&state);
+    String keyFormatString = value.toWTFString(&state);
     RETURN_IF_EXCEPTION(scope, false);
     if (keyFormatString == "raw")
         result = CryptoKeyFormat::Raw;
@@ -116,7 +116,7 @@ static bool cryptoKeyUsagesFromJSValue(ExecState& state, JSValue value, CryptoKe
     JSArray* array = asArray(value);
     for (size_t i = 0; i < array->length(); ++i) {
         JSValue element = array->getIndex(&state, i);
-        String usageString = element.toString(&state)->value(&state);
+        String usageString = element.toWTFString(&state);
         RETURN_IF_EXCEPTION(scope, false);
         if (usageString == "encrypt")
             result |= CryptoKeyUsageEncrypt;
index 2bd1153..2fd72af 100644 (file)
@@ -124,7 +124,7 @@ JSValue JSXMLHttpRequest::send(ExecState& state)
     else {
         // FIXME: If toString raises an exception, should we exit before calling willSendXMLHttpRequest?
         // FIXME: If toString raises an exception, should we exit before calling send?
-        result = wrapped().send(value.toString(&state)->value(&state));
+        result = wrapped().send(value.toWTFString(&state));
     }
 
     // FIXME: This should probably use ShadowChicken so that we get the right frame even when it did a tail call.
index 152b873..2a8a9df 100644 (file)
@@ -50,9 +50,9 @@ JSValue JSXSLTProcessor::setParameter(ExecState& state)
 {
     if (state.argument(1).isUndefinedOrNull() || state.argument(2).isUndefinedOrNull())
         return jsUndefined(); // Throw exception?
-    String namespaceURI = state.uncheckedArgument(0).toString(&state)->value(&state);
-    String localName = state.uncheckedArgument(1).toString(&state)->value(&state);
-    String value = state.uncheckedArgument(2).toString(&state)->value(&state);
+    String namespaceURI = state.uncheckedArgument(0).toWTFString(&state);
+    String localName = state.uncheckedArgument(1).toWTFString(&state);
+    String value = state.uncheckedArgument(2).toWTFString(&state);
     wrapped().setParameter(namespaceURI, localName, value);
     return jsUndefined();
 }
@@ -61,8 +61,8 @@ JSValue JSXSLTProcessor::getParameter(ExecState& state)
 {
     if (state.argument(1).isUndefinedOrNull())
         return jsUndefined();
-    String namespaceURI = state.uncheckedArgument(0).toString(&state)->value(&state);
-    String localName = state.uncheckedArgument(1).toString(&state)->value(&state);
+    String namespaceURI = state.uncheckedArgument(0).toWTFString(&state);
+    String localName = state.uncheckedArgument(1).toWTFString(&state);
     String value = wrapped().getParameter(namespaceURI, localName);
     return jsStringOrUndefined(&state, value);
 }
@@ -71,8 +71,8 @@ JSValue JSXSLTProcessor::removeParameter(ExecState& state)
 {
     if (state.argument(1).isUndefinedOrNull())
         return jsUndefined();
-    String namespaceURI = state.uncheckedArgument(0).toString(&state)->value(&state);
-    String localName = state.uncheckedArgument(1).toString(&state)->value(&state);
+    String namespaceURI = state.uncheckedArgument(0).toWTFString(&state);
+    String localName = state.uncheckedArgument(1).toWTFString(&state);
     wrapped().removeParameter(namespaceURI, localName);
     return jsUndefined();
 }
index 0d36403..908f4dc 100644 (file)
@@ -55,7 +55,7 @@ std::unique_ptr<ScheduledAction> ScheduledAction::create(ExecState* exec, DOMWra
     if (getCallData(v, callData) == CallType::None) {
         if (policy && !policy->allowEval(exec))
             return nullptr;
-        String string = v.toString(exec)->value(exec);
+        String string = v.toWTFString(exec);
         RETURN_IF_EXCEPTION(scope, nullptr);
         return std::unique_ptr<ScheduledAction>(new ScheduledAction(string, isolatedWorld));
     }
index e4ec3c6..7bda026 100644 (file)
@@ -74,7 +74,7 @@ void convertValueToNPVariant(ExecState* exec, JSValue value, NPVariant* result)
     VOID_TO_NPVARIANT(*result);
 
     if (value.isString()) {
-        String ustring = value.toString(exec)->value(exec);
+        String ustring = value.toWTFString(exec);
         CString cstring = ustring.utf8();
         NPString string = { (const NPUTF8*)cstring.data(), static_cast<uint32_t>(cstring.length()) };
         NPN_InitializeVariantWithStringCopy(result, &string);
index baf247d..15bf48c 100644 (file)
@@ -391,7 +391,9 @@ int main(int argc, char **argv)
                 
                 if (comp.complType() == Throw) {
                     Value exVal = comp.value();
-                    char* msg = exVal.toString(exec)->value(exec).ascii();
+                    String message = exVal.toWTFString(exec);
+                    auto cstring = msg.ascii();
+                    const char* msg = cstring.data();
                     int lineno = -1;
                     if (exVal.type() == ObjectType) {
                         Value lineVal = Object::dynamicCast(exVal).get(exec, Identifier::fromString(exec, "line"));
index 5af27b5..180dfb5 100644 (file)
@@ -1,3 +1,13 @@
+2016-12-13  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        Use JSValue::toWTFString instead of calling toString(exec) and value(exec)
+        https://bugs.webkit.org/show_bug.cgi?id=165795
+
+        Reviewed by Saam Barati.
+
+        * WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp:
+        (WebKit::NPRuntimeObjectMap::convertJSValueToNPVariant):
+
 2016-12-14  Enrique Ocaña González  <eocanha@igalia.com>
 
         REGRESSION(r207879-207891): [GStreamer] Introduced many layout test failures and crashes, bots exiting early
index 49920f2..2593289 100644 (file)
@@ -168,7 +168,7 @@ void NPRuntimeObjectMap::convertJSValueToNPVariant(ExecState* exec, JSValue valu
     }
 
     if (value.isString()) {
-        NPString npString = createNPString(value.toString(exec)->value(exec).utf8());
+        NPString npString = createNPString(value.toWTFString(exec).utf8());
         STRINGN_TO_NPVARIANT(npString.UTF8Characters, npString.UTF8Length, variant);
         return;
     }