Bug 1406727 - Improve diagnostics in BuildDisplayList. r=froydnj
authorMatt Woodrow <mwoodrow@mozilla.com>
Tue, 06 Feb 2018 12:21:31 +1300
changeset 467969 9ff54d6e39b0e215df9cf3fa251d0f1c5ba0d811
parent 467968 39f5189c574b0a14db6ddc23c9c9ec8410a55048
child 467970 912d129db081b9d7cce5d239645b7859d74eac6f
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1406727
milestone61.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 1406727 - Improve diagnostics in BuildDisplayList. r=froydnj MozReview-Commit-ID: Ctb7HFxgPac
layout/base/nsPresArena.h
layout/generic/nsFrame.cpp
layout/painting/nsDisplayList.h
xpcom/ds/ArenaAllocator.h
--- a/layout/base/nsPresArena.h
+++ b/layout/base/nsPresArena.h
@@ -105,21 +105,19 @@ public:
   void ClearArenaRefPtrs(mozilla::ArenaObjectID aObjectID);
 
   /**
    * Increment nsWindowSizes with sizes of interesting objects allocated in this
    * arena.
    */
   void AddSizeOfExcludingThis(nsWindowSizes& aWindowSizes) const;
 
-#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
   void Check() {
     mPool.Check();
   }
-#endif
 
 private:
   void* Allocate(uint32_t aCode, size_t aSize);
   void Free(uint32_t aCode, void* aPtr);
 
   inline void ClearArenaRefPtrWithoutDeregistering(
       void* aPtr,
       mozilla::ArenaObjectID aObjectID);
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -2776,20 +2776,36 @@ ComputeClipForMaskItem(nsDisplayListBuil
     // The resulting clip is relative to the reference frame, but the caller
     // expects it to be relative to the masked frame, so adjust it.
     result -= toReferenceFrame;
     return Some(result);
   }
   return Nothing();
 }
 
+struct AutoCheckBuilder {
+  explicit AutoCheckBuilder(nsDisplayListBuilder* aBuilder)
+    : mBuilder(aBuilder)
+  {
+    aBuilder->Check();
+  }
+
+  ~AutoCheckBuilder()
+  {
+    mBuilder->Check();
+  }
+
+  nsDisplayListBuilder* mBuilder;
+};
+
 void
 nsIFrame::BuildDisplayListForStackingContext(nsDisplayListBuilder* aBuilder,
                                              nsDisplayList*        aList,
                                              bool*                 aCreatedContainerItem) {
+  AutoCheckBuilder check(aBuilder);
   if (GetStateBits() & NS_FRAME_TOO_DEEP_IN_FRAME_TREE)
     return;
 
   // Replaced elements have their visibility handled here, because
   // they're visually atomic
   if (IsFrameOfType(eReplaced) && !IsVisibleForPainting(aBuilder))
     return;
 
@@ -3064,17 +3080,19 @@ nsIFrame::BuildDisplayListForStackingCon
       eventRegions->AddFrame(aBuilder, this);
       aBuilder->SetLayerEventRegions(eventRegions);
     }
 
     aBuilder->BuildCompositorHitTestInfoIfNeeded(this, set.BorderBackground(),
                                                  true);
 
     MarkAbsoluteFramesForDisplayList(aBuilder);
+    aBuilder->Check();
     BuildDisplayList(aBuilder, set);
+    aBuilder->Check();
 
     // Blend modes are a real pain for retained display lists. We build a blend
     // container item if the built list contains any blend mode items within
     // the current stacking context. This can change without an invalidation
     // to the stacking context frame, or the blend mode frame (e.g. by moving
     // an intermediate frame).
     // When we gain/remove a blend container item, we need to mark this frame
     // as invalid and have the full display list for merging to track
@@ -3112,17 +3130,19 @@ nsIFrame::BuildDisplayListForStackingCon
         // If this is the root frame, then the previous call to
         // MarkAbsoluteFramesForDisplayList might have stored some fixed
         // background data. Clear that now.
         if (!GetParent()) {
           aBuilder->ClearFixedBackgroundDisplayData();
         }
 
         MarkAbsoluteFramesForDisplayList(aBuilder);
+        aBuilder->Check();
         BuildDisplayList(aBuilder, set);
+        aBuilder->Check();
       }
     }
 
     if (eventRegions) {
       // If the event regions item ended up empty, throw it away rather than
       // adding it to the display list.
       if (!eventRegions->IsEmpty()) {
         set.BorderBackground()->AppendToBottom(eventRegions);
@@ -3510,16 +3530,17 @@ DescendIntoChild(nsDisplayListBuilder* a
   return true;
 }
 
 void
 nsIFrame::BuildDisplayListForChild(nsDisplayListBuilder*   aBuilder,
                                    nsIFrame*               aChild,
                                    const nsDisplayListSet& aLists,
                                    uint32_t                aFlags) {
+  AutoCheckBuilder check(aBuilder);
   // If painting is restricted to just the background of the top level frame,
   // then we have nothing to do here.
   if (aBuilder->IsBackgroundOnly())
     return;
 
   if (aBuilder->IsForGenerateGlyphMask() ||
       aBuilder->IsForPaintingSelectionBG()) {
     if (!aChild->IsTextFrame() && aChild->IsLeaf()) {
@@ -3572,17 +3593,19 @@ nsIFrame::BuildDisplayListForChild(nsDis
 
     nsDisplayLayerEventRegions* eventRegions = aBuilder->GetLayerEventRegions();
     if (eventRegions) {
       eventRegions->AddFrame(aBuilder, child);
     }
 
     child->MarkAbsoluteFramesForDisplayList(aBuilder);
     aBuilder->AdjustWindowDraggingRegion(child);
+    aBuilder->Check();
     child->BuildDisplayList(aBuilder, aLists);
+    aBuilder->Check();
     aBuilder->DisplayCaret(child, aLists.Content());
 #ifdef DEBUG
     DisplayDebugBorders(aBuilder, child, aLists);
 #endif
     return;
   }
 
   const bool isSVG = child->GetStateBits() & NS_FRAME_SVG_LAYOUT;
@@ -3820,17 +3843,19 @@ nsIFrame::BuildDisplayListForChild(nsDis
       // Not a pseudo or real stacking context. Do the simple thing and
       // return early.
 
       aBuilder->BuildCompositorHitTestInfoIfNeeded(child,
                                                    aLists.BorderBackground(),
                                                    differentAGR);
 
       aBuilder->AdjustWindowDraggingRegion(child);
+      aBuilder->Check();
       child->BuildDisplayList(aBuilder, aLists);
+      aBuilder->Check();
       aBuilder->DisplayCaret(child, aLists.Content());
 #ifdef DEBUG
       DisplayDebugBorders(aBuilder, child, aLists);
 #endif
       return;
     }
 
     // A pseudo-stacking context (e.g., a positioned element with z-index auto).
@@ -3840,17 +3865,19 @@ nsIFrame::BuildDisplayListForChild(nsDis
     nsDisplayListCollection pseudoStack(aBuilder);
 
     aBuilder->BuildCompositorHitTestInfoIfNeeded(child,
                                                  pseudoStack.BorderBackground(),
                                                  differentAGR);
 
     aBuilder->AdjustWindowDraggingRegion(child);
     nsDisplayListBuilder::AutoContainerASRTracker contASRTracker(aBuilder);
+    aBuilder->Check();
     child->BuildDisplayList(aBuilder, pseudoStack);
+    aBuilder->Check();
     if (aBuilder->DisplayCaret(child, pseudoStack.Content())) {
       canSkipWrapList = false;
     }
     wrapListASR = contASRTracker.GetContainerASR();
 
     list.AppendToTop(pseudoStack.BorderBackground());
     list.AppendToTop(pseudoStack.BlockBorderBackgrounds());
     list.AppendToTop(pseudoStack.Floats());
--- a/layout/painting/nsDisplayList.h
+++ b/layout/painting/nsDisplayList.h
@@ -706,19 +706,17 @@ public:
   }
   AnimatedGeometryRoot* GetRootAnimatedGeometryRoot() {
     return mRootAGR;
   }
 
   void RecomputeCurrentAnimatedGeometryRoot();
 
   void Check() {
-#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
     mPool.Check();
-#endif
   }
 
   /**
    * Returns true if merging and flattening of display lists should be
    * performed while computing visibility.
    */
   bool AllowMergingAndFlattening() { return mAllowMergingAndFlattening; }
   void SetAllowMergingAndFlattening(bool aAllow) { mAllowMergingAndFlattening = aAllow; }
--- a/xpcom/ds/ArenaAllocator.h
+++ b/xpcom/ds/ArenaAllocator.h
@@ -120,24 +120,22 @@ public:
     for (auto arena = mHead.next; arena; arena = arena->next) {
       s += aMallocSizeOf(arena);
     }
 
     return s;
   }
 
 
-#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
   void Check()
   {
-    for (auto arena = mHead.next; arena; arena = arena->next) {
-      arena->canary.Check();
+    if (mCurrent) {
+      mCurrent->canary.Check();
     }
   }
-#endif
 
 private:
   struct ArenaHeader
   {
     /**
      * The location in memory of the data portion of the arena.
      */
     uintptr_t offset;