Ignore:
Timestamp:
Sep 19, 2008, 8:19:17 PM (17 years ago)
Author:
[email protected]
Message:

2008-09-19 Sam Weinig <[email protected]>

Roll out r36694.

  • JavaScriptCore.exp:
  • VM/JSPropertyNameIterator.cpp: (JSC::JSPropertyNameIterator::~JSPropertyNameIterator): (JSC::JSPropertyNameIterator::invalidate):
  • VM/JSPropertyNameIterator.h: (JSC::JSPropertyNameIterator::JSPropertyNameIterator): (JSC::JSPropertyNameIterator::create):
  • kjs/JSObject.cpp: (JSC::JSObject::getPropertyNames):
  • kjs/PropertyMap.cpp: (JSC::PropertyMap::getEnumerablePropertyNames):
  • kjs/PropertyMap.h:
  • kjs/PropertyNameArray.cpp: (JSC::PropertyNameArray::add):
  • kjs/PropertyNameArray.h: (JSC::PropertyNameArray::PropertyNameArray): (JSC::PropertyNameArray::addKnownUnique): (JSC::PropertyNameArray::begin): (JSC::PropertyNameArray::end): (JSC::PropertyNameArray::size): (JSC::PropertyNameArray::operator[]): (JSC::PropertyNameArray::releaseIdentifiers):
  • kjs/StructureID.cpp: (JSC::StructureID::getEnumerablePropertyNames):
  • kjs/StructureID.h: (JSC::StructureID::clearEnumerationCache):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/StructureID.cpp

    r36694 r36696  
    3030#include "JSObject.h"
    3131#include "PropertyNameArray.h"
    32 #include "lookup.h"
    3332#include <wtf/RefPtr.h>
    3433
     
    5049}
    5150
    52 static bool structureIDChainsAreEqual(StructureIDChain* chainA, StructureIDChain* chainB)
     51void StructureID::getEnumerablePropertyNames(PropertyNameArray& propertyNames) const
    5352{
    54     if (!chainA || !chainB)
    55         return false;
     53    if (m_cachedPropertyNameArray.isEmpty())
     54        m_propertyMap.getEnumerablePropertyNames(m_cachedPropertyNameArray);
    5655
    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]);
    6662    }
    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 properties
    83     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();
    11363}
    11464
     
    201151}
    202152
    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 
    217153StructureIDChain::StructureIDChain(StructureID* structureID)
    218154{
Note: See TracChangeset for help on using the changeset viewer.