- Revision
- 104254
- Author
- [email protected]
- Date
- 2012-01-05 17:19:42 -0800 (Thu, 05 Jan 2012)
Log Message
sizeof(CSSRule) is 20 instead of 12 on Windows
https://bugs.webkit.org/show_bug.cgi?id=75665
Reviewed by Darin Fisher.
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.
Fix the bloat by turning all bitfields in CSSRule either signed or unsigned integers.
* css/CSSRule.cpp:
* css/CSSRule.h:
(WebCore::CSSRule::sourceLine):
(WebCore::CSSRule::setSourceLine):
(WebCore::CSSRule::hasCachedSelectorText):
(WebCore::CSSRule::setHasCachedSelectorText):
* css/CSSStyleRule.cpp:
(WebCore::CSSStyleRule::CSSStyleRule):
(WebCore::CSSStyleRule::cleanup):
(WebCore::CSSStyleRule::selectorText):
(WebCore::CSSStyleRule::setSelectorText):
* css/CSSStyleRule.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (104253 => 104254)
--- trunk/Source/WebCore/ChangeLog 2012-01-06 01:17:23 UTC (rev 104253)
+++ trunk/Source/WebCore/ChangeLog 2012-01-06 01:19:42 UTC (rev 104254)
@@ -1,3 +1,36 @@
+2012-01-05 Ryosuke Niwa <[email protected]>
+
+ sizeof(CSSRule) is 20 instead of 12 on Windows
+ https://bugs.webkit.org/show_bug.cgi?id=75665
+
+ Reviewed by Darin Fisher.
+
+ 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.
+
+ Fix the bloat by turning all bitfields in CSSRule either signed or unsigned integers.
+
+ * css/CSSRule.cpp:
+ * css/CSSRule.h:
+ (WebCore::CSSRule::sourceLine):
+ (WebCore::CSSRule::setSourceLine):
+ (WebCore::CSSRule::hasCachedSelectorText):
+ (WebCore::CSSRule::setHasCachedSelectorText):
+ * css/CSSStyleRule.cpp:
+ (WebCore::CSSStyleRule::CSSStyleRule):
+ (WebCore::CSSStyleRule::cleanup):
+ (WebCore::CSSStyleRule::selectorText):
+ (WebCore::CSSStyleRule::setSelectorText):
+ * css/CSSStyleRule.h:
+
2012-01-05 David Grogan <[email protected]>
IndexedDB: fix cursor prefetch crash
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (104253 => 104254)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2012-01-06 01:17:23 UTC (rev 104253)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2012-01-06 01:19:42 UTC (rev 104254)
@@ -23832,7 +23832,7 @@
FD6F252D13F5EF0E0065165F /* MediaElementAudioSourceNode.h in Headers */,
E44613AD0CD6331000FADA75 /* MediaError.h in Headers */,
4E1959220A39DABA00220FE5 /* MediaFeatureNames.h in Headers */,
- 07A6D1EC1491137700051D0C /* MediaFragmentURIParser.h in Headers */,
+ 07A6D1EC1491137700051D0C /* MediaFragmentURIParser.h in Headers */,
A8EA800E0A19516E00A8EF5F /* MediaList.h in Headers */,
E44613E40CD681A200FADA75 /* MediaPlayer.h in Headers */,
076F0D0E12B8192700C26AA4 /* MediaPlayerPrivateAVFoundation.h in Headers */,
@@ -26943,7 +26943,7 @@
97205AB71239291000B17380 /* MediaDocument.cpp in Sources */,
FD6F252C13F5EF0E0065165F /* MediaElementAudioSourceNode.cpp in Sources */,
4E1959210A39DABA00220FE5 /* MediaFeatureNames.cpp in Sources */,
- 07A6D1EB1491137700051D0C /* MediaFragmentURIParser.cpp in Sources */,
+ 07A6D1EB1491137700051D0C /* MediaFragmentURIParser.cpp in Sources */,
A8EA80090A19516E00A8EF5F /* MediaList.cpp in Sources */,
E44613E30CD6819F00FADA75 /* MediaPlayer.cpp in Sources */,
072C8B11131C518600A4FCE9 /* MediaPlayerPrivateAVFoundation.cpp in Sources */,
Modified: trunk/Source/WebCore/css/CSSRule.cpp (104253 => 104254)
--- trunk/Source/WebCore/css/CSSRule.cpp 2012-01-06 01:17:23 UTC (rev 104253)
+++ trunk/Source/WebCore/css/CSSRule.cpp 2012-01-06 01:19:42 UTC (rev 104254)
@@ -36,6 +36,13 @@
namespace WebCore {
+struct SameSizeAsCSSRule : public RefCounted<SameSizeAsCSSRule> {
+ unsigned bitfields;
+ void* pointerUnion;
+};
+
+COMPILE_ASSERT(sizeof(CSSRule) == sizeof(SameSizeAsCSSRule), CSSRule_should_stay_small);
+
void CSSRule::setCssText(const String& /*cssText*/, ExceptionCode& /*ec*/)
{
notImplemented();
Modified: trunk/Source/WebCore/css/CSSRule.h (104253 => 104254)
--- trunk/Source/WebCore/css/CSSRule.h 2012-01-06 01:17:23 UTC (rev 104253)
+++ trunk/Source/WebCore/css/CSSRule.h 2012-01-06 01:19:42 UTC (rev 104254)
@@ -122,12 +122,16 @@
~CSSRule() { }
+ int sourceLine() const { return m_sourceLine; }
+ void setSourceLine(int sourceLine) { m_sourceLine = sourceLine; }
+ bool hasCachedSelectorText() const { return m_hasCachedSelectorText; }
+ void setHasCachedSelectorText(bool hasCachedSelectorText) const { m_hasCachedSelectorText = hasCachedSelectorText; }
+
+private:
// Only used by CSSStyleRule but kept here to maximize struct packing.
signed m_sourceLine : 26;
- mutable bool m_hasCachedSelectorText : 1;
-
-private:
- bool m_parentIsRule : 1;
+ mutable unsigned m_hasCachedSelectorText : 1;
+ unsigned m_parentIsRule : 1;
unsigned m_type : 4;
union {
CSSRule* m_parentRule;
Modified: trunk/Source/WebCore/css/CSSStyleRule.cpp (104253 => 104254)
--- trunk/Source/WebCore/css/CSSStyleRule.cpp 2012-01-06 01:17:23 UTC (rev 104253)
+++ trunk/Source/WebCore/css/CSSStyleRule.cpp 2012-01-06 01:19:42 UTC (rev 104254)
@@ -35,13 +35,13 @@
namespace WebCore {
-CSSStyleRule::CSSStyleRule(CSSStyleSheet* parent, int sourceLine, CSSRule::Type type)
+CSSStyleRule::CSSStyleRule(CSSStyleSheet* parent, int line, CSSRule::Type type)
: CSSRule(parent, type)
{
- m_sourceLine = sourceLine;
+ setSourceLine(line);
// m_sourceLine is a bitfield, so let's catch any overflow early in debug mode.
- ASSERT(m_sourceLine == sourceLine);
+ ASSERT(sourceLine() == line);
}
CSSStyleRule::~CSSStyleRule()
@@ -60,9 +60,9 @@
inline void CSSStyleRule::cleanup()
{
- if (m_hasCachedSelectorText) {
+ if (hasCachedSelectorText()) {
selectorTextCache().remove(this);
- m_hasCachedSelectorText = false;
+ setHasCachedSelectorText(false);
}
}
@@ -83,7 +83,7 @@
String CSSStyleRule::selectorText() const
{
- if (m_hasCachedSelectorText) {
+ if (hasCachedSelectorText()) {
ASSERT(selectorTextCache().contains(this));
return selectorTextCache().get(this);
}
@@ -91,7 +91,7 @@
ASSERT(!selectorTextCache().contains(this));
String text = generateSelectorText();
selectorTextCache().set(this, text);
- m_hasCachedSelectorText = true;
+ setHasCachedSelectorText(true);
return text;
}
@@ -119,7 +119,7 @@
String oldSelectorText = this->selectorText();
m_selectorList.adopt(selectorList);
- if (m_hasCachedSelectorText) {
+ if (hasCachedSelectorText()) {
ASSERT(selectorTextCache().contains(this));
selectorTextCache().set(this, generateSelectorText());
}
Modified: trunk/Source/WebCore/css/CSSStyleRule.h (104253 => 104254)
--- trunk/Source/WebCore/css/CSSStyleRule.h 2012-01-06 01:17:23 UTC (rev 104253)
+++ trunk/Source/WebCore/css/CSSStyleRule.h 2012-01-06 01:19:42 UTC (rev 104254)
@@ -55,7 +55,7 @@
void addSubresourceStyleURLs(ListHashSet<KURL>& urls);
- int sourceLine() { return m_sourceLine; }
+ using CSSRule::sourceLine;
protected:
CSSStyleRule(CSSStyleSheet* parent, int sourceLine, CSSRule::Type = CSSRule::STYLE_RULE);