Changeset 37645 in webkit for trunk/JavaScriptCore
- Timestamp:
- Oct 16, 2008, 7:57:02 PM (17 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r37632 r37645 1 2008-10-16 Sam Weinig <[email protected]> 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 1 29 2008-10-16 Maciej Stachowiak <[email protected]> 2 30 -
trunk/JavaScriptCore/kjs/JSGlobalObject.cpp
r37631 r37645 206 206 d()->prototypeFunctionStructure = PrototypeFunction::createStructureID(d()->functionPrototype); 207 207 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()); 209 210 d()->emptyObjectStructure = d()->objectPrototype->inheritorID(); 210 211 d()->functionPrototype->setPrototype(d()->objectPrototype); … … 259 260 d()->typeErrorConstructor = new (exec) NativeErrorConstructor(exec, nativeErrorStructure, typeErrorPrototype); 260 261 d()->URIErrorConstructor = new (exec) NativeErrorConstructor(exec, nativeErrorStructure, URIErrorPrototype); 261 262 262 263 d()->functionPrototype->putDirect(exec->propertyNames().constructor, functionConstructor, DontEnum); 263 264 264 d()->objectPrototype->putDirect(exec->propertyNames().constructor, objectConstructor, DontEnum); 265 d()->objectPrototype->putDirectWithoutTransition(exec->propertyNames().constructor, objectConstructor, DontEnum); 266 265 267 d()->functionPrototype->putDirect(exec->propertyNames().constructor, functionConstructor, DontEnum); 266 268 d()->arrayPrototype->putDirect(exec->propertyNames().constructor, arrayConstructor, DontEnum); -
trunk/JavaScriptCore/kjs/JSObject.cpp
r37400 r37645 491 491 } 492 492 493 void JSObject::putDirectFunctionWithoutTransition(ExecState* exec, InternalFunction* function, unsigned attr) 494 { 495 putDirectWithoutTransition(Identifier(exec, function->name(&exec->globalData())), function, attr); 496 } 497 493 498 NEVER_INLINE void JSObject::fillGetterPropertySlot(PropertySlot& slot, JSValue** location) 494 499 { -
trunk/JavaScriptCore/kjs/JSObject.h
r37497 r37645 158 158 void putDirect(const Identifier& propertyName, JSValue* value, unsigned attr, bool checkReadOnly, PutPropertySlot& slot); 159 159 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); 160 162 161 163 // Fast access to known property offsets. … … 414 416 } 415 417 418 inline 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 416 427 inline void JSObject::transitionTo(StructureID* newStructureID) 417 428 { -
trunk/JavaScriptCore/kjs/ObjectPrototype.cpp
r36726 r37645 40 40 static JSValue* objectProtoFuncToLocaleString(ExecState*, JSObject*, JSValue*, const ArgList&); 41 41 42 ObjectPrototype::ObjectPrototype(ExecState* exec, StructureID* prototypeFunctionStructure)43 : JSObject( exec->globalData().nullProtoStructureID)42 ObjectPrototype::ObjectPrototype(ExecState* exec, PassRefPtr<StructureID> stucture, StructureID* prototypeFunctionStructure) 43 : JSObject(stucture) 44 44 { 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); 51 51 52 52 // 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); 57 57 } 58 58 -
trunk/JavaScriptCore/kjs/ObjectPrototype.h
r36726 r37645 28 28 class ObjectPrototype : public JSObject { 29 29 public: 30 ObjectPrototype(ExecState*, StructureID* prototypeFunctionStructure);30 ObjectPrototype(ExecState*, PassRefPtr<StructureID>, StructureID* prototypeFunctionStructure); 31 31 }; 32 32 -
trunk/JavaScriptCore/kjs/StructureID.cpp
r37632 r37645 318 318 } 319 319 320 size_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 320 328 StructureIDChain* StructureID::createCachedPrototypeChain() 321 329 { -
trunk/JavaScriptCore/kjs/StructureID.h
r37629 r37645 106 106 } 107 107 108 size_t addPropertyWithoutTransition(const Identifier& propertyName, unsigned attributes); 109 108 110 bool isDictionary() const { return m_isDictionary; } 109 111
Note:
See TracChangeset
for help on using the changeset viewer.