michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set ts=8 sts=2 et sw=2 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsArenaMemoryStats_h michael@0: #define nsArenaMemoryStats_h michael@0: michael@0: #include "mozilla/Assertions.h" michael@0: #include "mozilla/PodOperations.h" michael@0: michael@0: class nsTabSizes { michael@0: public: michael@0: enum Kind { michael@0: DOM, // DOM stuff. michael@0: Style, // Style stuff. michael@0: Other // Everything else. michael@0: }; michael@0: michael@0: nsTabSizes() { mozilla::PodZero(this); } michael@0: michael@0: void add(Kind kind, size_t n) michael@0: { michael@0: switch (kind) { michael@0: case DOM: mDom += n; break; michael@0: case Style: mStyle += n; break; michael@0: case Other: mOther += n; break; michael@0: default: MOZ_CRASH("bad nsTabSizes kind"); michael@0: } michael@0: } michael@0: michael@0: size_t mDom; michael@0: size_t mStyle; michael@0: size_t mOther; michael@0: }; michael@0: michael@0: #define FRAME_ID_STAT_FIELD(classname) mArena##classname michael@0: michael@0: struct nsArenaMemoryStats { michael@0: #define FOR_EACH_SIZE(macro) \ michael@0: macro(Other, mLineBoxes) \ michael@0: macro(Style, mRuleNodes) \ michael@0: macro(Style, mStyleContexts) \ michael@0: macro(Other, mOther) michael@0: michael@0: nsArenaMemoryStats() michael@0: : michael@0: #define ZERO_SIZE(kind, mSize) mSize(0), michael@0: FOR_EACH_SIZE(ZERO_SIZE) michael@0: #undef ZERO_SIZE michael@0: #define FRAME_ID(classname) FRAME_ID_STAT_FIELD(classname)(), michael@0: #include "nsFrameIdList.h" michael@0: #undef FRAME_ID michael@0: dummy() michael@0: {} michael@0: michael@0: void addToTabSizes(nsTabSizes *sizes) const michael@0: { michael@0: #define ADD_TO_TAB_SIZES(kind, mSize) sizes->add(nsTabSizes::kind, mSize); michael@0: FOR_EACH_SIZE(ADD_TO_TAB_SIZES) michael@0: #undef ADD_TO_TAB_SIZES michael@0: #define FRAME_ID(classname) \ michael@0: sizes->add(nsTabSizes::Other, FRAME_ID_STAT_FIELD(classname)); michael@0: #include "nsFrameIdList.h" michael@0: #undef FRAME_ID michael@0: } michael@0: michael@0: #define DECL_SIZE(kind, mSize) size_t mSize; michael@0: FOR_EACH_SIZE(DECL_SIZE) michael@0: #undef DECL_SIZE michael@0: #define FRAME_ID(classname) size_t FRAME_ID_STAT_FIELD(classname); michael@0: #include "nsFrameIdList.h" michael@0: #undef FRAME_ID michael@0: int dummy; // present just to absorb the trailing comma from FRAME_ID in the michael@0: // constructor michael@0: michael@0: #undef FOR_EACH_SIZE michael@0: }; michael@0: michael@0: #endif // nsArenaMemoryStats_h