Ignore:
Timestamp:
Oct 13, 2011, 12:24:53 PM (14 years ago)
Author:
[email protected]
Message:

De-virtualized JSCell::toNumber
https://bugs.webkit.org/show_bug.cgi?id=69858

Reviewed by Sam Weinig.

Source/JavaScriptCore:

Removed JSCallbackObject::toNumber because its no longer necessary since
JSObject::toNumber now suffices since we implicitly add valueOf to an object's
prototype whenever a convertToType callback is provided.

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

De-virtualized JSCell::toNumber, JSObject::toNumber, and JSString::toNumber.

  • runtime/JSCell.cpp:

(JSC::JSCell::toNumber):

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

Removed JSNotAnObject::toNumber because its result doesn't matter and it implements
defaultValue, therefore JSObject::toNumber can cover its case.

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

Source/JavaScriptGlue:

Removed UserObjectImp::toNumber because it's no longer necessary since
JSObject::toNumber can cover this case.

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

Legend:

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

    r97292 r97381  
    480480
    481481template <class Parent>
    482 double JSCallbackObject<Parent>::toNumber(ExecState* exec) const
    483 {
    484     // We need this check to guard against the case where this object is rhs of
    485     // a binary expression where lhs threw an exception in its conversion to
    486     // primitive
    487     if (exec->hadException())
    488         return std::numeric_limits<double>::quiet_NaN();
    489     JSContextRef ctx = toRef(exec);
    490     JSObjectRef thisRef = toRef(this);
    491    
    492     for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass)
    493         if (JSObjectConvertToTypeCallback convertToType = jsClass->convertToType) {
    494             JSValueRef exception = 0;
    495             JSValueRef value;
    496             {
    497                 APICallbackShim callbackShim(exec);
    498                 value = convertToType(ctx, thisRef, kJSTypeNumber, &exception);
    499             }
    500             if (exception) {
    501                 throwError(exec, toJS(exec, exception));
    502                 return 0;
    503             }
    504             if (!value)
    505                 continue;
    506                
    507             JSValue jsValue = toJS(exec, value);
    508             if (!jsValue.isNumber())
    509                 return std::numeric_limits<double>::quiet_NaN();
    510             return jsValue.asNumber();
    511         }
    512            
    513     return Parent::toNumber(exec);
    514 }
    515 
    516 template <class Parent>
    517482void JSCallbackObject<Parent>::setPrivate(void* data)
    518483{
Note: See TracChangeset for help on using the changeset viewer.