Ignore:
Timestamp:
Sep 29, 2009, 10:54:39 AM (16 years ago)
Author:
[email protected]
Message:

Removed virtual destructor from JSGlobalObjectData to eliminate pointer
fix-ups when accessing JSGlobalObject::d.

Patch by Geoffrey Garen <[email protected]> on 2009-09-28
Reviewed by Sam Weinig.

JavaScriptCore:

Replaced with an explicit destructor function pointer.

6% speedup on bench-alloc-nonretained.js.

(JSC::JSGlobalObject::~JSGlobalObject):
(JSC::JSGlobalObject::destroyJSGlobalObjectData):

  • runtime/JSGlobalObject.h:

(JSC::JSGlobalObject::JSGlobalObjectData::JSGlobalObjectData):
(JSC::JSGlobalObject::JSGlobalObject):

JavaScriptGlue:

Replaced with an explicit destructor function pointer.

  • JSRun.cpp:

(JSGlueGlobalObject::destroyData):

  • JSRun.h:

(JSGlueGlobalObject::Data::Data):

WebCore:

Replaced with an explicit destructor function pointer.

  • bindings/js/JSDOMGlobalObject.cpp:

(WebCore::JSDOMGlobalObject::destroyJSDOMGlobalObjectData):

  • bindings/js/JSDOMGlobalObject.h:

(WebCore::JSDOMGlobalObject::JSDOMGlobalObjectData::JSDOMGlobalObjectData):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/JSGlobalObject.h

    r48836 r48883  
    5353
    5454    typedef Vector<ExecState*, 16> ExecStateStack;
    55 
     55   
    5656    class JSGlobalObject : public JSVariableObject {
    5757    protected:
     
    5959
    6060        struct JSGlobalObjectData : public JSVariableObjectData {
    61             JSGlobalObjectData()
     61            // We use an explicit destructor function pointer instead of a
     62            // virtual destructor because we want to avoid adding a vtable
     63            // pointer to this struct. Adding a vtable pointer would force the
     64            // compiler to emit costly pointer fixup code when casting from
     65            // JSVariableObjectData* to JSGlobalObjectData*.
     66            typedef void (*Destructor)(void*);
     67
     68            JSGlobalObjectData(Destructor destructor)
    6269                : JSVariableObjectData(&symbolTable, 0)
     70                , destructor(destructor)
    6371                , registerArraySize(0)
    6472                , globalScopeChain(NoScopeChain())
     
    8694            }
    8795           
    88             virtual ~JSGlobalObjectData()
    89             {
    90             }
    91 
     96            Destructor destructor;
     97           
    9298            size_t registerArraySize;
    9399
     
    154160
    155161        explicit JSGlobalObject()
    156             : JSVariableObject(JSGlobalObject::createStructure(jsNull()), new JSGlobalObjectData)
     162            : JSVariableObject(JSGlobalObject::createStructure(jsNull()), new JSGlobalObjectData(destroyJSGlobalObjectData))
    157163        {
    158164            init(this);
     
    281287
    282288    private:
     289        static void destroyJSGlobalObjectData(void*);
     290
    283291        // FIXME: Fold reset into init.
    284292        void init(JSObject* thisValue);
Note: See TracChangeset for help on using the changeset viewer.