hotspot/src/share/vm/services/memReporter.hpp
author coleenp
Tue, 22 Dec 2015 11:11:29 -0500
changeset 35214 d86005e0b4c2
parent 27162 0a4a7276949b
child 46489 40abcea5a9d5
permissions -rw-r--r--
8074457: Remove the non-Zero CPP Interpreter Summary: Remove cppInterpreter assembly files and reorganize InterpreterGenerator includes Reviewed-by: goetz, bdelsart
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
     1
/*
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
     2
 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
     4
 *
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
     7
 * published by the Free Software Foundation.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
     8
 *
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    13
 * accompanied this code).
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    14
 *
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    18
 *
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    21
 * questions.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    22
 *
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    23
 */
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    24
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    25
#ifndef SHARE_VM_SERVICES_MEM_REPORTER_HPP
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    26
#define SHARE_VM_SERVICES_MEM_REPORTER_HPP
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    27
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    28
#if INCLUDE_NMT
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    29
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    30
#include "oops/instanceKlass.hpp"
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    31
#include "services/memBaseline.hpp"
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    32
#include "services/nmtCommon.hpp"
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    33
#include "services/mallocTracker.hpp"
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    34
#include "services/virtualMemoryTracker.hpp"
13975
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13195
diff changeset
    35
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    36
/*
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    37
 * Base class that provides helpers
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    38
*/
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    39
class MemReporterBase : public StackObj {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    40
 private:
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    41
  size_t        _scale;  // report in this scale
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    42
  outputStream* _output; // destination
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    43
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    44
 public:
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    45
  MemReporterBase(outputStream* out = NULL, size_t scale = K)
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    46
    : _scale(scale) {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    47
    _output = (out == NULL) ? tty : out;
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    48
  }
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    49
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    50
 protected:
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    51
  inline outputStream* output() const {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    52
    return _output;
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    53
  }
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    54
  // Current reporting scale
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    55
  inline const char* current_scale() const {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    56
    return NMTUtil::scale_name(_scale);
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    57
  }
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    58
  // Convert memory amount in bytes to current reporting scale
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    59
  inline size_t amount_in_current_scale(size_t amount) const {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    60
    return NMTUtil::amount_in_scale(amount, _scale);
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    61
  }
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    62
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    63
  // Convert diff amount in bytes to current reporting scale
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    64
  inline long diff_in_current_scale(size_t s1, size_t s2) const {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    65
    long amount = (long)(s1 - s2);
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    66
    long scale = (long)_scale;
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    67
    amount = (amount > 0) ? (amount + scale / 2) : (amount - scale / 2);
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    68
    return amount / scale;
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    69
  }
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    70
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    71
  // Helper functions
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    72
  // Calculate total reserved and committed amount
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    73
  size_t reserved_total(const MallocMemory* malloc, const VirtualMemory* vm) const;
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    74
  size_t committed_total(const MallocMemory* malloc, const VirtualMemory* vm) const;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    75
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    76
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    77
  // Print summary total, malloc and virtual memory
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    78
  void print_total(size_t reserved, size_t committed) const;
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    79
  void print_malloc(size_t amount, size_t count) const;
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    80
  void print_virtual_memory(size_t reserved, size_t committed) const;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    81
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    82
  void print_malloc_line(size_t amount, size_t count) const;
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    83
  void print_virtual_memory_line(size_t reserved, size_t committed) const;
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    84
  void print_arena_line(size_t amount, size_t count) const;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    85
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    86
  void print_virtual_memory_region(const char* type, address base, size_t size) const;
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    87
};
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    88
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    89
/*
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    90
 * The class is for generating summary tracking report.
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    91
 */
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    92
class MemSummaryReporter : public MemReporterBase {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    93
 private:
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    94
  MallocMemorySnapshot*   _malloc_snapshot;
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    95
  VirtualMemorySnapshot*  _vm_snapshot;
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    96
  size_t                  _class_count;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    97
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    98
 public:
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
    99
  // This constructor is for normal reporting from a recent baseline.
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   100
  MemSummaryReporter(MemBaseline& baseline, outputStream* output,
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   101
    size_t scale = K) : MemReporterBase(output, scale),
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   102
    _malloc_snapshot(baseline.malloc_memory_snapshot()),
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   103
    _vm_snapshot(baseline.virtual_memory_snapshot()),
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   104
    _class_count(baseline.class_count()) { }
14120
7d298141c258 7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents: 13975
diff changeset
   105
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   106
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   107
  // Generate summary report
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   108
  virtual void report();
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   109
 private:
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   110
  // Report summary for each memory type
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   111
  void report_summary_of_type(MEMFLAGS type, MallocMemory* malloc_memory,
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   112
    VirtualMemory* virtual_memory);
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   113
};
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   114
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   115
/*
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   116
 * The class is for generating detail tracking report.
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   117
 */
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   118
class MemDetailReporter : public MemSummaryReporter {
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   119
 private:
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   120
  MemBaseline&   _baseline;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   121
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   122
 public:
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   123
  MemDetailReporter(MemBaseline& baseline, outputStream* output, size_t scale = K) :
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   124
    MemSummaryReporter(baseline, output, scale),
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   125
     _baseline(baseline) { }
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   126
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   127
  // Generate detail report.
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   128
  // The report contains summary and detail sections.
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   129
  virtual void report() {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   130
    MemSummaryReporter::report();
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   131
    report_virtual_memory_map();
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   132
    report_detail();
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   133
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   134
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   135
 private:
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   136
  // Report detail tracking data.
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   137
  void report_detail();
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   138
  // Report virtual memory map
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   139
  void report_virtual_memory_map();
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   140
  // Report malloc allocation sites
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   141
  void report_malloc_sites();
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   142
  // Report virtual memory reservation sites
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   143
  void report_virtual_memory_allocation_sites();
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   144
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   145
  // Report a virtual memory region
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   146
  void report_virtual_memory_region(const ReservedMemoryRegion* rgn);
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   147
};
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   148
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   149
/*
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   150
 * The class is for generating summary comparison report.
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   151
 * It compares current memory baseline against an early baseline.
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   152
 */
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   153
class MemSummaryDiffReporter : public MemReporterBase {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   154
 protected:
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   155
  MemBaseline&      _early_baseline;
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   156
  MemBaseline&      _current_baseline;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   157
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   158
 public:
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   159
  MemSummaryDiffReporter(MemBaseline& early_baseline, MemBaseline& current_baseline,
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   160
    outputStream* output, size_t scale = K) : MemReporterBase(output, scale),
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   161
    _early_baseline(early_baseline), _current_baseline(current_baseline) {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   162
    assert(early_baseline.baseline_type()   != MemBaseline::Not_baselined, "Not baselined");
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   163
    assert(current_baseline.baseline_type() != MemBaseline::Not_baselined, "Not baselined");
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   164
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   165
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   166
  // Generate summary comparison report
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   167
  virtual void report_diff();
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   168
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   169
 private:
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   170
  // report the comparison of each memory type
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   171
  void diff_summary_of_type(MEMFLAGS type,
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   172
    const MallocMemory* early_malloc, const VirtualMemory* early_vm,
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   173
    const MallocMemory* current_malloc, const VirtualMemory* current_vm) const;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   174
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   175
 protected:
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   176
  void print_malloc_diff(size_t current_amount, size_t current_count,
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   177
    size_t early_amount, size_t early_count) const;
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   178
  void print_virtual_memory_diff(size_t current_reserved, size_t current_committed,
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   179
    size_t early_reserved, size_t early_committed) const;
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   180
  void print_arena_diff(size_t current_amount, size_t current_count,
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   181
    size_t early_amount, size_t early_count) const;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   182
};
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   183
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   184
/*
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   185
 * The class is for generating detail comparison report.
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   186
 * It compares current memory baseline against an early baseline,
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   187
 * both baselines have to be detail baseline.
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   188
 */
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   189
class MemDetailDiffReporter : public MemSummaryDiffReporter {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   190
 public:
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   191
  MemDetailDiffReporter(MemBaseline& early_baseline, MemBaseline& current_baseline,
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   192
    outputStream* output, size_t scale = K) :
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   193
    MemSummaryDiffReporter(early_baseline, current_baseline, output, scale) { }
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   194
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   195
  // Generate detail comparison report
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   196
  virtual void report_diff();
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   197
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   198
  // Malloc allocation site comparison
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   199
  void diff_malloc_sites() const;
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   200
  // Virutal memory reservation site comparison
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   201
  void diff_virtual_memory_sites() const;
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   202
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   203
  // New malloc allocation site in recent baseline
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   204
  void new_malloc_site (const MallocSite* site) const;
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   205
  // The malloc allocation site is not in recent baseline
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   206
  void old_malloc_site (const MallocSite* site) const;
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   207
  // Compare malloc allocation site, it is in both baselines
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   208
  void diff_malloc_site(const MallocSite* early, const MallocSite* current)  const;
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   209
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   210
  // New virtual memory allocation site in recent baseline
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   211
  void new_virtual_memory_site (const VirtualMemoryAllocationSite* callsite) const;
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   212
  // The virtual memory allocation site is not in recent baseline
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   213
  void old_virtual_memory_site (const VirtualMemoryAllocationSite* callsite) const;
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   214
  // Compare virtual memory allocation site, it is in both baseline
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   215
  void diff_virtual_memory_site(const VirtualMemoryAllocationSite* early,
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   216
                                const VirtualMemoryAllocationSite* current)  const;
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   217
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   218
  void diff_malloc_site(const NativeCallStack* stack, size_t current_size,
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   219
    size_t currrent_count, size_t early_size, size_t early_count) const;
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   220
  void diff_virtual_memory_site(const NativeCallStack* stack, size_t current_reserved,
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   221
    size_t current_committed, size_t early_reserved, size_t early_committed) const;
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   222
};
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   223
13975
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13195
diff changeset
   224
#endif // INCLUDE_NMT
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13195
diff changeset
   225
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   226
#endif
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 22234
diff changeset
   227