Title: [126139] trunk/Source/WebCore
Revision
126139
Author
[email protected]
Date
2012-08-21 00:17:53 -0700 (Tue, 21 Aug 2012)

Log 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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (126138 => 126139)


--- trunk/Source/WebCore/ChangeLog	2012-08-21 06:50:57 UTC (rev 126138)
+++ trunk/Source/WebCore/ChangeLog	2012-08-21 07:17:53 UTC (rev 126139)
@@ -1,3 +1,24 @@
+2012-08-20  Ilya Tikhonovsky  <[email protected]>
+
+        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):
+
 2012-08-20  Kentaro Hara  <[email protected]>
 
         [V8] Move handleOutOfMemory() from V8Proxy to V8Binding

Modified: trunk/Source/WebCore/css/StylePropertySet.cpp (126138 => 126139)


--- trunk/Source/WebCore/css/StylePropertySet.cpp	2012-08-21 06:50:57 UTC (rev 126138)
+++ trunk/Source/WebCore/css/StylePropertySet.cpp	2012-08-21 07:17:53 UTC (rev 126139)
@@ -50,9 +50,14 @@
     return propertySetCSSOMWrapperMapInstance;
 }
 
+static size_t immutableStylePropertySetSize(unsigned count)
+{
+    return sizeof(StylePropertySet) - sizeof(void*) + sizeof(CSSProperty) * count;
+}
+
 PassRefPtr<StylePropertySet> StylePropertySet::createImmutable(const CSSProperty* properties, unsigned count, CSSParserMode cssParserMode)
 {
-    void* slot = WTF::fastMalloc(sizeof(StylePropertySet) - sizeof(void*) + sizeof(CSSProperty) * count);
+    void* slot = WTF::fastMalloc(immutableStylePropertySetSize(count));
     return adoptRef(new (slot) StylePropertySet(properties, count, cssParserMode, /* makeMutable */ false));
 }
 
@@ -1091,11 +1096,11 @@
 
 void StylePropertySet::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
 {
-    MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    size_t actualSize = m_isMutable ? sizeof(StylePropertySet) : immutableStylePropertySetSize(m_arraySize);
+    MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS, actualSize);
     if (m_isMutable)
         info.addVectorPtr(m_mutablePropertyVector);
-    else
-        info.addRawBuffer(m_properties, m_arraySize * sizeof(CSSProperty));
+
     unsigned count = propertyCount();
     for (unsigned i = 0; i < count; ++i)
         info.addInstrumentedMember(propertyAt(i));

Modified: trunk/Source/WebCore/dom/MemoryInstrumentation.h (126138 => 126139)


--- trunk/Source/WebCore/dom/MemoryInstrumentation.h	2012-08-21 06:50:57 UTC (rev 126138)
+++ trunk/Source/WebCore/dom/MemoryInstrumentation.h	2012-08-21 07:17:53 UTC (rev 126139)
@@ -168,10 +168,10 @@
 private:
     friend class MemoryClassInfo;
 
-    template <typename T> void reportObjectInfo(MemoryInstrumentation::ObjectType objectType)
+    template <typename T> void reportObjectInfo(MemoryInstrumentation::ObjectType objectType, size_t actualSize)
     {
         if (!m_objectSize) {
-            m_objectSize = sizeof(T);
+            m_objectSize = actualSize ? actualSize : sizeof(T);
             if (objectType != MemoryInstrumentation::Other)
                 m_objectType = objectType;
         }
@@ -185,11 +185,11 @@
 class MemoryClassInfo {
 public:
     template <typename T>
-    MemoryClassInfo(MemoryObjectInfo* memoryObjectInfo, const T*, MemoryInstrumentation::ObjectType objectType)
+    MemoryClassInfo(MemoryObjectInfo* memoryObjectInfo, const T*, MemoryInstrumentation::ObjectType objectType, size_t actualSize = 0)
         : m_memoryObjectInfo(memoryObjectInfo)
         , m_memoryInstrumentation(memoryObjectInfo->memoryInstrumentation())
     {
-        m_memoryObjectInfo->reportObjectInfo<T>(objectType);
+        m_memoryObjectInfo->reportObjectInfo<T>(objectType, actualSize);
         m_objectType = memoryObjectInfo->objectType();
     }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to