JSValue::toString() should return a JSString* instead of a UString
authorggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Jan 2012 07:34:10 +0000 (07:34 +0000)
committerggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Jan 2012 07:34:10 +0000 (07:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=76861

../JavaScriptCore:

Reviewed by Gavin Barraclough.

This makes the common case -- toString() on a string -- faster and
inline-able. (Not a measureable speedup, but we can now remove a bunch
of duplicate hand-rolled code for this optimization.)

This also clarifies the boundary between "C++ strings" and "JS strings".

In all cases other than true, false, null, undefined, and multi-digit
numbers, the JS runtime was just retrieving a UString from a JSString,
so returning a JSString* is strictly better. In the other cases, we can
optimize to avoid creating a new JSString if we care to, but it doesn't
seem to be a big deal.

* JavaScriptCore.exp: Export!

* jsc.cpp:
(functionPrint):
(functionDebug):
(functionRun):
(functionLoad):
(functionCheckSyntax):
(runWithScripts):
(runInteractive):
* API/JSValueRef.cpp:
(JSValueToStringCopy):
* bytecode/CodeBlock.cpp:
(JSC::valueToSourceString): Call value() after calling toString(), to
convert from "JS string" (JSString*) to "C++ string" (UString), since
toString() no longer returns a "C++ string".

* dfg/DFGOperations.cpp:
(JSC::DFG::operationValueAddNotNumber):
* jit/JITStubs.cpp:
(op_add): Updated for removal of toPrimitiveString():
all '+' operands can use toString(), except for object operands, which
need to take a slow path to call toPrimitive().

* runtime/ArrayPrototype.cpp:
(JSC::arrayProtoFuncToString):
(JSC::arrayProtoFuncToLocaleString):
(JSC::arrayProtoFuncJoin):
(JSC::arrayProtoFuncPush):
* runtime/CommonSlowPaths.h:
(JSC::CommonSlowPaths::opIn):
* runtime/DateConstructor.cpp:
(JSC::dateParse):
* runtime/DatePrototype.cpp:
(JSC::formatLocaleDate): Call value() after calling toString(), as above.

* runtime/ErrorInstance.h:
(JSC::ErrorInstance::create): Simplified down to one canonical create()
function, to make string handling easier.

* runtime/ErrorPrototype.cpp:
(JSC::errorProtoFuncToString):
* runtime/ExceptionHelpers.cpp:
(JSC::createInvalidParamError):
(JSC::createNotAConstructorError):
(JSC::createNotAFunctionError):
(JSC::createNotAnObjectError):
* runtime/FunctionConstructor.cpp:
(JSC::constructFunctionSkippingEvalEnabledCheck):
* runtime/FunctionPrototype.cpp:
(JSC::functionProtoFuncBind):
* runtime/JSArray.cpp:
(JSC::JSArray::sort): Call value() after calling toString(), as above.

* runtime/JSCell.cpp:
* runtime/JSCell.h: Removed JSCell::toString() because JSValue does this
job now. Doing it in JSCell is slower (requires extra type checking), and
creates the misimpression that language-defined toString() behavior is
an implementation detail of JSCell.

* runtime/JSGlobalObjectFunctions.cpp:
(JSC::encode):
(JSC::decode):
(JSC::globalFuncEval):
(JSC::globalFuncParseInt):
(JSC::globalFuncParseFloat):
(JSC::globalFuncEscape):
(JSC::globalFuncUnescape): Call value() after calling toString(), as above.

* runtime/JSONObject.cpp:
(JSC::unwrapBoxedPrimitive):
(JSC::Stringifier::Stringifier):
(JSC::JSONProtoFuncParse): Removed some manual optimization that toString()
takes care of.

* runtime/JSObject.cpp:
(JSC::JSObject::toString):
* runtime/JSObject.h: Updated to return JSString*.

* runtime/JSString.cpp:
* runtime/JSString.h:
(JSC::JSValue::toString): Removed, since I removed JSCell::toString().

* runtime/JSValue.cpp:
(JSC::JSValue::toStringSlowCase): Removed toPrimitiveString(), and re-
spawned toStringSlowCase() from its zombie corpse, since toPrimitiveString()
basically did what we want all the time. (Note that the toPrimitive()
preference changes from NoPreference to PreferString, because that's
how ToString is defined in the language. op_add does not want this behavior.)

* runtime/NumberPrototype.cpp:
(JSC::numberProtoFuncToString):
(JSC::numberProtoFuncToLocaleString): A little simpler, now that toString()
returns a JSString*.

* runtime/ObjectConstructor.cpp:
(JSC::objectConstructorGetOwnPropertyDescriptor):
(JSC::objectConstructorDefineProperty):
* runtime/ObjectPrototype.cpp:
(JSC::objectProtoFuncHasOwnProperty):
(JSC::objectProtoFuncDefineGetter):
(JSC::objectProtoFuncDefineSetter):
(JSC::objectProtoFuncLookupGetter):
(JSC::objectProtoFuncLookupSetter):
(JSC::objectProtoFuncPropertyIsEnumerable): More calls to value(), as above.

* runtime/Operations.cpp:
(JSC::jsAddSlowCase): Need to check for object before taking the toString()
fast path becuase adding an object to a string requires calling toPrimitive()
on the object, not toString(). (They differ in their preferred conversion
type.)

* runtime/Operations.h:
(JSC::jsString):
(JSC::jsStringFromArguments): This code gets simpler, now that toString()
does the right thing.

(JSC::jsAdd): Now checks for object, just like jsAddSlowCase().

* runtime/RegExpConstructor.cpp:
(JSC::setRegExpConstructorInput):
(JSC::constructRegExp):
* runtime/RegExpObject.cpp:
(JSC::RegExpObject::match):
* runtime/RegExpPrototype.cpp:
(JSC::regExpProtoFuncCompile):
(JSC::regExpProtoFuncToString): More calls to value(), as above.

* runtime/StringConstructor.cpp:
(JSC::constructWithStringConstructor):
(JSC::callStringConstructor): This code gets simpler, now that toString()
does the right thing.

* runtime/StringPrototype.cpp:
(JSC::replaceUsingRegExpSearch):
(JSC::replaceUsingStringSearch):
(JSC::stringProtoFuncReplace):
(JSC::stringProtoFuncCharAt):
(JSC::stringProtoFuncCharCodeAt):
(JSC::stringProtoFuncConcat):
(JSC::stringProtoFuncIndexOf):
(JSC::stringProtoFuncLastIndexOf):
(JSC::stringProtoFuncMatch):
(JSC::stringProtoFuncSearch):
(JSC::stringProtoFuncSlice):
(JSC::stringProtoFuncSplit):
(JSC::stringProtoFuncSubstr):
(JSC::stringProtoFuncSubstring):
(JSC::stringProtoFuncToLowerCase):
(JSC::stringProtoFuncToUpperCase):
(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): Some of this code gets simpler, now that toString()
does the right thing. More calls to value(), as above.

../JavaScriptGlue:

Reviewed by Gavin Barraclough.

* JSUtils.cpp:
(KJSValueToCFTypeInternal):

../WebCore:

Reviewed by Gavin Barraclough.

Mechanical changes to call value() after calling toString(), to
convert from "JS string" (JSString*) to "C++ string" (UString), since
toString() no longer returns a "C++ string".

* bindings/js/IDBBindingUtilities.cpp:
(WebCore::createIDBKeyFromValue):
* bindings/js/JSCSSStyleDeclarationCustom.cpp:
(WebCore::JSCSSStyleDeclaration::getPropertyCSSValue):
* bindings/js/JSClipboardCustom.cpp:
(WebCore::JSClipboard::clearData):
(WebCore::JSClipboard::getData):
* bindings/js/JSCustomXPathNSResolver.cpp:
(WebCore::JSCustomXPathNSResolver::lookupNamespaceURI):
* bindings/js/JSDOMBinding.cpp:
(WebCore::valueToStringWithNullCheck):
(WebCore::valueToStringWithUndefinedOrNullCheck):
(WebCore::reportException):
* bindings/js/JSDOMFormDataCustom.cpp:
(WebCore::JSDOMFormData::append):
* bindings/js/JSDOMStringMapCustom.cpp:
(WebCore::JSDOMStringMap::putDelegate):
* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::JSDOMWindow::setLocation):
(WebCore::JSDOMWindow::open):
(WebCore::JSDOMWindow::addEventListener):
(WebCore::JSDOMWindow::removeEventListener):
* bindings/js/JSDeviceMotionEventCustom.cpp:
(WebCore::JSDeviceMotionEvent::initDeviceMotionEvent):
* bindings/js/JSDeviceOrientationEventCustom.cpp:
(WebCore::JSDeviceOrientationEvent::initDeviceOrientationEvent):
* bindings/js/JSDictionary.cpp:
(WebCore::JSDictionary::convertValue):
* bindings/js/JSDocumentCustom.cpp:
(WebCore::JSDocument::setLocation):
* bindings/js/JSEventListener.cpp:
(WebCore::JSEventListener::handleEvent):
* bindings/js/JSHTMLAllCollectionCustom.cpp:
(WebCore::callHTMLAllCollection):
(WebCore::JSHTMLAllCollection::item):
(WebCore::JSHTMLAllCollection::namedItem):
* bindings/js/JSHTMLCanvasElementCustom.cpp:
(WebCore::JSHTMLCanvasElement::getContext):
* bindings/js/JSHTMLCollectionCustom.cpp:
(WebCore::JSHTMLCollection::item):
(WebCore::JSHTMLCollection::namedItem):
* bindings/js/JSHTMLDocumentCustom.cpp:
(WebCore::documentWrite):
* bindings/js/JSHTMLInputElementCustom.cpp:
(WebCore::JSHTMLInputElement::setSelectionDirection):
(WebCore::JSHTMLInputElement::setSelectionRange):
* bindings/js/JSInspectorFrontendHostCustom.cpp:
(WebCore::JSInspectorFrontendHost::showContextMenu):
* bindings/js/JSJavaScriptCallFrameCustom.cpp:
(WebCore::JSJavaScriptCallFrame::evaluate):
* bindings/js/JSLocationCustom.cpp:
(WebCore::JSLocation::setHref):
(WebCore::JSLocation::setProtocol):
(WebCore::JSLocation::setHost):
(WebCore::JSLocation::setHostname):
(WebCore::JSLocation::setPort):
(WebCore::JSLocation::setPathname):
(WebCore::JSLocation::setSearch):
(WebCore::JSLocation::setHash):
(WebCore::JSLocation::replace):
(WebCore::JSLocation::assign):
* bindings/js/JSMessageEventCustom.cpp:
(WebCore::handleInitMessageEvent):
* bindings/js/JSSQLTransactionCustom.cpp:
(WebCore::JSSQLTransaction::executeSql):
* bindings/js/JSSQLTransactionSyncCustom.cpp:
(WebCore::JSSQLTransactionSync::executeSql):
* bindings/js/JSSharedWorkerCustom.cpp:
(WebCore::JSSharedWorkerConstructor::constructJSSharedWorker):
* bindings/js/JSStorageCustom.cpp:
(WebCore::JSStorage::putDelegate):
* bindings/js/JSWebGLRenderingContextCustom.cpp:
(WebCore::JSWebGLRenderingContext::getExtension):
* bindings/js/JSWebSocketCustom.cpp:
(WebCore::JSWebSocketConstructor::constructJSWebSocket):
(WebCore::JSWebSocket::send):
(WebCore::JSWebSocket::close):
* bindings/js/JSWorkerContextCustom.cpp:
(WebCore::JSWorkerContext::importScripts):
* bindings/js/JSWorkerCustom.cpp:
(WebCore::JSWorkerConstructor::constructJSWorker):
* bindings/js/JSXMLHttpRequestCustom.cpp:
(WebCore::JSXMLHttpRequest::open):
(WebCore::JSXMLHttpRequest::send):
* bindings/js/JSXSLTProcessorCustom.cpp:
(WebCore::JSXSLTProcessor::setParameter):
(WebCore::JSXSLTProcessor::getParameter):
(WebCore::JSXSLTProcessor::removeParameter):
* bindings/js/ScheduledAction.cpp:
(WebCore::ScheduledAction::create):
* bindings/js/ScriptEventListener.cpp:
(WebCore::eventListenerHandlerBody):
* bindings/js/ScriptValue.cpp:
(WebCore::ScriptValue::toString):
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateEventListenerCall):
(JSValueToNative):
(GenerateConstructorDefinition):
* bridge/c/c_utility.cpp:
(JSC::Bindings::convertValueToNPVariant):
* bridge/jni/jni_jsobject.mm:
(JavaJSObject::convertValueToJObject):
* bridge/jni/jsc/JNIUtilityPrivate.cpp:
(JSC::Bindings::convertArrayInstanceToJavaArray):
(JSC::Bindings::convertValueToJValue):
* bridge/jni/jsc/JavaFieldJSC.cpp:
(JavaField::dispatchValueFromInstance):
(JavaField::valueFromInstance):
(JavaField::dispatchSetValueToInstance):
(JavaField::setValueToInstance):
* bridge/jni/jsc/JavaInstanceJSC.cpp:
(JavaInstance::invokeMethod):
* testing/js/JSInternalsCustom.cpp:
(WebCore::JSInternals::setUserPreferredLanguages):

../WebKit/mac:

Reviewed by Gavin Barraclough.

Mechanical changes to call value() after calling toString(), to
convert from "JS string" (JSString*) to "C++ string" (UString), since
toString() no longer returns a "C++ string".

* Plugins/Hosted/NetscapePluginInstanceProxy.mm:
(WebKit::NetscapePluginInstanceProxy::addValueToArray):
* WebView/WebFrame.mm:
(-[WebFrame _stringByEvaluatingJavaScriptFromString:forceUserGesture:]):
(-[WebFrame _stringByEvaluatingJavaScriptFromString:withGlobalObject:inScriptWorld:]):

../WebKit2:

Reviewed by Gavin Barraclough.

Mechanical changes to call value() after calling toString(), to
convert from "JS string" (JSString*) to "C++ string" (UString), since
toString() no longer returns a "C++ string".

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

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

93 files changed:
Source/JavaScriptCore/API/JSValueRef.cpp
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/JavaScriptCore.exp
Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
Source/JavaScriptCore/bytecode/CodeBlock.cpp
Source/JavaScriptCore/dfg/DFGOperations.cpp
Source/JavaScriptCore/jit/JITStubs.cpp
Source/JavaScriptCore/jsc.cpp
Source/JavaScriptCore/runtime/ArrayPrototype.cpp
Source/JavaScriptCore/runtime/CommonSlowPaths.h
Source/JavaScriptCore/runtime/DateConstructor.cpp
Source/JavaScriptCore/runtime/DatePrototype.cpp
Source/JavaScriptCore/runtime/ErrorInstance.h
Source/JavaScriptCore/runtime/ErrorPrototype.cpp
Source/JavaScriptCore/runtime/ExceptionHelpers.cpp
Source/JavaScriptCore/runtime/FunctionConstructor.cpp
Source/JavaScriptCore/runtime/FunctionPrototype.cpp
Source/JavaScriptCore/runtime/JSArray.cpp
Source/JavaScriptCore/runtime/JSCell.cpp
Source/JavaScriptCore/runtime/JSCell.h
Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp
Source/JavaScriptCore/runtime/JSONObject.cpp
Source/JavaScriptCore/runtime/JSObject.cpp
Source/JavaScriptCore/runtime/JSObject.h
Source/JavaScriptCore/runtime/JSString.cpp
Source/JavaScriptCore/runtime/JSString.h
Source/JavaScriptCore/runtime/JSValue.cpp
Source/JavaScriptCore/runtime/JSValue.h
Source/JavaScriptCore/runtime/NumberPrototype.cpp
Source/JavaScriptCore/runtime/ObjectConstructor.cpp
Source/JavaScriptCore/runtime/ObjectPrototype.cpp
Source/JavaScriptCore/runtime/Operations.cpp
Source/JavaScriptCore/runtime/Operations.h
Source/JavaScriptCore/runtime/RegExpConstructor.cpp
Source/JavaScriptCore/runtime/RegExpObject.cpp
Source/JavaScriptCore/runtime/RegExpPrototype.cpp
Source/JavaScriptCore/runtime/StringConstructor.cpp
Source/JavaScriptCore/runtime/StringPrototype.cpp
Source/JavaScriptGlue/ChangeLog
Source/JavaScriptGlue/JSUtils.cpp
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/IDBBindingUtilities.cpp
Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp
Source/WebCore/bindings/js/JSClipboardCustom.cpp
Source/WebCore/bindings/js/JSCustomXPathNSResolver.cpp
Source/WebCore/bindings/js/JSDOMBinding.cpp
Source/WebCore/bindings/js/JSDOMFormDataCustom.cpp
Source/WebCore/bindings/js/JSDOMStringMapCustom.cpp
Source/WebCore/bindings/js/JSDOMWindowCustom.cpp
Source/WebCore/bindings/js/JSDeviceMotionEventCustom.cpp
Source/WebCore/bindings/js/JSDeviceOrientationEventCustom.cpp
Source/WebCore/bindings/js/JSDictionary.cpp
Source/WebCore/bindings/js/JSDocumentCustom.cpp
Source/WebCore/bindings/js/JSEventListener.cpp
Source/WebCore/bindings/js/JSHTMLAllCollectionCustom.cpp
Source/WebCore/bindings/js/JSHTMLCanvasElementCustom.cpp
Source/WebCore/bindings/js/JSHTMLCollectionCustom.cpp
Source/WebCore/bindings/js/JSHTMLDocumentCustom.cpp
Source/WebCore/bindings/js/JSHTMLInputElementCustom.cpp
Source/WebCore/bindings/js/JSInspectorFrontendHostCustom.cpp
Source/WebCore/bindings/js/JSJavaScriptCallFrameCustom.cpp
Source/WebCore/bindings/js/JSLocationCustom.cpp
Source/WebCore/bindings/js/JSMessageEventCustom.cpp
Source/WebCore/bindings/js/JSSQLTransactionCustom.cpp
Source/WebCore/bindings/js/JSSQLTransactionSyncCustom.cpp
Source/WebCore/bindings/js/JSSharedWorkerCustom.cpp
Source/WebCore/bindings/js/JSStorageCustom.cpp
Source/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp
Source/WebCore/bindings/js/JSWebSocketCustom.cpp
Source/WebCore/bindings/js/JSWorkerContextCustom.cpp
Source/WebCore/bindings/js/JSWorkerCustom.cpp
Source/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp
Source/WebCore/bindings/js/JSXSLTProcessorCustom.cpp
Source/WebCore/bindings/js/ScheduledAction.cpp
Source/WebCore/bindings/js/ScriptEventListener.cpp
Source/WebCore/bindings/js/ScriptValue.cpp
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bridge/c/c_utility.cpp
Source/WebCore/bridge/jni/jni_jsobject.mm
Source/WebCore/bridge/jni/jsc/JNIUtilityPrivate.cpp
Source/WebCore/bridge/jni/jsc/JavaFieldJSC.cpp
Source/WebCore/bridge/jni/jsc/JavaInstanceJSC.cpp
Source/WebCore/bridge/qt/qt_runtime.cpp
Source/WebCore/bridge/testbindings.cpp
Source/WebCore/bridge/testqtbindings.cpp
Source/WebCore/testing/js/JSInternalsCustom.cpp
Source/WebKit/efl/ewk/ewk_frame.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm
Source/WebKit/mac/WebView/WebFrame.mm
Source/WebKit/win/WebFrame.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp

index c89e267..1b4e03b 100644 (file)
@@ -293,7 +293,7 @@ JSStringRef JSValueToStringCopy(JSContextRef ctx, JSValueRef value, JSValueRef*
 
     JSValue jsValue = toJS(exec, value);
     
-    RefPtr<OpaqueJSString> stringRef(OpaqueJSString::create(jsValue.toString(exec)));
+    RefPtr<OpaqueJSString> stringRef(OpaqueJSString::create(jsValue.toString(exec)->value(exec)));
     if (exec->hadException()) {
         if (exception)
             *exception = toRef(exec, exec->exception());
index 83e0002..1ba9f1e 100644 (file)
@@ -1,3 +1,189 @@
+2012-01-23  Geoffrey Garen  <ggaren@apple.com>
+
+        JSValue::toString() should return a JSString* instead of a UString
+        https://bugs.webkit.org/show_bug.cgi?id=76861
+
+        Reviewed by Gavin Barraclough.
+        
+        This makes the common case -- toString() on a string -- faster and
+        inline-able. (Not a measureable speedup, but we can now remove a bunch
+        of duplicate hand-rolled code for this optimization.)
+        
+        This also clarifies the boundary between "C++ strings" and "JS strings".
+        
+        In all cases other than true, false, null, undefined, and multi-digit
+        numbers, the JS runtime was just retrieving a UString from a JSString,
+        so returning a JSString* is strictly better. In the other cases, we can
+        optimize to avoid creating a new JSString if we care to, but it doesn't
+        seem to be a big deal.
+
+        * JavaScriptCore.exp: Export!
+        
+        * jsc.cpp:
+        (functionPrint):
+        (functionDebug):
+        (functionRun):
+        (functionLoad):
+        (functionCheckSyntax):
+        (runWithScripts):
+        (runInteractive):
+        * API/JSValueRef.cpp:
+        (JSValueToStringCopy):
+        * bytecode/CodeBlock.cpp:
+        (JSC::valueToSourceString): Call value() after calling toString(), to
+        convert from "JS string" (JSString*) to "C++ string" (UString), since
+        toString() no longer returns a "C++ string".
+
+        * dfg/DFGOperations.cpp:
+        (JSC::DFG::operationValueAddNotNumber):
+        * jit/JITStubs.cpp:
+        (op_add): Updated for removal of toPrimitiveString():
+        all '+' operands can use toString(), except for object operands, which
+        need to take a slow path to call toPrimitive().
+
+        * runtime/ArrayPrototype.cpp:
+        (JSC::arrayProtoFuncToString):
+        (JSC::arrayProtoFuncToLocaleString):
+        (JSC::arrayProtoFuncJoin):
+        (JSC::arrayProtoFuncPush):
+        * runtime/CommonSlowPaths.h:
+        (JSC::CommonSlowPaths::opIn):
+        * runtime/DateConstructor.cpp:
+        (JSC::dateParse):
+        * runtime/DatePrototype.cpp:
+        (JSC::formatLocaleDate): Call value() after calling toString(), as above.
+
+        * runtime/ErrorInstance.h:
+        (JSC::ErrorInstance::create): Simplified down to one canonical create()
+        function, to make string handling easier.
+
+        * runtime/ErrorPrototype.cpp:
+        (JSC::errorProtoFuncToString):
+        * runtime/ExceptionHelpers.cpp:
+        (JSC::createInvalidParamError):
+        (JSC::createNotAConstructorError):
+        (JSC::createNotAFunctionError):
+        (JSC::createNotAnObjectError):
+        * runtime/FunctionConstructor.cpp:
+        (JSC::constructFunctionSkippingEvalEnabledCheck):
+        * runtime/FunctionPrototype.cpp:
+        (JSC::functionProtoFuncBind):
+        * runtime/JSArray.cpp:
+        (JSC::JSArray::sort): Call value() after calling toString(), as above.
+
+        * runtime/JSCell.cpp:
+        * runtime/JSCell.h: Removed JSCell::toString() because JSValue does this
+        job now. Doing it in JSCell is slower (requires extra type checking), and
+        creates the misimpression that language-defined toString() behavior is
+        an implementation detail of JSCell.
+        
+        * runtime/JSGlobalObjectFunctions.cpp:
+        (JSC::encode):
+        (JSC::decode):
+        (JSC::globalFuncEval):
+        (JSC::globalFuncParseInt):
+        (JSC::globalFuncParseFloat):
+        (JSC::globalFuncEscape):
+        (JSC::globalFuncUnescape): Call value() after calling toString(), as above.
+
+        * runtime/JSONObject.cpp:
+        (JSC::unwrapBoxedPrimitive):
+        (JSC::Stringifier::Stringifier):
+        (JSC::JSONProtoFuncParse): Removed some manual optimization that toString()
+        takes care of.
+
+        * runtime/JSObject.cpp:
+        (JSC::JSObject::toString):
+        * runtime/JSObject.h: Updated to return JSString*.
+
+        * runtime/JSString.cpp:
+        * runtime/JSString.h:
+        (JSC::JSValue::toString): Removed, since I removed JSCell::toString().
+
+        * runtime/JSValue.cpp:
+        (JSC::JSValue::toStringSlowCase): Removed toPrimitiveString(), and re-
+        spawned toStringSlowCase() from its zombie corpse, since toPrimitiveString()
+        basically did what we want all the time. (Note that the toPrimitive()
+        preference changes from NoPreference to PreferString, because that's
+        how ToString is defined in the language. op_add does not want this behavior.)
+
+        * runtime/NumberPrototype.cpp:
+        (JSC::numberProtoFuncToString):
+        (JSC::numberProtoFuncToLocaleString): A little simpler, now that toString()
+        returns a JSString*.
+
+        * runtime/ObjectConstructor.cpp:
+        (JSC::objectConstructorGetOwnPropertyDescriptor):
+        (JSC::objectConstructorDefineProperty):
+        * runtime/ObjectPrototype.cpp:
+        (JSC::objectProtoFuncHasOwnProperty):
+        (JSC::objectProtoFuncDefineGetter):
+        (JSC::objectProtoFuncDefineSetter):
+        (JSC::objectProtoFuncLookupGetter):
+        (JSC::objectProtoFuncLookupSetter):
+        (JSC::objectProtoFuncPropertyIsEnumerable): More calls to value(), as above.
+
+        * runtime/Operations.cpp:
+        (JSC::jsAddSlowCase): Need to check for object before taking the toString()
+        fast path becuase adding an object to a string requires calling toPrimitive()
+        on the object, not toString(). (They differ in their preferred conversion
+        type.)
+
+        * runtime/Operations.h:
+        (JSC::jsString):
+        (JSC::jsStringFromArguments): This code gets simpler, now that toString()
+        does the right thing.
+
+        (JSC::jsAdd): Now checks for object, just like jsAddSlowCase().
+
+        * runtime/RegExpConstructor.cpp:
+        (JSC::setRegExpConstructorInput):
+        (JSC::constructRegExp):
+        * runtime/RegExpObject.cpp:
+        (JSC::RegExpObject::match):
+        * runtime/RegExpPrototype.cpp:
+        (JSC::regExpProtoFuncCompile):
+        (JSC::regExpProtoFuncToString): More calls to value(), as above.
+
+        * runtime/StringConstructor.cpp:
+        (JSC::constructWithStringConstructor):
+        (JSC::callStringConstructor): This code gets simpler, now that toString()
+        does the right thing.
+
+        * runtime/StringPrototype.cpp:
+        (JSC::replaceUsingRegExpSearch):
+        (JSC::replaceUsingStringSearch):
+        (JSC::stringProtoFuncReplace):
+        (JSC::stringProtoFuncCharAt):
+        (JSC::stringProtoFuncCharCodeAt):
+        (JSC::stringProtoFuncConcat):
+        (JSC::stringProtoFuncIndexOf):
+        (JSC::stringProtoFuncLastIndexOf):
+        (JSC::stringProtoFuncMatch):
+        (JSC::stringProtoFuncSearch):
+        (JSC::stringProtoFuncSlice):
+        (JSC::stringProtoFuncSplit):
+        (JSC::stringProtoFuncSubstr):
+        (JSC::stringProtoFuncSubstring):
+        (JSC::stringProtoFuncToLowerCase):
+        (JSC::stringProtoFuncToUpperCase):
+        (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): Some of this code gets simpler, now that toString()
+        does the right thing. More calls to value(), as above.
+
 2012-01-23  Luke Macpherson   <macpherson@chromium.org>
 
         Unreviewed, rolling out r105676.
index 34ebe93..4bf3ed9 100644 (file)
@@ -567,13 +567,13 @@ __ZNK3JSC19SourceProviderCache8byteSizeEv
 __ZNK3JSC6JSCell11toPrimitiveEPNS_9ExecStateENS_22PreferredPrimitiveTypeE
 __ZNK3JSC6JSCell8toNumberEPNS_9ExecStateE
 __ZNK3JSC6JSCell8toObjectEPNS_9ExecStateEPNS_14JSGlobalObjectE
-__ZNK3JSC6JSCell8toStringEPNS_9ExecStateE
 __ZNK3JSC6JSCell9getStringEPNS_9ExecStateE
 __ZNK3JSC6JSCell9getStringEPNS_9ExecStateERNS_7UStringE
 __ZNK3JSC7ArgList8getSliceEiRS0_
 __ZNK3JSC7JSArray12subclassDataEv
 __ZNK3JSC7JSValue16toNumberSlowCaseEPNS_9ExecStateE
 __ZNK3JSC7JSValue16toObjectSlowCaseEPNS_9ExecStateEPNS_14JSGlobalObjectE
+__ZNK3JSC7JSValue16toStringSlowCaseEPNS_9ExecStateE
 __ZNK3JSC7JSValue19synthesizePrototypeEPNS_9ExecStateE
 __ZNK3JSC7JSValue20toThisObjectSlowCaseEPNS_9ExecStateE
 __ZNK3JSC7JSValue9toIntegerEPNS_9ExecStateE
index 4ef8ed3..5095d5c 100644 (file)
@@ -339,10 +339,10 @@ EXPORTS
     ?toNumberSlowCase@JSValue@JSC@@ABENPAVExecState@2@@Z
     ?toObject@JSCell@JSC@@QBEPAVJSObject@2@PAVExecState@2@PAVJSGlobalObject@2@@Z
     ?toObjectSlowCase@JSValue@JSC@@ABEPAVJSObject@2@PAVExecState@2@PAVJSGlobalObject@2@@Z
-    ?toString@JSCell@JSC@@QBE?AVUString@2@PAVExecState@2@@Z
-    ?toString@JSObject@JSC@@QBE?AVUString@2@PAVExecState@2@@Z
+    ?toString@JSObject@JSC@@QBEPAVJSString@2@PAVExecState@2@@Z
     ?toStringDecimal@DecimalNumber@WTF@@QBEIPA_WI@Z
     ?toStringExponential@DecimalNumber@WTF@@QBEIPA_WI@Z
+    ?toStringSlowCase@JSValue@JSC@@ABEPAVJSString@2@PAVExecState@2@@Z
     ?toThisObject@JSObject@JSC@@SAPAV12@PAVJSCell@2@PAVExecState@2@@Z
     ?toThisObjectSlowCase@JSValue@JSC@@ABEPAVJSObject@2@PAVExecState@2@@Z
     ?toUInt32@Identifier@JSC@@SAIABVUString@2@AA_N@Z
index 72ea0b4..0599833 100644 (file)
@@ -78,7 +78,7 @@ static UString valueToSourceString(ExecState* exec, JSValue val)
         return "0";
 
     if (val.isString())
-        return makeUString("\"", escapeQuotes(val.toString(exec)), "\"");
+        return makeUString("\"", escapeQuotes(val.toString(exec)->value(exec)), "\"");
 
     return val.description();
 }
index d1d9bd3..26be252 100644 (file)
@@ -197,7 +197,7 @@ ALWAYS_INLINE static void DFG_OPERATION operationPutByValInternal(ExecState* exe
     JSGlobalData* globalData = &exec->globalData();
 
     // Don't put to an object if toString throws an exception.
-    Identifier ident(exec, property.toString(exec));
+    Identifier ident(exec, property.toString(exec)->value(exec));
     if (!globalData->exception) {
         PutPropertySlot slot(strict);
         baseValue.put(exec, ident, value, slot);
@@ -259,11 +259,8 @@ EncodedJSValue DFG_OPERATION operationValueAddNotNumber(ExecState* exec, Encoded
     
     ASSERT(!op1.isNumber() || !op2.isNumber());
     
-    if (op1.isString()) {
-        if (op2.isString())
-            return JSValue::encode(jsString(exec, asString(op1), asString(op2)));
-        return JSValue::encode(jsString(exec, asString(op1), op2.toPrimitiveString(exec)));
-    }
+    if (op1.isString() && !op2.isObject())
+        return JSValue::encode(jsString(exec, asString(op1), op2.toString(exec)));
 
     return JSValue::encode(jsAddSlowCase(exec, op1, op2));
 }
@@ -306,7 +303,7 @@ EncodedJSValue DFG_OPERATION operationGetByVal(ExecState* exec, EncodedJSValue e
         }
     }
 
-    Identifier ident(exec, property.toString(exec));
+    Identifier ident(exec, property.toString(exec)->value(exec));
     return JSValue::encode(baseValue.get(exec, ident));
 }
 
@@ -326,7 +323,7 @@ EncodedJSValue DFG_OPERATION operationGetByValCell(ExecState* exec, JSCell* base
             return JSValue::encode(result);
     }
 
-    Identifier ident(exec, property.toString(exec));
+    Identifier ident(exec, property.toString(exec)->value(exec));
     return JSValue::encode(JSValue(base).get(exec, ident));
 }
 
index 29c5b98..38c8504 100644 (file)
@@ -1303,10 +1303,8 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_add)
     JSValue v2 = stackFrame.args[1].jsValue();
     CallFrame* callFrame = stackFrame.callFrame;
 
-    if (v1.isString()) {
-        JSValue result = v2.isString()
-            ? jsString(callFrame, asString(v1), asString(v2))
-            : jsString(callFrame, asString(v1), v2.toPrimitiveString(callFrame));
+    if (v1.isString() && !v2.isObject()) {
+        JSValue result = jsString(callFrame, asString(v1), v2.toString(callFrame));
         CHECK_FOR_EXCEPTION_AT_END();
         return JSValue::encode(result);
     }
@@ -2461,7 +2459,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_val)
         return JSValue::encode(result);
     }
     
-    Identifier property(callFrame, subscript.toString(callFrame));
+    Identifier property(callFrame, subscript.toString(callFrame)->value(callFrame));
     JSValue result = baseValue.get(callFrame, property);
     CHECK_FOR_EXCEPTION_AT_END();
     return JSValue::encode(result);
@@ -2488,7 +2486,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_val_string)
                 ctiPatchCallByReturnAddress(callFrame->codeBlock(), STUB_RETURN_ADDRESS, FunctionPtr(cti_op_get_by_val));
         }
     } else {
-        Identifier property(callFrame, subscript.toString(callFrame));
+        Identifier property(callFrame, subscript.toString(callFrame)->value(callFrame));
         result = baseValue.get(callFrame, property);
     }
     
@@ -2518,7 +2516,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_val_byte_array)
         if (!isJSByteArray(baseValue))
             ctiPatchCallByReturnAddress(callFrame->codeBlock(), STUB_RETURN_ADDRESS, FunctionPtr(cti_op_get_by_val));
     } else {
-        Identifier property(callFrame, subscript.toString(callFrame));
+        Identifier property(callFrame, subscript.toString(callFrame)->value(callFrame));
         result = baseValue.get(callFrame, property);
     }
     
@@ -2579,7 +2577,7 @@ DEFINE_STUB_FUNCTION(void, op_put_by_val)
         } else
             baseValue.put(callFrame, i, value);
     } else {
-        Identifier property(callFrame, subscript.toString(callFrame));
+        Identifier property(callFrame, subscript.toString(callFrame)->value(callFrame));
         if (!stackFrame.globalData->exception) { // Don't put to an object if toString threw an exception.
             PutPropertySlot slot(callFrame->codeBlock()->isStrictMode());
             baseValue.put(callFrame, property, value, slot);
@@ -2620,7 +2618,7 @@ DEFINE_STUB_FUNCTION(void, op_put_by_val_byte_array)
             ctiPatchCallByReturnAddress(callFrame->codeBlock(), STUB_RETURN_ADDRESS, FunctionPtr(cti_op_put_by_val));
         baseValue.put(callFrame, i, value);
     } else {
-        Identifier property(callFrame, subscript.toString(callFrame));
+        Identifier property(callFrame, subscript.toString(callFrame)->value(callFrame));
         if (!stackFrame.globalData->exception) { // Don't put to an object if toString threw an exception.
             PutPropertySlot slot(callFrame->codeBlock()->isStrictMode());
             baseValue.put(callFrame, property, value, slot);
@@ -3386,7 +3384,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_in)
     if (propName.getUInt32(i))
         return JSValue::encode(jsBoolean(baseObj->hasProperty(callFrame, i)));
 
-    Identifier property(callFrame, propName.toString(callFrame));
+    Identifier property(callFrame, propName.toString(callFrame)->value(callFrame));
     CHECK_FOR_EXCEPTION();
     return JSValue::encode(jsBoolean(baseObj->hasProperty(callFrame, property)));
 }
@@ -3498,7 +3496,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_del_by_val)
         result = baseObj->methodTable()->deletePropertyByIndex(baseObj, callFrame, i);
     else {
         CHECK_FOR_EXCEPTION();
-        Identifier property(callFrame, subscript.toString(callFrame));
+        Identifier property(callFrame, subscript.toString(callFrame)->value(callFrame));
         CHECK_FOR_EXCEPTION();
         result = baseObj->methodTable()->deleteProperty(baseObj, callFrame, property);
     }
@@ -3539,7 +3537,7 @@ DEFINE_STUB_FUNCTION(void, op_throw_reference_error)
     STUB_INIT_STACK_FRAME(stackFrame);
 
     CallFrame* callFrame = stackFrame.callFrame;
-    UString message = stackFrame.args[0].jsValue().toString(callFrame);
+    UString message = stackFrame.args[0].jsValue().toString(callFrame)->value(callFrame);
     stackFrame.globalData->exception = createReferenceError(callFrame, message);
     VM_THROW_EXCEPTION_AT_END();
 }
index ea32d89..47ec8c6 100644 (file)
@@ -238,7 +238,7 @@ EncodedJSValue JSC_HOST_CALL functionPrint(ExecState* exec)
         if (i)
             putchar(' ');
 
-        printf("%s", exec->argument(i).toString(exec).utf8().data());
+        printf("%s", exec->argument(i).toString(exec)->value(exec).utf8().data());
     }
 
     putchar('\n');
@@ -248,7 +248,7 @@ EncodedJSValue JSC_HOST_CALL functionPrint(ExecState* exec)
 
 EncodedJSValue JSC_HOST_CALL functionDebug(ExecState* exec)
 {
-    fprintf(stderr, "--> %s\n", exec->argument(0).toString(exec).utf8().data());
+    fprintf(stderr, "--> %s\n", exec->argument(0).toString(exec)->value(exec).utf8().data());
     return JSValue::encode(jsUndefined());
 }
 
@@ -277,7 +277,7 @@ EncodedJSValue JSC_HOST_CALL functionVersion(ExecState*)
 
 EncodedJSValue JSC_HOST_CALL functionRun(ExecState* exec)
 {
-    UString fileName = exec->argument(0).toString(exec);
+    UString fileName = exec->argument(0).toString(exec)->value(exec);
     Vector<char> script;
     if (!fillBufferWithContentsOfFile(fileName, script))
         return JSValue::encode(throwError(exec, createError(exec, "Could not open file.")));
@@ -294,7 +294,7 @@ EncodedJSValue JSC_HOST_CALL functionRun(ExecState* exec)
 
 EncodedJSValue JSC_HOST_CALL functionLoad(ExecState* exec)
 {
-    UString fileName = exec->argument(0).toString(exec);
+    UString fileName = exec->argument(0).toString(exec)->value(exec);
     Vector<char> script;
     if (!fillBufferWithContentsOfFile(fileName, script))
         return JSValue::encode(throwError(exec, createError(exec, "Could not open file.")));
@@ -310,7 +310,7 @@ EncodedJSValue JSC_HOST_CALL functionLoad(ExecState* exec)
 
 EncodedJSValue JSC_HOST_CALL functionCheckSyntax(ExecState* exec)
 {
-    UString fileName = exec->argument(0).toString(exec);
+    UString fileName = exec->argument(0).toString(exec)->value(exec);
     Vector<char> script;
     if (!fillBufferWithContentsOfFile(fileName, script))
         return JSValue::encode(throwError(exec, createError(exec, "Could not open file.")));
@@ -487,9 +487,9 @@ static bool runWithScripts(GlobalObject* globalObject, const Vector<Script>& scr
         success = success && !evaluationException;
         if (dump) {
             if (evaluationException)
-                printf("Exception: %s\n", evaluationException.toString(globalObject->globalExec()).utf8().data());
+                printf("Exception: %s\n", evaluationException.toString(globalObject->globalExec())->value(globalObject->globalExec()).utf8().data());
             else
-                printf("End: %s\n", returnValue.toString(globalObject->globalExec()).utf8().data());
+                printf("End: %s\n", returnValue.toString(globalObject->globalExec())->value(globalObject->globalExec()).utf8().data());
         }
 
         globalData.stopSampling();
@@ -546,9 +546,9 @@ static void runInteractive(GlobalObject* globalObject)
         JSValue returnValue = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), jscSource(line.data(), interpreterName), JSValue(), &evaluationException);
 #endif
         if (evaluationException)
-            printf("Exception: %s\n", evaluationException.toString(globalObject->globalExec()).utf8().data());
+            printf("Exception: %s\n", evaluationException.toString(globalObject->globalExec())->value(globalObject->globalExec()).utf8().data());
         else
-            printf("%s\n", returnValue.toString(globalObject->globalExec()).utf8().data());
+            printf("%s\n", returnValue.toString(globalObject->globalExec())->value(globalObject->globalExec()).utf8().data());
 
         globalObject->globalExec()->clearException();
     }
index dcf7a2f..22d6804 100644 (file)
@@ -197,7 +197,7 @@ EncodedJSValue JSC_HOST_CALL arrayProtoFuncToString(ExecState* exec)
         if (element.isUndefinedOrNull())
             continue;
         
-        UString str = element.toString(exec);
+        UString str = element.toString(exec)->value(exec);
         strBuffer[k] = str.impl();
         totalSize += str.length();
         allStrings8Bit = allStrings8Bit && str.is8Bit();
@@ -272,9 +272,9 @@ EncodedJSValue JSC_HOST_CALL arrayProtoFuncToLocaleString(ExecState* exec)
             CallData callData;
             CallType callType = getCallData(conversionFunction, callData);
             if (callType != CallTypeNone)
-                str = call(exec, conversionFunction, callType, callData, element, exec->emptyList()).toString(exec);
+                str = call(exec, conversionFunction, callType, callData, element, exec->emptyList()).toString(exec)->value(exec);
             else
-                str = element.toString(exec);
+                str = element.toString(exec)->value(exec);
             strBuffer.append(str);
         }
     }
@@ -297,7 +297,7 @@ EncodedJSValue JSC_HOST_CALL arrayProtoFuncJoin(ExecState* exec)
 
     UString separator;
     if (!exec->argument(0).isUndefined())
-        separator = exec->argument(0).toString(exec);
+        separator = exec->argument(0).toString(exec)->value(exec);
 
     unsigned k = 0;
     if (isJSArray(thisObj)) {
@@ -308,7 +308,7 @@ EncodedJSValue JSC_HOST_CALL arrayProtoFuncJoin(ExecState* exec)
                 goto skipFirstLoop;
             JSValue element = array->getIndex(k);
             if (!element.isUndefinedOrNull())
-                strBuffer.append(element.toString(exec));
+                strBuffer.append(element.toString(exec)->value(exec));
             k++;
         }
 
@@ -319,7 +319,7 @@ EncodedJSValue JSC_HOST_CALL arrayProtoFuncJoin(ExecState* exec)
                 strBuffer.append(',');
                 JSValue element = array->getIndex(k);
                 if (!element.isUndefinedOrNull())
-                    strBuffer.append(element.toString(exec));
+                    strBuffer.append(element.toString(exec)->value(exec));
             }
         } else {
             for (; k < length; k++) {
@@ -328,7 +328,7 @@ EncodedJSValue JSC_HOST_CALL arrayProtoFuncJoin(ExecState* exec)
                 strBuffer.append(separator);
                 JSValue element = array->getIndex(k);
                 if (!element.isUndefinedOrNull())
-                    strBuffer.append(element.toString(exec));
+                    strBuffer.append(element.toString(exec)->value(exec));
             }
         }
     }
@@ -343,7 +343,7 @@ EncodedJSValue JSC_HOST_CALL arrayProtoFuncJoin(ExecState* exec)
 
         JSValue element = thisObj->get(exec, k);
         if (!element.isUndefinedOrNull())
-            strBuffer.append(element.toString(exec));
+            strBuffer.append(element.toString(exec)->value(exec));
     }
 
     return JSValue::encode(strBuffer.build(exec));
@@ -429,7 +429,7 @@ EncodedJSValue JSC_HOST_CALL arrayProtoFuncPush(ExecState* exec)
             thisObj->methodTable()->putByIndex(thisObj, exec, length + n, exec->argument(n));
         else {
             PutPropertySlot slot;
-            Identifier propertyName(exec, JSValue(static_cast<int64_t>(length) + static_cast<int64_t>(n)).toString(exec));
+            Identifier propertyName(exec, JSValue(static_cast<int64_t>(length) + static_cast<int64_t>(n)).toString(exec)->value(exec));
             thisObj->methodTable()->put(thisObj, exec, propertyName, exec->argument(n), slot);
         }
     }
index ab4de7d..86c4bd5 100644 (file)
@@ -76,7 +76,7 @@ inline bool opIn(ExecState* exec, JSValue propName, JSValue baseVal)
     if (propName.getUInt32(i))
         return baseObj->hasProperty(exec, i);
 
-    Identifier property(exec, propName.toString(exec));
+    Identifier property(exec, propName.toString(exec)->value(exec));
     if (exec->globalData().exception)
         return false;
     return baseObj->hasProperty(exec, property);
index 79c5181..3651722 100644 (file)
@@ -185,7 +185,7 @@ CallType DateConstructor::getCallData(JSCell*, CallData& callData)
 
 static EncodedJSValue JSC_HOST_CALL dateParse(ExecState* exec)
 {
-    return JSValue::encode(jsNumber(parseDate(exec, exec->argument(0).toString(exec))));
+    return JSValue::encode(jsNumber(parseDate(exec, exec->argument(0).toString(exec)->value(exec))));
 }
 
 static EncodedJSValue JSC_HOST_CALL dateNow(ExecState*)
index 96dea01..93261f6 100644 (file)
@@ -154,13 +154,13 @@ static JSCell* formatLocaleDate(ExecState* exec, DateInstance*, double timeInMil
     bool useCustomFormat = false;
     UString customFormatString;
 
-    UString arg0String = exec->argument(0).toString(exec);
+    UString arg0String = exec->argument(0).toString(exec)->value(exec);
     if (arg0String == "custom" && !exec->argument(1).isUndefined()) {
         useCustomFormat = true;
-        customFormatString = exec->argument(1).toString(exec);
+        customFormatString = exec->argument(1).toString(exec)->value(exec);
     } else if (format == LocaleDateAndTime && !exec->argument(1).isUndefined()) {
         dateStyle = styleFromArgString(arg0String, dateStyle);
-        timeStyle = styleFromArgString(exec->argument(1).toString(exec), timeStyle);
+        timeStyle = styleFromArgString(exec->argument(1).toString(exec)->value(exec), timeStyle);
     } else if (format != LocaleTime && !exec->argument(0).isUndefined())
         dateStyle = styleFromArgString(arg0String, dateStyle);
     else if (format != LocaleDate && !exec->argument(0).isUndefined())
index 888bfe8..d6fa32f 100644 (file)
@@ -42,14 +42,10 @@ namespace JSC {
             instance->finishCreation(globalData, message);
             return instance;
         }
+
         static ErrorInstance* create(ExecState* exec, Structure* structure, JSValue message)
         {
-            if (message.isUndefined()) {
-                ErrorInstance* instance = new (NotNull, allocateCell<ErrorInstance>(*exec->heap())) ErrorInstance(exec->globalData(), structure);
-                instance->finishCreation(exec->globalData(), UString());
-                return instance;
-            }
-            return create(exec->globalData(), structure, message.toString(exec));
+            return create(exec->globalData(), structure, message.isUndefined() ? UString() : message.toString(exec)->value(exec));
         }
 
         bool appendSourceToMessage() { return m_appendSourceToMessage; }
index e1a395c..7af2947 100644 (file)
@@ -101,7 +101,7 @@ EncodedJSValue JSC_HOST_CALL errorProtoFuncToString(ExecState* exec)
     if (name.isUndefined())
         nameString = "Error";
     else {
-        nameString = name.toString(exec);
+        nameString = name.toString(exec)->value(exec);
         if (exec->hadException())
             return JSValue::encode(jsUndefined());
     }
@@ -118,7 +118,7 @@ EncodedJSValue JSC_HOST_CALL errorProtoFuncToString(ExecState* exec)
     if (message.isUndefined())
         messageString = "";
     else {
-        messageString = message.toString(exec);
+        messageString = message.toString(exec)->value(exec);
         if (exec->hadException())
             return JSValue::encode(jsUndefined());
     }
index 05e971f..ce63ae9 100644 (file)
@@ -113,7 +113,7 @@ JSObject* createUndefinedVariableError(ExecState* exec, const Identifier& ident)
     
 JSObject* createInvalidParamError(ExecState* exec, const char* op, JSValue value)
 {
-    UString errorMessage = makeUString("'", value.toString(exec), "' is not a valid argument for '", op, "'");
+    UString errorMessage = makeUString("'", value.toString(exec)->value(exec), "' is not a valid argument for '", op, "'");
     JSObject* exception = createTypeError(exec, errorMessage);
     ASSERT(exception->isErrorInstance());
     static_cast<ErrorInstance*>(exception)->setAppendSourceToMessage();
@@ -122,7 +122,7 @@ JSObject* createInvalidParamError(ExecState* exec, const char* op, JSValue value
 
 JSObject* createNotAConstructorError(ExecState* exec, JSValue value)
 {
-    UString errorMessage = makeUString("'", value.toString(exec), "' is not a constructor");
+    UString errorMessage = makeUString("'", value.toString(exec)->value(exec), "' is not a constructor");
     JSObject* exception = createTypeError(exec, errorMessage);
     ASSERT(exception->isErrorInstance());
     static_cast<ErrorInstance*>(exception)->setAppendSourceToMessage();
@@ -131,7 +131,7 @@ JSObject* createNotAConstructorError(ExecState* exec, JSValue value)
 
 JSObject* createNotAFunctionError(ExecState* exec, JSValue value)
 {
-    UString errorMessage = makeUString("'", value.toString(exec), "' is not a function");
+    UString errorMessage = makeUString("'", value.toString(exec)->value(exec), "' is not a function");
     JSObject* exception = createTypeError(exec, errorMessage);
     ASSERT(exception->isErrorInstance());
     static_cast<ErrorInstance*>(exception)->setAppendSourceToMessage();
@@ -140,7 +140,7 @@ JSObject* createNotAFunctionError(ExecState* exec, JSValue value)
 
 JSObject* createNotAnObjectError(ExecState* exec, JSValue value)
 {
-    UString errorMessage = makeUString("'", value.toString(exec), "' is not an object");
+    UString errorMessage = makeUString("'", value.toString(exec)->value(exec), "' is not an object");
     JSObject* exception = createTypeError(exec, errorMessage);
     ASSERT(exception->isErrorInstance());
     static_cast<ErrorInstance*>(exception)->setAppendSourceToMessage();
index e08e58c..956b216 100644 (file)
@@ -96,17 +96,17 @@ JSObject* constructFunctionSkippingEvalEnabledCheck(ExecState* exec, JSGlobalObj
     if (args.isEmpty())
         program = "(function() { \n})";
     else if (args.size() == 1)
-        program = makeUString("(function() { ", args.at(0).toString(exec), "\n})");
+        program = makeUString("(function() { ", args.at(0).toString(exec)->value(exec), "\n})");
     else {
         UStringBuilder builder;
         builder.append("(function(");
-        builder.append(args.at(0).toString(exec));
+        builder.append(args.at(0).toString(exec)->value(exec));
         for (size_t i = 1; i < args.size() - 1; i++) {
             builder.append(",");
-            builder.append(args.at(i).toString(exec));
+            builder.append(args.at(i).toString(exec)->value(exec));
         }
         builder.append(") { ");
-        builder.append(args.at(args.size() - 1).toString(exec));
+        builder.append(args.at(args.size() - 1).toString(exec)->value(exec));
         builder.append("\n})");
         program = builder.toUString();
     }
index 049b7b9..266ddc2 100644 (file)
@@ -207,7 +207,7 @@ EncodedJSValue JSC_HOST_CALL functionProtoFuncBind(ExecState* exec)
             length = targetLength - numBoundArgs;
     }
 
-    Identifier name(exec, target.get(exec, exec->propertyNames().name).toString(exec));
+    Identifier name(exec, target.get(exec, exec->propertyNames().name).toString(exec)->value(exec));
 
     return JSValue::encode(JSBoundFunction::create(exec, globalObject, targetObject, exec->argument(0), boundArgs, length, name));
 }
index fa658a6..2afb6a0 100644 (file)
@@ -1448,7 +1448,7 @@ void JSArray::sort(ExecState* exec)
     // a toString call raises an exception.
 
     for (size_t i = 0; i < lengthNotIncludingUndefined; i++)
-        values[i].second = values[i].first.toString(exec);
+        values[i].second = values[i].first.toString(exec)->value(exec);
 
     if (exec->hadException()) {
         Heap::heap(this)->popTempSortVector(&values);
index 144e377..9dcd636 100644 (file)
@@ -145,13 +145,6 @@ double JSCell::toNumber(ExecState* exec) const
     return static_cast<const JSObject*>(this)->toNumber(exec);
 }
 
-UString JSCell::toString(ExecState* exec) const
-{
-    if (isString())
-        return static_cast<const JSString*>(this)->toString(exec);
-    return static_cast<const JSObject*>(this)->toString(exec);
-}
-
 JSObject* JSCell::toObject(ExecState* exec, JSGlobalObject* globalObject) const
 {
     if (isString())
index cf66ee9..a36bb7d 100644 (file)
@@ -96,7 +96,6 @@ namespace JSC {
         bool getPrimitiveNumber(ExecState*, double& number, JSValue&) const;
         bool toBoolean(ExecState*) const;
         JS_EXPORT_PRIVATE double toNumber(ExecState*) const;
-        JS_EXPORT_PRIVATE UString toString(ExecState*) const;
         JS_EXPORT_PRIVATE JSObject* toObject(ExecState*, JSGlobalObject*) const;
 
         static void visitChildren(JSCell*, SlotVisitor&);
index bf6b31e..b82ab62 100644 (file)
@@ -51,8 +51,7 @@ namespace JSC {
 
 static JSValue encode(ExecState* exec, const char* doNotEscape)
 {
-    UString str = exec->argument(0).toString(exec);
-    CString cstr = str.utf8(true);
+    CString cstr = exec->argument(0).toString(exec)->value(exec).utf8(true);
     if (!cstr.data())
         return throwError(exec, createURIError(exec, "String contained an illegal UTF-16 sequence."));
 
@@ -143,7 +142,7 @@ static JSValue decode(ExecState* exec, const CharType* characters, int length, c
 static JSValue decode(ExecState* exec, const char* doNotUnescape, bool strict)
 {
     JSStringBuilder builder;
-    UString str = exec->argument(0).toString(exec);
+    UString str = exec->argument(0).toString(exec)->value(exec);
     
     if (str.is8Bit())
         return decode(exec, str.characters8(), str.length(), doNotUnescape, strict);
@@ -513,7 +512,7 @@ EncodedJSValue JSC_HOST_CALL globalFuncEval(ExecState* exec)
     if (!x.isString())
         return JSValue::encode(x);
 
-    UString s = x.toString(exec);
+    UString s = x.toString(exec)->value(exec);
 
     if (s.is8Bit()) {
         LiteralParser<LChar> preparser(exec, s.characters8(), s.length(), NonStrictJSON);
@@ -556,7 +555,7 @@ EncodedJSValue JSC_HOST_CALL globalFuncParseInt(ExecState* exec)
     }
 
     // If ToString throws, we shouldn't call ToInt32.
-    UString s = value.toString(exec);
+    UString s = value.toString(exec)->value(exec);
     if (exec->hadException())
         return JSValue::encode(jsUndefined());
 
@@ -565,7 +564,7 @@ EncodedJSValue JSC_HOST_CALL globalFuncParseInt(ExecState* exec)
 
 EncodedJSValue JSC_HOST_CALL globalFuncParseFloat(ExecState* exec)
 {
-    return JSValue::encode(jsNumber(parseFloat(exec->argument(0).toString(exec))));
+    return JSValue::encode(jsNumber(parseFloat(exec->argument(0).toString(exec)->value(exec))));
 }
 
 EncodedJSValue JSC_HOST_CALL globalFuncIsNaN(ExecState* exec)
@@ -623,7 +622,7 @@ EncodedJSValue JSC_HOST_CALL globalFuncEscape(ExecState* exec)
         "*+-./@_";
 
     JSStringBuilder builder;
-    UString str = exec->argument(0).toString(exec);
+    UString str = exec->argument(0).toString(exec)->value(exec);
     if (str.is8Bit()) {
         const LChar* c = str.characters8();
         for (unsigned k = 0; k < str.length(); k++, c++) {
@@ -662,7 +661,7 @@ EncodedJSValue JSC_HOST_CALL globalFuncEscape(ExecState* exec)
 EncodedJSValue JSC_HOST_CALL globalFuncUnescape(ExecState* exec)
 {
     UStringBuilder builder;
-    UString str = exec->argument(0).toString(exec);
+    UString str = exec->argument(0).toString(exec)->value(exec);
     int k = 0;
     int len = str.length();
     
index 05c6c29..83b1184 100644 (file)
@@ -142,7 +142,7 @@ static inline JSValue unwrapBoxedPrimitive(ExecState* exec, JSValue value)
     if (object->inherits(&NumberObject::s_info))
         return jsNumber(object->toNumber(exec));
     if (object->inherits(&StringObject::s_info))
-        return jsString(exec, object->toString(exec));
+        return object->toString(exec);
     if (object->inherits(&BooleanObject::s_info))
         return object->toPrimitive(exec);
     return value;
@@ -223,25 +223,12 @@ Stringifier::Stringifier(ExecState* exec, const Local<Unknown>& replacer, const
             if (exec->hadException())
                 break;
 
-            UString propertyName;
-            if (name.getString(exec, propertyName)) {
-                m_arrayReplacerPropertyNames.add(Identifier(exec, propertyName));
-                continue;
-            }
-
-            if (name.isNumber()) {
-                m_arrayReplacerPropertyNames.add(Identifier::from(exec, name.asNumber()));
-                continue;
-            }
-
             if (name.isObject()) {
                 if (!asObject(name)->inherits(&NumberObject::s_info) && !asObject(name)->inherits(&StringObject::s_info))
                     continue;
-                propertyName = name.toString(exec);
-                if (exec->hadException())
-                    break;
-                m_arrayReplacerPropertyNames.add(Identifier(exec, propertyName));
             }
+
+            m_arrayReplacerPropertyNames.add(Identifier(exec, name.toString(exec)->value(exec)));
         }
         return;
     }
@@ -825,8 +812,7 @@ EncodedJSValue JSC_HOST_CALL JSONProtoFuncParse(ExecState* exec)
 {
     if (!exec->argumentCount())
         return throwVMError(exec, createError(exec, "JSON.parse requires at least one parameter"));
-    JSValue value = exec->argument(0);
-    UString source = value.toString(exec);
+    UString source = exec->argument(0).toString(exec)->value(exec);
     if (exec->hadException())
         return JSValue::encode(jsNull());
 
index 653ddf0..060fcff 100644 (file)
@@ -518,11 +518,11 @@ double JSObject::toNumber(ExecState* exec) const
     return primitive.toNumber(exec);
 }
 
-UString JSObject::toString(ExecState* exec) const
+JSString* JSObject::toString(ExecState* exec) const
 {
     JSValue primitive = toPrimitive(exec, PreferString);
     if (exec->hadException())
-        return "";
+        return jsEmptyString(exec);
     return primitive.toString(exec);
 }
 
index 6d45e82..7774920 100644 (file)
@@ -141,7 +141,7 @@ namespace JSC {
         JS_EXPORT_PRIVATE bool toBoolean(ExecState*) const;
         bool getPrimitiveNumber(ExecState*, double& number, JSValue&) const;
         JS_EXPORT_PRIVATE double toNumber(ExecState*) const;
-        JS_EXPORT_PRIVATE UString toString(ExecState*) const;
+        JS_EXPORT_PRIVATE JSString* toString(ExecState*) const;
 
         // NOTE: JSObject and its subclasses must be able to gracefully handle ExecState* = 0,
         // because this call may come from inside the compiler.
index 93193b5..4e98f9d 100644 (file)
@@ -229,11 +229,6 @@ double JSString::toNumber(ExecState* exec) const
     return jsToNumber(value(exec));
 }
 
-UString JSString::toString(ExecState* exec) const
-{
-    return value(exec);
-}
-
 inline StringObject* StringObject::create(ExecState* exec, JSGlobalObject* globalObject, JSString* string)
 {
     StringObject* object = new (NotNull, allocateCell<StringObject>(*exec->heap())) StringObject(exec->globalData(), globalObject->stringObjectStructure());
index 7ca90de..c0637a6 100644 (file)
@@ -217,7 +217,6 @@ namespace JSC {
         JS_EXPORT_PRIVATE bool toBoolean(ExecState*) const;
         bool getPrimitiveNumber(ExecState*, double& number, JSValue&) const;
         JSObject* toObject(ExecState*, JSGlobalObject*) const;
-        UString toString(ExecState*) const;
         double toNumber(ExecState*) const;
         
         bool getStringPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
@@ -453,24 +452,11 @@ namespace JSC {
         return isTrue(); // false, null, and undefined all convert to false.
     }
 
-    inline UString JSValue::toString(ExecState* exec) const
+    inline JSString* JSValue::toString(ExecState* exec) const
     {
         if (isString())
-            return static_cast<JSString*>(asCell())->value(exec);
-        if (isInt32())
-            return exec->globalData().numericStrings.add(asInt32());
-        if (isDouble())
-            return exec->globalData().numericStrings.add(asDouble());
-        if (isTrue())
-            return "true";
-        if (isFalse())
-            return "false";
-        if (isNull())
-            return "null";
-        if (isUndefined())
-            return "undefined";
-        ASSERT(isCell());
-        return asCell()->toString(exec);
+            return static_cast<JSString*>(asCell());
+        return toStringSlowCase(exec);
     }
 
 } // namespace JSC
index a5d3d93..6b803c3 100644 (file)
@@ -204,10 +204,9 @@ bool JSValue::isValidCallee()
     return asObject(asCell())->globalObject();
 }
 
-JSString* JSValue::toPrimitiveString(ExecState* exec) const
+JSString* JSValue::toStringSlowCase(ExecState* exec) const
 {
-    if (isString())
-        return static_cast<JSString*>(asCell());
+    ASSERT(!isString());
     if (isInt32())
         return jsString(&exec->globalData(), exec->globalData().numericStrings.add(asInt32()));
     if (isDouble())
@@ -222,10 +221,11 @@ JSString* JSValue::toPrimitiveString(ExecState* exec) const
         return jsNontrivialString(exec, exec->propertyNames().undefined.ustring());
 
     ASSERT(isCell());
-    JSValue v = asCell()->toPrimitive(exec, NoPreference);
-    if (v.isString())
-        return static_cast<JSString*>(v.asCell());
-    return jsString(&exec->globalData(), v.toString(exec));
+    JSValue value = asCell()->toPrimitive(exec, PreferString);
+    if (exec->hadException())
+        return jsEmptyString(exec);
+    ASSERT(!value.isObject());
+    return value.toString(exec);
 }
 
 } // namespace JSC
index de5e181..e3415eb 100644 (file)
@@ -197,8 +197,7 @@ namespace JSC {
         // toNumber conversion is expected to be side effect free if an exception has
         // been set in the ExecState already.
         double toNumber(ExecState*) const;
-        UString toString(ExecState*) const;
-        JSString* toPrimitiveString(ExecState*) const;
+        JSString* toString(ExecState*) const;
         JSObject* toObject(ExecState*) const;
         JSObject* toObject(ExecState*, JSGlobalObject*) const;
 
@@ -245,6 +244,7 @@ namespace JSC {
 
         inline const JSValue asValue() const { return *this; }
         JS_EXPORT_PRIVATE double toNumberSlowCase(ExecState*) const;
+        JSString* toStringSlowCase(ExecState*) const;
         JS_EXPORT_PRIVATE JSObject* toObjectSlowCase(ExecState*, JSGlobalObject*) const;
         JS_EXPORT_PRIVATE JSObject* toThisObjectSlowCase(ExecState*) const;
 
index 4612b56..fb90bcd 100644 (file)
@@ -447,7 +447,7 @@ EncodedJSValue JSC_HOST_CALL numberProtoFuncToString(ExecState* exec)
         radix = static_cast<int>(radixValue.toInteger(exec)); // nan -> 0
 
     if (radix == 10)
-        return JSValue::encode(jsString(exec, jsNumber(x).toString(exec)));
+        return JSValue::encode(jsNumber(x).toString(exec));
 
     // Fast path for number to character conversion.
     if (radix == 36) {
@@ -474,7 +474,7 @@ EncodedJSValue JSC_HOST_CALL numberProtoFuncToLocaleString(ExecState* exec)
     if (!toThisNumber(exec->hostThisValue(), x))
         return throwVMTypeError(exec);
 
-    return JSValue::encode(jsString(exec, jsNumber(x).toString(exec)));
+    return JSValue::encode(jsNumber(x).toString(exec));
 }
 
 EncodedJSValue JSC_HOST_CALL numberProtoFuncValueOf(ExecState* exec)
index abcff8c..d96c1de 100644 (file)
@@ -149,7 +149,7 @@ EncodedJSValue JSC_HOST_CALL objectConstructorGetOwnPropertyDescriptor(ExecState
 {
     if (!exec->argument(0).isObject())
         return throwVMError(exec, createTypeError(exec, "Requested property descriptor of a value that is not an object."));
-    UString propertyName = exec->argument(1).toString(exec);
+    UString propertyName = exec->argument(1).toString(exec)->value(exec);
     if (exec->hadException())
         return JSValue::encode(jsNull());
     JSObject* object = asObject(exec->argument(0));
@@ -292,7 +292,7 @@ EncodedJSValue JSC_HOST_CALL objectConstructorDefineProperty(ExecState* exec)
     if (!exec->argument(0).isObject())
         return throwVMError(exec, createTypeError(exec, "Properties can only be defined on Objects."));
     JSObject* O = asObject(exec->argument(0));
-    UString propertyName = exec->argument(1).toString(exec);
+    UString propertyName = exec->argument(1).toString(exec)->value(exec);
     if (exec->hadException())
         return JSValue::encode(jsNull());
     PropertyDescriptor descriptor;
index 3f4dc19..7ca7dae 100644 (file)
@@ -118,7 +118,7 @@ EncodedJSValue JSC_HOST_CALL objectProtoFuncValueOf(ExecState* exec)
 EncodedJSValue JSC_HOST_CALL objectProtoFuncHasOwnProperty(ExecState* exec)
 {
     JSValue thisValue = exec->hostThisValue();
-    return JSValue::encode(jsBoolean(thisValue.toObject(exec)->hasOwnProperty(exec, Identifier(exec, exec->argument(0).toString(exec)))));
+    return JSValue::encode(jsBoolean(thisValue.toObject(exec)->hasOwnProperty(exec, Identifier(exec, exec->argument(0).toString(exec)->value(exec)))));
 }
 
 EncodedJSValue JSC_HOST_CALL objectProtoFuncIsPrototypeOf(ExecState* exec)
@@ -149,7 +149,7 @@ EncodedJSValue JSC_HOST_CALL objectProtoFuncDefineGetter(ExecState* exec)
     CallData callData;
     if (getCallData(exec->argument(1), callData) == CallTypeNone)
         return throwVMError(exec, createSyntaxError(exec, "invalid getter usage"));
-    thisObject->methodTable()->defineGetter(thisObject, exec, Identifier(exec, exec->argument(0).toString(exec)), asObject(exec->argument(1)), 0);
+    thisObject->methodTable()->defineGetter(thisObject, exec, Identifier(exec, exec->argument(0).toString(exec)->value(exec)), asObject(exec->argument(1)), 0);
     return JSValue::encode(jsUndefined());
 }
 
@@ -162,7 +162,7 @@ EncodedJSValue JSC_HOST_CALL objectProtoFuncDefineSetter(ExecState* exec)
     CallData callData;
     if (getCallData(exec->argument(1), callData) == CallTypeNone)
         return throwVMError(exec, createSyntaxError(exec, "invalid setter usage"));
-    thisObject->methodTable()->defineSetter(thisObject, exec, Identifier(exec, exec->argument(0).toString(exec)), asObject(exec->argument(1)), 0);
+    thisObject->methodTable()->defineSetter(thisObject, exec, Identifier(exec, exec->argument(0).toString(exec)->value(exec)), asObject(exec->argument(1)), 0);
     return JSValue::encode(jsUndefined());
 }
 
@@ -172,7 +172,7 @@ EncodedJSValue JSC_HOST_CALL objectProtoFuncLookupGetter(ExecState* exec)
     if (exec->hadException())
         return JSValue::encode(jsUndefined());
 
-    return JSValue::encode(thisObject->lookupGetter(exec, Identifier(exec, exec->argument(0).toString(exec))));
+    return JSValue::encode(thisObject->lookupGetter(exec, Identifier(exec, exec->argument(0).toString(exec)->value(exec))));
 }
 
 EncodedJSValue JSC_HOST_CALL objectProtoFuncLookupSetter(ExecState* exec)
@@ -181,13 +181,13 @@ EncodedJSValue JSC_HOST_CALL objectProtoFuncLookupSetter(ExecState* exec)
     if (exec->hadException())
         return JSValue::encode(jsUndefined());
 
-    return JSValue::encode(thisObject->lookupSetter(exec, Identifier(exec, exec->argument(0).toString(exec))));
+    return JSValue::encode(thisObject->lookupSetter(exec, Identifier(exec, exec->argument(0).toString(exec)->value(exec))));
 }
 
 EncodedJSValue JSC_HOST_CALL objectProtoFuncPropertyIsEnumerable(ExecState* exec)
 {
     JSValue thisValue = exec->hostThisValue();
-    return JSValue::encode(jsBoolean(thisValue.toObject(exec)->propertyIsEnumerable(exec, Identifier(exec, exec->argument(0).toString(exec)))));
+    return JSValue::encode(jsBoolean(thisValue.toObject(exec)->propertyIsEnumerable(exec, Identifier(exec, exec->argument(0).toString(exec)->value(exec)))));
 }
 
 // 15.2.4.3 Object.prototype.toLocaleString()
index b89746f..459feb4 100644 (file)
@@ -47,13 +47,11 @@ NEVER_INLINE JSValue jsAddSlowCase(CallFrame* callFrame, JSValue v1, JSValue v2)
     JSValue p1 = v1.toPrimitive(callFrame);
     JSValue p2 = v2.toPrimitive(callFrame);
 
-    if (p1.isString()) {
-        return p2.isString()
-            ? jsString(callFrame, asString(p1), asString(p2))
-            : jsString(callFrame, asString(p1), jsString(callFrame, p2.toString(callFrame)));
-    }
+    if (p1.isString())
+        return jsString(callFrame, asString(p1), p2.toString(callFrame));
+
     if (p2.isString())
-        return jsString(callFrame, jsString(callFrame, p1.toString(callFrame)), asString(p2));
+        return jsString(callFrame, p1.toString(callFrame), asString(p2));
 
     return jsNumber(p1.toNumber(callFrame) + p2.toNumber(callFrame));
 }
index ca2174f..9452838 100644 (file)
@@ -81,10 +81,7 @@ namespace JSC {
 
         for (unsigned i = 0; i < count; ++i) {
             JSValue v = strings[i].jsValue();
-            if (v.isString())
-                ropeBuilder.append(asString(v));
-            else
-                ropeBuilder.append(jsString(globalData, v.toString(exec)));
+            ropeBuilder.append(v.toString(exec));
 
             if (ropeBuilder.length() < oldLength) // True for overflow
                 return throwOutOfMemoryError(exec);
@@ -97,20 +94,13 @@ namespace JSC {
     {
         JSGlobalData* globalData = &exec->globalData();
         JSString::RopeBuilder ropeBuilder(*globalData);
-
-        if (thisValue.isString())
-            ropeBuilder.append(asString(thisValue));
-        else
-            ropeBuilder.append(jsString(globalData, thisValue.toString(exec)));
+        ropeBuilder.append(thisValue.toString(exec));
 
         unsigned oldLength = 0;
 
         for (unsigned i = 0; i < exec->argumentCount(); ++i) {
             JSValue v = exec->argument(i);
-            if (v.isString())
-                ropeBuilder.append(asString(v));
-            else
-                ropeBuilder.append(jsString(globalData, v.toString(exec)));
+            ropeBuilder.append(v.toString(exec));
 
             if (ropeBuilder.length() < oldLength) // True for overflow
                 return throwOutOfMemoryError(exec);
@@ -300,11 +290,8 @@ namespace JSC {
         if (v1.isNumber() && v2.isNumber())
             return jsNumber(v1.asNumber() + v2.asNumber());
         
-        if (v1.isString()) {
-            return v2.isString()
-                ? jsString(callFrame, asString(v1), asString(v2))
-                : jsString(callFrame, asString(v1), v2.toPrimitiveString(callFrame));
-        }
+        if (v1.isString() && !v2.isObject())
+            return jsString(callFrame, asString(v1), v2.toString(callFrame));
 
         // All other cases are pretty uncommon
         return jsAddSlowCase(callFrame, v1, v2);
index c0a71de..53e880e 100644 (file)
@@ -298,7 +298,7 @@ void RegExpConstructor::put(JSCell* cell, ExecState* exec, const Identifier& pro
 
 void setRegExpConstructorInput(ExecState* exec, JSObject* baseObject, JSValue value)
 {
-    asRegExpConstructor(baseObject)->setInput(value.toString(exec));
+    asRegExpConstructor(baseObject)->setInput(value.toString(exec)->value(exec));
 }
 
 void setRegExpConstructorMultiline(ExecState* exec, JSObject* baseObject, JSValue value)
@@ -323,13 +323,13 @@ JSObject* constructRegExp(ExecState* exec, JSGlobalObject* globalObject, const A
         return asObject(arg0);
     }
 
-    UString pattern = arg0.isUndefined() ? UString("") : arg0.toString(exec);
+    UString pattern = arg0.isUndefined() ? UString("") : arg0.toString(exec)->value(exec);
     if (exec->hadException())
         return 0;
 
     RegExpFlags flags = NoFlags;
     if (!arg1.isUndefined()) {
-        flags = regExpFlags(arg1.toString(exec));
+        flags = regExpFlags(arg1.toString(exec)->value(exec));
         if (exec->hadException())
             return 0;
         if (flags == InvalidFlags)
index 4553f7a..4c192ff 100644 (file)
@@ -231,7 +231,7 @@ JSValue RegExpObject::exec(ExecState* exec)
 bool RegExpObject::match(ExecState* exec)
 {
     RegExpConstructor* regExpConstructor = exec->lexicalGlobalObject()->regExpConstructor();
-    UString input = exec->argument(0).toString(exec);
+    UString input = exec->argument(0).toString(exec)->value(exec);
     JSGlobalData* globalData = &exec->globalData();
     if (!regExp()->global()) {
         int position;
index 6c79f94..9074e97 100644 (file)
@@ -110,13 +110,13 @@ EncodedJSValue JSC_HOST_CALL regExpProtoFuncCompile(ExecState* exec)
             return throwVMError(exec, createTypeError(exec, "Cannot supply flags when constructing one RegExp from another."));
         regExp = asRegExpObject(arg0)->regExp();
     } else {
-        UString pattern = !exec->argumentCount() ? UString("") : arg0.toString(exec);
+        UString pattern = !exec->argumentCount() ? UString("") : arg0.toString(exec)->value(exec);
         if (exec->hadException())
             return JSValue::encode(jsUndefined());
 
         RegExpFlags flags = NoFlags;
         if (!arg1.isUndefined()) {
-            flags = regExpFlags(arg1.toString(exec));
+            flags = regExpFlags(arg1.toString(exec)->value(exec));
             if (exec->hadException())
                 return JSValue::encode(jsUndefined());
             if (flags == InvalidFlags)
@@ -153,7 +153,7 @@ EncodedJSValue JSC_HOST_CALL regExpProtoFuncToString(ExecState* exec)
         postfix[index++] = 'i';
     if (thisObject->get(exec, exec->propertyNames().multiline).toBoolean(exec))
         postfix[index] = 'm';
-    UString source = thisObject->get(exec, exec->propertyNames().source).toString(exec);
+    UString source = thisObject->get(exec, exec->propertyNames().source).toString(exec)->value(exec);
     // If source is empty, use "/(?:)/" to avoid colliding with comment syntax
     return JSValue::encode(jsMakeNontrivialString(exec, "/", source.length() ? source : UString("(?:)"), postfix));
 }
index d2f75a0..e03a87f 100644 (file)
@@ -95,10 +95,7 @@ static EncodedJSValue JSC_HOST_CALL constructWithStringConstructor(ExecState* ex
     if (!exec->argumentCount())
         return JSValue::encode(StringObject::create(exec, globalObject->stringObjectStructure()));
     
-    JSString* string = exec->argument(0).isString()
-        ? asString(exec->argument(0))
-        : jsString(exec, exec->argument(0).toString(exec));
-    return JSValue::encode(StringObject::create(exec, globalObject->stringObjectStructure(), string));
+    return JSValue::encode(StringObject::create(exec, globalObject->stringObjectStructure(), exec->argument(0).toString(exec)));
 }
 
 ConstructType StringConstructor::getConstructData(JSCell*, ConstructData& constructData)
@@ -111,7 +108,7 @@ static EncodedJSValue JSC_HOST_CALL callStringConstructor(ExecState* exec)
 {
     if (!exec->argumentCount())
         return JSValue::encode(jsEmptyString(exec));
-    return JSValue::encode(jsString(exec, exec->argument(0).toString(exec)));
+    return JSValue::encode(exec->argument(0).toString(exec));
 }
 
 CallType StringConstructor::getCallData(JSCell*, CallData& callData)
index 9dd4f81..00f1ceb 100644 (file)
@@ -445,7 +445,7 @@ static NEVER_INLINE EncodedJSValue replaceUsingRegExpSearch(ExecState* exec, JSS
     CallData callData;
     CallType callType = getCallData(replaceValue, callData);
     if (callType == CallTypeNone)
-        replacementString = replaceValue.toString(exec);
+        replacementString = replaceValue.toString(exec)->value(exec);
 
     const UString& source = string->value(exec);
     unsigned sourceLen = source.length();
@@ -502,10 +502,7 @@ static NEVER_INLINE EncodedJSValue replaceUsingRegExpSearch(ExecState* exec, JSS
 
                 cachedCall.setThis(jsUndefined());
                 JSValue result = cachedCall.call();
-                if (LIKELY(result.isString()))
-                    replacements.append(asString(result)->value(exec));
-                else
-                    replacements.append(result.toString(cachedCall.newCallFrame(exec)));
+                replacements.append(result.toString(cachedCall.newCallFrame(exec))->value(exec));
                 if (exec->hadException())
                     break;
 
@@ -547,10 +544,7 @@ static NEVER_INLINE EncodedJSValue replaceUsingRegExpSearch(ExecState* exec, JSS
 
                 cachedCall.setThis(jsUndefined());
                 JSValue result = cachedCall.call();
-                if (LIKELY(result.isString()))
-                    replacements.append(asString(result)->value(exec));
-                else
-                    replacements.append(result.toString(cachedCall.newCallFrame(exec)));
+                replacements.append(result.toString(cachedCall.newCallFrame(exec))->value(exec));
                 if (exec->hadException())
                     break;
 
@@ -594,7 +588,7 @@ static NEVER_INLINE EncodedJSValue replaceUsingRegExpSearch(ExecState* exec, JSS
                 args.append(jsNumber(completeMatchStart));
                 args.append(string);
 
-                replacements.append(call(exec, replaceValue, callType, callData, jsUndefined(), args).toString(exec));
+                replacements.append(call(exec, replaceValue, callType, callData, jsUndefined(), args).toString(exec)->value(exec));
                 if (exec->hadException())
                     break;
             } else {
@@ -633,7 +627,7 @@ static NEVER_INLINE EncodedJSValue replaceUsingRegExpSearch(ExecState* exec, JSS
 static NEVER_INLINE EncodedJSValue replaceUsingStringSearch(ExecState* exec, JSString* jsString, JSValue searchValue, JSValue replaceValue)
 {
     const UString& string = jsString->value(exec);
-    UString searchString = searchValue.toString(exec);
+    UString searchString = searchValue.toString(exec)->value(exec);
     if (exec->hadException())
         return JSValue::encode(jsUndefined());
 
@@ -653,7 +647,7 @@ static NEVER_INLINE EncodedJSValue replaceUsingStringSearch(ExecState* exec, JSS
             return JSValue::encode(jsUndefined());
     }
 
-    UString replaceString = replaceValue.toString(exec);
+    UString replaceString = replaceValue.toString(exec)->value(exec);
     if (exec->hadException())
         return JSValue::encode(jsUndefined());
 
@@ -665,12 +659,9 @@ static NEVER_INLINE EncodedJSValue replaceUsingStringSearch(ExecState* exec, JSS
 EncodedJSValue JSC_HOST_CALL stringProtoFuncReplace(ExecState* exec)
 {
     JSValue thisValue = exec->hostThisValue();
-    if (!thisValue.isString()) {
-        if (thisValue.isUndefinedOrNull()) // CheckObjectCoercible
-            return throwVMTypeError(exec);
-        thisValue = jsString(exec, thisValue.toString(exec));
-    }
-    JSString* string = asString(thisValue);
+    if (thisValue.isUndefinedOrNull()) // CheckObjectCoercible
+        return throwVMTypeError(exec);
+    JSString* string = thisValue.toString(exec);
     JSValue searchValue = exec->argument(0);
     JSValue replaceValue = exec->argument(1);
 
@@ -698,7 +689,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncCharAt(ExecState* exec)
     JSValue thisValue = exec->hostThisValue();
     if (thisValue.isUndefinedOrNull()) // CheckObjectCoercible
         return throwVMTypeError(exec);
-    UString s = thisValue.toString(exec);
+    UString s = thisValue.toString(exec)->value(exec);
     unsigned len = s.length();
     JSValue a0 = exec->argument(0);
     if (a0.isUInt32()) {
@@ -718,7 +709,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncCharCodeAt(ExecState* exec)
     JSValue thisValue = exec->hostThisValue();
     if (thisValue.isUndefinedOrNull()) // CheckObjectCoercible
         return throwVMTypeError(exec);
-    UString s = thisValue.toString(exec);
+    UString s = thisValue.toString(exec)->value(exec);
     unsigned len = s.length();
     JSValue a0 = exec->argument(0);
     if (a0.isUInt32()) {
@@ -739,12 +730,9 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncCharCodeAt(ExecState* exec)
 EncodedJSValue JSC_HOST_CALL stringProtoFuncConcat(ExecState* exec)
 {
     JSValue thisValue = exec->hostThisValue();
-    if (thisValue.isString() && (exec->argumentCount() == 1)) {
-        JSValue v = exec->argument(0);
-        return JSValue::encode(v.isString()
-            ? jsString(exec, asString(thisValue), asString(v))
-            : jsString(exec, asString(thisValue), jsString(&exec->globalData(), v.toString(exec))));
-    }
+    if (thisValue.isString() && (exec->argumentCount() == 1))
+        return JSValue::encode(jsString(exec, asString(thisValue), exec->argument(0).toString(exec)));
+
     if (thisValue.isUndefinedOrNull()) // CheckObjectCoercible
         return throwVMTypeError(exec);
     return JSValue::encode(jsStringFromArguments(exec, thisValue));
@@ -755,12 +743,12 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncIndexOf(ExecState* exec)
     JSValue thisValue = exec->hostThisValue();
     if (thisValue.isUndefinedOrNull()) // CheckObjectCoercible
         return throwVMTypeError(exec);
-    UString s = thisValue.toString(exec);
+    UString s = thisValue.toString(exec)->value(exec);
     int len = s.length();
 
     JSValue a0 = exec->argument(0);
     JSValue a1 = exec->argument(1);
-    UString u2 = a0.toString(exec);
+    UString u2 = a0.toString(exec)->value(exec);
     int pos;
     if (a1.isUndefined())
         pos = 0;
@@ -786,13 +774,13 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncLastIndexOf(ExecState* exec)
     JSValue thisValue = exec->hostThisValue();
     if (thisValue.isUndefinedOrNull()) // CheckObjectCoercible
         return throwVMTypeError(exec);
-    UString s = thisValue.toString(exec);
+    UString s = thisValue.toString(exec)->value(exec);
     int len = s.length();
 
     JSValue a0 = exec->argument(0);
     JSValue a1 = exec->argument(1);
 
-    UString u2 = a0.toString(exec);
+    UString u2 = a0.toString(exec)->value(exec);
     double dpos = a1.toIntegerPreserveNaN(exec);
     if (dpos < 0)
         dpos = 0;
@@ -810,7 +798,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncMatch(ExecState* exec)
     JSValue thisValue = exec->hostThisValue();
     if (thisValue.isUndefinedOrNull()) // CheckObjectCoercible
         return throwVMTypeError(exec);
-    UString s = thisValue.toString(exec);
+    UString s = thisValue.toString(exec)->value(exec);
     JSGlobalData* globalData = &exec->globalData();
 
     JSValue a0 = exec->argument(0);
@@ -825,7 +813,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncMatch(ExecState* exec)
          *  replaced with the result of the expression new RegExp(regexp).
          *  Per ECMA 15.10.4.1, if a0 is undefined substitute the empty string.
          */
-        reg = RegExp::create(exec->globalData(), a0.isUndefined() ? UString("") : a0.toString(exec), NoFlags);
+        reg = RegExp::create(exec->globalData(), a0.isUndefined() ? UString("") : a0.toString(exec)->value(exec), NoFlags);
         if (!reg->isValid())
             return throwVMError(exec, createSyntaxError(exec, reg->errorMessage()));
     }
@@ -862,7 +850,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncSearch(ExecState* exec)
     JSValue thisValue = exec->hostThisValue();
     if (thisValue.isUndefinedOrNull()) // CheckObjectCoercible
         return throwVMTypeError(exec);
-    UString s = thisValue.toString(exec);
+    UString s = thisValue.toString(exec)->value(exec);
     JSGlobalData* globalData = &exec->globalData();
 
     JSValue a0 = exec->argument(0);
@@ -877,7 +865,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncSearch(ExecState* exec)
          *  replaced with the result of the expression new RegExp(regexp).
          *  Per ECMA 15.10.4.1, if a0 is undefined substitute the empty string.
          */
-        reg = RegExp::create(exec->globalData(), a0.isUndefined() ? UString("") : a0.toString(exec), NoFlags);
+        reg = RegExp::create(exec->globalData(), a0.isUndefined() ? UString("") : a0.toString(exec)->value(exec), NoFlags);
         if (!reg->isValid())
             return throwVMError(exec, createSyntaxError(exec, reg->errorMessage()));
     }
@@ -893,7 +881,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncSlice(ExecState* exec)
     JSValue thisValue = exec->hostThisValue();
     if (thisValue.isUndefinedOrNull()) // CheckObjectCoercible
         return throwVMTypeError(exec);
-    UString s = thisValue.toString(exec);
+    UString s = thisValue.toString(exec)->value(exec);
     int len = s.length();
 
     JSValue a0 = exec->argument(0);
@@ -925,7 +913,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncSplit(ExecState* exec)
 
     // 2. Let S be the result of calling ToString, giving it the this value as its argument.
     // 6. Let s be the number of characters in S.
-    UString input = thisValue.toString(exec);
+    UString input = thisValue.toString(exec)->value(exec);
 
     // 3. Let A be a new array created as if by the expression new Array()
     //    where Array is the standard built-in constructor with that name.
@@ -1027,7 +1015,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncSplit(ExecState* exec)
             }
         }
     } else {
-        UString separator = separatorValue.toString(exec);
+        UString separator = separatorValue.toString(exec)->value(exec);
 
         // 9. If lim == 0, return A.
         if (!limit)
@@ -1114,7 +1102,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncSubstr(ExecState* exec)
         // CheckObjectCoercible
         return throwVMTypeError(exec);
     } else {
-        uString = thisValue.toString(exec);
+        uString = thisValue.toString(exec)->value(exec);
         if (exec->hadException())
             return JSValue::encode(jsUndefined());
         len = uString.length();
@@ -1144,24 +1132,16 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncSubstr(ExecState* exec)
 EncodedJSValue JSC_HOST_CALL stringProtoFuncSubstring(ExecState* exec)
 {
     JSValue thisValue = exec->hostThisValue();
-    int len;
-    JSString* jsString = 0;
-    UString uString;
-    if (thisValue.isString()) {
-        jsString = static_cast<JSString*>(thisValue.asCell());
-        len = jsString->length();
-    } else if (thisValue.isUndefinedOrNull()) {
-        // CheckObjectCoercible
+    if (thisValue.isUndefinedOrNull()) // CheckObjectCoercible
         return throwVMTypeError(exec);
-    } else {
-        uString = thisValue.toString(exec);
-        if (exec->hadException())
-            return JSValue::encode(jsUndefined());
-        len = uString.length();
-    }
+
+    JSString* jsString = thisValue.toString(exec);
+    if (exec->hadException())
+        return JSValue::encode(jsUndefined());
 
     JSValue a0 = exec->argument(0);
     JSValue a1 = exec->argument(1);
+    int len = jsString->length();
 
     double start = a0.toNumber(exec);
     double end;
@@ -1185,9 +1165,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncSubstring(ExecState* exec)
     }
     unsigned substringStart = static_cast<unsigned>(start);
     unsigned substringLength = static_cast<unsigned>(end) - substringStart;
-    if (jsString)
-        return JSValue::encode(jsSubstring(exec, jsString, substringStart, substringLength));
-    return JSValue::encode(jsSubstring(exec, uString, substringStart, substringLength));
+    return JSValue::encode(jsSubstring(exec, jsString, substringStart, substringLength));
 }
 
 EncodedJSValue JSC_HOST_CALL stringProtoFuncToLowerCase(ExecState* exec)
@@ -1195,7 +1173,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncToLowerCase(ExecState* exec)
     JSValue thisValue = exec->hostThisValue();
     if (thisValue.isUndefinedOrNull()) // CheckObjectCoercible
         return throwVMTypeError(exec);
-    JSString* sVal = thisValue.isString() ? asString(thisValue) : jsString(exec, thisValue.toString(exec));
+    JSString* sVal = thisValue.toString(exec);
     const UString& s = sVal->value(exec);
 
     int sSize = s.length();
@@ -1214,7 +1192,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncToUpperCase(ExecState* exec)
     JSValue thisValue = exec->hostThisValue();
     if (thisValue.isUndefinedOrNull()) // CheckObjectCoercible
         return throwVMTypeError(exec);
-    JSString* sVal = thisValue.isString() ? asString(thisValue) : jsString(exec, thisValue.toString(exec));
+    JSString* sVal = thisValue.toString(exec);
     const UString& s = sVal->value(exec);
 
     int sSize = s.length();
@@ -1257,10 +1235,10 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncLocaleCompare(ExecState* exec)
     JSValue thisValue = exec->hostThisValue();
     if (thisValue.isUndefinedOrNull()) // CheckObjectCoercible
         return throwVMTypeError(exec);
-    UString s = thisValue.toString(exec);
+    UString s = thisValue.toString(exec)->value(exec);
 
     JSValue a0 = exec->argument(0);
-    return JSValue::encode(jsNumber(localeCompare(s, a0.toString(exec))));
+    return JSValue::encode(jsNumber(localeCompare(s, a0.toString(exec)->value(exec))));
 }
 
 EncodedJSValue JSC_HOST_CALL stringProtoFuncBig(ExecState* exec)
@@ -1268,7 +1246,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncBig(ExecState* exec)
     JSValue thisValue = exec->hostThisValue();
     if (thisValue.isUndefinedOrNull()) // CheckObjectCoercible
         return throwVMTypeError(exec);
-    UString s = thisValue.toString(exec);
+    UString s = thisValue.toString(exec)->value(exec);
     return JSValue::encode(jsMakeNontrivialString(exec, "<big>", s, "</big>"));
 }
 
@@ -1277,7 +1255,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncSmall(ExecState* exec)
     JSValue thisValue = exec->hostThisValue();
     if (thisValue.isUndefinedOrNull()) // CheckObjectCoercible
         return throwVMTypeError(exec);
-    UString s = thisValue.toString(exec);
+    UString s = thisValue.toString(exec)->value(exec);
     return JSValue::encode(jsMakeNontrivialString(exec, "<small>", s, "</small>"));
 }
 
@@ -1286,7 +1264,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncBlink(ExecState* exec)
     JSValue thisValue = exec->hostThisValue();
     if (thisValue.isUndefinedOrNull()) // CheckObjectCoercible
         return throwVMTypeError(exec);
-    UString s = thisValue.toString(exec);
+    UString s = thisValue.toString(exec)->value(exec);
     return JSValue::encode(jsMakeNontrivialString(exec, "<blink>", s, "</blink>"));
 }
 
@@ -1295,7 +1273,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncBold(ExecState* exec)
     JSValue thisValue = exec->hostThisValue();
     if (thisValue.isUndefinedOrNull()) // CheckObjectCoercible
         return throwVMTypeError(exec);
-    UString s = thisValue.toString(exec);
+    UString s = thisValue.toString(exec)->value(exec);
     return JSValue::encode(jsMakeNontrivialString(exec, "<b>", s, "</b>"));
 }
 
@@ -1304,7 +1282,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncFixed(ExecState* exec)
     JSValue thisValue = exec->hostThisValue();
     if (thisValue.isUndefinedOrNull()) // CheckObjectCoercible
         return throwVMTypeError(exec);
-    UString s = thisValue.toString(exec);
+    UString s = thisValue.toString(exec)->value(exec);
     return JSValue::encode(jsMakeNontrivialString(exec, "<tt>", s, "</tt>"));
 }
 
@@ -1313,7 +1291,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncItalics(ExecState* exec)
     JSValue thisValue = exec->hostThisValue();
     if (thisValue.isUndefinedOrNull()) // CheckObjectCoercible
         return throwVMTypeError(exec);
-    UString s = thisValue.toString(exec);
+    UString s = thisValue.toString(exec)->value(exec);
     return JSValue::encode(jsMakeNontrivialString(exec, "<i>", s, "</i>"));
 }
 
@@ -1322,7 +1300,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncStrike(ExecState* exec)
     JSValue thisValue = exec->hostThisValue();
     if (thisValue.isUndefinedOrNull()) // CheckObjectCoercible
         return throwVMTypeError(exec);
-    UString s = thisValue.toString(exec);
+    UString s = thisValue.toString(exec)->value(exec);
     return JSValue::encode(jsMakeNontrivialString(exec, "<strike>", s, "</strike>"));
 }
 
@@ -1331,7 +1309,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncSub(ExecState* exec)
     JSValue thisValue = exec->hostThisValue();
     if (thisValue.isUndefinedOrNull()) // CheckObjectCoercible
         return throwVMTypeError(exec);
-    UString s = thisValue.toString(exec);
+    UString s = thisValue.toString(exec)->value(exec);
     return JSValue::encode(jsMakeNontrivialString(exec, "<sub>", s, "</sub>"));
 }
 
@@ -1340,7 +1318,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncSup(ExecState* exec)
     JSValue thisValue = exec->hostThisValue();
     if (thisValue.isUndefinedOrNull()) // CheckObjectCoercible
         return throwVMTypeError(exec);
-    UString s = thisValue.toString(exec);
+    UString s = thisValue.toString(exec)->value(exec);
     return JSValue::encode(jsMakeNontrivialString(exec, "<sup>", s, "</sup>"));
 }
 
@@ -1349,9 +1327,9 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncFontcolor(ExecState* exec)
     JSValue thisValue = exec->hostThisValue();
     if (thisValue.isUndefinedOrNull()) // CheckObjectCoercible
         return throwVMTypeError(exec);
-    UString s = thisValue.toString(exec);
+    UString s = thisValue.toString(exec)->value(exec);
     JSValue a0 = exec->argument(0);
-    return JSValue::encode(jsMakeNontrivialString(exec, "<font color=\"", a0.toString(exec), "\">", s, "</font>"));
+    return JSValue::encode(jsMakeNontrivialString(exec, "<font color=\"", a0.toString(exec)->value(exec), "\">", s, "</font>"));
 }
 
 EncodedJSValue JSC_HOST_CALL stringProtoFuncFontsize(ExecState* exec)
@@ -1359,7 +1337,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncFontsize(ExecState* exec)
     JSValue thisValue = exec->hostThisValue();
     if (thisValue.isUndefinedOrNull()) // CheckObjectCoercible
         return throwVMTypeError(exec);
-    UString s = thisValue.toString(exec);
+    UString s = thisValue.toString(exec)->value(exec);
     JSValue a0 = exec->argument(0);
 
     uint32_t smallInteger;
@@ -1396,7 +1374,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncFontsize(ExecState* exec)
         return JSValue::encode(jsNontrivialString(exec, impl));
     }
 
-    return JSValue::encode(jsMakeNontrivialString(exec, "<font size=\"", a0.toString(exec), "\">", s, "</font>"));
+    return JSValue::encode(jsMakeNontrivialString(exec, "<font size=\"", a0.toString(exec)->value(exec), "\">", s, "</font>"));
 }
 
 EncodedJSValue JSC_HOST_CALL stringProtoFuncAnchor(ExecState* exec)
@@ -1404,9 +1382,9 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncAnchor(ExecState* exec)
     JSValue thisValue = exec->hostThisValue();
     if (thisValue.isUndefinedOrNull()) // CheckObjectCoercible
         return throwVMTypeError(exec);
-    UString s = thisValue.toString(exec);
+    UString s = thisValue.toString(exec)->value(exec);
     JSValue a0 = exec->argument(0);
-    return JSValue::encode(jsMakeNontrivialString(exec, "<a name=\"", a0.toString(exec), "\">", s, "</a>"));
+    return JSValue::encode(jsMakeNontrivialString(exec, "<a name=\"", a0.toString(exec)->value(exec), "\">", s, "</a>"));
 }
 
 EncodedJSValue JSC_HOST_CALL stringProtoFuncLink(ExecState* exec)
@@ -1414,9 +1392,9 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncLink(ExecState* exec)
     JSValue thisValue = exec->hostThisValue();
     if (thisValue.isUndefinedOrNull()) // CheckObjectCoercible
         return throwVMTypeError(exec);
-    UString s = thisValue.toString(exec);
+    UString s = thisValue.toString(exec)->value(exec);
     JSValue a0 = exec->argument(0);
-    UString linkText = a0.toString(exec);
+    UString linkText = a0.toString(exec)->value(exec);
 
     unsigned linkTextSize = linkText.length();
     unsigned stringSize = s.length();
@@ -1459,7 +1437,7 @@ static inline JSValue trimString(ExecState* exec, JSValue thisValue, int trimKin
 {
     if (thisValue.isUndefinedOrNull()) // CheckObjectCoercible
         return throwTypeError(exec);
-    UString str = thisValue.toString(exec);
+    UString str = thisValue.toString(exec)->value(exec);
     unsigned left = 0;
     if (trimKind & TrimLeft) {
         while (left < str.length() && isTrimWhitespace(str[left]))
index 94b7e39..d943fd0 100644 (file)
@@ -1,3 +1,13 @@
+2012-01-23  Geoffrey Garen  <ggaren@apple.com>
+
+        JSValue::toString() should return a JSString* instead of a UString
+        https://bugs.webkit.org/show_bug.cgi?id=76861
+
+        Reviewed by Gavin Barraclough.
+
+        * JSUtils.cpp:
+        (KJSValueToCFTypeInternal):
+
 2012-01-19  Mark Hahnenberg  <mhahnenberg@apple.com>
 
         Implement a new allocator for backing stores
index e42e6ac..6bf0928 100644 (file)
@@ -215,7 +215,7 @@ CFTypeRef KJSValueToCFTypeInternal(JSValue inValue, ExecState *exec, ObjectImpLi
 
         if (inValue.isString())
             {
-                UString uString = inValue.toString(exec);
+                UString uString = inValue.toString(exec)->value(exec);
                 result = UStringToCFString(uString);
                 return result;
             }
index c115554..4a36eca 100644 (file)
@@ -1,3 +1,129 @@
+2012-01-23  Geoffrey Garen  <ggaren@apple.com>
+
+        JSValue::toString() should return a JSString* instead of a UString
+        https://bugs.webkit.org/show_bug.cgi?id=76861
+
+        Reviewed by Gavin Barraclough.
+
+        Mechanical changes to call value() after calling toString(), to
+        convert from "JS string" (JSString*) to "C++ string" (UString), since
+        toString() no longer returns a "C++ string".
+
+        * bindings/js/IDBBindingUtilities.cpp:
+        (WebCore::createIDBKeyFromValue):
+        * bindings/js/JSCSSStyleDeclarationCustom.cpp:
+        (WebCore::JSCSSStyleDeclaration::getPropertyCSSValue):
+        * bindings/js/JSClipboardCustom.cpp:
+        (WebCore::JSClipboard::clearData):
+        (WebCore::JSClipboard::getData):
+        * bindings/js/JSCustomXPathNSResolver.cpp:
+        (WebCore::JSCustomXPathNSResolver::lookupNamespaceURI):
+        * bindings/js/JSDOMBinding.cpp:
+        (WebCore::valueToStringWithNullCheck):
+        (WebCore::valueToStringWithUndefinedOrNullCheck):
+        (WebCore::reportException):
+        * bindings/js/JSDOMFormDataCustom.cpp:
+        (WebCore::JSDOMFormData::append):
+        * bindings/js/JSDOMStringMapCustom.cpp:
+        (WebCore::JSDOMStringMap::putDelegate):
+        * bindings/js/JSDOMWindowCustom.cpp:
+        (WebCore::JSDOMWindow::setLocation):
+        (WebCore::JSDOMWindow::open):
+        (WebCore::JSDOMWindow::addEventListener):
+        (WebCore::JSDOMWindow::removeEventListener):
+        * bindings/js/JSDeviceMotionEventCustom.cpp:
+        (WebCore::JSDeviceMotionEvent::initDeviceMotionEvent):
+        * bindings/js/JSDeviceOrientationEventCustom.cpp:
+        (WebCore::JSDeviceOrientationEvent::initDeviceOrientationEvent):
+        * bindings/js/JSDictionary.cpp:
+        (WebCore::JSDictionary::convertValue):
+        * bindings/js/JSDocumentCustom.cpp:
+        (WebCore::JSDocument::setLocation):
+        * bindings/js/JSEventListener.cpp:
+        (WebCore::JSEventListener::handleEvent):
+        * bindings/js/JSHTMLAllCollectionCustom.cpp:
+        (WebCore::callHTMLAllCollection):
+        (WebCore::JSHTMLAllCollection::item):
+        (WebCore::JSHTMLAllCollection::namedItem):
+        * bindings/js/JSHTMLCanvasElementCustom.cpp:
+        (WebCore::JSHTMLCanvasElement::getContext):
+        * bindings/js/JSHTMLCollectionCustom.cpp:
+        (WebCore::JSHTMLCollection::item):
+        (WebCore::JSHTMLCollection::namedItem):
+        * bindings/js/JSHTMLDocumentCustom.cpp:
+        (WebCore::documentWrite):
+        * bindings/js/JSHTMLInputElementCustom.cpp:
+        (WebCore::JSHTMLInputElement::setSelectionDirection):
+        (WebCore::JSHTMLInputElement::setSelectionRange):
+        * bindings/js/JSInspectorFrontendHostCustom.cpp:
+        (WebCore::JSInspectorFrontendHost::showContextMenu):
+        * bindings/js/JSJavaScriptCallFrameCustom.cpp:
+        (WebCore::JSJavaScriptCallFrame::evaluate):
+        * bindings/js/JSLocationCustom.cpp:
+        (WebCore::JSLocation::setHref):
+        (WebCore::JSLocation::setProtocol):
+        (WebCore::JSLocation::setHost):
+        (WebCore::JSLocation::setHostname):
+        (WebCore::JSLocation::setPort):
+        (WebCore::JSLocation::setPathname):
+        (WebCore::JSLocation::setSearch):
+        (WebCore::JSLocation::setHash):
+        (WebCore::JSLocation::replace):
+        (WebCore::JSLocation::assign):
+        * bindings/js/JSMessageEventCustom.cpp:
+        (WebCore::handleInitMessageEvent):
+        * bindings/js/JSSQLTransactionCustom.cpp:
+        (WebCore::JSSQLTransaction::executeSql):
+        * bindings/js/JSSQLTransactionSyncCustom.cpp:
+        (WebCore::JSSQLTransactionSync::executeSql):
+        * bindings/js/JSSharedWorkerCustom.cpp:
+        (WebCore::JSSharedWorkerConstructor::constructJSSharedWorker):
+        * bindings/js/JSStorageCustom.cpp:
+        (WebCore::JSStorage::putDelegate):
+        * bindings/js/JSWebGLRenderingContextCustom.cpp:
+        (WebCore::JSWebGLRenderingContext::getExtension):
+        * bindings/js/JSWebSocketCustom.cpp:
+        (WebCore::JSWebSocketConstructor::constructJSWebSocket):
+        (WebCore::JSWebSocket::send):
+        (WebCore::JSWebSocket::close):
+        * bindings/js/JSWorkerContextCustom.cpp:
+        (WebCore::JSWorkerContext::importScripts):
+        * bindings/js/JSWorkerCustom.cpp:
+        (WebCore::JSWorkerConstructor::constructJSWorker):
+        * bindings/js/JSXMLHttpRequestCustom.cpp:
+        (WebCore::JSXMLHttpRequest::open):
+        (WebCore::JSXMLHttpRequest::send):
+        * bindings/js/JSXSLTProcessorCustom.cpp:
+        (WebCore::JSXSLTProcessor::setParameter):
+        (WebCore::JSXSLTProcessor::getParameter):
+        (WebCore::JSXSLTProcessor::removeParameter):
+        * bindings/js/ScheduledAction.cpp:
+        (WebCore::ScheduledAction::create):
+        * bindings/js/ScriptEventListener.cpp:
+        (WebCore::eventListenerHandlerBody):
+        * bindings/js/ScriptValue.cpp:
+        (WebCore::ScriptValue::toString):
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateEventListenerCall):
+        (JSValueToNative):
+        (GenerateConstructorDefinition):
+        * bridge/c/c_utility.cpp:
+        (JSC::Bindings::convertValueToNPVariant):
+        * bridge/jni/jni_jsobject.mm:
+        (JavaJSObject::convertValueToJObject):
+        * bridge/jni/jsc/JNIUtilityPrivate.cpp:
+        (JSC::Bindings::convertArrayInstanceToJavaArray):
+        (JSC::Bindings::convertValueToJValue):
+        * bridge/jni/jsc/JavaFieldJSC.cpp:
+        (JavaField::dispatchValueFromInstance):
+        (JavaField::valueFromInstance):
+        (JavaField::dispatchSetValueToInstance):
+        (JavaField::setValueToInstance):
+        * bridge/jni/jsc/JavaInstanceJSC.cpp:
+        (JavaInstance::invokeMethod):
+        * testing/js/JSInternalsCustom.cpp:
+        (WebCore::JSInternals::setUserPreferredLanguages):
+
 2012-01-23  Kentaro Hara  <haraken@chromium.org>
 
         In CodeGeneratorObjC.pm, overwrite the output .h/.mm
index 1232054..67623f8 100644 (file)
@@ -40,7 +40,7 @@ PassRefPtr<IDBKey> createIDBKeyFromValue(JSC::ExecState* exec, JSC::JSValue valu
     if (value.isInt32())
         return IDBKey::create(value.toInt32(exec));
     if (value.isString())
-        return IDBKey::create(ustringToString(value.toString(exec)));
+        return IDBKey::create(ustringToString(value.toString(exec)->value(exec)));
     // FIXME: Implement dates.
     return 0;
 }
index affe0e0..1fab242 100644 (file)
@@ -184,7 +184,7 @@ bool JSCSSStyleDeclaration::putDelegate(ExecState* exec, const Identifier& prope
 
 JSValue JSCSSStyleDeclaration::getPropertyCSSValue(ExecState* exec)
 {
-    const String& propertyName(ustringToString(exec->argument(0).toString(exec)));
+    const String& propertyName(ustringToString(exec->argument(0).toString(exec)->value(exec)));
     if (exec->hadException())
         return jsUndefined();
 
index e605fce..efce79b 100644 (file)
@@ -73,7 +73,7 @@ JSValue JSClipboard::clearData(ExecState* exec)
     }
 
     if (exec->argumentCount() == 1) {
-        clipboard->clearData(ustringToString(exec->argument(0).toString(exec)));
+        clipboard->clearData(ustringToString(exec->argument(0).toString(exec)->value(exec)));
         return jsUndefined();
     }
 
@@ -90,7 +90,7 @@ JSValue JSClipboard::getData(ExecState* exec)
     Clipboard* clipboard = impl();
 
     bool success;
-    String result = clipboard->getData(ustringToString(exec->argument(0).toString(exec)), success);
+    String result = clipboard->getData(ustringToString(exec->argument(0).toString(exec)->value(exec)), success);
     if (!success)
         return jsUndefined();
 
index c8a0096..14f51f4 100644 (file)
@@ -97,7 +97,7 @@ String JSCustomXPathNSResolver::lookupNamespaceURI(const String& prefix)
         reportCurrentException(exec);
     else {
         if (!retval.isUndefinedOrNull())
-            result = ustringToString(retval.toString(exec));
+            result = ustringToString(retval.toString(exec)->value(exec));
     }
 
     Document::updateStyleForAllDocuments();
index de78d47..ef3efe9 100644 (file)
@@ -120,14 +120,14 @@ String valueToStringWithNullCheck(ExecState* exec, JSValue value)
 {
     if (value.isNull())
         return String();
-    return ustringToString(value.toString(exec));
+    return ustringToString(value.toString(exec)->value(exec));
 }
 
 String valueToStringWithUndefinedOrNullCheck(ExecState* exec, JSValue value)
 {
     if (value.isUndefinedOrNull())
         return String();
-    return ustringToString(value.toString(exec));
+    return ustringToString(value.toString(exec)->value(exec));
 }
 
 JSValue jsDateOrNull(ExecState* exec, double value)
@@ -151,10 +151,10 @@ void reportException(ExecState* exec, JSValue exception)
     if (isTerminatedExecutionException(exception))
         return;
 
-    UString errorMessage = exception.toString(exec);
+    UString errorMessage = exception.toString(exec)->value(exec);
     JSObject* exceptionObject = exception.toObject(exec);
     int lineNumber = exceptionObject->get(exec, Identifier(exec, "line")).toInt32(exec);
-    UString exceptionSourceURL = exceptionObject->get(exec, Identifier(exec, "sourceURL")).toString(exec);
+    UString exceptionSourceURL = exceptionObject->get(exec, Identifier(exec, "sourceURL")).toString(exec)->value(exec);
     exec->clearException();
 
     if (ExceptionBase* exceptionBase = toExceptionBase(exception))
index 318600b..65c1cf4 100644 (file)
@@ -60,15 +60,15 @@ EncodedJSValue JSC_HOST_CALL JSDOMFormDataConstructor::constructJSDOMFormData(Ex
 JSValue JSDOMFormData::append(ExecState* exec)
 {
     if (exec->argumentCount() >= 2) {
-        String name = ustringToString(exec->argument(0).toString(exec));
+        String name = ustringToString(exec->argument(0).toString(exec)->value(exec));
         JSValue value = exec->argument(1);
         if (value.inherits(&JSBlob::s_info)) {
             String filename;
             if (exec->argumentCount() >= 3 && !exec->argument(2).isUndefinedOrNull())
-                filename = ustringToString(exec->argument(2).toString(exec));
+                filename = ustringToString(exec->argument(2).toString(exec)->value(exec));
             impl()->append(name, toBlob(value), filename);
         } else
-            impl()->append(name, ustringToString(value.toString(exec)));
+            impl()->append(name, ustringToString(value.toString(exec)->value(exec)));
     }
 
     return jsUndefined();
index cbe6d94..7c599c5 100644 (file)
@@ -72,7 +72,7 @@ bool JSDOMStringMap::deleteProperty(JSCell* cell, ExecState* exec, const Identif
 
 bool JSDOMStringMap::putDelegate(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot&)
 {
-    String stringValue = ustringToString(value.toString(exec));
+    String stringValue = ustringToString(value.toString(exec)->value(exec));
     if (exec->hadException())
         return false;
     ExceptionCode ec = 0;
index 0ed3b28..40d8964 100644 (file)
@@ -462,7 +462,7 @@ void JSDOMWindow::setLocation(ExecState* exec, JSValue value)
     }
 #endif
 
-    UString locationString = value.toString(exec);
+    UString locationString = value.toString(exec)->value(exec);
     if (exec->hadException())
         return;
 
@@ -512,7 +512,7 @@ JSValue JSDOMWindow::open(ExecState* exec)
     String urlString = valueToStringWithUndefinedOrNullCheck(exec, exec->argument(0));
     if (exec->hadException())
         return jsUndefined();
-    AtomicString frameName = exec->argument(1).isUndefinedOrNull() ? "_blank" : ustringToAtomicString(exec->argument(1).toString(exec));
+    AtomicString frameName = exec->argument(1).isUndefinedOrNull() ? "_blank" : ustringToAtomicString(exec->argument(1).toString(exec)->value(exec));
     if (exec->hadException())
         return jsUndefined();
     String windowFeaturesString = valueToStringWithUndefinedOrNullCheck(exec, exec->argument(2));
@@ -679,7 +679,7 @@ JSValue JSDOMWindow::addEventListener(ExecState* exec)
     if (!listener.isObject())
         return jsUndefined();
 
-    impl()->addEventListener(ustringToAtomicString(exec->argument(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)), exec->argument(2).toBoolean(exec));
+    impl()->addEventListener(ustringToAtomicString(exec->argument(0).toString(exec)->value(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)), exec->argument(2).toBoolean(exec));
     return jsUndefined();
 }
 
@@ -693,7 +693,7 @@ JSValue JSDOMWindow::removeEventListener(ExecState* exec)
     if (!listener.isObject())
         return jsUndefined();
 
-    impl()->removeEventListener(ustringToAtomicString(exec->argument(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)).get(), exec->argument(2).toBoolean(exec));
+    impl()->removeEventListener(ustringToAtomicString(exec->argument(0).toString(exec)->value(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)).get(), exec->argument(2).toBoolean(exec));
     return jsUndefined();
 }
 
index f4ccb86..8e9948f 100644 (file)
@@ -164,7 +164,7 @@ JSValue JSDeviceMotionEvent::interval(ExecState*) const
 
 JSValue JSDeviceMotionEvent::initDeviceMotionEvent(ExecState* exec)
 {
-    const String& type = ustringToString(exec->argument(0).toString(exec));
+    const String& type = ustringToString(exec->argument(0).toString(exec)->value(exec));
     bool bubbles = exec->argument(1).toBoolean(exec);
     bool cancelable = exec->argument(2).toBoolean(exec);
 
index c37a074..1c329f4 100644 (file)
@@ -70,7 +70,7 @@ JSValue JSDeviceOrientationEvent::absolute(ExecState*) const
 
 JSValue JSDeviceOrientationEvent::initDeviceOrientationEvent(ExecState* exec)
 {
-    const String& type = ustringToString(exec->argument(0).toString(exec));
+    const String& type = ustringToString(exec->argument(0).toString(exec)->value(exec));
     bool bubbles = exec->argument(1).toBoolean(exec);
     bool cancelable = exec->argument(2).toBoolean(exec);
     // If alpha, beta or gamma are null or undefined, mark them as not provided.
index d634018..da24d82 100644 (file)
@@ -91,7 +91,7 @@ void JSDictionary::convertValue(ExecState* exec, JSValue value, double& result)
 
 void JSDictionary::convertValue(ExecState* exec, JSValue value, String& result)
 {
-    result = ustringToString(value.toString(exec));
+    result = ustringToString(value.toString(exec)->value(exec));
 }
 
 void JSDictionary::convertValue(ExecState* exec, JSValue value, ScriptValue& result)
index 5faa340..466caf2 100644 (file)
@@ -69,7 +69,7 @@ void JSDocument::setLocation(ExecState* exec, JSValue value)
     if (!frame)
         return;
 
-    String str = ustringToString(value.toString(exec));
+    String str = ustringToString(value.toString(exec)->value(exec));
 
     Frame* lexicalFrame = asJSDOMWindow(exec->lexicalGlobalObject())->impl()->frame();
 
index 4361707..62d0ce1 100644 (file)
@@ -139,7 +139,7 @@ void JSEventListener::handleEvent(ScriptExecutionContext* scriptExecutionContext
             reportCurrentException(exec);
         } else {
             if (!retval.isUndefinedOrNull() && event->storesResultAsString())
-                event->storeResult(ustringToString(retval.toString(exec)));
+                event->storeResult(ustringToString(retval.toString(exec)->value(exec)));
             if (m_isAttribute) {
                 if (retval.isFalse())
                     event->preventDefault();
index a54374e..3626cdc 100644 (file)
@@ -72,7 +72,7 @@ static EncodedJSValue JSC_HOST_CALL callHTMLAllCollection(ExecState* exec)
     if (exec->argumentCount() == 1) {
         // Support for document.all(<index>) etc.
         bool ok;
-        UString string = exec->argument(0).toString(exec);
+        UString string = exec->argument(0).toString(exec)->value(exec);
         unsigned index = Identifier::toUInt32(string, ok);
         if (ok)
             return JSValue::encode(toJS(exec, jsCollection->globalObject(), collection->item(index)));
@@ -83,8 +83,8 @@ static EncodedJSValue JSC_HOST_CALL callHTMLAllCollection(ExecState* exec)
 
     // The second arg, if set, is the index of the item we want
     bool ok;
-    UString string = exec->argument(0).toString(exec);
-    unsigned index = Identifier::toUInt32(exec->argument(1).toString(exec), ok);
+    UString string = exec->argument(0).toString(exec)->value(exec);
+    unsigned index = Identifier::toUInt32(exec->argument(1).toString(exec)->value(exec), ok);
     if (ok) {
         if (Node* node = collection->namedItemWithIndex(ustringToAtomicString(string), index))
             return JSValue::encode(toJS(exec, jsCollection->globalObject(), node));
@@ -113,15 +113,15 @@ JSValue JSHTMLAllCollection::nameGetter(ExecState* exec, JSValue slotBase, const
 JSValue JSHTMLAllCollection::item(ExecState* exec)
 {
     bool ok;
-    uint32_t index = Identifier::toUInt32(exec->argument(0).toString(exec), ok);
+    uint32_t index = Identifier::toUInt32(exec->argument(0).toString(exec)->value(exec), ok);
     if (ok)
         return toJS(exec, globalObject(), impl()->item(index));
-    return getNamedItems(exec, this, Identifier(exec, exec->argument(0).toString(exec)));
+    return getNamedItems(exec, this, Identifier(exec, exec->argument(0).toString(exec)->value(exec)));
 }
 
 JSValue JSHTMLAllCollection::namedItem(ExecState* exec)
 {
-    return getNamedItems(exec, this, Identifier(exec, exec->argument(0).toString(exec)));
+    return getNamedItems(exec, this, Identifier(exec, exec->argument(0).toString(exec)->value(exec)));
 }
 
 } // namespace WebCore
index 61efff1..df1866f 100644 (file)
@@ -43,7 +43,7 @@ namespace WebCore {
 JSValue JSHTMLCanvasElement::getContext(ExecState* exec)
 {
     HTMLCanvasElement* canvas = static_cast<HTMLCanvasElement*>(impl());
-    const UString& contextId = exec->argument(0).toString(exec);
+    const UString& contextId = exec->argument(0).toString(exec)->value(exec);
     RefPtr<CanvasContextAttributes> attrs;
 #if ENABLE(WEBGL)
     if (contextId == "experimental-webgl" || contextId == "webkit-3d") {
index 494c1ba..03d4679 100644 (file)
@@ -72,15 +72,15 @@ JSValue JSHTMLCollection::nameGetter(ExecState* exec, JSValue slotBase, const Id
 JSValue JSHTMLCollection::item(ExecState* exec)
 {
     bool ok;
-    uint32_t index = Identifier::toUInt32(exec->argument(0).toString(exec), ok);
+    uint32_t index = Identifier::toUInt32(exec->argument(0).toString(exec)->value(exec), ok);
     if (ok)
         return toJS(exec, globalObject(), impl()->item(index));
-    return getNamedItems(exec, this, Identifier(exec, exec->argument(0).toString(exec)));
+    return getNamedItems(exec, this, Identifier(exec, exec->argument(0).toString(exec)->value(exec)));
 }
 
 JSValue JSHTMLCollection::namedItem(ExecState* exec)
 {
-    return getNamedItems(exec, this, Identifier(exec, exec->argument(0).toString(exec)));
+    return getNamedItems(exec, this, Identifier(exec, exec->argument(0).toString(exec)->value(exec)));
 }
 
 JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, HTMLCollection* collection)
index fd51845..623973a 100644 (file)
@@ -136,14 +136,14 @@ static inline void documentWrite(ExecState* exec, HTMLDocument* document, Newlin
 
     size_t size = exec->argumentCount();
 
-    UString firstString = exec->argument(0).toString(exec);
+    UString firstString = exec->argument(0).toString(exec)->value(exec);
     SegmentedString segmentedString = ustringToString(firstString);
     if (size != 1) {
         if (!size)
             segmentedString.clear();
         else {
             for (size_t i = 1; i < size; ++i) {
-                UString subsequentString = exec->argument(i).toString(exec);
+                UString subsequentString = exec->argument(i).toString(exec)->value(exec);
                 segmentedString.append(SegmentedString(ustringToString(subsequentString)));
             }
         }
index 32a2e44..36fd8b7 100644 (file)
@@ -86,7 +86,7 @@ void JSHTMLInputElement::setSelectionDirection(ExecState* exec, JSValue value)
         return;
     }
 
-    input->setSelectionDirection(ustringToString(value.toString(exec)));
+    input->setSelectionDirection(ustringToString(value.toString(exec)->value(exec)));
 }
 
 JSValue JSHTMLInputElement::setSelectionRange(ExecState* exec)
@@ -97,7 +97,7 @@ JSValue JSHTMLInputElement::setSelectionRange(ExecState* exec)
 
     int start = exec->argument(0).toInt32(exec);
     int end = exec->argument(1).toInt32(exec);
-    String direction = ustringToString(exec->argument(2).toString(exec));
+    String direction = ustringToString(exec->argument(2).toString(exec)->value(exec));
 
     input->setSelectionRange(start, end, direction);
     return jsUndefined();
index f5f28f6..e8d5170 100644 (file)
@@ -105,14 +105,14 @@ JSValue JSInspectorFrontendHost::showContextMenu(ExecState* exec)
         if (!type.isString())
             continue;
 
-        String typeString = ustringToString(type.toString(exec));
+        String typeString = ustringToString(type.toString(exec)->value(exec));
         if (typeString == "separator") {
             items.append(new ContextMenuItem(SeparatorType,
                                              ContextMenuItemCustomTagNoAction,
                                              String()));
         } else {
             ContextMenuAction typedId = static_cast<ContextMenuAction>(ContextMenuItemBaseCustomTag + id.toInt32(exec));
-            ContextMenuItem* menuItem = new ContextMenuItem((typeString == "checkbox" ? CheckableActionType : ActionType), typedId, ustringToString(label.toString(exec)));
+            ContextMenuItem* menuItem = new ContextMenuItem((typeString == "checkbox" ? CheckableActionType : ActionType), typedId, ustringToString(label.toString(exec)->value(exec)));
             if (!enabled.isUndefined())
                 menuItem->setEnabled(enabled.toBoolean(exec));
             if (!checked.isUndefined())
index 1dba251..a325467 100644 (file)
@@ -40,7 +40,7 @@ namespace WebCore {
 JSValue JSJavaScriptCallFrame::evaluate(ExecState* exec)
 {
     JSValue exception;
-    JSValue result = impl()->evaluate(exec->argument(0).toString(exec), exception);
+    JSValue result = impl()->evaluate(exec->argument(0).toString(exec)->value(exec), exception);
 
     if (exception)
         throwError(exec, exception);
index 22032c7..4bbd56e 100644 (file)
@@ -179,7 +179,7 @@ void JSLocation::defineGetter(JSObject* object, ExecState* exec, const Identifie
 
 void JSLocation::setHref(ExecState* exec, JSValue value)
 {
-    UString href = value.toString(exec);
+    UString href = value.toString(exec)->value(exec);
     if (exec->hadException())
         return;
     impl()->setHref(ustringToString(href), activeDOMWindow(exec), firstDOMWindow(exec));
@@ -187,7 +187,7 @@ void JSLocation::setHref(ExecState* exec, JSValue value)
 
 void JSLocation::setProtocol(ExecState* exec, JSValue value)
 {
-    UString protocol = value.toString(exec);
+    UString protocol = value.toString(exec)->value(exec);
     if (exec->hadException())
         return;
     ExceptionCode ec = 0;
@@ -197,7 +197,7 @@ void JSLocation::setProtocol(ExecState* exec, JSValue value)
 
 void JSLocation::setHost(ExecState* exec, JSValue value)
 {
-    UString host = value.toString(exec);
+    UString host = value.toString(exec)->value(exec);
     if (exec->hadException())
         return;
     impl()->setHost(ustringToString(host), activeDOMWindow(exec), firstDOMWindow(exec));
@@ -205,7 +205,7 @@ void JSLocation::setHost(ExecState* exec, JSValue value)
 
 void JSLocation::setHostname(ExecState* exec, JSValue value)
 {
-    UString hostname = value.toString(exec);
+    UString hostname = value.toString(exec)->value(exec);
     if (exec->hadException())
         return;
     impl()->setHostname(ustringToString(hostname), activeDOMWindow(exec), firstDOMWindow(exec));
@@ -213,7 +213,7 @@ void JSLocation::setHostname(ExecState* exec, JSValue value)
 
 void JSLocation::setPort(ExecState* exec, JSValue value)
 {
-    UString port = value.toString(exec);
+    UString port = value.toString(exec)->value(exec);
     if (exec->hadException())
         return;
     impl()->setPort(ustringToString(port), activeDOMWindow(exec), firstDOMWindow(exec));
@@ -221,7 +221,7 @@ void JSLocation::setPort(ExecState* exec, JSValue value)
 
 void JSLocation::setPathname(ExecState* exec, JSValue value)
 {
-    UString pathname = value.toString(exec);
+    UString pathname = value.toString(exec)->value(exec);
     if (exec->hadException())
         return;
     impl()->setPathname(ustringToString(pathname), activeDOMWindow(exec), firstDOMWindow(exec));
@@ -229,7 +229,7 @@ void JSLocation::setPathname(ExecState* exec, JSValue value)
 
 void JSLocation::setSearch(ExecState* exec, JSValue value)
 {
-    UString pathname = value.toString(exec);
+    UString pathname = value.toString(exec)->value(exec);
     if (exec->hadException())
         return;
     impl()->setSearch(ustringToString(pathname), activeDOMWindow(exec), firstDOMWindow(exec));
@@ -237,7 +237,7 @@ void JSLocation::setSearch(ExecState* exec, JSValue value)
 
 void JSLocation::setHash(ExecState* exec, JSValue value)
 {
-    UString hash = value.toString(exec);
+    UString hash = value.toString(exec)->value(exec);
     if (exec->hadException())
         return;
     impl()->setHash(ustringToString(hash), activeDOMWindow(exec), firstDOMWindow(exec));
@@ -245,7 +245,7 @@ void JSLocation::setHash(ExecState* exec, JSValue value)
 
 JSValue JSLocation::replace(ExecState* exec)
 {
-    UString urlString = exec->argument(0).toString(exec);
+    UString urlString = exec->argument(0).toString(exec)->value(exec);
     if (exec->hadException())
         return jsUndefined();
     impl()->replace(ustringToString(urlString), activeDOMWindow(exec), firstDOMWindow(exec));
@@ -260,7 +260,7 @@ JSValue JSLocation::reload(ExecState* exec)
 
 JSValue JSLocation::assign(ExecState* exec)
 {
-    UString urlString = exec->argument(0).toString(exec);
+    UString urlString = exec->argument(0).toString(exec)->value(exec);
     if (exec->hadException())
         return jsUndefined();
     impl()->assign(ustringToString(urlString), activeDOMWindow(exec), firstDOMWindow(exec));
index bbfc00e..64b989c 100644 (file)
@@ -102,11 +102,11 @@ JSValue JSMessageEvent::ports(ExecState* exec) const
 
 static JSC::JSValue handleInitMessageEvent(JSMessageEvent* jsEvent, JSC::ExecState* exec)
 {
-    const UString& typeArg = exec->argument(0).toString(exec);
+    const UString& typeArg = exec->argument(0).toString(exec)->value(exec);
     bool canBubbleArg = exec->argument(1).toBoolean(exec);
     bool cancelableArg = exec->argument(2).toBoolean(exec);
-    const UString& originArg = exec->argument(4).toString(exec);
-    const UString& lastEventIdArg = exec->argument(5).toString(exec);
+    const UString& originArg = exec->argument(4).toString(exec)->value(exec);
+    const UString& lastEventIdArg = exec->argument(5).toString(exec)->value(exec);
     DOMWindow* sourceArg = toDOMWindow(exec->argument(6));
     OwnPtr<MessagePortArray> messagePorts;
     if (!exec->argument(7).isUndefinedOrNull()) {
index 8578fe1..30aae1b 100644 (file)
@@ -50,7 +50,7 @@ JSValue JSSQLTransaction::executeSql(ExecState* exec)
         return jsUndefined();
     }
 
-    String sqlStatement = ustringToString(exec->argument(0).toString(exec));
+    String sqlStatement = ustringToString(exec->argument(0).toString(exec)->value(exec));
     if (exec->hadException())
         return jsUndefined();
 
@@ -81,7 +81,7 @@ JSValue JSSQLTransaction::executeSql(ExecState* exec)
                 sqlValues.append(value.asNumber());
             else {
                 // Convert the argument to a string and append it
-                sqlValues.append(ustringToString(value.toString(exec)));
+                sqlValues.append(ustringToString(value.toString(exec)->value(exec)));
                 if (exec->hadException())
                     return jsUndefined();
             }
index a9d3a5c..96c1884 100644 (file)
@@ -49,7 +49,7 @@ JSValue JSSQLTransactionSync::executeSql(ExecState* exec)
         return jsUndefined();
     }
 
-    String sqlStatement = ustringToString(exec->argument(0).toString(exec));
+    String sqlStatement = ustringToString(exec->argument(0).toString(exec)->value(exec));
     if (exec->hadException())
         return jsUndefined();
 
@@ -80,7 +80,7 @@ JSValue JSSQLTransactionSync::executeSql(ExecState* exec)
                 sqlValues.append(value.asNumber());
             else {
                 // Convert the argument to a string and append it
-                sqlValues.append(ustringToString(value.toString(exec)));
+                sqlValues.append(ustringToString(value.toString(exec)->value(exec)));
                 if (exec->hadException())
                     return jsUndefined();
             }
index 4720787..fb8dc18 100644 (file)
@@ -62,10 +62,10 @@ EncodedJSValue JSC_HOST_CALL JSSharedWorkerConstructor::constructJSSharedWorker(
     if (exec->argumentCount() < 1)
         return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
 
-    UString scriptURL = exec->argument(0).toString(exec);
+    UString scriptURL = exec->argument(0).toString(exec)->value(exec);
     UString name;
     if (exec->argumentCount() > 1)
-        name = exec->argument(1).toString(exec);
+        name = exec->argument(1).toString(exec)->value(exec);
 
     if (exec->hadException())
         return JSValue::encode(JSValue());
index dad77c6..31be269 100644 (file)
@@ -86,7 +86,7 @@ bool JSStorage::putDelegate(ExecState* exec, const Identifier& propertyName, JSV
     if (prototype.isObject() && asObject(prototype)->hasProperty(exec, propertyName))
         return false;
     
-    String stringValue = ustringToString(value.toString(exec));
+    String stringValue = ustringToString(value.toString(exec)->value(exec));
     if (exec->hadException())
         return true;
     
index 69010ae..b4f5662 100644 (file)
@@ -241,7 +241,7 @@ JSValue JSWebGLRenderingContext::getExtension(ExecState* exec)
         return throwSyntaxError(exec);
 
     WebGLRenderingContext* context = static_cast<WebGLRenderingContext*>(impl());
-    const String& name = ustringToString(exec->argument(0).toString(exec));
+    const String& name = ustringToString(exec->argument(0).toString(exec)->value(exec));
     if (exec->hadException())
         return jsUndefined();
     WebGLExtension* extension = context->getExtension(name);
index 777e5b8..c8e0069 100644 (file)
@@ -60,7 +60,7 @@ EncodedJSValue JSC_HOST_CALL JSWebSocketConstructor::constructJSWebSocket(ExecSt
     if (!exec->argumentCount())
         return throwVMError(exec, createSyntaxError(exec, "Not enough arguments"));
 
-    String urlString = ustringToString(exec->argument(0).toString(exec));
+    String urlString = ustringToString(exec->argument(0).toString(exec)->value(exec));
     if (exec->hadException())
         return throwVMError(exec, createSyntaxError(exec, "wrong URL"));
     RefPtr<WebSocket> webSocket = WebSocket::create(context);
@@ -73,14 +73,14 @@ EncodedJSValue JSC_HOST_CALL JSWebSocketConstructor::constructJSWebSocket(ExecSt
             Vector<String> protocols;
             JSArray* protocolsArray = asArray(protocolsValue);
             for (unsigned i = 0; i < protocolsArray->length(); ++i) {
-                String protocol = ustringToString(protocolsArray->getIndex(i).toString(exec));
+                String protocol = ustringToString(protocolsArray->getIndex(i).toString(exec)->value(exec));
                 if (exec->hadException())
                     return JSValue::encode(JSValue());
                 protocols.append(protocol);
             }
             webSocket->connect(urlString, protocols, ec);
         } else {
-            String protocol = ustringToString(protocolsValue.toString(exec));
+            String protocol = ustringToString(protocolsValue.toString(exec)->value(exec));
             if (exec->hadException())
                 return JSValue::encode(JSValue());
             webSocket->connect(urlString, protocol, ec);
@@ -103,7 +103,7 @@ JSValue JSWebSocket::send(ExecState* exec)
     else if (message.inherits(&JSBlob::s_info))
         result = impl()->send(toBlob(message), ec);
     else {
-        String stringMessage = ustringToString(message.toString(exec));
+        String stringMessage = ustringToString(message.toString(exec)->value(exec));
         if (exec->hadException())
             return jsUndefined();
         result = impl()->send(stringMessage, ec);
@@ -135,7 +135,7 @@ JSValue JSWebSocket::close(ExecState* exec)
             x = clampTo(x, minValue, maxValue);
         code = clampToInteger(x);
         if (argumentCount >= 2) {
-            reason = ustringToString(exec->argument(1).toString(exec));
+            reason = ustringToString(exec->argument(1).toString(exec)->value(exec));
             if (exec->hadException()) {
                 setDOMException(exec, SYNTAX_ERR);
                 return jsUndefined();
index 7612686..e103a8e 100644 (file)
@@ -109,7 +109,7 @@ JSValue JSWorkerContext::importScripts(ExecState* exec)
 
     Vector<String> urls;
     for (unsigned i = 0; i < exec->argumentCount(); i++) {
-        urls.append(ustringToString(exec->argument(i).toString(exec)));
+        urls.append(ustringToString(exec->argument(i).toString(exec)->value(exec)));
         if (exec->hadException())
             return jsUndefined();
     }
index aa1eee5..ca0f761 100644 (file)
@@ -57,7 +57,7 @@ EncodedJSValue JSC_HOST_CALL JSWorkerConstructor::constructJSWorker(ExecState* e
     if (!exec->argumentCount())
         return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
 
-    UString scriptURL = exec->argument(0).toString(exec);
+    UString scriptURL = exec->argument(0).toString(exec)->value(exec);
     if (exec->hadException())
         return JSValue::encode(JSValue());
 
index 3ab207e..4cdf68c 100644 (file)
@@ -85,8 +85,8 @@ JSValue JSXMLHttpRequest::open(ExecState* exec)
     if (exec->argumentCount() < 2)
         return throwError(exec, createSyntaxError(exec, "Not enough arguments"));
 
-    const KURL& url = impl()->scriptExecutionContext()->completeURL(ustringToString(exec->argument(1).toString(exec)));
-    String method = ustringToString(exec->argument(0).toString(exec));
+    const KURL& url = impl()->scriptExecutionContext()->completeURL(ustringToString(exec->argument(1).toString(exec)->value(exec)));
+    String method = ustringToString(exec->argument(0).toString(exec)->value(exec));
 
     ExceptionCode ec = 0;
     if (exec->argumentCount() >= 3) {
@@ -129,7 +129,7 @@ JSValue JSXMLHttpRequest::send(ExecState* exec)
         else if (val.inherits(&JSArrayBuffer::s_info))
             impl()->send(toArrayBuffer(val), ec);
         else
-            impl()->send(ustringToString(val.toString(exec)), ec);
+            impl()->send(ustringToString(val.toString(exec)->value(exec)), ec);
     }
 
     int signedLineNumber;
index e669303..da80097 100644 (file)
@@ -89,9 +89,9 @@ JSValue JSXSLTProcessor::setParameter(ExecState* exec)
 {
     if (exec->argument(1).isUndefinedOrNull() || exec->argument(2).isUndefinedOrNull())
         return jsUndefined(); // Throw exception?
-    String namespaceURI = ustringToString(exec->argument(0).toString(exec));
-    String localName = ustringToString(exec->argument(1).toString(exec));
-    String value = ustringToString(exec->argument(2).toString(exec));
+    String namespaceURI = ustringToString(exec->argument(0).toString(exec)->value(exec));
+    String localName = ustringToString(exec->argument(1).toString(exec)->value(exec));
+    String value = ustringToString(exec->argument(2).toString(exec)->value(exec));
     impl()->setParameter(namespaceURI, localName, value);
     return jsUndefined();
 }
@@ -100,8 +100,8 @@ JSValue JSXSLTProcessor::getParameter(ExecState* exec)
 {
     if (exec->argument(1).isUndefinedOrNull())
         return jsUndefined();
-    String namespaceURI = ustringToString(exec->argument(0).toString(exec));
-    String localName = ustringToString(exec->argument(1).toString(exec));
+    String namespaceURI = ustringToString(exec->argument(0).toString(exec)->value(exec));
+    String localName = ustringToString(exec->argument(1).toString(exec)->value(exec));
     String value = impl()->getParameter(namespaceURI, localName);
     return jsStringOrUndefined(exec, value);
 }
@@ -110,8 +110,8 @@ JSValue JSXSLTProcessor::removeParameter(ExecState* exec)
 {
     if (exec->argument(1).isUndefinedOrNull())
         return jsUndefined();
-    String namespaceURI = ustringToString(exec->argument(0).toString(exec));
-    String localName = ustringToString(exec->argument(1).toString(exec));
+    String namespaceURI = ustringToString(exec->argument(0).toString(exec)->value(exec));
+    String localName = ustringToString(exec->argument(1).toString(exec)->value(exec));
     impl()->removeParameter(namespaceURI, localName);
     return jsUndefined();
 }
index 572b450..e81c097 100644 (file)
@@ -55,7 +55,7 @@ PassOwnPtr<ScheduledAction> ScheduledAction::create(ExecState* exec, DOMWrapperW
     if (getCallData(v, callData) == CallTypeNone) {
         if (policy && !policy->allowEval())
             return nullptr;
-        UString string = v.toString(exec);
+        UString string = v.toString(exec)->value(exec);
         if (exec->hadException())
             return nullptr;
         return adoptPtr(new ScheduledAction(ustringToString(string), isolatedWorld));
index 9ccdb39..c210907 100644 (file)
@@ -103,7 +103,8 @@ String eventListenerHandlerBody(Document* document, EventListener* eventListener
     JSC::JSObject* jsFunction = jsListener->jsFunction(document);
     if (!jsFunction)
         return "";
-    return ustringToString(jsFunction->toString(scriptStateFromNode(jsListener->isolatedWorld(), document)));
+    ScriptState* scriptState = scriptStateFromNode(jsListener->isolatedWorld(), document);
+    return ustringToString(jsFunction->toString(scriptState)->value(scriptState));
 }
 
 bool eventListenerHandlerLocation(Document* document, EventListener* eventListener, String& sourceName, int& lineNumber)
index bfa93aa..7272a10 100644 (file)
@@ -58,7 +58,7 @@ bool ScriptValue::getString(ScriptState* scriptState, String& result) const
 
 String ScriptValue::toString(ScriptState* scriptState) const
 {
-    String result = ustringToString(m_value.get().toString(scriptState));
+    String result = ustringToString(m_value.get().toString(scriptState)->value(scriptState));
     // Handle the case where an exception is thrown as part of invoking toString on the object.
     if (scriptState->hadException())
         scriptState->clearException();
index 3814bf2..5f0f3b8 100644 (file)
@@ -171,7 +171,7 @@ END
     JSValue listener = exec->argument(1);
     if (!listener.isObject())
         return JSValue::encode(jsUndefined());
-    impl->${functionName}EventListener(ustringToAtomicString(exec->argument(0).toString(exec)), JSEventListener::create(asObject(listener), $wrapperObject, false, currentWorld(exec))$passRefPtrHandling, exec->argument(2).toBoolean(exec));
+    impl->${functionName}EventListener(ustringToAtomicString(exec->argument(0).toString(exec)->value(exec)), JSEventListener::create(asObject(listener), $wrapperObject, false, currentWorld(exec))$passRefPtrHandling, exec->argument(2).toBoolean(exec));
     return JSValue::encode(jsUndefined());
 END
     return @GenerateEventListenerImpl;
@@ -2895,7 +2895,7 @@ sub JSValueToNative
     if ($type eq "DOMString") {
         return "valueToStringWithNullCheck(exec, $value)" if $signature->extendedAttributes->{"ConvertNullToNullString"} || $signature->extendedAttributes->{"Reflect"};
         return "valueToStringWithUndefinedOrNullCheck(exec, $value)" if $signature->extendedAttributes->{"ConvertUndefinedOrNullToNullString"};
-        return "ustringToString($value.isEmpty() ? UString() : $value.toString(exec))";
+        return "ustringToString($value.isEmpty() ? UString() : $value.toString(exec)->value(exec))";
     }
 
     if ($type eq "DOMObject") {
@@ -3485,7 +3485,7 @@ EncodedJSValue JSC_HOST_CALL ${constructorClassName}::construct${className}(Exec
     if (!executionContext)
         return throwVMError(exec, createReferenceError(exec, "Constructor associated execution context is unavailable"));
 
-    AtomicString eventType = ustringToAtomicString(exec->argument(0).toString(exec));
+    AtomicString eventType = ustringToAtomicString(exec->argument(0).toString(exec)->value(exec));
     if (exec->hadException())
         return JSValue::encode(jsUndefined());
 
index e786896..449293c 100644 (file)
@@ -73,7 +73,7 @@ void convertValueToNPVariant(ExecState* exec, JSValue value, NPVariant* result)
     VOID_TO_NPVARIANT(*result);
 
     if (value.isString()) {
-        UString ustring = value.toString(exec);
+        UString ustring = value.toString(exec)->value(exec);
         CString cstring = ustring.utf8();
         NPString string = { (const NPUTF8*)cstring.data(), static_cast<uint32_t>(cstring.length()) };
         NPN_InitializeVariantWithStringCopy(result, &string);
index fdce0cb..a5cb9ee 100644 (file)
@@ -488,7 +488,7 @@ jobject JavaJSObject::convertValueToJObject(JSValue value) const
             result = env->NewObject (JSObjectClass, constructorID, (jdouble)value.toNumber(exec));
         }
     } else if (value.isString()) {
-        UString stringValue = value.toString(exec);
+        UString stringValue = value.toString(exec)->value(exec);
         JNIEnv *env = getJNIEnv();
         result = env->NewString ((const jchar *)stringValue.characters(), stringValue.length());
     } else if (value.isBoolean()) {
index 3030e49..9872da8 100644 (file)
@@ -63,7 +63,7 @@ static jobject convertArrayInstanceToJavaArray(ExecState* exec, JSArray* jsArray
                     env->NewStringUTF(""));
                 for (unsigned i = 0; i < length; i++) {
                     JSValue item = jsArray->get(exec, i);
-                    UString stringValue = item.toString(exec);
+                    UString stringValue = item.toString(exec)->value(exec);
                     env->SetObjectArrayElement(jarray, i,
                         env->functions->NewString(env, (const jchar *)stringValue.characters(), stringValue.length()));
                 }
@@ -98,7 +98,7 @@ static jobject convertArrayInstanceToJavaArray(ExecState* exec, JSArray* jsArray
             jarray = (jobjectArray)env->NewCharArray(length);
             for (unsigned i = 0; i < length; i++) {
                 JSValue item = jsArray->get(exec, i);
-                UString stringValue = item.toString(exec);
+                UString stringValue = item.toString(exec)->value(exec);
                 jchar value = 0;
                 if (stringValue.length() > 0)
                     value = ((const jchar*)stringValue.characters())[0];
@@ -249,7 +249,7 @@ jvalue convertValueToJValue(ExecState* exec, RootObject* rootObject, JSValue val
             // converting from a null.
             if (!result.l && !strcmp(javaClassName, "java.lang.String")) {
                 if (!value.isNull()) {
-                    UString stringValue = value.toString(exec);
+                    UString stringValue = value.toString(exec)->value(exec);
                     JNIEnv* env = getJNIEnv();
                     jobject javaString = env->functions->NewString(env, (const jchar*)stringValue.characters(), stringValue.length());
                     result.l = javaString;
index 84c42bf..1ebf1e6 100644 (file)
@@ -85,7 +85,7 @@ jvalue JavaField::dispatchValueFromInstance(ExecState* exec, const JavaInstance*
                 args[0].l = jinstance;
                 dispatchJNICall(exec, rootObject->nativeHandle(), fieldJInstance, false, returnType, mid, args, result, 0, exceptionDescription);
                 if (exceptionDescription)
-                    throwError(exec, createError(exec, exceptionDescription.toString(exec)));
+                    throwError(exec, createError(exec, exceptionDescription.toString(exec)->value(exec)));
             }
         }
     }
@@ -147,7 +147,7 @@ JSValue JavaField::valueFromInstance(ExecState* exec, const Instance* i) const
         break;
     }
 
-    LOG(LiveConnect, "JavaField::valueFromInstance getting %s = %s", UString(name().impl()).utf8().data(), jsresult.toString(exec).ascii().data());
+    LOG(LiveConnect, "JavaField::valueFromInstance getting %s = %s", UString(name().impl()).utf8().data(), jsresult.toString(exec)->value(exec).ascii().data());
 
     return jsresult;
 }
@@ -172,7 +172,7 @@ void JavaField::dispatchSetValueToInstance(ExecState* exec, const JavaInstance*
                 args[1] = javaValue;
                 dispatchJNICall(exec, rootObject->nativeHandle(), fieldJInstance, false, JavaTypeVoid, mid, args, result, 0, exceptionDescription);
                 if (exceptionDescription)
-                    throwError(exec, createError(exec, exceptionDescription.toString(exec)));
+                    throwError(exec, createError(exec, exceptionDescription.toString(exec)->value(exec)));
             }
         }
     }
@@ -183,7 +183,7 @@ void JavaField::setValueToInstance(ExecState* exec, const Instance* i, JSValue a
     const JavaInstance* instance = static_cast<const JavaInstance*>(i);
     jvalue javaValue = convertValueToJValue(exec, i->rootObject(), aValue, m_type, typeClassName());
 
-    LOG(LiveConnect, "JavaField::setValueToInstance setting value %s to %s", UString(name().impl()).utf8().data(), aValue.toString(exec).ascii().data());
+    LOG(LiveConnect, "JavaField::setValueToInstance setting value %s to %s", UString(name().impl()).utf8().data(), aValue.toString(exec)->value(exec).ascii().data());
 
     switch (m_type) {
     case JavaTypeArray:
index 7edac1c..c942719 100644 (file)
@@ -194,7 +194,7 @@ JSValue JavaInstance::invokeMethod(ExecState* exec, RuntimeMethod* runtimeMethod
     for (i = 0; i < count; i++) {
         CString javaClassName = jMethod->parameterAt(i).utf8();
         jArgs[i] = convertValueToJValue(exec, m_rootObject.get(), exec->argument(i), javaTypeFromClassName(javaClassName.data()), javaClassName.data());
-        LOG(LiveConnect, "JavaInstance::invokeMethod arg[%d] = %s", i, exec->argument(i).toString(exec).ascii().data());
+        LOG(LiveConnect, "JavaInstance::invokeMethod arg[%d] = %s", i, exec->argument(i).toString(exec)->value(exec).ascii().data());
     }
 
     jvalue result;
@@ -214,7 +214,7 @@ JSValue JavaInstance::invokeMethod(ExecState* exec, RuntimeMethod* runtimeMethod
         jmethodID methodId = getMethodID(obj, jMethod->name().utf8().data(), jMethod->signature());
         handled = dispatchJNICall(exec, rootObject->nativeHandle(), obj, jMethod->isStatic(), jMethod->returnType(), methodId, jArgs.data(), result, callingURL, exceptionDescription);
         if (exceptionDescription) {
-            throwError(exec, createError(exec, exceptionDescription.toString(exec)));
+            throwError(exec, createError(exec, exceptionDescription.toString(exec)->value(exec)));
             return jsUndefined();
         }
     }
index ac61986..7022c02 100644 (file)
@@ -343,7 +343,7 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue value, QMetaType::Type
                 else
                     dist = 6;
             } else {
-                UString str = value.toString(exec);
+                UString str = value.toString(exec)->value(exec);
                 ret = QVariant(QChar(str.length() ? *(const ushort*)str.impl()->characters() : 0));
                 if (type == String)
                     dist = 3;
@@ -358,7 +358,7 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue value, QMetaType::Type
                     *distance = 1;
                 return QString();
             } else {
-                UString ustring = value.toString(exec);
+                UString ustring = value.toString(exec)->value(exec);
                 ret = QVariant(QString((const QChar*)ustring.impl()->characters(), ustring.length()));
                 if (type == String)
                     dist = 0;
@@ -439,7 +439,7 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue value, QMetaType::Type
                 int len = rtarray->getLength();
                 for (int i = 0; i < len; ++i) {
                     JSValue val = rtarray->getConcreteArray()->valueAt(exec, i);
-                    UString ustring = val.toString(exec);
+                    UString ustring = val.toString(exec)->value(exec);
                     QString qstring = QString((const QChar*)ustring.impl()->characters(), ustring.length());
 
                     result.append(qstring);
@@ -453,7 +453,7 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue value, QMetaType::Type
                 int len = array->length();
                 for (int i = 0; i < len; ++i) {
                     JSValue val = array->get(exec, i);
-                    UString ustring = val.toString(exec);
+                    UString ustring = val.toString(exec)->value(exec);
                     QString qstring = QString((const QChar*)ustring.impl()->characters(), ustring.length());
 
                     result.append(qstring);
@@ -462,7 +462,7 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue value, QMetaType::Type
                 ret = QVariant(result);
             } else {
                 // Make a single length array
-                UString ustring = value.toString(exec);
+                UString ustring = value.toString(exec)->value(exec);
                 QString qstring = QString((const QChar*)ustring.impl()->characters(), ustring.length());
                 QStringList result;
                 result.append(qstring);
@@ -478,7 +478,7 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue value, QMetaType::Type
                 ret = QVariant(QByteArray(reinterpret_cast<const char*>(arr->data()), arr->length()));
                 dist = 0;
             } else {
-                UString ustring = value.toString(exec);
+                UString ustring = value.toString(exec)->value(exec);
                 ret = QVariant(QString((const QChar*)ustring.impl()->characters(), ustring.length()).toLatin1());
                 if (type == String)
                     dist = 5;
@@ -521,7 +521,7 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue value, QMetaType::Type
                 }
 #ifndef QT_NO_DATESTRING
             } else if (type == String) {
-                UString ustring = value.toString(exec);
+                UString ustring = value.toString(exec)->value(exec);
                 QString qstring = QString((const QChar*)ustring.impl()->characters(), ustring.length());
 
                 if (hint == QMetaType::QDateTime) {
@@ -571,7 +571,7 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue value, QMetaType::Type
                 RegExpObject *re = static_cast<RegExpObject*>(object);
 */
                 // Attempt to convert.. a bit risky
-                UString ustring = value.toString(exec);
+                UString ustring = value.toString(exec)->value(exec);
                 QString qstring = QString((const QChar*)ustring.impl()->characters(), ustring.length());
 
                 // this is of the form '/xxxxxx/i'
@@ -591,7 +591,7 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue value, QMetaType::Type
                     qConvDebug() << "couldn't parse a JS regexp";
                 }
             } else if (type == String) {
-                UString ustring = value.toString(exec);
+                UString ustring = value.toString(exec)->value(exec);
                 QString qstring = QString((const QChar*)ustring.impl()->characters(), ustring.length());
 
                 QRegExp re(qstring);
@@ -1599,7 +1599,7 @@ EncodedJSValue QtRuntimeConnectionMethod::call(ExecState* exec)
                         funcObject = asObj;
                     } else {
                         // Convert it to a string
-                        UString funcName = exec->argument(1).toString(exec);
+                        UString funcName = exec->argument(1).toString(exec)->value(exec);
                         Identifier funcIdent(exec, funcName);
 
                         // ### DropAllLocks
index 2f5b1ae..fe9fc1b 100644 (file)
@@ -391,7 +391,7 @@ int main(int argc, char **argv)
                 
                 if (comp.complType() == Throw) {
                     Value exVal = comp.value();
-                    char *msg = exVal.toString(exec).ascii();
+                    char* msg = exVal.toString(exec)->value(exec).ascii();
                     int lineno = -1;
                     if (exVal.type() == ObjectType) {
                         Value lineVal = Object::dynamicCast(exVal).get(exec,Identifier("line"));
index d7bc096..609f5cb 100644 (file)
@@ -114,7 +114,7 @@ int main(int argc, char** argv)
             if (comp.complType() == Throw) {
                 qDebug() << "exception thrown";
                 JSValue* exVal = comp.value();
-                char* msg = exVal->toString(exec).ascii();
+                char* msg = exVal->toString(exec)->value(exec).ascii();
                 int lineno = -1;
                 if (exVal->type() == ObjectType) {
                     JSValue* lineVal = exVal->getObject()->get(exec, Identifier("line"));
index 39f9fb7..0002319 100644 (file)
@@ -56,7 +56,7 @@ void JSInternals::setUserPreferredLanguages(ExecState* exec, JSValue value)
     Vector<String> languages;
     JSArray* array = asArray(value);
     for (unsigned i = 0; i < array->length(); ++i) {
-        String language = ustringToString(array->getIndex(i).toString(exec));
+        String language = ustringToString(array->getIndex(i).toString(exec)->value(exec));
         languages.append(language);
     }
     
index 11b2af6..961fa0b 100644 (file)
@@ -436,7 +436,8 @@ char* ewk_frame_script_execute(Evas_Object* ewkFrame, const char* script)
         return 0;
 
     JSC::JSLock lock(JSC::SilenceAssertionsOnly);
-    resultString = WebCore::ustringToString(result.toString(smartData->frame->script()->globalObject(WebCore::mainThreadNormalWorld())->globalExec()));
+    JSC::ExecState* exec = smartData->frame->script()->globalObject(WebCore::mainThreadNormalWorld())->globalExec();
+    resultString = WebCore::ustringToString(result.toString(exec)->value(exec));
     return strdup(resultString.utf8().data());
 #else
     notImplemented();
index 0c67530..26407bf 100644 (file)
@@ -1,3 +1,20 @@
+2012-01-23  Geoffrey Garen  <ggaren@apple.com>
+
+        JSValue::toString() should return a JSString* instead of a UString
+        https://bugs.webkit.org/show_bug.cgi?id=76861
+
+        Reviewed by Gavin Barraclough.
+
+        Mechanical changes to call value() after calling toString(), to
+        convert from "JS string" (JSString*) to "C++ string" (UString), since
+        toString() no longer returns a "C++ string".
+
+        * Plugins/Hosted/NetscapePluginInstanceProxy.mm:
+        (WebKit::NetscapePluginInstanceProxy::addValueToArray):
+        * WebView/WebFrame.mm:
+        (-[WebFrame _stringByEvaluatingJavaScriptFromString:forceUserGesture:]):
+        (-[WebFrame _stringByEvaluatingJavaScriptFromString:withGlobalObject:inScriptWorld:]):
+
 2012-01-20  Sam Weinig  <sam@webkit.org>
 
         Make WebCore RunLoop work for WebKit1
index 1537f39..7248f46 100644 (file)
@@ -1258,7 +1258,7 @@ void NetscapePluginInstanceProxy::addValueToArray(NSMutableArray *array, ExecSta
 
     if (value.isString()) {
         [array addObject:[NSNumber numberWithInt:StringValueType]];
-        [array addObject:ustringToString(value.toString(exec))];
+        [array addObject:ustringToString(value.toString(exec)->value(exec))];
     } else if (value.isNumber()) {
         [array addObject:[NSNumber numberWithInt:DoubleValueType]];
         [array addObject:[NSNumber numberWithDouble:value.toNumber(exec)]];
index 0b56862..c034354 100644 (file)
@@ -613,7 +613,8 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
         return @"";
 
     JSLock lock(SilenceAssertionsOnly);
-    return ustringToString(result.toString(_private->coreFrame->script()->globalObject(mainThreadNormalWorld())->globalExec()));
+    JSC::ExecState* exec = _private->coreFrame->script()->globalObject(mainThreadNormalWorld())->globalExec();
+    return ustringToString(result.toString(exec)->value(exec));
 }
 
 - (NSRect)_caretRectAtPosition:(const Position&)pos affinity:(NSSelectionAffinity)affinity
@@ -1191,7 +1192,8 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
         return @"";
 
     JSLock lock(SilenceAssertionsOnly);
-    return ustringToString(result.toString(anyWorldGlobalObject->globalExec()));
+    JSC::ExecState* exec = anyWorldGlobalObject->globalExec();
+    return ustringToString(result.toString(exec)->value(exec));
 }
 
 - (JSGlobalContextRef)_globalContextForScriptWorld:(WebScriptWorld *)world
index 17bc731..f15d3ef 100644 (file)
@@ -2604,7 +2604,8 @@ HRESULT WebFrame::stringByEvaluatingJavaScriptInScriptWorld(IWebScriptWorld* iWo
         return S_OK;
 
     JSLock lock(SilenceAssertionsOnly);
-    String resultString = ustringToString(result.toString(anyWorldGlobalObject->globalExec()));
+    JSC::ExecState* exec = anyWorldGlobalObject->globalExec();
+    String resultString = ustringToString(result.toString(exec)->value(exec));
     *evaluationResult = BString(resultString).release();
 
     return S_OK;
index 476cbec..3b8aa48 100644 (file)
@@ -1,3 +1,17 @@
+2012-01-23  Geoffrey Garen  <ggaren@apple.com>
+
+        JSValue::toString() should return a JSString* instead of a UString
+        https://bugs.webkit.org/show_bug.cgi?id=76861
+
+        Reviewed by Gavin Barraclough.
+
+        Mechanical changes to call value() after calling toString(), to
+        convert from "JS string" (JSString*) to "C++ string" (UString), since
+        toString() no longer returns a "C++ string".
+
+        * WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp:
+        (WebKit::NPRuntimeObjectMap::convertJSValueToNPVariant):
+
 2012-01-23  Jesus Sanchez-Palencia  <jesus.palencia@openbossa.org>
 
         [Qt][WK2] QQuickWebView is initializing touch mode twice while being constructed
index 5aadd13..b4657f9 100644 (file)
@@ -163,7 +163,7 @@ void NPRuntimeObjectMap::convertJSValueToNPVariant(ExecState* exec, JSValue valu
     }
 
     if (value.isString()) {
-        NPString npString = createNPString(value.toString(exec).utf8());
+        NPString npString = createNPString(value.toString(exec)->value(exec).utf8());
         STRINGN_TO_NPVARIANT(npString.UTF8Characters, npString.UTF8Length, variant);
         return;
     }