Unzip initialization lists and constructors in JSCell hierarchy (3/7)

https://bugs.webkit.org/show_bug.cgi?id=67064

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

Source/JavaScriptCore:

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

This primarily consists of pushing the calls to finishCreation() down
into the constructors of the subclasses of the second level of the hierarchy
as well as pulling the finishCreation() calls out into the class's corresponding
create() method if it has one.  Doing both simultaneously allows us to
maintain the invariant that the finishCreation() method chain is called exactly
once during the creation of an object, since calling it any other number of
times (0, 2, or more) will cause an assertion failure.

* debugger/DebuggerActivation.cpp:
(JSC::DebuggerActivation::DebuggerActivation):
(JSC::DebuggerActivation::finishCreation):
* debugger/DebuggerActivation.h:
(JSC::DebuggerActivation::create):
* runtime/Arguments.h:
(JSC::Arguments::create):
(JSC::Arguments::createNoParameters):
(JSC::Arguments::Arguments):
(JSC::Arguments::finishCreation):
* runtime/ErrorInstance.cpp:
(JSC::ErrorInstance::ErrorInstance):
* runtime/ErrorInstance.h:
(JSC::ErrorInstance::finishCreation):
* runtime/ExceptionHelpers.cpp:
(JSC::InterruptedExecutionError::InterruptedExecutionError):
(JSC::TerminatedExecutionError::TerminatedExecutionError):
* runtime/Executable.cpp:
(JSC::EvalExecutable::EvalExecutable):
(JSC::ProgramExecutable::ProgramExecutable):
(JSC::FunctionExecutable::FunctionExecutable):
Moved the assignment of m_firstLine and m_lastLine into the
FunctionExecutable::finishCreation() method in Executable.h
* runtime/Executable.h:
(JSC::ScriptExecutable::ScriptExecutable):
(JSC::EvalExecutable::create):
(JSC::ProgramExecutable::create):
(JSC::FunctionExecutable::create):
(JSC::FunctionExecutable::finishCreation):
* runtime/JSArray.cpp:
(JSC::JSArray::JSArray):
(JSC::JSArray::finishCreation):
* runtime/JSArray.h:
* runtime/JSByteArray.cpp:
(JSC::JSByteArray::JSByteArray):
* runtime/JSByteArray.h:
(JSC::JSByteArray::finishCreation):
* runtime/JSNotAnObject.h:
(JSC::JSNotAnObject::JSNotAnObject):
* runtime/JSObject.h:
(JSC::JSNonFinalObject::JSNonFinalObject):
* runtime/JSObjectWithGlobalObject.cpp:
(JSC::JSObjectWithGlobalObject::JSObjectWithGlobalObject):
(JSC::JSObjectWithGlobalObject::finishCreation):
* runtime/JSObjectWithGlobalObject.h:
* runtime/JSVariableObject.h:
(JSC::JSVariableObject::JSVariableObject):
(JSC::JSVariableObject::finishCreation):
* runtime/JSWrapperObject.h:
(JSC::JSWrapperObject::JSWrapperObject):
* runtime/ObjectPrototype.cpp:
(JSC::ObjectPrototype::ObjectPrototype):
(JSC::ObjectPrototype::finishCreation):
* runtime/ObjectPrototype.h:
* runtime/StrictEvalActivation.cpp:
(JSC::StrictEvalActivation::StrictEvalActivation):

Source/JavaScriptGlue:

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

This primarily consists of pushing the calls to finishCreation() down
into the constructors of the subclasses of the second level of the hierarchy
as well as pulling the finishCreation() calls out into the class's corresponding
create() method if it has one.  Doing both simultaneously allows us to
maintain the invariant that the finishCreation() method chain is called exactly
once during the creation of an object, since calling it any other number of
times (0, 2, or more) will cause an assertion failure.

* UserObjectImp.cpp:
(UserObjectImp::UserObjectImp):

Source/WebCore:

No new tests.

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

This primarily consists of pushing the calls to finishCreation() down
into the constructors of the subclasses of the second level of the hierarchy
as well as pulling the finishCreation() calls out into the class's corresponding
create() method if it has one.  Doing both simultaneously allows us to
maintain the invariant that the finishCreation() method chain is called exactly
once during the creation of an object, since calling it any other number of
times (0, 2, or more) will cause an assertion failure.

* bindings/js/JSDOMWindowShell.cpp:
(WebCore::JSDOMWindowShell::JSDOMWindowShell):
(WebCore::JSDOMWindowShell::finishCreation):
* bindings/js/JSDOMWindowShell.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@94035 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 05df213e
2011-08-29 Mark Hahnenberg <mhahnenberg@apple.com>
Unzip initialization lists and constructors in JSCell hierarchy (3/7)
https://bugs.webkit.org/show_bug.cgi?id=67064
Reviewed by Darin Adler.
Completed the third level of the refactoring to add finishCreation()
methods to all classes within the JSCell hierarchy with non-trivial
constructor bodies.
This primarily consists of pushing the calls to finishCreation() down
into the constructors of the subclasses of the second level of the hierarchy
as well as pulling the finishCreation() calls out into the class's corresponding
create() method if it has one. Doing both simultaneously allows us to
maintain the invariant that the finishCreation() method chain is called exactly
once during the creation of an object, since calling it any other number of
times (0, 2, or more) will cause an assertion failure.
* debugger/DebuggerActivation.cpp:
(JSC::DebuggerActivation::DebuggerActivation):
(JSC::DebuggerActivation::finishCreation):
* debugger/DebuggerActivation.h:
(JSC::DebuggerActivation::create):
* runtime/Arguments.h:
(JSC::Arguments::create):
(JSC::Arguments::createNoParameters):
(JSC::Arguments::Arguments):
(JSC::Arguments::finishCreation):
* runtime/ErrorInstance.cpp:
(JSC::ErrorInstance::ErrorInstance):
* runtime/ErrorInstance.h:
(JSC::ErrorInstance::finishCreation):
* runtime/ExceptionHelpers.cpp:
(JSC::InterruptedExecutionError::InterruptedExecutionError):
(JSC::TerminatedExecutionError::TerminatedExecutionError):
* runtime/Executable.cpp:
(JSC::EvalExecutable::EvalExecutable):
(JSC::ProgramExecutable::ProgramExecutable):
(JSC::FunctionExecutable::FunctionExecutable):
Moved the assignment of m_firstLine and m_lastLine into the
FunctionExecutable::finishCreation() method in Executable.h
* runtime/Executable.h:
(JSC::ScriptExecutable::ScriptExecutable):
(JSC::EvalExecutable::create):
(JSC::ProgramExecutable::create):
(JSC::FunctionExecutable::create):
(JSC::FunctionExecutable::finishCreation):
* runtime/JSArray.cpp:
(JSC::JSArray::JSArray):
(JSC::JSArray::finishCreation):
* runtime/JSArray.h:
* runtime/JSByteArray.cpp:
(JSC::JSByteArray::JSByteArray):
* runtime/JSByteArray.h:
(JSC::JSByteArray::finishCreation):
* runtime/JSNotAnObject.h:
(JSC::JSNotAnObject::JSNotAnObject):
* runtime/JSObject.h:
(JSC::JSNonFinalObject::JSNonFinalObject):
* runtime/JSObjectWithGlobalObject.cpp:
(JSC::JSObjectWithGlobalObject::JSObjectWithGlobalObject):
(JSC::JSObjectWithGlobalObject::finishCreation):
* runtime/JSObjectWithGlobalObject.h:
* runtime/JSVariableObject.h:
(JSC::JSVariableObject::JSVariableObject):
(JSC::JSVariableObject::finishCreation):
* runtime/JSWrapperObject.h:
(JSC::JSWrapperObject::JSWrapperObject):
* runtime/ObjectPrototype.cpp:
(JSC::ObjectPrototype::ObjectPrototype):
(JSC::ObjectPrototype::finishCreation):
* runtime/ObjectPrototype.h:
* runtime/StrictEvalActivation.cpp:
(JSC::StrictEvalActivation::StrictEvalActivation):
2011-08-29 Andreas Kling <kling@webkit.org>
Unreviewed build fix after r93990.
......
......@@ -33,6 +33,12 @@ namespace JSC {
DebuggerActivation::DebuggerActivation(JSGlobalData& globalData, JSObject* activation)
: JSNonFinalObject(globalData, globalData.debuggerActivationStructure.get())
{
finishCreation(globalData, activation);
}
void DebuggerActivation::finishCreation(JSGlobalData& globalData, JSObject* activation)
{
Base::finishCreation(globalData);
ASSERT(activation);
ASSERT(activation->isActivationObject());
m_activation.set(globalData, this, static_cast<JSActivation*>(activation));
......
......@@ -30,15 +30,14 @@
namespace JSC {
class JSActivation;
class DebuggerActivation : public JSNonFinalObject {
public:
typedef JSNonFinalObject Base;
static DebuggerActivation* create(JSGlobalData& globalData, JSObject* object)
{
return new (allocateCell<DebuggerActivation>(globalData.heap)) DebuggerActivation(globalData, object);
DebuggerActivation* activation = new (allocateCell<DebuggerActivation>(globalData.heap)) DebuggerActivation(globalData, object);
return activation;
}
virtual void visitChildren(SlotVisitor&);
......@@ -62,6 +61,8 @@ namespace JSC {
protected:
static const unsigned StructureFlags = OverridesGetOwnPropertySlot | OverridesVisitChildren | JSObject::StructureFlags;
void finishCreation(JSGlobalData&, JSObject* activation);
private:
DebuggerActivation(JSGlobalData&, JSObject*);
WriteBarrier<JSActivation> m_activation;
......
......@@ -63,12 +63,14 @@ namespace JSC {
static Arguments* create(JSGlobalData& globalData, CallFrame* callFrame)
{
return new (allocateCell<Arguments>(globalData.heap)) Arguments(callFrame);
Arguments* arguments = new (allocateCell<Arguments>(globalData.heap)) Arguments(callFrame);
return arguments;
}
static Arguments* createNoParameters(JSGlobalData& globalData, CallFrame* callFrame)
{
return new (allocateCell<Arguments>(globalData.heap)) Arguments(callFrame, NoParameters);
Arguments* arguments = new (allocateCell<Arguments>(globalData.heap)) Arguments(callFrame, NoParameters);
return arguments;
}
// Use an enum because otherwise gcc insists on doing a memory
......@@ -115,6 +117,9 @@ namespace JSC {
protected:
static const unsigned StructureFlags = OverridesGetOwnPropertySlot | OverridesVisitChildren | OverridesGetPropertyNames | JSObject::StructureFlags;
void finishCreation(CallFrame*);
void finishCreation(CallFrame*, NoParametersType);
private:
void getArgumentsData(CallFrame*, JSFunction*&, ptrdiff_t& firstParameterIndex, Register*& argv, int& argc);
virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
......@@ -161,6 +166,19 @@ namespace JSC {
: JSNonFinalObject(callFrame->globalData(), callFrame->lexicalGlobalObject()->argumentsStructure())
, d(adoptPtr(new ArgumentsData))
{
finishCreation(callFrame);
}
inline Arguments::Arguments(CallFrame* callFrame, NoParametersType)
: JSNonFinalObject(callFrame->globalData(), callFrame->lexicalGlobalObject()->argumentsStructure())
, d(adoptPtr(new ArgumentsData))
{
finishCreation(callFrame, NoParameters);
}
inline void Arguments::finishCreation(CallFrame* callFrame)
{
Base::finishCreation(callFrame->globalData());
ASSERT(inherits(&s_info));
JSFunction* callee;
......@@ -199,10 +217,9 @@ namespace JSC {
copyRegisters(callFrame->globalData());
}
inline Arguments::Arguments(CallFrame* callFrame, NoParametersType)
: JSNonFinalObject(callFrame->globalData(), callFrame->lexicalGlobalObject()->argumentsStructure())
, d(adoptPtr(new ArgumentsData))
inline void Arguments::finishCreation(CallFrame* callFrame, NoParametersType)
{
Base::finishCreation(callFrame->globalData());
ASSERT(inherits(&s_info));
ASSERT(!asFunction(callFrame->callee())->jsExecutable()->parameterCount());
......
......@@ -29,15 +29,14 @@ ErrorInstance::ErrorInstance(JSGlobalData& globalData, Structure* structure)
: JSNonFinalObject(globalData, structure)
, m_appendSourceToMessage(false)
{
constructorBody(globalData);
finishCreation(globalData, UString("", 0));
}
ErrorInstance::ErrorInstance(JSGlobalData& globalData, Structure* structure, const UString& message)
: JSNonFinalObject(globalData, structure)
, m_appendSourceToMessage(false)
{
ASSERT(inherits(&s_info));
putDirect(globalData, globalData.propertyNames->message, jsString(&globalData, message), DontEnum);
finishCreation(globalData, message);
}
ErrorInstance* ErrorInstance::create(JSGlobalData& globalData, Structure* structure, const UString& message)
......
......@@ -50,10 +50,11 @@ namespace JSC {
explicit ErrorInstance(JSGlobalData&, Structure*);
explicit ErrorInstance(JSGlobalData&, Structure*, const UString&);
void constructorBody(JSGlobalData& globalData)
void finishCreation(JSGlobalData& globalData, const UString& message)
{
Base::finishCreation(globalData);
ASSERT(inherits(&s_info));
putDirect(globalData, globalData.propertyNames->message, jsString(&globalData, ""), DontEnum);
putDirect(globalData, globalData.propertyNames->message, jsString(&globalData, message), DontEnum);
}
bool m_appendSourceToMessage;
......
......@@ -46,6 +46,7 @@ private:
InterruptedExecutionError(JSGlobalData& globalData)
: JSNonFinalObject(globalData, globalData.interruptedExecutionErrorStructure.get())
{
finishCreation(globalData);
}
public:
......@@ -71,6 +72,7 @@ private:
TerminatedExecutionError(JSGlobalData& globalData)
: JSNonFinalObject(globalData, globalData.terminatedExecutionErrorStructure.get())
{
finishCreation(globalData);
}
public:
......
......@@ -127,6 +127,7 @@ const ClassInfo EvalExecutable::s_info = { "EvalExecutable", &ScriptExecutable::
EvalExecutable::EvalExecutable(ExecState* exec, const SourceCode& source, bool inStrictContext)
: ScriptExecutable(exec->globalData().evalExecutableStructure.get(), exec, source, inStrictContext)
{
finishCreation(exec->globalData());
}
EvalExecutable::~EvalExecutable()
......@@ -138,6 +139,7 @@ const ClassInfo ProgramExecutable::s_info = { "ProgramExecutable", &ScriptExecut
ProgramExecutable::ProgramExecutable(ExecState* exec, const SourceCode& source)
: ScriptExecutable(exec->globalData().programExecutableStructure.get(), exec, source, false)
{
finishCreation(exec->globalData());
}
ProgramExecutable::~ProgramExecutable()
......@@ -165,8 +167,6 @@ FunctionExecutable::FunctionExecutable(ExecState* exec, const Identifier& name,
, m_name(name)
, m_symbolTable(0)
{
m_firstLine = firstLine;
m_lastLine = lastLine;
finishCreation(exec->globalData(), name, firstLine, lastLine);
}
......
......@@ -243,7 +243,6 @@ namespace JSC {
, m_source(source)
, m_features(isInStrictContext ? StrictModeFeature : 0)
{
finishCreation(globalData);
}
ScriptExecutable(Structure* structure, ExecState* exec, const SourceCode& source, bool isInStrictContext)
......@@ -251,7 +250,6 @@ namespace JSC {
, m_source(source)
, m_features(isInStrictContext ? StrictModeFeature : 0)
{
finishCreation(exec->globalData());
}
const SourceCode& source() { return m_source; }
......@@ -318,7 +316,8 @@ namespace JSC {
static EvalExecutable* create(ExecState* exec, const SourceCode& source, bool isInStrictContext)
{
return new (allocateCell<EvalExecutable>(*exec->heap())) EvalExecutable(exec, source, isInStrictContext);
EvalExecutable* executable = new (allocateCell<EvalExecutable>(*exec->heap())) EvalExecutable(exec, source, isInStrictContext);
return executable;
}
#if ENABLE(JIT)
......@@ -354,7 +353,8 @@ namespace JSC {
static ProgramExecutable* create(ExecState* exec, const SourceCode& source)
{
return new (allocateCell<ProgramExecutable>(*exec->heap())) ProgramExecutable(exec, source);
ProgramExecutable* executable = new (allocateCell<ProgramExecutable>(*exec->heap())) ProgramExecutable(exec, source);
return executable;
}
~ProgramExecutable();
......@@ -412,12 +412,14 @@ namespace JSC {
static FunctionExecutable* create(ExecState* exec, const Identifier& name, const SourceCode& source, bool forceUsesArguments, FunctionParameters* parameters, bool isInStrictContext, int firstLine, int lastLine)
{
return new (allocateCell<FunctionExecutable>(*exec->heap())) FunctionExecutable(exec, name, source, forceUsesArguments, parameters, isInStrictContext, firstLine, lastLine);
FunctionExecutable* executable = new (allocateCell<FunctionExecutable>(*exec->heap())) FunctionExecutable(exec, name, source, forceUsesArguments, parameters, isInStrictContext, firstLine, lastLine);
return executable;
}
static FunctionExecutable* create(JSGlobalData& globalData, const Identifier& name, const SourceCode& source, bool forceUsesArguments, FunctionParameters* parameters, bool isInStrictContext, int firstLine, int lastLine)
{
return new (allocateCell<FunctionExecutable>(globalData.heap)) FunctionExecutable(globalData, name, source, forceUsesArguments, parameters, isInStrictContext, firstLine, lastLine);
FunctionExecutable* executable = new (allocateCell<FunctionExecutable>(globalData.heap)) FunctionExecutable(globalData, name, source, forceUsesArguments, parameters, isInStrictContext, firstLine, lastLine);
return executable;
}
JSFunction* make(ExecState* exec, ScopeChainNode* scopeChain)
......@@ -530,6 +532,7 @@ namespace JSC {
void finishCreation(JSGlobalData& globalData, const Identifier& name, int firstLine, int lastLine)
{
Base::finishCreation(globalData);
m_firstLine = firstLine;
m_lastLine = lastLine;
m_nameValue.set(globalData, this, jsString(&globalData, name.ustring()));
......
......@@ -134,6 +134,24 @@ JSArray::JSArray(VPtrStealingHackType)
JSArray::JSArray(JSGlobalData& globalData, Structure* structure)
: JSNonFinalObject(globalData, structure)
{
finishCreation(globalData);
}
JSArray::JSArray(JSGlobalData& globalData, Structure* structure, unsigned initialLength, ArrayCreationMode creationMode)
: JSNonFinalObject(globalData, structure)
{
finishCreation(globalData, initialLength, creationMode);
}
JSArray::JSArray(JSGlobalData& globalData, Structure* structure, const ArgList& list)
: JSNonFinalObject(globalData, structure)
{
finishCreation(globalData, list);
}
void JSArray::finishCreation(JSGlobalData& globalData)
{
Base::finishCreation(globalData);
ASSERT(inherits(&s_info));
unsigned initialCapacity = 0;
......@@ -148,9 +166,9 @@ JSArray::JSArray(JSGlobalData& globalData, Structure* structure)
Heap::heap(this)->reportExtraMemoryCost(storageSize(0));
}
JSArray::JSArray(JSGlobalData& globalData, Structure* structure, unsigned initialLength, ArrayCreationMode creationMode)
: JSNonFinalObject(globalData, structure)
void JSArray::finishCreation(JSGlobalData& globalData, unsigned initialLength, ArrayCreationMode creationMode)
{
Base::finishCreation(globalData);
ASSERT(inherits(&s_info));
unsigned initialCapacity;
......@@ -190,9 +208,9 @@ JSArray::JSArray(JSGlobalData& globalData, Structure* structure, unsigned initia
Heap::heap(this)->reportExtraMemoryCost(storageSize(initialCapacity));
}
JSArray::JSArray(JSGlobalData& globalData, Structure* structure, const ArgList& list)
: JSNonFinalObject(globalData, structure)
void JSArray::finishCreation(JSGlobalData& globalData, const ArgList& list)
{
Base::finishCreation(globalData);
ASSERT(inherits(&s_info));
unsigned initialCapacity = list.size();
......
......@@ -64,7 +64,11 @@ namespace JSC {
explicit JSArray(JSGlobalData&, Structure*);
JSArray(JSGlobalData&, Structure*, unsigned initialLength, ArrayCreationMode);
JSArray(JSGlobalData&, Structure*, const ArgList& initialValues);
void finishCreation(JSGlobalData&);
void finishCreation(JSGlobalData&, unsigned initialLength, ArrayCreationMode);
void finishCreation(JSGlobalData&, const ArgList&);
public:
typedef JSNonFinalObject Base;
......
......@@ -39,7 +39,7 @@ JSByteArray::JSByteArray(ExecState* exec, Structure* structure, ByteArray* stora
: JSNonFinalObject(exec->globalData(), structure)
, m_storage(storage)
{
constructorBody(exec);
finishCreation(exec);
}
JSByteArray* JSByteArray::create(ExecState* exec, Structure* structure, ByteArray* storage)
......
......@@ -104,8 +104,9 @@ namespace JSC {
protected:
static const unsigned StructureFlags = OverridesGetOwnPropertySlot | OverridesGetPropertyNames | JSObject::StructureFlags;
void constructorBody(ExecState* exec)
void finishCreation(ExecState* exec)
{
Base::finishCreation(exec->globalData());
putDirect(exec->globalData(), exec->globalData().propertyNames->length, jsNumber(m_storage->length()), ReadOnly | DontDelete);
}
......
......@@ -41,6 +41,7 @@ namespace JSC {
JSNotAnObject(ExecState* exec)
: JSNonFinalObject(exec->globalData(), exec->globalData().notAnObjectStructure.get())
{
finishCreation(exec->globalData());
}
public:
......
......@@ -361,7 +361,6 @@ COMPILE_ASSERT((JSFinalObject_inlineStorageCapacity >= JSNonFinalObject_inlineSt
explicit JSNonFinalObject(JSGlobalData& globalData, Structure* structure)
: JSObject(globalData, structure, m_inlineStorage)
{
finishCreation(globalData);
}
void finishCreation(JSGlobalData& globalData)
......
......@@ -33,17 +33,18 @@ namespace JSC {
JSObjectWithGlobalObject::JSObjectWithGlobalObject(JSGlobalObject* globalObject, Structure* structure)
: JSNonFinalObject(globalObject->globalData(), structure)
{
COMPILE_ASSERT(AnonymousSlotCount == 1, AnonymousSlotCount_must_be_one);
ASSERT(!globalObject || globalObject->isGlobalObject());
if (!globalObject)
clearAnonymousValue(GlobalObjectSlot);
else
putAnonymousValue(globalObject->globalData(), GlobalObjectSlot, globalObject);
finishCreation(globalObject->globalData(), globalObject);
}
JSObjectWithGlobalObject::JSObjectWithGlobalObject(JSGlobalData& globalData, JSGlobalObject* globalObject, Structure* structure)
: JSNonFinalObject(globalData, structure)
{
finishCreation(globalData, globalObject);
}
void JSObjectWithGlobalObject::finishCreation(JSGlobalData& globalData, JSGlobalObject* globalObject)
{
Base::finishCreation(globalData);
COMPILE_ASSERT(AnonymousSlotCount == 1, AnonymousSlotCount_must_be_one);
ASSERT(!globalObject || globalObject->isGlobalObject());
if (!globalObject)
......
......@@ -34,6 +34,8 @@ class JSGlobalObject;
class JSObjectWithGlobalObject : public JSNonFinalObject {
public:
typedef JSNonFinalObject Base;
static Structure* createStructure(JSGlobalData& globalData, JSValue proto)
{
return Structure::create(globalData, proto, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
......@@ -53,6 +55,9 @@ protected:
{
// Should only be used by JSFunction when we aquire the JSFunction vptr.
}
void finishCreation(JSGlobalData&, JSGlobalObject*);
static const unsigned AnonymousSlotCount = JSObject::AnonymousSlotCount + 1;
static const unsigned GlobalObjectSlot = 0;
};
......
......@@ -74,6 +74,12 @@ namespace JSC {
, m_symbolTable(symbolTable)
, m_registers(reinterpret_cast<WriteBarrier<Unknown>*>(registers))
{
finishCreation(globalData);
}
void finishCreation(JSGlobalData& globalData)
{
Base::finishCreation(globalData);
ASSERT(m_symbolTable);
COMPILE_ASSERT(sizeof(WriteBarrier<Unknown>) == sizeof(Register), Register_should_be_same_size_as_WriteBarrier);
}
......
......@@ -53,6 +53,7 @@ namespace JSC {
inline JSWrapperObject::JSWrapperObject(JSGlobalData& globalData, Structure* structure)
: JSNonFinalObject(globalData, structure)
{
finishCreation(globalData);
}
inline JSValue JSWrapperObject::internalValue() const
......
......@@ -67,6 +67,12 @@ ObjectPrototype::ObjectPrototype(ExecState* exec, JSGlobalObject* globalObject,
: JSNonFinalObject(exec->globalData(), stucture)
, m_hasNoPropertiesWithUInt32Names(true)
{
finishCreation(exec->globalData(), globalObject);
}
void ObjectPrototype::finishCreation(JSGlobalData& globalData, JSGlobalObject* globalObject)
{
Base::finishCreation(globalData);
ASSERT(inherits(&s_info));
putAnonymousValue(globalObject->globalData(), 0, globalObject);
}
......
......@@ -45,6 +45,8 @@ namespace JSC {
static const unsigned StructureFlags = OverridesGetOwnPropertySlot | JSNonFinalObject::StructureFlags;
static const unsigned AnonymousSlotCount = JSNonFinalObject::AnonymousSlotCount + 1;
void finishCreation(JSGlobalData&, JSGlobalObject*);
private:
ObjectPrototype(ExecState*, JSGlobalObject*, Structure*);
virtual void put(ExecState*, const Identifier&, JSValue, PutPropertySlot&);
......
......@@ -31,6 +31,7 @@ namespace JSC {
StrictEvalActivation::StrictEvalActivation(ExecState* exec)
: JSNonFinalObject(exec->globalData(), exec->globalData().strictEvalActivationStructure.get())
{
finishCreation(exec->globalData());
}
bool StrictEvalActivation::deleteProperty(ExecState*, const Identifier&)
......
2011-08-29 Mark Hahnenberg <mhahnenberg@apple.com>
Unzip initialization lists and constructors in JSCell hierarchy (3/7)
https://bugs.webkit.org/show_bug.cgi?id=67064
Reviewed by Darin Adler.
Completed the third level of the refactoring to add finishCreation()
methods to all classes within the JSCell hierarchy with non-trivial
constructor bodies.
This primarily consists of pushing the calls to finishCreation() down
into the constructors of the subclasses of the second level of the hierarchy
as well as pulling the finishCreation() calls out into the class's corresponding
create() method if it has one. Doing both simultaneously allows us to
maintain the invariant that the finishCreation() method chain is called exactly
once during the creation of an object, since calling it any other number of
times (0, 2, or more) will cause an assertion failure.
* UserObjectImp.cpp:
(UserObjectImp::UserObjectImp):
2011-08-15 Mark Hahnenberg <mhahnenberg@apple.com>
Refactor JS objects to allocate in static create methods rather than constructors
......
......@@ -38,6 +38,7 @@ UserObjectImp::UserObjectImp(JSGlobalData& globalData, Structure* structure, JSU
: JSNonFinalObject(globalData, structure)
, fJSUserObject((JSUserObject*)userObject->Retain())
{
finishCreation(globalData);
}
UserObjectImp::~UserObjectImp()
......
2011-08-29 Mark Hahnenberg <mhahnenberg@apple.com>
Unzip initialization lists and constructors in JSCell hierarchy (3/7)
https://bugs.webkit.org/show_bug.cgi?id=67064
Reviewed by Darin Adler.
No new tests.
Completed the third level of the refactoring to add finishCreation()
methods to all classes within the JSCell hierarchy with non-trivial
constructor bodies.
This primarily consists of pushing the calls to finishCreation() down
into the constructors of the subclasses of the second level of the hierarchy
as well as pulling the finishCreation() calls out into the class's corresponding
create() method if it has one. Doing both simultaneously allows us to
maintain the invariant that the finishCreation() method chain is called exactly
once during the creation of an object, since calling it any other number of
times (0, 2, or more) will cause an assertion failure.
* bindings/js/JSDOMWindowShell.cpp:
(WebCore::JSDOMWindowShell::JSDOMWindowShell):
(WebCore::JSDOMWindowShell::finishCreation):
* bindings/js/JSDOMWindowShell.h:
2011-08-29 John Bauman <jbauman@chromium.org>
Speed up texImage from BGRA
......@@ -47,6 +47,12 @@ JSDOMWindowShell::JSDOMWindowShell(PassRefPtr<DOMWindow> window, Structure* stru
: Base(*world->globalData(), structure)
, m_world(world)
{
finishCreation(*world->globalData(), window);
}
void JSDOMWindowShell::finishCreation(JSGlobalData& globalData, PassRefPtr<DOMWindow> window)
{
Base::finishCreation(globalData);
ASSERT(inherits(&s_info));
setWindow(window);
}
......
......@@ -64,6 +64,9 @@ namespace WebCore {
DOMWrapperWorld* world() { return m_world.get(); }
protected:
void finishCreation(JSC::JSGlobalData&, PassRefPtr<DOMWindow>);
private:
static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::OverridesVisitChildren | JSC::OverridesGetPropertyNames | Base::StructureFlags;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment