Changeset 49331 in webkit for trunk/JavaScriptCore/runtime/Structure.cpp
- Timestamp:
- Oct 8, 2009, 4:24:55 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/Structure.cpp
r49328 r49331 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 331 285 void Structure::clearEnumerationCache() 332 286 { … … 1058 1012 } 1059 1013 1060 void Structure::getEnumerable NamesFromPropertyTable(PropertyNameArray& propertyNames)1014 void Structure::getEnumerablePropertyNames(PropertyNameArray& propertyNames) 1061 1015 { 1062 1016 materializePropertyMapIfNecessary(); … … 1112 1066 for (size_t i = 0; i < sortedEnumerables.size(); ++i) 1113 1067 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 properties1120 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 }1133 1068 } 1134 1069 }
Note:
See TracChangeset
for help on using the changeset viewer.