Ignore:
Timestamp:
Sep 15, 2008, 12:27:14 AM (17 years ago)
Author:
[email protected]
Message:

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

Reviewed by Maciej Stachowiak.

Patch for https://bugs.webkit.org/show_bug.cgi?id=20849
Cache property names for getEnumerablePropertyNames in the StructureID.

~0.5% speedup on Sunspider overall (9.7% speedup on string-fasta). ~1% speedup
on the v8 test suite.

  • kjs/JSObject.cpp: (JSC::JSObject::getPropertyNames):
  • kjs/PropertyMap.cpp: (JSC::PropertyMap::getEnumerablePropertyNames):
  • kjs/PropertyMap.h:
  • kjs/StructureID.cpp: (JSC::StructureID::StructureID): (JSC::StructureID::getEnumerablePropertyNames):
  • kjs/StructureID.h:
File:
1 edited

Legend:

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

    r36401 r36429  
    2929#include "identifier.h"
    3030#include "JSObject.h"
     31#include "PropertyNameArray.h";
    3132#include <wtf/RefPtr.h>
    3233
     
    3536namespace JSC {
    3637
    37     StructureID::StructureID(JSValue* prototype, JSType type)
     38StructureID::StructureID(JSValue* prototype, JSType type)
    3839    : m_isDictionary(false)
    3940    , m_type(type)
     
    4647    ASSERT(m_prototype);
    4748    ASSERT(m_prototype->isObject() || m_prototype->isNull());
     49}
     50
     51void 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    }
    4863}
    4964
Note: See TracChangeset for help on using the changeset viewer.