Title: [101218] trunk/Source/WebCore
Revision
101218
Author
andreas.kl...@nokia.com
Date
2011-11-27 19:50:23 -0800 (Sun, 27 Nov 2011)

Log Message

CSSStyleRule: Pack m_sourceLine with CSSRule bits.
<http://webkit.org/b/73168>

Reviewed by Antti Koivisto.

Make CSSStyleRule::m_sourceLine a 27-bit integer and pack it with the rest
of the members in CSSRule. This shrinks CSSStyleRule by one CPU word
and reduces memory consumption by 81 kB on the GMail inbox (on 64-bit.)

* css/CSSRule.h:
(WebCore::CSSRule::CSSRule):
* css/CSSStyleRule.cpp:
(WebCore::CSSStyleRule::CSSStyleRule):
* css/CSSStyleRule.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (101217 => 101218)


--- trunk/Source/WebCore/ChangeLog	2011-11-28 02:11:58 UTC (rev 101217)
+++ trunk/Source/WebCore/ChangeLog	2011-11-28 03:50:23 UTC (rev 101218)
@@ -1,3 +1,20 @@
+2011-11-27  Andreas Kling  <kl...@webkit.org>
+
+        CSSStyleRule: Pack m_sourceLine with CSSRule bits.
+        <http://webkit.org/b/73168>
+
+        Reviewed by Antti Koivisto.
+
+        Make CSSStyleRule::m_sourceLine a 27-bit integer and pack it with the rest
+        of the members in CSSRule. This shrinks CSSStyleRule by one CPU word
+        and reduces memory consumption by 81 kB on the GMail inbox (on 64-bit.)
+
+        * css/CSSRule.h:
+        (WebCore::CSSRule::CSSRule):
+        * css/CSSStyleRule.cpp:
+        (WebCore::CSSStyleRule::CSSStyleRule):
+        * css/CSSStyleRule.h:
+
 2011-11-27  Mark Rowe  <mr...@apple.com>
 
         <http://webkit.org/b/72665> Switch to a more modern approach to retrieving the OS marketing version

Modified: trunk/Source/WebCore/css/CSSRule.h (101217 => 101218)


--- trunk/Source/WebCore/css/CSSRule.h	2011-11-28 02:11:58 UTC (rev 101217)
+++ trunk/Source/WebCore/css/CSSRule.h	2011-11-28 03:50:23 UTC (rev 101218)
@@ -109,7 +109,8 @@
 
 protected:
     CSSRule(CSSStyleSheet* parent, Type type)
-        : m_parentIsRule(false)
+        : m_sourceLine(0)
+        , m_parentIsRule(false)
         , m_type(type)
         , m_parentStyleSheet(parent)
     {
@@ -120,15 +121,18 @@
 
     ~CSSRule() { }
 
+    // Only used by CSSStyleRule but kept here to maximize struct packing.
+    signed m_sourceLine : 27;
+
 private:
-    void destroy();
-
     bool m_parentIsRule : 1;
-    unsigned m_type : 31; // Plenty of space for additional flags here.
+    unsigned m_type : 4;
     union {
         CSSRule* m_parentRule;
         CSSStyleSheet* m_parentStyleSheet;
     };
+
+    void destroy();
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/css/CSSStyleRule.cpp (101217 => 101218)


--- trunk/Source/WebCore/css/CSSStyleRule.cpp	2011-11-28 02:11:58 UTC (rev 101217)
+++ trunk/Source/WebCore/css/CSSStyleRule.cpp	2011-11-28 03:50:23 UTC (rev 101218)
@@ -35,8 +35,11 @@
 
 CSSStyleRule::CSSStyleRule(CSSStyleSheet* parent, int sourceLine, CSSRule::Type type)
     : CSSRule(parent, type)
-    , m_sourceLine(sourceLine)
 {
+    m_sourceLine = sourceLine;
+
+    // m_sourceLine is a bitfield, so let's catch any overflow early in debug mode.
+    ASSERT(m_sourceLine == sourceLine);
 }
 
 CSSStyleRule::~CSSStyleRule()

Modified: trunk/Source/WebCore/css/CSSStyleRule.h (101217 => 101218)


--- trunk/Source/WebCore/css/CSSStyleRule.h	2011-11-28 02:11:58 UTC (rev 101217)
+++ trunk/Source/WebCore/css/CSSStyleRule.h	2011-11-28 03:50:23 UTC (rev 101218)
@@ -63,7 +63,6 @@
 private:
     RefPtr<CSSMutableStyleDeclaration> m_style;
     CSSSelectorList m_selectorList;
-    int m_sourceLine;
 };
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to