Bumping manifests a=b2g-bump
[gecko.git] / layout / base / nsArenaMemoryStats.h
blob5d11182b9efa688c0511b0624b17d248b1fdfcbf
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.
21 nsTabSizes() { mozilla::PodZero(this); }
23 void add(Kind kind, size_t n)
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");
33 size_t mDom;
34 size_t mStyle;
35 size_t mOther;
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()
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()
58 void addToTabSizes(nsTabSizes *sizes) const
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
69 size_t getTotalSize() const
71 size_t total = 0;
72 #define ADD_TO_TOTAL_SIZE(kind, mSize) total += mSize;
73 FOR_EACH_SIZE(ADD_TO_TOTAL_SIZE)
74 #undef ADD_TO_TOTAL_SIZE
75 #define FRAME_ID(classname) \
76 total += FRAME_ID_STAT_FIELD(classname);
77 #include "nsFrameIdList.h"
78 #undef FRAME_ID
79 return total;
82 #define DECL_SIZE(kind, mSize) size_t mSize;
83 FOR_EACH_SIZE(DECL_SIZE)
84 #undef DECL_SIZE
85 #define FRAME_ID(classname) size_t FRAME_ID_STAT_FIELD(classname);
86 #include "nsFrameIdList.h"
87 #undef FRAME_ID
88 int dummy; // present just to absorb the trailing comma from FRAME_ID in the
89 // constructor
91 #undef FOR_EACH_SIZE
94 #endif // nsArenaMemoryStats_h