Changeset 37714 in webkit


Ignore:
Timestamp:
Oct 20, 2008 12:29:28 AM (16 years ago)
Author:
Darin Adler
Message:

2008-10-19 Darin Adler <Darin Adler>

Reviewed by Cameron Zwarich.

  • VM/Machine.cpp: (JSC::Machine::cti_op_call_profiler): Use asFunction. (JSC::Machine::cti_vm_lazyLinkCall): Ditto. (JSC::Machine::cti_op_construct_JSConstructFast): Use asObject.
  • kjs/JSCell.h: Re-sort friend classes. Eliminate inheritance from JSValue. Changed cast in asCell from static_cast to reinterpret_cast. Removed JSValue::getNumber(double&) and one of JSValue::getObject overloads.
  • kjs/JSValue.h: Made the private constructor and destructor both non-virtual and also remove the definitions. This class can never be instantiated or derived.
Location:
trunk/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r37712 r37714  
     12008-10-19  Darin Adler  <darin@apple.com>
     2
     3        Reviewed by Cameron Zwarich.
     4
     5        - finish https://bugs.webkit.org/show_bug.cgi?id=21732
     6          improve performance by eliminating JSValue as a base class for JSCell
     7
     8        * VM/Machine.cpp:
     9        (JSC::Machine::cti_op_call_profiler): Use asFunction.
     10        (JSC::Machine::cti_vm_lazyLinkCall): Ditto.
     11        (JSC::Machine::cti_op_construct_JSConstructFast): Use asObject.
     12
     13        * kjs/JSCell.h: Re-sort friend classes. Eliminate inheritance from
     14        JSValue. Changed cast in asCell from static_cast to reinterpret_cast.
     15        Removed JSValue::getNumber(double&) and one of JSValue::getObject
     16        overloads.
     17
     18        * kjs/JSValue.h: Made the private constructor and destructor both
     19        non-virtual and also remove the definitions. This class can never
     20        be instantiated or derived.
     21
    1222008-10-19  Darin Adler  <darin@apple.com>
    223
  • trunk/JavaScriptCore/VM/Machine.cpp

    r37706 r37714  
    46174617
    46184618    ASSERT(*ARG_profilerReference);
    4619     (*ARG_profilerReference)->willExecute(ARG_callFrame, static_cast<JSFunction*>(ARG_src1));
     4619    (*ARG_profilerReference)->willExecute(ARG_callFrame, asFunction(ARG_src1));
    46204620}
    46214621
     
    46774677    CodeBlock* callerCodeBlock = callerCallFrame->codeBlock();
    46784678
    4679     JSFunction* callee = static_cast<JSFunction*>(ARG_src1);
     4679    JSFunction* callee = asFunction(ARG_src1);
    46804680    CodeBlock* codeBlock = &callee->m_body->byteCode(callee->m_scopeChain.node());
    46814681    if (!codeBlock->ctiCode)
     
    48424842#ifndef NDEBUG
    48434843    ConstructData constructData;
    4844     ASSERT(static_cast<JSFunction*>(ARG_src1)->getConstructData(constructData) == ConstructTypeJS);
     4844    ASSERT(asFunction(ARG_src1)->getConstructData(constructData) == ConstructTypeJS);
    48454845#endif
    48464846
    48474847    StructureID* structure;
    48484848    if (ARG_src2->isObject())
    4849         structure = static_cast<JSObject*>(ARG_src2)->inheritorID();
     4849        structure = asObject(ARG_src2)->inheritorID();
    48504850    else
    4851         structure = static_cast<JSFunction*>(ARG_src1)->m_scopeChain.node()->globalObject()->emptyObjectStructure();
     4851        structure = asFunction(ARG_src1)->m_scopeChain.node()->globalObject()->emptyObjectStructure();
    48524852    return new (ARG_globalData) JSObject(structure);
    48534853}
  • trunk/JavaScriptCore/kjs/JSCell.h

    r37712 r37714  
    3030namespace JSC {
    3131
    32     class JSCell : public JSValue {
     32    class JSCell : Noncopyable {
     33        friend class CTI;
     34        friend class GetterSetter;
    3335        friend class Heap;
    34         friend class GetterSetter;
     36        friend class JSNumberCell;
    3537        friend class JSObject;
    3638        friend class JSPropertyNameIterator;
     39        friend class JSString;
    3740        friend class JSValue;
    38         friend class JSNumberCell;
    39         friend class JSString;
    4041        friend class Machine;
    41         friend class CTI;
     42
    4243    private:
    4344        explicit JSCell(StructureID*);
     
    111112    {
    112113        ASSERT(!JSImmediate::isImmediate(value));
    113         return static_cast<JSCell*>(value.payload());
     114        return reinterpret_cast<JSCell*>(value.payload());
    114115    }
    115116
     
    197198    }
    198199
    199     inline bool JSValue::getNumber(double& v) const
    200     {
    201         if (JSImmediate::isImmediate(asValue())) {
    202             v = JSImmediate::toDouble(asValue());
    203             return true;
    204         }
    205         return asCell()->getNumber(v);
    206     }
    207 
    208200    inline double JSValue::getNumber() const
    209201    {
     
    221213    }
    222214
    223     inline JSObject* JSValue::getObject()
    224     {
    225         return JSImmediate::isImmediate(asValue()) ? 0 : asCell()->getObject();
    226     }
    227 
    228     inline const JSObject* JSValue::getObject() const
     215    inline JSObject* JSValue::getObject() const
    229216    {
    230217        return JSImmediate::isImmediate(asValue()) ? 0 : asCell()->getObject();
  • trunk/JavaScriptCore/kjs/JSValue.h

    r37712 r37714  
    3636namespace JSC {
    3737
    38     class ExecState;
    3938    class Identifier;
    40     class JSCell;
    41     class JSObject;
    4239    class JSString;
    4340    class PropertySlot;
    4441    class PutPropertySlot;
    45     class StructureID;
    4642
    4743    struct ClassInfo;
     
    5046    enum PreferredPrimitiveType { NoPreference, PreferNumber, PreferString };
    5147
    52     /**
    53      * JSValue is the base type for all primitives (Undefined, Null, Boolean,
    54      * String, Number) and objects in ECMAScript.
    55      *
    56      * Note: you should never inherit from JSValue as it is for primitive types
    57      * only (all of which are provided internally by KJS). Instead, inherit from
    58      * JSObject.
    59      */
    6048    class JSValue : Noncopyable {
    61         friend class JSCell; // so it can derive from this class
    6249    private:
    6350        JSValue();
    64         virtual ~JSValue();
     51        ~JSValue();
    6552
    6653    public:
     
    7461        bool isGetterSetter() const;
    7562        bool isObject() const;
    76         bool isObject(const ClassInfo*) const; // FIXME: Merge with inherits.
     63        bool isObject(const ClassInfo*) const;
    7764       
    7865        // Extracting the value.
    7966        bool getBoolean(bool&) const;
    8067        bool getBoolean() const; // false if not a boolean
    81         bool getNumber(double&) const;
    8268        double getNumber() const; // NaN if not a number
    8369        double uncheckedGetNumber() const;
    8470        bool getString(UString&) const;
    8571        UString getString() const; // null string if not a string
    86         JSObject* getObject(); // NULL if not an object
    87         const JSObject* getObject() const; // NULL if not an object
     72        JSObject* getObject() const; // 0 if not an object
    8873
    8974        CallType getCallData(CallData&);
     
    10590        double toNumber(ExecState*) const;
    10691        JSValuePtr toJSNumber(ExecState*) const; // Fast path for when you expect that the value is an immediate number.
     92
    10793        UString toString(ExecState*) const;
    10894        JSObject* toObject(ExecState*) const;
     
    160146    uint32_t toUInt32SlowCase(double, bool& ok);
    161147
    162     inline JSValue::JSValue()
    163     {
    164     }
    165 
    166     inline JSValue::~JSValue()
    167     {
    168     }
    169 
    170148    inline JSValuePtr JSValue::asValue() const
    171149    {
Note: See TracChangeset for help on using the changeset viewer.