Commit aa2c55b9 authored by oliver@apple.com's avatar oliver@apple.com

2010-01-28 Oliver Hunt <oliver@apple.com>

        Reviewed by Gavin Barraclough.

        Simplify anonymous slot implementation
        https://bugs.webkit.org/show_bug.cgi?id=34282

        A class must now specify the number of slots it needs at construction time
        rather than later on with a transition.  This makes many things simpler,
        we no longer need to need an additional transition on object creation to
        add the anonymous slots, and we remove the need for a number of transition
        type checks.

        * API/JSCallbackConstructor.h:
        (JSC::JSCallbackConstructor::createStructure):
        * API/JSCallbackFunction.h:
        (JSC::JSCallbackFunction::createStructure):
        * API/JSCallbackObject.h:
        (JSC::JSCallbackObject::createStructure):
        * JavaScriptCore.exp:
        * debugger/DebuggerActivation.h:
        (JSC::DebuggerActivation::createStructure):
        * runtime/Arguments.h:
        (JSC::Arguments::createStructure):
        * runtime/BooleanObject.h:
        (JSC::BooleanObject::createStructure):
        * runtime/DateInstance.h:
        (JSC::DateInstance::createStructure):
        * runtime/DatePrototype.h:
        (JSC::DatePrototype::createStructure):
        * runtime/FunctionPrototype.h:
        (JSC::FunctionPrototype::createStructure):
        * runtime/GetterSetter.h:
        (JSC::GetterSetter::createStructure):
        * runtime/GlobalEvalFunction.h:
        (JSC::GlobalEvalFunction::createStructure):
        * runtime/InternalFunction.h:
        (JSC::InternalFunction::createStructure):
        * runtime/JSAPIValueWrapper.h:
        (JSC::JSAPIValueWrapper::createStructure):
        * runtime/JSActivation.h:
        (JSC::JSActivation::createStructure):
        * runtime/JSArray.h:
        (JSC::JSArray::createStructure):
        * runtime/JSByteArray.cpp:
        (JSC::JSByteArray::createStructure):
        * runtime/JSCell.h:
        (JSC::JSCell::createDummyStructure):
        * runtime/JSFunction.h:
        (JSC::JSFunction::createStructure):
        * runtime/JSGlobalObject.h:
        (JSC::JSGlobalObject::createStructure):
        * runtime/JSNotAnObject.h:
        (JSC::JSNotAnObject::createStructure):
        * runtime/JSONObject.h:
        (JSC::JSONObject::createStructure):
        * runtime/JSObject.h:
        (JSC::JSObject::createStructure):
        (JSC::JSObject::putAnonymousValue):
        (JSC::JSObject::getAnonymousValue):
        * runtime/JSPropertyNameIterator.h:
        (JSC::JSPropertyNameIterator::createStructure):
        * runtime/JSStaticScopeObject.h:
        (JSC::JSStaticScopeObject::createStructure):
        * runtime/JSString.h:
        (JSC::Fiber::createStructure):
        * runtime/JSVariableObject.h:
        (JSC::JSVariableObject::createStructure):
        * runtime/JSWrapperObject.h:
        (JSC::JSWrapperObject::createStructure):
        (JSC::JSWrapperObject::JSWrapperObject):
        * runtime/MathObject.h:
        (JSC::MathObject::createStructure):
        * runtime/NumberConstructor.h:
        (JSC::NumberConstructor::createStructure):
        * runtime/NumberObject.h:
        (JSC::NumberObject::createStructure):
        * runtime/RegExpConstructor.h:
        (JSC::RegExpConstructor::createStructure):
        * runtime/RegExpObject.h:
        (JSC::RegExpObject::createStructure):
        * runtime/StringObject.h:
        (JSC::StringObject::createStructure):
        * runtime/StringObjectThatMasqueradesAsUndefined.h:
        (JSC::StringObjectThatMasqueradesAsUndefined::createStructure):
        * runtime/Structure.cpp:
        (JSC::Structure::~Structure):
        (JSC::Structure::materializePropertyMap):
        * runtime/Structure.h:
        (JSC::Structure::create):
        (JSC::Structure::anonymousSlotCount):
        * runtime/StructureTransitionTable.h:
2010-01-28  Oliver Hunt  <oliver@apple.com>

        Reviewed by Gavin Barraclough.

        Simplify anonymous slot implementation
        https://bugs.webkit.org/show_bug.cgi?id=34282

        Update JSGlue Structure usage to pass the anonymous slot count.

        * UserObjectImp.h:
        (UserObjectImp::createStructure):
2010-01-28  Oliver Hunt  <oliver@apple.com>

        Reviewed by Gavin Barraclough.

        Simplify anonymous slot implementation
        https://bugs.webkit.org/show_bug.cgi?id=34282

        Update the WebCore JS DOM bindings to correctly pass and
        propagate the anonymous slot count information.

        * bindings/js/JSDOMBinding.h:
        (WebCore::DOMObjectWithGlobalPointer::createStructure):
        (WebCore::DOMConstructorObject::createStructure):
        * bindings/js/JSDOMWindowShell.h:
        (WebCore::JSDOMWindowShell::createStructure):
        * bindings/scripts/CodeGeneratorJS.pm:
        * bridge/objc/objc_runtime.h:
        (JSC::Bindings::ObjcFallbackObjectImp::createStructure):
        * bridge/runtime_array.h:
        (JSC::RuntimeArray::createStructure):
        * bridge/runtime_method.h:
        (JSC::RuntimeMethod::createStructure):
        * bridge/runtime_object.h:
        (JSC::RuntimeObjectImp::createStructure):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54022 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 4b55d704
......@@ -41,7 +41,7 @@ public:
static PassRefPtr<Structure> createStructure(JSValue proto)
{
return Structure::create(proto, TypeInfo(ObjectType, StructureFlags));
return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
}
protected:
......
......@@ -41,7 +41,7 @@ public:
// refactor the code so this override isn't necessary
static PassRefPtr<Structure> createStructure(JSValue proto)
{
return Structure::create(proto, TypeInfo(ObjectType, StructureFlags));
return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
}
private:
......
......@@ -50,7 +50,7 @@ public:
static PassRefPtr<Structure> createStructure(JSValue proto)
{
return Structure::create(proto, TypeInfo(ObjectType, StructureFlags));
return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), Base::AnonymousSlotCount);
}
protected:
......
2010-01-28 Oliver Hunt <oliver@apple.com>
Reviewed by Gavin Barraclough.
Simplify anonymous slot implementation
https://bugs.webkit.org/show_bug.cgi?id=34282
A class must now specify the number of slots it needs at construction time
rather than later on with a transition. This makes many things simpler,
we no longer need to need an additional transition on object creation to
add the anonymous slots, and we remove the need for a number of transition
type checks.
* API/JSCallbackConstructor.h:
(JSC::JSCallbackConstructor::createStructure):
* API/JSCallbackFunction.h:
(JSC::JSCallbackFunction::createStructure):
* API/JSCallbackObject.h:
(JSC::JSCallbackObject::createStructure):
* JavaScriptCore.exp:
* debugger/DebuggerActivation.h:
(JSC::DebuggerActivation::createStructure):
* runtime/Arguments.h:
(JSC::Arguments::createStructure):
* runtime/BooleanObject.h:
(JSC::BooleanObject::createStructure):
* runtime/DateInstance.h:
(JSC::DateInstance::createStructure):
* runtime/DatePrototype.h:
(JSC::DatePrototype::createStructure):
* runtime/FunctionPrototype.h:
(JSC::FunctionPrototype::createStructure):
* runtime/GetterSetter.h:
(JSC::GetterSetter::createStructure):
* runtime/GlobalEvalFunction.h:
(JSC::GlobalEvalFunction::createStructure):
* runtime/InternalFunction.h:
(JSC::InternalFunction::createStructure):
* runtime/JSAPIValueWrapper.h:
(JSC::JSAPIValueWrapper::createStructure):
* runtime/JSActivation.h:
(JSC::JSActivation::createStructure):
* runtime/JSArray.h:
(JSC::JSArray::createStructure):
* runtime/JSByteArray.cpp:
(JSC::JSByteArray::createStructure):
* runtime/JSCell.h:
(JSC::JSCell::createDummyStructure):
* runtime/JSFunction.h:
(JSC::JSFunction::createStructure):
* runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::createStructure):
* runtime/JSNotAnObject.h:
(JSC::JSNotAnObject::createStructure):
* runtime/JSONObject.h:
(JSC::JSONObject::createStructure):
* runtime/JSObject.h:
(JSC::JSObject::createStructure):
(JSC::JSObject::putAnonymousValue):
(JSC::JSObject::getAnonymousValue):
* runtime/JSPropertyNameIterator.h:
(JSC::JSPropertyNameIterator::createStructure):
* runtime/JSStaticScopeObject.h:
(JSC::JSStaticScopeObject::createStructure):
* runtime/JSString.h:
(JSC::Fiber::createStructure):
* runtime/JSVariableObject.h:
(JSC::JSVariableObject::createStructure):
* runtime/JSWrapperObject.h:
(JSC::JSWrapperObject::createStructure):
(JSC::JSWrapperObject::JSWrapperObject):
* runtime/MathObject.h:
(JSC::MathObject::createStructure):
* runtime/NumberConstructor.h:
(JSC::NumberConstructor::createStructure):
* runtime/NumberObject.h:
(JSC::NumberObject::createStructure):
* runtime/RegExpConstructor.h:
(JSC::RegExpConstructor::createStructure):
* runtime/RegExpObject.h:
(JSC::RegExpObject::createStructure):
* runtime/StringObject.h:
(JSC::StringObject::createStructure):
* runtime/StringObjectThatMasqueradesAsUndefined.h:
(JSC::StringObjectThatMasqueradesAsUndefined::createStructure):
* runtime/Structure.cpp:
(JSC::Structure::~Structure):
(JSC::Structure::materializePropertyMap):
* runtime/Structure.h:
(JSC::Structure::create):
(JSC::Structure::anonymousSlotCount):
* runtime/StructureTransitionTable.h:
2010-01-27 Oliver Hunt <oliver@apple.com>
Windows build fix.
......
......@@ -287,7 +287,6 @@ __ZN3JSC9Structure18startIgnoringLeaksEv
__ZN3JSC9Structure21addPropertyTransitionEPS0_RKNS_10IdentifierEjPNS_6JSCellERm
__ZN3JSC9Structure22materializePropertyMapEv
__ZN3JSC9Structure25changePrototypeTransitionEPS0_NS_7JSValueE
__ZN3JSC9Structure27addAnonymousSlotsTransitionEPS0_j
__ZN3JSC9Structure27despecifyDictionaryFunctionERKNS_10IdentifierE
__ZN3JSC9Structure27despecifyFunctionTransitionEPS0_RKNS_10IdentifierE
__ZN3JSC9Structure28addPropertyWithoutTransitionERKNS_10IdentifierEjPNS_6JSCellE
......
......@@ -51,7 +51,7 @@ namespace JSC {
static PassRefPtr<Structure> createStructure(JSValue prototype)
{
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
}
protected:
......
......@@ -85,7 +85,7 @@ namespace JSC {
static PassRefPtr<Structure> createStructure(JSValue prototype)
{
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
}
protected:
......
......@@ -34,7 +34,7 @@ namespace JSC {
static PassRefPtr<Structure> createStructure(JSValue prototype)
{
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
}
};
......
......@@ -55,7 +55,7 @@ namespace JSC {
static PassRefPtr<Structure> createStructure(JSValue prototype)
{
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
}
protected:
......
......@@ -39,7 +39,7 @@ namespace JSC {
static PassRefPtr<Structure> createStructure(JSValue prototype)
{
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
}
protected:
......
......@@ -34,7 +34,7 @@ namespace JSC {
static PassRefPtr<Structure> createStructure(JSValue proto)
{
return Structure::create(proto, TypeInfo(ObjectType, StructureFlags));
return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
}
private:
......
......@@ -50,7 +50,7 @@ namespace JSC {
void setSetter(JSObject* setter) { m_setter = setter; }
static PassRefPtr<Structure> createStructure(JSValue prototype)
{
return Structure::create(prototype, TypeInfo(GetterSetterType, OverridesMarkChildren));
return Structure::create(prototype, TypeInfo(GetterSetterType, OverridesMarkChildren), AnonymousSlotCount);
}
private:
virtual bool isGetterSetter() const;
......
......@@ -37,7 +37,7 @@ namespace JSC {
static PassRefPtr<Structure> createStructure(JSValue prototype)
{
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
}
protected:
......
......@@ -42,7 +42,7 @@ namespace JSC {
static PassRefPtr<Structure> createStructure(JSValue proto)
{
return Structure::create(proto, TypeInfo(ObjectType, StructureFlags));
return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
}
protected:
......
......@@ -39,7 +39,7 @@ namespace JSC {
static PassRefPtr<Structure> createStructure(JSValue prototype)
{
return Structure::create(prototype, TypeInfo(CompoundType, OverridesMarkChildren | OverridesGetPropertyNames));
return Structure::create(prototype, TypeInfo(CompoundType, OverridesMarkChildren | OverridesGetPropertyNames), AnonymousSlotCount);
}
......
......@@ -66,7 +66,7 @@ namespace JSC {
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
static PassRefPtr<Structure> createStructure(JSValue proto) { return Structure::create(proto, TypeInfo(ObjectType, StructureFlags)); }
static PassRefPtr<Structure> createStructure(JSValue proto) { return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount); }
protected:
static const unsigned StructureFlags = OverridesGetOwnPropertySlot | NeedsThisConversion | OverridesMarkChildren | OverridesGetPropertyNames | JSVariableObject::StructureFlags;
......
......@@ -88,7 +88,7 @@ namespace JSC {
static PassRefPtr<Structure> createStructure(JSValue prototype)
{
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
}
inline void markChildrenDirect(MarkStack& markStack);
......
......@@ -53,7 +53,7 @@ JSByteArray::~JSByteArray()
PassRefPtr<Structure> JSByteArray::createStructure(JSValue prototype)
{
PassRefPtr<Structure> result = Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
PassRefPtr<Structure> result = Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
return result;
}
......
......@@ -52,7 +52,7 @@ namespace JSC {
public:
static PassRefPtr<Structure> createDummyStructure()
{
return Structure::create(jsNull(), TypeInfo(UnspecifiedType));
return Structure::create(jsNull(), TypeInfo(UnspecifiedType), AnonymousSlotCount);
}
// Querying the type.
......@@ -113,6 +113,9 @@ namespace JSC {
void* vptr() { return *reinterpret_cast<void**>(this); }
void setVPtr(void* vptr) { *reinterpret_cast<void**>(this) = vptr; }
protected:
static const unsigned AnonymousSlotCount = 0;
private:
// Base implementation; for non-object classes implements getPropertySlot.
bool fastGetOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
......
......@@ -61,7 +61,7 @@ namespace JSC {
static PassRefPtr<Structure> createStructure(JSValue prototype)
{
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
}
NativeFunction nativeFunction()
......
......@@ -267,7 +267,7 @@ namespace JSC {
static PassRefPtr<Structure> createStructure(JSValue prototype)
{
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
}
protected:
......
......@@ -62,7 +62,7 @@ namespace JSC {
static PassRefPtr<Structure> createStructure(JSValue prototype)
{
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
}
private:
......
......@@ -41,7 +41,7 @@ namespace JSC {
static PassRefPtr<Structure> createStructure(JSValue prototype)
{
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
}
static void markStringifiers(MarkStack&, Stringifier*);
......
......@@ -206,7 +206,7 @@ namespace JSC {
static PassRefPtr<Structure> createStructure(JSValue prototype)
{
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
}
void flattenDictionaryObject()
......@@ -217,13 +217,14 @@ namespace JSC {
protected:
static const unsigned StructureFlags = 0;
void addAnonymousSlots(unsigned count);
void putAnonymousValue(unsigned index, JSValue value)
{
ASSERT(index < m_structure->anonymousSlotCount());
*locationForOffset(index) = value;
}
JSValue getAnonymousValue(unsigned index)
{
ASSERT(index < m_structure->anonymousSlotCount());
return *locationForOffset(index);
}
......@@ -528,17 +529,6 @@ inline void JSObject::putDirectInternal(JSGlobalData& globalData, const Identifi
putDirectInternal(propertyName, value, attributes, false, slot, getJSFunction(globalData, value));
}
inline void JSObject::addAnonymousSlots(unsigned count)
{
size_t currentCapacity = m_structure->propertyStorageCapacity();
RefPtr<Structure> structure = Structure::addAnonymousSlotsTransition(m_structure, count);
if (currentCapacity != structure->propertyStorageCapacity())
allocatePropertyStorage(currentCapacity, structure->propertyStorageCapacity());
setStructure(structure.release());
}
inline void JSObject::putDirect(const Identifier& propertyName, JSValue value, unsigned attributes, bool checkReadOnly, PutPropertySlot& slot)
{
ASSERT(value);
......
......@@ -47,7 +47,7 @@ namespace JSC {
static PassRefPtr<Structure> createStructure(JSValue prototype)
{
return Structure::create(prototype, TypeInfo(CompoundType, OverridesMarkChildren));
return Structure::create(prototype, TypeInfo(CompoundType, OverridesMarkChildren), AnonymousSlotCount);
}
virtual bool isPropertyNameIterator() const { return true; }
......
......@@ -57,7 +57,7 @@ namespace JSC{
virtual void put(ExecState*, const Identifier&, JSValue, PutPropertySlot&);
void putWithAttributes(ExecState*, const Identifier&, JSValue, unsigned attributes);
static PassRefPtr<Structure> createStructure(JSValue proto) { return Structure::create(proto, TypeInfo(ObjectType, StructureFlags)); }
static PassRefPtr<Structure> createStructure(JSValue proto) { return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount); }
protected:
static const unsigned StructureFlags = OverridesGetOwnPropertySlot | NeedsThisConversion | OverridesMarkChildren | OverridesGetPropertyNames | JSVariableObject::StructureFlags;
......
......@@ -296,7 +296,7 @@ namespace JSC {
bool canGetIndex(unsigned i) { return i < m_stringLength; }
JSString* getIndex(ExecState*, unsigned);
static PassRefPtr<Structure> createStructure(JSValue proto) { return Structure::create(proto, TypeInfo(StringType, OverridesGetOwnPropertySlot | NeedsThisConversion)); }
static PassRefPtr<Structure> createStructure(JSValue proto) { return Structure::create(proto, TypeInfo(StringType, OverridesGetOwnPropertySlot | NeedsThisConversion), AnonymousSlotCount); }
private:
enum VPtrStealingHackType { VPtrStealingHack };
......
......@@ -58,7 +58,7 @@ namespace JSC {
static PassRefPtr<Structure> createStructure(JSValue prototype)
{
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
}
protected:
......
......@@ -38,9 +38,12 @@ namespace JSC {
static PassRefPtr<Structure> createStructure(JSValue prototype)
{
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
}
protected:
static const unsigned AnonymousSlotCount = 1 + JSObject::AnonymousSlotCount;
private:
virtual void markChildren(MarkStack&);
......@@ -50,7 +53,6 @@ namespace JSC {
inline JSWrapperObject::JSWrapperObject(NonNullPassRefPtr<Structure> structure)
: JSObject(structure)
{
addAnonymousSlots(1);
putAnonymousValue(0, jsNull());
}
......
......@@ -37,7 +37,7 @@ namespace JSC {
static PassRefPtr<Structure> createStructure(JSValue prototype)
{
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
}
protected:
......
......@@ -39,7 +39,7 @@ namespace JSC {
static PassRefPtr<Structure> createStructure(JSValue proto)
{
return Structure::create(proto, TypeInfo(ObjectType, StructureFlags));
return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
}
enum { NaNValue, NegInfinity, PosInfinity, MaxValue, MinValue };
......
......@@ -33,7 +33,7 @@ namespace JSC {
static PassRefPtr<Structure> createStructure(JSValue prototype)
{
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
}
protected:
......
......@@ -59,7 +59,7 @@ namespace JSC {
static PassRefPtr<Structure> createStructure(JSValue prototype)
{
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
}
virtual void put(ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&);
......
......@@ -49,7 +49,7 @@ namespace JSC {
static PassRefPtr<Structure> createStructure(JSValue prototype)
{
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
}
protected:
......
......@@ -48,7 +48,7 @@ namespace JSC {
static PassRefPtr<Structure> createStructure(JSValue prototype)
{
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
}
protected:
......
......@@ -44,7 +44,7 @@ namespace JSC {
static PassRefPtr<Structure> createStructure(JSValue proto)
{
return Structure::create(proto, TypeInfo(ObjectType, StructureFlags));
return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
}
static const unsigned StructureFlags = OverridesGetOwnPropertySlot | MasqueradesAsUndefined | OverridesGetPropertyNames | StringObject::StructureFlags;
......
......@@ -157,10 +157,8 @@ Structure::Structure(JSValue prototype, const TypeInfo& typeInfo)
Structure::~Structure()
{
if (m_previous) {
if (m_nameInPrevious)
m_previous->table.remove(make_pair(m_nameInPrevious.get(), m_attributesInPrevious), m_specificValueInPrevious);
else
m_previous->table.removeAnonymousSlotTransition(m_anonymousSlotsInPrevious);
ASSERT(m_nameInPrevious);
m_previous->table.remove(make_pair(m_nameInPrevious.get(), m_attributesInPrevious), m_specificValueInPrevious);
}
......@@ -276,10 +274,6 @@ void Structure::materializePropertyMap()
for (ptrdiff_t i = structures.size() - 2; i >= 0; --i) {
structure = structures[i];
if (!structure->m_nameInPrevious) {
m_propertyTable->anonymousSlotCount += structure->m_anonymousSlotsInPrevious;
continue;
}
structure->m_nameInPrevious->ref();
PropertyMapEntry entry(structure->m_nameInPrevious.get(), structure->m_offset, structure->m_attributesInPrevious, structure->m_specificValueInPrevious, ++m_propertyTable->lastIndexUsed);
insertIntoPropertyMapHashTable(entry);
......@@ -463,49 +457,6 @@ PassRefPtr<Structure> Structure::despecifyFunctionTransition(Structure* structur
return transition.release();
}
PassRefPtr<Structure> Structure::addAnonymousSlotsTransition(Structure* structure, unsigned count)
{
if (Structure* transition = structure->table.getAnonymousSlotTransition(count)) {
ASSERT(transition->storedPrototype() == structure->storedPrototype());
return transition;
}
ASSERT(count);
ASSERT(count < ((1<<6) - 2));
RefPtr<Structure> transition = create(structure->m_prototype, structure->typeInfo());
transition->m_cachedPrototypeChain = structure->m_cachedPrototypeChain;
transition->m_previous = structure;
transition->m_nameInPrevious = 0;
transition->m_attributesInPrevious = 0;
transition->m_anonymousSlotsInPrevious = count;
transition->m_specificValueInPrevious = 0;
transition->m_propertyStorageCapacity = structure->m_propertyStorageCapacity;
transition->m_hasGetterSetterProperties = structure->m_hasGetterSetterProperties;
transition->m_hasNonEnumerableProperties = structure->m_hasNonEnumerableProperties;
transition->m_specificFunctionThrashCount = structure->m_specificFunctionThrashCount;
if (structure->m_propertyTable) {
if (structure->m_isPinnedPropertyTable)
transition->m_propertyTable = structure->copyPropertyTable();
else {
transition->m_propertyTable = structure->m_propertyTable;
structure->m_propertyTable = 0;
}
} else {
if (structure->m_previous)
transition->materializePropertyMap();
else
transition->createPropertyMapHashTable();
}
transition->addAnonymousSlots(count);
if (transition->propertyStorageSize() > transition->propertyStorageCapacity())
transition->growPropertyStorageCapacity();
structure->table.addAnonymousSlotTransition(count, transition.get());
return transition.release();
}
PassRefPtr<Structure> Structure::getterSetterTransition(Structure* structure)
{
RefPtr<Structure> transition = create(structure->storedPrototype(), structure->typeInfo());
......@@ -882,11 +833,6 @@ size_t Structure::put(const Identifier& propertyName, unsigned attributes, JSCel
return newOffset;
}
void Structure::addAnonymousSlots(unsigned count)
{
m_propertyTable->anonymousSlotCount += count;
}
bool Structure::hasTransition(UString::Rep* rep, unsigned attributes)
{
return table.hasTransition(make_pair(rep, attributes));
......
......@@ -60,9 +60,17 @@ namespace JSC {
public:
friend class JIT;
friend class StructureTransitionTable;
static PassRefPtr<Structure> create(JSValue prototype, const TypeInfo& typeInfo)
static PassRefPtr<Structure> create(JSValue prototype, const TypeInfo& typeInfo, unsigned anonymousSlotCount)
{
return adoptRef(new Structure(prototype, typeInfo));
Structure* structure = (new Structure(prototype, typeInfo));
if (anonymousSlotCount) {
structure->materializePropertyMap();
structure->m_isPinnedPropertyTable = true;
structure->m_propertyTable->anonymousSlotCount = anonymousSlotCount;
// Currently we don't allow more anonymous slots than fit in the inline capacity
ASSERT(structure->propertyStorageSize() <= structure->propertyStorageCapacity());
}
return adoptRef(structure);
}
static void startIgnoringLeaks();
......@@ -75,7 +83,6 @@ namespace JSC {
static PassRefPtr<Structure> removePropertyTransition(Structure*, const Identifier& propertyName, size_t& offset);
static PassRefPtr<Structure> changePrototypeTransition(Structure*, JSValue prototype);
static PassRefPtr<Structure> despecifyFunctionTransition(Structure*, const Identifier&);
static PassRefPtr<Structure> addAnonymousSlotsTransition(Structure*, unsigned count);
static PassRefPtr<Structure> getterSetterTransition(Structure*);
static PassRefPtr<Structure> toCacheableDictionaryTransition(Structure*);
static PassRefPtr<Structure> toUncacheableDictionaryTransition(Structure*);
......@@ -128,6 +135,7 @@ namespace JSC {
bool hasNonEnumerableProperties() const { return m_hasNonEnumerableProperties; }
bool hasAnonymousSlots() const { return m_propertyTable && m_propertyTable->anonymousSlotCount; }
unsigned anonymousSlotCount() const { return m_propertyTable ? m_propertyTable->anonymousSlotCount : 0; }
bool isEmpty() const { return m_propertyTable ? !m_propertyTable->keyCount : m_offset == noOffset; }
......@@ -139,6 +147,11 @@ namespace JSC {
void getPropertyNames(PropertyNameArray&, EnumerationMode mode);
private:
static PassRefPtr<Structure> create(JSValue prototype, const TypeInfo& typeInfo)
{
return adoptRef(new Structure(prototype, typeInfo));
}
Structure(JSValue prototype, const TypeInfo&);
typedef enum {
......@@ -150,7 +163,6 @@ namespace JSC {
size_t put(const Identifier& propertyName, unsigned attributes, JSCell* specificValue);
size_t remove(const Identifier& propertyName);
void addAnonymousSlots(unsigned slotCount);
void expandPropertyMapHashTable();
void rehashPropertyMapHashTable();
......@@ -218,9 +230,8 @@ namespace JSC {
#else
unsigned m_attributesInPrevious : 7;
#endif
unsigned m_anonymousSlotsInPrevious : 6;
unsigned m_specificFunctionThrashCount : 2;
// 4 free bits
// 10 free bits
};
inline size_t Structure::get(const Identifier& propertyName)
......
......@@ -69,36 +69,7 @@ namespace JSC {
class StructureTransitionTable {
typedef std::pair<Structure*, Structure*> Transition;
struct TransitionTable : public HashMap<StructureTransitionTableHash::Key, Transition, StructureTransitionTableHash, StructureTransitionTableHashTraits>