Changeset 49328 in webkit for trunk/JavaScriptCore/runtime
- Timestamp:
- Oct 8, 2009, 3:25:14 PM (16 years ago)
- Location:
- trunk/JavaScriptCore/runtime
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/JSCell.h
r49323 r49328 343 343 } 344 344 345 inline void Structure::markAggregate(MarkStack& markStack) 346 { 347 markStack.append(m_prototype); 348 } 349 345 350 inline Heap* Heap::heap(JSValue v) 346 351 { -
trunk/JavaScriptCore/runtime/JSGlobalData.h
r49324 r49328 37 37 #include "NumericStrings.h" 38 38 #include "SmallStrings.h" 39 #include "Structure.h"40 39 #include "TimeoutChecker.h" 41 40 #include <wtf/Forward.h> -
trunk/JavaScriptCore/runtime/JSGlobalObject.cpp
r49323 r49328 90 90 { 91 91 if (s) 92 markIfNeeded(markStack, s->storedPrototype());92 s->markAggregate(markStack); 93 93 } 94 94 … … 395 395 396 396 markIfNeeded(markStack, d()->errorStructure); 397 markIfNeeded(markStack, d()->argumentsStructure);398 markIfNeeded(markStack, d()->arrayStructure);399 markIfNeeded(markStack, d()->booleanObjectStructure);400 markIfNeeded(markStack, d()->callbackConstructorStructure);401 markIfNeeded(markStack, d()->callbackFunctionStructure);402 markIfNeeded(markStack, d()->callbackObjectStructure);403 markIfNeeded(markStack, d()->dateStructure);404 markIfNeeded(markStack, d()->emptyObjectStructure);405 markIfNeeded(markStack, d()->errorStructure);406 markIfNeeded(markStack, d()->functionStructure);407 markIfNeeded(markStack, d()->numberObjectStructure);408 markIfNeeded(markStack, d()->prototypeFunctionStructure);409 markIfNeeded(markStack, d()->regExpMatchesArrayStructure);410 markIfNeeded(markStack, d()->regExpStructure);411 markIfNeeded(markStack, d()->stringObjectStructure);412 397 413 398 // No need to mark the other structures, because their prototypes are all -
trunk/JavaScriptCore/runtime/JSObject.cpp
r49323 r49328 43 43 ASSERT_CLASS_FITS_IN_CELL(JSObject); 44 44 45 static inline void getEnumerablePropertyNames(ExecState* exec, const ClassInfo* classInfo, PropertyNameArray& propertyNames)46 {47 // Add properties from the static hashtables of properties48 for (; classInfo; classInfo = classInfo->parentClass) {49 const HashTable* table = classInfo->propHashTable(exec);50 if (!table)51 continue;52 table->initializeIfNeeded(exec);53 ASSERT(table->table);54 55 int hashSizeMask = table->compactSize - 1;56 const HashEntry* entry = table->table;57 for (int i = 0; i <= hashSizeMask; ++i, ++entry) {58 if (entry->key() && !(entry->attributes() & DontEnum))59 propertyNames.add(entry->key());60 }61 }62 }63 64 45 void JSObject::markChildren(MarkStack& markStack) 65 46 { … … 444 425 void JSObject::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames) 445 426 { 446 bool shouldCache = propertyNames.shouldCache() && !(propertyNames.size() || m_structure->isDictionary()); 447 448 if (shouldCache) { 449 if (PropertyNameArrayData* data = m_structure->enumerationCache()) { 450 if (data->cachedPrototypeChain() == m_structure->prototypeChain(exec)) { 451 propertyNames.setData(data); 452 return; 453 } 454 455 m_structure->clearEnumerationCache(); 456 } 457 } 458 459 getOwnPropertyNames(exec, propertyNames); 460 461 if (prototype().isObject()) { 462 propertyNames.setShouldCache(false); // No need for our prototypes to waste memory on caching, since they're not being enumerated directly. 463 JSObject* prototype = asObject(this->prototype()); 464 while(1) { 465 if (!prototype->structure()->typeInfo().hasDefaultGetPropertyNames()) { 466 prototype->getPropertyNames(exec, propertyNames); 467 break; 468 } 469 prototype->getOwnPropertyNames(exec, propertyNames); 470 JSValue nextProto = prototype->prototype(); 471 if (!nextProto.isObject()) 472 break; 473 prototype = asObject(nextProto); 474 } 475 } 476 477 if (shouldCache) { 478 StructureChain* protoChain = m_structure->prototypeChain(exec); 479 if (!protoChain->isCacheable()) 480 return; 481 RefPtr<PropertyNameArrayData> data = propertyNames.data(); 482 data->setCachedPrototypeChain(protoChain); 483 data->setCachedStructure(m_structure); 484 m_structure->setEnumerationCache(data.release()); 485 } 427 m_structure->getEnumerablePropertyNames(exec, propertyNames, this); 486 428 } 487 429 488 430 void JSObject::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames) 489 431 { 490 m_structure->getEnumerablePropertyNames(propertyNames); 491 getEnumerablePropertyNames(exec, classInfo(), propertyNames); 432 m_structure->getOwnEnumerablePropertyNames(exec, propertyNames, this); 492 433 } 493 434 -
trunk/JavaScriptCore/runtime/JSObject.h
r49323 r49328 683 683 JSCell::markChildren(markStack); 684 684 685 m arkStack.append(prototype());685 m_structure->markAggregate(markStack); 686 686 687 687 PropertyStorage storage = propertyStorage(); -
trunk/JavaScriptCore/runtime/PropertyNameArray.h
r49323 r49328 24 24 #include "CallFrame.h" 25 25 #include "Identifier.h" 26 #include "Structure Chain.h"26 #include "Structure.h" 27 27 #include <wtf/HashSet.h> 28 28 #include <wtf/Vector.h> 29 29 30 30 namespace JSC { 31 32 class Structure;33 31 34 32 class PropertyNameArrayData : public RefCounted<PropertyNameArrayData> { -
trunk/JavaScriptCore/runtime/Structure.cpp
r49323 r49328 283 283 } 284 284 285 void Structure::getOwnEnumerablePropertyNames(ExecState* exec, PropertyNameArray& propertyNames, JSObject* baseObject) 286 { 287 getEnumerableNamesFromPropertyTable(propertyNames); 288 getEnumerableNamesFromClassInfoTable(exec, baseObject->classInfo(), propertyNames); 289 } 290 291 void Structure::getEnumerablePropertyNames(ExecState* exec, PropertyNameArray& propertyNames, JSObject* baseObject) 292 { 293 bool shouldCache = propertyNames.shouldCache() && !(propertyNames.size() || isDictionary()); 294 295 if (shouldCache && m_cachedPropertyNameArrayData) { 296 if (m_cachedPropertyNameArrayData->cachedPrototypeChain() == prototypeChain(exec)) { 297 propertyNames.setData(m_cachedPropertyNameArrayData); 298 return; 299 } 300 clearEnumerationCache(); 301 } 302 303 baseObject->getOwnPropertyNames(exec, propertyNames); 304 305 if (m_prototype.isObject()) { 306 propertyNames.setShouldCache(false); // No need for our prototypes to waste memory on caching, since they're not being enumerated directly. 307 JSObject* prototype = asObject(m_prototype); 308 while(1) { 309 if (!prototype->structure()->typeInfo().hasDefaultGetPropertyNames()) { 310 prototype->getPropertyNames(exec, propertyNames); 311 break; 312 } 313 prototype->getOwnPropertyNames(exec, propertyNames); 314 JSValue nextProto = prototype->prototype(); 315 if (!nextProto.isObject()) 316 break; 317 prototype = asObject(nextProto); 318 } 319 } 320 321 if (shouldCache) { 322 StructureChain* protoChain = prototypeChain(exec); 323 m_cachedPropertyNameArrayData = propertyNames.data(); 324 if (!protoChain->isCacheable()) 325 return; 326 m_cachedPropertyNameArrayData->setCachedPrototypeChain(protoChain); 327 m_cachedPropertyNameArrayData->setCachedStructure(this); 328 } 329 } 330 285 331 void Structure::clearEnumerationCache() 286 332 { … … 1012 1058 } 1013 1059 1014 void Structure::getEnumerable PropertyNames(PropertyNameArray& propertyNames)1060 void Structure::getEnumerableNamesFromPropertyTable(PropertyNameArray& propertyNames) 1015 1061 { 1016 1062 materializePropertyMapIfNecessary(); … … 1066 1112 for (size_t i = 0; i < sortedEnumerables.size(); ++i) 1067 1113 propertyNames.add(sortedEnumerables[i]->key); 1114 } 1115 } 1116 1117 void Structure::getEnumerableNamesFromClassInfoTable(ExecState* exec, const ClassInfo* classInfo, PropertyNameArray& propertyNames) 1118 { 1119 // Add properties from the static hashtables of properties 1120 for (; classInfo; classInfo = classInfo->parentClass) { 1121 const HashTable* table = classInfo->propHashTable(exec); 1122 if (!table) 1123 continue; 1124 table->initializeIfNeeded(exec); 1125 ASSERT(table->table); 1126 1127 int hashSizeMask = table->compactSize - 1; 1128 const HashEntry* entry = table->table; 1129 for (int i = 0; i <= hashSizeMask; ++i, ++entry) { 1130 if (entry->key() && !(entry->attributes() & DontEnum)) 1131 propertyNames.add(entry->key()); 1132 } 1068 1133 } 1069 1134 } -
trunk/JavaScriptCore/runtime/Structure.h
r49323 r49328 31 31 #include "JSValue.h" 32 32 #include "PropertyMapHashTable.h" 33 #include "PropertyNameArray.h"34 33 #include "StructureChain.h" 35 34 #include "StructureTransitionTable.h" … … 78 77 ~Structure(); 79 78 79 void markAggregate(MarkStack&); 80 80 81 // These should be used with caution. 81 82 size_t addPropertyWithoutTransition(const Identifier& propertyName, unsigned attributes, JSCell* specificValue); … … 116 117 } 117 118 119 void getEnumerablePropertyNames(ExecState*, PropertyNameArray&, JSObject*); 120 void getOwnEnumerablePropertyNames(ExecState*, PropertyNameArray&, JSObject*); 121 118 122 bool hasGetterSetterProperties() const { return m_hasGetterSetterProperties; } 119 123 void setHasGetterSetterProperties(bool hasGetterSetterProperties) { m_hasGetterSetterProperties = hasGetterSetterProperties; } … … 123 127 JSCell* specificValue() { return m_specificValueInPrevious; } 124 128 void despecifyDictionaryFunction(const Identifier& propertyName); 125 126 void setEnumerationCache(PassRefPtr<PropertyNameArrayData> data) { m_cachedPropertyNameArrayData = data; }127 PropertyNameArrayData* enumerationCache() { return m_cachedPropertyNameArrayData.get(); }128 void clearEnumerationCache();129 void getEnumerablePropertyNames(PropertyNameArray&);130 129 131 130 private: … … 142 141 size_t remove(const Identifier& propertyName); 143 142 void addAnonymousSlots(unsigned slotCount); 143 void getEnumerableNamesFromPropertyTable(PropertyNameArray&); 144 void getEnumerableNamesFromClassInfoTable(ExecState*, const ClassInfo*, PropertyNameArray&); 144 145 145 146 void expandPropertyMapHashTable(); … … 161 162 materializePropertyMap(); 162 163 } 164 165 void clearEnumerationCache(); 163 166 164 167 signed char transitionCount() const
Note:
See TracChangeset
for help on using the changeset viewer.