Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (93919 => 93920)
--- trunk/Source/_javascript_Core/ChangeLog 2011-08-26 22:26:25 UTC (rev 93919)
+++ trunk/Source/_javascript_Core/ChangeLog 2011-08-26 22:32:53 UTC (rev 93920)
@@ -1,3 +1,57 @@
+2011-08-26 Mark Hahnenberg <[email protected]>
+
+ 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 <[email protected]>
The GC does not have a facility for profiling the kinds of objects
Modified: trunk/Source/_javascript_Core/runtime/Executable.h (93919 => 93920)
--- trunk/Source/_javascript_Core/runtime/Executable.h 2011-08-26 22:26:25 UTC (rev 93919)
+++ trunk/Source/_javascript_Core/runtime/Executable.h 2011-08-26 22:32:53 UTC (rev 93920)
@@ -58,7 +58,6 @@
, m_numParametersForCall(numParameters)
, m_numParametersForConstruct(numParameters)
{
- finishCreation(globalData);
}
void finishCreation(JSGlobalData& globalData)
@@ -75,7 +74,9 @@
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
@@ -180,9 +181,12 @@
#if ENABLE(JIT)
static NativeExecutable* create(JSGlobalData& globalData, MacroAssemblerCodePtr callThunk, NativeFunction function, MacroAssemblerCodePtr constructThunk, NativeFunction constructor)
{
+ NativeExecutable* executable;
if (!callThunk)
- return 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);
+ executable = new (allocateCell<NativeExecutable>(globalData.heap)) NativeExecutable(globalData, JITCode(), function, JITCode(), constructor);
+ else
+ executable = new (allocateCell<NativeExecutable>(globalData.heap)) NativeExecutable(globalData, JITCode::HostFunction(callThunk), function, JITCode::HostFunction(constructThunk), constructor);
+ return executable;
}
#else
static NativeExecutable* create(JSGlobalData& globalData, NativeFunction function, NativeFunction constructor)
@@ -198,7 +202,19 @@
static Structure* createStructure(JSGlobalData& globalData, JSValue proto) { return Structure::create(globalData, proto, TypeInfo(LeafType, StructureFlags), AnonymousSlotCount, &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:
#if ENABLE(JIT)
NativeExecutable(JSGlobalData& globalData, JITCode callThunk, NativeFunction function, JITCode constructThunk, NativeFunction constructor)
@@ -206,10 +222,7 @@
, m_function(function)
, m_constructor(constructor)
{
- m_jitCodeForCall = callThunk;
- m_jitCodeForConstruct = constructThunk;
- m_jitCodeForCallWithArityCheck = callThunk.addressForCall();
- m_jitCodeForConstructWithArityCheck = constructThunk.addressForCall();
+ finishCreation(globalData, callThunk, constructThunk);
}
#else
NativeExecutable(JSGlobalData& globalData, NativeFunction function, NativeFunction constructor)
@@ -217,6 +230,7 @@
, m_function(function)
, m_constructor(constructor)
{
+ finishCreation(globalData);
}
#endif
@@ -235,12 +249,7 @@
, m_source(source)
, m_features(isInStrictContext ? StrictModeFeature : 0)
{
-#if ENABLE(CODEBLOCK_SAMPLING)
- if (SamplingTool* sampler = globalData.interpreter->sampler())
- sampler->notifyOfScope(globalData, this);
-#else
- UNUSED_PARAM(globalData);
-#endif
+ finishCreation(globalData);
}
ScriptExecutable(Structure* structure, ExecState* exec, const SourceCode& source, bool isInStrictContext)
@@ -248,12 +257,7 @@
, m_source(source)
, m_features(isInStrictContext ? StrictModeFeature : 0)
{
-#if ENABLE(CODEBLOCK_SAMPLING)
- if (SamplingTool* sampler = exec->globalData().interpreter->sampler())
- sampler->notifyOfScope(exec->globalData(), this);
-#else
- UNUSED_PARAM(exec);
-#endif
+ finishCreation(exec->globalData());
}
const SourceCode& source() { return m_source; }
@@ -270,7 +274,17 @@
virtual void unlinkCalls() = 0;
static const ClassInfo s_info;
+
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)
{
m_features = features;
Modified: trunk/Source/_javascript_Core/runtime/GetterSetter.h (93919 => 93920)
--- trunk/Source/_javascript_Core/runtime/GetterSetter.h 2011-08-26 22:26:25 UTC (rev 93919)
+++ trunk/Source/_javascript_Core/runtime/GetterSetter.h 2011-08-26 22:32:53 UTC (rev 93920)
@@ -41,7 +41,6 @@
GetterSetter(ExecState* exec)
: JSCell(exec->globalData(), exec->globalData().getterSetterStructure.get())
{
- finishCreation(exec->globalData());
}
public:
@@ -49,7 +48,9 @@
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&);
Modified: trunk/Source/_javascript_Core/runtime/JSAPIValueWrapper.h (93919 => 93920)
--- trunk/Source/_javascript_Core/runtime/JSAPIValueWrapper.h 2011-08-26 22:26:25 UTC (rev 93919)
+++ trunk/Source/_javascript_Core/runtime/JSAPIValueWrapper.h 2011-08-26 22:32:53 UTC (rev 93920)
@@ -48,7 +48,9 @@
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:
@@ -60,10 +62,9 @@
}
private:
- JSAPIValueWrapper(ExecState* exec, JSValue value)
+ JSAPIValueWrapper(ExecState* exec)
: JSCell(exec->globalData(), exec->globalData().apiWrapperStructure.get())
{
- finishCreation(exec, value);
}
WriteBarrier<Unknown> m_value;
Modified: trunk/Source/_javascript_Core/runtime/JSObject.h (93919 => 93920)
--- trunk/Source/_javascript_Core/runtime/JSObject.h 2011-08-26 22:26:25 UTC (rev 93919)
+++ trunk/Source/_javascript_Core/runtime/JSObject.h 2011-08-26 22:32:53 UTC (rev 93920)
@@ -361,6 +361,12 @@
explicit JSNonFinalObject(JSGlobalData& globalData, Structure* structure)
: 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(this->structure()->propertyStorageCapacity() == JSNonFinalObject_inlineStorageCapacity);
}
@@ -384,7 +390,9 @@
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)
@@ -392,12 +400,18 @@
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:
explicit JSFinalObject(JSGlobalData& globalData, Structure* structure)
: 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;
@@ -446,7 +460,6 @@
: JSCell(globalData, structure)
, m_propertyStorage(inlineStorage)
{
- finishCreation(globalData, inlineStorage);
}
inline JSObject::~JSObject()
Modified: trunk/Source/_javascript_Core/runtime/JSPropertyNameIterator.cpp (93919 => 93920)
--- trunk/Source/_javascript_Core/runtime/JSPropertyNameIterator.cpp 2011-08-26 22:26:25 UTC (rev 93919)
+++ trunk/Source/_javascript_Core/runtime/JSPropertyNameIterator.cpp 2011-08-26 22:32:53 UTC (rev 93920)
@@ -43,7 +43,6 @@
, m_jsStringsSize(propertyNameArrayData->propertyNameVector().size())
, m_jsStrings(adoptArrayPtr(new WriteBarrier<Unknown>[m_jsStringsSize]))
{
- finishCreation(exec, propertyNameArrayData);
}
JSPropertyNameIterator* JSPropertyNameIterator::create(ExecState* exec, JSObject* o)
@@ -61,6 +60,7 @@
numCacheableSlots = o->structure()->propertyStorageSize();
JSPropertyNameIterator* jsPropertyNameIterator = new (allocateCell<JSPropertyNameIterator>(*exec->heap())) JSPropertyNameIterator(exec, propertyNames.data(), numCacheableSlots);
+ jsPropertyNameIterator->finishCreation(exec, propertyNames.data());
if (o->structure()->isDictionary())
return jsPropertyNameIterator;
Modified: trunk/Source/_javascript_Core/runtime/JSPropertyNameIterator.h (93919 => 93920)
--- trunk/Source/_javascript_Core/runtime/JSPropertyNameIterator.h 2011-08-26 22:26:25 UTC (rev 93919)
+++ trunk/Source/_javascript_Core/runtime/JSPropertyNameIterator.h 2011-08-26 22:32:53 UTC (rev 93920)
@@ -48,7 +48,9 @@
static JSPropertyNameIterator* create(ExecState*, JSObject*);
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)
Modified: trunk/Source/_javascript_Core/runtime/RegExp.cpp (93919 => 93920)
--- trunk/Source/_javascript_Core/runtime/RegExp.cpp 2011-08-26 22:26:25 UTC (rev 93919)
+++ trunk/Source/_javascript_Core/runtime/RegExp.cpp 2011-08-26 22:32:53 UTC (rev 93920)
@@ -88,7 +88,6 @@
, m_rtMatchFoundCount(0)
#endif
{
- finishCreation(globalData);
}
void RegExp::finishCreation(JSGlobalData& globalData)
@@ -107,7 +106,9 @@
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)
Modified: trunk/Source/_javascript_Core/runtime/ScopeChain.h (93919 => 93920)
--- trunk/Source/_javascript_Core/runtime/ScopeChain.h 2011-08-26 22:26:25 UTC (rev 93919)
+++ trunk/Source/_javascript_Core/runtime/ScopeChain.h 2011-08-26 22:32:53 UTC (rev 93920)
@@ -43,7 +43,6 @@
, globalObject(*globalData, this, globalObject)
, globalThis(*globalData, this, globalThis)
{
- finishCreation(globalData, globalObject);
}
protected:
@@ -58,11 +57,15 @@
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)
{
- 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;
Modified: trunk/Source/_javascript_Core/runtime/Structure.cpp (93919 => 93920)
--- trunk/Source/_javascript_Core/runtime/Structure.cpp 2011-08-26 22:26:25 UTC (rev 93919)
+++ trunk/Source/_javascript_Core/runtime/Structure.cpp 2011-08-26 22:32:53 UTC (rev 93920)
@@ -176,9 +176,6 @@
, m_preventExtensions(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 };
@@ -200,10 +197,6 @@
, m_preventExtensions(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)
@@ -223,9 +216,6 @@
, m_preventExtensions(previous->m_preventExtensions)
, m_didTransition(true)
{
- finishCreation(globalData);
- ASSERT(m_prototype);
- ASSERT(m_prototype.isObject() || m_prototype.isNull());
}
Structure::~Structure()
Modified: trunk/Source/_javascript_Core/runtime/Structure.h (93919 => 93920)
--- trunk/Source/_javascript_Core/runtime/Structure.h 2011-08-26 22:26:25 UTC (rev 93919)
+++ trunk/Source/_javascript_Core/runtime/Structure.h 2011-08-26 22:32:53 UTC (rev 93920)
@@ -66,9 +66,28 @@
{
ASSERT(globalData.structureStructure);
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 Structure* addPropertyTransition(JSGlobalData&, Structure*, const Identifier& propertyName, unsigned attributes, JSCell* specificValue, size_t& offset);
@@ -161,7 +180,9 @@
static Structure* createStructure(JSGlobalData& globalData)
{
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;
@@ -174,7 +195,9 @@
static Structure* create(JSGlobalData& globalData, const Structure* structure)
{
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 {
Modified: trunk/Source/_javascript_Core/runtime/StructureChain.cpp (93919 => 93920)
--- trunk/Source/_javascript_Core/runtime/StructureChain.cpp 2011-08-26 22:26:25 UTC (rev 93919)
+++ trunk/Source/_javascript_Core/runtime/StructureChain.cpp 2011-08-26 22:32:53 UTC (rev 93920)
@@ -34,10 +34,9 @@
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)
{
- finishCreation(globalData, head);
}
StructureChain::~StructureChain()
Modified: trunk/Source/_javascript_Core/runtime/StructureChain.h (93919 => 93920)
--- trunk/Source/_javascript_Core/runtime/StructureChain.h 2011-08-26 22:26:25 UTC (rev 93919)
+++ trunk/Source/_javascript_Core/runtime/StructureChain.h 2011-08-26 22:32:53 UTC (rev 93920)
@@ -47,7 +47,9 @@
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;
}
WriteBarrier<Structure>* head() { return m_vector.get(); }
void visitChildren(SlotVisitor&);
@@ -72,7 +74,7 @@
}
private:
- StructureChain(JSGlobalData&, Structure*, Structure* head);
+ StructureChain(JSGlobalData&, Structure*);
~StructureChain();
OwnArrayPtr<WriteBarrier<Structure> > m_vector;
};