Changeset 95893 in webkit


Ignore:
Timestamp:
Sep 23, 2011 6:19:56 PM (13 years ago)
Author:
mhahnenberg@apple.com
Message:

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

Reviewed by Oliver Hunt.

Added a new JSType to check whether or not something is a
NumberObject (which includes NumberPrototype) in TypeInfo::isNumberObject because there's not
currently a better way to determine whether something is indeed a NumberObject.
Also de-virtualized JSCell::getJSNumber, having it check the TypeInfo
for whether the object is a NumberObject or not. This patch is part of
the larger process of de-virtualizing JSCell.

(JSC::JSCell::getJSNumber):

  • runtime/JSCell.h:

(JSC::JSValue::getJSNumber):

  • runtime/JSType.h:
  • runtime/JSTypeInfo.h:

(JSC::TypeInfo::isNumberObject):

  • runtime/JSValue.h:
  • runtime/NumberObject.cpp:

(JSC::NumberObject::getJSNumber):

  • runtime/NumberObject.h:

(JSC::NumberObject::createStructure):

  • runtime/NumberPrototype.h:

(JSC::NumberPrototype::createStructure):

Location:
trunk/Source/JavaScriptCore
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r95887 r95893  
     12011-09-23  Mark Hahnenberg  <mhahnenberg@apple.com>
     2
     3        De-virtualize JSCell::getJSNumber
     4        https://bugs.webkit.org/show_bug.cgi?id=68651
     5
     6        Reviewed by Oliver Hunt.
     7
     8        Added a new JSType to check whether or not something is a
     9        NumberObject (which includes NumberPrototype) in TypeInfo::isNumberObject because there's not
     10        currently a better way to determine whether something is indeed a NumberObject.
     11        Also de-virtualized JSCell::getJSNumber, having it check the TypeInfo
     12        for whether the object is a NumberObject or not.  This patch is part of
     13        the larger process of de-virtualizing JSCell.
     14
     15        * JavaScriptCore.exp:
     16        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
     17        * runtime/JSCell.cpp:
     18        (JSC::JSCell::getJSNumber):
     19        * runtime/JSCell.h:
     20        (JSC::JSValue::getJSNumber):
     21        * runtime/JSType.h:
     22        * runtime/JSTypeInfo.h:
     23        (JSC::TypeInfo::isNumberObject):
     24        * runtime/JSValue.h:
     25        * runtime/NumberObject.cpp:
     26        (JSC::NumberObject::getJSNumber):
     27        * runtime/NumberObject.h:
     28        (JSC::NumberObject::createStructure):
     29        * runtime/NumberPrototype.h:
     30        (JSC::NumberPrototype::createStructure):
     31
    1322011-09-23  Filip Pizlo  <fpizlo@apple.com>
    233
  • trunk/Source/JavaScriptCore/JavaScriptCore.exp

    r95865 r95893  
    254254__ZN3JSC4callEPNS_9ExecStateENS_7JSValueENS_8CallTypeERKNS_8CallDataES2_RKNS_7ArgListE
    255255__ZN3JSC6JSCell11getCallDataERNS_8CallDataE
    256 __ZN3JSC6JSCell11getJSNumberEv
    257256__ZN3JSC6JSCell14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
    258257__ZN3JSC6JSCell14deletePropertyEPNS_9ExecStateEj
  • trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def

    r95884 r95893  
    189189    ?getCallData@JSCell@JSC@@UAE?AW4CallType@2@AATCallData@2@@Z
    190190    ?getConstructData@JSCell@JSC@@UAE?AW4ConstructType@2@AATConstructData@2@@Z
    191     ?getJSNumber@JSCell@JSC@@UAE?AVJSValue@2@XZ
    192191    ?getObject@JSCell@JSC@@QAEPAVJSObject@2@XZ
    193192    ?getOwnPropertyDescriptor@JSGlobalObject@JSC@@UAE_NPAVExecState@2@ABVIdentifier@2@AAVPropertyDescriptor@2@@Z
  • trunk/Source/JavaScriptCore/runtime/JSCell.cpp

    r95516 r95893  
    2727#include "JSString.h"
    2828#include "JSObject.h"
     29#include "NumberObject.h"
    2930#include <wtf/MathExtras.h>
    3031
     
    113114}
    114115
    115 JSValue JSCell::getJSNumber()
     116JSValue JSCell::getJSNumber() const
    116117{
     118    if (structure()->typeInfo().isNumberObject())
     119        return static_cast<const NumberObject*>(this)->getJSNumber();
    117120    return JSValue();
    118121}
  • trunk/Source/JavaScriptCore/runtime/JSCell.h

    r95849 r95893  
    9696
    9797        virtual JSObject* toThisObject(ExecState*) const;
    98         virtual JSValue getJSNumber();
     98        JSValue getJSNumber() const;
    9999        void* vptr() { return *reinterpret_cast<void**>(this); }
    100100        void setVPtr(void* vptr) { *reinterpret_cast<void**>(this) = vptr; }
     
    315315    }
    316316
    317     inline JSValue JSValue::getJSNumber()
     317    inline JSValue JSValue::getJSNumber() const
    318318    {
    319319        if (isInt32() || isDouble())
  • trunk/Source/JavaScriptCore/runtime/JSType.h

    r95666 r95893  
    4242    FinalObjectType     = 11,
    4343    JSFunctionType      = 12,
     44    NumberObjectType    = 13,
    4445};
    4546
  • trunk/Source/JavaScriptCore/runtime/JSTypeInfo.h

    r95340 r95893  
    6565        bool isObject() const { return type() >= ObjectType; }
    6666        bool isFinalObject() const { return type() == FinalObjectType; }
     67        bool isNumberObject() const { return type() == NumberObjectType; }
    6768
    6869        bool masqueradesAsUndefined() const { return isSetOnFlags1(MasqueradesAsUndefined); }
  • trunk/Source/JavaScriptCore/runtime/JSValue.h

    r95214 r95893  
    216216        static bool strictEqualSlowCaseInline(ExecState* exec, JSValue v1, JSValue v2);
    217217
    218         JSValue getJSNumber(); // JSValue() if this is not a JSNumber or number object
     218        JSValue getJSNumber() const; // JSValue() if this is not a JSNumber or number object
    219219
    220220        bool isCell() const;
  • trunk/Source/JavaScriptCore/runtime/NumberObject.cpp

    r94875 r95893  
    4343}
    4444
    45 JSValue NumberObject::getJSNumber()
     45JSValue NumberObject::getJSNumber() const
    4646{
    4747    return internalValue();
  • trunk/Source/JavaScriptCore/runtime/NumberObject.h

    r94929 r95893  
    4545        static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue prototype)
    4646        {
    47             return Structure::create(globalData, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), &s_info);
     47            return Structure::create(globalData, globalObject, prototype, TypeInfo(NumberObjectType, StructureFlags), &s_info);
    4848        }
    4949
    50     private:
    51         virtual JSValue getJSNumber();
     50        JSValue getJSNumber() const;
    5251    };
    5352
  • trunk/Source/JavaScriptCore/runtime/NumberPrototype.h

    r95108 r95893  
    4141        static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue prototype)
    4242        {
    43             return Structure::create(globalData, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), &s_info);
     43            return Structure::create(globalData, globalObject, prototype, TypeInfo(NumberObjectType, StructureFlags), &s_info);
    4444        }
    4545
Note: See TracChangeset for help on using the changeset viewer.