Changeset 126139 in webkit


Ignore:
Timestamp:
Aug 21, 2012 12:17:53 AM (12 years ago)
Author:
loislo@chromium.org
Message:

Web Inspector: NMI: wrong size was reported for immutable StylePropertySet
https://bugs.webkit.org/show_bug.cgi?id=94489

Reviewed by Yury Semikhatsky.

Immutable StylePropertySet is created via placement new.
The rest of the allocated buffer is used as an array of CSSProperty.
This means that we don't need to report m_properties member but have to report actual size of the buffer
used for both, the object and CSSProperty array.

  • css/StylePropertySet.cpp:

(WebCore::immutableStylePropertySetSize):
(WebCore):
(WebCore::StylePropertySet::createImmutable):
(WebCore::StylePropertySet::reportMemoryUsage):

  • dom/MemoryInstrumentation.h:

(WebCore::MemoryObjectInfo::reportObjectInfo):
(WebCore::MemoryClassInfo::MemoryClassInfo):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r126137 r126139  
     12012-08-20  Ilya Tikhonovsky  <loislo@chromium.org>
     2
     3        Web Inspector: NMI: wrong size was reported for immutable StylePropertySet
     4        https://bugs.webkit.org/show_bug.cgi?id=94489
     5
     6        Reviewed by Yury Semikhatsky.
     7
     8        Immutable StylePropertySet is created via placement new.
     9        The rest of the allocated buffer is used as an array of CSSProperty.
     10        This means that we don't need to report m_properties member but have to report actual size of the buffer
     11        used for both, the object and CSSProperty array.
     12
     13        * css/StylePropertySet.cpp:
     14        (WebCore::immutableStylePropertySetSize):
     15        (WebCore):
     16        (WebCore::StylePropertySet::createImmutable):
     17        (WebCore::StylePropertySet::reportMemoryUsage):
     18        * dom/MemoryInstrumentation.h:
     19        (WebCore::MemoryObjectInfo::reportObjectInfo):
     20        (WebCore::MemoryClassInfo::MemoryClassInfo):
     21
    1222012-08-20  Kentaro Hara  <haraken@chromium.org>
    223
  • trunk/Source/WebCore/css/StylePropertySet.cpp

    r124884 r126139  
    5151}
    5252
     53static size_t immutableStylePropertySetSize(unsigned count)
     54{
     55    return sizeof(StylePropertySet) - sizeof(void*) + sizeof(CSSProperty) * count;
     56}
     57
    5358PassRefPtr<StylePropertySet> StylePropertySet::createImmutable(const CSSProperty* properties, unsigned count, CSSParserMode cssParserMode)
    5459{
    55     void* slot = WTF::fastMalloc(sizeof(StylePropertySet) - sizeof(void*) + sizeof(CSSProperty) * count);
     60    void* slot = WTF::fastMalloc(immutableStylePropertySetSize(count));
    5661    return adoptRef(new (slot) StylePropertySet(properties, count, cssParserMode, /* makeMutable */ false));
    5762}
     
    10921097void StylePropertySet::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
    10931098{
    1094     MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
     1099    size_t actualSize = m_isMutable ? sizeof(StylePropertySet) : immutableStylePropertySetSize(m_arraySize);
     1100    MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS, actualSize);
    10951101    if (m_isMutable)
    10961102        info.addVectorPtr(m_mutablePropertyVector);
    1097     else
    1098         info.addRawBuffer(m_properties, m_arraySize * sizeof(CSSProperty));
     1103
    10991104    unsigned count = propertyCount();
    11001105    for (unsigned i = 0; i < count; ++i)
  • trunk/Source/WebCore/dom/MemoryInstrumentation.h

    r125763 r126139  
    169169    friend class MemoryClassInfo;
    170170
    171     template <typename T> void reportObjectInfo(MemoryInstrumentation::ObjectType objectType)
     171    template <typename T> void reportObjectInfo(MemoryInstrumentation::ObjectType objectType, size_t actualSize)
    172172    {
    173173        if (!m_objectSize) {
    174             m_objectSize = sizeof(T);
     174            m_objectSize = actualSize ? actualSize : sizeof(T);
    175175            if (objectType != MemoryInstrumentation::Other)
    176176                m_objectType = objectType;
     
    186186public:
    187187    template <typename T>
    188     MemoryClassInfo(MemoryObjectInfo* memoryObjectInfo, const T*, MemoryInstrumentation::ObjectType objectType)
     188    MemoryClassInfo(MemoryObjectInfo* memoryObjectInfo, const T*, MemoryInstrumentation::ObjectType objectType, size_t actualSize = 0)
    189189        : m_memoryObjectInfo(memoryObjectInfo)
    190190        , m_memoryInstrumentation(memoryObjectInfo->memoryInstrumentation())
    191191    {
    192         m_memoryObjectInfo->reportObjectInfo<T>(objectType);
     192        m_memoryObjectInfo->reportObjectInfo<T>(objectType, actualSize);
    193193        m_objectType = memoryObjectInfo->objectType();
    194194    }
Note: See TracChangeset for help on using the changeset viewer.