Changeset 36696 in webkit for trunk/JavaScriptCore/kjs/StructureID.cpp
- Timestamp:
- Sep 19, 2008, 8:19:17 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/StructureID.cpp
r36694 r36696 30 30 #include "JSObject.h" 31 31 #include "PropertyNameArray.h" 32 #include "lookup.h"33 32 #include <wtf/RefPtr.h> 34 33 … … 50 49 } 51 50 52 static bool structureIDChainsAreEqual(StructureIDChain* chainA, StructureIDChain* chainB) 51 void StructureID::getEnumerablePropertyNames(PropertyNameArray& propertyNames) const 53 52 { 54 if ( !chainA || !chainB)55 return false;53 if (m_cachedPropertyNameArray.isEmpty()) 54 m_propertyMap.getEnumerablePropertyNames(m_cachedPropertyNameArray); 56 55 57 RefPtr<StructureID>* a = chainA->head(); 58 RefPtr<StructureID>* b = chainB->head(); 59 while (1) { 60 if (*a != *b) 61 return false; 62 if (!*a) 63 return true; 64 a++; 65 b++; 56 if (!propertyNames.size()) { 57 for (size_t i = 0; i < m_cachedPropertyNameArray.size(); ++i) 58 propertyNames.addKnownUnique(m_cachedPropertyNameArray[i]); 59 } else { 60 for (size_t i = 0; i < m_cachedPropertyNameArray.size(); ++i) 61 propertyNames.add(m_cachedPropertyNameArray[i]); 66 62 } 67 }68 69 void StructureID::getEnumerablePropertyNames(ExecState* exec, PropertyNameArray& propertyNames, JSObject* baseObject)70 {71 bool shouldCache = !(propertyNames.size() || m_isDictionary);72 73 if (shouldCache && m_cachedPropertyNameArrayData) {74 if (structureIDChainsAreEqual(m_cachedPropertyNameArrayData->cachedPrototypeChain(), cachedPrototypeChain())) {75 propertyNames.setData(m_cachedPropertyNameArrayData);76 return;77 }78 }79 80 m_propertyMap.getEnumerablePropertyNames(propertyNames);81 82 // Add properties from the static hashtables of properties83 for (const ClassInfo* info = baseObject->classInfo(); info; info = info->parentClass) {84 const HashTable* table = info->propHashTable(exec);85 if (!table)86 continue;87 table->initializeIfNeeded(exec);88 ASSERT(table->table);89 int hashSizeMask = table->hashSizeMask;90 const HashEntry* entry = table->table;91 for (int i = 0; i <= hashSizeMask; ++i, ++entry) {92 if (entry->key && !(entry->attributes & DontEnum))93 propertyNames.add(entry->key);94 }95 }96 97 if (m_prototype->isObject())98 static_cast<JSObject*>(m_prototype)->getPropertyNames(exec, propertyNames);99 100 if (shouldCache) {101 m_cachedPropertyNameArrayData = propertyNames.data();102 103 StructureIDChain* chain = cachedPrototypeChain();104 if (!chain)105 chain = createCachedPrototypeChain();106 m_cachedPropertyNameArrayData->setCachedPrototypeChain(chain);107 }108 }109 110 void StructureID::clearEnumerationCache()111 {112 m_cachedPropertyNameArrayData.clear();113 63 } 114 64 … … 201 151 } 202 152 203 StructureIDChain* StructureID::createCachedPrototypeChain()204 {205 ASSERT(m_type == ObjectType);206 ASSERT(!m_cachedPrototypeChain);207 208 JSValue* prototype = storedPrototype();209 if (JSImmediate::isImmediate(prototype))210 return 0;211 212 RefPtr<StructureIDChain> chain = StructureIDChain::create(static_cast<JSObject*>(prototype)->structureID());213 setCachedPrototypeChain(chain.release());214 return cachedPrototypeChain();215 }216 217 153 StructureIDChain::StructureIDChain(StructureID* structureID) 218 154 {
Note:
See TracChangeset
for help on using the changeset viewer.