Changeset 147570 in webkit


Ignore:
Timestamp:
Apr 3, 2013 11:38:33 AM (11 years ago)
Author:
mhahnenberg@apple.com
Message:

get_by_pname can become confused when iterating over objects with static properties
https://bugs.webkit.org/show_bug.cgi?id=113831

Reviewed by Geoffrey Garen.

get_by_pname doesn't take static properties into account when using a JSPropertyNameIterator to directly
access an object's backing store. One way to fix this is to not cache any properties when iterating over
objects with static properties. This patch fixes the bug that was originally reported on swisscom.ch.

Source/JavaScriptCore:

  • runtime/JSObject.cpp:

(JSC::JSObject::getOwnNonIndexPropertyNames):

  • runtime/JSPropertyNameIterator.cpp:

(JSC::JSPropertyNameIterator::create):

  • runtime/PropertyNameArray.h:

(JSC::PropertyNameArray::PropertyNameArray):
(JSC::PropertyNameArray::numCacheableSlots):
(JSC::PropertyNameArray::setNumCacheableSlots):
(PropertyNameArray):

LayoutTests:

  • fast/js/dom-static-property-for-in-iteration-expected.txt: Added.
  • fast/js/dom-static-property-for-in-iteration.html: Added.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r147558 r147570  
     12013-04-02  Mark Hahnenberg  <mhahnenberg@apple.com>
     2
     3        get_by_pname can become confused when iterating over objects with static properties
     4        https://bugs.webkit.org/show_bug.cgi?id=113831
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        get_by_pname doesn't take static properties into account when using a JSPropertyNameIterator to directly
     9        access an object's backing store. One way to fix this is to not cache any properties when iterating over
     10        objects with static properties. This patch fixes the bug that was originally reported on swisscom.ch.
     11
     12        * fast/js/dom-static-property-for-in-iteration-expected.txt: Added.
     13        * fast/js/dom-static-property-for-in-iteration.html: Added.
     14
    1152013-04-03  Felipe Zimmerle  <felipe@zimmerle.org>
    216
  • trunk/Source/JavaScriptCore/ChangeLog

    r147514 r147570  
     12013-04-02  Mark Hahnenberg  <mhahnenberg@apple.com>
     2
     3        get_by_pname can become confused when iterating over objects with static properties
     4        https://bugs.webkit.org/show_bug.cgi?id=113831
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        get_by_pname doesn't take static properties into account when using a JSPropertyNameIterator to directly
     9        access an object's backing store. One way to fix this is to not cache any properties when iterating over
     10        objects with static properties. This patch fixes the bug that was originally reported on swisscom.ch.
     11
     12        * runtime/JSObject.cpp:
     13        (JSC::JSObject::getOwnNonIndexPropertyNames):
     14        * runtime/JSPropertyNameIterator.cpp:
     15        (JSC::JSPropertyNameIterator::create):
     16        * runtime/PropertyNameArray.h:
     17        (JSC::PropertyNameArray::PropertyNameArray):
     18        (JSC::PropertyNameArray::numCacheableSlots):
     19        (JSC::PropertyNameArray::setNumCacheableSlots):
     20        (PropertyNameArray):
     21
    1222013-04-02  Geoffrey Garen  <ggaren@apple.com>
    223
  • trunk/Source/JavaScriptCore/runtime/JSObject.cpp

    r146829 r147570  
    15331533{
    15341534    getClassPropertyNames(exec, object->classInfo(), propertyNames, mode, object->staticFunctionsReified());
     1535    size_t preStructurePropertyNamesCount = propertyNames.size();
    15351536    object->structure()->getPropertyNamesFromStructure(exec->globalData(), propertyNames, mode);
     1537    size_t numCacheableSlots = preStructurePropertyNamesCount ? 0 : propertyNames.size();
     1538    propertyNames.setNumCacheableSlots(numCacheableSlots);
    15361539}
    15371540
  • trunk/Source/JavaScriptCore/runtime/JSPropertyNameIterator.cpp

    r131088 r147570  
    5555    if (!o->structure()->hasNonEnumerableProperties() && !o->structure()->hasGetterSetterProperties()
    5656        && !o->structure()->isUncacheableDictionary() && !o->structure()->typeInfo().overridesGetPropertyNames())
    57         numCacheableSlots = o->structure()->totalStorageSize();
     57        numCacheableSlots = propertyNames.numCacheableSlots();
    5858   
    5959    JSPropertyNameIterator* jsPropertyNameIterator = new (NotNull, allocateCell<JSPropertyNameIterator>(*exec->heap())) JSPropertyNameIterator(exec, propertyNames.data(), numCacheableSlots);
  • trunk/Source/JavaScriptCore/runtime/PropertyNameArray.h

    r123989 r147570  
    5656            : m_data(PropertyNameArrayData::create())
    5757            , m_globalData(globalData)
     58            , m_numCacheableSlots(0)
    5859        {
    5960        }
     
    6263            : m_data(PropertyNameArrayData::create())
    6364            , m_globalData(&exec->globalData())
     65            , m_numCacheableSlots(0)
    6466        {
    6567        }
     
    8486        const_iterator end() const { return m_data->propertyNameVector().end(); }
    8587
     88        size_t numCacheableSlots() const { return m_numCacheableSlots; }
     89        void setNumCacheableSlots(size_t numCacheableSlots) { m_numCacheableSlots = numCacheableSlots; }
     90
    8691    private:
    8792        typedef HashSet<StringImpl*, PtrHash<StringImpl*> > IdentifierSet;
     
    9095        IdentifierSet m_set;
    9196        JSGlobalData* m_globalData;
     97        size_t m_numCacheableSlots;
    9298    };
    9399
Note: See TracChangeset for help on using the changeset viewer.