⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 184050 in webkit


Ignore:
Timestamp:
May 10, 2015, 1:03:57 PM (11 years ago)
Author:
akling@apple.com
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.

Location:
trunk/Source/JavaScriptCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r184040 r184050  
     12015-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
    1402015-05-09  Yoav Weiss  <yoav@yoav.ws>
    241
  • trunk/Source/JavaScriptCore/runtime/JSObject.cpp

    r183615 r184050  
    14571457void JSObject::getPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
    14581458{
    1459     propertyNames.setBaseObject(object);
    14601459    object->methodTable(exec->vm())->getOwnPropertyNames(object, exec, propertyNames, mode);
    14611460
  • trunk/Source/JavaScriptCore/runtime/JSPropertyNameEnumerator.cpp

    r181891 r184050  
    4848    uint32_t inlineCapacity = structure ? structure->inlineCapacity() : 0;
    4949    JSPropertyNameEnumerator* enumerator = new (NotNull,
    50         allocateCell<JSPropertyNameEnumerator>(vm.heap)) JSPropertyNameEnumerator(vm, structureID, inlineCapacity, propertyNames.identifierSet());
     50        allocateCell<JSPropertyNameEnumerator>(vm.heap)) JSPropertyNameEnumerator(vm, structureID, inlineCapacity);
    5151    enumerator->finishCreation(vm, indexedLength, numberStructureProperties, propertyNames.data());
    5252    return enumerator;
    5353}
    5454
    55 JSPropertyNameEnumerator::JSPropertyNameEnumerator(VM& vm, StructureID structureID, uint32_t inlineCapacity, RefCountedIdentifierSet* set)
     55JSPropertyNameEnumerator::JSPropertyNameEnumerator(VM& vm, StructureID structureID, uint32_t inlineCapacity)
    5656    : JSCell(vm, vm.propertyNameEnumeratorStructure.get())
    57     , m_identifierSet(set)
    5857    , m_cachedStructureID(structureID)
    5958    , m_cachedInlineCapacity(inlineCapacity)
  • trunk/Source/JavaScriptCore/runtime/JSPropertyNameEnumerator.h

    r182747 r184050  
    6161    }
    6262
    63     RefCountedIdentifierSet* identifierSet() const
    64     {
    65         return m_identifierSet.get();
    66     }
    67 
    6863    StructureChain* cachedPrototypeChain() const { return m_prototypeChain.get(); }
    6964    void setCachedPrototypeChain(VM& vm, StructureChain* prototypeChain) { return m_prototypeChain.set(vm, this, prototypeChain); }
     
    9388
    9489private:
    95     JSPropertyNameEnumerator(VM&, StructureID, uint32_t, RefCountedIdentifierSet*);
     90    JSPropertyNameEnumerator(VM&, StructureID, uint32_t);
    9691    void finishCreation(VM&, uint32_t, uint32_t, PassRefPtr<PropertyNameArrayData>);
    9792
    9893    Vector<WriteBarrier<JSString>> m_propertyNames;
    99     RefPtr<RefCountedIdentifierSet> m_identifierSet;
    10094    StructureID m_cachedStructureID;
    10195    WriteBarrier<StructureChain> m_prototypeChain;
  • trunk/Source/JavaScriptCore/runtime/PropertyNameArray.cpp

    r182406 r184050  
    3030namespace JSC {
    3131
    32 void PropertyNameArray::add(StringImpl* identifier)
     32void PropertyNameArray::add(AtomicStringImpl* identifier)
    3333{
    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);
    3935
    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)
    4437        return;
    4538
     
    4740}
    4841
    49 void PropertyNameArray::setPreviouslyEnumeratedProperties(const JSPropertyNameEnumerator* enumerator)
    50 {
    51     m_alternateSet = enumerator->identifierSet();
    52 }
    53 
    5442} // namespace JSC
  • trunk/Source/JavaScriptCore/runtime/PropertyNameArray.h

    r182205 r184050  
    3131class JSPropertyNameEnumerator;
    3232class 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 };
    4633
    4734// FIXME: Rename to PropertyNameArray.
     
    6754    PropertyNameArray(VM* vm)
    6855        : m_data(PropertyNameArrayData::create())
    69         , m_set(adoptRef(new RefCountedIdentifierSet))
    7056        , m_vm(vm)
    71         , m_numCacheableSlots(0)
    72         , m_baseObject(0)
    73         , m_previouslyEnumeratedLength(0)
    7457    {
    7558    }
     
    7760    PropertyNameArray(ExecState* exec)
    7861        : m_data(PropertyNameArrayData::create())
    79         , m_set(adoptRef(new RefCountedIdentifierSet))
    8062        , m_vm(&exec->vm())
    81         , m_numCacheableSlots(0)
    82         , m_baseObject(0)
    83         , m_previouslyEnumeratedLength(0)
    8463    {
    8564    }
     
    8968    void add(uint32_t index)
    9069    {
    91         if (index < m_previouslyEnumeratedLength)
    92             return;
    9370        add(Identifier::from(m_vm, index));
    9471    }
    9572
    9673    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)
    9976    {
    100         m_set->add(identifier);
     77        m_set.add(identifier);
    10178        m_data->propertyNameVector().append(Identifier::fromUid(m_vm, identifier));
    10279    }
     
    10986    PassRefPtr<PropertyNameArrayData> releaseData() { return m_data.release(); }
    11087
    111     RefCountedIdentifierSet* identifierSet() const { return m_set.get(); }
    112 
    11388    // 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(); }
    11590    typedef PropertyNameArrayData::PropertyNameVector::const_iterator const_iterator;
    11691    size_t size() const { return m_data->propertyNameVector().size(); }
     
    11893    const_iterator end() const { return m_data->propertyNameVector().end(); }
    11994
    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 
    13795private:
    13896    RefPtr<PropertyNameArrayData> m_data;
    139     RefPtr<RefCountedIdentifierSet> m_set;
    140     RefPtr<RefCountedIdentifierSet> m_alternateSet;
     97    HashSet<AtomicStringImpl*, PtrHash<AtomicStringImpl*>> m_set;
    14198    VM* m_vm;
    142     size_t m_numCacheableSlots;
    143     JSObject* m_baseObject;
    144     uint32_t m_previouslyEnumeratedLength;
    14599};
    146100
Note: See TracChangeset for help on using the changeset viewer.