LCOV - code coverage report
Current view: directory - objdir/dist/include/js - MemoryMetrics.h (source / functions) Found Hit Coverage
Test: app.info Lines: 8 8 100.0 %
Date: 2012-06-02 Functions: 4 4 100.0 %

       1                 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
       2                 :  * vim: set ts=8 sw=4 et tw=99 ft=cpp:
       3                 :  *
       4                 :  * ***** BEGIN LICENSE BLOCK *****
       5                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       6                 :  *
       7                 :  * The contents of this file are subject to the Mozilla Public License Version
       8                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       9                 :  * the License. You may obtain a copy of the License at
      10                 :  * http://www.mozilla.org/MPL/
      11                 :  *
      12                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      13                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      14                 :  * for the specific language governing rights and limitations under the
      15                 :  * License.
      16                 :  *
      17                 :  * The Original Code is about:memory glue.
      18                 :  *
      19                 :  * The Initial Developer of the Original Code is
      20                 :  * Ms2ger <ms2ger@gmail.com>.
      21                 :  * Portions created by the Initial Developer are Copyright (C) 2011
      22                 :  * the Initial Developer. All Rights Reserved.
      23                 :  *
      24                 :  * Contributor(s):
      25                 :  *
      26                 :  * Alternatively, the contents of this file may be used under the terms of
      27                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      28                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      29                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      30                 :  * of those above. If you wish to allow use of your version of this file only
      31                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      32                 :  * use your version of this file under the terms of the MPL, indicate your
      33                 :  * decision by deleting the provisions above and replace them with the notice
      34                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      35                 :  * the provisions above, a recipient may use your version of this file under
      36                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      37                 :  *
      38                 :  * ***** END LICENSE BLOCK ***** */
      39                 : 
      40                 : #ifndef js_MemoryMetrics_h
      41                 : #define js_MemoryMetrics_h
      42                 : 
      43                 : /*
      44                 :  * These declarations are not within jsapi.h because they are highly likely
      45                 :  * to change in the future. Depend on them at your own risk.
      46                 :  */
      47                 : 
      48                 : #include <string.h>
      49                 : 
      50                 : #include "jsalloc.h"
      51                 : #include "jspubtd.h"
      52                 : 
      53                 : #include "js/Utility.h"
      54                 : #include "js/Vector.h"
      55                 : 
      56                 : namespace JS {
      57                 : 
      58                 : /* Data for tracking analysis/inference memory usage. */
      59                 : struct TypeInferenceSizes
      60                 : {
      61                 :     size_t scripts;
      62                 :     size_t objects;
      63                 :     size_t tables;
      64                 :     size_t temporary;
      65                 : };
      66                 : 
      67                 : struct CompartmentStats
      68               9 : {
      69               9 :     CompartmentStats() {
      70               9 :         memset(this, 0, sizeof(*this));
      71               9 :     }
      72                 : 
      73                 :     void   *extra;
      74                 :     size_t gcHeapArenaHeaders;
      75                 :     size_t gcHeapArenaPadding;
      76                 :     size_t gcHeapArenaUnused;
      77                 : 
      78                 :     size_t gcHeapObjectsNonFunction;
      79                 :     size_t gcHeapObjectsFunction;
      80                 :     size_t gcHeapStrings;
      81                 :     size_t gcHeapShapesTree;
      82                 :     size_t gcHeapShapesDict;
      83                 :     size_t gcHeapShapesBase;
      84                 :     size_t gcHeapScripts;
      85                 :     size_t gcHeapTypeObjects;
      86                 :     size_t gcHeapXML;
      87                 : 
      88                 :     size_t objectSlots;
      89                 :     size_t objectElements;
      90                 :     size_t objectMisc;
      91                 :     size_t stringChars;
      92                 :     size_t shapesExtraTreeTables;
      93                 :     size_t shapesExtraDictTables;
      94                 :     size_t shapesExtraTreeShapeKids;
      95                 :     size_t shapesCompartmentTables;
      96                 :     size_t scriptData;
      97                 : 
      98                 : #ifdef JS_METHODJIT
      99                 :     size_t mjitCode;
     100                 :     size_t mjitData;
     101                 : #endif
     102                 :     TypeInferenceSizes typeInferenceSizes;
     103                 : };
     104                 : 
     105                 : struct RuntimeStats
     106               3 : {
     107               3 :     RuntimeStats(JSMallocSizeOfFun mallocSizeOf)
     108                 :       : runtimeObject(0)
     109                 :       , runtimeAtomsTable(0)
     110                 :       , runtimeContexts(0)
     111                 :       , runtimeNormal(0)
     112                 :       , runtimeTemporary(0)
     113                 :       , runtimeRegexpCode(0)
     114                 :       , runtimeStackCommitted(0)
     115                 :       , runtimeGCMarker(0)
     116                 :       , gcHeapChunkTotal(0)
     117                 :       , gcHeapChunkCleanUnused(0)
     118                 :       , gcHeapChunkDirtyUnused(0)
     119                 :       , gcHeapChunkCleanDecommitted(0)
     120                 :       , gcHeapChunkDirtyDecommitted(0)
     121                 :       , gcHeapArenaUnused(0)
     122                 :       , gcHeapChunkAdmin(0)
     123                 :       , gcHeapUnusedPercentage(0)
     124                 :       , totalObjects(0)
     125                 :       , totalShapes(0)
     126                 :       , totalScripts(0)
     127                 :       , totalStrings(0)
     128                 : #ifdef JS_METHODJIT
     129                 :       , totalMjit(0)
     130                 : #endif
     131                 :       , totalTypeInference(0)
     132                 :       , totalAnalysisTemp(0)
     133                 :       , compartmentStatsVector()
     134                 :       , currCompartmentStats(NULL)
     135               3 :       , mallocSizeOf(mallocSizeOf)
     136               3 :     {}
     137                 : 
     138                 :     size_t runtimeObject;
     139                 :     size_t runtimeAtomsTable;
     140                 :     size_t runtimeContexts;
     141                 :     size_t runtimeNormal;
     142                 :     size_t runtimeTemporary;
     143                 :     size_t runtimeRegexpCode;
     144                 :     size_t runtimeStackCommitted;
     145                 :     size_t runtimeGCMarker;
     146                 :     size_t gcHeapChunkTotal;
     147                 :     size_t gcHeapChunkCleanUnused;
     148                 :     size_t gcHeapChunkDirtyUnused;
     149                 :     size_t gcHeapChunkCleanDecommitted;
     150                 :     size_t gcHeapChunkDirtyDecommitted;
     151                 :     size_t gcHeapArenaUnused;
     152                 :     size_t gcHeapChunkAdmin;
     153                 :     size_t gcHeapUnusedPercentage;
     154                 :     size_t totalObjects;
     155                 :     size_t totalShapes;
     156                 :     size_t totalScripts;
     157                 :     size_t totalStrings;
     158                 : #ifdef JS_METHODJIT
     159                 :     size_t totalMjit;
     160                 : #endif
     161                 :     size_t totalTypeInference;
     162                 :     size_t totalAnalysisTemp;
     163                 : 
     164                 :     js::Vector<CompartmentStats, 0, js::SystemAllocPolicy> compartmentStatsVector;
     165                 :     CompartmentStats *currCompartmentStats;
     166                 : 
     167                 :     JSMallocSizeOfFun mallocSizeOf;
     168                 : 
     169                 :     virtual void initExtraCompartmentStats(JSCompartment *c, CompartmentStats *cstats) = 0;
     170                 : };
     171                 : 
     172                 : #ifdef JS_THREADSAFE
     173                 : 
     174                 : extern JS_PUBLIC_API(bool)
     175                 : CollectRuntimeStats(JSRuntime *rt, RuntimeStats *rtStats);
     176                 : 
     177                 : extern JS_PUBLIC_API(int64_t)
     178                 : GetExplicitNonHeapForRuntime(JSRuntime *rt, JSMallocSizeOfFun mallocSizeOf);
     179                 : 
     180                 : #endif /* JS_THREADSAFE */
     181                 : 
     182                 : extern JS_PUBLIC_API(size_t)
     183                 : SystemCompartmentCount(const JSRuntime *rt);
     184                 : 
     185                 : extern JS_PUBLIC_API(size_t)
     186                 : UserCompartmentCount(const JSRuntime *rt);
     187                 : 
     188                 : } // namespace JS
     189                 : 
     190                 : #endif // js_MemoryMetrics_h

Generated by: LCOV version 1.7