layout/base/nsArenaMemoryStats.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/base/nsArenaMemoryStats.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,81 @@
     1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim: set ts=8 sts=2 et sw=2 tw=80: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef nsArenaMemoryStats_h
    1.11 +#define nsArenaMemoryStats_h
    1.12 +
    1.13 +#include "mozilla/Assertions.h"
    1.14 +#include "mozilla/PodOperations.h"
    1.15 +
    1.16 +class nsTabSizes {
    1.17 +public:
    1.18 +  enum Kind {
    1.19 +      DOM,        // DOM stuff.
    1.20 +      Style,      // Style stuff.
    1.21 +      Other       // Everything else.
    1.22 +  };
    1.23 +
    1.24 +  nsTabSizes() { mozilla::PodZero(this); }
    1.25 +
    1.26 +  void add(Kind kind, size_t n)
    1.27 +  {
    1.28 +    switch (kind) {
    1.29 +      case DOM:   mDom   += n; break;
    1.30 +      case Style: mStyle += n; break;
    1.31 +      case Other: mOther += n; break;
    1.32 +      default:    MOZ_CRASH("bad nsTabSizes kind");
    1.33 +    }
    1.34 +  }
    1.35 +
    1.36 +  size_t mDom;
    1.37 +  size_t mStyle;
    1.38 +  size_t mOther;
    1.39 +};
    1.40 +
    1.41 +#define FRAME_ID_STAT_FIELD(classname) mArena##classname
    1.42 +
    1.43 +struct nsArenaMemoryStats {
    1.44 +#define FOR_EACH_SIZE(macro) \
    1.45 +  macro(Other, mLineBoxes) \
    1.46 +  macro(Style, mRuleNodes) \
    1.47 +  macro(Style, mStyleContexts) \
    1.48 +  macro(Other, mOther)
    1.49 +
    1.50 +  nsArenaMemoryStats()
    1.51 +    :
    1.52 +      #define ZERO_SIZE(kind, mSize) mSize(0),
    1.53 +      FOR_EACH_SIZE(ZERO_SIZE)
    1.54 +      #undef ZERO_SIZE
    1.55 +      #define FRAME_ID(classname) FRAME_ID_STAT_FIELD(classname)(),
    1.56 +      #include "nsFrameIdList.h"
    1.57 +      #undef FRAME_ID
    1.58 +      dummy()
    1.59 +  {}
    1.60 +
    1.61 +  void addToTabSizes(nsTabSizes *sizes) const
    1.62 +  {
    1.63 +    #define ADD_TO_TAB_SIZES(kind, mSize) sizes->add(nsTabSizes::kind, mSize);
    1.64 +    FOR_EACH_SIZE(ADD_TO_TAB_SIZES)
    1.65 +    #undef ADD_TO_TAB_SIZES
    1.66 +    #define FRAME_ID(classname) \
    1.67 +      sizes->add(nsTabSizes::Other, FRAME_ID_STAT_FIELD(classname));
    1.68 +    #include "nsFrameIdList.h"
    1.69 +    #undef FRAME_ID
    1.70 +  }
    1.71 +
    1.72 +  #define DECL_SIZE(kind, mSize) size_t mSize;
    1.73 +  FOR_EACH_SIZE(DECL_SIZE)
    1.74 +  #undef DECL_SIZE
    1.75 +  #define FRAME_ID(classname) size_t FRAME_ID_STAT_FIELD(classname);
    1.76 +  #include "nsFrameIdList.h"
    1.77 +  #undef FRAME_ID
    1.78 +  int dummy;  // present just to absorb the trailing comma from FRAME_ID in the
    1.79 +              // constructor
    1.80 +
    1.81 +#undef FOR_EACH_SIZE
    1.82 +};
    1.83 +
    1.84 +#endif // nsArenaMemoryStats_h

mercurial