src/share/vm/services/memReporter.cpp

Wed, 31 Jan 2018 19:24:57 -0500

author
dbuck
date
Wed, 31 Jan 2018 19:24:57 -0500
changeset 9289
427b2fb1944f
parent 9054
db49d511817a
child 9122
024be04bb151
child 9621
c3abd2b71b9a
permissions
-rw-r--r--

8189170: Add option to disable stack overflow checking in primordial thread for use with JNI_CreateJavaJVM
Reviewed-by: dcubed

     1 /*
     2  * Copyright (c) 2012, 2017, 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"
    26 #include "memory/allocation.hpp"
    27 #include "services/mallocTracker.hpp"
    28 #include "services/memReporter.hpp"
    29 #include "services/virtualMemoryTracker.hpp"
    30 #include "utilities/globalDefinitions.hpp"
    32 size_t MemReporterBase::reserved_total(const MallocMemory* malloc, const VirtualMemory* vm) const {
    33   return malloc->malloc_size() + malloc->arena_size() + vm->reserved();
    34 }
    36 size_t MemReporterBase::committed_total(const MallocMemory* malloc, const VirtualMemory* vm) const {
    37   return malloc->malloc_size() + malloc->arena_size() + vm->committed();
    38 }
    40 void MemReporterBase::print_total(size_t reserved, size_t committed) const {
    41   const char* scale = current_scale();
    42   output()->print("reserved=" SIZE_FORMAT "%s, committed=" SIZE_FORMAT "%s",
    43     amount_in_current_scale(reserved), scale, amount_in_current_scale(committed), scale);
    44 }
    46 void MemReporterBase::print_malloc(size_t amount, size_t count, MEMFLAGS flag) const {
    47   const char* scale = current_scale();
    48   outputStream* out = output();
    49   if (flag != mtNone) {
    50     out->print("(malloc=" SIZE_FORMAT "%s type=%s",
    51       amount_in_current_scale(amount), scale, NMTUtil::flag_to_name(flag));
    52   } else {
    53     out->print("(malloc=" SIZE_FORMAT "%s",
    54       amount_in_current_scale(amount), scale);
    55   }
    57   if (count > 0) {
    58     out->print(" #" SIZE_FORMAT "", count);
    59   }
    61   out->print(")");
    62 }
    64 void MemReporterBase::print_virtual_memory(size_t reserved, size_t committed) const {
    65   const char* scale = current_scale();
    66   output()->print("(mmap: reserved=" SIZE_FORMAT "%s, committed=" SIZE_FORMAT "%s)",
    67     amount_in_current_scale(reserved), scale, amount_in_current_scale(committed), scale);
    68 }
    70 void MemReporterBase::print_malloc_line(size_t amount, size_t count) const {
    71   output()->print("%28s", " ");
    72   print_malloc(amount, count);
    73   output()->print_cr(" ");
    74 }
    76 void MemReporterBase::print_virtual_memory_line(size_t reserved, size_t committed) const {
    77   output()->print("%28s", " ");
    78   print_virtual_memory(reserved, committed);
    79   output()->print_cr(" ");
    80 }
    82 void MemReporterBase::print_arena_line(size_t amount, size_t count) const {
    83   const char* scale = current_scale();
    84   output()->print_cr("%27s (arena=" SIZE_FORMAT "%s #" SIZE_FORMAT ")", " ",
    85     amount_in_current_scale(amount), scale, count);
    86 }
    88 void MemReporterBase::print_virtual_memory_region(const char* type, address base, size_t size) const {
    89   const char* scale = current_scale();
    90   output()->print("[" PTR_FORMAT " - " PTR_FORMAT "] %s " SIZE_FORMAT "%s",
    91     p2i(base), p2i(base + size), type, amount_in_current_scale(size), scale);
    92 }
    95 void MemSummaryReporter::report() {
    96   const char* scale = current_scale();
    97   outputStream* out = output();
    98   size_t total_reserved_amount = _malloc_snapshot->total() +
    99     _vm_snapshot->total_reserved();
   100   size_t total_committed_amount = _malloc_snapshot->total() +
   101     _vm_snapshot->total_committed();
   103   // Overall total
   104   out->print_cr("\nNative Memory Tracking:\n");
   105   out->print("Total: ");
   106   print_total(total_reserved_amount, total_committed_amount);
   107   out->print("\n");
   109   // Summary by memory type
   110   for (int index = 0; index < mt_number_of_types; index ++) {
   111     MEMFLAGS flag = NMTUtil::index_to_flag(index);
   112     // thread stack is reported as part of thread category
   113     if (flag == mtThreadStack) continue;
   114     MallocMemory* malloc_memory = _malloc_snapshot->by_type(flag);
   115     VirtualMemory* virtual_memory = _vm_snapshot->by_type(flag);
   117     report_summary_of_type(flag, malloc_memory, virtual_memory);
   118   }
   119 }
   121 void MemSummaryReporter::report_summary_of_type(MEMFLAGS flag,
   122   MallocMemory*  malloc_memory, VirtualMemory* virtual_memory) {
   124   size_t reserved_amount  = reserved_total (malloc_memory, virtual_memory);
   125   size_t committed_amount = committed_total(malloc_memory, virtual_memory);
   127   // Count thread's native stack in "Thread" category
   128   if (flag == mtThread) {
   129     const VirtualMemory* thread_stack_usage =
   130       (const VirtualMemory*)_vm_snapshot->by_type(mtThreadStack);
   131     reserved_amount  += thread_stack_usage->reserved();
   132     committed_amount += thread_stack_usage->committed();
   133   } else if (flag == mtNMT) {
   134     // Count malloc headers in "NMT" category
   135     reserved_amount  += _malloc_snapshot->malloc_overhead()->size();
   136     committed_amount += _malloc_snapshot->malloc_overhead()->size();
   137   }
   139   if (amount_in_current_scale(reserved_amount) > 0) {
   140     outputStream* out   = output();
   141     const char*   scale = current_scale();
   142     out->print("-%26s (", NMTUtil::flag_to_name(flag));
   143     print_total(reserved_amount, committed_amount);
   144     out->print_cr(")");
   146     if (flag == mtClass) {
   147       // report class count
   148       out->print_cr("%27s (classes #" SIZE_FORMAT ")", " ", _class_count);
   149     } else if (flag == mtThread) {
   150       // report thread count
   151       out->print_cr("%27s (thread #" SIZE_FORMAT ")", " ", _malloc_snapshot->thread_count());
   152       const VirtualMemory* thread_stack_usage =
   153        _vm_snapshot->by_type(mtThreadStack);
   154       out->print("%27s (stack: ", " ");
   155       print_total(thread_stack_usage->reserved(), thread_stack_usage->committed());
   156       out->print_cr(")");
   157     }
   159      // report malloc'd memory
   160     if (amount_in_current_scale(malloc_memory->malloc_size()) > 0) {
   161       // We don't know how many arena chunks are in used, so don't report the count
   162       size_t count = (flag == mtChunk) ? 0 : malloc_memory->malloc_count();
   163       print_malloc_line(malloc_memory->malloc_size(), count);
   164     }
   166     if (amount_in_current_scale(virtual_memory->reserved()) > 0) {
   167       print_virtual_memory_line(virtual_memory->reserved(), virtual_memory->committed());
   168     }
   170     if (amount_in_current_scale(malloc_memory->arena_size()) > 0) {
   171       print_arena_line(malloc_memory->arena_size(), malloc_memory->arena_count());
   172     }
   174     if (flag == mtNMT &&
   175       amount_in_current_scale(_malloc_snapshot->malloc_overhead()->size()) > 0) {
   176       out->print_cr("%27s (tracking overhead=" SIZE_FORMAT "%s)", " ",
   177         amount_in_current_scale(_malloc_snapshot->malloc_overhead()->size()), scale);
   178     }
   180     out->print_cr(" ");
   181   }
   182 }
   184 void MemDetailReporter::report_detail() {
   185   // Start detail report
   186   outputStream* out = output();
   187   out->print_cr("Details:\n");
   189   report_malloc_sites();
   190   report_virtual_memory_allocation_sites();
   191 }
   193 void MemDetailReporter::report_malloc_sites() {
   194   MallocSiteIterator         malloc_itr = _baseline.malloc_sites(MemBaseline::by_size);
   195   if (malloc_itr.is_empty()) return;
   197   outputStream* out = output();
   199   const MallocSite* malloc_site;
   200   while ((malloc_site = malloc_itr.next()) != NULL) {
   201     // Don't report if size is too small
   202     if (amount_in_current_scale(malloc_site->size()) == 0)
   203       continue;
   205     const NativeCallStack* stack = malloc_site->call_stack();
   206     stack->print_on(out);
   207     out->print("%29s", " ");
   208     MEMFLAGS flag = malloc_site->flags();
   209     assert((flag >= 0 && flag < (int)mt_number_of_types) && flag != mtNone,
   210       "Must have a valid memory type");
   211     print_malloc(malloc_site->size(), malloc_site->count(),flag);
   212     out->print_cr("\n");
   213   }
   214 }
   216 void MemDetailReporter::report_virtual_memory_allocation_sites()  {
   217   VirtualMemorySiteIterator  virtual_memory_itr =
   218     _baseline.virtual_memory_sites(MemBaseline::by_size);
   220   if (virtual_memory_itr.is_empty()) return;
   222   outputStream* out = output();
   223   const VirtualMemoryAllocationSite*  virtual_memory_site;
   225   while ((virtual_memory_site = virtual_memory_itr.next()) != NULL) {
   226     // Don't report if size is too small
   227     if (amount_in_current_scale(virtual_memory_site->reserved()) == 0)
   228       continue;
   230     const NativeCallStack* stack = virtual_memory_site->call_stack();
   231     stack->print_on(out);
   232     out->print("%28s (", " ");
   233     print_total(virtual_memory_site->reserved(), virtual_memory_site->committed());
   234     out->print_cr(")\n");
   235   }
   236 }
   239 void MemDetailReporter::report_virtual_memory_map() {
   240   // Virtual memory map always in base address order
   241   VirtualMemoryAllocationIterator itr = _baseline.virtual_memory_allocations();
   242   const ReservedMemoryRegion* rgn;
   244   output()->print_cr("Virtual memory map:");
   245   while ((rgn = itr.next()) != NULL) {
   246     report_virtual_memory_region(rgn);
   247   }
   248 }
   250 void MemDetailReporter::report_virtual_memory_region(const ReservedMemoryRegion* reserved_rgn) {
   251   assert(reserved_rgn != NULL, "NULL pointer");
   253   // Don't report if size is too small
   254   if (amount_in_current_scale(reserved_rgn->size()) == 0) return;
   256   outputStream* out = output();
   257   const char* scale = current_scale();
   258   const NativeCallStack*  stack = reserved_rgn->call_stack();
   259   bool all_committed = reserved_rgn->all_committed();
   260   const char* region_type = (all_committed ? "reserved and committed" : "reserved");
   261   out->print_cr(" ");
   262   print_virtual_memory_region(region_type, reserved_rgn->base(), reserved_rgn->size());
   263   out->print(" for %s", NMTUtil::flag_to_name(reserved_rgn->flag()));
   264   if (stack->is_empty()) {
   265     out->print_cr(" ");
   266   } else {
   267     out->print_cr(" from");
   268     stack->print_on(out, 4);
   269   }
   271   if (all_committed) return;
   273   CommittedRegionIterator itr = reserved_rgn->iterate_committed_regions();
   274   const CommittedMemoryRegion* committed_rgn;
   275   while ((committed_rgn = itr.next()) != NULL) {
   276     // Don't report if size is too small
   277     if (amount_in_current_scale(committed_rgn->size()) == 0) continue;
   278     stack = committed_rgn->call_stack();
   279     out->print("\n\t");
   280     print_virtual_memory_region("committed", committed_rgn->base(), committed_rgn->size());
   281     if (stack->is_empty()) {
   282       out->print_cr(" ");
   283     } else {
   284       out->print_cr(" from");
   285       stack->print_on(out, 12);
   286     }
   287   }
   288 }
   290 void MemSummaryDiffReporter::report_diff() {
   291   const char* scale = current_scale();
   292   outputStream* out = output();
   293   out->print_cr("\nNative Memory Tracking:\n");
   295   // Overall diff
   296   out->print("Total: ");
   297   print_virtual_memory_diff(_current_baseline.total_reserved_memory(),
   298     _current_baseline.total_committed_memory(), _early_baseline.total_reserved_memory(),
   299     _early_baseline.total_committed_memory());
   301   out->print_cr("\n");
   303   // Summary diff by memory type
   304   for (int index = 0; index < mt_number_of_types; index ++) {
   305     MEMFLAGS flag = NMTUtil::index_to_flag(index);
   306     // thread stack is reported as part of thread category
   307     if (flag == mtThreadStack) continue;
   308     diff_summary_of_type(flag, _early_baseline.malloc_memory(flag),
   309       _early_baseline.virtual_memory(flag), _current_baseline.malloc_memory(flag),
   310       _current_baseline.virtual_memory(flag));
   311   }
   312 }
   314 void MemSummaryDiffReporter::print_malloc_diff(size_t current_amount, size_t current_count,
   315     size_t early_amount, size_t early_count, MEMFLAGS flags) const {
   316   const char* scale = current_scale();
   317   outputStream* out = output();
   319   out->print("malloc=" SIZE_FORMAT "%s", amount_in_current_scale(current_amount), scale);
   320   // Report type only if it is valid
   321   if (flags != mtNone) {
   322     out->print(" type=%s", NMTUtil::flag_to_name(flags));
   323   }
   325   long amount_diff = diff_in_current_scale(current_amount, early_amount);
   326   if (amount_diff != 0) {
   327     out->print(" %+ld%s", amount_diff, scale);
   328   }
   329   if (current_count > 0) {
   330     out->print(" #" SIZE_FORMAT "", current_count);
   331     if (current_count != early_count) {
   332       out->print(" %+d", (int)(current_count - early_count));
   333     }
   334   }
   335 }
   337 void MemSummaryDiffReporter::print_arena_diff(size_t current_amount, size_t current_count,
   338   size_t early_amount, size_t early_count) const {
   339   const char* scale = current_scale();
   340   outputStream* out = output();
   341   out->print("arena=" SIZE_FORMAT "%s", amount_in_current_scale(current_amount), scale);
   342   if (diff_in_current_scale(current_amount, early_amount) != 0) {
   343     out->print(" %+ld", diff_in_current_scale(current_amount, early_amount));
   344   }
   346   out->print(" #" SIZE_FORMAT "", current_count);
   347   if (current_count != early_count) {
   348     out->print(" %+d", (int)(current_count - early_count));
   349   }
   350 }
   352 void MemSummaryDiffReporter::print_virtual_memory_diff(size_t current_reserved, size_t current_committed,
   353     size_t early_reserved, size_t early_committed) const {
   354   const char* scale = current_scale();
   355   outputStream* out = output();
   356   out->print("reserved=" SIZE_FORMAT "%s", amount_in_current_scale(current_reserved), scale);
   357   long reserved_diff = diff_in_current_scale(current_reserved, early_reserved);
   358   if (reserved_diff != 0) {
   359     out->print(" %+ld%s", reserved_diff, scale);
   360   }
   362   out->print(", committed=" SIZE_FORMAT "%s", amount_in_current_scale(current_committed), scale);
   363   long committed_diff = diff_in_current_scale(current_committed, early_committed);
   364   if (committed_diff != 0) {
   365     out->print(" %+ld%s", committed_diff, scale);
   366   }
   367 }
   370 void MemSummaryDiffReporter::diff_summary_of_type(MEMFLAGS flag, const MallocMemory* early_malloc,
   371   const VirtualMemory* early_vm, const MallocMemory* current_malloc,
   372   const VirtualMemory* current_vm) const {
   374   outputStream* out = output();
   375   const char* scale = current_scale();
   377   // Total reserved and committed memory in current baseline
   378   size_t current_reserved_amount  = reserved_total (current_malloc, current_vm);
   379   size_t current_committed_amount = committed_total(current_malloc, current_vm);
   381   // Total reserved and committed memory in early baseline
   382   size_t early_reserved_amount  = reserved_total(early_malloc, early_vm);
   383   size_t early_committed_amount = committed_total(early_malloc, early_vm);
   385   // Adjust virtual memory total
   386   if (flag == mtThread) {
   387     const VirtualMemory* early_thread_stack_usage =
   388       _early_baseline.virtual_memory(mtThreadStack);
   389     const VirtualMemory* current_thread_stack_usage =
   390       _current_baseline.virtual_memory(mtThreadStack);
   392     early_reserved_amount  += early_thread_stack_usage->reserved();
   393     early_committed_amount += early_thread_stack_usage->committed();
   395     current_reserved_amount  += current_thread_stack_usage->reserved();
   396     current_committed_amount += current_thread_stack_usage->committed();
   397   } else if (flag == mtNMT) {
   398     early_reserved_amount  += _early_baseline.malloc_tracking_overhead();
   399     early_committed_amount += _early_baseline.malloc_tracking_overhead();
   401     current_reserved_amount  += _current_baseline.malloc_tracking_overhead();
   402     current_committed_amount += _current_baseline.malloc_tracking_overhead();
   403   }
   405   if (amount_in_current_scale(current_reserved_amount) > 0 ||
   406       diff_in_current_scale(current_reserved_amount, early_reserved_amount) != 0) {
   408     // print summary line
   409     out->print("-%26s (", NMTUtil::flag_to_name(flag));
   410     print_virtual_memory_diff(current_reserved_amount, current_committed_amount,
   411       early_reserved_amount, early_committed_amount);
   412     out->print_cr(")");
   414     // detail lines
   415     if (flag == mtClass) {
   416       // report class count
   417       out->print("%27s (classes #" SIZE_FORMAT "", " ", _current_baseline.class_count());
   418       int class_count_diff = (int)(_current_baseline.class_count() -
   419         _early_baseline.class_count());
   420       if (_current_baseline.class_count() != _early_baseline.class_count()) {
   421         out->print(" %+d", (int)(_current_baseline.class_count() - _early_baseline.class_count()));
   422       }
   423       out->print_cr(")");
   424     } else if (flag == mtThread) {
   425       // report thread count
   426       out->print("%27s (thread #" SIZE_FORMAT "", " ", _current_baseline.thread_count());
   427       int thread_count_diff = (int)(_current_baseline.thread_count() -
   428           _early_baseline.thread_count());
   429       if (thread_count_diff != 0) {
   430         out->print(" %+d", thread_count_diff);
   431       }
   432       out->print_cr(")");
   434       // report thread stack
   435       const VirtualMemory* current_thread_stack =
   436           _current_baseline.virtual_memory(mtThreadStack);
   437       const VirtualMemory* early_thread_stack =
   438         _early_baseline.virtual_memory(mtThreadStack);
   440       out->print("%27s (stack: ", " ");
   441       print_virtual_memory_diff(current_thread_stack->reserved(), current_thread_stack->committed(),
   442         early_thread_stack->reserved(), early_thread_stack->committed());
   443       out->print_cr(")");
   444     }
   446     // Report malloc'd memory
   447     size_t current_malloc_amount = current_malloc->malloc_size();
   448     size_t early_malloc_amount   = early_malloc->malloc_size();
   449     if (amount_in_current_scale(current_malloc_amount) > 0 ||
   450         diff_in_current_scale(current_malloc_amount, early_malloc_amount) != 0) {
   451       out->print("%28s(", " ");
   452       print_malloc_diff(current_malloc_amount, (flag == mtChunk) ? 0 : current_malloc->malloc_count(),
   453         early_malloc_amount, early_malloc->malloc_count(), mtNone);
   454       out->print_cr(")");
   455     }
   457     // Report virtual memory
   458     if (amount_in_current_scale(current_vm->reserved()) > 0 ||
   459         diff_in_current_scale(current_vm->reserved(), early_vm->reserved()) != 0) {
   460       out->print("%27s (mmap: ", " ");
   461       print_virtual_memory_diff(current_vm->reserved(), current_vm->committed(),
   462         early_vm->reserved(), early_vm->committed());
   463       out->print_cr(")");
   464     }
   466     // Report arena memory
   467     if (amount_in_current_scale(current_malloc->arena_size()) > 0 ||
   468         diff_in_current_scale(current_malloc->arena_size(), early_malloc->arena_size()) != 0) {
   469       out->print("%28s(", " ");
   470       print_arena_diff(current_malloc->arena_size(), current_malloc->arena_count(),
   471         early_malloc->arena_size(), early_malloc->arena_count());
   472       out->print_cr(")");
   473     }
   475     // Report native memory tracking overhead
   476     if (flag == mtNMT) {
   477       size_t current_tracking_overhead = amount_in_current_scale(_current_baseline.malloc_tracking_overhead());
   478       size_t early_tracking_overhead   = amount_in_current_scale(_early_baseline.malloc_tracking_overhead());
   480       out->print("%27s (tracking overhead=" SIZE_FORMAT "%s", " ",
   481         amount_in_current_scale(_current_baseline.malloc_tracking_overhead()), scale);
   483       long overhead_diff = diff_in_current_scale(_current_baseline.malloc_tracking_overhead(),
   484            _early_baseline.malloc_tracking_overhead());
   485       if (overhead_diff != 0) {
   486         out->print(" %+ld%s", overhead_diff, scale);
   487       }
   488       out->print_cr(")");
   489     }
   490     out->print_cr(" ");
   491   }
   492 }
   494 void MemDetailDiffReporter::report_diff() {
   495   MemSummaryDiffReporter::report_diff();
   496   diff_malloc_sites();
   497   diff_virtual_memory_sites();
   498 }
   500 void MemDetailDiffReporter::diff_malloc_sites() const {
   501   MallocSiteIterator early_itr = _early_baseline.malloc_sites(MemBaseline::by_site_and_type);
   502   MallocSiteIterator current_itr = _current_baseline.malloc_sites(MemBaseline::by_site_and_type);
   504   const MallocSite* early_site   = early_itr.next();
   505   const MallocSite* current_site = current_itr.next();
   507   while (early_site != NULL || current_site != NULL) {
   508     if (early_site == NULL) {
   509       new_malloc_site(current_site);
   510       current_site = current_itr.next();
   511     } else if (current_site == NULL) {
   512       old_malloc_site(early_site);
   513       early_site = early_itr.next();
   514     } else {
   515       int compVal = current_site->call_stack()->compare(*early_site->call_stack());
   516       if (compVal < 0) {
   517         new_malloc_site(current_site);
   518         current_site = current_itr.next();
   519       } else if (compVal > 0) {
   520         old_malloc_site(early_site);
   521         early_site = early_itr.next();
   522       } else {
   523         diff_malloc_site(early_site, current_site);
   524         early_site   = early_itr.next();
   525         current_site = current_itr.next();
   526       }
   527     }
   528   }
   529 }
   531 void MemDetailDiffReporter::diff_virtual_memory_sites() const {
   532   VirtualMemorySiteIterator early_itr = _early_baseline.virtual_memory_sites(MemBaseline::by_site);
   533   VirtualMemorySiteIterator current_itr = _current_baseline.virtual_memory_sites(MemBaseline::by_site);
   535   const VirtualMemoryAllocationSite* early_site   = early_itr.next();
   536   const VirtualMemoryAllocationSite* current_site = current_itr.next();
   538   while (early_site != NULL || current_site != NULL) {
   539     if (early_site == NULL) {
   540       new_virtual_memory_site(current_site);
   541       current_site = current_itr.next();
   542     } else if (current_site == NULL) {
   543       old_virtual_memory_site(early_site);
   544       early_site = early_itr.next();
   545     } else {
   546       int compVal = current_site->call_stack()->compare(*early_site->call_stack());
   547       if (compVal < 0) {
   548         new_virtual_memory_site(current_site);
   549         current_site = current_itr.next();
   550       } else if (compVal > 0) {
   551         old_virtual_memory_site(early_site);
   552         early_site = early_itr.next();
   553       } else {
   554         diff_virtual_memory_site(early_site, current_site);
   555         early_site   = early_itr.next();
   556         current_site = current_itr.next();
   557       }
   558     }
   559   }
   560 }
   563 void MemDetailDiffReporter::new_malloc_site(const MallocSite* malloc_site) const {
   564   diff_malloc_site(malloc_site->call_stack(), malloc_site->size(), malloc_site->count(),
   565     0, 0, malloc_site->flags());
   566 }
   568 void MemDetailDiffReporter::old_malloc_site(const MallocSite* malloc_site) const {
   569   diff_malloc_site(malloc_site->call_stack(), 0, 0, malloc_site->size(),
   570     malloc_site->count(), malloc_site->flags());
   571 }
   573 void MemDetailDiffReporter::diff_malloc_site(const MallocSite* early,
   574   const MallocSite* current)  const {
   575   assert(early->flags() == current->flags(), "Must be the same memory type");
   576   diff_malloc_site(current->call_stack(), current->size(), current->count(),
   577     early->size(), early->count(), early->flags());
   578 }
   580 void MemDetailDiffReporter::diff_malloc_site(const NativeCallStack* stack, size_t current_size,
   581   size_t current_count, size_t early_size, size_t early_count, MEMFLAGS flags) const {
   582   outputStream* out = output();
   584   assert(stack != NULL, "NULL stack");
   586   if (diff_in_current_scale(current_size, early_size) == 0) {
   587       return;
   588   }
   590   stack->print_on(out);
   591   out->print("%28s (", " ");
   592   print_malloc_diff(current_size, current_count,
   593     early_size, early_count, flags);
   595   out->print_cr(")\n");
   596 }
   599 void MemDetailDiffReporter::new_virtual_memory_site(const VirtualMemoryAllocationSite* site) const {
   600   diff_virtual_memory_site(site->call_stack(), site->reserved(), site->committed(), 0, 0);
   601 }
   603 void MemDetailDiffReporter::old_virtual_memory_site(const VirtualMemoryAllocationSite* site) const {
   604   diff_virtual_memory_site(site->call_stack(), 0, 0, site->reserved(), site->committed());
   605 }
   607 void MemDetailDiffReporter::diff_virtual_memory_site(const VirtualMemoryAllocationSite* early,
   608   const VirtualMemoryAllocationSite* current) const {
   609   diff_virtual_memory_site(current->call_stack(), current->reserved(), current->committed(),
   610     early->reserved(), early->committed());
   611 }
   613 void MemDetailDiffReporter::diff_virtual_memory_site(const NativeCallStack* stack, size_t current_reserved,
   614   size_t current_committed, size_t early_reserved, size_t early_committed) const  {
   615   outputStream* out = output();
   617   // no change
   618   if (diff_in_current_scale(current_reserved, early_reserved) == 0 &&
   619       diff_in_current_scale(current_committed, early_committed) == 0) {
   620     return;
   621   }
   623   stack->print_on(out);
   624   out->print("%28s (mmap: ", " ");
   625   print_virtual_memory_diff(current_reserved, current_committed,
   626     early_reserved, early_committed);
   628   out->print_cr(")\n");
   629  }

mercurial