Pack WebCore::RuleData better.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Jan 2015 21:20:33 +0000 (21:20 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Jan 2015 21:20:33 +0000 (21:20 +0000)
<https://webkit.org/b/140109>

Reviewed by Benjamin Poulain.

Shrink RuleData by 8 bytes per instance by reordering members so that
the CSS JIT compilation status fits into the bitfield.

* css/RuleSet.h:
(WebCore::RuleData::compilationStatus):
* cssjit/SelectorCompiler.h:
(WebCore::SelectorCompilationStatus::SelectorCompilationStatus):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@177988 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/css/RuleSet.h
Source/WebCore/cssjit/SelectorCompiler.h

index 3ccf227..51c2b3e 100644 (file)
@@ -1,3 +1,18 @@
+2015-01-06  Andreas Kling  <akling@apple.com>
+
+        Pack WebCore::RuleData better.
+        <https://webkit.org/b/140109>
+
+        Reviewed by Benjamin Poulain.
+
+        Shrink RuleData by 8 bytes per instance by reordering members so that
+        the CSS JIT compilation status fits into the bitfield.
+
+        * css/RuleSet.h:
+        (WebCore::RuleData::compilationStatus):
+        * cssjit/SelectorCompiler.h:
+        (WebCore::SelectorCompilationStatus::SelectorCompilationStatus):
+
 2015-01-06  Anders Carlsson  <andersca@apple.com>
 
         Add a WebKit1 database provider
index e7d8a0b..5232341 100644 (file)
@@ -84,7 +84,7 @@ public:
     const unsigned* descendantSelectorIdentifierHashes() const { return m_descendantSelectorIdentifierHashes; }
 
 #if ENABLE(CSS_SELECTOR_JIT)
-    SelectorCompilationStatus compilationStatus() const { return m_compilationStatus; }
+    SelectorCompilationStatus compilationStatus() const { return SelectorCompilationStatus(m_compilationStatus); }
     JSC::MacroAssemblerCodeRef compiledSelectorCodeRef() const { return m_compiledSelectorCodeRef; }
     void setCompiledSelector(SelectorCompilationStatus status, JSC::MacroAssemblerCodeRef codeRef) const
     {
@@ -113,20 +113,20 @@ private:
     unsigned m_containsUncommonAttributeSelector : 1;
     unsigned m_linkMatchType : 2; //  SelectorChecker::LinkMatchMask
     unsigned m_propertyWhitelistType : 2;
-    // Use plain array instead of a Vector to minimize memory overhead.
-    unsigned m_descendantSelectorIdentifierHashes[maximumIdentifierCount];
 #if ENABLE(CSS_SELECTOR_JIT)
-    mutable SelectorCompilationStatus m_compilationStatus;
+    mutable unsigned m_compilationStatus : 2; // SelectorCompilationStatus
     mutable JSC::MacroAssemblerCodeRef m_compiledSelectorCodeRef;
 #if CSS_SELECTOR_JIT_PROFILING
     mutable unsigned m_compiledSelectorUseCount;
 #endif
 #endif // ENABLE(CSS_SELECTOR_JIT)
+    // Use plain array instead of a Vector to minimize memory overhead.
+    unsigned m_descendantSelectorIdentifierHashes[maximumIdentifierCount];
 };
     
 struct SameSizeAsRuleData {
 #if ENABLE(CSS_SELECTOR_JIT)
-    unsigned compilationStatus;
+    // NOTE: The compilationStatus field fits in the bitfield.
     void* compiledSelectorPointer;
     void* codeRefPtr;
 #if CSS_SELECTOR_JIT_PROFILING
index 2cb64a8..445ffa4 100644 (file)
@@ -61,6 +61,10 @@ public:
         : m_status(status)
     { }
 
+    explicit SelectorCompilationStatus(unsigned status)
+        : m_status(static_cast<Status>(status))
+    { }
+
     operator Status() const { return m_status; }
 
 private: