Changeset 102835 in webkit


Ignore:
Timestamp:
Dec 14, 2011 3:21:35 PM (12 years ago)
Author:
rniwa@webkit.org
Message:

COMPILE_ASSERT in CSSStyleSelector.cpp doesn't compile on Windows
https://bugs.webkit.org/show_bug.cgi?id=74327

Reviewed by Darin Adler.

Always use unsigned instead of bool and unsigned in the bitfields of RuleData to shrink
its size under MSVC.

Unlike gcc and clang, MSVC pads each consecutive member variables of the same type
in bitfields. e.g. if you have:
sturct AB {

unsigned m_1 : 31;
bool m_2 : 1;

}
then MSVC pads m_1 and allocates sizeof(unsigned) * 2 for AB whereas gcc and clang
only allocate sizeof(unsigned) * 1 for AB.

  • css/CSSStyleSelector.cpp:

(WebCore::RuleData::RuleData):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r102834 r102835  
     12011-12-14  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        COMPILE_ASSERT in CSSStyleSelector.cpp doesn't compile on Windows
     4        https://bugs.webkit.org/show_bug.cgi?id=74327
     5
     6        Reviewed by Darin Adler.
     7
     8        Always use unsigned instead of bool and unsigned in the bitfields of RuleData to shrink
     9        its size under MSVC.
     10
     11        Unlike gcc and clang, MSVC pads each consecutive member variables of the same type
     12        in bitfields. e.g. if you have:
     13        sturct AB {
     14            unsigned m_1 : 31;
     15            bool m_2 : 1;
     16        }
     17        then MSVC pads m_1 and allocates sizeof(unsigned) * 2 for AB whereas gcc and clang
     18        only allocate sizeof(unsigned) * 1 for AB.
     19
     20        * css/CSSStyleSelector.cpp:
     21        (WebCore::RuleData::RuleData):
     22
    1232011-12-14  Ryosuke Niwa  <rniwa@webkit.org>
    224
  • trunk/Source/WebCore/css/CSSStyleSelector.cpp

    r102832 r102835  
    194194    // Some simple testing showed <100,000 RuleData's on large sites.
    195195    unsigned m_position : 25;
    196     bool m_hasFastCheckableSelector : 1;
    197     bool m_hasMultipartSelector : 1;
    198     bool m_hasRightmostSelectorMatchingHTMLBasedOnRuleHash : 1;
    199     bool m_containsUncommonAttributeSelector : 1;
     196    unsigned m_hasFastCheckableSelector : 1;
     197    unsigned m_hasMultipartSelector : 1;
     198    unsigned m_hasRightmostSelectorMatchingHTMLBasedOnRuleHash : 1;
     199    unsigned m_containsUncommonAttributeSelector : 1;
    200200    unsigned m_linkMatchType : 2; //  SelectorChecker::LinkMatchMask
    201     bool m_regionStyleRule : 1;
     201    unsigned m_regionStyleRule : 1;
    202202    // Use plain array instead of a Vector to minimize memory overhead.
    203203    unsigned m_descendantSelectorIdentifierHashes[maximumIdentifierCount];
     
    212212};
    213213
    214 #if !OS(WINDOWS)
    215214COMPILE_ASSERT(sizeof(RuleData) == sizeof(SameSizeAsRuleData), RuleData_should_stay_small);
    216 #endif
    217215
    218216class RuleSet {
     
    18951893    , m_position(position)
    18961894    , m_hasFastCheckableSelector(SelectorChecker::isFastCheckableSelector(selector))
    1897     , m_hasMultipartSelector(selector->tagHistory())
     1895    , m_hasMultipartSelector(!!selector->tagHistory())
    18981896    , m_hasRightmostSelectorMatchingHTMLBasedOnRuleHash(isSelectorMatchingHTMLBasedOnRuleHash(selector))
    18991897    , m_containsUncommonAttributeSelector(WebCore::containsUncommonAttributeSelector(selector))
Note: See TracChangeset for help on using the changeset viewer.