Title: [184050] trunk/Source/_javascript_Core
Revision
184050
Author
[email protected]
Date
2015-05-10 13:03:57 -0700 (Sun, 10 May 2015)

Log Message

Remove unused things from PropertyNameArray.
<https://webkit.org/b/144834>

Reviewed by Filip Pizlo.

PropertyNameArray had a bunch of bells and whistles added to it when for-in iteration
was refactored and optimized last year. Then more refactoring happened and this class
doesn't need to ring and toot anymore.

The RefCountedIdentifierSet class disappears since the JSPropertyNameEnumerator wasn't
actually using it for anything and we were just wasting time creating these.

Also made the member functions take AtomicStringImpl* instead of plain StringImpl*.

* runtime/JSObject.cpp:
(JSC::JSObject::getPropertyNames):
* runtime/JSPropertyNameEnumerator.cpp:
(JSC::JSPropertyNameEnumerator::create):
(JSC::JSPropertyNameEnumerator::JSPropertyNameEnumerator):
* runtime/JSPropertyNameEnumerator.h:
* runtime/PropertyNameArray.cpp:
(JSC::PropertyNameArray::add):
(JSC::PropertyNameArray::setPreviouslyEnumeratedProperties): Deleted.
* runtime/PropertyNameArray.h:
(JSC::PropertyNameArray::PropertyNameArray):
(JSC::PropertyNameArray::add):
(JSC::PropertyNameArray::addKnownUnique):
(JSC::PropertyNameArray::canAddKnownUniqueForStructure):
(JSC::RefCountedIdentifierSet::contains): Deleted.
(JSC::RefCountedIdentifierSet::size): Deleted.
(JSC::RefCountedIdentifierSet::add): Deleted.
(JSC::PropertyNameArray::identifierSet): Deleted.
(JSC::PropertyNameArray::numCacheableSlots): Deleted.
(JSC::PropertyNameArray::setNumCacheableSlotsForObject): Deleted.
(JSC::PropertyNameArray::setBaseObject): Deleted.
(JSC::PropertyNameArray::setPreviouslyEnumeratedLength): Deleted.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (184049 => 184050)


--- trunk/Source/_javascript_Core/ChangeLog	2015-05-10 19:28:08 UTC (rev 184049)
+++ trunk/Source/_javascript_Core/ChangeLog	2015-05-10 20:03:57 UTC (rev 184050)
@@ -1,3 +1,42 @@
+2015-05-10  Andreas Kling  <[email protected]>
+
+        Remove unused things from PropertyNameArray.
+        <https://webkit.org/b/144834>
+
+        Reviewed by Filip Pizlo.
+
+        PropertyNameArray had a bunch of bells and whistles added to it when for-in iteration
+        was refactored and optimized last year. Then more refactoring happened and this class
+        doesn't need to ring and toot anymore.
+
+        The RefCountedIdentifierSet class disappears since the JSPropertyNameEnumerator wasn't
+        actually using it for anything and we were just wasting time creating these.
+
+        Also made the member functions take AtomicStringImpl* instead of plain StringImpl*.
+
+        * runtime/JSObject.cpp:
+        (JSC::JSObject::getPropertyNames):
+        * runtime/JSPropertyNameEnumerator.cpp:
+        (JSC::JSPropertyNameEnumerator::create):
+        (JSC::JSPropertyNameEnumerator::JSPropertyNameEnumerator):
+        * runtime/JSPropertyNameEnumerator.h:
+        * runtime/PropertyNameArray.cpp:
+        (JSC::PropertyNameArray::add):
+        (JSC::PropertyNameArray::setPreviouslyEnumeratedProperties): Deleted.
+        * runtime/PropertyNameArray.h:
+        (JSC::PropertyNameArray::PropertyNameArray):
+        (JSC::PropertyNameArray::add):
+        (JSC::PropertyNameArray::addKnownUnique):
+        (JSC::PropertyNameArray::canAddKnownUniqueForStructure):
+        (JSC::RefCountedIdentifierSet::contains): Deleted.
+        (JSC::RefCountedIdentifierSet::size): Deleted.
+        (JSC::RefCountedIdentifierSet::add): Deleted.
+        (JSC::PropertyNameArray::identifierSet): Deleted.
+        (JSC::PropertyNameArray::numCacheableSlots): Deleted.
+        (JSC::PropertyNameArray::setNumCacheableSlotsForObject): Deleted.
+        (JSC::PropertyNameArray::setBaseObject): Deleted.
+        (JSC::PropertyNameArray::setPreviouslyEnumeratedLength): Deleted.
+
 2015-05-09  Yoav Weiss  <[email protected]>
 
         Remove the PICTURE_SIZES build flag

Modified: trunk/Source/_javascript_Core/runtime/JSObject.cpp (184049 => 184050)


--- trunk/Source/_javascript_Core/runtime/JSObject.cpp	2015-05-10 19:28:08 UTC (rev 184049)
+++ trunk/Source/_javascript_Core/runtime/JSObject.cpp	2015-05-10 20:03:57 UTC (rev 184050)
@@ -1456,7 +1456,6 @@
 
 void JSObject::getPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
 {
-    propertyNames.setBaseObject(object);
     object->methodTable(exec->vm())->getOwnPropertyNames(object, exec, propertyNames, mode);
 
     if (object->prototype().isNull())

Modified: trunk/Source/_javascript_Core/runtime/JSPropertyNameEnumerator.cpp (184049 => 184050)


--- trunk/Source/_javascript_Core/runtime/JSPropertyNameEnumerator.cpp	2015-05-10 19:28:08 UTC (rev 184049)
+++ trunk/Source/_javascript_Core/runtime/JSPropertyNameEnumerator.cpp	2015-05-10 20:03:57 UTC (rev 184050)
@@ -47,14 +47,13 @@
     StructureID structureID = structure ? structure->id() : 0;
     uint32_t inlineCapacity = structure ? structure->inlineCapacity() : 0;
     JSPropertyNameEnumerator* enumerator = new (NotNull, 
-        allocateCell<JSPropertyNameEnumerator>(vm.heap)) JSPropertyNameEnumerator(vm, structureID, inlineCapacity, propertyNames.identifierSet());
+        allocateCell<JSPropertyNameEnumerator>(vm.heap)) JSPropertyNameEnumerator(vm, structureID, inlineCapacity);
     enumerator->finishCreation(vm, indexedLength, numberStructureProperties, propertyNames.data());
     return enumerator;
 }
 
-JSPropertyNameEnumerator::JSPropertyNameEnumerator(VM& vm, StructureID structureID, uint32_t inlineCapacity, RefCountedIdentifierSet* set)
+JSPropertyNameEnumerator::JSPropertyNameEnumerator(VM& vm, StructureID structureID, uint32_t inlineCapacity)
     : JSCell(vm, vm.propertyNameEnumeratorStructure.get())
-    , m_identifierSet(set)
     , m_cachedStructureID(structureID)
     , m_cachedInlineCapacity(inlineCapacity)
 {

Modified: trunk/Source/_javascript_Core/runtime/JSPropertyNameEnumerator.h (184049 => 184050)


--- trunk/Source/_javascript_Core/runtime/JSPropertyNameEnumerator.h	2015-05-10 19:28:08 UTC (rev 184049)
+++ trunk/Source/_javascript_Core/runtime/JSPropertyNameEnumerator.h	2015-05-10 20:03:57 UTC (rev 184050)
@@ -60,11 +60,6 @@
         return m_propertyNames[index].get();
     }
 
-    RefCountedIdentifierSet* identifierSet() const
-    {
-        return m_identifierSet.get();
-    }
-
     StructureChain* cachedPrototypeChain() const { return m_prototypeChain.get(); }
     void setCachedPrototypeChain(VM& vm, StructureChain* prototypeChain) { return m_prototypeChain.set(vm, this, prototypeChain); }
 
@@ -92,11 +87,10 @@
     static void visitChildren(JSCell*, SlotVisitor&);
 
 private:
-    JSPropertyNameEnumerator(VM&, StructureID, uint32_t, RefCountedIdentifierSet*);
+    JSPropertyNameEnumerator(VM&, StructureID, uint32_t);
     void finishCreation(VM&, uint32_t, uint32_t, PassRefPtr<PropertyNameArrayData>);
 
     Vector<WriteBarrier<JSString>> m_propertyNames;
-    RefPtr<RefCountedIdentifierSet> m_identifierSet;
     StructureID m_cachedStructureID;
     WriteBarrier<StructureChain> m_prototypeChain;
     uint32_t m_indexedLength;

Modified: trunk/Source/_javascript_Core/runtime/PropertyNameArray.cpp (184049 => 184050)


--- trunk/Source/_javascript_Core/runtime/PropertyNameArray.cpp	2015-05-10 19:28:08 UTC (rev 184049)
+++ trunk/Source/_javascript_Core/runtime/PropertyNameArray.cpp	2015-05-10 20:03:57 UTC (rev 184050)
@@ -29,26 +29,14 @@
 
 namespace JSC {
 
-void PropertyNameArray::add(StringImpl* identifier)
+void PropertyNameArray::add(AtomicStringImpl* identifier)
 {
-    ASSERT(!identifier || (identifier == StringImpl::empty() || identifier->isAtomic() || identifier->isSymbol()));
-    if (!ASSERT_DISABLED) {
-        Optional<uint32_t> index = parseIndex(Identifier::fromUid(m_vm, identifier));
-        ASSERT_UNUSED(index, !index || index.value() >= m_previouslyEnumeratedLength);
-    }
+    ASSERT(identifier);
 
-    if (m_alternateSet && m_alternateSet->contains(identifier))
+    if (!m_set.add(identifier).isNewEntry)
         return;
 
-    if (!m_set->add(identifier).isNewEntry)
-        return;
-
     addKnownUnique(identifier);
 }
 
-void PropertyNameArray::setPreviouslyEnumeratedProperties(const JSPropertyNameEnumerator* enumerator)
-{
-    m_alternateSet = enumerator->identifierSet();
-}
-
 } // namespace JSC

Modified: trunk/Source/_javascript_Core/runtime/PropertyNameArray.h (184049 => 184050)


--- trunk/Source/_javascript_Core/runtime/PropertyNameArray.h	2015-05-10 19:28:08 UTC (rev 184049)
+++ trunk/Source/_javascript_Core/runtime/PropertyNameArray.h	2015-05-10 20:03:57 UTC (rev 184050)
@@ -30,20 +30,7 @@
 
 class JSPropertyNameEnumerator;
 class Structure;
-class StructureChain;
 
-class RefCountedIdentifierSet : public RefCounted<RefCountedIdentifierSet> {
-public:
-    typedef HashSet<StringImpl*, PtrHash<StringImpl*>> Set;
-
-    bool contains(StringImpl* impl) const { return m_set.contains(impl); }
-    size_t size() const  { return m_set.size(); }
-    Set::AddResult add(StringImpl* impl) { return m_set.add(impl); }
-
-private:
-    Set m_set;
-};
-
 // FIXME: Rename to PropertyNameArray.
 class PropertyNameArrayData : public RefCounted<PropertyNameArrayData> {
 public:
@@ -66,21 +53,13 @@
 public:
     PropertyNameArray(VM* vm)
         : m_data(PropertyNameArrayData::create())
-        , m_set(adoptRef(new RefCountedIdentifierSet))
         , m_vm(vm)
-        , m_numCacheableSlots(0)
-        , m_baseObject(0)
-        , m_previouslyEnumeratedLength(0)
     {
     }
 
     PropertyNameArray(ExecState* exec)
         : m_data(PropertyNameArrayData::create())
-        , m_set(adoptRef(new RefCountedIdentifierSet))
         , m_vm(&exec->vm())
-        , m_numCacheableSlots(0)
-        , m_baseObject(0)
-        , m_previouslyEnumeratedLength(0)
     {
     }
 
@@ -88,16 +67,14 @@
 
     void add(uint32_t index)
     {
-        if (index < m_previouslyEnumeratedLength)
-            return;
         add(Identifier::from(m_vm, index));
     }
 
     void add(const Identifier& identifier) { add(identifier.impl()); }
-    JS_EXPORT_PRIVATE void add(StringImpl*);
-    void addKnownUnique(StringImpl* identifier)
+    JS_EXPORT_PRIVATE void add(AtomicStringImpl*);
+    void addKnownUnique(AtomicStringImpl* identifier)
     {
-        m_set->add(identifier);
+        m_set.add(identifier);
         m_data->propertyNameVector().append(Identifier::fromUid(m_vm, identifier));
     }
 
@@ -108,40 +85,17 @@
     PropertyNameArrayData* data() { return m_data.get(); }
     PassRefPtr<PropertyNameArrayData> releaseData() { return m_data.release(); }
 
-    RefCountedIdentifierSet* identifierSet() const { return m_set.get(); }
-
     // FIXME: Remove these functions.
-    bool canAddKnownUniqueForStructure() const { return !m_set->size() && (!m_alternateSet || !m_alternateSet->size()); }
+    bool canAddKnownUniqueForStructure() const { return m_set.isEmpty(); }
     typedef PropertyNameArrayData::PropertyNameVector::const_iterator const_iterator;
     size_t size() const { return m_data->propertyNameVector().size(); }
     const_iterator begin() const { return m_data->propertyNameVector().begin(); }
     const_iterator end() const { return m_data->propertyNameVector().end(); }
 
-    size_t numCacheableSlots() const { return m_numCacheableSlots; }
-    void setNumCacheableSlotsForObject(JSObject* object, size_t numCacheableSlots)
-    {
-        if (object != m_baseObject)
-            return;
-        m_numCacheableSlots = numCacheableSlots;
-    }
-    void setBaseObject(JSObject* object)
-    {
-        if (m_baseObject)
-            return;
-        m_baseObject = object;
-    }
-
-    void setPreviouslyEnumeratedLength(uint32_t length) { m_previouslyEnumeratedLength = length; }
-    void setPreviouslyEnumeratedProperties(const JSPropertyNameEnumerator*);
-
 private:
     RefPtr<PropertyNameArrayData> m_data;
-    RefPtr<RefCountedIdentifierSet> m_set;
-    RefPtr<RefCountedIdentifierSet> m_alternateSet;
+    HashSet<AtomicStringImpl*, PtrHash<AtomicStringImpl*>> m_set;
     VM* m_vm;
-    size_t m_numCacheableSlots;
-    JSObject* m_baseObject;
-    uint32_t m_previouslyEnumeratedLength;
 };
 
 } // namespace JSC
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to