Changeset 36429 in webkit for trunk/JavaScriptCore
- Timestamp:
- Sep 15, 2008, 12:27:14 AM (17 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r36427 r36429 1 2008-09-15 Sam Weinig <[email protected]> 2 3 Reviewed by Maciej Stachowiak. 4 5 Patch for https://bugs.webkit.org/show_bug.cgi?id=20849 6 Cache property names for getEnumerablePropertyNames in the StructureID. 7 8 ~0.5% speedup on Sunspider overall (9.7% speedup on string-fasta). ~1% speedup 9 on the v8 test suite. 10 11 * kjs/JSObject.cpp: 12 (JSC::JSObject::getPropertyNames): 13 * kjs/PropertyMap.cpp: 14 (JSC::PropertyMap::getEnumerablePropertyNames): 15 * kjs/PropertyMap.h: 16 * kjs/StructureID.cpp: 17 (JSC::StructureID::StructureID): 18 (JSC::StructureID::getEnumerablePropertyNames): 19 * kjs/StructureID.h: 20 1 21 2008-09-14 Maciej Stachowiak <[email protected]> 2 22 -
trunk/JavaScriptCore/kjs/JSObject.cpp
r36417 r36429 433 433 void JSObject::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames) 434 434 { 435 m_structureID-> propertyMap().getEnumerablePropertyNames(propertyNames);435 m_structureID->getEnumerablePropertyNames(propertyNames); 436 436 437 437 // Add properties from the static hashtables of properties -
trunk/JavaScriptCore/kjs/PropertyMap.cpp
r36325 r36429 24 24 #include "JSObject.h" 25 25 #include "protect.h" 26 #include "PropertyNameArray.h"27 26 #include <algorithm> 28 27 #include <wtf/Assertions.h> … … 474 473 } 475 474 476 void PropertyMap::getEnumerablePropertyNames( PropertyNameArray& propertyNames) const475 void PropertyMap::getEnumerablePropertyNames(Vector<UString::Rep*>& propertyNames) const 477 476 { 478 477 if (!m_table) … … 493 492 } 494 493 } 495 if (!propertyNames.size()) { 496 for (int k = 0; k < i; ++k) 497 propertyNames.addKnownUnique(a[k]->key); 498 } else { 499 for (int k = 0; k < i; ++k) 500 propertyNames.add(a[k]->key); 501 } 494 propertyNames.reserveCapacity(i); 495 for (int k = 0; k < i; ++k) 496 propertyNames.append(a[k]->key); 502 497 return; 503 498 } … … 518 513 519 514 // Put the keys of the sorted entries into the list. 520 for (Entry** q = sortedEnumerables.data(); q != p; ++q) 521 propertyNames.add(q[0]->key); 515 propertyNames.reserveCapacity(sortedEnumerables.size()); 516 for (size_t i = 0; i < sortedEnumerables.size(); ++i) 517 propertyNames.append(sortedEnumerables[i]->key); 522 518 } 523 519 -
trunk/JavaScriptCore/kjs/PropertyMap.h
r36325 r36429 31 31 class JSObject; 32 32 class JSValue; 33 class PropertyNameArray;34 33 35 34 typedef JSValue** PropertyStorage; … … 95 94 size_t getOffset(const Identifier& propertyName, unsigned& attributes); 96 95 97 void getEnumerablePropertyNames( PropertyNameArray&) const;96 void getEnumerablePropertyNames(Vector<UString::Rep*>&) const; 98 97 99 98 bool hasGetterSetterProperties() const { return m_getterSetterFlag; } -
trunk/JavaScriptCore/kjs/StructureID.cpp
r36401 r36429 29 29 #include "identifier.h" 30 30 #include "JSObject.h" 31 #include "PropertyNameArray.h"; 31 32 #include <wtf/RefPtr.h> 32 33 … … 35 36 namespace JSC { 36 37 37 38 StructureID::StructureID(JSValue* prototype, JSType type) 38 39 : m_isDictionary(false) 39 40 , m_type(type) … … 46 47 ASSERT(m_prototype); 47 48 ASSERT(m_prototype->isObject() || m_prototype->isNull()); 49 } 50 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 } 48 63 } 49 64 -
trunk/JavaScriptCore/kjs/StructureID.h
r36401 r36429 40 40 41 41 class JSValue; 42 class PropertyNameArray; 42 43 class StructureIDChain; 43 44 … … 108 109 PropertyMap& propertyMap() { return m_propertyMap; } 109 110 111 void getEnumerablePropertyNames(PropertyNameArray&) const; 112 110 113 static void transitionTo(StructureID* oldStructureID, StructureID* newStructureID, JSObject* slotBase); 111 114 … … 131 134 TransitionTable m_transitionTable; 132 135 136 mutable Vector<UString::Rep*> m_cachedPropertyNameArray; 137 133 138 PropertyMap m_propertyMap; 134 139 };
Note:
See TracChangeset
for help on using the changeset viewer.