Bug 1351904 - Switch layout over to ArenaAllocator. r=xidorn
authorEric Rahm <erahm@mozilla.com>
Fri, 31 Mar 2017 14:06:33 -0700
changeset 350729 102d5db4cb8c74513fd11b53e8f2d743aa40578a
parent 350728 ae5cee559eeb2d82bbb4fefb1ac85930c291d533
child 350730 cb9742f4629f9052dc89ce919162a42ecaa46227
push id88705
push usererahm@mozilla.com
push dateFri, 31 Mar 2017 21:06:50 +0000
treeherdermozilla-inbound@102d5db4cb8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersxidorn
bugs1351904
milestone55.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 1351904 - Switch layout over to ArenaAllocator. r=xidorn This switches over layout's usage of PLArena to ArenaAllocator. This allows us to build more files in unified sources and gets rid of various CONST masks. MozReview-Commit-ID: Aaf3Dl2kaoz
layout/base/moz.build
layout/base/nsPresArena.cpp
layout/base/nsPresArena.h
layout/generic/moz.build
layout/generic/nsLineLayout.cpp
layout/generic/nsLineLayout.h
layout/painting/nsDisplayList.cpp
layout/painting/nsDisplayList.h
layout/style/moz.build
layout/style/nsCSSRuleProcessor.cpp
view/moz.build
view/nsViewManager.cpp
--- a/layout/base/moz.build
+++ b/layout/base/moz.build
@@ -99,16 +99,17 @@ UNIFIED_SOURCES += [
     'nsCSSFrameConstructor.cpp',
     'nsDocumentViewer.cpp',
     'nsFrameManager.cpp',
     'nsFrameTraversal.cpp',
     'nsGenConList.cpp',
     'nsLayoutDebugger.cpp',
     'nsLayoutHistoryState.cpp',
     'nsLayoutUtils.cpp',
+    'nsPresArena.cpp',
     'nsPresContext.cpp',
     'nsQuoteList.cpp',
     'nsStyleChangeList.cpp',
     'nsStyleSheetService.cpp',
     'PositionedEventTargeting.cpp',
     'PresShell.cpp',
     'RestyleManager.cpp',
     'RestyleTracker.cpp',
@@ -131,20 +132,18 @@ if CONFIG['ENABLE_INTL_API']:
 else:
     EXPORTS += [
         'nsBidi_noICU.h',
     ]
     UNIFIED_SOURCES += [
         'nsBidi_noICU.cpp',
     ]
 
-# nsPresArena.cpp needs to be built separately because it uses plarena.h.
 # nsRefreshDriver.cpp needs to be built separately because of name clashes in the OS X headers
 SOURCES += [
-    'nsPresArena.cpp',
     'nsRefreshDriver.cpp',
 ]
 
 if CONFIG['ENABLE_TESTS']:
     DIRS += ['gtest']
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
--- a/layout/base/nsPresArena.cpp
+++ b/layout/base/nsPresArena.cpp
@@ -2,44 +2,30 @@
  * vim: set ts=2 sw=2 et tw=78:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
 /* arena allocation for the frame tree and closely-related objects */
 
-// Even on 32-bit systems, we allocate objects from the frame arena
-// that require 8-byte alignment.  The cast to uintptr_t is needed
-// because plarena isn't as careful about mask construction as it
-// ought to be.
-#define ALIGN_SHIFT 3
-#define PL_ARENA_CONST_ALIGN_MASK ((uintptr_t(1) << ALIGN_SHIFT) - 1)
-#include "plarena.h"
-// plarena.h needs to be included first to make it use the above
-// PL_ARENA_CONST_ALIGN_MASK in this file.
-
 #include "nsPresArena.h"
 
 #include "mozilla/Poison.h"
 #include "nsDebug.h"
 #include "nsArenaMemoryStats.h"
 #include "nsPrintfCString.h"
 #include "nsStyleContext.h"
 
 #include <inttypes.h>
 
 using namespace mozilla;
 
-// Size to use for PLArena block allocations.
-static const size_t ARENA_PAGE_SIZE = 8192;
-
 nsPresArena::nsPresArena()
 {
-  PL_INIT_ARENA_POOL(&mPool, "PresArena", ARENA_PAGE_SIZE);
 }
 
 nsPresArena::~nsPresArena()
 {
   ClearArenaRefPtrs();
 
 #if defined(MOZ_HAVE_MEM_CHECKS)
   for (auto iter = mFreeLists.Iter(); !iter.Done(); iter.Next()) {
@@ -47,18 +33,16 @@ nsPresArena::~nsPresArena()
     nsTArray<void*>::index_type len;
     while ((len = entry->mEntries.Length())) {
       void* result = entry->mEntries.ElementAt(len - 1);
       entry->mEntries.RemoveElementAt(len - 1);
       MOZ_MAKE_MEM_UNDEFINED(result, entry->mEntrySize);
     }
   }
 #endif
-
-  PL_FinishArenaPool(&mPool);
 }
 
 /* inline */ void
 nsPresArena::ClearArenaRefPtrWithoutDeregistering(void* aPtr,
                                                   ArenaObjectID aObjectID)
 {
   switch (aObjectID) {
 #define PRES_ARENA_OBJECT_WITH_ARENAREFPTR_SUPPORT(name_)                     \
@@ -109,17 +93,17 @@ nsPresArena::ClearArenaRefPtrs(ArenaObje
 }
 
 void*
 nsPresArena::Allocate(uint32_t aCode, size_t aSize)
 {
   MOZ_ASSERT(aSize > 0, "PresArena cannot allocate zero bytes");
 
   // We only hand out aligned sizes
-  aSize = PL_ARENA_ALIGN(&mPool, aSize);
+  aSize = mPool.AlignedSize(aSize);
 
   // If there is no free-list entry for this type already, we have
   // to create one now, to record its size.
   FreeList* list = mFreeLists.PutEntry(aCode);
 
   nsTArray<void*>::index_type len = list->mEntries.Length();
   if (list->mEntrySize == 0) {
     MOZ_ASSERT(len == 0, "list with entries but no recorded size");
@@ -157,21 +141,17 @@ nsPresArena::Allocate(uint32_t aCode, si
     }
 #endif
     MOZ_MAKE_MEM_UNDEFINED(result, list->mEntrySize);
     return result;
   }
 
   // Allocate a new chunk from the arena
   list->mEntriesEverAllocated++;
-  PL_ARENA_ALLOCATE(result, &mPool, aSize);
-  if (!result) {
-    NS_ABORT_OOM(aSize);
-  }
-  return result;
+  return mPool.Allocate(aSize);
 }
 
 void
 nsPresArena::Free(uint32_t aCode, void* aPtr)
 {
   // Try to recycle this entry.
   FreeList* list = mFreeLists.GetEntry(aCode);
   MOZ_ASSERT(list, "no free list for pres arena object");
@@ -193,17 +173,17 @@ nsPresArena::AddSizeOfExcludingThis(mozi
   // we wouldn't be able to use aMallocSizeOf on them, since they were
   // allocated out of malloc'd chunks of memory.  So we compute the
   // size of the arena as known by malloc and we add up the sizes of
   // all the objects that we care about.  Subtracting these two
   // quantities gives us a catch-all "other" number, which includes
   // slop in the arena itself as well as the size of objects that
   // we've not measured explicitly.
 
-  size_t mallocSize = PL_SizeOfArenaPoolExcludingPool(&mPool, aMallocSizeOf);
+  size_t mallocSize = mPool.SizeOfExcludingThis(aMallocSizeOf);
   mallocSize += mFreeLists.SizeOfExcludingThis(aMallocSizeOf);
 
   size_t totalSizeInFreeLists = 0;
   for (auto iter = mFreeLists.Iter(); !iter.Done(); iter.Next()) {
     FreeList* entry = iter.Get();
 
     // Note that we're not measuring the size of the entries on the free
     // list here.  The free list knows how many objects we've allocated
--- a/layout/base/nsPresArena.h
+++ b/layout/base/nsPresArena.h
@@ -5,27 +5,27 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
 /* arena allocation for the frame tree and closely-related objects */
 
 #ifndef nsPresArena_h___
 #define nsPresArena_h___
 
+#include "mozilla/ArenaAllocator.h"
 #include "mozilla/ArenaObjectID.h"
 #include "mozilla/ArenaRefPtr.h"
 #include "mozilla/MemoryChecking.h" // Note: Do not remove this, needed for MOZ_HAVE_MEM_CHECKS below
 #include "mozilla/MemoryReporting.h"
 #include <stdint.h>
 #include "nscore.h"
 #include "nsDataHashtable.h"
 #include "nsHashKeys.h"
 #include "nsTArray.h"
 #include "nsTHashtable.h"
-#include "plarena.h"
 
 struct nsArenaMemoryStats;
 
 class nsPresArena {
 public:
   nsPresArena();
   ~nsPresArena();
 
@@ -151,13 +151,13 @@ private:
 
     size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
     { return mEntries.ShallowSizeOfExcludingThis(aMallocSizeOf); }
 
     enum { ALLOW_MEMMOVE = false };
   };
 
   nsTHashtable<FreeList> mFreeLists;
-  PLArenaPool mPool;
+  mozilla::ArenaAllocator<8192, 8> mPool;
   nsDataHashtable<nsPtrHashKey<void>, mozilla::ArenaObjectID> mArenaRefPtrs;
 };
 
 #endif
--- a/layout/generic/moz.build
+++ b/layout/generic/moz.build
@@ -153,16 +153,17 @@ UNIFIED_SOURCES += [
     'nsGridContainerFrame.cpp',
     'nsHTMLCanvasFrame.cpp',
     'nsImageFrame.cpp',
     'nsImageMap.cpp',
     'nsInlineFrame.cpp',
     'nsIntervalSet.cpp',
     'nsLeafFrame.cpp',
     'nsLineBox.cpp',
+    'nsLineLayout.cpp',
     'nsPageContentFrame.cpp',
     'nsPageFrame.cpp',
     'nsPlaceholderFrame.cpp',
     'nsRubyBaseContainerFrame.cpp',
     'nsRubyBaseFrame.cpp',
     'nsRubyContentFrame.cpp',
     'nsRubyFrame.cpp',
     'nsRubyTextContainerFrame.cpp',
@@ -181,20 +182,18 @@ UNIFIED_SOURCES += [
     'ScrollbarActivity.cpp',
     'ScrollSnap.cpp',
     'ScrollVelocityQueue.cpp',
     'StickyScrollContainer.cpp',
     'TextOverflow.cpp',
     'ViewportFrame.cpp',
 ]
 
-# nsLineLayout.cpp needs to be built separately because it uses plarena.h.
 # nsPluginFrame.cpp needs to be built separately because of name clashes in the OS X headers.
 SOURCES += [
-    'nsLineLayout.cpp',
     'nsPluginFrame.cpp',
 ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'
 
 LOCAL_INCLUDES += [
--- a/layout/generic/nsLineLayout.cpp
+++ b/layout/generic/nsLineLayout.cpp
@@ -1,18 +1,15 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* state and methods used while laying out a single line of a block frame */
 
-// This has to be defined before nsLineLayout.h is included, because
-// nsLineLayout.h has a #include for plarena.h, which needs this defined:
-#define PL_ARENA_CONST_ALIGN_MASK (sizeof(void*)-1)
 #include "nsLineLayout.h"
 
 #include "LayoutLogging.h"
 #include "SVGTextFrame.h"
 #include "nsBlockFrame.h"
 #include "nsFontMetrics.h"
 #include "nsStyleConsts.h"
 #include "nsContainerFrame.h"
@@ -106,17 +103,16 @@ nsLineLayout::nsLineLayout(nsPresContext
 
   mInflationMinFontSize =
     nsLayoutUtils::InflationMinFontSizeFor(aOuterReflowInput->mFrame);
 
   // Instead of always pre-initializing the free-lists for frames and
   // spans, we do it on demand so that situations that only use a few
   // frames and spans won't waste a lot of time in unneeded
   // initialization.
-  PL_INIT_ARENA_POOL(&mArena, "nsLineLayout", 1024);
   mFrameFreeList = nullptr;
   mSpanFreeList = nullptr;
 
   mCurrentSpan = mRootSpan = nullptr;
   mSpanDepth = 0;
 
   if (aLine) {
     mGotLineBox = true;
@@ -124,18 +120,16 @@ nsLineLayout::nsLineLayout(nsPresContext
   }
 }
 
 nsLineLayout::~nsLineLayout()
 {
   MOZ_COUNT_DTOR(nsLineLayout);
 
   NS_ASSERTION(nullptr == mRootSpan, "bad line-layout user");
-
-  PL_FinishArenaPool(&mArena);
 }
 
 // Find out if the frame has a non-null prev-in-flow, i.e., whether it
 // is a continuation.
 inline bool
 HasPrevInFlow(nsIFrame *aFrame)
 {
   nsIFrame *prevInFlow = aFrame->GetPrevInFlow();
@@ -381,22 +375,17 @@ nsLineLayout::UpdateBand(WritingMode aWM
 }
 
 nsLineLayout::PerSpanData*
 nsLineLayout::NewPerSpanData()
 {
   nsLineLayout* outerLineLayout = GetOutermostLineLayout();
   PerSpanData* psd = outerLineLayout->mSpanFreeList;
   if (!psd) {
-    void *mem;
-    size_t sz = sizeof(PerSpanData);
-    PL_ARENA_ALLOCATE(mem, &outerLineLayout->mArena, sz);
-    if (!mem) {
-      NS_ABORT_OOM(sz);
-    }
+    void *mem = outerLineLayout->mArena.Allocate(sizeof(PerSpanData));
     psd = reinterpret_cast<PerSpanData*>(mem);
   }
   else {
     outerLineLayout->mSpanFreeList = psd->mNextFreeSpan;
   }
   psd->mParent = nullptr;
   psd->mFrame = nullptr;
   psd->mFirstFrame = nullptr;
@@ -647,22 +636,17 @@ nsLineLayout::IsZeroBSize()
 }
 
 nsLineLayout::PerFrameData*
 nsLineLayout::NewPerFrameData(nsIFrame* aFrame)
 {
   nsLineLayout* outerLineLayout = GetOutermostLineLayout();
   PerFrameData* pfd = outerLineLayout->mFrameFreeList;
   if (!pfd) {
-    void *mem;
-    size_t sz = sizeof(PerFrameData);
-    PL_ARENA_ALLOCATE(mem, &outerLineLayout->mArena, sz);
-    if (!mem) {
-      NS_ABORT_OOM(sz);
-    }
+    void *mem = outerLineLayout->mArena.Allocate(sizeof(PerFrameData));
     pfd = reinterpret_cast<PerFrameData*>(mem);
   }
   else {
     outerLineLayout->mFrameFreeList = pfd->mNext;
   }
   pfd->mSpan = nullptr;
   pfd->mNext = nullptr;
   pfd->mPrev = nullptr;
--- a/layout/generic/nsLineLayout.h
+++ b/layout/generic/nsLineLayout.h
@@ -14,20 +14,20 @@
 
 /* state and methods used while laying out a single line of a block frame */
 
 #ifndef nsLineLayout_h___
 #define nsLineLayout_h___
 
 #include "gfxTypes.h"
 #include "JustificationUtils.h"
+#include "mozilla/ArenaAllocator.h"
 #include "mozilla/WritingModes.h"
 #include "BlockReflowInput.h"
 #include "nsLineBox.h"
-#include "plarena.h"
 
 class nsFloatManager;
 struct nsStyleText;
 
 class nsLineLayout {
   using BlockReflowInput = mozilla::BlockReflowInput;
   using ReflowInput = mozilla::ReflowInput;
   using ReflowOutput = mozilla::ReflowOutput;
@@ -630,17 +630,21 @@ protected:
   bool mHasRuby                 : 1;
   bool mSuppressLineWrap        : 1;
 
   int32_t mSpanDepth;
 #ifdef DEBUG
   int32_t mSpansAllocated, mSpansFreed;
   int32_t mFramesAllocated, mFramesFreed;
 #endif
-  PLArenaPool mArena; // Per span and per frame data, 4 byte aligned
+
+  /**
+   * Per span and per frame data.
+   */
+  mozilla::ArenaAllocator<1024, sizeof(void*)> mArena;
 
   /**
    * Allocate a PerFrameData from the mArena pool. The allocation is infallible.
    */
   PerFrameData* NewPerFrameData(nsIFrame* aFrame);
 
   /**
    * Allocate a PerSpanData from the mArena pool. The allocation is infallible.
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -917,18 +917,16 @@ nsDisplayListBuilder::nsDisplayListBuild
       mWindowDraggingAllowed(false),
       mIsBuildingForPopup(nsLayoutUtils::IsPopup(aReferenceFrame)),
       mForceLayerForScrollParent(false),
       mAsyncPanZoomEnabled(nsLayoutUtils::AsyncPanZoomEnabled(aReferenceFrame)),
       mBuildingInvisibleItems(false),
       mHitTestShouldStopAtFirstOpaque(false)
 {
   MOZ_COUNT_CTOR(nsDisplayListBuilder);
-  PL_InitArenaPool(&mPool, "displayListArena", 4096,
-                   std::max(NS_ALIGNMENT_OF(void*),NS_ALIGNMENT_OF(double))-1);
 
   nsPresContext* pc = aReferenceFrame->PresContext();
   nsIPresShell *shell = pc->PresShell();
   if (pc->IsRenderingOnlySelection()) {
     nsCOMPtr<nsISelectionController> selcon(do_QueryInterface(shell));
     if (selcon) {
       selcon->GetSelection(nsISelectionController::SELECTION_NORMAL,
                            getter_AddRefs(mBoundingSelection));
@@ -1106,17 +1104,16 @@ nsDisplayListBuilder::~nsDisplayListBuil
 
   for (ActiveScrolledRoot* asr : mActiveScrolledRoots) {
     asr->ActiveScrolledRoot::~ActiveScrolledRoot();
   }
   for (DisplayItemClipChain* c : mClipChainsToDestroy) {
     c->DisplayItemClipChain::~DisplayItemClipChain();
   }
 
-  PL_FinishArenaPool(&mPool);
   MOZ_COUNT_DTOR(nsDisplayListBuilder);
 }
 
 uint32_t
 nsDisplayListBuilder::GetBackgroundPaintFlags() {
   uint32_t flags = 0;
   if (mSyncDecodeImages) {
     flags |= nsCSSRendering::PAINTBG_SYNC_DECODE_IMAGES;
@@ -1330,22 +1327,17 @@ nsDisplayListBuilder::MarkPreserve3DFram
       }
     }
   }
 }
 
 void*
 nsDisplayListBuilder::Allocate(size_t aSize)
 {
-  void *tmp;
-  PL_ARENA_ALLOCATE(tmp, &mPool, aSize);
-  if (!tmp) {
-    NS_ABORT_OOM(aSize);
-  }
-  return tmp;
+  return mPool.Allocate(aSize);
 }
 
 ActiveScrolledRoot*
 nsDisplayListBuilder::AllocateActiveScrolledRoot(const ActiveScrolledRoot* aParent,
                                                  nsIScrollableFrame* aScrollableFrame)
 {
   void* p = Allocate(sizeof(ActiveScrolledRoot));
   ActiveScrolledRoot* asr =
--- a/layout/painting/nsDisplayList.h
+++ b/layout/painting/nsDisplayList.h
@@ -8,26 +8,27 @@
 /*
  * structures that represent things to be painted (ordered in z-order),
  * used during painting and hit testing
  */
 
 #ifndef NSDISPLAYLIST_H_
 #define NSDISPLAYLIST_H_
 
+#include "mozilla/ArenaAllocator.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/Array.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/EnumSet.h"
 #include "mozilla/Maybe.h"
+#include "mozilla/TemplateLib.h" // mozilla::tl::Max
 #include "nsCOMPtr.h"
 #include "nsContainerFrame.h"
 #include "nsPoint.h"
 #include "nsRect.h"
-#include "plarena.h"
 #include "nsRegion.h"
 #include "nsDisplayListInvalidation.h"
 #include "nsRenderingContext.h"
 #include "DisplayListClipState.h"
 #include "LayerState.h"
 #include "FrameMetrics.h"
 #include "mozilla/EnumeratedArray.h"
 #include "mozilla/Maybe.h"
@@ -230,17 +231,17 @@ enum class nsDisplayListBuilderMode : ui
   GENERATE_GLYPH,
   PAINTING_SELECTION_BACKGROUND
 };
 
 /**
  * This manages a display list and is passed as a parameter to
  * nsIFrame::BuildDisplayList.
  * It contains the parameters that don't change from frame to frame and manages
- * the display list memory using a PLArena. It also establishes the reference
+ * the display list memory using an arena. It also establishes the reference
  * coordinate system for all display list items. Some of the parameters are
  * available from the prescontext/presshell, but we copy them into the builder
  * for faster/more convenient access.
  */
 class nsDisplayListBuilder {
   typedef mozilla::LayoutDeviceIntRect LayoutDeviceIntRect;
   typedef mozilla::LayoutDeviceIntRegion LayoutDeviceIntRegion;
 
@@ -1450,17 +1451,21 @@ private:
     {}
 
     uint32_t mBudget;
   };
 
   nsIFrame* const                mReferenceFrame;
   nsIFrame*                      mIgnoreScrollFrame;
   nsDisplayLayerEventRegions*    mLayerEventRegions;
-  PLArenaPool                    mPool;
+
+  static const size_t kArenaAlignment =
+      mozilla::tl::Max<NS_ALIGNMENT_OF(void*), NS_ALIGNMENT_OF(double)>::value;
+  mozilla::ArenaAllocator<4096, kArenaAlignment> mPool;
+
   nsCOMPtr<nsISelection>         mBoundingSelection;
   AutoTArray<PresShellState,8> mPresShellStates;
   AutoTArray<nsIFrame*,100>    mFramesMarkedForDisplay;
   AutoTArray<ThemeGeometry,2>  mThemeGeometries;
   nsDisplayTableItem*            mCurrentTableItem;
   DisplayListClipState           mClipState;
   const ActiveScrolledRoot*      mCurrentActiveScrolledRoot;
   const ActiveScrolledRoot*      mCurrentContainerASR;
--- a/layout/style/moz.build
+++ b/layout/style/moz.build
@@ -182,16 +182,17 @@ UNIFIED_SOURCES += [
     'nsComputedDOMStyle.cpp',
     'nsCSSAnonBoxes.cpp',
     'nsCSSDataBlock.cpp',
     'nsCSSKeywords.cpp',
     'nsCSSParser.cpp',
     'nsCSSProps.cpp',
     'nsCSSPseudoClasses.cpp',
     'nsCSSPseudoElements.cpp',
+    'nsCSSRuleProcessor.cpp',
     'nsCSSRules.cpp',
     'nsCSSScanner.cpp',
     'nsCSSValue.cpp',
     'nsDOMCSSAttrDeclaration.cpp',
     'nsDOMCSSDeclaration.cpp',
     'nsDOMCSSRect.cpp',
     'nsDOMCSSRGBColor.cpp',
     'nsDOMCSSValueList.cpp',
@@ -226,22 +227,19 @@ UNIFIED_SOURCES += [
     'ServoStyleRule.cpp',
     'ServoStyleSet.cpp',
     'ServoStyleSheet.cpp',
     'StyleAnimationValue.cpp',
     'StyleRule.cpp',
     'StyleSheet.cpp',
 ]
 
-# - nsCSSRuleProcessor.cpp needs to be built separately because it uses
-# plarena.h.
 # - nsLayoutStylesheetCache.cpp needs to be built separately because it uses
 # nsExceptionHandler.h, which includes windows.h.
 SOURCES += [
-    'nsCSSRuleProcessor.cpp',
     'nsLayoutStylesheetCache.cpp',
 ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'
 
 LOCAL_INCLUDES += [
--- a/layout/style/nsCSSRuleProcessor.cpp
+++ b/layout/style/nsCSSRuleProcessor.cpp
@@ -4,23 +4,16 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /*
  * style rule processor for CSS style sheets, responsible for selector
  * matching and cascading
  */
 
-#define PL_ARENA_CONST_ALIGN_MASK 7
-// We want page-sized arenas so there's no fragmentation involved.
-// Including plarena.h must come first to avoid it being included by some
-// header file thereby making PL_ARENA_CONST_ALIGN_MASK ineffective.
-#define NS_CASCADEENUMDATA_ARENA_BLOCK_SIZE (4096)
-#include "plarena.h"
-
 #include "nsCSSRuleProcessor.h"
 
 #include "nsAutoPtr.h"
 #include "nsRuleProcessorData.h"
 #include <algorithm>
 #include "nsIAtom.h"
 #include "PLDHashTable.h"
 #include "nsICSSPseudoComparator.h"
@@ -59,16 +52,18 @@
 #include "mozilla/OperatorNewExtensions.h"
 #include "mozilla/TypedEnumBits.h"
 #include "RuleProcessorCache.h"
 #include "nsIDOMMutationEvent.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
+typedef ArenaAllocator<4096, 8> CascadeAllocator;
+
 #define VISITED_PSEUDO_PREF "layout.css.visited_links_enabled"
 
 static bool gSupportVisitedPseudo = true;
 
 static nsTArray< nsCOMPtr<nsIAtom> >* sSystemMetrics = 0;
 
 #ifdef XP_WIN
 uint8_t nsCSSRuleProcessor::sWinThemeId = LookAndFeel::eWindowsTheme_Generic;
@@ -3439,20 +3434,18 @@ struct PerWeightDataListItem : public Ru
   PerWeightDataListItem(css::StyleRule* aRule, nsCSSSelector* aSelector)
     : RuleSelectorPair(aRule, aSelector)
     , mNext(nullptr)
   {}
   // No destructor; these are arena-allocated
 
 
   // Placement new to arena allocate the PerWeightDataListItem
-  void *operator new(size_t aSize, PLArenaPool &aArena) CPP_THROW_NEW {
-    void *mem;
-    PL_ARENA_ALLOCATE(mem, &aArena, aSize);
-    return mem;
+  void *operator new(size_t aSize, CascadeAllocator &aArena) CPP_THROW_NEW {
+    return aArena.Allocate(aSize, fallible);
   }
 
   PerWeightDataListItem *mNext;
 };
 
 struct PerWeightData {
   PerWeightData()
     : mRuleSelectorPairs(nullptr)
@@ -3516,36 +3509,33 @@ struct CascadeEnumData {
       mCounterStyleRules(aCounterStyleRules),
       mDocumentRules(aDocumentRules),
       mCacheKey(aKey),
       mDocumentCacheKey(aDocumentKey),
       mRulesByWeight(&gRulesByWeightOps, sizeof(RuleByWeightEntry), 32),
       mSheetType(aSheetType),
       mMustGatherDocumentRules(aMustGatherDocumentRules)
   {
-    // Initialize our arena
-    PL_INIT_ARENA_POOL(&mArena, "CascadeEnumDataArena",
-                       NS_CASCADEENUMDATA_ARENA_BLOCK_SIZE);
   }
 
   ~CascadeEnumData()
   {
-    PL_FinishArenaPool(&mArena);
   }
 
   nsPresContext* mPresContext;
   nsTArray<nsFontFaceRuleContainer>& mFontFaceRules;
   nsTArray<nsCSSKeyframesRule*>& mKeyframesRules;
   nsTArray<nsCSSFontFeatureValuesRule*>& mFontFeatureValuesRules;
   nsTArray<nsCSSPageRule*>& mPageRules;
   nsTArray<nsCSSCounterStyleRule*>& mCounterStyleRules;
   nsTArray<css::DocumentRule*>& mDocumentRules;
   nsMediaQueryResultCacheKey& mCacheKey;
   nsDocumentRuleResultCacheKey& mDocumentCacheKey;
-  PLArenaPool mArena;
+  // We want page-sized arenas so there's no fragmentation involved.
+  CascadeAllocator  mArena;
   // Hooray, a manual PLDHashTable since nsClassHashtable doesn't
   // provide a getter that gives me a *reference* to the value.
   PLDHashTable mRulesByWeight; // of PerWeightDataListItem linked lists
   SheetType mSheetType;
   bool mMustGatherDocumentRules;
 };
 
 /**
--- a/view/moz.build
+++ b/view/moz.build
@@ -7,17 +7,16 @@
 with Files('**'):
     BUG_COMPONENT = ('Core', 'Layout: View Rendering')
 
 EXPORTS += [
     'nsView.h',
     'nsViewManager.h',
 ]
 
-# nsViewManager.cpp cannot be built in unified mode because it uses PL_ARENA_CONST_ALIGN_MASK.
-SOURCES += [
+UNIFIED_SOURCES += [
     'nsView.cpp',
     'nsViewManager.cpp',
 ]
 
 FINAL_LIBRARY = 'xul'
 
 CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
--- a/view/nsViewManager.cpp
+++ b/view/nsViewManager.cpp
@@ -1,16 +1,13 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#define PL_ARENA_CONST_ALIGN_MASK (sizeof(void*)-1)
-#include "plarena.h"
-
 #include "nsAutoPtr.h"
 #include "nsViewManager.h"
 #include "nsGfxCIID.h"
 #include "nsView.h"
 #include "nsCOMPtr.h"
 #include "mozilla/MouseEvents.h"
 #include "nsRegion.h"
 #include "nsCOMArray.h"