Mercurial > hg > truffle
annotate src/share/vm/services/memReporter.hpp @ 7811:94ea9a864fc6
Remove usages of VmIds.toString.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Mon, 18 Feb 2013 19:08:52 -0800 |
parents | 79f492f184d0 |
children | db9981fd3124 |
rev | line source |
---|---|
6197 | 1 /* |
7440 | 2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
6197 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 * | |
23 */ | |
24 | |
25 #ifndef SHARE_VM_SERVICES_MEM_REPORTER_HPP | |
26 #define SHARE_VM_SERVICES_MEM_REPORTER_HPP | |
27 | |
28 #include "runtime/mutexLocker.hpp" | |
29 #include "services/memBaseline.hpp" | |
30 #include "services/memTracker.hpp" | |
31 #include "utilities/ostream.hpp" | |
32 | |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6197
diff
changeset
|
33 #if INCLUDE_NMT |
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6197
diff
changeset
|
34 |
6197 | 35 /* |
36 * MemBaselineReporter reports data to this outputer class, | |
37 * ReportOutputer is responsible for format, store and redirect | |
38 * the data to the final destination. | |
39 */ | |
40 class BaselineOutputer : public StackObj { | |
41 public: | |
42 // start to report memory usage in specified scale. | |
43 // if report_diff = true, the reporter reports baseline comparison | |
44 // information. | |
45 | |
46 virtual void start(size_t scale, bool report_diff = false) = 0; | |
47 // Done reporting | |
48 virtual void done() = 0; | |
49 | |
50 /* report baseline summary information */ | |
51 virtual void total_usage(size_t total_reserved, | |
52 size_t total_committed) = 0; | |
53 virtual void num_of_classes(size_t classes) = 0; | |
54 virtual void num_of_threads(size_t threads) = 0; | |
55 | |
56 virtual void thread_info(size_t stack_reserved_amt, size_t stack_committed_amt) = 0; | |
57 | |
58 /* report baseline summary comparison */ | |
59 virtual void diff_total_usage(size_t total_reserved, | |
60 size_t total_committed, | |
61 int reserved_diff, | |
62 int committed_diff) = 0; | |
63 virtual void diff_num_of_classes(size_t classes, int diff) = 0; | |
64 virtual void diff_num_of_threads(size_t threads, int diff) = 0; | |
65 | |
66 virtual void diff_thread_info(size_t stack_reserved, size_t stack_committed, | |
67 int stack_reserved_diff, int stack_committed_diff) = 0; | |
68 | |
69 | |
70 /* | |
71 * memory summary by memory types. | |
72 * for each memory type, following summaries are reported: | |
73 * - reserved amount, committed amount | |
74 * - malloc'd amount, malloc count | |
75 * - arena amount, arena count | |
76 */ | |
77 | |
78 // start reporting memory summary by memory type | |
79 virtual void start_category_summary() = 0; | |
80 | |
81 virtual void category_summary(MEMFLAGS type, size_t reserved_amt, | |
82 size_t committed_amt, | |
83 size_t malloc_amt, size_t malloc_count, | |
84 size_t arena_amt, size_t arena_count) = 0; | |
85 | |
86 virtual void diff_category_summary(MEMFLAGS type, size_t cur_reserved_amt, | |
87 size_t cur_committed_amt, | |
88 size_t cur_malloc_amt, size_t cur_malloc_count, | |
89 size_t cur_arena_amt, size_t cur_arena_count, | |
90 int reserved_diff, int committed_diff, int malloc_diff, | |
91 int malloc_count_diff, int arena_diff, | |
92 int arena_count_diff) = 0; | |
93 | |
94 virtual void done_category_summary() = 0; | |
95 | |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6854
diff
changeset
|
96 virtual void start_virtual_memory_map() = 0; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6854
diff
changeset
|
97 virtual void reserved_memory_region(MEMFLAGS type, address base, address end, size_t size, address pc) = 0; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6854
diff
changeset
|
98 virtual void committed_memory_region(address base, address end, size_t size, address pc) = 0; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6854
diff
changeset
|
99 virtual void done_virtual_memory_map() = 0; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6854
diff
changeset
|
100 |
6197 | 101 /* |
102 * Report callsite information | |
103 */ | |
104 virtual void start_callsite() = 0; | |
105 virtual void malloc_callsite(address pc, size_t malloc_amt, size_t malloc_count) = 0; | |
106 virtual void virtual_memory_callsite(address pc, size_t reserved_amt, size_t committed_amt) = 0; | |
107 | |
108 virtual void diff_malloc_callsite(address pc, size_t cur_malloc_amt, size_t cur_malloc_count, | |
109 int malloc_diff, int malloc_count_diff) = 0; | |
110 virtual void diff_virtual_memory_callsite(address pc, size_t cur_reserved_amt, size_t cur_committed_amt, | |
111 int reserved_diff, int committed_diff) = 0; | |
112 | |
113 virtual void done_callsite() = 0; | |
114 | |
115 // return current scale in "KB", "MB" or "GB" | |
116 static const char* memory_unit(size_t scale); | |
117 }; | |
118 | |
119 /* | |
120 * This class reports processed data from a baseline or | |
121 * the changes between the two baseline. | |
122 */ | |
123 class BaselineReporter : public StackObj { | |
124 private: | |
125 BaselineOutputer& _outputer; | |
126 size_t _scale; | |
127 | |
128 public: | |
129 // construct a reporter that reports memory usage | |
130 // in specified scale | |
131 BaselineReporter(BaselineOutputer& outputer, size_t scale = K): | |
132 _outputer(outputer) { | |
133 _scale = scale; | |
134 } | |
135 virtual void report_baseline(const MemBaseline& baseline, bool summary_only = false); | |
136 virtual void diff_baselines(const MemBaseline& cur, const MemBaseline& prev, | |
137 bool summary_only = false); | |
138 | |
139 void set_scale(size_t scale); | |
140 size_t scale() const { return _scale; } | |
141 | |
142 private: | |
143 void report_summaries(const MemBaseline& baseline); | |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6854
diff
changeset
|
144 void report_virtual_memory_map(const MemBaseline& baseline); |
6197 | 145 void report_callsites(const MemBaseline& baseline); |
146 | |
147 void diff_summaries(const MemBaseline& cur, const MemBaseline& prev); | |
148 void diff_callsites(const MemBaseline& cur, const MemBaseline& prev); | |
149 | |
150 // calculate memory size in current memory scale | |
151 size_t amount_in_current_scale(size_t amt) const; | |
152 // diff two unsigned values in current memory scale | |
153 int diff_in_current_scale(size_t value1, size_t value2) const; | |
154 // diff two unsigned value | |
155 int diff(size_t value1, size_t value2) const; | |
156 }; | |
157 | |
158 /* | |
159 * tty output implementation. Native memory tracking | |
160 * DCmd uses this outputer. | |
161 */ | |
162 class BaselineTTYOutputer : public BaselineOutputer { | |
163 private: | |
164 size_t _scale; | |
165 | |
166 size_t _num_of_classes; | |
167 size_t _num_of_threads; | |
168 size_t _thread_stack_reserved; | |
169 size_t _thread_stack_committed; | |
170 | |
171 int _num_of_classes_diff; | |
172 int _num_of_threads_diff; | |
173 int _thread_stack_reserved_diff; | |
174 int _thread_stack_committed_diff; | |
175 | |
176 outputStream* _output; | |
177 | |
178 public: | |
179 BaselineTTYOutputer(outputStream* st) { | |
180 _scale = K; | |
181 _num_of_classes = 0; | |
182 _num_of_threads = 0; | |
183 _thread_stack_reserved = 0; | |
184 _thread_stack_committed = 0; | |
185 _num_of_classes_diff = 0; | |
186 _num_of_threads_diff = 0; | |
187 _thread_stack_reserved_diff = 0; | |
188 _thread_stack_committed_diff = 0; | |
189 _output = st; | |
190 } | |
191 | |
192 // begin reporting memory usage in specified scale | |
193 void start(size_t scale, bool report_diff = false); | |
194 // done reporting | |
195 void done(); | |
196 | |
197 // total memory usage | |
198 void total_usage(size_t total_reserved, | |
199 size_t total_committed); | |
200 // report total loaded classes | |
201 void num_of_classes(size_t classes) { | |
202 _num_of_classes = classes; | |
203 } | |
204 | |
205 void num_of_threads(size_t threads) { | |
206 _num_of_threads = threads; | |
207 } | |
208 | |
209 void thread_info(size_t stack_reserved_amt, size_t stack_committed_amt) { | |
210 _thread_stack_reserved = stack_reserved_amt; | |
211 _thread_stack_committed = stack_committed_amt; | |
212 } | |
213 | |
214 void diff_total_usage(size_t total_reserved, | |
215 size_t total_committed, | |
216 int reserved_diff, | |
217 int committed_diff); | |
218 | |
219 void diff_num_of_classes(size_t classes, int diff) { | |
220 _num_of_classes = classes; | |
221 _num_of_classes_diff = diff; | |
222 } | |
223 | |
224 void diff_num_of_threads(size_t threads, int diff) { | |
225 _num_of_threads = threads; | |
226 _num_of_threads_diff = diff; | |
227 } | |
228 | |
229 void diff_thread_info(size_t stack_reserved_amt, size_t stack_committed_amt, | |
230 int stack_reserved_diff, int stack_committed_diff) { | |
231 _thread_stack_reserved = stack_reserved_amt; | |
232 _thread_stack_committed = stack_committed_amt; | |
233 _thread_stack_reserved_diff = stack_reserved_diff; | |
234 _thread_stack_committed_diff = stack_committed_diff; | |
235 } | |
236 | |
237 /* | |
238 * Report memory summary categoriuzed by memory types. | |
239 * For each memory type, following summaries are reported: | |
240 * - reserved amount, committed amount | |
241 * - malloc-ed amount, malloc count | |
242 * - arena amount, arena count | |
243 */ | |
244 // start reporting memory summary by memory type | |
245 void start_category_summary(); | |
246 void category_summary(MEMFLAGS type, size_t reserved_amt, size_t committed_amt, | |
247 size_t malloc_amt, size_t malloc_count, | |
248 size_t arena_amt, size_t arena_count); | |
249 | |
250 void diff_category_summary(MEMFLAGS type, size_t cur_reserved_amt, | |
251 size_t cur_committed_amt, | |
252 size_t cur_malloc_amt, size_t cur_malloc_count, | |
253 size_t cur_arena_amt, size_t cur_arena_count, | |
254 int reserved_diff, int committed_diff, int malloc_diff, | |
255 int malloc_count_diff, int arena_diff, | |
256 int arena_count_diff); | |
257 | |
258 void done_category_summary(); | |
259 | |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6854
diff
changeset
|
260 // virtual memory map |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6854
diff
changeset
|
261 void start_virtual_memory_map(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6854
diff
changeset
|
262 void reserved_memory_region(MEMFLAGS type, address base, address end, size_t size, address pc); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6854
diff
changeset
|
263 void committed_memory_region(address base, address end, size_t size, address pc); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6854
diff
changeset
|
264 void done_virtual_memory_map(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6854
diff
changeset
|
265 |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6854
diff
changeset
|
266 |
6197 | 267 /* |
268 * Report callsite information | |
269 */ | |
270 void start_callsite(); | |
271 void malloc_callsite(address pc, size_t malloc_amt, size_t malloc_count); | |
272 void virtual_memory_callsite(address pc, size_t reserved_amt, size_t committed_amt); | |
273 | |
274 void diff_malloc_callsite(address pc, size_t cur_malloc_amt, size_t cur_malloc_count, | |
275 int malloc_diff, int malloc_count_diff); | |
276 void diff_virtual_memory_callsite(address pc, size_t cur_reserved_amt, size_t cur_committed_amt, | |
277 int reserved_diff, int committed_diff); | |
278 | |
279 void done_callsite(); | |
280 }; | |
281 | |
282 | |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6197
diff
changeset
|
283 #endif // INCLUDE_NMT |
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6197
diff
changeset
|
284 |
6197 | 285 #endif // SHARE_VM_SERVICES_MEM_REPORTER_HPP |