Changeset 41232 in webkit for trunk/JavaScriptCore/runtime/Structure.cpp
- Timestamp:
- Feb 25, 2009, 3:44:07 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/Structure.cpp
r40608 r41232 124 124 : m_typeInfo(typeInfo) 125 125 , m_prototype(prototype) 126 , m_cachedPrototypeChain(0)127 , m_previous(0)128 , m_nameInPrevious(0)129 126 , m_propertyTable(0) 130 127 , m_propertyStorageCapacity(JSObject::inlineStorageCapacity) … … 290 287 void Structure::getEnumerablePropertyNames(ExecState* exec, PropertyNameArray& propertyNames, JSObject* baseObject) 291 288 { 292 bool shouldCache = propertyNames.cacheable() && !(propertyNames.size() || m_isDictionary); 289 bool shouldCache = propertyNames.shouldCache() && !(propertyNames.size() || m_isDictionary); 290 291 if (shouldCache && m_cachedPropertyNameArrayData) { 292 if (m_cachedPropertyNameArrayData->cachedPrototypeChain() == prototypeChain(exec)) { 293 propertyNames.setData(m_cachedPropertyNameArrayData); 294 return; 295 } 296 clearEnumerationCache(); 297 } 298 299 getEnumerableNamesFromPropertyTable(propertyNames); 300 getEnumerableNamesFromClassInfoTable(exec, baseObject->classInfo(), propertyNames); 301 302 if (m_prototype.isObject()) { 303 propertyNames.setShouldCache(false); // No need for our prototypes to waste memory on caching, since they're not being enumerated directly. 304 asObject(m_prototype)->getPropertyNames(exec, propertyNames); 305 } 293 306 294 307 if (shouldCache) { 295 if (m_cachedPropertyNameArrayData) {296 if (structureChainsAreEqual(m_cachedPropertyNameArrayData->cachedPrototypeChain(), cachedPrototypeChain())) {297 propertyNames.setData(m_cachedPropertyNameArrayData);298 return;299 }300 }301 propertyNames.setCacheable(false);302 }303 304 getEnumerablePropertyNamesInternal(propertyNames);305 306 // Add properties from the static hashtables of properties307 for (const ClassInfo* info = baseObject->classInfo(); info; info = info->parentClass) {308 const HashTable* table = info->propHashTable(exec);309 if (!table)310 continue;311 table->initializeIfNeeded(exec);312 ASSERT(table->table);313 #if ENABLE(PERFECT_HASH_SIZE)314 int hashSizeMask = table->hashSizeMask;315 #else316 int hashSizeMask = table->compactSize - 1;317 #endif318 const HashEntry* entry = table->table;319 for (int i = 0; i <= hashSizeMask; ++i, ++entry) {320 if (entry->key() && !(entry->attributes() & DontEnum))321 propertyNames.add(entry->key());322 }323 }324 325 if (m_prototype.isObject())326 asObject(m_prototype)->getPropertyNames(exec, propertyNames);327 328 if (shouldCache) {329 if (m_cachedPropertyNameArrayData)330 m_cachedPropertyNameArrayData->setCachedStructure(0);331 332 308 m_cachedPropertyNameArrayData = propertyNames.data(); 333 334 StructureChain* chain = cachedPrototypeChain(); 335 if (!chain) 336 chain = createCachedPrototypeChain(); 337 m_cachedPropertyNameArrayData->setCachedPrototypeChain(chain); 309 m_cachedPropertyNameArrayData->setCachedPrototypeChain(prototypeChain(exec)); 338 310 m_cachedPropertyNameArrayData->setCachedStructure(this); 339 311 } … … 535 507 clearEnumerationCache(); 536 508 return offset; 537 }538 539 StructureChain* Structure::createCachedPrototypeChain()540 {541 ASSERT(typeInfo().type() == ObjectType);542 ASSERT(!m_cachedPrototypeChain);543 544 JSValuePtr prototype = storedPrototype();545 if (!prototype.isCell())546 return 0;547 548 RefPtr<StructureChain> chain = StructureChain::create(asObject(prototype)->structure());549 setCachedPrototypeChain(chain.release());550 return cachedPrototypeChain();551 509 } 552 510 … … 925 883 } 926 884 927 void Structure::getEnumerable PropertyNamesInternal(PropertyNameArray& propertyNames)885 void Structure::getEnumerableNamesFromPropertyTable(PropertyNameArray& propertyNames) 928 886 { 929 887 materializePropertyMapIfNecessary(); … … 979 937 for (size_t i = 0; i < sortedEnumerables.size(); ++i) 980 938 propertyNames.add(sortedEnumerables[i]->key); 939 } 940 } 941 942 void Structure::getEnumerableNamesFromClassInfoTable(ExecState* exec, const ClassInfo* classInfo, PropertyNameArray& propertyNames) 943 { 944 // Add properties from the static hashtables of properties 945 for (; classInfo; classInfo = classInfo->parentClass) { 946 const HashTable* table = classInfo->propHashTable(exec); 947 if (!table) 948 continue; 949 table->initializeIfNeeded(exec); 950 ASSERT(table->table); 951 #if ENABLE(PERFECT_HASH_SIZE) 952 int hashSizeMask = table->hashSizeMask; 953 #else 954 int hashSizeMask = table->compactSize - 1; 955 #endif 956 const HashEntry* entry = table->table; 957 for (int i = 0; i <= hashSizeMask; ++i, ++entry) { 958 if (entry->key() && !(entry->attributes() & DontEnum)) 959 propertyNames.add(entry->key()); 960 } 981 961 } 982 962 }
Note:
See TracChangeset
for help on using the changeset viewer.