Changeset 37645 in webkit


Ignore:
Timestamp:
Oct 16, 2008 7:57:02 PM (15 years ago)
Author:
weinig@apple.com
Message:

2008-10-16 Sam Weinig <sam@webkit.org>

Reviewed by Maciej Stachowiak.

Fix for https://bugs.webkit.org/show_bug.cgi?id=21683
Don't create intermediate StructureIDs for builtin objects

First step in reduce number of StructureIDs created when initializing the
JSGlobalObject.

  • In order to avoid creating the intermediate StructureIDs use the new putDirectWithoutTransition and putDirectFunctionWithoutTransition to add properties to JSObjects without transitioning the StructureID. This patch just implements this strategy for ObjectPrototype but alone reduces the number of StructureIDs create for about:blank by 10, from 142 to 132.
  • kjs/JSGlobalObject.cpp: (JSC::JSGlobalObject::reset):
  • kjs/JSObject.cpp: (JSC::JSObject::putDirectFunctionWithoutTransition):
  • kjs/JSObject.h: (JSC::JSObject::putDirectWithoutTransition):
  • kjs/ObjectPrototype.cpp: (JSC::ObjectPrototype::ObjectPrototype):
  • kjs/ObjectPrototype.h:
  • kjs/StructureID.cpp: (JSC::StructureID::addPropertyWithoutTransition):
  • kjs/StructureID.h:
Location:
trunk/JavaScriptCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r37632 r37645  
     12008-10-16  Sam Weinig  <sam@webkit.org>
     2
     3        Reviewed by Maciej Stachowiak.
     4
     5        Fix for https://bugs.webkit.org/show_bug.cgi?id=21683
     6        Don't create intermediate StructureIDs for builtin objects
     7
     8        First step in reduce number of StructureIDs created when initializing the
     9        JSGlobalObject.
     10
     11        - In order to avoid creating the intermediate StructureIDs use the new putDirectWithoutTransition
     12          and putDirectFunctionWithoutTransition to add properties to JSObjects without transitioning
     13          the StructureID.  This patch just implements this strategy for ObjectPrototype but alone
     14          reduces the number of StructureIDs create for about:blank by 10, from 142 to 132.
     15
     16        * kjs/JSGlobalObject.cpp:
     17        (JSC::JSGlobalObject::reset):
     18        * kjs/JSObject.cpp:
     19        (JSC::JSObject::putDirectFunctionWithoutTransition):
     20        * kjs/JSObject.h:
     21        (JSC::JSObject::putDirectWithoutTransition):
     22        * kjs/ObjectPrototype.cpp:
     23        (JSC::ObjectPrototype::ObjectPrototype):
     24        * kjs/ObjectPrototype.h:
     25        * kjs/StructureID.cpp:
     26        (JSC::StructureID::addPropertyWithoutTransition):
     27        * kjs/StructureID.h:
     28
    1292008-10-16  Maciej Stachowiak  <mjs@apple.com>
    230
  • trunk/JavaScriptCore/kjs/JSGlobalObject.cpp

    r37631 r37645  
    206206    d()->prototypeFunctionStructure = PrototypeFunction::createStructureID(d()->functionPrototype);
    207207    d()->functionPrototype->addFunctionProperties(exec, d()->prototypeFunctionStructure.get());
    208     d()->objectPrototype = new (exec) ObjectPrototype(exec, d()->prototypeFunctionStructure.get());
     208
     209    d()->objectPrototype = new (exec) ObjectPrototype(exec, ObjectPrototype::createStructureID(jsNull()), d()->prototypeFunctionStructure.get());
    209210    d()->emptyObjectStructure = d()->objectPrototype->inheritorID();
    210211    d()->functionPrototype->setPrototype(d()->objectPrototype);
     
    259260    d()->typeErrorConstructor = new (exec) NativeErrorConstructor(exec, nativeErrorStructure, typeErrorPrototype);
    260261    d()->URIErrorConstructor = new (exec) NativeErrorConstructor(exec, nativeErrorStructure, URIErrorPrototype);
    261    
     262
    262263    d()->functionPrototype->putDirect(exec->propertyNames().constructor, functionConstructor, DontEnum);
    263264
    264     d()->objectPrototype->putDirect(exec->propertyNames().constructor, objectConstructor, DontEnum);
     265    d()->objectPrototype->putDirectWithoutTransition(exec->propertyNames().constructor, objectConstructor, DontEnum);
     266
    265267    d()->functionPrototype->putDirect(exec->propertyNames().constructor, functionConstructor, DontEnum);
    266268    d()->arrayPrototype->putDirect(exec->propertyNames().constructor, arrayConstructor, DontEnum);
  • trunk/JavaScriptCore/kjs/JSObject.cpp

    r37400 r37645  
    491491}
    492492
     493void JSObject::putDirectFunctionWithoutTransition(ExecState* exec, InternalFunction* function, unsigned attr)
     494{
     495    putDirectWithoutTransition(Identifier(exec, function->name(&exec->globalData())), function, attr);
     496}
     497
    493498NEVER_INLINE void JSObject::fillGetterPropertySlot(PropertySlot& slot, JSValue** location)
    494499{
  • trunk/JavaScriptCore/kjs/JSObject.h

    r37497 r37645  
    158158        void putDirect(const Identifier& propertyName, JSValue* value, unsigned attr, bool checkReadOnly, PutPropertySlot& slot);
    159159        void putDirectFunction(ExecState* exec, InternalFunction* function, unsigned attr = 0);
     160        void putDirectWithoutTransition(const Identifier& propertyName, JSValue* value, unsigned attr);
     161        void putDirectFunctionWithoutTransition(ExecState* exec, InternalFunction* function, unsigned attr);
    160162
    161163        // Fast access to known property offsets.
     
    414416}
    415417
     418inline void JSObject::putDirectWithoutTransition(const Identifier& propertyName, JSValue* value, unsigned attributes)
     419{
     420    size_t currentCapacity = m_structureID->propertyStorageCapacity();
     421    size_t offset = m_structureID->addPropertyWithoutTransition(propertyName, attributes);
     422    if (currentCapacity != m_structureID->propertyStorageCapacity())
     423        allocatePropertyStorage(currentCapacity, m_structureID->propertyStorageCapacity());
     424    m_propertyStorage[offset] = value;
     425}
     426
    416427inline void JSObject::transitionTo(StructureID* newStructureID)
    417428{
  • trunk/JavaScriptCore/kjs/ObjectPrototype.cpp

    r36726 r37645  
    4040static JSValue* objectProtoFuncToLocaleString(ExecState*, JSObject*, JSValue*, const ArgList&);
    4141
    42 ObjectPrototype::ObjectPrototype(ExecState* exec, StructureID* prototypeFunctionStructure)
    43     : JSObject(exec->globalData().nullProtoStructureID)
     42ObjectPrototype::ObjectPrototype(ExecState* exec, PassRefPtr<StructureID> stucture, StructureID* prototypeFunctionStructure)
     43    : JSObject(stucture)
    4444{
    45     putDirectFunction(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().toString, objectProtoFuncToString), DontEnum);
    46     putDirectFunction(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().toLocaleString, objectProtoFuncToLocaleString), DontEnum);
    47     putDirectFunction(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().valueOf, objectProtoFuncValueOf), DontEnum);
    48     putDirectFunction(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 1, exec->propertyNames().hasOwnProperty, objectProtoFuncHasOwnProperty), DontEnum);
    49     putDirectFunction(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 1, exec->propertyNames().propertyIsEnumerable, objectProtoFuncPropertyIsEnumerable), DontEnum);
    50     putDirectFunction(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 1, exec->propertyNames().isPrototypeOf, objectProtoFuncIsPrototypeOf), DontEnum);
     45    putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().toString, objectProtoFuncToString), DontEnum);
     46    putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().toLocaleString, objectProtoFuncToLocaleString), DontEnum);
     47    putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().valueOf, objectProtoFuncValueOf), DontEnum);
     48    putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 1, exec->propertyNames().hasOwnProperty, objectProtoFuncHasOwnProperty), DontEnum);
     49    putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 1, exec->propertyNames().propertyIsEnumerable, objectProtoFuncPropertyIsEnumerable), DontEnum);
     50    putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 1, exec->propertyNames().isPrototypeOf, objectProtoFuncIsPrototypeOf), DontEnum);
    5151
    5252    // Mozilla extensions
    53     putDirectFunction(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 2, exec->propertyNames().__defineGetter__, objectProtoFuncDefineGetter), DontEnum);
    54     putDirectFunction(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 2, exec->propertyNames().__defineSetter__, objectProtoFuncDefineSetter), DontEnum);
    55     putDirectFunction(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 1, exec->propertyNames().__lookupGetter__, objectProtoFuncLookupGetter), DontEnum);
    56     putDirectFunction(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 1, exec->propertyNames().__lookupSetter__, objectProtoFuncLookupSetter), DontEnum);
     53    putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 2, exec->propertyNames().__defineGetter__, objectProtoFuncDefineGetter), DontEnum);
     54    putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 2, exec->propertyNames().__defineSetter__, objectProtoFuncDefineSetter), DontEnum);
     55    putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 1, exec->propertyNames().__lookupGetter__, objectProtoFuncLookupGetter), DontEnum);
     56    putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 1, exec->propertyNames().__lookupSetter__, objectProtoFuncLookupSetter), DontEnum);
    5757}
    5858
  • trunk/JavaScriptCore/kjs/ObjectPrototype.h

    r36726 r37645  
    2828    class ObjectPrototype : public JSObject {
    2929    public:
    30         ObjectPrototype(ExecState*, StructureID* prototypeFunctionStructure);
     30        ObjectPrototype(ExecState*, PassRefPtr<StructureID>, StructureID* prototypeFunctionStructure);
    3131    };
    3232
  • trunk/JavaScriptCore/kjs/StructureID.cpp

    r37632 r37645  
    318318}
    319319
     320size_t StructureID::addPropertyWithoutTransition(const Identifier& propertyName, unsigned attributes)
     321{
     322    size_t offset = m_propertyMap.put(propertyName, attributes);
     323    if (m_propertyMap.storageSize() > propertyStorageCapacity())
     324        growPropertyStorageCapacity();
     325    return offset;
     326}
     327
    320328StructureIDChain* StructureID::createCachedPrototypeChain()
    321329{
  • trunk/JavaScriptCore/kjs/StructureID.h

    r37629 r37645  
    106106        }
    107107
     108        size_t addPropertyWithoutTransition(const Identifier& propertyName, unsigned attributes);
     109
    108110        bool isDictionary() const { return m_isDictionary; }
    109111
Note: See TracChangeset for help on using the changeset viewer.