Changeset 96381 in webkit


Ignore:
Timestamp:
Sep 29, 2011 7:09:16 PM (13 years ago)
Author:
mhahnenberg@apple.com
Message:

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

Reviewed by Darin Adler.

De-virtualized JSCell::toObject and changed its implementation to manually check the
cases for JSString and JSObject rather than leaving it up to the virtual method call.

  • runtime/JSCell.cpp:

(JSC::JSCell::toObject):

  • runtime/JSCell.h:

Removed JSNotAnObject::toObject because the case for JSObject works for it.
Also removed JSObject::toObject because it was essentially the identity function,
which is not necessary since toObject is no longer virtual.

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

De-virtualized JSObject::toObject and JSString::toObject.

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

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r96379 r96381  
     12011-09-29  Mark Hahnenberg  <mhahnenberg@apple.com>
     2
     3        De-virtualize JSCell::toObject
     4        https://bugs.webkit.org/show_bug.cgi?id=68937
     5
     6        Reviewed by Darin Adler.
     7
     8        * JavaScriptCore.exp:
     9        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
     10
     11        De-virtualized JSCell::toObject and changed its implementation to manually check the
     12        cases for JSString and JSObject rather than leaving it up to the virtual method call.
     13        * runtime/JSCell.cpp:
     14        (JSC::JSCell::toObject):
     15        * runtime/JSCell.h:
     16
     17        Removed JSNotAnObject::toObject because the case for JSObject works for it.
     18        Also removed JSObject::toObject because it was essentially the identity function,
     19        which is not necessary since toObject is no longer virtual.
     20        * runtime/JSNotAnObject.cpp:
     21        * runtime/JSNotAnObject.h:
     22        * runtime/JSObject.cpp:
     23        * runtime/JSObject.h:
     24
     25        De-virtualized JSObject::toObject and JSString::toObject.
     26        * runtime/JSString.h:
     27
    1282011-09-29  Gavin Barraclough  <barraclough@apple.com>
    229
  • trunk/Source/JavaScriptCore/JavaScriptCore.exp

    r96346 r96381  
    574574__ZNK3JSC8JSObject18toStrictThisObjectEPNS_9ExecStateE
    575575__ZNK3JSC8JSObject8toNumberEPNS_9ExecStateE
    576 __ZNK3JSC8JSObject8toObjectEPNS_9ExecStateEPNS_14JSGlobalObjectE
    577576__ZNK3JSC8JSObject8toStringEPNS_9ExecStateE
    578577__ZNK3JSC8JSObject9classNameEv
  • trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def

    r96346 r96381  
    345345    ?toNumber@JSString@JSC@@EBENPAVExecState@2@@Z
    346346    ?toNumberSlowCase@JSValue@JSC@@ABENPAVExecState@2@@Z
    347     ?toObject@JSCell@JSC@@UBEPAVJSObject@2@PAVExecState@2@PAVJSGlobalObject@2@@Z
    348     ?toObject@JSObject@JSC@@UBEPAV12@PAVExecState@2@PAVJSGlobalObject@2@@Z
     347    ?toObject@JSCell@JSC@@QBEPAVJSObject@2@PAVExecState@2@PAVJSGlobalObject@2@@Z
    349348    ?toObjectSlowCase@JSValue@JSC@@ABEPAVJSObject@2@PAVExecState@2@PAVJSGlobalObject@2@@Z
    350349    ?toStrictThisObject@JSObject@JSC@@UBE?AVJSValue@2@PAVExecState@2@@Z
  • trunk/Source/JavaScriptCore/runtime/JSCell.cpp

    r96164 r96381  
    152152}
    153153
    154 JSObject* JSCell::toObject(ExecState*, JSGlobalObject*) const
     154JSObject* JSCell::toObject(ExecState* exec, JSGlobalObject* globalObject) const
    155155{
    156     ASSERT_NOT_REACHED();
    157     return 0;
     156    if (isString())
     157        return static_cast<const JSString*>(this)->toObject(exec, globalObject);
     158    ASSERT(isObject());
     159    return static_cast<JSObject*>(const_cast<JSCell*>(this));
    158160}
    159161
  • trunk/Source/JavaScriptCore/runtime/JSCell.h

    r96346 r96381  
    8484        virtual double toNumber(ExecState*) const;
    8585        virtual UString toString(ExecState*) const;
    86         virtual JSObject* toObject(ExecState*, JSGlobalObject*) const;
     86        JSObject* toObject(ExecState*, JSGlobalObject*) const;
    8787
    8888        static void visitChildren(JSCell*, SlotVisitor&);
  • trunk/Source/JavaScriptCore/runtime/JSNotAnObject.cpp

    r96143 r96381  
    5656}
    5757
    58 JSObject* JSNotAnObject::toObject(ExecState* exec, JSGlobalObject*) const
    59 {
    60     ASSERT_UNUSED(exec, exec->hadException());
    61     return const_cast<JSNotAnObject*>(this);
    62 }
    63 
    6458// JSObject methods
    6559bool JSNotAnObject::getOwnPropertySlot(ExecState* exec, const Identifier&, PropertySlot&)
  • trunk/Source/JavaScriptCore/runtime/JSNotAnObject.h

    r96143 r96381  
    6767        virtual double toNumber(ExecState*) const;
    6868        virtual UString toString(ExecState*) const;
    69         virtual JSObject* toObject(ExecState*, JSGlobalObject*) const;
    7069
    7170        // JSObject methods
  • trunk/Source/JavaScriptCore/runtime/JSObject.cpp

    r96346 r96381  
    511511        return "";
    512512    return primitive.toString(exec);
    513 }
    514 
    515 JSObject* JSObject::toObject(ExecState*, JSGlobalObject*) const
    516 {
    517     return const_cast<JSObject*>(this);
    518513}
    519514
  • trunk/Source/JavaScriptCore/runtime/JSObject.h

    r96346 r96381  
    137137        virtual double toNumber(ExecState*) const;
    138138        virtual UString toString(ExecState*) const;
    139         virtual JSObject* toObject(ExecState*, JSGlobalObject*) const;
    140139
    141140        virtual JSObject* toThisObject(ExecState*) const;
     
    272271        using JSCell::isAPIValueWrapper;
    273272        using JSCell::isGetterSetter;
    274         using JSCell::toObject;
    275273        void getObject();
    276274        void getString(ExecState* exec);
  • trunk/Source/JavaScriptCore/runtime/JSString.h

    r96143 r96381  
    430430        bool toBoolean(ExecState*) const;
    431431        bool getPrimitiveNumber(ExecState*, double& number, JSValue&) const;
     432        JSObject* toObject(ExecState*, JSGlobalObject*) const;
    432433       
    433434        bool getStringPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
     
    498499
    499500        virtual double toNumber(ExecState*) const;
    500         virtual JSObject* toObject(ExecState*, JSGlobalObject*) const;
    501501        virtual UString toString(ExecState*) const;
    502502
Note: See TracChangeset for help on using the changeset viewer.