Changeset 93920 in webkit


Ignore:
Timestamp:
Aug 26, 2011 3:32:53 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

Unzip initialization lists and constructors in JSCell hierarchy (2/7)
https://bugs.webkit.org/show_bug.cgi?id=66957

Patch by Mark Hahnenberg <mhahnenberg@apple.com> on 2011-08-26
Reviewed by Darin Adler.

Completed the second level of the refactoring to add finishCreation()
methods to all classes within the JSCell hierarchy with non-trivial
constructor bodies.

  • runtime/Executable.h:

(JSC::ExecutableBase::ExecutableBase):
(JSC::ExecutableBase::create):
(JSC::NativeExecutable::create):
(JSC::NativeExecutable::finishCreation):
(JSC::NativeExecutable::NativeExecutable):
(JSC::ScriptExecutable::ScriptExecutable):
(JSC::ScriptExecutable::finishCreation):

  • runtime/GetterSetter.h:

(JSC::GetterSetter::GetterSetter):
(JSC::GetterSetter::create):

  • runtime/JSAPIValueWrapper.h:

(JSC::JSAPIValueWrapper::create):
(JSC::JSAPIValueWrapper::JSAPIValueWrapper):

  • runtime/JSObject.h:

(JSC::JSNonFinalObject::JSNonFinalObject):
(JSC::JSNonFinalObject::finishCreation):
(JSC::JSFinalObject::create):
(JSC::JSFinalObject::finishCreation):
(JSC::JSFinalObject::JSFinalObject):
(JSC::JSObject::JSObject):

  • runtime/JSPropertyNameIterator.cpp:

(JSC::JSPropertyNameIterator::JSPropertyNameIterator):
(JSC::JSPropertyNameIterator::create):

  • runtime/JSPropertyNameIterator.h:

(JSC::JSPropertyNameIterator::create):

  • runtime/RegExp.cpp:

(JSC::RegExp::RegExp):
(JSC::RegExp::createWithoutCaching):

  • runtime/ScopeChain.h:

(JSC::ScopeChainNode::ScopeChainNode):
(JSC::ScopeChainNode::create):

  • runtime/Structure.cpp:

(JSC::Structure::Structure):

  • runtime/Structure.h:

(JSC::Structure::create):
(JSC::Structure::finishCreation):
(JSC::Structure::createStructure):

  • runtime/StructureChain.cpp:

(JSC::StructureChain::StructureChain):

  • runtime/StructureChain.h:

(JSC::StructureChain::create):

Location:
trunk/Source/JavaScriptCore
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r93918 r93920  
     12011-08-26  Mark Hahnenberg  <mhahnenberg@apple.com>
     2
     3        Unzip initialization lists and constructors in JSCell hierarchy (2/7)
     4        https://bugs.webkit.org/show_bug.cgi?id=66957
     5
     6        Reviewed by Darin Adler.
     7
     8        Completed the second level of the refactoring to add finishCreation()
     9        methods to all classes within the JSCell hierarchy with non-trivial
     10        constructor bodies.
     11
     12        * runtime/Executable.h:
     13        (JSC::ExecutableBase::ExecutableBase):
     14        (JSC::ExecutableBase::create):
     15        (JSC::NativeExecutable::create):
     16        (JSC::NativeExecutable::finishCreation):
     17        (JSC::NativeExecutable::NativeExecutable):
     18        (JSC::ScriptExecutable::ScriptExecutable):
     19        (JSC::ScriptExecutable::finishCreation):
     20        * runtime/GetterSetter.h:
     21        (JSC::GetterSetter::GetterSetter):
     22        (JSC::GetterSetter::create):
     23        * runtime/JSAPIValueWrapper.h:
     24        (JSC::JSAPIValueWrapper::create):
     25        (JSC::JSAPIValueWrapper::JSAPIValueWrapper):
     26        * runtime/JSObject.h:
     27        (JSC::JSNonFinalObject::JSNonFinalObject):
     28        (JSC::JSNonFinalObject::finishCreation):
     29        (JSC::JSFinalObject::create):
     30        (JSC::JSFinalObject::finishCreation):
     31        (JSC::JSFinalObject::JSFinalObject):
     32        (JSC::JSObject::JSObject):
     33        * runtime/JSPropertyNameIterator.cpp:
     34        (JSC::JSPropertyNameIterator::JSPropertyNameIterator):
     35        (JSC::JSPropertyNameIterator::create):
     36        * runtime/JSPropertyNameIterator.h:
     37        (JSC::JSPropertyNameIterator::create):
     38        * runtime/RegExp.cpp:
     39        (JSC::RegExp::RegExp):
     40        (JSC::RegExp::createWithoutCaching):
     41        * runtime/ScopeChain.h:
     42        (JSC::ScopeChainNode::ScopeChainNode):
     43        (JSC::ScopeChainNode::create):
     44        * runtime/Structure.cpp:
     45        (JSC::Structure::Structure):
     46        * runtime/Structure.h:
     47        (JSC::Structure::create):
     48        (JSC::Structure::finishCreation):
     49        (JSC::Structure::createStructure):
     50        * runtime/StructureChain.cpp:
     51        (JSC::StructureChain::StructureChain):
     52        * runtime/StructureChain.h:
     53        (JSC::StructureChain::create):
     54
    1552011-08-26  Filip Pizlo  <fpizlo@apple.com>
    256
  • trunk/Source/JavaScriptCore/runtime/Executable.h

    r93835 r93920  
    5959            , m_numParametersForConstruct(numParameters)
    6060        {
    61             finishCreation(globalData);
    6261        }
    6362
     
    7675        static ExecutableBase* create(JSGlobalData& globalData, Structure* structure, int numParameters)
    7776        {
    78             return new (allocateCell<ExecutableBase>(globalData.heap)) ExecutableBase(globalData, structure, numParameters);
     77            ExecutableBase* executable = new (allocateCell<ExecutableBase>(globalData.heap)) ExecutableBase(globalData, structure, numParameters);
     78            executable->finishCreation(globalData);
     79            return executable;
    7980        }
    8081
     
    181182        static NativeExecutable* create(JSGlobalData& globalData, MacroAssemblerCodePtr callThunk, NativeFunction function, MacroAssemblerCodePtr constructThunk, NativeFunction constructor)
    182183        {
     184            NativeExecutable* executable;
    183185            if (!callThunk)
    184                 return new (allocateCell<NativeExecutable>(globalData.heap)) NativeExecutable(globalData, JITCode(), function, JITCode(), constructor);
    185             return new (allocateCell<NativeExecutable>(globalData.heap)) NativeExecutable(globalData, JITCode::HostFunction(callThunk), function, JITCode::HostFunction(constructThunk), constructor);
     186                executable = new (allocateCell<NativeExecutable>(globalData.heap)) NativeExecutable(globalData, JITCode(), function, JITCode(), constructor);
     187            else
     188                executable = new (allocateCell<NativeExecutable>(globalData.heap)) NativeExecutable(globalData, JITCode::HostFunction(callThunk), function, JITCode::HostFunction(constructThunk), constructor);
     189            return executable;
    186190        }
    187191#else
     
    199203       
    200204        static const ClassInfo s_info;
    201    
     205
     206    protected:
     207#if ENABLE(JIT)
     208        void finishCreation(JSGlobalData& globalData, JITCode callThunk, JITCode constructThunk)
     209        {
     210            Base::finishCreation(globalData);
     211            m_jitCodeForCall = callThunk;
     212            m_jitCodeForConstruct = constructThunk;
     213            m_jitCodeForCallWithArityCheck = callThunk.addressForCall();
     214            m_jitCodeForConstructWithArityCheck = constructThunk.addressForCall();
     215        }
     216#endif
     217 
    202218    private:
    203219#if ENABLE(JIT)
     
    207223            , m_constructor(constructor)
    208224        {
    209             m_jitCodeForCall = callThunk;
    210             m_jitCodeForConstruct = constructThunk;
    211             m_jitCodeForCallWithArityCheck = callThunk.addressForCall();
    212             m_jitCodeForConstructWithArityCheck = constructThunk.addressForCall();
     225            finishCreation(globalData, callThunk, constructThunk);
    213226        }
    214227#else
     
    218231            , m_constructor(constructor)
    219232        {
     233            finishCreation(globalData);
    220234        }
    221235#endif
     
    236250            , m_features(isInStrictContext ? StrictModeFeature : 0)
    237251        {
    238 #if ENABLE(CODEBLOCK_SAMPLING)
    239             if (SamplingTool* sampler = globalData.interpreter->sampler())
    240                 sampler->notifyOfScope(globalData, this);
    241 #else
    242             UNUSED_PARAM(globalData);
    243 #endif
     252            finishCreation(globalData);
    244253        }
    245254
     
    249258            , m_features(isInStrictContext ? StrictModeFeature : 0)
    250259        {
    251 #if ENABLE(CODEBLOCK_SAMPLING)
    252             if (SamplingTool* sampler = exec->globalData().interpreter->sampler())
    253                 sampler->notifyOfScope(exec->globalData(), this);
    254 #else
    255             UNUSED_PARAM(exec);
    256 #endif
     260            finishCreation(exec->globalData());
    257261        }
    258262
     
    271275       
    272276        static const ClassInfo s_info;
     277
    273278    protected:
     279        void finishCreation(JSGlobalData& globalData)
     280        {
     281            Base::finishCreation(globalData);
     282#if ENABLE(CODEBLOCK_SAMPLING)
     283            if (SamplingTool* sampler = globalData.interpreter->sampler())
     284                sampler->notifyOfScope(globalData, this);
     285#endif
     286        }
     287
    274288        void recordParse(CodeFeatures features, bool hasCapturedVariables, int firstLine, int lastLine)
    275289        {
  • trunk/Source/JavaScriptCore/runtime/GetterSetter.h

    r93835 r93920  
    4242            : JSCell(exec->globalData(), exec->globalData().getterSetterStructure.get())
    4343        {
    44             finishCreation(exec->globalData());
    4544        }
    4645
     
    5049        static GetterSetter* create(ExecState* exec)
    5150        {
    52             return new (allocateCell<GetterSetter>(*exec->heap())) GetterSetter(exec);
     51            GetterSetter* getterSetter = new (allocateCell<GetterSetter>(*exec->heap())) GetterSetter(exec);
     52            getterSetter->finishCreation(exec->globalData());
     53            return getterSetter;
    5354        }
    5455
  • trunk/Source/JavaScriptCore/runtime/JSAPIValueWrapper.h

    r93835 r93920  
    4949        static JSAPIValueWrapper* create(ExecState* exec, JSValue value)
    5050        {
    51             return new (allocateCell<JSAPIValueWrapper>(*exec->heap())) JSAPIValueWrapper(exec, value);
     51            JSAPIValueWrapper* wrapper = new (allocateCell<JSAPIValueWrapper>(*exec->heap())) JSAPIValueWrapper(exec);
     52            wrapper->finishCreation(exec, value);
     53            return wrapper;
    5254        }
    5355
     
    6163
    6264    private:
    63         JSAPIValueWrapper(ExecState* exec, JSValue value)
     65        JSAPIValueWrapper(ExecState* exec)
    6466            : JSCell(exec->globalData(), exec->globalData().apiWrapperStructure.get())
    6567        {
    66             finishCreation(exec, value);
    6768        }
    6869
  • trunk/Source/JavaScriptCore/runtime/JSObject.h

    r93841 r93920  
    362362            : JSObject(globalData, structure, m_inlineStorage)
    363363        {
     364            finishCreation(globalData);
     365        }
     366
     367        void finishCreation(JSGlobalData& globalData)
     368        {
     369            Base::finishCreation(globalData, m_inlineStorage);
    364370            ASSERT(!(OBJECT_OFFSETOF(JSNonFinalObject, m_inlineStorage) % sizeof(double)));
    365371            ASSERT(this->structure()->propertyStorageCapacity() == JSNonFinalObject_inlineStorageCapacity);
     
    385391        static JSFinalObject* create(ExecState* exec, Structure* structure)
    386392        {
    387             return new (allocateCell<JSFinalObject>(*exec->heap())) JSFinalObject(exec->globalData(), structure);
     393            JSFinalObject* finalObject = new (allocateCell<JSFinalObject>(*exec->heap())) JSFinalObject(exec->globalData(), structure);
     394            finalObject->finishCreation(exec->globalData());
     395            return finalObject;
    388396        }
    389397
     
    391399        {
    392400            return Structure::create(globalData, prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
     401        }
     402
     403    protected:
     404        void finishCreation(JSGlobalData& globalData)
     405        {
     406            Base::finishCreation(globalData, m_inlineStorage);
     407            ASSERT(!(OBJECT_OFFSETOF(JSFinalObject, m_inlineStorage) % sizeof(double)));
     408            ASSERT(this->structure()->propertyStorageCapacity() == JSFinalObject_inlineStorageCapacity);
    393409        }
    394410
     
    397413            : JSObject(globalData, structure, m_inlineStorage)
    398414        {
    399             ASSERT(OBJECT_OFFSETOF(JSFinalObject, m_inlineStorage) % sizeof(double) == 0);
    400             ASSERT(this->structure()->propertyStorageCapacity() == JSFinalObject_inlineStorageCapacity);
    401415        }
    402416
     
    447461    , m_propertyStorage(inlineStorage)
    448462{
    449     finishCreation(globalData, inlineStorage);
    450463}
    451464
  • trunk/Source/JavaScriptCore/runtime/JSPropertyNameIterator.cpp

    r93835 r93920  
    4444    , m_jsStrings(adoptArrayPtr(new WriteBarrier<Unknown>[m_jsStringsSize]))
    4545{
    46     finishCreation(exec, propertyNameArrayData);
    4746}
    4847
     
    6261   
    6362    JSPropertyNameIterator* jsPropertyNameIterator = new (allocateCell<JSPropertyNameIterator>(*exec->heap())) JSPropertyNameIterator(exec, propertyNames.data(), numCacheableSlots);
     63    jsPropertyNameIterator->finishCreation(exec, propertyNames.data());
    6464
    6565    if (o->structure()->isDictionary())
  • trunk/Source/JavaScriptCore/runtime/JSPropertyNameIterator.h

    r93835 r93920  
    4949        static JSPropertyNameIterator* create(ExecState* exec, PropertyNameArrayData* propertyNameArrayData, size_t numCacheableSlot)
    5050        {
    51             return new (allocateCell<JSPropertyNameIterator>(*exec->heap())) JSPropertyNameIterator(exec, propertyNameArrayData, numCacheableSlot);
     51            JSPropertyNameIterator* iterator = new (allocateCell<JSPropertyNameIterator>(*exec->heap())) JSPropertyNameIterator(exec, propertyNameArrayData, numCacheableSlot);
     52            iterator->finishCreation(exec, propertyNameArrayData);
     53            return iterator;
    5254        }
    5355       
  • trunk/Source/JavaScriptCore/runtime/RegExp.cpp

    r93835 r93920  
    8989#endif
    9090{
    91     finishCreation(globalData);
    9291}
    9392
     
    108107RegExp* RegExp::createWithoutCaching(JSGlobalData& globalData, const UString& patternString, RegExpFlags flags)
    109108{
    110     return new (allocateCell<RegExp>(globalData.heap)) RegExp(globalData, patternString, flags);
     109    RegExp* regExp = new (allocateCell<RegExp>(globalData.heap)) RegExp(globalData, patternString, flags);
     110    regExp->finishCreation(globalData);
     111    return regExp;
    111112}
    112113
  • trunk/Source/JavaScriptCore/runtime/ScopeChain.h

    r93841 r93920  
    4444            , globalThis(*globalData, this, globalThis)
    4545        {
    46             finishCreation(globalData, globalObject);
    4746        }
    4847
     
    5958        static ScopeChainNode* create(ExecState* exec, ScopeChainNode* next, JSObject* object, JSGlobalData* globalData, JSGlobalObject* globalObject, JSObject* globalThis)
    6059        {
    61             return new (allocateCell<ScopeChainNode>(*exec->heap())) ScopeChainNode(next, object, globalData, globalObject, globalThis);
     60            ScopeChainNode* node = new (allocateCell<ScopeChainNode>(*exec->heap())) ScopeChainNode(next, object, globalData, globalObject, globalThis);
     61            node->finishCreation(globalData, globalObject);
     62            return node;
    6263        }
    6364        static ScopeChainNode* create(ScopeChainNode* next, JSObject* object, JSGlobalData* globalData, JSGlobalObject* globalObject, JSObject* globalThis)
    6465        {
    65             return new (allocateCell<ScopeChainNode>(globalData->heap)) ScopeChainNode(next, object, globalData, globalObject, globalThis);
     66            ScopeChainNode* node = new (allocateCell<ScopeChainNode>(globalData->heap)) ScopeChainNode(next, object, globalData, globalObject, globalThis);
     67            node->finishCreation(globalData, globalObject);
     68            return node;
    6669        }
    6770       
  • trunk/Source/JavaScriptCore/runtime/Structure.cpp

    r93835 r93920  
    177177    , m_didTransition(false)
    178178{
    179     finishCreation(globalData);
    180     ASSERT(m_prototype);
    181     ASSERT(m_prototype.isObject() || m_prototype.isNull());
    182179}
    183180
     
    201198    , m_didTransition(false)
    202199{
    203     finishCreation(globalData, this, CreatingEarlyCell);
    204     ASSERT(m_prototype);
    205     ASSERT(m_prototype.isNull());
    206     ASSERT(!globalData.structureStructure);
    207200}
    208201
     
    224217    , m_didTransition(true)
    225218{
    226     finishCreation(globalData);
    227     ASSERT(m_prototype);
    228     ASSERT(m_prototype.isObject() || m_prototype.isNull());
    229219}
    230220
  • trunk/Source/JavaScriptCore/runtime/Structure.h

    r92706 r93920  
    6767            ASSERT(globalData.structureStructure);
    6868            ASSERT(classInfo);
    69             return new (allocateCell<Structure>(globalData.heap)) Structure(globalData, prototype, typeInfo, anonymousSlotCount, classInfo);
    70         }
    71 
     69            Structure* structure = new (allocateCell<Structure>(globalData.heap)) Structure(globalData, prototype, typeInfo, anonymousSlotCount, classInfo);
     70            structure->finishCreation(globalData);
     71            return structure;
     72        }
     73
     74    protected:
     75        void finishCreation(JSGlobalData& globalData)
     76        {
     77            Base::finishCreation(globalData);
     78            ASSERT(m_prototype);
     79            ASSERT(m_prototype.isObject() || m_prototype.isNull());
     80        }
     81
     82        void finishCreation(JSGlobalData& globalData, CreatingEarlyCellTag)
     83        {
     84            Base::finishCreation(globalData, this, CreatingEarlyCell);
     85            ASSERT(m_prototype);
     86            ASSERT(m_prototype.isNull());
     87            ASSERT(!globalData.structureStructure);
     88        }
     89
     90    public:
    7291        static void dumpStatistics();
    7392
     
    162181        {
    163182            ASSERT(!globalData.structureStructure);
    164             return new (allocateCell<Structure>(globalData.heap)) Structure(globalData);
     183            Structure* structure = new (allocateCell<Structure>(globalData.heap)) Structure(globalData);
     184            structure->finishCreation(globalData, CreatingEarlyCell);
     185            return structure;
    165186        }
    166187       
     
    175196        {
    176197            ASSERT(globalData.structureStructure);
    177             return new (allocateCell<Structure>(globalData.heap)) Structure(globalData, structure);
     198            Structure* newStructure = new (allocateCell<Structure>(globalData.heap)) Structure(globalData, structure);
     199            newStructure->finishCreation(globalData);
     200            return newStructure;
    178201        }
    179202       
  • trunk/Source/JavaScriptCore/runtime/StructureChain.cpp

    r93835 r93920  
    3535ClassInfo StructureChain::s_info = { "StructureChain", 0, 0, 0 };
    3636
    37 StructureChain::StructureChain(JSGlobalData& globalData, Structure* structure, Structure* head)
     37StructureChain::StructureChain(JSGlobalData& globalData, Structure* structure)
    3838    : JSCell(globalData, structure)
    3939{
    40     finishCreation(globalData, head);
    4140}
    4241
  • trunk/Source/JavaScriptCore/runtime/StructureChain.h

    r93835 r93920  
    4848        static StructureChain* create(JSGlobalData& globalData, Structure* head)
    4949        {
    50             return new (allocateCell<StructureChain>(globalData.heap)) StructureChain(globalData, globalData.structureChainStructure.get(), head);
     50            StructureChain* chain = new (allocateCell<StructureChain>(globalData.heap)) StructureChain(globalData, globalData.structureChainStructure.get());
     51            chain->finishCreation(globalData, head);
     52            return chain;
    5153        }
    5254        WriteBarrier<Structure>* head() { return m_vector.get(); }
     
    7375
    7476    private:
    75         StructureChain(JSGlobalData&, Structure*, Structure* head);
     77        StructureChain(JSGlobalData&, Structure*);
    7678        ~StructureChain();
    7779        OwnArrayPtr<WriteBarrier<Structure> > m_vector;
Note: See TracChangeset for help on using the changeset viewer.