Title: [133160] trunk/Source/WebCore
Revision
133160
Author
rak...@webkit.org
Date
2012-11-01 07:10:37 -0700 (Thu, 01 Nov 2012)

Log 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 <kl...@webkit.org> on 2012-11-01

* css/StylePropertySet.cpp:
(WebCore::sizeForImmutableStylePropertySetWithPropertyCount):
* dom/ElementAttributeData.cpp:
(WebCore::sizeForImmutableElementAttributeDataWithAttributeCount):
(WebCore::ElementAttributeData::createImmutable):
(WebCore::ElementAttributeData::reportMemoryUsage):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (133159 => 133160)


--- trunk/Source/WebCore/ChangeLog	2012-11-01 14:05:34 UTC (rev 133159)
+++ trunk/Source/WebCore/ChangeLog	2012-11-01 14:10:37 UTC (rev 133160)
@@ -1,3 +1,21 @@
+2012-11-01  Andreas Kling  <kl...@webkit.org>
+
+        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.
+
+        * css/StylePropertySet.cpp:
+        (WebCore::sizeForImmutableStylePropertySetWithPropertyCount):
+        * dom/ElementAttributeData.cpp:
+        (WebCore::sizeForImmutableElementAttributeDataWithAttributeCount):
+        (WebCore::ElementAttributeData::createImmutable):
+        (WebCore::ElementAttributeData::reportMemoryUsage):
+
 2012-11-01  Stephen Chenney  <schen...@chromium.org>
 
         FEImage::m_document is never cleared. Why not?

Modified: trunk/Source/WebCore/css/StylePropertySet.cpp (133159 => 133160)


--- trunk/Source/WebCore/css/StylePropertySet.cpp	2012-11-01 14:05:34 UTC (rev 133159)
+++ trunk/Source/WebCore/css/StylePropertySet.cpp	2012-11-01 14:10:37 UTC (rev 133160)
@@ -57,7 +57,7 @@
 
 static size_t sizeForImmutableStylePropertySetWithPropertyCount(unsigned count)
 {
-    return sizeof(StylePropertySet) + sizeof(CSSValue*) * count + sizeof(StylePropertyMetadata) * count;
+    return sizeof(ImmutableStylePropertySet) - sizeof(void*) + sizeof(CSSValue*) * count + sizeof(StylePropertyMetadata) * count;
 }
 
 PassRefPtr<StylePropertySet> StylePropertySet::createImmutable(const CSSProperty* properties, unsigned count, CSSParserMode cssParserMode)

Modified: trunk/Source/WebCore/dom/ElementAttributeData.cpp (133159 => 133160)


--- trunk/Source/WebCore/dom/ElementAttributeData.cpp	2012-11-01 14:05:34 UTC (rev 133159)
+++ trunk/Source/WebCore/dom/ElementAttributeData.cpp	2012-11-01 14:10:37 UTC (rev 133160)
@@ -35,14 +35,14 @@
 
 namespace WebCore {
 
-static size_t immutableElementAttributeDataSize(unsigned count)
+static size_t sizeForImmutableElementAttributeDataWithAttributeCount(unsigned count)
 {
-    return sizeof(ElementAttributeData) + sizeof(Attribute) * count;
+    return sizeof(ImmutableElementAttributeData) - sizeof(void*) + sizeof(Attribute) * count;
 }
 
 PassRefPtr<ElementAttributeData> ElementAttributeData::createImmutable(const Vector<Attribute>& attributes)
 {
-    void* slot = WTF::fastMalloc(immutableElementAttributeDataSize(attributes.size()));
+    void* slot = WTF::fastMalloc(sizeForImmutableElementAttributeDataWithAttributeCount(attributes.size()));
     return adoptRef(new (slot) ImmutableElementAttributeData(attributes));
 }
 
@@ -274,7 +274,7 @@
 
 void ElementAttributeData::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
 {
-    size_t actualSize = m_isMutable ? sizeof(ElementAttributeData) : immutableElementAttributeDataSize(m_arraySize);
+    size_t actualSize = m_isMutable ? sizeof(ElementAttributeData) : sizeForImmutableElementAttributeDataWithAttributeCount(m_arraySize);
     MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM, actualSize);
     info.addMember(m_inlineStyleDecl);
     info.addMember(m_attributeStyle);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to