Changeset 54022 in webkit


Ignore:
Timestamp:
Jan 28, 2010 2:51:06 PM (14 years ago)
Author:
oliver@apple.com
Message:

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):
Location:
trunk
Files:
49 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/API/JSCallbackConstructor.h

    r49721 r54022  
    4242    static PassRefPtr<Structure> createStructure(JSValue proto)
    4343    {
    44         return Structure::create(proto, TypeInfo(ObjectType, StructureFlags));
     44        return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
    4545    }
    4646
  • trunk/JavaScriptCore/API/JSCallbackFunction.h

    r49721 r54022  
    4242    static PassRefPtr<Structure> createStructure(JSValue proto)
    4343    {
    44         return Structure::create(proto, TypeInfo(ObjectType, StructureFlags));
     44        return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
    4545    }
    4646
  • trunk/JavaScriptCore/API/JSCallbackObject.h

    r53638 r54022  
    5151    static PassRefPtr<Structure> createStructure(JSValue proto)
    5252    {
    53         return Structure::create(proto, TypeInfo(ObjectType, StructureFlags));
     53        return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), Base::AnonymousSlotCount);
    5454    }
    5555
  • trunk/JavaScriptCore/ChangeLog

    r53970 r54022  
     12010-01-28  Oliver Hunt  <oliver@apple.com>
     2
     3        Reviewed by Gavin Barraclough.
     4
     5        Simplify anonymous slot implementation
     6        https://bugs.webkit.org/show_bug.cgi?id=34282
     7
     8        A class must now specify the number of slots it needs at construction time
     9        rather than later on with a transition.  This makes many things simpler,
     10        we no longer need to need an additional transition on object creation to
     11        add the anonymous slots, and we remove the need for a number of transition
     12        type checks.
     13
     14        * API/JSCallbackConstructor.h:
     15        (JSC::JSCallbackConstructor::createStructure):
     16        * API/JSCallbackFunction.h:
     17        (JSC::JSCallbackFunction::createStructure):
     18        * API/JSCallbackObject.h:
     19        (JSC::JSCallbackObject::createStructure):
     20        * JavaScriptCore.exp:
     21        * debugger/DebuggerActivation.h:
     22        (JSC::DebuggerActivation::createStructure):
     23        * runtime/Arguments.h:
     24        (JSC::Arguments::createStructure):
     25        * runtime/BooleanObject.h:
     26        (JSC::BooleanObject::createStructure):
     27        * runtime/DateInstance.h:
     28        (JSC::DateInstance::createStructure):
     29        * runtime/DatePrototype.h:
     30        (JSC::DatePrototype::createStructure):
     31        * runtime/FunctionPrototype.h:
     32        (JSC::FunctionPrototype::createStructure):
     33        * runtime/GetterSetter.h:
     34        (JSC::GetterSetter::createStructure):
     35        * runtime/GlobalEvalFunction.h:
     36        (JSC::GlobalEvalFunction::createStructure):
     37        * runtime/InternalFunction.h:
     38        (JSC::InternalFunction::createStructure):
     39        * runtime/JSAPIValueWrapper.h:
     40        (JSC::JSAPIValueWrapper::createStructure):
     41        * runtime/JSActivation.h:
     42        (JSC::JSActivation::createStructure):
     43        * runtime/JSArray.h:
     44        (JSC::JSArray::createStructure):
     45        * runtime/JSByteArray.cpp:
     46        (JSC::JSByteArray::createStructure):
     47        * runtime/JSCell.h:
     48        (JSC::JSCell::createDummyStructure):
     49        * runtime/JSFunction.h:
     50        (JSC::JSFunction::createStructure):
     51        * runtime/JSGlobalObject.h:
     52        (JSC::JSGlobalObject::createStructure):
     53        * runtime/JSNotAnObject.h:
     54        (JSC::JSNotAnObject::createStructure):
     55        * runtime/JSONObject.h:
     56        (JSC::JSONObject::createStructure):
     57        * runtime/JSObject.h:
     58        (JSC::JSObject::createStructure):
     59        (JSC::JSObject::putAnonymousValue):
     60        (JSC::JSObject::getAnonymousValue):
     61        * runtime/JSPropertyNameIterator.h:
     62        (JSC::JSPropertyNameIterator::createStructure):
     63        * runtime/JSStaticScopeObject.h:
     64        (JSC::JSStaticScopeObject::createStructure):
     65        * runtime/JSString.h:
     66        (JSC::Fiber::createStructure):
     67        * runtime/JSVariableObject.h:
     68        (JSC::JSVariableObject::createStructure):
     69        * runtime/JSWrapperObject.h:
     70        (JSC::JSWrapperObject::createStructure):
     71        (JSC::JSWrapperObject::JSWrapperObject):
     72        * runtime/MathObject.h:
     73        (JSC::MathObject::createStructure):
     74        * runtime/NumberConstructor.h:
     75        (JSC::NumberConstructor::createStructure):
     76        * runtime/NumberObject.h:
     77        (JSC::NumberObject::createStructure):
     78        * runtime/RegExpConstructor.h:
     79        (JSC::RegExpConstructor::createStructure):
     80        * runtime/RegExpObject.h:
     81        (JSC::RegExpObject::createStructure):
     82        * runtime/StringObject.h:
     83        (JSC::StringObject::createStructure):
     84        * runtime/StringObjectThatMasqueradesAsUndefined.h:
     85        (JSC::StringObjectThatMasqueradesAsUndefined::createStructure):
     86        * runtime/Structure.cpp:
     87        (JSC::Structure::~Structure):
     88        (JSC::Structure::materializePropertyMap):
     89        * runtime/Structure.h:
     90        (JSC::Structure::create):
     91        (JSC::Structure::anonymousSlotCount):
     92        * runtime/StructureTransitionTable.h:
     93
    1942010-01-27  Oliver Hunt  <oliver@apple.com>
    295
  • trunk/JavaScriptCore/JavaScriptCore.exp

    r53969 r54022  
    288288__ZN3JSC9Structure22materializePropertyMapEv
    289289__ZN3JSC9Structure25changePrototypeTransitionEPS0_NS_7JSValueE
    290 __ZN3JSC9Structure27addAnonymousSlotsTransitionEPS0_j
    291290__ZN3JSC9Structure27despecifyDictionaryFunctionERKNS_10IdentifierE
    292291__ZN3JSC9Structure27despecifyFunctionTransitionEPS0_RKNS_10IdentifierE
  • trunk/JavaScriptCore/debugger/DebuggerActivation.h

    r53170 r54022  
    5252        static PassRefPtr<Structure> createStructure(JSValue prototype)
    5353        {
    54             return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
     54            return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
    5555        }
    5656
  • trunk/JavaScriptCore/runtime/Arguments.h

    r53170 r54022  
    8686        static PassRefPtr<Structure> createStructure(JSValue prototype)
    8787        {
    88             return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
     88            return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
    8989        }
    9090
  • trunk/JavaScriptCore/runtime/BooleanObject.h

    r49721 r54022  
    3535        static PassRefPtr<Structure> createStructure(JSValue prototype)
    3636        {
    37             return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
     37            return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
    3838        }
    3939    };
  • trunk/JavaScriptCore/runtime/DateInstance.h

    r53969 r54022  
    5656        static PassRefPtr<Structure> createStructure(JSValue prototype)
    5757        {
    58             return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
     58            return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
    5959        }
    6060
  • trunk/JavaScriptCore/runtime/DatePrototype.h

    r49845 r54022  
    4040        static PassRefPtr<Structure> createStructure(JSValue prototype)
    4141        {
    42             return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
     42            return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
    4343        }
    4444
  • trunk/JavaScriptCore/runtime/FunctionPrototype.h

    r49721 r54022  
    3535        static PassRefPtr<Structure> createStructure(JSValue proto)
    3636        {
    37             return Structure::create(proto, TypeInfo(ObjectType, StructureFlags));
     37            return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
    3838        }
    3939
  • trunk/JavaScriptCore/runtime/GetterSetter.h

    r49649 r54022  
    5151        static PassRefPtr<Structure> createStructure(JSValue prototype)
    5252        {
    53             return Structure::create(prototype, TypeInfo(GetterSetterType, OverridesMarkChildren));
     53            return Structure::create(prototype, TypeInfo(GetterSetterType, OverridesMarkChildren), AnonymousSlotCount);
    5454        }
    5555    private:
  • trunk/JavaScriptCore/runtime/GlobalEvalFunction.h

    r49721 r54022  
    3838        static PassRefPtr<Structure> createStructure(JSValue prototype)
    3939        {
    40             return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
     40            return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
    4141        }
    4242
  • trunk/JavaScriptCore/runtime/InternalFunction.h

    r51801 r54022  
    4343        static PassRefPtr<Structure> createStructure(JSValue proto)
    4444        {
    45             return Structure::create(proto, TypeInfo(ObjectType, StructureFlags));
     45            return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
    4646        }
    4747
  • trunk/JavaScriptCore/runtime/JSAPIValueWrapper.h

    r49694 r54022  
    4040        static PassRefPtr<Structure> createStructure(JSValue prototype)
    4141        {
    42             return Structure::create(prototype, TypeInfo(CompoundType, OverridesMarkChildren | OverridesGetPropertyNames));
     42            return Structure::create(prototype, TypeInfo(CompoundType, OverridesMarkChildren | OverridesGetPropertyNames), AnonymousSlotCount);
    4343        }
    4444
  • trunk/JavaScriptCore/runtime/JSActivation.h

    r49721 r54022  
    6767        static const ClassInfo info;
    6868
    69         static PassRefPtr<Structure> createStructure(JSValue proto) { return Structure::create(proto, TypeInfo(ObjectType, StructureFlags)); }
     69        static PassRefPtr<Structure> createStructure(JSValue proto) { return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount); }
    7070
    7171    protected:
  • trunk/JavaScriptCore/runtime/JSArray.h

    r53170 r54022  
    8989        static PassRefPtr<Structure> createStructure(JSValue prototype)
    9090        {
    91             return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
     91            return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
    9292        }
    9393       
  • trunk/JavaScriptCore/runtime/JSByteArray.cpp

    r53170 r54022  
    5454PassRefPtr<Structure> JSByteArray::createStructure(JSValue prototype)
    5555{
    56     PassRefPtr<Structure> result = Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
     56    PassRefPtr<Structure> result = Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
    5757    return result;
    5858}
  • trunk/JavaScriptCore/runtime/JSCell.h

    r52956 r54022  
    5353        static PassRefPtr<Structure> createDummyStructure()
    5454        {
    55             return Structure::create(jsNull(), TypeInfo(UnspecifiedType));
     55            return Structure::create(jsNull(), TypeInfo(UnspecifiedType), AnonymousSlotCount);
    5656        }
    5757
     
    114114        void setVPtr(void* vptr) { *reinterpret_cast<void**>(this) = vptr; }
    115115
     116    protected:
     117        static const unsigned AnonymousSlotCount = 0;
     118
    116119    private:
    117120        // Base implementation; for non-object classes implements getPropertySlot.
  • trunk/JavaScriptCore/runtime/JSFunction.h

    r53170 r54022  
    6262        static PassRefPtr<Structure> createStructure(JSValue prototype)
    6363        {
    64             return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
     64            return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
    6565        }
    6666
  • trunk/JavaScriptCore/runtime/JSGlobalObject.h

    r53969 r54022  
    268268        static PassRefPtr<Structure> createStructure(JSValue prototype)
    269269        {
    270             return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
     270            return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
    271271        }
    272272
  • trunk/JavaScriptCore/runtime/JSNotAnObject.h

    r53170 r54022  
    6363        static PassRefPtr<Structure> createStructure(JSValue prototype)
    6464        {
    65             return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
     65            return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
    6666        }
    6767
  • trunk/JavaScriptCore/runtime/JSONObject.h

    r49721 r54022  
    4242        static PassRefPtr<Structure> createStructure(JSValue prototype)
    4343        {
    44             return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
     44            return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
    4545        }
    4646
  • trunk/JavaScriptCore/runtime/JSObject.h

    r53437 r54022  
    207207        static PassRefPtr<Structure> createStructure(JSValue prototype)
    208208        {
    209             return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
     209            return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
    210210        }
    211211
     
    218218        static const unsigned StructureFlags = 0;
    219219
    220         void addAnonymousSlots(unsigned count);
    221220        void putAnonymousValue(unsigned index, JSValue value)
    222221        {
     222            ASSERT(index < m_structure->anonymousSlotCount());
    223223            *locationForOffset(index) = value;
    224224        }
    225225        JSValue getAnonymousValue(unsigned index)
    226226        {
     227            ASSERT(index < m_structure->anonymousSlotCount());
    227228            return *locationForOffset(index);
    228229        }
     
    529530}
    530531
    531 inline void JSObject::addAnonymousSlots(unsigned count)
    532 {
    533     size_t currentCapacity = m_structure->propertyStorageCapacity();
    534     RefPtr<Structure> structure = Structure::addAnonymousSlotsTransition(m_structure, count);
    535 
    536     if (currentCapacity != structure->propertyStorageCapacity())
    537         allocatePropertyStorage(currentCapacity, structure->propertyStorageCapacity());
    538 
    539     setStructure(structure.release());
    540 }
    541 
    542532inline void JSObject::putDirect(const Identifier& propertyName, JSValue value, unsigned attributes, bool checkReadOnly, PutPropertySlot& slot)
    543533{
  • trunk/JavaScriptCore/runtime/JSPropertyNameIterator.h

    r50254 r54022  
    4848        static PassRefPtr<Structure> createStructure(JSValue prototype)
    4949        {
    50             return Structure::create(prototype, TypeInfo(CompoundType, OverridesMarkChildren));
     50            return Structure::create(prototype, TypeInfo(CompoundType, OverridesMarkChildren), AnonymousSlotCount);
    5151        }
    5252
  • trunk/JavaScriptCore/runtime/JSStaticScopeObject.h

    r49721 r54022  
    5858        void putWithAttributes(ExecState*, const Identifier&, JSValue, unsigned attributes);
    5959
    60         static PassRefPtr<Structure> createStructure(JSValue proto) { return Structure::create(proto, TypeInfo(ObjectType, StructureFlags)); }
     60        static PassRefPtr<Structure> createStructure(JSValue proto) { return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount); }
    6161
    6262    protected:
  • trunk/JavaScriptCore/runtime/JSString.h

    r53437 r54022  
    297297        JSString* getIndex(ExecState*, unsigned);
    298298
    299         static PassRefPtr<Structure> createStructure(JSValue proto) { return Structure::create(proto, TypeInfo(StringType, OverridesGetOwnPropertySlot | NeedsThisConversion)); }
     299        static PassRefPtr<Structure> createStructure(JSValue proto) { return Structure::create(proto, TypeInfo(StringType, OverridesGetOwnPropertySlot | NeedsThisConversion), AnonymousSlotCount); }
    300300
    301301    private:
  • trunk/JavaScriptCore/runtime/JSVariableObject.h

    r53170 r54022  
    5959        static PassRefPtr<Structure> createStructure(JSValue prototype)
    6060        {
    61             return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
     61            return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
    6262        }
    6363       
  • trunk/JavaScriptCore/runtime/JSWrapperObject.h

    r49721 r54022  
    3939        static PassRefPtr<Structure> createStructure(JSValue prototype)
    4040        {
    41             return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
     41            return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
    4242        }
     43
     44    protected:
     45        static const unsigned AnonymousSlotCount = 1 + JSObject::AnonymousSlotCount;
    4346
    4447    private:
     
    5154        : JSObject(structure)
    5255    {
    53         addAnonymousSlots(1);
    5456        putAnonymousValue(0, jsNull());
    5557    }
  • trunk/JavaScriptCore/runtime/MathObject.h

    r49721 r54022  
    3838        static PassRefPtr<Structure> createStructure(JSValue prototype)
    3939        {
    40             return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
     40            return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
    4141        }
    4242
  • trunk/JavaScriptCore/runtime/NumberConstructor.h

    r49721 r54022  
    4040        static PassRefPtr<Structure> createStructure(JSValue proto)
    4141        {
    42             return Structure::create(proto, TypeInfo(ObjectType, StructureFlags));
     42            return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
    4343        }
    4444
  • trunk/JavaScriptCore/runtime/NumberObject.h

    r49721 r54022  
    3434        static PassRefPtr<Structure> createStructure(JSValue prototype)
    3535        {
    36             return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
     36            return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
    3737        }
    3838
  • trunk/JavaScriptCore/runtime/RegExpConstructor.h

    r49721 r54022  
    6060        static PassRefPtr<Structure> createStructure(JSValue prototype)
    6161        {
    62             return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
     62            return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
    6363        }
    6464
  • trunk/JavaScriptCore/runtime/RegExpObject.h

    r49721 r54022  
    5050        static PassRefPtr<Structure> createStructure(JSValue prototype)
    5151        {
    52             return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
     52            return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
    5353        }
    5454
  • trunk/JavaScriptCore/runtime/StringObject.h

    r53170 r54022  
    4949        static PassRefPtr<Structure> createStructure(JSValue prototype)
    5050        {
    51             return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
     51            return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
    5252        }
    5353
  • trunk/JavaScriptCore/runtime/StringObjectThatMasqueradesAsUndefined.h

    r49721 r54022  
    4545        static PassRefPtr<Structure> createStructure(JSValue proto)
    4646        {
    47             return Structure::create(proto, TypeInfo(ObjectType, StructureFlags));
     47            return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
    4848        }
    4949
  • trunk/JavaScriptCore/runtime/Structure.cpp

    r53320 r54022  
    158158{
    159159    if (m_previous) {
    160         if (m_nameInPrevious)
    161             m_previous->table.remove(make_pair(m_nameInPrevious.get(), m_attributesInPrevious), m_specificValueInPrevious);
    162         else
    163             m_previous->table.removeAnonymousSlotTransition(m_anonymousSlotsInPrevious);
     160        ASSERT(m_nameInPrevious);
     161        m_previous->table.remove(make_pair(m_nameInPrevious.get(), m_attributesInPrevious), m_specificValueInPrevious);
    164162
    165163    }
     
    277275    for (ptrdiff_t i = structures.size() - 2; i >= 0; --i) {
    278276        structure = structures[i];
    279         if (!structure->m_nameInPrevious) {
    280             m_propertyTable->anonymousSlotCount += structure->m_anonymousSlotsInPrevious;
    281             continue;
    282         }
    283277        structure->m_nameInPrevious->ref();
    284278        PropertyMapEntry entry(structure->m_nameInPrevious.get(), structure->m_offset, structure->m_attributesInPrevious, structure->m_specificValueInPrevious, ++m_propertyTable->lastIndexUsed);
     
    462456
    463457    return transition.release();
    464 }
    465 
    466 PassRefPtr<Structure> Structure::addAnonymousSlotsTransition(Structure* structure, unsigned count)
    467 {
    468     if (Structure* transition = structure->table.getAnonymousSlotTransition(count)) {
    469         ASSERT(transition->storedPrototype() == structure->storedPrototype());
    470         return transition;
    471     }
    472     ASSERT(count);
    473     ASSERT(count < ((1<<6) - 2));
    474     RefPtr<Structure> transition = create(structure->m_prototype, structure->typeInfo());
    475    
    476     transition->m_cachedPrototypeChain = structure->m_cachedPrototypeChain;
    477     transition->m_previous = structure;
    478     transition->m_nameInPrevious = 0;
    479     transition->m_attributesInPrevious = 0;
    480     transition->m_anonymousSlotsInPrevious = count;
    481     transition->m_specificValueInPrevious = 0;
    482     transition->m_propertyStorageCapacity = structure->m_propertyStorageCapacity;
    483     transition->m_hasGetterSetterProperties = structure->m_hasGetterSetterProperties;
    484     transition->m_hasNonEnumerableProperties = structure->m_hasNonEnumerableProperties;
    485     transition->m_specificFunctionThrashCount = structure->m_specificFunctionThrashCount;
    486 
    487     if (structure->m_propertyTable) {
    488         if (structure->m_isPinnedPropertyTable)
    489             transition->m_propertyTable = structure->copyPropertyTable();
    490         else {
    491             transition->m_propertyTable = structure->m_propertyTable;
    492             structure->m_propertyTable = 0;
    493         }
    494     } else {
    495         if (structure->m_previous)
    496             transition->materializePropertyMap();
    497         else
    498             transition->createPropertyMapHashTable();
    499     }
    500 
    501     transition->addAnonymousSlots(count);
    502     if (transition->propertyStorageSize() > transition->propertyStorageCapacity())
    503         transition->growPropertyStorageCapacity();
    504 
    505     structure->table.addAnonymousSlotTransition(count, transition.get());
    506     return transition.release();   
    507458}
    508459
     
    881832    checkConsistency();
    882833    return newOffset;
    883 }
    884 
    885 void Structure::addAnonymousSlots(unsigned count)
    886 {
    887     m_propertyTable->anonymousSlotCount += count;
    888834}
    889835
  • trunk/JavaScriptCore/runtime/Structure.h

    r53320 r54022  
    6161        friend class JIT;
    6262        friend class StructureTransitionTable;
    63         static PassRefPtr<Structure> create(JSValue prototype, const TypeInfo& typeInfo)
    64         {
    65             return adoptRef(new Structure(prototype, typeInfo));
     63        static PassRefPtr<Structure> create(JSValue prototype, const TypeInfo& typeInfo, unsigned anonymousSlotCount)
     64        {
     65            Structure* structure = (new Structure(prototype, typeInfo));
     66            if (anonymousSlotCount) {
     67                structure->materializePropertyMap();
     68                structure->m_isPinnedPropertyTable = true;
     69                structure->m_propertyTable->anonymousSlotCount = anonymousSlotCount;
     70                // Currently we don't allow more anonymous slots than fit in the inline capacity
     71                ASSERT(structure->propertyStorageSize() <= structure->propertyStorageCapacity());
     72            }
     73            return adoptRef(structure);
    6674        }
    6775
     
    7684        static PassRefPtr<Structure> changePrototypeTransition(Structure*, JSValue prototype);
    7785        static PassRefPtr<Structure> despecifyFunctionTransition(Structure*, const Identifier&);
    78         static PassRefPtr<Structure> addAnonymousSlotsTransition(Structure*, unsigned count);
    7986        static PassRefPtr<Structure> getterSetterTransition(Structure*);
    8087        static PassRefPtr<Structure> toCacheableDictionaryTransition(Structure*);
     
    129136
    130137        bool hasAnonymousSlots() const { return m_propertyTable && m_propertyTable->anonymousSlotCount; }
     138        unsigned anonymousSlotCount() const { return m_propertyTable ? m_propertyTable->anonymousSlotCount : 0; }
    131139       
    132140        bool isEmpty() const { return m_propertyTable ? !m_propertyTable->keyCount : m_offset == noOffset; }
     
    140148       
    141149    private:
     150        static PassRefPtr<Structure> create(JSValue prototype, const TypeInfo& typeInfo)
     151        {
     152            return adoptRef(new Structure(prototype, typeInfo));
     153        }
     154
    142155        Structure(JSValue prototype, const TypeInfo&);
    143156       
     
    151164        size_t put(const Identifier& propertyName, unsigned attributes, JSCell* specificValue);
    152165        size_t remove(const Identifier& propertyName);
    153         void addAnonymousSlots(unsigned slotCount);
    154166
    155167        void expandPropertyMapHashTable();
     
    219231        unsigned m_attributesInPrevious : 7;
    220232#endif
    221         unsigned m_anonymousSlotsInPrevious : 6;
    222233        unsigned m_specificFunctionThrashCount : 2;
    223         // 4 free bits
     234        // 10 free bits
    224235    };
    225236
  • trunk/JavaScriptCore/runtime/StructureTransitionTable.h

    r53320 r54022  
    7070    class StructureTransitionTable {
    7171        typedef std::pair<Structure*, Structure*> Transition;
    72         struct TransitionTable : public HashMap<StructureTransitionTableHash::Key, Transition, StructureTransitionTableHash, StructureTransitionTableHashTraits> {
    73             typedef HashMap<unsigned, Structure*> AnonymousSlotMap;
    74 
    75             void addSlotTransition(unsigned count, Structure* structure)
    76             {
    77                 ASSERT(!getSlotTransition(count));
    78                 if (!m_anonymousSlotTable)
    79                     m_anonymousSlotTable.set(new AnonymousSlotMap);
    80                 m_anonymousSlotTable->add(count, structure);
    81             }
    82 
    83             void removeSlotTransition(unsigned count)
    84             {
    85                 ASSERT(getSlotTransition(count));
    86                 m_anonymousSlotTable->remove(count);
    87             }
    88 
    89             Structure* getSlotTransition(unsigned count)
    90             {
    91                 if (!m_anonymousSlotTable)
    92                     return 0;
    93 
    94                 AnonymousSlotMap::iterator find = m_anonymousSlotTable->find(count);
    95                 if (find == m_anonymousSlotTable->end())
    96                     return 0;
    97                 return find->second;
    98             }
    99         private:
    100             OwnPtr<AnonymousSlotMap> m_anonymousSlotTable;
    101         };
     72        typedef HashMap<StructureTransitionTableHash::Key, Transition, StructureTransitionTableHash, StructureTransitionTableHashTraits> TransitionTable;
    10273    public:
    10374        StructureTransitionTable() {
     
    155126        }
    156127
    157         Structure* getAnonymousSlotTransition(unsigned count)
    158         {
    159             if (usingSingleTransitionSlot())
    160                 return 0;
    161             return table()->getSlotTransition(count);
    162         }
    163 
    164         void addAnonymousSlotTransition(unsigned count, Structure* structure)
    165         {
    166             if (usingSingleTransitionSlot())
    167                 reifySingleTransition();
    168             ASSERT(!table()->getSlotTransition(count));
    169             table()->addSlotTransition(count, structure);
    170         }
    171        
    172         void removeAnonymousSlotTransition(unsigned count)
    173         {
    174             ASSERT(!usingSingleTransitionSlot());
    175             table()->removeSlotTransition(count);
    176         }
    177128    private:
    178129        TransitionTable* table() const { ASSERT(!usingSingleTransitionSlot()); return m_transitions.m_table; }
  • trunk/JavaScriptGlue/ChangeLog

    r53170 r54022  
     12010-01-28  Oliver Hunt  <oliver@apple.com>
     2
     3        Reviewed by Gavin Barraclough.
     4
     5        Simplify anonymous slot implementation
     6        https://bugs.webkit.org/show_bug.cgi?id=34282
     7
     8        Update JSGlue Structure usage to pass the anonymous slot count.
     9
     10        * UserObjectImp.h:
     11        (UserObjectImp::createStructure):
     12
    1132010-01-12  Kent Hansen  <kent.hansen@nokia.com>
    214
  • trunk/JavaScriptGlue/UserObjectImp.h

    r53170 r54022  
    6262    static PassRefPtr<Structure> createStructure(JSValue prototype)
    6363    {
    64         return Structure::create(prototype, TypeInfo(ObjectType, OverridesGetOwnPropertySlot | OverridesMarkChildren | OverridesGetPropertyNames));
     64        return Structure::create(prototype, TypeInfo(ObjectType, OverridesGetOwnPropertySlot | OverridesMarkChildren | OverridesGetPropertyNames), AnonymousSlotCount);
    6565    }
    6666
  • trunk/WebCore/ChangeLog

    r54020 r54022  
     12010-01-28  Oliver Hunt  <oliver@apple.com>
     2
     3        Reviewed by Gavin Barraclough.
     4
     5        Simplify anonymous slot implementation
     6        https://bugs.webkit.org/show_bug.cgi?id=34282
     7
     8        Update the WebCore JS DOM bindings to correctly pass and
     9        propagate the anonymous slot count information.
     10
     11        * bindings/js/JSDOMBinding.h:
     12        (WebCore::DOMObjectWithGlobalPointer::createStructure):
     13        (WebCore::DOMConstructorObject::createStructure):
     14        * bindings/js/JSDOMWindowShell.h:
     15        (WebCore::JSDOMWindowShell::createStructure):
     16        * bindings/scripts/CodeGeneratorJS.pm:
     17        * bridge/objc/objc_runtime.h:
     18        (JSC::Bindings::ObjcFallbackObjectImp::createStructure):
     19        * bridge/runtime_array.h:
     20        (JSC::RuntimeArray::createStructure):
     21        * bridge/runtime_method.h:
     22        (JSC::RuntimeMethod::createStructure):
     23        * bridge/runtime_object.h:
     24        (JSC::RuntimeObjectImp::createStructure):
     25
    1262010-01-27  Evan Martin  <evan@chromium.org>
    227
  • trunk/WebCore/bindings/js/JSDOMBinding.h

    r53666 r54022  
    8282        static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype)
    8383        {
    84             return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags));
     84            return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount);
    8585        }
    8686
     
    114114        static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype)
    115115        {
    116             return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags));
     116            return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount);
    117117        }
    118118
  • trunk/WebCore/bindings/js/JSDOMWindowShell.h

    r53170 r54022  
    6161        static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype)
    6262        {
    63             return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags));
     63            return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount);
    6464        }
    6565
  • trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r53969 r54022  
    604604        "    static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype)\n" .
    605605        "    {\n" .
    606         "        return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags));\n" .
     606        "        return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount);\n" .
    607607        "    }\n\n");
    608608
     
    809809        "    static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype)\n" .
    810810        "    {\n" .
    811         "        return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags));\n" .
     811        "        return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount);\n" .
    812812        "    }\n");
    813813    if ($dataNode->extendedAttributes->{"DelegatingPrototypePutFunction"}) {
     
    22492249    static PassRefPtr<Structure> createStructure(JSValue proto)
    22502250    {
    2251         return Structure::create(proto, TypeInfo(ObjectType, StructureFlags));
     2251        return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
    22522252    }
    22532253   
  • trunk/WebCore/bridge/objc/objc_runtime.h

    r53464 r54022  
    105105    static PassRefPtr<Structure> createStructure(JSValue prototype)
    106106    {
    107         return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
     107        return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
    108108    }
    109109
  • trunk/WebCore/bridge/runtime_array.h

    r53464 r54022  
    6161    static PassRefPtr<Structure> createStructure(JSValue prototype)
    6262    {
    63         return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
     63        return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
    6464    }
    6565
  • trunk/WebCore/bridge/runtime_method.h

    r53464 r54022  
    4848    static PassRefPtr<Structure> createStructure(JSValue prototype)
    4949    {
    50         return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
     50        return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
    5151    }
    5252
  • trunk/WebCore/bridge/runtime_object.h

    r53464 r54022  
    6262    static PassRefPtr<Structure> createStructure(JSValue prototype)
    6363    {
    64         return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
     64        return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
    6565    }
    6666
Note: See TracChangeset for help on using the changeset viewer.