Changeset 133160 in webkit


Ignore:
Timestamp:
Nov 1, 2012 7:10:37 AM (11 years ago)
Author:
rakuco@webkit.org
Message:

Fix StylePropertySet/ElementAttributeData custom allocation in debug builds.
<http://webkit.org/b/100753>

Unreviewed debug bot crash fix after r133138.

There's additional padding after StylePropertySet and ElementAttributeData
in 64-bit debug builds since there are additional members in RefCountedBase.
Use 'sizeof(ImmutableFoo) - sizeof(void*)' as the base size of ImmutableFoo.

Patch by Andreas Kling <kling@webkit.org> on 2012-11-01

  • css/StylePropertySet.cpp:

(WebCore::sizeForImmutableStylePropertySetWithPropertyCount):

  • dom/ElementAttributeData.cpp:

(WebCore::sizeForImmutableElementAttributeDataWithAttributeCount):
(WebCore::ElementAttributeData::createImmutable):
(WebCore::ElementAttributeData::reportMemoryUsage):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r133158 r133160  
     12012-11-01  Andreas Kling  <kling@webkit.org>
     2
     3        Fix StylePropertySet/ElementAttributeData custom allocation in debug builds.
     4        <http://webkit.org/b/100753>
     5
     6        Unreviewed debug bot crash fix after r133138.
     7
     8        There's additional padding after StylePropertySet and ElementAttributeData
     9        in 64-bit debug builds since there are additional members in RefCountedBase.
     10        Use 'sizeof(ImmutableFoo) - sizeof(void*)' as the base size of ImmutableFoo.
     11
     12        * css/StylePropertySet.cpp:
     13        (WebCore::sizeForImmutableStylePropertySetWithPropertyCount):
     14        * dom/ElementAttributeData.cpp:
     15        (WebCore::sizeForImmutableElementAttributeDataWithAttributeCount):
     16        (WebCore::ElementAttributeData::createImmutable):
     17        (WebCore::ElementAttributeData::reportMemoryUsage):
     18
    1192012-11-01  Stephen Chenney  <schenney@chromium.org>
    220
  • trunk/Source/WebCore/css/StylePropertySet.cpp

    r133148 r133160  
    5858static size_t sizeForImmutableStylePropertySetWithPropertyCount(unsigned count)
    5959{
    60     return sizeof(StylePropertySet) + sizeof(CSSValue*) * count + sizeof(StylePropertyMetadata) * count;
     60    return sizeof(ImmutableStylePropertySet) - sizeof(void*) + sizeof(CSSValue*) * count + sizeof(StylePropertyMetadata) * count;
    6161}
    6262
  • trunk/Source/WebCore/dom/ElementAttributeData.cpp

    r132288 r133160  
    3636namespace WebCore {
    3737
    38 static size_t immutableElementAttributeDataSize(unsigned count)
    39 {
    40     return sizeof(ElementAttributeData) + sizeof(Attribute) * count;
     38static size_t sizeForImmutableElementAttributeDataWithAttributeCount(unsigned count)
     39{
     40    return sizeof(ImmutableElementAttributeData) - sizeof(void*) + sizeof(Attribute) * count;
    4141}
    4242
    4343PassRefPtr<ElementAttributeData> ElementAttributeData::createImmutable(const Vector<Attribute>& attributes)
    4444{
    45     void* slot = WTF::fastMalloc(immutableElementAttributeDataSize(attributes.size()));
     45    void* slot = WTF::fastMalloc(sizeForImmutableElementAttributeDataWithAttributeCount(attributes.size()));
    4646    return adoptRef(new (slot) ImmutableElementAttributeData(attributes));
    4747}
     
    275275void ElementAttributeData::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
    276276{
    277     size_t actualSize = m_isMutable ? sizeof(ElementAttributeData) : immutableElementAttributeDataSize(m_arraySize);
     277    size_t actualSize = m_isMutable ? sizeof(ElementAttributeData) : sizeForImmutableElementAttributeDataWithAttributeCount(m_arraySize);
    278278    MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM, actualSize);
    279279    info.addMember(m_inlineStyleDecl);
Note: See TracChangeset for help on using the changeset viewer.