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:
4 * ***** BEGIN LICENSE BLOCK *****
5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
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/
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
17 * The Original Code is about:memory glue.
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.
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.
38 * ***** END LICENSE BLOCK ***** */
40 #ifndef js_MemoryMetrics_h
41 #define js_MemoryMetrics_h
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.
53 #include "js/Utility.h"
54 #include "js/Vector.h"
58 /* Data for tracking analysis/inference memory usage. */
59 struct TypeInferenceSizes
67 struct CompartmentStats
70 memset(this, 0, sizeof(*this));
74 size_t gcHeapArenaHeaders
;
75 size_t gcHeapArenaPadding
;
76 size_t gcHeapArenaUnused
;
78 size_t gcHeapObjectsNonFunction
;
79 size_t gcHeapObjectsFunction
;
81 size_t gcHeapShapesTree
;
82 size_t gcHeapShapesDict
;
83 size_t gcHeapShapesBase
;
85 size_t gcHeapTypeObjects
;
89 size_t objectElements
;
92 size_t shapesExtraTreeTables
;
93 size_t shapesExtraDictTables
;
94 size_t shapesExtraTreeShapeKids
;
95 size_t shapesCompartmentTables
;
102 TypeInferenceSizes typeInferenceSizes
;
107 RuntimeStats(JSMallocSizeOfFun mallocSizeOf
)
109 , runtimeAtomsTable(0)
112 , runtimeTemporary(0)
113 , runtimeRegexpCode(0)
114 , runtimeStackCommitted(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)
131 , totalTypeInference(0)
132 , totalAnalysisTemp(0)
133 , compartmentStatsVector()
134 , currCompartmentStats(NULL
)
135 , mallocSizeOf(mallocSizeOf
)
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
;
161 size_t totalTypeInference
;
162 size_t totalAnalysisTemp
;
164 js::Vector
<CompartmentStats
, 0, js::SystemAllocPolicy
> compartmentStatsVector
;
165 CompartmentStats
*currCompartmentStats
;
167 JSMallocSizeOfFun mallocSizeOf
;
169 virtual void initExtraCompartmentStats(JSCompartment
*c
, CompartmentStats
*cstats
) = 0;
174 extern JS_PUBLIC_API(bool)
175 CollectRuntimeStats(JSRuntime
*rt
, RuntimeStats
*rtStats
);
177 extern JS_PUBLIC_API(int64_t)
178 GetExplicitNonHeapForRuntime(JSRuntime
*rt
, JSMallocSizeOfFun mallocSizeOf
);
180 #endif /* JS_THREADSAFE */
182 extern JS_PUBLIC_API(size_t)
183 SystemCompartmentCount(const JSRuntime
*rt
);
185 extern JS_PUBLIC_API(size_t)
186 UserCompartmentCount(const JSRuntime
*rt
);
190 #endif // js_MemoryMetrics_h