Bug 1180120 - Part 6: Replace HasSameCachedStyleData call with samePointerStructs bit tests. r=dbaron
authorCameron McCormack <cam@mcc.id.au>
Sat, 29 Aug 2015 06:13:47 +1000
changeset 259884 bcb20dbe84bdefaa0c7c623ee79fee13160de3ac
parent 259883 12994503774640077faca4cb3702b948ff68ab62
child 259885 f8942f7f4edd7097d4571dec43e8348c3a0e4691
push id29296
push userryanvm@gmail.com
push dateSun, 30 Aug 2015 19:45:10 +0000
treeherdermozilla-central@2ad5077d86ba [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs1180120
milestone43.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1180120 - Part 6: Replace HasSameCachedStyleData call with samePointerStructs bit tests. r=dbaron
layout/base/RestyleManager.cpp
layout/style/nsStyleContext.cpp
layout/style/nsStyleContext.h
--- a/layout/base/RestyleManager.cpp
+++ b/layout/base/RestyleManager.cpp
@@ -3580,21 +3580,24 @@ ElementRestyler::RestyleSelf(nsIFrame* a
       // only time we hit this deoptimization is either
       //
       // (a) when at least one of the (old or new) equal structs could be stored
       //     in the rule tree, and those structs are then inherited (by pointer
       //     sharing) to descendant style contexts; or
       //
       // (b) when we were unable to swap the structs on the parent because
       //     either or both of the old parent and new parent are shared.
+      //
+      // FIXME This loop could be rewritten as bit operations on
+      //       oldContext->mBits and samePointerStructs.
       for (nsStyleStructID sid = nsStyleStructID(0);
            sid < nsStyleStructID_Length;
            sid = nsStyleStructID(sid + 1)) {
         if (oldContext->HasCachedInheritedStyleData(sid) &&
-            !oldContext->HasSameCachedStyleData(newContext, sid)) {
+            !(samePointerStructs & nsCachedStyleData::GetBitForSID(sid))) {
           LOG_RESTYLE_CONTINUE("there are different struct pointers");
           result = eRestyleResult_Continue;
           break;
         }
       }
     }
 
     if (!(mHintsHandled & nsChangeHint_ReconstructFrame)) {
--- a/layout/style/nsStyleContext.cpp
+++ b/layout/style/nsStyleContext.cpp
@@ -1337,23 +1337,16 @@ nsStyleContext::LookupStruct(const nsACS
 #include "nsStyleStructList.h"
 #undef STYLE_STRUCT
   else
     return false;
   return true;
 }
 #endif
 
-bool
-nsStyleContext::HasSameCachedStyleData(nsStyleContext* aOther,
-                                       nsStyleStructID aSID)
-{
-  return GetCachedStyleData(aSID) == aOther->GetCachedStyleData(aSID);
-}
-
 void
 nsStyleContext::SwapStyleData(nsStyleContext* aNewContext, uint32_t aStructs)
 {
   static_assert(nsStyleStructID_Length <= 32, "aStructs is not big enough");
 
   for (nsStyleStructID i = nsStyleStructID_Inherited_Start;
        i < nsStyleStructID_Inherited_Start + nsStyleStructID_Inherited_Count;
        i = nsStyleStructID(i + 1)) {
--- a/layout/style/nsStyleContext.h
+++ b/layout/style/nsStyleContext.h
@@ -270,22 +270,16 @@ public:
       slot = aStruct;                                                       \
     }
 #define STYLE_STRUCT_RESET(name_, checkdata_cb_) /* nothing */
   #include "nsStyleStructList.h"
   #undef STYLE_STRUCT_RESET
   #undef STYLE_STRUCT_INHERITED
 
   /**
-   * Returns whether this style context and aOther both have the same
-   * cached style struct pointer for a given style struct.
-   */
-  bool HasSameCachedStyleData(nsStyleContext* aOther, nsStyleStructID aSID);
-
-  /**
    * Returns whether this style context has cached, inherited style data for a
    * given style struct.
    */
   bool HasCachedInheritedStyleData(nsStyleStructID aSID)
     { return mBits & nsCachedStyleData::GetBitForSID(aSID); }
 
   nsRuleNode* RuleNode() { return mRuleNode; }
   void AddStyleBit(const uint64_t& aBit) { mBits |= aBit; }