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):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@93920 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 36e68b5a
2011-08-26 Mark Hahnenberg <mhahnenberg@apple.com>
Unzip initialization lists and constructors in JSCell hierarchy (2/7)
https://bugs.webkit.org/show_bug.cgi?id=66957
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):
2011-08-26 Filip Pizlo <fpizlo@apple.com> 2011-08-26 Filip Pizlo <fpizlo@apple.com>
The GC does not have a facility for profiling the kinds of objects The GC does not have a facility for profiling the kinds of objects
......
...@@ -58,7 +58,6 @@ namespace JSC { ...@@ -58,7 +58,6 @@ namespace JSC {
, m_numParametersForCall(numParameters) , m_numParametersForCall(numParameters)
, m_numParametersForConstruct(numParameters) , m_numParametersForConstruct(numParameters)
{ {
finishCreation(globalData);
} }
void finishCreation(JSGlobalData& globalData) void finishCreation(JSGlobalData& globalData)
...@@ -75,7 +74,9 @@ namespace JSC { ...@@ -75,7 +74,9 @@ namespace JSC {
static ExecutableBase* create(JSGlobalData& globalData, Structure* structure, int numParameters) static ExecutableBase* create(JSGlobalData& globalData, Structure* structure, int numParameters)
{ {
return new (allocateCell<ExecutableBase>(globalData.heap)) ExecutableBase(globalData, structure, numParameters); ExecutableBase* executable = new (allocateCell<ExecutableBase>(globalData.heap)) ExecutableBase(globalData, structure, numParameters);
executable->finishCreation(globalData);
return executable;
} }
bool isHostFunction() const bool isHostFunction() const
...@@ -180,9 +181,12 @@ namespace JSC { ...@@ -180,9 +181,12 @@ namespace JSC {
#if ENABLE(JIT) #if ENABLE(JIT)
static NativeExecutable* create(JSGlobalData& globalData, MacroAssemblerCodePtr callThunk, NativeFunction function, MacroAssemblerCodePtr constructThunk, NativeFunction constructor) static NativeExecutable* create(JSGlobalData& globalData, MacroAssemblerCodePtr callThunk, NativeFunction function, MacroAssemblerCodePtr constructThunk, NativeFunction constructor)
{ {
NativeExecutable* executable;
if (!callThunk) if (!callThunk)
return new (allocateCell<NativeExecutable>(globalData.heap)) NativeExecutable(globalData, JITCode(), function, JITCode(), constructor); executable = new (allocateCell<NativeExecutable>(globalData.heap)) NativeExecutable(globalData, JITCode(), function, JITCode(), constructor);
return new (allocateCell<NativeExecutable>(globalData.heap)) NativeExecutable(globalData, JITCode::HostFunction(callThunk), function, JITCode::HostFunction(constructThunk), constructor); else
executable = new (allocateCell<NativeExecutable>(globalData.heap)) NativeExecutable(globalData, JITCode::HostFunction(callThunk), function, JITCode::HostFunction(constructThunk), constructor);
return executable;
} }
#else #else
static NativeExecutable* create(JSGlobalData& globalData, NativeFunction function, NativeFunction constructor) static NativeExecutable* create(JSGlobalData& globalData, NativeFunction function, NativeFunction constructor)
...@@ -198,7 +202,19 @@ namespace JSC { ...@@ -198,7 +202,19 @@ namespace JSC {
static Structure* createStructure(JSGlobalData& globalData, JSValue proto) { return Structure::create(globalData, proto, TypeInfo(LeafType, StructureFlags), AnonymousSlotCount, &s_info); } static Structure* createStructure(JSGlobalData& globalData, JSValue proto) { return Structure::create(globalData, proto, TypeInfo(LeafType, StructureFlags), AnonymousSlotCount, &s_info); }
static const ClassInfo s_info; static const ClassInfo s_info;
protected:
#if ENABLE(JIT)
void finishCreation(JSGlobalData& globalData, JITCode callThunk, JITCode constructThunk)
{
Base::finishCreation(globalData);
m_jitCodeForCall = callThunk;
m_jitCodeForConstruct = constructThunk;
m_jitCodeForCallWithArityCheck = callThunk.addressForCall();
m_jitCodeForConstructWithArityCheck = constructThunk.addressForCall();
}
#endif
private: private:
#if ENABLE(JIT) #if ENABLE(JIT)
NativeExecutable(JSGlobalData& globalData, JITCode callThunk, NativeFunction function, JITCode constructThunk, NativeFunction constructor) NativeExecutable(JSGlobalData& globalData, JITCode callThunk, NativeFunction function, JITCode constructThunk, NativeFunction constructor)
...@@ -206,10 +222,7 @@ namespace JSC { ...@@ -206,10 +222,7 @@ namespace JSC {
, m_function(function) , m_function(function)
, m_constructor(constructor) , m_constructor(constructor)
{ {
m_jitCodeForCall = callThunk; finishCreation(globalData, callThunk, constructThunk);
m_jitCodeForConstruct = constructThunk;
m_jitCodeForCallWithArityCheck = callThunk.addressForCall();
m_jitCodeForConstructWithArityCheck = constructThunk.addressForCall();
} }
#else #else
NativeExecutable(JSGlobalData& globalData, NativeFunction function, NativeFunction constructor) NativeExecutable(JSGlobalData& globalData, NativeFunction function, NativeFunction constructor)
...@@ -217,6 +230,7 @@ namespace JSC { ...@@ -217,6 +230,7 @@ namespace JSC {
, m_function(function) , m_function(function)
, m_constructor(constructor) , m_constructor(constructor)
{ {
finishCreation(globalData);
} }
#endif #endif
...@@ -235,12 +249,7 @@ namespace JSC { ...@@ -235,12 +249,7 @@ namespace JSC {
, m_source(source) , m_source(source)
, m_features(isInStrictContext ? StrictModeFeature : 0) , m_features(isInStrictContext ? StrictModeFeature : 0)
{ {
#if ENABLE(CODEBLOCK_SAMPLING) finishCreation(globalData);
if (SamplingTool* sampler = globalData.interpreter->sampler())
sampler->notifyOfScope(globalData, this);
#else
UNUSED_PARAM(globalData);
#endif
} }
ScriptExecutable(Structure* structure, ExecState* exec, const SourceCode& source, bool isInStrictContext) ScriptExecutable(Structure* structure, ExecState* exec, const SourceCode& source, bool isInStrictContext)
...@@ -248,12 +257,7 @@ namespace JSC { ...@@ -248,12 +257,7 @@ namespace JSC {
, m_source(source) , m_source(source)
, m_features(isInStrictContext ? StrictModeFeature : 0) , m_features(isInStrictContext ? StrictModeFeature : 0)
{ {
#if ENABLE(CODEBLOCK_SAMPLING) finishCreation(exec->globalData());
if (SamplingTool* sampler = exec->globalData().interpreter->sampler())
sampler->notifyOfScope(exec->globalData(), this);
#else
UNUSED_PARAM(exec);
#endif
} }
const SourceCode& source() { return m_source; } const SourceCode& source() { return m_source; }
...@@ -270,7 +274,17 @@ namespace JSC { ...@@ -270,7 +274,17 @@ namespace JSC {
virtual void unlinkCalls() = 0; virtual void unlinkCalls() = 0;
static const ClassInfo s_info; static const ClassInfo s_info;
protected: protected:
void finishCreation(JSGlobalData& globalData)
{
Base::finishCreation(globalData);
#if ENABLE(CODEBLOCK_SAMPLING)
if (SamplingTool* sampler = globalData.interpreter->sampler())
sampler->notifyOfScope(globalData, this);
#endif
}
void recordParse(CodeFeatures features, bool hasCapturedVariables, int firstLine, int lastLine) void recordParse(CodeFeatures features, bool hasCapturedVariables, int firstLine, int lastLine)
{ {
m_features = features; m_features = features;
......
...@@ -41,7 +41,6 @@ namespace JSC { ...@@ -41,7 +41,6 @@ namespace JSC {
GetterSetter(ExecState* exec) GetterSetter(ExecState* exec)
: JSCell(exec->globalData(), exec->globalData().getterSetterStructure.get()) : JSCell(exec->globalData(), exec->globalData().getterSetterStructure.get())
{ {
finishCreation(exec->globalData());
} }
public: public:
...@@ -49,7 +48,9 @@ namespace JSC { ...@@ -49,7 +48,9 @@ namespace JSC {
static GetterSetter* create(ExecState* exec) static GetterSetter* create(ExecState* exec)
{ {
return new (allocateCell<GetterSetter>(*exec->heap())) GetterSetter(exec); GetterSetter* getterSetter = new (allocateCell<GetterSetter>(*exec->heap())) GetterSetter(exec);
getterSetter->finishCreation(exec->globalData());
return getterSetter;
} }
virtual void visitChildren(SlotVisitor&); virtual void visitChildren(SlotVisitor&);
......
...@@ -48,7 +48,9 @@ namespace JSC { ...@@ -48,7 +48,9 @@ namespace JSC {
static JSAPIValueWrapper* create(ExecState* exec, JSValue value) static JSAPIValueWrapper* create(ExecState* exec, JSValue value)
{ {
return new (allocateCell<JSAPIValueWrapper>(*exec->heap())) JSAPIValueWrapper(exec, value); JSAPIValueWrapper* wrapper = new (allocateCell<JSAPIValueWrapper>(*exec->heap())) JSAPIValueWrapper(exec);
wrapper->finishCreation(exec, value);
return wrapper;
} }
protected: protected:
...@@ -60,10 +62,9 @@ namespace JSC { ...@@ -60,10 +62,9 @@ namespace JSC {
} }
private: private:
JSAPIValueWrapper(ExecState* exec, JSValue value) JSAPIValueWrapper(ExecState* exec)
: JSCell(exec->globalData(), exec->globalData().apiWrapperStructure.get()) : JSCell(exec->globalData(), exec->globalData().apiWrapperStructure.get())
{ {
finishCreation(exec, value);
} }
WriteBarrier<Unknown> m_value; WriteBarrier<Unknown> m_value;
......
...@@ -361,6 +361,12 @@ COMPILE_ASSERT((JSFinalObject_inlineStorageCapacity >= JSNonFinalObject_inlineSt ...@@ -361,6 +361,12 @@ COMPILE_ASSERT((JSFinalObject_inlineStorageCapacity >= JSNonFinalObject_inlineSt
explicit JSNonFinalObject(JSGlobalData& globalData, Structure* structure) explicit JSNonFinalObject(JSGlobalData& globalData, Structure* structure)
: JSObject(globalData, structure, m_inlineStorage) : JSObject(globalData, structure, m_inlineStorage)
{ {
finishCreation(globalData);
}
void finishCreation(JSGlobalData& globalData)
{
Base::finishCreation(globalData, m_inlineStorage);
ASSERT(!(OBJECT_OFFSETOF(JSNonFinalObject, m_inlineStorage) % sizeof(double))); ASSERT(!(OBJECT_OFFSETOF(JSNonFinalObject, m_inlineStorage) % sizeof(double)));
ASSERT(this->structure()->propertyStorageCapacity() == JSNonFinalObject_inlineStorageCapacity); ASSERT(this->structure()->propertyStorageCapacity() == JSNonFinalObject_inlineStorageCapacity);
} }
...@@ -384,7 +390,9 @@ COMPILE_ASSERT((JSFinalObject_inlineStorageCapacity >= JSNonFinalObject_inlineSt ...@@ -384,7 +390,9 @@ COMPILE_ASSERT((JSFinalObject_inlineStorageCapacity >= JSNonFinalObject_inlineSt
static JSFinalObject* create(ExecState* exec, Structure* structure) static JSFinalObject* create(ExecState* exec, Structure* structure)
{ {
return new (allocateCell<JSFinalObject>(*exec->heap())) JSFinalObject(exec->globalData(), structure); JSFinalObject* finalObject = new (allocateCell<JSFinalObject>(*exec->heap())) JSFinalObject(exec->globalData(), structure);
finalObject->finishCreation(exec->globalData());
return finalObject;
} }
static Structure* createStructure(JSGlobalData& globalData, JSValue prototype) static Structure* createStructure(JSGlobalData& globalData, JSValue prototype)
...@@ -392,12 +400,18 @@ COMPILE_ASSERT((JSFinalObject_inlineStorageCapacity >= JSNonFinalObject_inlineSt ...@@ -392,12 +400,18 @@ COMPILE_ASSERT((JSFinalObject_inlineStorageCapacity >= JSNonFinalObject_inlineSt
return Structure::create(globalData, prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info); return Structure::create(globalData, prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
} }
protected:
void finishCreation(JSGlobalData& globalData)
{
Base::finishCreation(globalData, m_inlineStorage);
ASSERT(!(OBJECT_OFFSETOF(JSFinalObject, m_inlineStorage) % sizeof(double)));
ASSERT(this->structure()->propertyStorageCapacity() == JSFinalObject_inlineStorageCapacity);
}
private: private:
explicit JSFinalObject(JSGlobalData& globalData, Structure* structure) explicit JSFinalObject(JSGlobalData& globalData, Structure* structure)
: JSObject(globalData, structure, m_inlineStorage) : JSObject(globalData, structure, m_inlineStorage)
{ {
ASSERT(OBJECT_OFFSETOF(JSFinalObject, m_inlineStorage) % sizeof(double) == 0);
ASSERT(this->structure()->propertyStorageCapacity() == JSFinalObject_inlineStorageCapacity);
} }
static const unsigned StructureFlags = JSObject::StructureFlags | IsJSFinalObject; static const unsigned StructureFlags = JSObject::StructureFlags | IsJSFinalObject;
...@@ -446,7 +460,6 @@ inline JSObject::JSObject(JSGlobalData& globalData, Structure* structure, Proper ...@@ -446,7 +460,6 @@ inline JSObject::JSObject(JSGlobalData& globalData, Structure* structure, Proper
: JSCell(globalData, structure) : JSCell(globalData, structure)
, m_propertyStorage(inlineStorage) , m_propertyStorage(inlineStorage)
{ {
finishCreation(globalData, inlineStorage);
} }
inline JSObject::~JSObject() inline JSObject::~JSObject()
......
...@@ -43,7 +43,6 @@ inline JSPropertyNameIterator::JSPropertyNameIterator(ExecState* exec, PropertyN ...@@ -43,7 +43,6 @@ inline JSPropertyNameIterator::JSPropertyNameIterator(ExecState* exec, PropertyN
, m_jsStringsSize(propertyNameArrayData->propertyNameVector().size()) , m_jsStringsSize(propertyNameArrayData->propertyNameVector().size())
, m_jsStrings(adoptArrayPtr(new WriteBarrier<Unknown>[m_jsStringsSize])) , m_jsStrings(adoptArrayPtr(new WriteBarrier<Unknown>[m_jsStringsSize]))
{ {
finishCreation(exec, propertyNameArrayData);
} }
JSPropertyNameIterator* JSPropertyNameIterator::create(ExecState* exec, JSObject* o) JSPropertyNameIterator* JSPropertyNameIterator::create(ExecState* exec, JSObject* o)
...@@ -61,6 +60,7 @@ JSPropertyNameIterator* JSPropertyNameIterator::create(ExecState* exec, JSObject ...@@ -61,6 +60,7 @@ JSPropertyNameIterator* JSPropertyNameIterator::create(ExecState* exec, JSObject
numCacheableSlots = o->structure()->propertyStorageSize(); numCacheableSlots = o->structure()->propertyStorageSize();
JSPropertyNameIterator* jsPropertyNameIterator = new (allocateCell<JSPropertyNameIterator>(*exec->heap())) JSPropertyNameIterator(exec, propertyNames.data(), numCacheableSlots); JSPropertyNameIterator* jsPropertyNameIterator = new (allocateCell<JSPropertyNameIterator>(*exec->heap())) JSPropertyNameIterator(exec, propertyNames.data(), numCacheableSlots);
jsPropertyNameIterator->finishCreation(exec, propertyNames.data());
if (o->structure()->isDictionary()) if (o->structure()->isDictionary())
return jsPropertyNameIterator; return jsPropertyNameIterator;
......
...@@ -48,7 +48,9 @@ namespace JSC { ...@@ -48,7 +48,9 @@ namespace JSC {
static JSPropertyNameIterator* create(ExecState*, JSObject*); static JSPropertyNameIterator* create(ExecState*, JSObject*);
static JSPropertyNameIterator* create(ExecState* exec, PropertyNameArrayData* propertyNameArrayData, size_t numCacheableSlot) static JSPropertyNameIterator* create(ExecState* exec, PropertyNameArrayData* propertyNameArrayData, size_t numCacheableSlot)
{ {
return new (allocateCell<JSPropertyNameIterator>(*exec->heap())) JSPropertyNameIterator(exec, propertyNameArrayData, numCacheableSlot); JSPropertyNameIterator* iterator = new (allocateCell<JSPropertyNameIterator>(*exec->heap())) JSPropertyNameIterator(exec, propertyNameArrayData, numCacheableSlot);
iterator->finishCreation(exec, propertyNameArrayData);
return iterator;
} }
static Structure* createStructure(JSGlobalData& globalData, JSValue prototype) static Structure* createStructure(JSGlobalData& globalData, JSValue prototype)
......
...@@ -88,7 +88,6 @@ RegExp::RegExp(JSGlobalData& globalData, const UString& patternString, RegExpFla ...@@ -88,7 +88,6 @@ RegExp::RegExp(JSGlobalData& globalData, const UString& patternString, RegExpFla
, m_rtMatchFoundCount(0) , m_rtMatchFoundCount(0)
#endif #endif
{ {
finishCreation(globalData);
} }
void RegExp::finishCreation(JSGlobalData& globalData) void RegExp::finishCreation(JSGlobalData& globalData)
...@@ -107,7 +106,9 @@ RegExp::~RegExp() ...@@ -107,7 +106,9 @@ RegExp::~RegExp()
RegExp* RegExp::createWithoutCaching(JSGlobalData& globalData, const UString& patternString, RegExpFlags flags) RegExp* RegExp::createWithoutCaching(JSGlobalData& globalData, const UString& patternString, RegExpFlags flags)
{ {
return new (allocateCell<RegExp>(globalData.heap)) RegExp(globalData, patternString, flags); RegExp* regExp = new (allocateCell<RegExp>(globalData.heap)) RegExp(globalData, patternString, flags);
regExp->finishCreation(globalData);
return regExp;
} }
RegExp* RegExp::create(JSGlobalData& globalData, const UString& patternString, RegExpFlags flags) RegExp* RegExp::create(JSGlobalData& globalData, const UString& patternString, RegExpFlags flags)
......
...@@ -43,7 +43,6 @@ namespace JSC { ...@@ -43,7 +43,6 @@ namespace JSC {
, globalObject(*globalData, this, globalObject) , globalObject(*globalData, this, globalObject)
, globalThis(*globalData, this, globalThis) , globalThis(*globalData, this, globalThis)
{ {
finishCreation(globalData, globalObject);
} }
protected: protected:
...@@ -58,11 +57,15 @@ namespace JSC { ...@@ -58,11 +57,15 @@ namespace JSC {
static ScopeChainNode* create(ExecState* exec, ScopeChainNode* next, JSObject* object, JSGlobalData* globalData, JSGlobalObject* globalObject, JSObject* globalThis) static ScopeChainNode* create(ExecState* exec, ScopeChainNode* next, JSObject* object, JSGlobalData* globalData, JSGlobalObject* globalObject, JSObject* globalThis)
{ {
return new (allocateCell<ScopeChainNode>(*exec->heap())) ScopeChainNode(next, object, globalData, globalObject, globalThis); ScopeChainNode* node = new (allocateCell<ScopeChainNode>(*exec->heap())) ScopeChainNode(next, object, globalData, globalObject, globalThis);
node->finishCreation(globalData, globalObject);
return node;
} }
static ScopeChainNode* create(ScopeChainNode* next, JSObject* object, JSGlobalData* globalData, JSGlobalObject* globalObject, JSObject* globalThis) static ScopeChainNode* create(ScopeChainNode* next, JSObject* object, JSGlobalData* globalData, JSGlobalObject* globalObject, JSObject* globalThis)
{ {
return new (allocateCell<ScopeChainNode>(globalData->heap)) ScopeChainNode(next, object, globalData, globalObject, globalThis); ScopeChainNode* node = new (allocateCell<ScopeChainNode>(globalData->heap)) ScopeChainNode(next, object, globalData, globalObject, globalThis);
node->finishCreation(globalData, globalObject);
return node;
} }
JSGlobalData* globalData; JSGlobalData* globalData;
......
...@@ -176,9 +176,6 @@ Structure::Structure(JSGlobalData& globalData, JSValue prototype, const TypeInfo ...@@ -176,9 +176,6 @@ Structure::Structure(JSGlobalData& globalData, JSValue prototype, const TypeInfo
, m_preventExtensions(false) , m_preventExtensions(false)
, m_didTransition(false) , m_didTransition(false)
{ {
finishCreation(globalData);
ASSERT(m_prototype);
ASSERT(m_prototype.isObject() || m_prototype.isNull());
} }
const ClassInfo Structure::s_info = { "Structure", 0, 0, 0 }; const ClassInfo Structure::s_info = { "Structure", 0, 0, 0 };
...@@ -200,10 +197,6 @@ Structure::Structure(JSGlobalData& globalData) ...@@ -200,10 +197,6 @@ Structure::Structure(JSGlobalData& globalData)
, m_preventExtensions(false) , m_preventExtensions(false)
, m_didTransition(false) , m_didTransition(false)
{ {
finishCreation(globalData, this, CreatingEarlyCell);
ASSERT(m_prototype);
ASSERT(m_prototype.isNull());
ASSERT(!globalData.structureStructure);
} }
Structure::Structure(JSGlobalData& globalData, const Structure* previous) Structure::Structure(JSGlobalData& globalData, const Structure* previous)
...@@ -223,9 +216,6 @@ Structure::Structure(JSGlobalData& globalData, const Structure* previous) ...@@ -223,9 +216,6 @@ Structure::Structure(JSGlobalData& globalData, const Structure* previous)
, m_preventExtensions(previous->m_preventExtensions) , m_preventExtensions(previous->m_preventExtensions)
, m_didTransition(true) , m_didTransition(true)
{ {
finishCreation(globalData);
ASSERT(m_prototype);
ASSERT(m_prototype.isObject() || m_prototype.isNull());
} }
Structure::~Structure() Structure::~Structure()
......
...@@ -66,9 +66,28 @@ namespace JSC { ...@@ -66,9 +66,28 @@ namespace JSC {
{ {
ASSERT(globalData.structureStructure); ASSERT(globalData.structureStructure);
ASSERT(classInfo); ASSERT(classInfo);
return new (allocateCell<Structure>(globalData.heap)) Structure(globalData, prototype, typeInfo, anonymousSlotCount, classInfo); Structure* structure = new (allocateCell<Structure>(globalData.heap)) Structure(globalData, prototype, typeInfo, anonymousSlotCount, classInfo);
structure->finishCreation(globalData);
return structure;
} }
protected:
void finishCreation(JSGlobalData& globalData)
{
Base::finishCreation(globalData);
ASSERT(m_prototype);
ASSERT(m_prototype.isObject() || m_prototype.isNull());
}
void finishCreation(JSGlobalData& globalData, CreatingEarlyCellTag)
{
Base::finishCreation(globalData, this, CreatingEarlyCell);
ASSERT(m_prototype);
ASSERT(m_prototype.isNull());
ASSERT(!globalData.structureStructure);
}
public:
static void dumpStatistics(); static void dumpStatistics();
static Structure* addPropertyTransition(JSGlobalData&, Structure*, const Identifier& propertyName, unsigned attributes, JSCell* specificValue, size_t& offset); static Structure* addPropertyTransition(JSGlobalData&, Structure*, const Identifier& propertyName, unsigned attributes, JSCell* specificValue, size_t& offset);
...@@ -161,7 +180,9 @@ namespace JSC { ...@@ -161,7 +180,9 @@ namespace JSC {
static Structure* createStructure(JSGlobalData& globalData) static Structure* createStructure(JSGlobalData& globalData)
{ {
ASSERT(!globalData.structureStructure); ASSERT(!globalData.structureStructure);
return new (allocateCell<Structure>(globalData.heap)) Structure(globalData); Structure* structure = new (allocateCell<Structure>(globalData.heap)) Structure(globalData);
structure->finishCreation(globalData, CreatingEarlyCell);
return structure;
} }
static JS_EXPORTDATA const ClassInfo s_info; static JS_EXPORTDATA const ClassInfo s_info;
...@@ -174,7 +195,9 @@ namespace JSC { ...@@ -174,7 +195,9 @@ namespace JSC {
static Structure* create(JSGlobalData& globalData, const Structure* structure) static Structure* create(JSGlobalData& globalData, const Structure* structure)
{ {
ASSERT(globalData.structureStructure); ASSERT(globalData.structureStructure);
return new (allocateCell<Structure>(globalData.heap)) Structure(globalData, structure); Structure* newStructure = new (allocateCell<Structure>(globalData.heap)) Structure(globalData, structure);
newStructure->finishCreation(globalData);
return newStructure;
} }
typedef enum { typedef enum {
......
...@@ -34,10 +34,9 @@ namespace JSC { ...@@ -34,10 +34,9 @@ namespace JSC {
ClassInfo StructureChain::s_info = { "StructureChain", 0, 0, 0 }; ClassInfo StructureChain::s_info = { "StructureChain", 0, 0, 0 };
StructureChain::StructureChain(JSGlobalData& globalData, Structure* structure, Structure* head) StructureChain::StructureChain(JSGlobalData& globalData, Structure* structure)
: JSCell(globalData, structure) : JSCell(globalData, structure)
{ {
finishCreation(globalData, head);
} }
StructureChain::~StructureChain() StructureChain::~StructureChain()
......
...@@ -47,7 +47,9 @@ namespace JSC { ...@@ -47,7 +47,9 @@ namespace JSC {
static StructureChain* create(JSGlobalData& globalData, Structure* head) static StructureChain* create(JSGlobalData& globalData, Structure* head)
{ {
return new (allocateCell<StructureChain>(globalData.heap)) StructureChain(globalData, globalData.structureChainStructure.get(), head); StructureChain* chain = new (allocateCell<StructureChain>(globalData.heap)) StructureChain(globalData, globalData.structureChainStructure.get());
chain->finishCreation(globalData, head);
return chain;
} }