Bug 732976 - SingleSourceFactory should generate checksums file. r=ted
[gecko.git] / js / public / MemoryMetrics.h
blob513db5b5e26b966cf4ea75df8ca1d7329aff9913
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
15 * License.
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.
24 * Contributor(s):
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.
48 #include <string.h>
50 #include "jsalloc.h"
51 #include "jspubtd.h"
53 #include "js/Utility.h"
54 #include "js/Vector.h"
56 namespace JS {
58 /* Data for tracking analysis/inference memory usage. */
59 struct TypeInferenceSizes
61 size_t scripts;
62 size_t objects;
63 size_t tables;
64 size_t temporary;
67 struct CompartmentStats
69 CompartmentStats() {
70 memset(this, 0, sizeof(*this));
73 void *extra;
74 size_t gcHeapArenaHeaders;
75 size_t gcHeapArenaPadding;
76 size_t gcHeapArenaUnused;
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;
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;
98 #ifdef JS_METHODJIT
99 size_t mjitCode;
100 size_t mjitData;
101 #endif
102 TypeInferenceSizes typeInferenceSizes;
105 struct RuntimeStats
107 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 , 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;
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;
164 js::Vector<CompartmentStats, 0, js::SystemAllocPolicy> compartmentStatsVector;
165 CompartmentStats *currCompartmentStats;
167 JSMallocSizeOfFun mallocSizeOf;
169 virtual void initExtraCompartmentStats(JSCompartment *c, CompartmentStats *cstats) = 0;
172 #ifdef JS_THREADSAFE
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);
188 } // namespace JS
190 #endif // js_MemoryMetrics_h