Changeset 184050 in webkit
- Timestamp:
- May 10, 2015, 1:03:57 PM (11 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 6 edited
-
ChangeLog (modified) (1 diff)
-
runtime/JSObject.cpp (modified) (1 diff)
-
runtime/JSPropertyNameEnumerator.cpp (modified) (1 diff)
-
runtime/JSPropertyNameEnumerator.h (modified) (2 diffs)
-
runtime/PropertyNameArray.cpp (modified) (2 diffs)
-
runtime/PropertyNameArray.h (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r184040 r184050 1 2015-05-10 Andreas Kling <akling@apple.com> 2 3 Remove unused things from PropertyNameArray. 4 <https://webkit.org/b/144834> 5 6 Reviewed by Filip Pizlo. 7 8 PropertyNameArray had a bunch of bells and whistles added to it when for-in iteration 9 was refactored and optimized last year. Then more refactoring happened and this class 10 doesn't need to ring and toot anymore. 11 12 The RefCountedIdentifierSet class disappears since the JSPropertyNameEnumerator wasn't 13 actually using it for anything and we were just wasting time creating these. 14 15 Also made the member functions take AtomicStringImpl* instead of plain StringImpl*. 16 17 * runtime/JSObject.cpp: 18 (JSC::JSObject::getPropertyNames): 19 * runtime/JSPropertyNameEnumerator.cpp: 20 (JSC::JSPropertyNameEnumerator::create): 21 (JSC::JSPropertyNameEnumerator::JSPropertyNameEnumerator): 22 * runtime/JSPropertyNameEnumerator.h: 23 * runtime/PropertyNameArray.cpp: 24 (JSC::PropertyNameArray::add): 25 (JSC::PropertyNameArray::setPreviouslyEnumeratedProperties): Deleted. 26 * runtime/PropertyNameArray.h: 27 (JSC::PropertyNameArray::PropertyNameArray): 28 (JSC::PropertyNameArray::add): 29 (JSC::PropertyNameArray::addKnownUnique): 30 (JSC::PropertyNameArray::canAddKnownUniqueForStructure): 31 (JSC::RefCountedIdentifierSet::contains): Deleted. 32 (JSC::RefCountedIdentifierSet::size): Deleted. 33 (JSC::RefCountedIdentifierSet::add): Deleted. 34 (JSC::PropertyNameArray::identifierSet): Deleted. 35 (JSC::PropertyNameArray::numCacheableSlots): Deleted. 36 (JSC::PropertyNameArray::setNumCacheableSlotsForObject): Deleted. 37 (JSC::PropertyNameArray::setBaseObject): Deleted. 38 (JSC::PropertyNameArray::setPreviouslyEnumeratedLength): Deleted. 39 1 40 2015-05-09 Yoav Weiss <yoav@yoav.ws> 2 41 -
trunk/Source/JavaScriptCore/runtime/JSObject.cpp
r183615 r184050 1457 1457 void JSObject::getPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode) 1458 1458 { 1459 propertyNames.setBaseObject(object);1460 1459 object->methodTable(exec->vm())->getOwnPropertyNames(object, exec, propertyNames, mode); 1461 1460 -
trunk/Source/JavaScriptCore/runtime/JSPropertyNameEnumerator.cpp
r181891 r184050 48 48 uint32_t inlineCapacity = structure ? structure->inlineCapacity() : 0; 49 49 JSPropertyNameEnumerator* enumerator = new (NotNull, 50 allocateCell<JSPropertyNameEnumerator>(vm.heap)) JSPropertyNameEnumerator(vm, structureID, inlineCapacity , propertyNames.identifierSet());50 allocateCell<JSPropertyNameEnumerator>(vm.heap)) JSPropertyNameEnumerator(vm, structureID, inlineCapacity); 51 51 enumerator->finishCreation(vm, indexedLength, numberStructureProperties, propertyNames.data()); 52 52 return enumerator; 53 53 } 54 54 55 JSPropertyNameEnumerator::JSPropertyNameEnumerator(VM& vm, StructureID structureID, uint32_t inlineCapacity , RefCountedIdentifierSet* set)55 JSPropertyNameEnumerator::JSPropertyNameEnumerator(VM& vm, StructureID structureID, uint32_t inlineCapacity) 56 56 : JSCell(vm, vm.propertyNameEnumeratorStructure.get()) 57 , m_identifierSet(set)58 57 , m_cachedStructureID(structureID) 59 58 , m_cachedInlineCapacity(inlineCapacity) -
trunk/Source/JavaScriptCore/runtime/JSPropertyNameEnumerator.h
r182747 r184050 61 61 } 62 62 63 RefCountedIdentifierSet* identifierSet() const64 {65 return m_identifierSet.get();66 }67 68 63 StructureChain* cachedPrototypeChain() const { return m_prototypeChain.get(); } 69 64 void setCachedPrototypeChain(VM& vm, StructureChain* prototypeChain) { return m_prototypeChain.set(vm, this, prototypeChain); } … … 93 88 94 89 private: 95 JSPropertyNameEnumerator(VM&, StructureID, uint32_t , RefCountedIdentifierSet*);90 JSPropertyNameEnumerator(VM&, StructureID, uint32_t); 96 91 void finishCreation(VM&, uint32_t, uint32_t, PassRefPtr<PropertyNameArrayData>); 97 92 98 93 Vector<WriteBarrier<JSString>> m_propertyNames; 99 RefPtr<RefCountedIdentifierSet> m_identifierSet;100 94 StructureID m_cachedStructureID; 101 95 WriteBarrier<StructureChain> m_prototypeChain; -
trunk/Source/JavaScriptCore/runtime/PropertyNameArray.cpp
r182406 r184050 30 30 namespace JSC { 31 31 32 void PropertyNameArray::add( StringImpl* identifier)32 void PropertyNameArray::add(AtomicStringImpl* identifier) 33 33 { 34 ASSERT(!identifier || (identifier == StringImpl::empty() || identifier->isAtomic() || identifier->isSymbol())); 35 if (!ASSERT_DISABLED) { 36 Optional<uint32_t> index = parseIndex(Identifier::fromUid(m_vm, identifier)); 37 ASSERT_UNUSED(index, !index || index.value() >= m_previouslyEnumeratedLength); 38 } 34 ASSERT(identifier); 39 35 40 if (m_alternateSet && m_alternateSet->contains(identifier)) 41 return; 42 43 if (!m_set->add(identifier).isNewEntry) 36 if (!m_set.add(identifier).isNewEntry) 44 37 return; 45 38 … … 47 40 } 48 41 49 void PropertyNameArray::setPreviouslyEnumeratedProperties(const JSPropertyNameEnumerator* enumerator)50 {51 m_alternateSet = enumerator->identifierSet();52 }53 54 42 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/PropertyNameArray.h
r182205 r184050 31 31 class JSPropertyNameEnumerator; 32 32 class Structure; 33 class StructureChain;34 35 class RefCountedIdentifierSet : public RefCounted<RefCountedIdentifierSet> {36 public:37 typedef HashSet<StringImpl*, PtrHash<StringImpl*>> Set;38 39 bool contains(StringImpl* impl) const { return m_set.contains(impl); }40 size_t size() const { return m_set.size(); }41 Set::AddResult add(StringImpl* impl) { return m_set.add(impl); }42 43 private:44 Set m_set;45 };46 33 47 34 // FIXME: Rename to PropertyNameArray. … … 67 54 PropertyNameArray(VM* vm) 68 55 : m_data(PropertyNameArrayData::create()) 69 , m_set(adoptRef(new RefCountedIdentifierSet))70 56 , m_vm(vm) 71 , m_numCacheableSlots(0)72 , m_baseObject(0)73 , m_previouslyEnumeratedLength(0)74 57 { 75 58 } … … 77 60 PropertyNameArray(ExecState* exec) 78 61 : m_data(PropertyNameArrayData::create()) 79 , m_set(adoptRef(new RefCountedIdentifierSet))80 62 , m_vm(&exec->vm()) 81 , m_numCacheableSlots(0)82 , m_baseObject(0)83 , m_previouslyEnumeratedLength(0)84 63 { 85 64 } … … 89 68 void add(uint32_t index) 90 69 { 91 if (index < m_previouslyEnumeratedLength)92 return;93 70 add(Identifier::from(m_vm, index)); 94 71 } 95 72 96 73 void add(const Identifier& identifier) { add(identifier.impl()); } 97 JS_EXPORT_PRIVATE void add( StringImpl*);98 void addKnownUnique( StringImpl* identifier)74 JS_EXPORT_PRIVATE void add(AtomicStringImpl*); 75 void addKnownUnique(AtomicStringImpl* identifier) 99 76 { 100 m_set ->add(identifier);77 m_set.add(identifier); 101 78 m_data->propertyNameVector().append(Identifier::fromUid(m_vm, identifier)); 102 79 } … … 109 86 PassRefPtr<PropertyNameArrayData> releaseData() { return m_data.release(); } 110 87 111 RefCountedIdentifierSet* identifierSet() const { return m_set.get(); }112 113 88 // FIXME: Remove these functions. 114 bool canAddKnownUniqueForStructure() const { return !m_set->size() && (!m_alternateSet || !m_alternateSet->size()); }89 bool canAddKnownUniqueForStructure() const { return m_set.isEmpty(); } 115 90 typedef PropertyNameArrayData::PropertyNameVector::const_iterator const_iterator; 116 91 size_t size() const { return m_data->propertyNameVector().size(); } … … 118 93 const_iterator end() const { return m_data->propertyNameVector().end(); } 119 94 120 size_t numCacheableSlots() const { return m_numCacheableSlots; }121 void setNumCacheableSlotsForObject(JSObject* object, size_t numCacheableSlots)122 {123 if (object != m_baseObject)124 return;125 m_numCacheableSlots = numCacheableSlots;126 }127 void setBaseObject(JSObject* object)128 {129 if (m_baseObject)130 return;131 m_baseObject = object;132 }133 134 void setPreviouslyEnumeratedLength(uint32_t length) { m_previouslyEnumeratedLength = length; }135 void setPreviouslyEnumeratedProperties(const JSPropertyNameEnumerator*);136 137 95 private: 138 96 RefPtr<PropertyNameArrayData> m_data; 139 RefPtr<RefCountedIdentifierSet> m_set; 140 RefPtr<RefCountedIdentifierSet> m_alternateSet; 97 HashSet<AtomicStringImpl*, PtrHash<AtomicStringImpl*>> m_set; 141 98 VM* m_vm; 142 size_t m_numCacheableSlots;143 JSObject* m_baseObject;144 uint32_t m_previouslyEnumeratedLength;145 99 }; 146 100
Note:
See TracChangeset
for help on using the changeset viewer.