Changeset 148142 in webkit


Ignore:
Timestamp:
Apr 10, 2013 3:25:36 PM (11 years ago)
Author:
mhahnenberg@apple.com
Message:

JSObject::getOwnNonIndexPropertyNames calculates numCacheableSlots incorrectly
https://bugs.webkit.org/show_bug.cgi?id=114235

Reviewed by Filip Pizlo.

If the object doesn't have any properties but the prototype does, we'll assume those prototype properties are
accessible in the base object's backing store, which is bad.

Source/JavaScriptCore:

  • runtime/JSObject.cpp:

(JSC::JSObject::getPropertyNames):
(JSC::JSObject::getOwnNonIndexPropertyNames):

  • runtime/PropertyNameArray.h:

(JSC::PropertyNameArray::PropertyNameArray):
(JSC::PropertyNameArray::setNumCacheableSlotsForObject):
(JSC::PropertyNameArray::setBaseObject):
(PropertyNameArray):

LayoutTests:

  • fast/js/get-by-pname-only-prototype-properties-expected.txt: Added.
  • fast/js/get-by-pname-only-prototype-properties.html: Added.
  • fast/js/script-tests/get-by-pname-only-prototype-properties.js: Added.

(foo):

Location:
trunk
Files:
3 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r148139 r148142  
     12013-04-10  Mark Hahnenberg  <mhahnenberg@apple.com>
     2
     3        JSObject::getOwnNonIndexPropertyNames calculates numCacheableSlots incorrectly
     4        https://bugs.webkit.org/show_bug.cgi?id=114235
     5
     6        Reviewed by Filip Pizlo.
     7
     8        If the object doesn't have any properties but the prototype does, we'll assume those prototype properties are
     9        accessible in the base object's backing store, which is bad.
     10
     11        * fast/js/get-by-pname-only-prototype-properties-expected.txt: Added.
     12        * fast/js/get-by-pname-only-prototype-properties.html: Added.
     13        * fast/js/script-tests/get-by-pname-only-prototype-properties.js: Added.
     14        (foo):
     15
    1162013-04-10  Hans Muller  <hmuller@adobe.com>
    217
  • trunk/Source/JavaScriptCore/ChangeLog

    r148134 r148142  
     12013-04-10  Mark Hahnenberg  <mhahnenberg@apple.com>
     2
     3        JSObject::getOwnNonIndexPropertyNames calculates numCacheableSlots incorrectly
     4        https://bugs.webkit.org/show_bug.cgi?id=114235
     5
     6        Reviewed by Filip Pizlo.
     7
     8        If the object doesn't have any properties but the prototype does, we'll assume those prototype properties are
     9        accessible in the base object's backing store, which is bad.
     10
     11        * runtime/JSObject.cpp:
     12        (JSC::JSObject::getPropertyNames):
     13        (JSC::JSObject::getOwnNonIndexPropertyNames):
     14        * runtime/PropertyNameArray.h:
     15        (JSC::PropertyNameArray::PropertyNameArray):
     16        (JSC::PropertyNameArray::setNumCacheableSlotsForObject):
     17        (JSC::PropertyNameArray::setBaseObject):
     18        (PropertyNameArray):
     19
    1202013-04-10  Patrick Gansterer  <paroga@webkit.org>
    221
  • trunk/Source/JavaScriptCore/runtime/JSObject.cpp

    r148036 r148142  
    14431443void JSObject::getPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
    14441444{
     1445    propertyNames.setBaseObject(object);
    14451446    object->methodTable()->getOwnPropertyNames(object, exec, propertyNames, mode);
    14461447
     
    15381539
    15391540    if (canCachePropertiesFromStructure)
    1540         propertyNames.setNumCacheableSlots(propertyNames.size());
     1541        propertyNames.setNumCacheableSlotsForObject(object, propertyNames.size());
    15411542}
    15421543
  • trunk/Source/JavaScriptCore/runtime/PropertyNameArray.h

    r147570 r148142  
    5757            , m_globalData(globalData)
    5858            , m_numCacheableSlots(0)
     59            , m_baseObject(0)
    5960        {
    6061        }
     
    6465            , m_globalData(&exec->globalData())
    6566            , m_numCacheableSlots(0)
     67            , m_baseObject(0)
    6668        {
    6769        }
     
    8789
    8890        size_t numCacheableSlots() const { return m_numCacheableSlots; }
    89         void setNumCacheableSlots(size_t numCacheableSlots) { m_numCacheableSlots = numCacheableSlots; }
     91        void setNumCacheableSlotsForObject(JSObject* object, size_t numCacheableSlots)
     92        {
     93            if (object != m_baseObject)
     94                return;
     95            m_numCacheableSlots = numCacheableSlots;
     96        }
     97        void setBaseObject(JSObject* object)
     98        {
     99            if (m_baseObject)
     100                return;
     101            m_baseObject = object;
     102        }
    90103
    91104    private:
     
    96109        JSGlobalData* m_globalData;
    97110        size_t m_numCacheableSlots;
     111        JSObject* m_baseObject;
    98112    };
    99113
Note: See TracChangeset for help on using the changeset viewer.