layout/base/nsArenaMemoryStats.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
     3 /* This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 #ifndef nsArenaMemoryStats_h
     8 #define nsArenaMemoryStats_h
    10 #include "mozilla/Assertions.h"
    11 #include "mozilla/PodOperations.h"
    13 class nsTabSizes {
    14 public:
    15   enum Kind {
    16       DOM,        // DOM stuff.
    17       Style,      // Style stuff.
    18       Other       // Everything else.
    19   };
    21   nsTabSizes() { mozilla::PodZero(this); }
    23   void add(Kind kind, size_t n)
    24   {
    25     switch (kind) {
    26       case DOM:   mDom   += n; break;
    27       case Style: mStyle += n; break;
    28       case Other: mOther += n; break;
    29       default:    MOZ_CRASH("bad nsTabSizes kind");
    30     }
    31   }
    33   size_t mDom;
    34   size_t mStyle;
    35   size_t mOther;
    36 };
    38 #define FRAME_ID_STAT_FIELD(classname) mArena##classname
    40 struct nsArenaMemoryStats {
    41 #define FOR_EACH_SIZE(macro) \
    42   macro(Other, mLineBoxes) \
    43   macro(Style, mRuleNodes) \
    44   macro(Style, mStyleContexts) \
    45   macro(Other, mOther)
    47   nsArenaMemoryStats()
    48     :
    49       #define ZERO_SIZE(kind, mSize) mSize(0),
    50       FOR_EACH_SIZE(ZERO_SIZE)
    51       #undef ZERO_SIZE
    52       #define FRAME_ID(classname) FRAME_ID_STAT_FIELD(classname)(),
    53       #include "nsFrameIdList.h"
    54       #undef FRAME_ID
    55       dummy()
    56   {}
    58   void addToTabSizes(nsTabSizes *sizes) const
    59   {
    60     #define ADD_TO_TAB_SIZES(kind, mSize) sizes->add(nsTabSizes::kind, mSize);
    61     FOR_EACH_SIZE(ADD_TO_TAB_SIZES)
    62     #undef ADD_TO_TAB_SIZES
    63     #define FRAME_ID(classname) \
    64       sizes->add(nsTabSizes::Other, FRAME_ID_STAT_FIELD(classname));
    65     #include "nsFrameIdList.h"
    66     #undef FRAME_ID
    67   }
    69   #define DECL_SIZE(kind, mSize) size_t mSize;
    70   FOR_EACH_SIZE(DECL_SIZE)
    71   #undef DECL_SIZE
    72   #define FRAME_ID(classname) size_t FRAME_ID_STAT_FIELD(classname);
    73   #include "nsFrameIdList.h"
    74   #undef FRAME_ID
    75   int dummy;  // present just to absorb the trailing comma from FRAME_ID in the
    76               // constructor
    78 #undef FOR_EACH_SIZE
    79 };
    81 #endif // nsArenaMemoryStats_h

mercurial