Mercurial > hg > graal-compiler
annotate src/share/vm/services/memReporter.cpp @ 14233:1f480770a1d4
8011391: C1: assert(code_offset() - offset == NativeInstruction::nop_instruction_size) failed: only one instruction can go in a delay slot
Summary: Remove the VerifyOopMaps flag which doesn't work for tiered or for C1 with more compiler threads than one.
Reviewed-by: twisti, drchase, iveresov
author | adlertz |
---|---|
date | Thu, 09 Jan 2014 10:47:40 +0100 |
parents | de6a9e811145 |
children | 4ca6dc0799b6 78bbf4d43a14 |
rev | line source |
---|---|
6197 | 1 /* |
14223
de6a9e811145
8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents:
11052
diff
changeset
|
2 * Copyright (c) 2012, 2013, 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 #include "precompiled.hpp" | |
25 #include "classfile/systemDictionary.hpp" | |
26 #include "runtime/os.hpp" | |
27 #include "services/memReporter.hpp" | |
28 #include "services/memPtrArray.hpp" | |
29 #include "services/memTracker.hpp" | |
30 | |
31 const char* BaselineOutputer::memory_unit(size_t scale) { | |
32 switch(scale) { | |
33 case K: return "KB"; | |
34 case M: return "MB"; | |
35 case G: return "GB"; | |
36 } | |
37 ShouldNotReachHere(); | |
38 return NULL; | |
39 } | |
40 | |
41 | |
42 void BaselineReporter::report_baseline(const MemBaseline& baseline, bool summary_only) { | |
43 assert(MemTracker::is_on(), "Native memory tracking is off"); | |
44 _outputer.start(scale()); | |
45 _outputer.total_usage( | |
46 amount_in_current_scale(baseline.total_malloc_amount() + baseline.total_reserved_amount()), | |
47 amount_in_current_scale(baseline.total_malloc_amount() + baseline.total_committed_amount())); | |
48 | |
49 _outputer.num_of_classes(baseline.number_of_classes()); | |
50 _outputer.num_of_threads(baseline.number_of_threads()); | |
51 | |
52 report_summaries(baseline); | |
53 if (!summary_only && MemTracker::track_callsite()) { | |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
54 report_virtual_memory_map(baseline); |
6197 | 55 report_callsites(baseline); |
56 } | |
57 _outputer.done(); | |
58 } | |
59 | |
60 void BaselineReporter::report_summaries(const MemBaseline& baseline) { | |
61 _outputer.start_category_summary(); | |
62 MEMFLAGS type; | |
63 | |
64 for (int index = 0; index < NUMBER_OF_MEMORY_TYPE; index ++) { | |
65 type = MemBaseline::MemType2NameMap[index]._flag; | |
66 _outputer.category_summary(type, | |
67 amount_in_current_scale(baseline.reserved_amount(type)), | |
68 amount_in_current_scale(baseline.committed_amount(type)), | |
69 amount_in_current_scale(baseline.malloc_amount(type)), | |
70 baseline.malloc_count(type), | |
71 amount_in_current_scale(baseline.arena_amount(type)), | |
72 baseline.arena_count(type)); | |
73 } | |
74 | |
75 _outputer.done_category_summary(); | |
76 } | |
77 | |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
78 void BaselineReporter::report_virtual_memory_map(const MemBaseline& baseline) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
79 _outputer.start_virtual_memory_map(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
80 MemBaseline* pBL = const_cast<MemBaseline*>(&baseline); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
81 MemPointerArrayIteratorImpl itr = MemPointerArrayIteratorImpl(pBL->_vm_map); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
82 VMMemRegionEx* rgn = (VMMemRegionEx*)itr.current(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
83 while (rgn != NULL) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
84 if (rgn->is_reserved_region()) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
85 _outputer.reserved_memory_region(FLAGS_TO_MEMORY_TYPE(rgn->flags()), |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
86 rgn->base(), rgn->base() + rgn->size(), amount_in_current_scale(rgn->size()), rgn->pc()); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
87 } else { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
88 _outputer.committed_memory_region(rgn->base(), rgn->base() + rgn->size(), |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
89 amount_in_current_scale(rgn->size()), rgn->pc()); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
90 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
91 rgn = (VMMemRegionEx*)itr.next(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
92 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
93 |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
94 _outputer.done_virtual_memory_map(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
95 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
96 |
6197 | 97 void BaselineReporter::report_callsites(const MemBaseline& baseline) { |
98 _outputer.start_callsite(); | |
99 MemBaseline* pBL = const_cast<MemBaseline*>(&baseline); | |
100 | |
101 pBL->_malloc_cs->sort((FN_SORT)MemBaseline::bl_malloc_sort_by_size); | |
102 pBL->_vm_cs->sort((FN_SORT)MemBaseline::bl_vm_sort_by_size); | |
103 | |
104 // walk malloc callsites | |
105 MemPointerArrayIteratorImpl malloc_itr(pBL->_malloc_cs); | |
106 MallocCallsitePointer* malloc_callsite = | |
107 (MallocCallsitePointer*)malloc_itr.current(); | |
108 while (malloc_callsite != NULL) { | |
109 _outputer.malloc_callsite(malloc_callsite->addr(), | |
110 amount_in_current_scale(malloc_callsite->amount()), malloc_callsite->count()); | |
111 malloc_callsite = (MallocCallsitePointer*)malloc_itr.next(); | |
112 } | |
113 | |
114 // walk virtual memory callsite | |
115 MemPointerArrayIteratorImpl vm_itr(pBL->_vm_cs); | |
116 VMCallsitePointer* vm_callsite = (VMCallsitePointer*)vm_itr.current(); | |
117 while (vm_callsite != NULL) { | |
118 _outputer.virtual_memory_callsite(vm_callsite->addr(), | |
119 amount_in_current_scale(vm_callsite->reserved_amount()), | |
120 amount_in_current_scale(vm_callsite->committed_amount())); | |
121 vm_callsite = (VMCallsitePointer*)vm_itr.next(); | |
122 } | |
123 pBL->_malloc_cs->sort((FN_SORT)MemBaseline::bl_malloc_sort_by_pc); | |
124 pBL->_vm_cs->sort((FN_SORT)MemBaseline::bl_vm_sort_by_pc); | |
125 _outputer.done_callsite(); | |
126 } | |
127 | |
128 void BaselineReporter::diff_baselines(const MemBaseline& cur, const MemBaseline& prev, | |
129 bool summary_only) { | |
130 assert(MemTracker::is_on(), "Native memory tracking is off"); | |
131 _outputer.start(scale()); | |
132 size_t total_reserved = cur.total_malloc_amount() + cur.total_reserved_amount(); | |
133 size_t total_committed = cur.total_malloc_amount() + cur.total_committed_amount(); | |
134 | |
135 _outputer.diff_total_usage( | |
136 amount_in_current_scale(total_reserved), amount_in_current_scale(total_committed), | |
137 diff_in_current_scale(total_reserved, (prev.total_malloc_amount() + prev.total_reserved_amount())), | |
138 diff_in_current_scale(total_committed, (prev.total_committed_amount() + prev.total_malloc_amount()))); | |
139 | |
140 _outputer.diff_num_of_classes(cur.number_of_classes(), | |
141 diff(cur.number_of_classes(), prev.number_of_classes())); | |
142 _outputer.diff_num_of_threads(cur.number_of_threads(), | |
143 diff(cur.number_of_threads(), prev.number_of_threads())); | |
144 | |
145 diff_summaries(cur, prev); | |
146 if (!summary_only && MemTracker::track_callsite()) { | |
147 diff_callsites(cur, prev); | |
148 } | |
149 _outputer.done(); | |
150 } | |
151 | |
152 void BaselineReporter::diff_summaries(const MemBaseline& cur, const MemBaseline& prev) { | |
153 _outputer.start_category_summary(); | |
154 MEMFLAGS type; | |
155 | |
156 for (int index = 0; index < NUMBER_OF_MEMORY_TYPE; index ++) { | |
157 type = MemBaseline::MemType2NameMap[index]._flag; | |
158 _outputer.diff_category_summary(type, | |
159 amount_in_current_scale(cur.reserved_amount(type)), | |
160 amount_in_current_scale(cur.committed_amount(type)), | |
161 amount_in_current_scale(cur.malloc_amount(type)), | |
162 cur.malloc_count(type), | |
163 amount_in_current_scale(cur.arena_amount(type)), | |
164 cur.arena_count(type), | |
165 diff_in_current_scale(cur.reserved_amount(type), prev.reserved_amount(type)), | |
166 diff_in_current_scale(cur.committed_amount(type), prev.committed_amount(type)), | |
167 diff_in_current_scale(cur.malloc_amount(type), prev.malloc_amount(type)), | |
168 diff(cur.malloc_count(type), prev.malloc_count(type)), | |
169 diff_in_current_scale(cur.arena_amount(type), prev.arena_amount(type)), | |
170 diff(cur.arena_count(type), prev.arena_count(type))); | |
171 } | |
172 | |
173 _outputer.done_category_summary(); | |
174 } | |
175 | |
176 void BaselineReporter::diff_callsites(const MemBaseline& cur, const MemBaseline& prev) { | |
177 _outputer.start_callsite(); | |
178 MemBaseline* pBL_cur = const_cast<MemBaseline*>(&cur); | |
179 MemBaseline* pBL_prev = const_cast<MemBaseline*>(&prev); | |
180 | |
181 // walk malloc callsites | |
182 MemPointerArrayIteratorImpl cur_malloc_itr(pBL_cur->_malloc_cs); | |
183 MemPointerArrayIteratorImpl prev_malloc_itr(pBL_prev->_malloc_cs); | |
184 | |
185 MallocCallsitePointer* cur_malloc_callsite = | |
186 (MallocCallsitePointer*)cur_malloc_itr.current(); | |
187 MallocCallsitePointer* prev_malloc_callsite = | |
188 (MallocCallsitePointer*)prev_malloc_itr.current(); | |
189 | |
190 while (cur_malloc_callsite != NULL || prev_malloc_callsite != NULL) { | |
11052
8cff1de240de
8017478: Kitchensink crashed with SIGSEGV in BaselineReporter::diff_callsites
zgu
parents:
10984
diff
changeset
|
191 if (prev_malloc_callsite == NULL) { |
8cff1de240de
8017478: Kitchensink crashed with SIGSEGV in BaselineReporter::diff_callsites
zgu
parents:
10984
diff
changeset
|
192 assert(cur_malloc_callsite != NULL, "sanity check"); |
10984
cd2118b62475
8013917: Kitchensink crashed with SIGSEGV in BaselineReporter::diff_callsites
zgu
parents:
8668
diff
changeset
|
193 // this is a new callsite |
6197 | 194 _outputer.diff_malloc_callsite(cur_malloc_callsite->addr(), |
195 amount_in_current_scale(cur_malloc_callsite->amount()), | |
196 cur_malloc_callsite->count(), | |
197 diff_in_current_scale(cur_malloc_callsite->amount(), 0), | |
198 diff(cur_malloc_callsite->count(), 0)); | |
199 cur_malloc_callsite = (MallocCallsitePointer*)cur_malloc_itr.next(); | |
11052
8cff1de240de
8017478: Kitchensink crashed with SIGSEGV in BaselineReporter::diff_callsites
zgu
parents:
10984
diff
changeset
|
200 } else if (cur_malloc_callsite == NULL) { |
8cff1de240de
8017478: Kitchensink crashed with SIGSEGV in BaselineReporter::diff_callsites
zgu
parents:
10984
diff
changeset
|
201 assert(prev_malloc_callsite != NULL, "Sanity check"); |
10984
cd2118b62475
8013917: Kitchensink crashed with SIGSEGV in BaselineReporter::diff_callsites
zgu
parents:
8668
diff
changeset
|
202 // this callsite is already gone |
cd2118b62475
8013917: Kitchensink crashed with SIGSEGV in BaselineReporter::diff_callsites
zgu
parents:
8668
diff
changeset
|
203 _outputer.diff_malloc_callsite(prev_malloc_callsite->addr(), |
11052
8cff1de240de
8017478: Kitchensink crashed with SIGSEGV in BaselineReporter::diff_callsites
zgu
parents:
10984
diff
changeset
|
204 0, 0, |
6197 | 205 diff_in_current_scale(0, prev_malloc_callsite->amount()), |
206 diff(0, prev_malloc_callsite->count())); | |
207 prev_malloc_callsite = (MallocCallsitePointer*)prev_malloc_itr.next(); | |
11052
8cff1de240de
8017478: Kitchensink crashed with SIGSEGV in BaselineReporter::diff_callsites
zgu
parents:
10984
diff
changeset
|
208 } else { |
8cff1de240de
8017478: Kitchensink crashed with SIGSEGV in BaselineReporter::diff_callsites
zgu
parents:
10984
diff
changeset
|
209 assert(cur_malloc_callsite != NULL, "Sanity check"); |
8cff1de240de
8017478: Kitchensink crashed with SIGSEGV in BaselineReporter::diff_callsites
zgu
parents:
10984
diff
changeset
|
210 assert(prev_malloc_callsite != NULL, "Sanity check"); |
8cff1de240de
8017478: Kitchensink crashed with SIGSEGV in BaselineReporter::diff_callsites
zgu
parents:
10984
diff
changeset
|
211 if (cur_malloc_callsite->addr() < prev_malloc_callsite->addr()) { |
8cff1de240de
8017478: Kitchensink crashed with SIGSEGV in BaselineReporter::diff_callsites
zgu
parents:
10984
diff
changeset
|
212 // this is a new callsite |
8cff1de240de
8017478: Kitchensink crashed with SIGSEGV in BaselineReporter::diff_callsites
zgu
parents:
10984
diff
changeset
|
213 _outputer.diff_malloc_callsite(cur_malloc_callsite->addr(), |
8cff1de240de
8017478: Kitchensink crashed with SIGSEGV in BaselineReporter::diff_callsites
zgu
parents:
10984
diff
changeset
|
214 amount_in_current_scale(cur_malloc_callsite->amount()), |
8cff1de240de
8017478: Kitchensink crashed with SIGSEGV in BaselineReporter::diff_callsites
zgu
parents:
10984
diff
changeset
|
215 cur_malloc_callsite->count(), |
8cff1de240de
8017478: Kitchensink crashed with SIGSEGV in BaselineReporter::diff_callsites
zgu
parents:
10984
diff
changeset
|
216 diff_in_current_scale(cur_malloc_callsite->amount(), 0), |
8cff1de240de
8017478: Kitchensink crashed with SIGSEGV in BaselineReporter::diff_callsites
zgu
parents:
10984
diff
changeset
|
217 diff(cur_malloc_callsite->count(), 0)); |
8cff1de240de
8017478: Kitchensink crashed with SIGSEGV in BaselineReporter::diff_callsites
zgu
parents:
10984
diff
changeset
|
218 cur_malloc_callsite = (MallocCallsitePointer*)cur_malloc_itr.next(); |
8cff1de240de
8017478: Kitchensink crashed with SIGSEGV in BaselineReporter::diff_callsites
zgu
parents:
10984
diff
changeset
|
219 } else if (cur_malloc_callsite->addr() > prev_malloc_callsite->addr()) { |
8cff1de240de
8017478: Kitchensink crashed with SIGSEGV in BaselineReporter::diff_callsites
zgu
parents:
10984
diff
changeset
|
220 // this callsite is already gone |
8cff1de240de
8017478: Kitchensink crashed with SIGSEGV in BaselineReporter::diff_callsites
zgu
parents:
10984
diff
changeset
|
221 _outputer.diff_malloc_callsite(prev_malloc_callsite->addr(), |
8cff1de240de
8017478: Kitchensink crashed with SIGSEGV in BaselineReporter::diff_callsites
zgu
parents:
10984
diff
changeset
|
222 0, 0, |
8cff1de240de
8017478: Kitchensink crashed with SIGSEGV in BaselineReporter::diff_callsites
zgu
parents:
10984
diff
changeset
|
223 diff_in_current_scale(0, prev_malloc_callsite->amount()), |
8cff1de240de
8017478: Kitchensink crashed with SIGSEGV in BaselineReporter::diff_callsites
zgu
parents:
10984
diff
changeset
|
224 diff(0, prev_malloc_callsite->count())); |
8cff1de240de
8017478: Kitchensink crashed with SIGSEGV in BaselineReporter::diff_callsites
zgu
parents:
10984
diff
changeset
|
225 prev_malloc_callsite = (MallocCallsitePointer*)prev_malloc_itr.next(); |
8cff1de240de
8017478: Kitchensink crashed with SIGSEGV in BaselineReporter::diff_callsites
zgu
parents:
10984
diff
changeset
|
226 } else { |
8cff1de240de
8017478: Kitchensink crashed with SIGSEGV in BaselineReporter::diff_callsites
zgu
parents:
10984
diff
changeset
|
227 // the same callsite |
8cff1de240de
8017478: Kitchensink crashed with SIGSEGV in BaselineReporter::diff_callsites
zgu
parents:
10984
diff
changeset
|
228 _outputer.diff_malloc_callsite(cur_malloc_callsite->addr(), |
8cff1de240de
8017478: Kitchensink crashed with SIGSEGV in BaselineReporter::diff_callsites
zgu
parents:
10984
diff
changeset
|
229 amount_in_current_scale(cur_malloc_callsite->amount()), |
8cff1de240de
8017478: Kitchensink crashed with SIGSEGV in BaselineReporter::diff_callsites
zgu
parents:
10984
diff
changeset
|
230 cur_malloc_callsite->count(), |
8cff1de240de
8017478: Kitchensink crashed with SIGSEGV in BaselineReporter::diff_callsites
zgu
parents:
10984
diff
changeset
|
231 diff_in_current_scale(cur_malloc_callsite->amount(), prev_malloc_callsite->amount()), |
8cff1de240de
8017478: Kitchensink crashed with SIGSEGV in BaselineReporter::diff_callsites
zgu
parents:
10984
diff
changeset
|
232 diff(cur_malloc_callsite->count(), prev_malloc_callsite->count())); |
8cff1de240de
8017478: Kitchensink crashed with SIGSEGV in BaselineReporter::diff_callsites
zgu
parents:
10984
diff
changeset
|
233 cur_malloc_callsite = (MallocCallsitePointer*)cur_malloc_itr.next(); |
8cff1de240de
8017478: Kitchensink crashed with SIGSEGV in BaselineReporter::diff_callsites
zgu
parents:
10984
diff
changeset
|
234 prev_malloc_callsite = (MallocCallsitePointer*)prev_malloc_itr.next(); |
8cff1de240de
8017478: Kitchensink crashed with SIGSEGV in BaselineReporter::diff_callsites
zgu
parents:
10984
diff
changeset
|
235 } |
6197 | 236 } |
237 } | |
238 | |
239 // walk virtual memory callsite | |
240 MemPointerArrayIteratorImpl cur_vm_itr(pBL_cur->_vm_cs); | |
241 MemPointerArrayIteratorImpl prev_vm_itr(pBL_prev->_vm_cs); | |
242 VMCallsitePointer* cur_vm_callsite = (VMCallsitePointer*)cur_vm_itr.current(); | |
243 VMCallsitePointer* prev_vm_callsite = (VMCallsitePointer*)prev_vm_itr.current(); | |
244 while (cur_vm_callsite != NULL || prev_vm_callsite != NULL) { | |
245 if (prev_vm_callsite == NULL || cur_vm_callsite->addr() < prev_vm_callsite->addr()) { | |
10984
cd2118b62475
8013917: Kitchensink crashed with SIGSEGV in BaselineReporter::diff_callsites
zgu
parents:
8668
diff
changeset
|
246 // this is a new callsite |
6197 | 247 _outputer.diff_virtual_memory_callsite(cur_vm_callsite->addr(), |
248 amount_in_current_scale(cur_vm_callsite->reserved_amount()), | |
249 amount_in_current_scale(cur_vm_callsite->committed_amount()), | |
250 diff_in_current_scale(cur_vm_callsite->reserved_amount(), 0), | |
251 diff_in_current_scale(cur_vm_callsite->committed_amount(), 0)); | |
252 cur_vm_callsite = (VMCallsitePointer*)cur_vm_itr.next(); | |
253 } else if (cur_vm_callsite == NULL || cur_vm_callsite->addr() > prev_vm_callsite->addr()) { | |
10984
cd2118b62475
8013917: Kitchensink crashed with SIGSEGV in BaselineReporter::diff_callsites
zgu
parents:
8668
diff
changeset
|
254 // this callsite is already gone |
6197 | 255 _outputer.diff_virtual_memory_callsite(prev_vm_callsite->addr(), |
10984
cd2118b62475
8013917: Kitchensink crashed with SIGSEGV in BaselineReporter::diff_callsites
zgu
parents:
8668
diff
changeset
|
256 amount_in_current_scale(0), |
cd2118b62475
8013917: Kitchensink crashed with SIGSEGV in BaselineReporter::diff_callsites
zgu
parents:
8668
diff
changeset
|
257 amount_in_current_scale(0), |
6197 | 258 diff_in_current_scale(0, prev_vm_callsite->reserved_amount()), |
259 diff_in_current_scale(0, prev_vm_callsite->committed_amount())); | |
260 prev_vm_callsite = (VMCallsitePointer*)prev_vm_itr.next(); | |
261 } else { // the same callsite | |
262 _outputer.diff_virtual_memory_callsite(cur_vm_callsite->addr(), | |
263 amount_in_current_scale(cur_vm_callsite->reserved_amount()), | |
264 amount_in_current_scale(cur_vm_callsite->committed_amount()), | |
265 diff_in_current_scale(cur_vm_callsite->reserved_amount(), prev_vm_callsite->reserved_amount()), | |
266 diff_in_current_scale(cur_vm_callsite->committed_amount(), prev_vm_callsite->committed_amount())); | |
267 cur_vm_callsite = (VMCallsitePointer*)cur_vm_itr.next(); | |
268 prev_vm_callsite = (VMCallsitePointer*)prev_vm_itr.next(); | |
269 } | |
270 } | |
271 | |
272 _outputer.done_callsite(); | |
273 } | |
274 | |
275 size_t BaselineReporter::amount_in_current_scale(size_t amt) const { | |
276 return (size_t)(((float)amt/(float)_scale) + 0.5); | |
277 } | |
278 | |
279 int BaselineReporter::diff_in_current_scale(size_t value1, size_t value2) const { | |
280 return (int)(((float)value1 - (float)value2)/((float)_scale) + 0.5); | |
281 } | |
282 | |
283 int BaselineReporter::diff(size_t value1, size_t value2) const { | |
284 return ((int)value1 - (int)value2); | |
285 } | |
286 | |
287 void BaselineTTYOutputer::start(size_t scale, bool report_diff) { | |
288 _scale = scale; | |
289 _output->print_cr(" "); | |
290 _output->print_cr("Native Memory Tracking:"); | |
291 _output->print_cr(" "); | |
292 } | |
293 | |
294 void BaselineTTYOutputer::done() { | |
295 | |
296 } | |
297 | |
298 void BaselineTTYOutputer::total_usage(size_t total_reserved, size_t total_committed) { | |
299 const char* unit = memory_unit(_scale); | |
300 _output->print_cr("Total: reserved=%d%s, committed=%d%s", | |
301 total_reserved, unit, total_committed, unit); | |
302 } | |
303 | |
304 void BaselineTTYOutputer::start_category_summary() { | |
305 _output->print_cr(" "); | |
306 } | |
307 | |
308 /** | |
309 * report a summary of memory type | |
310 */ | |
311 void BaselineTTYOutputer::category_summary(MEMFLAGS type, | |
312 size_t reserved_amt, size_t committed_amt, size_t malloc_amt, | |
313 size_t malloc_count, size_t arena_amt, size_t arena_count) { | |
314 | |
315 // we report mtThreadStack under mtThread category | |
316 if (type == mtThreadStack) { | |
317 assert(malloc_amt == 0 && malloc_count == 0 && arena_amt == 0, | |
318 "Just check"); | |
319 _thread_stack_reserved = reserved_amt; | |
320 _thread_stack_committed = committed_amt; | |
321 } else { | |
322 const char* unit = memory_unit(_scale); | |
323 size_t total_reserved = (reserved_amt + malloc_amt + arena_amt); | |
324 size_t total_committed = (committed_amt + malloc_amt + arena_amt); | |
325 if (type == mtThread) { | |
326 total_reserved += _thread_stack_reserved; | |
327 total_committed += _thread_stack_committed; | |
328 } | |
329 | |
330 if (total_reserved > 0) { | |
331 _output->print_cr("-%26s (reserved=%d%s, committed=%d%s)", | |
332 MemBaseline::type2name(type), total_reserved, unit, | |
333 total_committed, unit); | |
334 | |
335 if (type == mtClass) { | |
336 _output->print_cr("%27s (classes #%d)", " ", _num_of_classes); | |
337 } else if (type == mtThread) { | |
338 _output->print_cr("%27s (thread #%d)", " ", _num_of_threads); | |
339 _output->print_cr("%27s (stack: reserved=%d%s, committed=%d%s)", " ", | |
340 _thread_stack_reserved, unit, _thread_stack_committed, unit); | |
341 } | |
342 | |
343 if (malloc_amt > 0) { | |
344 if (type != mtChunk) { | |
345 _output->print_cr("%27s (malloc=%d%s, #%d)", " ", malloc_amt, unit, | |
346 malloc_count); | |
347 } else { | |
348 _output->print_cr("%27s (malloc=%d%s)", " ", malloc_amt, unit); | |
349 } | |
350 } | |
351 | |
352 if (reserved_amt > 0) { | |
353 _output->print_cr("%27s (mmap: reserved=%d%s, committed=%d%s)", | |
354 " ", reserved_amt, unit, committed_amt, unit); | |
355 } | |
356 | |
357 if (arena_amt > 0) { | |
358 _output->print_cr("%27s (arena=%d%s, #%d)", " ", arena_amt, unit, arena_count); | |
359 } | |
360 | |
361 _output->print_cr(" "); | |
362 } | |
363 } | |
364 } | |
365 | |
366 void BaselineTTYOutputer::done_category_summary() { | |
367 _output->print_cr(" "); | |
368 } | |
369 | |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
370 |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
371 void BaselineTTYOutputer::start_virtual_memory_map() { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
372 _output->print_cr("Virtual memory map:"); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
373 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
374 |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
375 void BaselineTTYOutputer::reserved_memory_region(MEMFLAGS type, address base, address end, |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
376 size_t size, address pc) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
377 const char* unit = memory_unit(_scale); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
378 char buf[128]; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
379 int offset; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
380 _output->print_cr(" "); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
381 _output->print_cr("[" PTR_FORMAT " - " PTR_FORMAT "] reserved %d%s for %s", base, end, size, unit, |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
382 MemBaseline::type2name(type)); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
383 if (os::dll_address_to_function_name(pc, buf, sizeof(buf), &offset)) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
384 _output->print_cr("\t\tfrom [%s+0x%x]", buf, offset); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
385 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
386 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
387 |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
388 void BaselineTTYOutputer::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:
6197
diff
changeset
|
389 const char* unit = memory_unit(_scale); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
390 char buf[128]; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
391 int offset; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
392 _output->print("\t[" PTR_FORMAT " - " PTR_FORMAT "] committed %d%s", base, end, size, unit); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
393 if (os::dll_address_to_function_name(pc, buf, sizeof(buf), &offset)) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
394 _output->print_cr(" from [%s+0x%x]", buf, offset); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
395 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
396 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
397 |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
398 void BaselineTTYOutputer::done_virtual_memory_map() { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
399 _output->print_cr(" "); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
400 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
401 |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
402 |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
403 |
6197 | 404 void BaselineTTYOutputer::start_callsite() { |
405 _output->print_cr("Details:"); | |
406 _output->print_cr(" "); | |
407 } | |
408 | |
409 void BaselineTTYOutputer::done_callsite() { | |
410 _output->print_cr(" "); | |
411 } | |
412 | |
413 void BaselineTTYOutputer::malloc_callsite(address pc, size_t malloc_amt, | |
414 size_t malloc_count) { | |
415 if (malloc_amt > 0) { | |
416 const char* unit = memory_unit(_scale); | |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
417 char buf[128]; |
6197 | 418 int offset; |
419 if (pc == 0) { | |
420 _output->print("[BOOTSTRAP]%18s", " "); | |
421 } else if (os::dll_address_to_function_name(pc, buf, sizeof(buf), &offset)) { | |
422 _output->print_cr("[" PTR_FORMAT "] %s+0x%x", pc, buf, offset); | |
423 _output->print("%28s", " "); | |
424 } else { | |
425 _output->print("[" PTR_FORMAT "]%18s", pc, " "); | |
426 } | |
427 | |
428 _output->print_cr("(malloc=%d%s #%d)", malloc_amt, unit, malloc_count); | |
429 _output->print_cr(" "); | |
430 } | |
431 } | |
432 | |
433 void BaselineTTYOutputer::virtual_memory_callsite(address pc, size_t reserved_amt, | |
434 size_t committed_amt) { | |
435 if (reserved_amt > 0) { | |
436 const char* unit = memory_unit(_scale); | |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
437 char buf[128]; |
6197 | 438 int offset; |
439 if (pc == 0) { | |
440 _output->print("[BOOTSTRAP]%18s", " "); | |
441 } else if (os::dll_address_to_function_name(pc, buf, sizeof(buf), &offset)) { | |
442 _output->print_cr("[" PTR_FORMAT "] %s+0x%x", pc, buf, offset); | |
443 _output->print("%28s", " "); | |
444 } else { | |
8668 | 445 _output->print("[" PTR_FORMAT "]%18s", pc, " "); |
6197 | 446 } |
447 | |
448 _output->print_cr("(mmap: reserved=%d%s, committed=%d%s)", | |
449 reserved_amt, unit, committed_amt, unit); | |
450 _output->print_cr(" "); | |
451 } | |
452 } | |
453 | |
454 void BaselineTTYOutputer::diff_total_usage(size_t total_reserved, | |
455 size_t total_committed, int reserved_diff, int committed_diff) { | |
456 const char* unit = memory_unit(_scale); | |
457 _output->print_cr("Total: reserved=%d%s %+d%s, committed=%d%s %+d%s", | |
458 total_reserved, unit, reserved_diff, unit, total_committed, unit, | |
459 committed_diff, unit); | |
460 } | |
461 | |
462 void BaselineTTYOutputer::diff_category_summary(MEMFLAGS type, | |
463 size_t cur_reserved_amt, size_t cur_committed_amt, | |
464 size_t cur_malloc_amt, size_t cur_malloc_count, | |
465 size_t cur_arena_amt, size_t cur_arena_count, | |
466 int reserved_diff, int committed_diff, int malloc_diff, | |
467 int malloc_count_diff, int arena_diff, int arena_count_diff) { | |
468 | |
469 if (type == mtThreadStack) { | |
470 assert(cur_malloc_amt == 0 && cur_malloc_count == 0 && | |
471 cur_arena_amt == 0, "Just check"); | |
472 _thread_stack_reserved = cur_reserved_amt; | |
473 _thread_stack_committed = cur_committed_amt; | |
474 _thread_stack_reserved_diff = reserved_diff; | |
475 _thread_stack_committed_diff = committed_diff; | |
476 } else { | |
477 const char* unit = memory_unit(_scale); | |
478 size_t total_reserved = (cur_reserved_amt + cur_malloc_amt + cur_arena_amt); | |
479 // nothing to report in this category | |
480 if (total_reserved == 0) { | |
481 return; | |
482 } | |
483 int diff_reserved = (reserved_diff + malloc_diff + arena_diff); | |
484 | |
485 // category summary | |
486 _output->print("-%26s (reserved=%d%s", MemBaseline::type2name(type), | |
487 total_reserved, unit); | |
488 | |
489 if (diff_reserved != 0) { | |
490 _output->print(" %+d%s", diff_reserved, unit); | |
491 } | |
492 | |
493 size_t total_committed = cur_committed_amt + cur_malloc_amt + cur_arena_amt; | |
494 _output->print(", committed=%d%s", total_committed, unit); | |
495 | |
496 int total_committed_diff = committed_diff + malloc_diff + arena_diff; | |
497 if (total_committed_diff != 0) { | |
498 _output->print(" %+d%s", total_committed_diff, unit); | |
499 } | |
500 | |
501 _output->print_cr(")"); | |
502 | |
503 // special cases | |
504 if (type == mtClass) { | |
505 _output->print("%27s (classes #%d", " ", _num_of_classes); | |
506 if (_num_of_classes_diff != 0) { | |
507 _output->print(" %+d", _num_of_classes_diff); | |
508 } | |
509 _output->print_cr(")"); | |
510 } else if (type == mtThread) { | |
511 // thread count | |
512 _output->print("%27s (thread #%d", " ", _num_of_threads); | |
513 if (_num_of_threads_diff != 0) { | |
514 _output->print_cr(" %+d)", _num_of_threads_diff); | |
515 } else { | |
516 _output->print_cr(")"); | |
517 } | |
518 _output->print("%27s (stack: reserved=%d%s", " ", _thread_stack_reserved, unit); | |
519 if (_thread_stack_reserved_diff != 0) { | |
520 _output->print(" %+d%s", _thread_stack_reserved_diff, unit); | |
521 } | |
522 | |
523 _output->print(", committed=%d%s", _thread_stack_committed, unit); | |
524 if (_thread_stack_committed_diff != 0) { | |
525 _output->print(" %+d%s",_thread_stack_committed_diff, unit); | |
526 } | |
527 | |
528 _output->print_cr(")"); | |
529 } | |
530 | |
531 // malloc'd memory | |
532 if (cur_malloc_amt > 0) { | |
533 _output->print("%27s (malloc=%d%s", " ", cur_malloc_amt, unit); | |
534 if (malloc_diff != 0) { | |
535 _output->print(" %+d%s", malloc_diff, unit); | |
536 } | |
537 if (type != mtChunk) { | |
538 _output->print(", #%d", cur_malloc_count); | |
539 if (malloc_count_diff) { | |
540 _output->print(" %+d", malloc_count_diff); | |
541 } | |
542 } | |
543 _output->print_cr(")"); | |
544 } | |
545 | |
546 // mmap'd memory | |
547 if (cur_reserved_amt > 0) { | |
548 _output->print("%27s (mmap: reserved=%d%s", " ", cur_reserved_amt, unit); | |
549 if (reserved_diff != 0) { | |
550 _output->print(" %+d%s", reserved_diff, unit); | |
551 } | |
552 | |
553 _output->print(", committed=%d%s", cur_committed_amt, unit); | |
554 if (committed_diff != 0) { | |
555 _output->print(" %+d%s", committed_diff, unit); | |
556 } | |
557 _output->print_cr(")"); | |
558 } | |
559 | |
560 // arena memory | |
561 if (cur_arena_amt > 0) { | |
562 _output->print("%27s (arena=%d%s", " ", cur_arena_amt, unit); | |
563 if (arena_diff != 0) { | |
564 _output->print(" %+d%s", arena_diff, unit); | |
565 } | |
566 _output->print(", #%d", cur_arena_count); | |
567 if (arena_count_diff != 0) { | |
568 _output->print(" %+d", arena_count_diff); | |
569 } | |
570 _output->print_cr(")"); | |
571 } | |
572 | |
573 _output->print_cr(" "); | |
574 } | |
575 } | |
576 | |
577 void BaselineTTYOutputer::diff_malloc_callsite(address pc, | |
578 size_t cur_malloc_amt, size_t cur_malloc_count, | |
579 int malloc_diff, int malloc_count_diff) { | |
580 if (malloc_diff != 0) { | |
581 const char* unit = memory_unit(_scale); | |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6197
diff
changeset
|
582 char buf[128]; |
6197 | 583 int offset; |
584 if (pc == 0) { | |
585 _output->print_cr("[BOOTSTRAP]%18s", " "); | |
586 } else { | |
587 if (os::dll_address_to_function_name(pc, buf, sizeof(buf), &offset)) { | |
588 _output->print_cr("[" PTR_FORMAT "] %s+0x%x", pc, buf, offset); | |
589 _output->print("%28s", " "); | |
590 } else { | |
591 _output->print("[" PTR_FORMAT "]%18s", pc, " "); | |
592 } | |
593 } | |
594 | |
595 _output->print("(malloc=%d%s", cur_malloc_amt, unit); | |
596 if (malloc_diff != 0) { | |
597 _output->print(" %+d%s", malloc_diff, unit); | |
598 } | |
599 _output->print(", #%d", cur_malloc_count); | |
600 if (malloc_count_diff != 0) { | |
601 _output->print(" %+d", malloc_count_diff); | |
602 } | |
603 _output->print_cr(")"); | |
604 _output->print_cr(" "); | |
605 } | |
606 } | |
607 | |
608 void BaselineTTYOutputer::diff_virtual_memory_callsite(address pc, | |
609 size_t cur_reserved_amt, size_t cur_committed_amt, | |
610 int reserved_diff, int committed_diff) { | |
611 if (reserved_diff != 0 || committed_diff != 0) { | |
612 const char* unit = memory_unit(_scale); | |
613 char buf[64]; | |
614 int offset; | |
615 if (pc == 0) { | |
616 _output->print_cr("[BOOSTRAP]%18s", " "); | |
617 } else { | |
618 if (os::dll_address_to_function_name(pc, buf, sizeof(buf), &offset)) { | |
619 _output->print_cr("[" PTR_FORMAT "] %s+0x%x", pc, buf, offset); | |
620 _output->print("%28s", " "); | |
621 } else { | |
8668 | 622 _output->print("[" PTR_FORMAT "]%18s", pc, " "); |
6197 | 623 } |
624 } | |
625 | |
626 _output->print("(mmap: reserved=%d%s", cur_reserved_amt, unit); | |
627 if (reserved_diff != 0) { | |
628 _output->print(" %+d%s", reserved_diff, unit); | |
629 } | |
630 _output->print(", committed=%d%s", cur_committed_amt, unit); | |
631 if (committed_diff != 0) { | |
632 _output->print(" %+d%s", committed_diff, unit); | |
633 } | |
634 _output->print_cr(")"); | |
635 _output->print_cr(" "); | |
636 } | |
637 } |