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

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

Roll r36694 back in. It did not cause the crash.

  • 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::PropertyNameArrayData::create): (JSC::PropertyNameArrayData::propertyNameVector): (JSC::PropertyNameArrayData::setCachedPrototypeChain): (JSC::PropertyNameArrayData::cachedPrototypeChain): (JSC::PropertyNameArrayData::begin): (JSC::PropertyNameArrayData::end): (JSC::PropertyNameArrayData::PropertyNameArrayData): (JSC::PropertyNameArray::PropertyNameArray): (JSC::PropertyNameArray::addKnownUnique): (JSC::PropertyNameArray::size): (JSC::PropertyNameArray::operator[]): (JSC::PropertyNameArray::begin): (JSC::PropertyNameArray::end): (JSC::PropertyNameArray::setData): (JSC::PropertyNameArray::data): (JSC::PropertyNameArray::releaseData):
  • kjs/StructureID.cpp: (JSC::structureIDChainsAreEqual): (JSC::StructureID::getEnumerablePropertyNames): (JSC::StructureID::clearEnumerationCache): (JSC::StructureID::createCachedPrototypeChain):
  • kjs/StructureID.h:
File:
1 edited

Legend:

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

    r36696 r36701  
    3030#include "JSObject.h"
    3131#include "PropertyNameArray.h"
     32#include "lookup.h"
    3233#include <wtf/RefPtr.h>
    3334
     
    4950}
    5051
    51 void StructureID::getEnumerablePropertyNames(PropertyNameArray& propertyNames) const
    52 {
    53     if (m_cachedPropertyNameArray.isEmpty())
    54         m_propertyMap.getEnumerablePropertyNames(m_cachedPropertyNameArray);
    55 
    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]);
    62     }
     52static bool structureIDChainsAreEqual(StructureIDChain* chainA, StructureIDChain* chainB)
     53{
     54    if (!chainA || !chainB)
     55        return false;
     56
     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++;
     66    }
     67}
     68
     69void 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
     110void StructureID::clearEnumerationCache()
     111{
     112    m_cachedPropertyNameArrayData.clear();
    63113}
    64114
     
    151201}
    152202
     203StructureIDChain* 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
    153217StructureIDChain::StructureIDChain(StructureID* structureID)
    154218{
Note: See TracChangeset for help on using the changeset viewer.