Changeset 96143 in webkit


Ignore:
Timestamp:
Sep 27, 2011 12:53:49 PM (13 years ago)
Author:
mhahnenberg@apple.com
Message:

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

Reviewed by Darin Adler.

Changed JSCell::getPrimitiveNumber to manually handle the dispatch for
JSCells (JSObject and JSString in this case).

  • runtime/JSCell.cpp:

(JSC::JSCell::getPrimitiveNumber):

  • runtime/JSCell.h:

Removed JSNotAnObject::getPrimitiveNumber since its return value doesn't
matter and it already implements defaultValue, so JSObject::getPrimitiveNumber
can cover the case for JSNotAnObject.

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

De-virtualized JSObject::getPrimitiveNumber and JSString::getPrimitiveNumber
and changed them to be const. Also made JSString::getPrimitiveNumber public
because it needs to be called from JSCell::getPrimitiveNumber and also since it's
no longer virtual, we want people who have a more specific pointer (JSString*
instead of JSCell*) to not have to pay the cost of a virtual method call.

  • runtime/JSObject.cpp:

(JSC::JSObject::getPrimitiveNumber):

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

(JSC::JSString::getPrimitiveNumber):

  • runtime/JSString.h:
Location:
trunk/Source/JavaScriptCore
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r96131 r96143  
     12011-09-27  Mark Hahnenberg  <mhahnenberg@apple.com>
     2
     3        De-virtualize JSCell::getPrimitiveNumber
     4        https://bugs.webkit.org/show_bug.cgi?id=68851
     5
     6        Reviewed by Darin Adler.
     7
     8        * JavaScriptCore.exp:
     9        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
     10
     11        Changed JSCell::getPrimitiveNumber to manually handle the dispatch for
     12        JSCells (JSObject and JSString in this case).
     13        * runtime/JSCell.cpp:
     14        (JSC::JSCell::getPrimitiveNumber):
     15        * runtime/JSCell.h:
     16
     17        Removed JSNotAnObject::getPrimitiveNumber since its return value doesn't
     18        matter and it already implements defaultValue, so JSObject::getPrimitiveNumber
     19        can cover the case for JSNotAnObject.
     20        * runtime/JSNotAnObject.cpp:
     21        * runtime/JSNotAnObject.h:
     22
     23        De-virtualized JSObject::getPrimitiveNumber and JSString::getPrimitiveNumber
     24        and changed them to be const.  Also made JSString::getPrimitiveNumber public
     25        because it needs to be called from JSCell::getPrimitiveNumber and also since it's
     26        no longer virtual, we want people who have a more specific pointer (JSString*
     27        instead of JSCell*) to not have to pay the cost of a virtual method call.
     28        * runtime/JSObject.cpp:
     29        (JSC::JSObject::getPrimitiveNumber):
     30        * runtime/JSObject.h:
     31        * runtime/JSString.cpp:
     32        (JSC::JSString::getPrimitiveNumber):
     33        * runtime/JSString.h:
     34
    1352011-09-27  Juan Carlos Montemayor Elosua  <j.mont@me.com>
    236
  • trunk/Source/JavaScriptCore/JavaScriptCore.exp

    r96131 r96143  
    260260__ZN3JSC6JSCell18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE
    261261__ZN3JSC6JSCell18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE
    262 __ZN3JSC6JSCell18getPrimitiveNumberEPNS_9ExecStateERdRNS_7JSValueE
    263262__ZN3JSC6JSCell3putEPNS_9ExecStateERKNS_10IdentifierENS_7JSValueERNS_15PutPropertySlotE
    264263__ZN3JSC6JSCell3putEPNS_9ExecStateEjNS_7JSValueE 
     
    323322__ZN3JSC8JSObject17putWithAttributesEPNS_9ExecStateEjNS_7JSValueEj
    324323__ZN3JSC8JSObject18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE
    325 __ZN3JSC8JSObject18getPrimitiveNumberEPNS_9ExecStateERdRNS_7JSValueE
    326324__ZN3JSC8JSObject19getOwnPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayENS_15EnumerationModeE
    327325__ZN3JSC8JSObject20visitChildrenVirtualERNS_11SlotVisitorE
  • trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def

    r96131 r96143  
    206206    ?getOwnPropertySlot@StringObject@JSC@@UAE_NPAVExecState@2@ABVIdentifier@2@AAVPropertySlot@2@@Z
    207207    ?getOwnPropertySlot@StringObject@JSC@@UAE_NPAVExecState@2@IAAVPropertySlot@2@@Z
    208     ?getPrimitiveNumber@JSCell@JSC@@UAE_NPAVExecState@2@AANAAVJSValue@2@@Z
    209     ?getPrimitiveNumber@JSObject@JSC@@UAE_NPAVExecState@2@AANAAVJSValue@2@@Z
    210     ?getPrimitiveNumber@JSString@JSC@@EAE_NPAVExecState@2@AANAAVJSValue@2@@Z
    211208    ?getPropertyDescriptor@JSObject@JSC@@QAE_NPAVExecState@2@ABVIdentifier@2@AAVPropertyDescriptor@2@@Z
    212209    ?getPropertyNames@JSObject@JSC@@UAEXPAVExecState@2@AAVPropertyNameArray@2@W4EnumerationMode@2@@Z
  • trunk/Source/JavaScriptCore/runtime/JSCell.cpp

    r96045 r96143  
    128128}
    129129
    130 bool JSCell::getPrimitiveNumber(ExecState*, double&, JSValue&)
     130bool JSCell::getPrimitiveNumber(ExecState* exec, double& number, JSValue& value) const
    131131{
    132     ASSERT_NOT_REACHED();
    133     return false;
     132    if (isString())
     133        return static_cast<const JSString*>(this)->getPrimitiveNumber(exec, number, value);
     134    return static_cast<const JSObject*>(this)->getPrimitiveNumber(exec, number, value);
    134135}
    135136
  • trunk/Source/JavaScriptCore/runtime/JSCell.h

    r96045 r96143  
    7979        // Basic conversions.
    8080        JSValue toPrimitive(ExecState*, PreferredPrimitiveType) const;
    81         virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue&);
     81        bool getPrimitiveNumber(ExecState*, double& number, JSValue&) const;
    8282        bool toBoolean(ExecState*) const;
    8383        virtual double toNumber(ExecState*) const;
  • trunk/Source/JavaScriptCore/runtime/JSNotAnObject.cpp

    r96045 r96143  
    4242    ASSERT_UNUSED(exec, exec->hadException());
    4343    return jsNumber(0);
    44 }
    45 
    46 bool JSNotAnObject::getPrimitiveNumber(ExecState* exec, double&, JSValue&)
    47 {
    48     ASSERT_UNUSED(exec, exec->hadException());
    49     return false;
    5044}
    5145
  • trunk/Source/JavaScriptCore/runtime/JSNotAnObject.h

    r96045 r96143  
    6565        // JSValue methods
    6666        virtual JSValue defaultValue(ExecState*, PreferredPrimitiveType) const;
    67         virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue&);
    6867        virtual double toNumber(ExecState*) const;
    6968        virtual UString toString(ExecState*) const;
  • trunk/Source/JavaScriptCore/runtime/JSObject.cpp

    r95936 r96143  
    289289}
    290290
    291 bool JSObject::getPrimitiveNumber(ExecState* exec, double& number, JSValue& result)
     291bool JSObject::getPrimitiveNumber(ExecState* exec, double& number, JSValue& result) const
    292292{
    293293    result = defaultValue(exec, PreferNumber);
  • trunk/Source/JavaScriptCore/runtime/JSObject.h

    r96045 r96143  
    134134
    135135        JSValue toPrimitive(ExecState*, PreferredPrimitiveType = NoPreference) const;
    136         virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue& value);
    137136        bool toBoolean(ExecState*) const;
     137        bool getPrimitiveNumber(ExecState*, double& number, JSValue&) const;
    138138        virtual double toNumber(ExecState*) const;
    139139        virtual UString toString(ExecState*) const;
  • trunk/Source/JavaScriptCore/runtime/JSString.cpp

    r95936 r96143  
    275275}
    276276
    277 bool JSString::getPrimitiveNumber(ExecState* exec, double& number, JSValue& result)
     277bool JSString::getPrimitiveNumber(ExecState* exec, double& number, JSValue& result) const
    278278{
    279279    result = this;
  • trunk/Source/JavaScriptCore/runtime/JSString.h

    r96045 r96143  
    429429        JSValue toPrimitive(ExecState*, PreferredPrimitiveType) const;
    430430        bool toBoolean(ExecState*) const;
     431        bool getPrimitiveNumber(ExecState*, double& number, JSValue&) const;
    431432       
    432433        bool getStringPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
     
    496497        }
    497498
    498         virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue& value);
    499499        virtual double toNumber(ExecState*) const;
    500500        virtual JSObject* toObject(ExecState*, JSGlobalObject*) const;
Note: See TracChangeset for help on using the changeset viewer.