Changeset 95516 in webkit


Ignore:
Timestamp:
Sep 19, 2011 9:33:10 PM (13 years ago)
Author:
mhahnenberg@apple.com
Message:

Remove toPrimitive from JSCell
https://bugs.webkit.org/show_bug.cgi?id=67875

Reviewed by Darin Adler.

Part of the refactoring process to un-virtualize JSCell. We move
all of the implicit functionality provided by the virtual toPrimitive method
in JSCell to be explicit in JSValue::toPrimitive and JSCell:toPrimitive while
also de-virtualizing JSCell::toPrimitive.

  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
  • runtime/JSCell.cpp:

(JSC::JSCell::toPrimitive):

  • runtime/JSCell.h:

We replace JSNotAnObject::toPrimitive with defaultValue, which it overrides from
JSObject. This pushes the virtual method further down, enabling us to get rid
of the virtual call in JSCell. Eventually we'll probably have to deal with this
again, but we'll cross that bridge when we come to it.

  • runtime/JSNotAnObject.cpp:

(JSC::JSNotAnObject::defaultValue):

  • runtime/JSNotAnObject.h:
  • runtime/JSObject.h:
  • runtime/JSString.h:
Location:
trunk/Source/JavaScriptCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r95512 r95516  
     12011-09-19  Mark Hahnenberg  <mhahnenberg@apple.com>
     2
     3        Remove toPrimitive from JSCell
     4        https://bugs.webkit.org/show_bug.cgi?id=67875
     5
     6        Reviewed by Darin Adler.
     7
     8        Part of the refactoring process to un-virtualize JSCell.  We move
     9        all of the implicit functionality provided by the virtual toPrimitive method
     10        in JSCell to be explicit in JSValue::toPrimitive and JSCell:toPrimitive while
     11        also de-virtualizing JSCell::toPrimitive.
     12
     13        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
     14        * runtime/JSCell.cpp:
     15        (JSC::JSCell::toPrimitive):
     16        * runtime/JSCell.h:
     17
     18        We replace JSNotAnObject::toPrimitive with defaultValue, which it overrides from
     19        JSObject.  This pushes the virtual method further down, enabling us to get rid
     20        of the virtual call in JSCell.  Eventually we'll probably have to deal with this
     21        again, but we'll cross that bridge when we come to it.
     22        * runtime/JSNotAnObject.cpp:
     23        (JSC::JSNotAnObject::defaultValue):
     24        * runtime/JSNotAnObject.h:
     25        * runtime/JSObject.h:
     26        * runtime/JSString.h:
     27
    1282011-09-19  Geoffrey Garen  <ggaren@apple.com>
    229
  • trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def

    r95507 r95516  
    357357    ?toObject@JSObject@JSC@@UBEPAV12@PAVExecState@2@PAVJSGlobalObject@2@@Z
    358358    ?toObjectSlowCase@JSValue@JSC@@ABEPAVJSObject@2@PAVExecState@2@PAVJSGlobalObject@2@@Z
    359     ?toPrimitive@JSCell@JSC@@UBE?AVJSValue@2@PAVExecState@2@W4PreferredPrimitiveType@2@@Z
    360     ?toPrimitive@JSString@JSC@@EBE?AVJSValue@2@PAVExecState@2@W4PreferredPrimitiveType@2@@Z
    361359    ?toStrictThisObject@JSObject@JSC@@UBE?AVJSValue@2@PAVExecState@2@@Z
    362360    ?toString@JSCell@JSC@@UBE?AVUString@2@PAVExecState@2@@Z
  • trunk/Source/JavaScriptCore/runtime/JSCell.cpp

    r95475 r95516  
    118118}
    119119
    120 JSValue JSCell::toPrimitive(ExecState*, PreferredPrimitiveType) const
     120JSValue JSCell::toPrimitive(ExecState* exec, PreferredPrimitiveType preferredType) const
    121121{
    122     ASSERT_NOT_REACHED();
    123     return JSValue();
     122    if (isString())
     123        return static_cast<const JSString*>(this)->toPrimitive(exec, preferredType);
     124    return static_cast<const JSObject*>(this)->toPrimitive(exec, preferredType);
    124125}
    125126
  • trunk/Source/JavaScriptCore/runtime/JSCell.h

    r95503 r95516  
    7878
    7979        // Basic conversions.
    80         virtual JSValue toPrimitive(ExecState*, PreferredPrimitiveType) const;
     80        JSValue toPrimitive(ExecState*, PreferredPrimitiveType) const;
    8181        virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue&);
    8282        virtual bool toBoolean(ExecState*) const;
  • trunk/Source/JavaScriptCore/runtime/JSNotAnObject.cpp

    r95475 r95516  
    3838
    3939// JSValue methods
    40 JSValue JSNotAnObject::toPrimitive(ExecState* exec, PreferredPrimitiveType) const
     40JSValue JSNotAnObject::defaultValue(ExecState* exec, PreferredPrimitiveType) const
    4141{
    4242    ASSERT_UNUSED(exec, exec->hadException());
  • trunk/Source/JavaScriptCore/runtime/JSNotAnObject.h

    r95475 r95516  
    6464
    6565        // JSValue methods
    66         virtual JSValue toPrimitive(ExecState*, PreferredPrimitiveType) const;
     66        virtual JSValue defaultValue(ExecState*, PreferredPrimitiveType) const;
    6767        virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue&);
    6868        virtual bool toBoolean(ExecState*) const;
  • trunk/Source/JavaScriptCore/runtime/JSObject.h

    r95503 r95516  
    132132        virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
    133133
    134         virtual JSValue toPrimitive(ExecState*, PreferredPrimitiveType = NoPreference) const;
     134        JSValue toPrimitive(ExecState*, PreferredPrimitiveType = NoPreference) const;
    135135        virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue& value);
    136136        virtual bool toBoolean(ExecState*) const;
  • trunk/Source/JavaScriptCore/runtime/JSString.h

    r95475 r95516  
    427427        unsigned length() { return m_length; }
    428428
     429        JSValue toPrimitive(ExecState*, PreferredPrimitiveType) const;
    429430        bool getStringPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
    430431        bool getStringPropertySlot(ExecState*, unsigned propertyName, PropertySlot&);
     
    493494        }
    494495
    495         virtual JSValue toPrimitive(ExecState*, PreferredPrimitiveType) const;
    496496        virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue& value);
    497497        virtual bool toBoolean(ExecState*) const;
Note: See TracChangeset for help on using the changeset viewer.