src/share/vm/services/memReporter.cpp

Thu, 20 Dec 2012 16:24:51 -0800

author
katleman
date
Thu, 20 Dec 2012 16:24:51 -0800
changeset 4376
79f492f184d0
parent 4193
716c64bda5ba
child 4668
3c9db54c2660
permissions
-rw-r--r--

8004982: JDK8 source with GPL header errors
Reviewed-by: ohair

     1 /*
     2  * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
     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"
    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 }
    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()));
    49   _outputer.num_of_classes(baseline.number_of_classes());
    50   _outputer.num_of_threads(baseline.number_of_threads());
    52   report_summaries(baseline);
    53   if (!summary_only && MemTracker::track_callsite()) {
    54     report_virtual_memory_map(baseline);
    55     report_callsites(baseline);
    56   }
    57   _outputer.done();
    58 }
    60 void BaselineReporter::report_summaries(const MemBaseline& baseline) {
    61   _outputer.start_category_summary();
    62   MEMFLAGS type;
    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   }
    75   _outputer.done_category_summary();
    76 }
    78 void BaselineReporter::report_virtual_memory_map(const MemBaseline& baseline) {
    79   _outputer.start_virtual_memory_map();
    80   MemBaseline* pBL = const_cast<MemBaseline*>(&baseline);
    81   MemPointerArrayIteratorImpl itr = MemPointerArrayIteratorImpl(pBL->_vm_map);
    82   VMMemRegionEx* rgn = (VMMemRegionEx*)itr.current();
    83   while (rgn != NULL) {
    84     if (rgn->is_reserved_region()) {
    85       _outputer.reserved_memory_region(FLAGS_TO_MEMORY_TYPE(rgn->flags()),
    86         rgn->base(), rgn->base() + rgn->size(), amount_in_current_scale(rgn->size()), rgn->pc());
    87     } else {
    88       _outputer.committed_memory_region(rgn->base(), rgn->base() + rgn->size(),
    89         amount_in_current_scale(rgn->size()), rgn->pc());
    90     }
    91     rgn = (VMMemRegionEx*)itr.next();
    92   }
    94   _outputer.done_virtual_memory_map();
    95 }
    97 void BaselineReporter::report_callsites(const MemBaseline& baseline) {
    98   _outputer.start_callsite();
    99   MemBaseline* pBL = const_cast<MemBaseline*>(&baseline);
   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);
   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   }
   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 }
   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();
   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())));
   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()));
   145   diff_summaries(cur, prev);
   146   if (!summary_only && MemTracker::track_callsite()) {
   147     diff_callsites(cur, prev);
   148   }
   149   _outputer.done();
   150 }
   152 void BaselineReporter::diff_summaries(const MemBaseline& cur, const MemBaseline& prev) {
   153   _outputer.start_category_summary();
   154   MEMFLAGS type;
   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   }
   173   _outputer.done_category_summary();
   174 }
   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);
   181   // walk malloc callsites
   182   MemPointerArrayIteratorImpl cur_malloc_itr(pBL_cur->_malloc_cs);
   183   MemPointerArrayIteratorImpl prev_malloc_itr(pBL_prev->_malloc_cs);
   185   MallocCallsitePointer*      cur_malloc_callsite =
   186                   (MallocCallsitePointer*)cur_malloc_itr.current();
   187   MallocCallsitePointer*      prev_malloc_callsite =
   188                   (MallocCallsitePointer*)prev_malloc_itr.current();
   190   while (cur_malloc_callsite != NULL || prev_malloc_callsite != NULL) {
   191     if (prev_malloc_callsite == NULL ||
   192         cur_malloc_callsite->addr() < prev_malloc_callsite->addr()) {
   193       _outputer.diff_malloc_callsite(cur_malloc_callsite->addr(),
   194         amount_in_current_scale(cur_malloc_callsite->amount()),
   195         cur_malloc_callsite->count(),
   196         diff_in_current_scale(cur_malloc_callsite->amount(), 0),
   197         diff(cur_malloc_callsite->count(), 0));
   198       cur_malloc_callsite = (MallocCallsitePointer*)cur_malloc_itr.next();
   199     } else if (prev_malloc_callsite == NULL ||
   200                cur_malloc_callsite->addr() > prev_malloc_callsite->addr()) {
   201       _outputer.diff_malloc_callsite(cur_malloc_callsite->addr(),
   202         amount_in_current_scale(prev_malloc_callsite->amount()),
   203         prev_malloc_callsite->count(),
   204         diff_in_current_scale(0, prev_malloc_callsite->amount()),
   205         diff(0, prev_malloc_callsite->count()));
   206       prev_malloc_callsite = (MallocCallsitePointer*)prev_malloc_itr.next();
   207     } else {  // the same callsite
   208       _outputer.diff_malloc_callsite(cur_malloc_callsite->addr(),
   209         amount_in_current_scale(cur_malloc_callsite->amount()),
   210         cur_malloc_callsite->count(),
   211         diff_in_current_scale(cur_malloc_callsite->amount(), prev_malloc_callsite->amount()),
   212         diff(cur_malloc_callsite->count(), prev_malloc_callsite->count()));
   213       cur_malloc_callsite = (MallocCallsitePointer*)cur_malloc_itr.next();
   214       prev_malloc_callsite = (MallocCallsitePointer*)prev_malloc_itr.next();
   215     }
   216   }
   218   // walk virtual memory callsite
   219   MemPointerArrayIteratorImpl cur_vm_itr(pBL_cur->_vm_cs);
   220   MemPointerArrayIteratorImpl prev_vm_itr(pBL_prev->_vm_cs);
   221   VMCallsitePointer*          cur_vm_callsite = (VMCallsitePointer*)cur_vm_itr.current();
   222   VMCallsitePointer*          prev_vm_callsite = (VMCallsitePointer*)prev_vm_itr.current();
   223   while (cur_vm_callsite != NULL || prev_vm_callsite != NULL) {
   224     if (prev_vm_callsite == NULL || cur_vm_callsite->addr() < prev_vm_callsite->addr()) {
   225       _outputer.diff_virtual_memory_callsite(cur_vm_callsite->addr(),
   226         amount_in_current_scale(cur_vm_callsite->reserved_amount()),
   227         amount_in_current_scale(cur_vm_callsite->committed_amount()),
   228         diff_in_current_scale(cur_vm_callsite->reserved_amount(), 0),
   229         diff_in_current_scale(cur_vm_callsite->committed_amount(), 0));
   230       cur_vm_callsite = (VMCallsitePointer*)cur_vm_itr.next();
   231     } else if (cur_vm_callsite == NULL || cur_vm_callsite->addr() > prev_vm_callsite->addr()) {
   232       _outputer.diff_virtual_memory_callsite(prev_vm_callsite->addr(),
   233         amount_in_current_scale(prev_vm_callsite->reserved_amount()),
   234         amount_in_current_scale(prev_vm_callsite->committed_amount()),
   235         diff_in_current_scale(0, prev_vm_callsite->reserved_amount()),
   236         diff_in_current_scale(0, prev_vm_callsite->committed_amount()));
   237       prev_vm_callsite = (VMCallsitePointer*)prev_vm_itr.next();
   238     } else { // the same callsite
   239       _outputer.diff_virtual_memory_callsite(cur_vm_callsite->addr(),
   240         amount_in_current_scale(cur_vm_callsite->reserved_amount()),
   241         amount_in_current_scale(cur_vm_callsite->committed_amount()),
   242         diff_in_current_scale(cur_vm_callsite->reserved_amount(), prev_vm_callsite->reserved_amount()),
   243         diff_in_current_scale(cur_vm_callsite->committed_amount(), prev_vm_callsite->committed_amount()));
   244       cur_vm_callsite  = (VMCallsitePointer*)cur_vm_itr.next();
   245       prev_vm_callsite = (VMCallsitePointer*)prev_vm_itr.next();
   246     }
   247   }
   249   _outputer.done_callsite();
   250 }
   252 size_t BaselineReporter::amount_in_current_scale(size_t amt) const {
   253   return (size_t)(((float)amt/(float)_scale) + 0.5);
   254 }
   256 int BaselineReporter::diff_in_current_scale(size_t value1, size_t value2) const {
   257   return (int)(((float)value1 - (float)value2)/((float)_scale) + 0.5);
   258 }
   260 int BaselineReporter::diff(size_t value1, size_t value2) const {
   261   return ((int)value1 - (int)value2);
   262 }
   264 void BaselineTTYOutputer::start(size_t scale, bool report_diff) {
   265   _scale = scale;
   266   _output->print_cr(" ");
   267   _output->print_cr("Native Memory Tracking:");
   268   _output->print_cr(" ");
   269 }
   271 void BaselineTTYOutputer::done() {
   273 }
   275 void BaselineTTYOutputer::total_usage(size_t total_reserved, size_t total_committed) {
   276   const char* unit = memory_unit(_scale);
   277   _output->print_cr("Total:  reserved=%d%s,  committed=%d%s",
   278     total_reserved, unit, total_committed, unit);
   279 }
   281 void BaselineTTYOutputer::start_category_summary() {
   282   _output->print_cr(" ");
   283 }
   285 /**
   286  * report a summary of memory type
   287  */
   288 void BaselineTTYOutputer::category_summary(MEMFLAGS type,
   289   size_t reserved_amt, size_t committed_amt, size_t malloc_amt,
   290   size_t malloc_count, size_t arena_amt, size_t arena_count) {
   292   // we report mtThreadStack under mtThread category
   293   if (type == mtThreadStack) {
   294     assert(malloc_amt == 0 && malloc_count == 0 && arena_amt == 0,
   295       "Just check");
   296     _thread_stack_reserved = reserved_amt;
   297     _thread_stack_committed = committed_amt;
   298   } else {
   299     const char* unit = memory_unit(_scale);
   300     size_t total_reserved = (reserved_amt + malloc_amt + arena_amt);
   301     size_t total_committed = (committed_amt + malloc_amt + arena_amt);
   302     if (type == mtThread) {
   303       total_reserved += _thread_stack_reserved;
   304       total_committed += _thread_stack_committed;
   305     }
   307     if (total_reserved > 0) {
   308       _output->print_cr("-%26s (reserved=%d%s, committed=%d%s)",
   309         MemBaseline::type2name(type), total_reserved, unit,
   310         total_committed, unit);
   312       if (type == mtClass) {
   313         _output->print_cr("%27s (classes #%d)", " ", _num_of_classes);
   314       } else if (type == mtThread) {
   315         _output->print_cr("%27s (thread #%d)", " ", _num_of_threads);
   316         _output->print_cr("%27s (stack: reserved=%d%s, committed=%d%s)", " ",
   317           _thread_stack_reserved, unit, _thread_stack_committed, unit);
   318       }
   320       if (malloc_amt > 0) {
   321         if (type != mtChunk) {
   322           _output->print_cr("%27s (malloc=%d%s, #%d)", " ", malloc_amt, unit,
   323             malloc_count);
   324         } else {
   325           _output->print_cr("%27s (malloc=%d%s)", " ", malloc_amt, unit);
   326         }
   327       }
   329       if (reserved_amt > 0) {
   330         _output->print_cr("%27s (mmap: reserved=%d%s, committed=%d%s)",
   331           " ", reserved_amt, unit, committed_amt, unit);
   332       }
   334       if (arena_amt > 0) {
   335         _output->print_cr("%27s (arena=%d%s, #%d)", " ", arena_amt, unit, arena_count);
   336       }
   338       _output->print_cr(" ");
   339     }
   340   }
   341 }
   343 void BaselineTTYOutputer::done_category_summary() {
   344   _output->print_cr(" ");
   345 }
   348 void BaselineTTYOutputer::start_virtual_memory_map() {
   349   _output->print_cr("Virtual memory map:");
   350 }
   352 void BaselineTTYOutputer::reserved_memory_region(MEMFLAGS type, address base, address end,
   353                                                  size_t size, address pc) {
   354   const char* unit = memory_unit(_scale);
   355   char buf[128];
   356   int  offset;
   357   _output->print_cr(" ");
   358   _output->print_cr("[" PTR_FORMAT " - " PTR_FORMAT "] reserved %d%s for %s", base, end, size, unit,
   359             MemBaseline::type2name(type));
   360   if (os::dll_address_to_function_name(pc, buf, sizeof(buf), &offset)) {
   361       _output->print_cr("\t\tfrom [%s+0x%x]", buf, offset);
   362   }
   363 }
   365 void BaselineTTYOutputer::committed_memory_region(address base, address end, size_t size, address pc) {
   366   const char* unit = memory_unit(_scale);
   367   char buf[128];
   368   int  offset;
   369   _output->print("\t[" PTR_FORMAT " - " PTR_FORMAT "] committed %d%s", base, end, size, unit);
   370   if (os::dll_address_to_function_name(pc, buf, sizeof(buf), &offset)) {
   371       _output->print_cr(" from [%s+0x%x]", buf, offset);
   372   }
   373 }
   375 void BaselineTTYOutputer::done_virtual_memory_map() {
   376   _output->print_cr(" ");
   377 }
   381 void BaselineTTYOutputer::start_callsite() {
   382   _output->print_cr("Details:");
   383   _output->print_cr(" ");
   384 }
   386 void BaselineTTYOutputer::done_callsite() {
   387   _output->print_cr(" ");
   388 }
   390 void BaselineTTYOutputer::malloc_callsite(address pc, size_t malloc_amt,
   391   size_t malloc_count) {
   392   if (malloc_amt > 0) {
   393     const char* unit = memory_unit(_scale);
   394     char buf[128];
   395     int  offset;
   396     if (pc == 0) {
   397       _output->print("[BOOTSTRAP]%18s", " ");
   398     } else if (os::dll_address_to_function_name(pc, buf, sizeof(buf), &offset)) {
   399       _output->print_cr("[" PTR_FORMAT "] %s+0x%x", pc, buf, offset);
   400       _output->print("%28s", " ");
   401     } else {
   402       _output->print("[" PTR_FORMAT "]%18s", pc, " ");
   403     }
   405     _output->print_cr("(malloc=%d%s #%d)", malloc_amt, unit, malloc_count);
   406     _output->print_cr(" ");
   407   }
   408 }
   410 void BaselineTTYOutputer::virtual_memory_callsite(address pc, size_t reserved_amt,
   411   size_t committed_amt) {
   412   if (reserved_amt > 0) {
   413     const char* unit = memory_unit(_scale);
   414     char buf[128];
   415     int  offset;
   416     if (pc == 0) {
   417       _output->print("[BOOTSTRAP]%18s", " ");
   418     } else if (os::dll_address_to_function_name(pc, buf, sizeof(buf), &offset)) {
   419       _output->print_cr("[" PTR_FORMAT "] %s+0x%x", pc, buf, offset);
   420       _output->print("%28s", " ");
   421     } else {
   422       _output->print("[" PTR_FORMAT "]%18s", " ");
   423     }
   425     _output->print_cr("(mmap: reserved=%d%s, committed=%d%s)",
   426       reserved_amt, unit, committed_amt, unit);
   427     _output->print_cr(" ");
   428   }
   429 }
   431 void BaselineTTYOutputer::diff_total_usage(size_t total_reserved,
   432   size_t total_committed, int reserved_diff, int committed_diff) {
   433   const char* unit = memory_unit(_scale);
   434   _output->print_cr("Total:  reserved=%d%s  %+d%s, committed=%d%s %+d%s",
   435     total_reserved, unit, reserved_diff, unit, total_committed, unit,
   436     committed_diff, unit);
   437 }
   439 void BaselineTTYOutputer::diff_category_summary(MEMFLAGS type,
   440   size_t cur_reserved_amt, size_t cur_committed_amt,
   441   size_t cur_malloc_amt, size_t cur_malloc_count,
   442   size_t cur_arena_amt, size_t cur_arena_count,
   443   int reserved_diff, int committed_diff, int malloc_diff,
   444   int malloc_count_diff, int arena_diff, int arena_count_diff) {
   446   if (type == mtThreadStack) {
   447     assert(cur_malloc_amt == 0 && cur_malloc_count == 0 &&
   448       cur_arena_amt == 0, "Just check");
   449     _thread_stack_reserved = cur_reserved_amt;
   450     _thread_stack_committed = cur_committed_amt;
   451     _thread_stack_reserved_diff = reserved_diff;
   452     _thread_stack_committed_diff = committed_diff;
   453   } else {
   454     const char* unit = memory_unit(_scale);
   455     size_t total_reserved = (cur_reserved_amt + cur_malloc_amt + cur_arena_amt);
   456     // nothing to report in this category
   457     if (total_reserved == 0) {
   458       return;
   459     }
   460     int    diff_reserved = (reserved_diff + malloc_diff + arena_diff);
   462     // category summary
   463     _output->print("-%26s (reserved=%d%s", MemBaseline::type2name(type),
   464       total_reserved, unit);
   466     if (diff_reserved != 0) {
   467       _output->print(" %+d%s", diff_reserved, unit);
   468     }
   470     size_t total_committed = cur_committed_amt + cur_malloc_amt + cur_arena_amt;
   471     _output->print(", committed=%d%s", total_committed, unit);
   473     int total_committed_diff = committed_diff + malloc_diff + arena_diff;
   474     if (total_committed_diff != 0) {
   475       _output->print(" %+d%s", total_committed_diff, unit);
   476     }
   478     _output->print_cr(")");
   480     // special cases
   481     if (type == mtClass) {
   482       _output->print("%27s (classes #%d", " ", _num_of_classes);
   483       if (_num_of_classes_diff != 0) {
   484         _output->print(" %+d", _num_of_classes_diff);
   485       }
   486       _output->print_cr(")");
   487     } else if (type == mtThread) {
   488       // thread count
   489       _output->print("%27s (thread #%d", " ", _num_of_threads);
   490       if (_num_of_threads_diff != 0) {
   491         _output->print_cr(" %+d)", _num_of_threads_diff);
   492       } else {
   493         _output->print_cr(")");
   494       }
   495       _output->print("%27s (stack: reserved=%d%s", " ", _thread_stack_reserved, unit);
   496       if (_thread_stack_reserved_diff != 0) {
   497         _output->print(" %+d%s", _thread_stack_reserved_diff, unit);
   498       }
   500       _output->print(", committed=%d%s", _thread_stack_committed, unit);
   501       if (_thread_stack_committed_diff != 0) {
   502         _output->print(" %+d%s",_thread_stack_committed_diff, unit);
   503       }
   505       _output->print_cr(")");
   506     }
   508     // malloc'd memory
   509     if (cur_malloc_amt > 0) {
   510       _output->print("%27s (malloc=%d%s", " ", cur_malloc_amt, unit);
   511       if (malloc_diff != 0) {
   512         _output->print(" %+d%s", malloc_diff, unit);
   513       }
   514       if (type != mtChunk) {
   515         _output->print(", #%d", cur_malloc_count);
   516         if (malloc_count_diff) {
   517           _output->print(" %+d", malloc_count_diff);
   518         }
   519       }
   520       _output->print_cr(")");
   521     }
   523     // mmap'd memory
   524     if (cur_reserved_amt > 0) {
   525       _output->print("%27s (mmap: reserved=%d%s", " ", cur_reserved_amt, unit);
   526       if (reserved_diff != 0) {
   527         _output->print(" %+d%s", reserved_diff, unit);
   528       }
   530       _output->print(", committed=%d%s", cur_committed_amt, unit);
   531       if (committed_diff != 0) {
   532         _output->print(" %+d%s", committed_diff, unit);
   533       }
   534       _output->print_cr(")");
   535     }
   537     // arena memory
   538     if (cur_arena_amt > 0) {
   539       _output->print("%27s (arena=%d%s", " ", cur_arena_amt, unit);
   540       if (arena_diff != 0) {
   541         _output->print(" %+d%s", arena_diff, unit);
   542       }
   543       _output->print(", #%d", cur_arena_count);
   544       if (arena_count_diff != 0) {
   545         _output->print(" %+d", arena_count_diff);
   546       }
   547       _output->print_cr(")");
   548     }
   550     _output->print_cr(" ");
   551   }
   552 }
   554 void BaselineTTYOutputer::diff_malloc_callsite(address pc,
   555     size_t cur_malloc_amt, size_t cur_malloc_count,
   556     int malloc_diff, int malloc_count_diff) {
   557   if (malloc_diff != 0) {
   558     const char* unit = memory_unit(_scale);
   559     char buf[128];
   560     int  offset;
   561     if (pc == 0) {
   562       _output->print_cr("[BOOTSTRAP]%18s", " ");
   563     } else {
   564       if (os::dll_address_to_function_name(pc, buf, sizeof(buf), &offset)) {
   565         _output->print_cr("[" PTR_FORMAT "] %s+0x%x", pc, buf, offset);
   566         _output->print("%28s", " ");
   567       } else {
   568         _output->print("[" PTR_FORMAT "]%18s", pc, " ");
   569       }
   570     }
   572     _output->print("(malloc=%d%s", cur_malloc_amt, unit);
   573     if (malloc_diff != 0) {
   574       _output->print(" %+d%s", malloc_diff, unit);
   575     }
   576     _output->print(", #%d", cur_malloc_count);
   577     if (malloc_count_diff != 0) {
   578       _output->print(" %+d", malloc_count_diff);
   579     }
   580     _output->print_cr(")");
   581     _output->print_cr(" ");
   582   }
   583 }
   585 void BaselineTTYOutputer::diff_virtual_memory_callsite(address pc,
   586     size_t cur_reserved_amt, size_t cur_committed_amt,
   587     int reserved_diff, int committed_diff) {
   588   if (reserved_diff != 0 || committed_diff != 0) {
   589     const char* unit = memory_unit(_scale);
   590     char buf[64];
   591     int  offset;
   592     if (pc == 0) {
   593       _output->print_cr("[BOOSTRAP]%18s", " ");
   594     } else {
   595       if (os::dll_address_to_function_name(pc, buf, sizeof(buf), &offset)) {
   596         _output->print_cr("[" PTR_FORMAT "] %s+0x%x", pc, buf, offset);
   597         _output->print("%28s", " ");
   598       } else {
   599         _output->print("[" PTR_FORMAT "]%18s", " ");
   600       }
   601     }
   603     _output->print("(mmap: reserved=%d%s", cur_reserved_amt, unit);
   604     if (reserved_diff != 0) {
   605       _output->print(" %+d%s", reserved_diff, unit);
   606     }
   607     _output->print(", committed=%d%s", cur_committed_amt, unit);
   608     if (committed_diff != 0) {
   609       _output->print(" %+d%s", committed_diff, unit);
   610     }
   611     _output->print_cr(")");
   612     _output->print_cr(" ");
   613   }
   614 }

mercurial