LCOV - code coverage report
Current view: top level - layout/base - nsArenaMemoryStats.h (source / functions) Hit Total Coverage
Test: output.info Lines: 8 19 42.1 %
Date: 2017-07-14 16:53:18 Functions: 2 5 40.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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/. */
       6             : 
       7             : #ifndef nsArenaMemoryStats_h
       8             : #define nsArenaMemoryStats_h
       9             : 
      10             : #include "mozilla/Assertions.h"
      11             : #include "mozilla/PodOperations.h"
      12             : 
      13             : class nsTabSizes {
      14             : public:
      15             :   enum Kind {
      16             :       DOM,        // DOM stuff.
      17             :       Style,      // Style stuff.
      18             :       Other       // Everything else.
      19             :   };
      20             : 
      21           0 :   nsTabSizes() { mozilla::PodZero(this); }
      22             : 
      23           0 :   void add(Kind kind, size_t n)
      24             :   {
      25           0 :     switch (kind) {
      26           0 :       case DOM:   mDom   += n; break;
      27           0 :       case Style: mStyle += n; break;
      28           0 :       case Other: mOther += n; break;
      29           0 :       default:    MOZ_CRASH("bad nsTabSizes kind");
      30             :     }
      31           0 :   }
      32             : 
      33             :   size_t mDom;
      34             :   size_t mStyle;
      35             :   size_t mOther;
      36             : };
      37             : 
      38             : #define FRAME_ID_STAT_FIELD(classname) mArena##classname
      39             : 
      40             : struct nsArenaMemoryStats {
      41             : #define FOR_EACH_SIZE(macro) \
      42             :   macro(Other, mLineBoxes) \
      43             :   macro(Style, mRuleNodes) \
      44             :   macro(Style, mStyleContexts) \
      45             :   macro(Style, mStyleStructs) \
      46             :   macro(Other, mOther)
      47             : 
      48          21 :   nsArenaMemoryStats()
      49          21 :     :
      50             :       #define ZERO_SIZE(kind, mSize) mSize(0),
      51             :       FOR_EACH_SIZE(ZERO_SIZE)
      52             :       #undef ZERO_SIZE
      53             :       #define FRAME_ID(classname, ...) FRAME_ID_STAT_FIELD(classname)(),
      54             :       #define ABSTRACT_FRAME_ID(...)
      55             :       #include "nsFrameIdList.h"
      56             :       #undef FRAME_ID
      57             :       #undef ABSTRACT_FRAME_ID
      58          21 :       dummy()
      59          21 :   {}
      60             : 
      61           0 :   void addToTabSizes(nsTabSizes *sizes) const
      62             :   {
      63             :     #define ADD_TO_TAB_SIZES(kind, mSize) sizes->add(nsTabSizes::kind, mSize);
      64           0 :     FOR_EACH_SIZE(ADD_TO_TAB_SIZES)
      65             :     #undef ADD_TO_TAB_SIZES
      66             :     #define FRAME_ID(classname, ...) \
      67             :       sizes->add(nsTabSizes::Other, FRAME_ID_STAT_FIELD(classname));
      68             :     #define ABSTRACT_FRAME_ID(...)
      69             :     #include "nsFrameIdList.h"
      70             :     #undef FRAME_ID
      71             :     #undef ABSTRACT_FRAME_ID
      72           0 :   }
      73             : 
      74          42 :   size_t getTotalSize() const
      75             :   {
      76          42 :     size_t total = 0;
      77             :     #define ADD_TO_TOTAL_SIZE(kind, mSize) total += mSize;
      78          42 :     FOR_EACH_SIZE(ADD_TO_TOTAL_SIZE)
      79             :     #undef ADD_TO_TOTAL_SIZE
      80             :     #define FRAME_ID(classname, ...) \
      81             :       total += FRAME_ID_STAT_FIELD(classname);
      82             :     #define ABSTRACT_FRAME_ID(...)
      83             :     #include "nsFrameIdList.h"
      84             :     #undef FRAME_ID
      85             :     #undef ABSTRACT_FRAME_ID
      86          42 :     return total;
      87             :   }
      88             : 
      89             :   #define DECL_SIZE(kind, mSize) size_t mSize;
      90             :   FOR_EACH_SIZE(DECL_SIZE)
      91             :   #undef DECL_SIZE
      92             :   #define FRAME_ID(classname, ...) size_t FRAME_ID_STAT_FIELD(classname);
      93             :   #define ABSTRACT_FRAME_ID(...)
      94             :   #include "nsFrameIdList.h"
      95             :   #undef FRAME_ID
      96             :   #undef ABSTRACT_FRAME_ID
      97             :   int dummy;  // present just to absorb the trailing comma from FRAME_ID in the
      98             :               // constructor
      99             : 
     100             : #undef FOR_EACH_SIZE
     101             : };
     102             : 
     103             : #endif // nsArenaMemoryStats_h

Generated by: LCOV version 1.13