Ignore:
Timestamp:
Oct 12, 2011, 1:23:08 PM (14 years ago)
Author:
[email protected]
Message:

De-virtualize JSCell::toString
https://bugs.webkit.org/show_bug.cgi?id=69677

Reviewed by Sam Weinig.

Source/JavaScriptCore:

Removed toString from JSCallbackObject, since it is no
longer necessary since we now implicitly add toString and valueOf
functions to object prototypes when a convertToType callback
is provided, which is now the standard way to override toString
and valueOf in the JSC C API.

  • API/JSCallbackObject.h:
  • API/JSCallbackObjectFunctions.h:
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:

Removed toString from InterruptedExecutionError and
TerminatedExecutionError and replaced it with defaultValue,
which JSObject::toString calls. We'll probably have to de-virtualize
defaultValue eventually, but we'll cross that bridge when we
come to it.

  • runtime/ExceptionHelpers.cpp:

(JSC::InterruptedExecutionError::defaultValue):
(JSC::TerminatedExecutionError::defaultValue):

  • runtime/ExceptionHelpers.h:

Removed toString from JSNotAnObject, since its return value doesn't
actually matter and JSObject::toString can cover it.

  • runtime/JSNotAnObject.cpp:
  • runtime/JSNotAnObject.h:

De-virtualized JSCell::toString, JSObject::toString and JSString::toString.
Added handling of all cases for JSCell to JSCell::toString.

  • runtime/JSObject.h:
  • runtime/JSString.h:
  • runtime/JSCell.cpp:

(JSC::JSCell::toString):

  • runtime/JSCell.h:

Source/JavaScriptGlue:

Removed UserObjectImp::toString because it's no longer necessary since
clients can provide their own toString callback which will in turn be
called by JSObject::toString.

  • UserObjectImp.cpp:
  • UserObjectImp.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/JSCallbackObjectFunctions.h

    r97097 r97292  
    515515
    516516template <class Parent>
    517 UString JSCallbackObject<Parent>::toString(ExecState* exec) const
    518 {
    519     JSContextRef ctx = toRef(exec);
    520     JSObjectRef thisRef = toRef(this);
    521    
    522     for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass)
    523         if (JSObjectConvertToTypeCallback convertToType = jsClass->convertToType) {
    524             JSValueRef exception = 0;
    525             JSValueRef value;
    526             {
    527                 APICallbackShim callbackShim(exec);
    528                 value = convertToType(ctx, thisRef, kJSTypeString, &exception);
    529             }
    530             if (exception) {
    531                 throwError(exec, toJS(exec, exception));
    532                 return "";
    533             }
    534             if (value)
    535                 return toJS(exec, value).getString(exec);
    536         }
    537            
    538     return Parent::toString(exec);
    539 }
    540 
    541 template <class Parent>
    542517void JSCallbackObject<Parent>::setPrivate(void* data)
    543518{
Note: See TracChangeset for help on using the changeset viewer.