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