src/hotspot/share/code/codeHeapState.cpp
author lucy
Thu, 30 Aug 2018 09:34:10 +0200
changeset 51591 9183040e34d8
parent 51139 c95334202a14
child 52815 10bb941d7fd4
permissions -rw-r--r--
8209950: SIGBUS in CodeHeapState::print_names() Reviewed-by: thartmann, kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
     1
/*
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
     2
 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
     3
 * Copyright (c) 2018 SAP SE. All rights reserved.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
     5
 *
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
     8
 * published by the Free Software Foundation.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
     9
 *
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    14
 * accompanied this code).
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    15
 *
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    19
 *
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    22
 * questions.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    23
 *
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    24
 */
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    25
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    26
#include "precompiled.hpp"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    27
#include "code/codeHeapState.hpp"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    28
#include "compiler/compileBroker.hpp"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    29
#include "runtime/sweeper.hpp"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    30
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    31
// -------------------------
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    32
// |  General Description  |
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    33
// -------------------------
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    34
// The CodeHeap state analytics are divided in two parts.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    35
// The first part examines the entire CodeHeap and aggregates all
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    36
// information that is believed useful/important.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    37
//
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    38
// Aggregation condenses the information of a piece of the CodeHeap
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    39
// (4096 bytes by default) into an analysis granule. These granules
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    40
// contain enough detail to gain initial insight while keeping the
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    41
// internal sttructure sizes in check.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    42
//
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    43
// The CodeHeap is a living thing. Therefore, the aggregate is collected
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    44
// under the CodeCache_lock. The subsequent print steps are only locked
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    45
// against concurrent aggregations. That keeps the impact on
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    46
// "normal operation" (JIT compiler and sweeper activity) to a minimum.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    47
//
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    48
// The second part, which consists of several, independent steps,
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    49
// prints the previously collected information with emphasis on
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    50
// various aspects.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    51
//
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    52
// Data collection and printing is done on an "on request" basis.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    53
// While no request is being processed, there is no impact on performance.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    54
// The CodeHeap state analytics do have some memory footprint.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    55
// The "aggregate" step allocates some data structures to hold the aggregated
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    56
// information for later output. These data structures live until they are
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    57
// explicitly discarded (function "discard") or until the VM terminates.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    58
// There is one exception: the function "all" does not leave any data
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    59
// structures allocated.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    60
//
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    61
// Requests for real-time, on-the-fly analysis can be issued via
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    62
//   jcmd <pid> Compiler.CodeHeap_Analytics [<function>] [<granularity>]
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    63
//
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    64
// If you are (only) interested in how the CodeHeap looks like after running
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    65
// a sample workload, you can use the command line option
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    66
//   -Xlog:codecache=Trace
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    67
//
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    68
// To see the CodeHeap state in case of a "CodeCache full" condition, start the
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    69
// VM with the
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    70
//   -Xlog:codecache=Debug
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    71
// command line option. It will produce output only for the first time the
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    72
// condition is recognized.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    73
//
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    74
// Both command line option variants produce output identical to the jcmd function
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    75
//   jcmd <pid> Compiler.CodeHeap_Analytics all 4096
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    76
// ---------------------------------------------------------------------------------
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    77
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    78
// With this declaration macro, it is possible to switch between
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    79
//  - direct output into an argument-passed outputStream and
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    80
//  - buffered output into a bufferedStream with subsequent flush
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    81
//    of the filled buffer to the outputStream.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    82
#define USE_STRINGSTREAM
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    83
#define HEX32_FORMAT  "0x%x"  // just a helper format string used below multiple times
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    84
//
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    85
// Writing to a bufferedStream buffer first has a significant advantage:
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    86
// It uses noticeably less cpu cycles and reduces (when wirting to a
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    87
// network file) the required bandwidth by at least a factor of ten.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    88
// That clearly makes up for the increased code complexity.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    89
#if defined(USE_STRINGSTREAM)
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    90
#define STRINGSTREAM_DECL(_anyst, _outst)                 \
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    91
    /* _anyst  name of the stream as used in the code */  \
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    92
    /* _outst  stream where final output will go to   */  \
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    93
    ResourceMark rm;                                      \
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    94
    bufferedStream   _sstobj = bufferedStream(4*K);       \
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    95
    bufferedStream*  _sstbuf = &_sstobj;                  \
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    96
    outputStream*    _outbuf = _outst;                    \
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    97
    bufferedStream*  _anyst  = &_sstobj; /* any stream. Use this to just print - no buffer flush.  */
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    98
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    99
#define STRINGSTREAM_FLUSH(termString)                    \
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   100
    _sstbuf->print("%s", termString);                     \
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   101
    _outbuf->print("%s", _sstbuf->as_string());           \
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   102
    _sstbuf->reset();
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   103
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   104
#define STRINGSTREAM_FLUSH_LOCKED(termString)             \
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   105
    { ttyLocker ttyl;/* keep this output block together */\
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   106
      STRINGSTREAM_FLUSH(termString)                      \
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   107
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   108
#else
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   109
#define STRINGSTREAM_DECL(_anyst, _outst)                 \
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   110
    outputStream*  _outbuf = _outst;                      \
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   111
    outputStream*  _anyst  = _outst;   /* any stream. Use this to just print - no buffer flush.  */
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   112
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   113
#define STRINGSTREAM_FLUSH(termString)                    \
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   114
    _outbuf->print("%s", termString);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   115
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   116
#define STRINGSTREAM_FLUSH_LOCKED(termString)             \
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   117
    _outbuf->print("%s", termString);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   118
#endif
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   119
51124
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
   120
const char  blobTypeChar[] = {' ', 'C', 'N', 'I', 'X', 'Z', 'U', 'R', '?', 'D', 'T', 'E', 'S', 'A', 'M', 'B', 'L' };
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   121
const char* blobTypeName[] = {"noType"
51124
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
   122
                             ,     "nMethod (under construction)"
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
   123
                             ,          "nMethod (active)"
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
   124
                             ,               "nMethod (inactive)"
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
   125
                             ,                    "nMethod (deopt)"
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
   126
                             ,                         "nMethod (zombie)"
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
   127
                             ,                              "nMethod (unloaded)"
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
   128
                             ,                                   "runtime stub"
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
   129
                             ,                                        "ricochet stub"
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
   130
                             ,                                             "deopt stub"
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
   131
                             ,                                                  "uncommon trap stub"
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
   132
                             ,                                                       "exception stub"
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
   133
                             ,                                                            "safepoint stub"
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
   134
                             ,                                                                 "adapter blob"
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
   135
                             ,                                                                      "MH adapter blob"
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
   136
                             ,                                                                           "buffer blob"
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
   137
                             ,                                                                                "lastType"
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   138
                             };
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   139
const char* compTypeName[] = { "none", "c1", "c2", "jvmci" };
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   140
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   141
// Be prepared for ten different CodeHeap segments. Should be enough for a few years.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   142
const  unsigned int        nSizeDistElements = 31;  // logarithmic range growth, max size: 2**32
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   143
const  unsigned int        maxTopSizeBlocks  = 50;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   144
const  unsigned int        tsbStopper        = 2 * maxTopSizeBlocks;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   145
const  unsigned int        maxHeaps          = 10;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   146
static unsigned int        nHeaps            = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   147
static struct CodeHeapStat CodeHeapStatArray[maxHeaps];
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   148
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   149
// static struct StatElement *StatArray      = NULL;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   150
static StatElement* StatArray             = NULL;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   151
static int          log2_seg_size         = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   152
static size_t       seg_size              = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   153
static size_t       alloc_granules        = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   154
static size_t       granule_size          = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   155
static bool         segment_granules      = false;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   156
static unsigned int nBlocks_t1            = 0;  // counting "in_use" nmethods only.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   157
static unsigned int nBlocks_t2            = 0;  // counting "in_use" nmethods only.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   158
static unsigned int nBlocks_alive         = 0;  // counting "not_used" and "not_entrant" nmethods only.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   159
static unsigned int nBlocks_dead          = 0;  // counting "zombie" and "unloaded" methods only.
51124
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
   160
static unsigned int nBlocks_inconstr      = 0;  // counting "inconstruction" nmethods only. This is a transient state.
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
   161
static unsigned int nBlocks_unloaded      = 0;  // counting "unloaded" nmethods only. This is a transient state.
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   162
static unsigned int nBlocks_stub          = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   163
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   164
static struct FreeBlk*          FreeArray = NULL;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   165
static unsigned int      alloc_freeBlocks = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   166
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   167
static struct TopSizeBlk*    TopSizeArray = NULL;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   168
static unsigned int   alloc_topSizeBlocks = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   169
static unsigned int    used_topSizeBlocks = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   170
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   171
static struct SizeDistributionElement*  SizeDistributionArray = NULL;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   172
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   173
// nMethod temperature (hotness) indicators.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   174
static int                     avgTemp    = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   175
static int                     maxTemp    = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   176
static int                     minTemp    = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   177
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   178
static unsigned int  latest_compilation_id   = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   179
static volatile bool initialization_complete = false;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   180
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   181
const char* CodeHeapState::get_heapName(CodeHeap* heap) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   182
  if (SegmentedCodeCache) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   183
    return heap->name();
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   184
  } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   185
    return "CodeHeap";
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   186
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   187
}
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   188
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   189
// returns the index for the heap being processed.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   190
unsigned int CodeHeapState::findHeapIndex(outputStream* out, const char* heapName) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   191
  if (heapName == NULL) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   192
    return maxHeaps;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   193
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   194
  if (SegmentedCodeCache) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   195
    // Search for a pre-existing entry. If found, return that index.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   196
    for (unsigned int i = 0; i < nHeaps; i++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   197
      if (CodeHeapStatArray[i].heapName != NULL && strcmp(heapName, CodeHeapStatArray[i].heapName) == 0) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   198
        return i;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   199
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   200
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   201
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   202
    // check if there are more code heap segments than we can handle.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   203
    if (nHeaps == maxHeaps) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   204
      out->print_cr("Too many heap segments for current limit(%d).", maxHeaps);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   205
      return maxHeaps;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   206
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   207
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   208
    // allocate new slot in StatArray.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   209
    CodeHeapStatArray[nHeaps].heapName = heapName;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   210
    return nHeaps++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   211
  } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   212
    nHeaps = 1;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   213
    CodeHeapStatArray[0].heapName = heapName;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   214
    return 0; // This is the default index if CodeCache is not segmented.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   215
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   216
}
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   217
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   218
void CodeHeapState::get_HeapStatGlobals(outputStream* out, const char* heapName) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   219
  unsigned int ix = findHeapIndex(out, heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   220
  if (ix < maxHeaps) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   221
    StatArray             = CodeHeapStatArray[ix].StatArray;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   222
    seg_size              = CodeHeapStatArray[ix].segment_size;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   223
    log2_seg_size         = seg_size == 0 ? 0 : exact_log2(seg_size);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   224
    alloc_granules        = CodeHeapStatArray[ix].alloc_granules;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   225
    granule_size          = CodeHeapStatArray[ix].granule_size;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   226
    segment_granules      = CodeHeapStatArray[ix].segment_granules;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   227
    nBlocks_t1            = CodeHeapStatArray[ix].nBlocks_t1;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   228
    nBlocks_t2            = CodeHeapStatArray[ix].nBlocks_t2;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   229
    nBlocks_alive         = CodeHeapStatArray[ix].nBlocks_alive;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   230
    nBlocks_dead          = CodeHeapStatArray[ix].nBlocks_dead;
51124
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
   231
    nBlocks_inconstr      = CodeHeapStatArray[ix].nBlocks_inconstr;
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   232
    nBlocks_unloaded      = CodeHeapStatArray[ix].nBlocks_unloaded;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   233
    nBlocks_stub          = CodeHeapStatArray[ix].nBlocks_stub;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   234
    FreeArray             = CodeHeapStatArray[ix].FreeArray;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   235
    alloc_freeBlocks      = CodeHeapStatArray[ix].alloc_freeBlocks;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   236
    TopSizeArray          = CodeHeapStatArray[ix].TopSizeArray;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   237
    alloc_topSizeBlocks   = CodeHeapStatArray[ix].alloc_topSizeBlocks;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   238
    used_topSizeBlocks    = CodeHeapStatArray[ix].used_topSizeBlocks;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   239
    SizeDistributionArray = CodeHeapStatArray[ix].SizeDistributionArray;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   240
    avgTemp               = CodeHeapStatArray[ix].avgTemp;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   241
    maxTemp               = CodeHeapStatArray[ix].maxTemp;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   242
    minTemp               = CodeHeapStatArray[ix].minTemp;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   243
  } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   244
    StatArray             = NULL;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   245
    seg_size              = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   246
    log2_seg_size         = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   247
    alloc_granules        = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   248
    granule_size          = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   249
    segment_granules      = false;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   250
    nBlocks_t1            = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   251
    nBlocks_t2            = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   252
    nBlocks_alive         = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   253
    nBlocks_dead          = 0;
51124
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
   254
    nBlocks_inconstr      = 0;
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   255
    nBlocks_unloaded      = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   256
    nBlocks_stub          = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   257
    FreeArray             = NULL;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   258
    alloc_freeBlocks      = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   259
    TopSizeArray          = NULL;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   260
    alloc_topSizeBlocks   = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   261
    used_topSizeBlocks    = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   262
    SizeDistributionArray = NULL;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   263
    avgTemp               = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   264
    maxTemp               = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   265
    minTemp               = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   266
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   267
}
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   268
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   269
void CodeHeapState::set_HeapStatGlobals(outputStream* out, const char* heapName) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   270
  unsigned int ix = findHeapIndex(out, heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   271
  if (ix < maxHeaps) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   272
    CodeHeapStatArray[ix].StatArray             = StatArray;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   273
    CodeHeapStatArray[ix].segment_size          = seg_size;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   274
    CodeHeapStatArray[ix].alloc_granules        = alloc_granules;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   275
    CodeHeapStatArray[ix].granule_size          = granule_size;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   276
    CodeHeapStatArray[ix].segment_granules      = segment_granules;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   277
    CodeHeapStatArray[ix].nBlocks_t1            = nBlocks_t1;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   278
    CodeHeapStatArray[ix].nBlocks_t2            = nBlocks_t2;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   279
    CodeHeapStatArray[ix].nBlocks_alive         = nBlocks_alive;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   280
    CodeHeapStatArray[ix].nBlocks_dead          = nBlocks_dead;
51124
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
   281
    CodeHeapStatArray[ix].nBlocks_inconstr      = nBlocks_inconstr;
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   282
    CodeHeapStatArray[ix].nBlocks_unloaded      = nBlocks_unloaded;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   283
    CodeHeapStatArray[ix].nBlocks_stub          = nBlocks_stub;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   284
    CodeHeapStatArray[ix].FreeArray             = FreeArray;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   285
    CodeHeapStatArray[ix].alloc_freeBlocks      = alloc_freeBlocks;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   286
    CodeHeapStatArray[ix].TopSizeArray          = TopSizeArray;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   287
    CodeHeapStatArray[ix].alloc_topSizeBlocks   = alloc_topSizeBlocks;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   288
    CodeHeapStatArray[ix].used_topSizeBlocks    = used_topSizeBlocks;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   289
    CodeHeapStatArray[ix].SizeDistributionArray = SizeDistributionArray;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   290
    CodeHeapStatArray[ix].avgTemp               = avgTemp;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   291
    CodeHeapStatArray[ix].maxTemp               = maxTemp;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   292
    CodeHeapStatArray[ix].minTemp               = minTemp;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   293
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   294
}
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   295
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   296
//---<  get a new statistics array  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   297
void CodeHeapState::prepare_StatArray(outputStream* out, size_t nElem, size_t granularity, const char* heapName) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   298
  if (StatArray == NULL) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   299
    StatArray      = new StatElement[nElem];
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   300
    //---<  reset some counts  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   301
    alloc_granules = nElem;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   302
    granule_size   = granularity;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   303
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   304
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   305
  if (StatArray == NULL) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   306
    //---<  just do nothing if allocation failed  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   307
    out->print_cr("Statistics could not be collected for %s, probably out of memory.", heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   308
    out->print_cr("Current granularity is " SIZE_FORMAT " bytes. Try a coarser granularity.", granularity);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   309
    alloc_granules = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   310
    granule_size   = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   311
  } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   312
    //---<  initialize statistics array  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   313
    memset((void*)StatArray, 0, nElem*sizeof(StatElement));
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   314
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   315
}
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   316
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   317
//---<  get a new free block array  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   318
void CodeHeapState::prepare_FreeArray(outputStream* out, unsigned int nElem, const char* heapName) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   319
  if (FreeArray == NULL) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   320
    FreeArray      = new FreeBlk[nElem];
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   321
    //---<  reset some counts  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   322
    alloc_freeBlocks = nElem;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   323
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   324
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   325
  if (FreeArray == NULL) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   326
    //---<  just do nothing if allocation failed  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   327
    out->print_cr("Free space analysis cannot be done for %s, probably out of memory.", heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   328
    alloc_freeBlocks = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   329
  } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   330
    //---<  initialize free block array  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   331
    memset((void*)FreeArray, 0, alloc_freeBlocks*sizeof(FreeBlk));
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   332
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   333
}
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   334
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   335
//---<  get a new TopSizeArray  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   336
void CodeHeapState::prepare_TopSizeArray(outputStream* out, unsigned int nElem, const char* heapName) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   337
  if (TopSizeArray == NULL) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   338
    TopSizeArray   = new TopSizeBlk[nElem];
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   339
    //---<  reset some counts  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   340
    alloc_topSizeBlocks = nElem;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   341
    used_topSizeBlocks  = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   342
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   343
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   344
  if (TopSizeArray == NULL) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   345
    //---<  just do nothing if allocation failed  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   346
    out->print_cr("Top-%d list of largest CodeHeap blocks can not be collected for %s, probably out of memory.", nElem, heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   347
    alloc_topSizeBlocks = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   348
  } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   349
    //---<  initialize TopSizeArray  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   350
    memset((void*)TopSizeArray, 0, nElem*sizeof(TopSizeBlk));
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   351
    used_topSizeBlocks  = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   352
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   353
}
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   354
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   355
//---<  get a new SizeDistributionArray  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   356
void CodeHeapState::prepare_SizeDistArray(outputStream* out, unsigned int nElem, const char* heapName) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   357
  if (SizeDistributionArray == NULL) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   358
    SizeDistributionArray = new SizeDistributionElement[nElem];
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   359
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   360
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   361
  if (SizeDistributionArray == NULL) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   362
    //---<  just do nothing if allocation failed  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   363
    out->print_cr("Size distribution can not be collected for %s, probably out of memory.", heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   364
  } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   365
    //---<  initialize SizeDistArray  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   366
    memset((void*)SizeDistributionArray, 0, nElem*sizeof(SizeDistributionElement));
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   367
    // Logarithmic range growth. First range starts at _segment_size.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   368
    SizeDistributionArray[log2_seg_size-1].rangeEnd = 1U;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   369
    for (unsigned int i = log2_seg_size; i < nElem; i++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   370
      SizeDistributionArray[i].rangeStart = 1U << (i     - log2_seg_size);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   371
      SizeDistributionArray[i].rangeEnd   = 1U << ((i+1) - log2_seg_size);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   372
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   373
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   374
}
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   375
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   376
//---<  get a new SizeDistributionArray  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   377
void CodeHeapState::update_SizeDistArray(outputStream* out, unsigned int len) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   378
  if (SizeDistributionArray != NULL) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   379
    for (unsigned int i = log2_seg_size-1; i < nSizeDistElements; i++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   380
      if ((SizeDistributionArray[i].rangeStart <= len) && (len < SizeDistributionArray[i].rangeEnd)) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   381
        SizeDistributionArray[i].lenSum += len;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   382
        SizeDistributionArray[i].count++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   383
        break;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   384
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   385
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   386
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   387
}
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   388
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   389
void CodeHeapState::discard_StatArray(outputStream* out) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   390
  if (StatArray != NULL) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   391
    delete StatArray;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   392
    StatArray        = NULL;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   393
    alloc_granules   = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   394
    granule_size     = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   395
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   396
}
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   397
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   398
void CodeHeapState::discard_FreeArray(outputStream* out) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   399
  if (FreeArray != NULL) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   400
    delete[] FreeArray;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   401
    FreeArray        = NULL;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   402
    alloc_freeBlocks = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   403
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   404
}
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   405
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   406
void CodeHeapState::discard_TopSizeArray(outputStream* out) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   407
  if (TopSizeArray != NULL) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   408
    delete[] TopSizeArray;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   409
    TopSizeArray        = NULL;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   410
    alloc_topSizeBlocks = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   411
    used_topSizeBlocks  = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   412
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   413
}
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   414
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   415
void CodeHeapState::discard_SizeDistArray(outputStream* out) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   416
  if (SizeDistributionArray != NULL) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   417
    delete[] SizeDistributionArray;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   418
    SizeDistributionArray = NULL;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   419
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   420
}
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   421
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   422
// Discard all allocated internal data structures.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   423
// This should be done after an analysis session is completed.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   424
void CodeHeapState::discard(outputStream* out, CodeHeap* heap) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   425
  if (!initialization_complete) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   426
    return;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   427
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   428
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   429
  if (nHeaps > 0) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   430
    for (unsigned int ix = 0; ix < nHeaps; ix++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   431
      get_HeapStatGlobals(out, CodeHeapStatArray[ix].heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   432
      discard_StatArray(out);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   433
      discard_FreeArray(out);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   434
      discard_TopSizeArray(out);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   435
      discard_SizeDistArray(out);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   436
      set_HeapStatGlobals(out, CodeHeapStatArray[ix].heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   437
      CodeHeapStatArray[ix].heapName = NULL;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   438
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   439
    nHeaps = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   440
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   441
}
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   442
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   443
void CodeHeapState::aggregate(outputStream* out, CodeHeap* heap, const char* granularity_request) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   444
  unsigned int nBlocks_free    = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   445
  unsigned int nBlocks_used    = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   446
  unsigned int nBlocks_zomb    = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   447
  unsigned int nBlocks_disconn = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   448
  unsigned int nBlocks_notentr = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   449
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   450
  //---<  max & min of TopSizeArray  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   451
  //  it is sufficient to have these sizes as 32bit unsigned ints.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   452
  //  The CodeHeap is limited in size to 4GB. Furthermore, the sizes
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   453
  //  are stored in _segment_size units, scaling them down by a factor of 64 (at least).
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   454
  unsigned int  currMax          = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   455
  unsigned int  currMin          = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   456
  unsigned int  currMin_ix       = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   457
  unsigned long total_iterations = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   458
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   459
  bool  done             = false;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   460
  const int min_granules = 256;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   461
  const int max_granules = 512*K; // limits analyzable CodeHeap (with segment_granules) to 32M..128M
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   462
                                  // results in StatArray size of 20M (= max_granules * 40 Bytes per element)
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   463
                                  // For a 1GB CodeHeap, the granule size must be at least 2kB to not violate the max_granles limit.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   464
  const char* heapName   = get_heapName(heap);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   465
  STRINGSTREAM_DECL(ast, out)
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   466
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   467
  if (!initialization_complete) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   468
    memset(CodeHeapStatArray, 0, sizeof(CodeHeapStatArray));
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   469
    initialization_complete = true;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   470
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   471
    printBox(ast, '=', "C O D E   H E A P   A N A L Y S I S   (general remarks)", NULL);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   472
    ast->print_cr("   The code heap analysis function provides deep insights into\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   473
                  "   the inner workings and the internal state of the Java VM's\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   474
                  "   code cache - the place where all the JVM generated machine\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   475
                  "   code is stored.\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   476
                  "   \n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   477
                  "   This function is designed and provided for support engineers\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   478
                  "   to help them understand and solve issues in customer systems.\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   479
                  "   It is not intended for use and interpretation by other persons.\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   480
                  "   \n");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   481
    STRINGSTREAM_FLUSH("")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   482
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   483
  get_HeapStatGlobals(out, heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   484
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   485
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   486
  // Since we are (and must be) analyzing the CodeHeap contents under the CodeCache_lock,
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   487
  // all heap information is "constant" and can be safely extracted/calculated before we
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   488
  // enter the while() loop. Actually, the loop will only be iterated once.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   489
  char*  low_bound     = heap->low_boundary();
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   490
  size_t size          = heap->capacity();
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   491
  size_t res_size      = heap->max_capacity();
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   492
  seg_size             = heap->segment_size();
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   493
  log2_seg_size        = seg_size == 0 ? 0 : exact_log2(seg_size);  // This is a global static value.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   494
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   495
  if (seg_size == 0) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   496
    printBox(ast, '-', "Heap not fully initialized yet, segment size is zero for segment ", heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   497
    STRINGSTREAM_FLUSH("")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   498
    return;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   499
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   500
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   501
  // Calculate granularity of analysis (and output).
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   502
  //   The CodeHeap is managed (allocated) in segments (units) of CodeCacheSegmentSize.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   503
  //   The CodeHeap can become fairly large, in particular in productive real-life systems.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   504
  //
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   505
  //   It is often neither feasible nor desirable to aggregate the data with the highest possible
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   506
  //   level of detail, i.e. inspecting and printing each segment on its own.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   507
  //
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   508
  //   The granularity parameter allows to specify the level of detail available in the analysis.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   509
  //   It must be a positive multiple of the segment size and should be selected such that enough
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   510
  //   detail is provided while, at the same time, the printed output does not explode.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   511
  //
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   512
  //   By manipulating the granularity value, we enforce that at least min_granules units
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   513
  //   of analysis are available. We also enforce an upper limit of max_granules units to
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   514
  //   keep the amount of allocated storage in check.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   515
  //
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   516
  //   Finally, we adjust the granularity such that each granule covers at most 64k-1 segments.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   517
  //   This is necessary to prevent an unsigned short overflow while accumulating space information.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   518
  //
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   519
  size_t granularity = strtol(granularity_request, NULL, 0);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   520
  if (granularity > size) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   521
    granularity = size;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   522
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   523
  if (size/granularity < min_granules) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   524
    granularity = size/min_granules;                                   // at least min_granules granules
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   525
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   526
  granularity = granularity & (~(seg_size - 1));                       // must be multiple of seg_size
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   527
  if (granularity < seg_size) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   528
    granularity = seg_size;                                            // must be at least seg_size
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   529
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   530
  if (size/granularity > max_granules) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   531
    granularity = size/max_granules;                                   // at most max_granules granules
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   532
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   533
  granularity = granularity & (~(seg_size - 1));                       // must be multiple of seg_size
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   534
  if (granularity>>log2_seg_size >= (1L<<sizeof(unsigned short)*8)) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   535
    granularity = ((1L<<(sizeof(unsigned short)*8))-1)<<log2_seg_size; // Limit: (64k-1) * seg_size
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   536
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   537
  segment_granules = granularity == seg_size;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   538
  size_t granules  = (size + (granularity-1))/granularity;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   539
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   540
  printBox(ast, '=', "C O D E   H E A P   A N A L Y S I S   (used blocks) for segment ", heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   541
  ast->print_cr("   The aggregate step takes an aggregated snapshot of the CodeHeap.\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   542
                "   Subsequent print functions create their output based on this snapshot.\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   543
                "   The CodeHeap is a living thing, and every effort has been made for the\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   544
                "   collected data to be consistent. Only the method names and signatures\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   545
                "   are retrieved at print time. That may lead to rare cases where the\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   546
                "   name of a method is no longer available, e.g. because it was unloaded.\n");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   547
  ast->print_cr("   CodeHeap committed size " SIZE_FORMAT "K (" SIZE_FORMAT "M), reserved size " SIZE_FORMAT "K (" SIZE_FORMAT "M), %d%% occupied.",
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   548
                size/(size_t)K, size/(size_t)M, res_size/(size_t)K, res_size/(size_t)M, (unsigned int)(100.0*size/res_size));
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   549
  ast->print_cr("   CodeHeap allocation segment size is " SIZE_FORMAT " bytes. This is the smallest possible granularity.", seg_size);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   550
  ast->print_cr("   CodeHeap (committed part) is mapped to " SIZE_FORMAT " granules of size " SIZE_FORMAT " bytes.", granules, granularity);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   551
  ast->print_cr("   Each granule takes " SIZE_FORMAT " bytes of C heap, that is " SIZE_FORMAT "K in total for statistics data.", sizeof(StatElement), (sizeof(StatElement)*granules)/(size_t)K);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   552
  ast->print_cr("   The number of granules is limited to %dk, requiring a granules size of at least %d bytes for a 1GB heap.", (unsigned int)(max_granules/K), (unsigned int)(G/max_granules));
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   553
  STRINGSTREAM_FLUSH("\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   554
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   555
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   556
  while (!done) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   557
    //---<  reset counters with every aggregation  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   558
    nBlocks_t1       = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   559
    nBlocks_t2       = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   560
    nBlocks_alive    = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   561
    nBlocks_dead     = 0;
51124
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
   562
    nBlocks_inconstr = 0;
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   563
    nBlocks_unloaded = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   564
    nBlocks_stub     = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   565
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   566
    nBlocks_free     = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   567
    nBlocks_used     = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   568
    nBlocks_zomb     = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   569
    nBlocks_disconn  = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   570
    nBlocks_notentr  = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   571
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   572
    //---<  discard old arrays if size does not match  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   573
    if (granules != alloc_granules) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   574
      discard_StatArray(out);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   575
      discard_TopSizeArray(out);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   576
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   577
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   578
    //---<  allocate arrays if they don't yet exist, initialize  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   579
    prepare_StatArray(out, granules, granularity, heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   580
    if (StatArray == NULL) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   581
      set_HeapStatGlobals(out, heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   582
      return;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   583
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   584
    prepare_TopSizeArray(out, maxTopSizeBlocks, heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   585
    prepare_SizeDistArray(out, nSizeDistElements, heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   586
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   587
    latest_compilation_id = CompileBroker::get_compilation_id();
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   588
    unsigned int highest_compilation_id = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   589
    size_t       usedSpace     = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   590
    size_t       t1Space       = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   591
    size_t       t2Space       = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   592
    size_t       aliveSpace    = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   593
    size_t       disconnSpace  = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   594
    size_t       notentrSpace  = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   595
    size_t       deadSpace     = 0;
51124
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
   596
    size_t       inconstrSpace = 0;
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   597
    size_t       unloadedSpace = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   598
    size_t       stubSpace     = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   599
    size_t       freeSpace     = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   600
    size_t       maxFreeSize   = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   601
    HeapBlock*   maxFreeBlock  = NULL;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   602
    bool         insane        = false;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   603
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   604
    int64_t hotnessAccumulator = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   605
    unsigned int n_methods     = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   606
    avgTemp       = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   607
    minTemp       = (int)(res_size > M ? (res_size/M)*2 : 1);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   608
    maxTemp       = -minTemp;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   609
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   610
    for (HeapBlock *h = heap->first_block(); h != NULL && !insane; h = heap->next_block(h)) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   611
      unsigned int hb_len     = (unsigned int)h->length();  // despite being size_t, length can never overflow an unsigned int.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   612
      size_t       hb_bytelen = ((size_t)hb_len)<<log2_seg_size;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   613
      unsigned int ix_beg     = (unsigned int)(((char*)h-low_bound)/granule_size);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   614
      unsigned int ix_end     = (unsigned int)(((char*)h-low_bound+(hb_bytelen-1))/granule_size);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   615
      unsigned int compile_id = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   616
      CompLevel    comp_lvl   = CompLevel_none;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   617
      compType     cType      = noComp;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   618
      blobType     cbType     = noType;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   619
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   620
      //---<  some sanity checks  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   621
      // Do not assert here, just check, print error message and return.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   622
      // This is a diagnostic function. It is not supposed to tear down the VM.
49825
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
   623
      if ((char*)h <  low_bound) {
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   624
        insane = true; ast->print_cr("Sanity check: HeapBlock @%p below low bound (%p)", (char*)h, low_bound);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   625
      }
49825
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
   626
      if ((char*)h >  (low_bound + res_size)) {
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
   627
        insane = true; ast->print_cr("Sanity check: HeapBlock @%p outside reserved range (%p)", (char*)h, low_bound + res_size);
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
   628
      }
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
   629
      if ((char*)h >  (low_bound + size)) {
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
   630
        insane = true; ast->print_cr("Sanity check: HeapBlock @%p outside used range (%p)", (char*)h, low_bound + size);
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
   631
      }
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
   632
      if (ix_end   >= granules) {
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   633
        insane = true; ast->print_cr("Sanity check: end index (%d) out of bounds (" SIZE_FORMAT ")", ix_end, granules);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   634
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   635
      if (size     != heap->capacity()) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   636
        insane = true; ast->print_cr("Sanity check: code heap capacity has changed (" SIZE_FORMAT "K to " SIZE_FORMAT "K)", size/(size_t)K, heap->capacity()/(size_t)K);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   637
      }
49825
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
   638
      if (ix_beg   >  ix_end) {
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   639
        insane = true; ast->print_cr("Sanity check: end index (%d) lower than begin index (%d)", ix_end, ix_beg);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   640
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   641
      if (insane) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   642
        STRINGSTREAM_FLUSH("")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   643
        continue;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   644
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   645
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   646
      if (h->free()) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   647
        nBlocks_free++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   648
        freeSpace    += hb_bytelen;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   649
        if (hb_bytelen > maxFreeSize) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   650
          maxFreeSize   = hb_bytelen;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   651
          maxFreeBlock  = h;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   652
        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   653
      } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   654
        update_SizeDistArray(out, hb_len);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   655
        nBlocks_used++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   656
        usedSpace    += hb_bytelen;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   657
        CodeBlob* cb  = (CodeBlob*)heap->find_start(h);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   658
        if (cb != NULL) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   659
          cbType = get_cbType(cb);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   660
          if (cb->is_nmethod()) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   661
            compile_id = ((nmethod*)cb)->compile_id();
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   662
            comp_lvl   = (CompLevel)((nmethod*)cb)->comp_level();
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   663
            if (((nmethod*)cb)->is_compiled_by_c1()) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   664
              cType = c1;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   665
            }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   666
            if (((nmethod*)cb)->is_compiled_by_c2()) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   667
              cType = c2;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   668
            }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   669
            if (((nmethod*)cb)->is_compiled_by_jvmci()) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   670
              cType = jvmci;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   671
            }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   672
            switch (cbType) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   673
              case nMethod_inuse: { // only for executable methods!!!
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   674
                // space for these cbs is accounted for later.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   675
                int temperature = ((nmethod*)cb)->hotness_counter();
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   676
                hotnessAccumulator += temperature;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   677
                n_methods++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   678
                maxTemp = (temperature > maxTemp) ? temperature : maxTemp;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   679
                minTemp = (temperature < minTemp) ? temperature : minTemp;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   680
                break;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   681
              }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   682
              case nMethod_notused:
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   683
                nBlocks_alive++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   684
                nBlocks_disconn++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   685
                aliveSpace     += hb_bytelen;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   686
                disconnSpace   += hb_bytelen;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   687
                break;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   688
              case nMethod_notentrant:  // equivalent to nMethod_alive
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   689
                nBlocks_alive++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   690
                nBlocks_notentr++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   691
                aliveSpace     += hb_bytelen;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   692
                notentrSpace   += hb_bytelen;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   693
                break;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   694
              case nMethod_unloaded:
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   695
                nBlocks_unloaded++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   696
                unloadedSpace  += hb_bytelen;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   697
                break;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   698
              case nMethod_dead:
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   699
                nBlocks_dead++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   700
                deadSpace      += hb_bytelen;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   701
                break;
51124
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
   702
              case nMethod_inconstruction:
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
   703
                nBlocks_inconstr++;
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
   704
                inconstrSpace  += hb_bytelen;
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
   705
                break;
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   706
              default:
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   707
                break;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   708
            }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   709
          }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   710
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   711
          //------------------------------------------
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   712
          //---<  register block in TopSizeArray  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   713
          //------------------------------------------
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   714
          if (alloc_topSizeBlocks > 0) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   715
            if (used_topSizeBlocks == 0) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   716
              TopSizeArray[0].start    = h;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   717
              TopSizeArray[0].len      = hb_len;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   718
              TopSizeArray[0].index    = tsbStopper;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   719
              TopSizeArray[0].compiler = cType;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   720
              TopSizeArray[0].level    = comp_lvl;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   721
              TopSizeArray[0].type     = cbType;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   722
              currMax    = hb_len;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   723
              currMin    = hb_len;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   724
              currMin_ix = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   725
              used_topSizeBlocks++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   726
            // This check roughly cuts 5000 iterations (JVM98, mixed, dbg, termination stats):
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   727
            } else if ((used_topSizeBlocks < alloc_topSizeBlocks) && (hb_len < currMin)) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   728
              //---<  all blocks in list are larger, but there is room left in array  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   729
              TopSizeArray[currMin_ix].index = used_topSizeBlocks;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   730
              TopSizeArray[used_topSizeBlocks].start    = h;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   731
              TopSizeArray[used_topSizeBlocks].len      = hb_len;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   732
              TopSizeArray[used_topSizeBlocks].index    = tsbStopper;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   733
              TopSizeArray[used_topSizeBlocks].compiler = cType;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   734
              TopSizeArray[used_topSizeBlocks].level    = comp_lvl;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   735
              TopSizeArray[used_topSizeBlocks].type     = cbType;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   736
              currMin    = hb_len;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   737
              currMin_ix = used_topSizeBlocks;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   738
              used_topSizeBlocks++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   739
            } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   740
              // This check cuts total_iterations by a factor of 6 (JVM98, mixed, dbg, termination stats):
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   741
              //   We don't need to search the list if we know beforehand that the current block size is
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   742
              //   smaller than the currently recorded minimum and there is no free entry left in the list.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   743
              if (!((used_topSizeBlocks == alloc_topSizeBlocks) && (hb_len <= currMin))) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   744
                if (currMax < hb_len) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   745
                  currMax = hb_len;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   746
                }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   747
                unsigned int i;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   748
                unsigned int prev_i  = tsbStopper;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   749
                unsigned int limit_i =  0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   750
                for (i = 0; i != tsbStopper; i = TopSizeArray[i].index) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   751
                  if (limit_i++ >= alloc_topSizeBlocks) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   752
                    insane = true; break; // emergency exit
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   753
                  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   754
                  if (i >= used_topSizeBlocks)  {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   755
                    insane = true; break; // emergency exit
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   756
                  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   757
                  total_iterations++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   758
                  if (TopSizeArray[i].len < hb_len) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   759
                    //---<  We want to insert here, element <i> is smaller than the current one  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   760
                    if (used_topSizeBlocks < alloc_topSizeBlocks) { // still room for a new entry to insert
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   761
                      // old entry gets moved to the next free element of the array.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   762
                      // That's necessary to keep the entry for the largest block at index 0.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   763
                      // This move might cause the current minimum to be moved to another place
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   764
                      if (i == currMin_ix) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   765
                        assert(TopSizeArray[i].len == currMin, "sort error");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   766
                        currMin_ix = used_topSizeBlocks;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   767
                      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   768
                      memcpy((void*)&TopSizeArray[used_topSizeBlocks], (void*)&TopSizeArray[i], sizeof(TopSizeBlk));
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   769
                      TopSizeArray[i].start    = h;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   770
                      TopSizeArray[i].len      = hb_len;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   771
                      TopSizeArray[i].index    = used_topSizeBlocks;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   772
                      TopSizeArray[i].compiler = cType;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   773
                      TopSizeArray[i].level    = comp_lvl;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   774
                      TopSizeArray[i].type     = cbType;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   775
                      used_topSizeBlocks++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   776
                    } else { // no room for new entries, current block replaces entry for smallest block
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   777
                      //---<  Find last entry (entry for smallest remembered block)  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   778
                      unsigned int      j  = i;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   779
                      unsigned int prev_j  = tsbStopper;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   780
                      unsigned int limit_j = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   781
                      while (TopSizeArray[j].index != tsbStopper) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   782
                        if (limit_j++ >= alloc_topSizeBlocks) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   783
                          insane = true; break; // emergency exit
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   784
                        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   785
                        if (j >= used_topSizeBlocks)  {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   786
                          insane = true; break; // emergency exit
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   787
                        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   788
                        total_iterations++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   789
                        prev_j = j;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   790
                        j      = TopSizeArray[j].index;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   791
                      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   792
                      if (!insane) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   793
                        if (prev_j == tsbStopper) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   794
                          //---<  Above while loop did not iterate, we already are the min entry  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   795
                          //---<  We have to just replace the smallest entry                      >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   796
                          currMin    = hb_len;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   797
                          currMin_ix = j;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   798
                          TopSizeArray[j].start    = h;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   799
                          TopSizeArray[j].len      = hb_len;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   800
                          TopSizeArray[j].index    = tsbStopper; // already set!!
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   801
                          TopSizeArray[j].compiler = cType;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   802
                          TopSizeArray[j].level    = comp_lvl;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   803
                          TopSizeArray[j].type     = cbType;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   804
                        } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   805
                          //---<  second-smallest entry is now smallest  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   806
                          TopSizeArray[prev_j].index = tsbStopper;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   807
                          currMin    = TopSizeArray[prev_j].len;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   808
                          currMin_ix = prev_j;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   809
                          //---<  smallest entry gets overwritten  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   810
                          memcpy((void*)&TopSizeArray[j], (void*)&TopSizeArray[i], sizeof(TopSizeBlk));
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   811
                          TopSizeArray[i].start    = h;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   812
                          TopSizeArray[i].len      = hb_len;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   813
                          TopSizeArray[i].index    = j;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   814
                          TopSizeArray[i].compiler = cType;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   815
                          TopSizeArray[i].level    = comp_lvl;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   816
                          TopSizeArray[i].type     = cbType;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   817
                        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   818
                      } // insane
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   819
                    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   820
                    break;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   821
                  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   822
                  prev_i = i;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   823
                }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   824
                if (insane) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   825
                  // Note: regular analysis could probably continue by resetting "insane" flag.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   826
                  out->print_cr("Possible loop in TopSizeBlocks list detected. Analysis aborted.");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   827
                  discard_TopSizeArray(out);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   828
                }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   829
              }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   830
            }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   831
          }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   832
          //----------------------------------------------
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   833
          //---<  END register block in TopSizeArray  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   834
          //----------------------------------------------
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   835
        } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   836
          nBlocks_zomb++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   837
        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   838
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   839
        if (ix_beg == ix_end) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   840
          StatArray[ix_beg].type = cbType;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   841
          switch (cbType) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   842
            case nMethod_inuse:
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   843
              highest_compilation_id = (highest_compilation_id >= compile_id) ? highest_compilation_id : compile_id;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   844
              if (comp_lvl < CompLevel_full_optimization) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   845
                nBlocks_t1++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   846
                t1Space   += hb_bytelen;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   847
                StatArray[ix_beg].t1_count++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   848
                StatArray[ix_beg].t1_space += (unsigned short)hb_len;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   849
                StatArray[ix_beg].t1_age    = StatArray[ix_beg].t1_age < compile_id ? compile_id : StatArray[ix_beg].t1_age;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   850
              } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   851
                nBlocks_t2++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   852
                t2Space   += hb_bytelen;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   853
                StatArray[ix_beg].t2_count++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   854
                StatArray[ix_beg].t2_space += (unsigned short)hb_len;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   855
                StatArray[ix_beg].t2_age    = StatArray[ix_beg].t2_age < compile_id ? compile_id : StatArray[ix_beg].t2_age;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   856
              }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   857
              StatArray[ix_beg].level     = comp_lvl;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   858
              StatArray[ix_beg].compiler  = cType;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   859
              break;
51124
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
   860
            case nMethod_inconstruction: // let's count "in construction" nmethods here.
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   861
            case nMethod_alive:
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   862
              StatArray[ix_beg].tx_count++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   863
              StatArray[ix_beg].tx_space += (unsigned short)hb_len;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   864
              StatArray[ix_beg].tx_age    = StatArray[ix_beg].tx_age < compile_id ? compile_id : StatArray[ix_beg].tx_age;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   865
              StatArray[ix_beg].level     = comp_lvl;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   866
              StatArray[ix_beg].compiler  = cType;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   867
              break;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   868
            case nMethod_dead:
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   869
            case nMethod_unloaded:
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   870
              StatArray[ix_beg].dead_count++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   871
              StatArray[ix_beg].dead_space += (unsigned short)hb_len;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   872
              break;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   873
            default:
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   874
              // must be a stub, if it's not a dead or alive nMethod
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   875
              nBlocks_stub++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   876
              stubSpace   += hb_bytelen;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   877
              StatArray[ix_beg].stub_count++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   878
              StatArray[ix_beg].stub_space += (unsigned short)hb_len;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   879
              break;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   880
          }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   881
        } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   882
          unsigned int beg_space = (unsigned int)(granule_size - ((char*)h - low_bound - ix_beg*granule_size));
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   883
          unsigned int end_space = (unsigned int)(hb_bytelen - beg_space - (ix_end-ix_beg-1)*granule_size);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   884
          beg_space = beg_space>>log2_seg_size;  // store in units of _segment_size
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   885
          end_space = end_space>>log2_seg_size;  // store in units of _segment_size
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   886
          StatArray[ix_beg].type = cbType;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   887
          StatArray[ix_end].type = cbType;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   888
          switch (cbType) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   889
            case nMethod_inuse:
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   890
              highest_compilation_id = (highest_compilation_id >= compile_id) ? highest_compilation_id : compile_id;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   891
              if (comp_lvl < CompLevel_full_optimization) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   892
                nBlocks_t1++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   893
                t1Space   += hb_bytelen;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   894
                StatArray[ix_beg].t1_count++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   895
                StatArray[ix_beg].t1_space += (unsigned short)beg_space;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   896
                StatArray[ix_beg].t1_age    = StatArray[ix_beg].t1_age < compile_id ? compile_id : StatArray[ix_beg].t1_age;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   897
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   898
                StatArray[ix_end].t1_count++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   899
                StatArray[ix_end].t1_space += (unsigned short)end_space;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   900
                StatArray[ix_end].t1_age    = StatArray[ix_end].t1_age < compile_id ? compile_id : StatArray[ix_end].t1_age;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   901
              } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   902
                nBlocks_t2++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   903
                t2Space   += hb_bytelen;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   904
                StatArray[ix_beg].t2_count++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   905
                StatArray[ix_beg].t2_space += (unsigned short)beg_space;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   906
                StatArray[ix_beg].t2_age    = StatArray[ix_beg].t2_age < compile_id ? compile_id : StatArray[ix_beg].t2_age;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   907
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   908
                StatArray[ix_end].t2_count++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   909
                StatArray[ix_end].t2_space += (unsigned short)end_space;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   910
                StatArray[ix_end].t2_age    = StatArray[ix_end].t2_age < compile_id ? compile_id : StatArray[ix_end].t2_age;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   911
              }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   912
              StatArray[ix_beg].level     = comp_lvl;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   913
              StatArray[ix_beg].compiler  = cType;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   914
              StatArray[ix_end].level     = comp_lvl;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   915
              StatArray[ix_end].compiler  = cType;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   916
              break;
51124
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
   917
            case nMethod_inconstruction: // let's count "in construction" nmethods here.
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   918
            case nMethod_alive:
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   919
              StatArray[ix_beg].tx_count++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   920
              StatArray[ix_beg].tx_space += (unsigned short)beg_space;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   921
              StatArray[ix_beg].tx_age    = StatArray[ix_beg].tx_age < compile_id ? compile_id : StatArray[ix_beg].tx_age;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   922
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   923
              StatArray[ix_end].tx_count++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   924
              StatArray[ix_end].tx_space += (unsigned short)end_space;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   925
              StatArray[ix_end].tx_age    = StatArray[ix_end].tx_age < compile_id ? compile_id : StatArray[ix_end].tx_age;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   926
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   927
              StatArray[ix_beg].level     = comp_lvl;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   928
              StatArray[ix_beg].compiler  = cType;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   929
              StatArray[ix_end].level     = comp_lvl;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   930
              StatArray[ix_end].compiler  = cType;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   931
              break;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   932
            case nMethod_dead:
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   933
            case nMethod_unloaded:
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   934
              StatArray[ix_beg].dead_count++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   935
              StatArray[ix_beg].dead_space += (unsigned short)beg_space;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   936
              StatArray[ix_end].dead_count++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   937
              StatArray[ix_end].dead_space += (unsigned short)end_space;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   938
              break;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   939
            default:
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   940
              // must be a stub, if it's not a dead or alive nMethod
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   941
              nBlocks_stub++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   942
              stubSpace   += hb_bytelen;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   943
              StatArray[ix_beg].stub_count++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   944
              StatArray[ix_beg].stub_space += (unsigned short)beg_space;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   945
              StatArray[ix_end].stub_count++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   946
              StatArray[ix_end].stub_space += (unsigned short)end_space;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   947
              break;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   948
          }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   949
          for (unsigned int ix = ix_beg+1; ix < ix_end; ix++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   950
            StatArray[ix].type = cbType;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   951
            switch (cbType) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   952
              case nMethod_inuse:
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   953
                if (comp_lvl < CompLevel_full_optimization) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   954
                  StatArray[ix].t1_count++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   955
                  StatArray[ix].t1_space += (unsigned short)(granule_size>>log2_seg_size);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   956
                  StatArray[ix].t1_age    = StatArray[ix].t1_age < compile_id ? compile_id : StatArray[ix].t1_age;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   957
                } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   958
                  StatArray[ix].t2_count++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   959
                  StatArray[ix].t2_space += (unsigned short)(granule_size>>log2_seg_size);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   960
                  StatArray[ix].t2_age    = StatArray[ix].t2_age < compile_id ? compile_id : StatArray[ix].t2_age;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   961
                }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   962
                StatArray[ix].level     = comp_lvl;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   963
                StatArray[ix].compiler  = cType;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   964
                break;
51124
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
   965
              case nMethod_inconstruction: // let's count "in construction" nmethods here.
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   966
              case nMethod_alive:
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   967
                StatArray[ix].tx_count++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   968
                StatArray[ix].tx_space += (unsigned short)(granule_size>>log2_seg_size);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   969
                StatArray[ix].tx_age    = StatArray[ix].tx_age < compile_id ? compile_id : StatArray[ix].tx_age;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   970
                StatArray[ix].level     = comp_lvl;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   971
                StatArray[ix].compiler  = cType;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   972
                break;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   973
              case nMethod_dead:
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   974
              case nMethod_unloaded:
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   975
                StatArray[ix].dead_count++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   976
                StatArray[ix].dead_space += (unsigned short)(granule_size>>log2_seg_size);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   977
                break;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   978
              default:
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   979
                // must be a stub, if it's not a dead or alive nMethod
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   980
                StatArray[ix].stub_count++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   981
                StatArray[ix].stub_space += (unsigned short)(granule_size>>log2_seg_size);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   982
                break;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   983
            }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   984
          }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   985
        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   986
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   987
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   988
    done = true;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   989
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   990
    if (!insane) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   991
      // There is a risk for this block (because it contains many print statements) to get
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   992
      // interspersed with print data from other threads. We take this risk intentionally.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   993
      // Getting stalled waiting for tty_lock while holding the CodeCache_lock is not desirable.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   994
      printBox(ast, '-', "Global CodeHeap statistics for segment ", heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   995
      ast->print_cr("freeSpace        = " SIZE_FORMAT_W(8) "k, nBlocks_free     = %6d, %10.3f%% of capacity, %10.3f%% of max_capacity", freeSpace/(size_t)K,     nBlocks_free,     (100.0*freeSpace)/size,     (100.0*freeSpace)/res_size);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   996
      ast->print_cr("usedSpace        = " SIZE_FORMAT_W(8) "k, nBlocks_used     = %6d, %10.3f%% of capacity, %10.3f%% of max_capacity", usedSpace/(size_t)K,     nBlocks_used,     (100.0*usedSpace)/size,     (100.0*usedSpace)/res_size);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   997
      ast->print_cr("  Tier1 Space    = " SIZE_FORMAT_W(8) "k, nBlocks_t1       = %6d, %10.3f%% of capacity, %10.3f%% of max_capacity", t1Space/(size_t)K,       nBlocks_t1,       (100.0*t1Space)/size,       (100.0*t1Space)/res_size);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   998
      ast->print_cr("  Tier2 Space    = " SIZE_FORMAT_W(8) "k, nBlocks_t2       = %6d, %10.3f%% of capacity, %10.3f%% of max_capacity", t2Space/(size_t)K,       nBlocks_t2,       (100.0*t2Space)/size,       (100.0*t2Space)/res_size);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   999
      ast->print_cr("  Alive Space    = " SIZE_FORMAT_W(8) "k, nBlocks_alive    = %6d, %10.3f%% of capacity, %10.3f%% of max_capacity", aliveSpace/(size_t)K,    nBlocks_alive,    (100.0*aliveSpace)/size,    (100.0*aliveSpace)/res_size);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1000
      ast->print_cr("    disconnected = " SIZE_FORMAT_W(8) "k, nBlocks_disconn  = %6d, %10.3f%% of capacity, %10.3f%% of max_capacity", disconnSpace/(size_t)K,  nBlocks_disconn,  (100.0*disconnSpace)/size,  (100.0*disconnSpace)/res_size);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1001
      ast->print_cr("    not entrant  = " SIZE_FORMAT_W(8) "k, nBlocks_notentr  = %6d, %10.3f%% of capacity, %10.3f%% of max_capacity", notentrSpace/(size_t)K,  nBlocks_notentr,  (100.0*notentrSpace)/size,  (100.0*notentrSpace)/res_size);
51124
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
  1002
      ast->print_cr("  inconstrSpace  = " SIZE_FORMAT_W(8) "k, nBlocks_inconstr = %6d, %10.3f%% of capacity, %10.3f%% of max_capacity", inconstrSpace/(size_t)K, nBlocks_inconstr, (100.0*inconstrSpace)/size, (100.0*inconstrSpace)/res_size);
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1003
      ast->print_cr("  unloadedSpace  = " SIZE_FORMAT_W(8) "k, nBlocks_unloaded = %6d, %10.3f%% of capacity, %10.3f%% of max_capacity", unloadedSpace/(size_t)K, nBlocks_unloaded, (100.0*unloadedSpace)/size, (100.0*unloadedSpace)/res_size);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1004
      ast->print_cr("  deadSpace      = " SIZE_FORMAT_W(8) "k, nBlocks_dead     = %6d, %10.3f%% of capacity, %10.3f%% of max_capacity", deadSpace/(size_t)K,     nBlocks_dead,     (100.0*deadSpace)/size,     (100.0*deadSpace)/res_size);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1005
      ast->print_cr("  stubSpace      = " SIZE_FORMAT_W(8) "k, nBlocks_stub     = %6d, %10.3f%% of capacity, %10.3f%% of max_capacity", stubSpace/(size_t)K,     nBlocks_stub,     (100.0*stubSpace)/size,     (100.0*stubSpace)/res_size);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1006
      ast->print_cr("ZombieBlocks     = %8d. These are HeapBlocks which could not be identified as CodeBlobs.", nBlocks_zomb);
49825
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  1007
      ast->cr();
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  1008
      ast->print_cr("Segment start          = " INTPTR_FORMAT ", used space      = " SIZE_FORMAT_W(8)"k", p2i(low_bound), size/K);
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  1009
      ast->print_cr("Segment end (used)     = " INTPTR_FORMAT ", remaining space = " SIZE_FORMAT_W(8)"k", p2i(low_bound) + size, (res_size - size)/K);
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  1010
      ast->print_cr("Segment end (reserved) = " INTPTR_FORMAT ", reserved space  = " SIZE_FORMAT_W(8)"k", p2i(low_bound) + res_size, res_size/K);
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  1011
      ast->cr();
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1012
      ast->print_cr("latest allocated compilation id = %d", latest_compilation_id);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1013
      ast->print_cr("highest observed compilation id = %d", highest_compilation_id);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1014
      ast->print_cr("Building TopSizeList iterations = %ld", total_iterations);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1015
      ast->cr();
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1016
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1017
      int             reset_val = NMethodSweeper::hotness_counter_reset_val();
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1018
      double reverse_free_ratio = (res_size > size) ? (double)res_size/(double)(res_size-size) : (double)res_size;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1019
      printBox(ast, '-', "Method hotness information at time of this analysis", NULL);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1020
      ast->print_cr("Highest possible method temperature:          %12d", reset_val);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1021
      ast->print_cr("Threshold for method to be considered 'cold': %12.3f", -reset_val + reverse_free_ratio * NmethodSweepActivity);
51124
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
  1022
      if (n_methods > 0) {
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
  1023
        avgTemp = hotnessAccumulator/n_methods;
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
  1024
        ast->print_cr("min. hotness = %6d", minTemp);
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
  1025
        ast->print_cr("avg. hotness = %6d", avgTemp);
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
  1026
        ast->print_cr("max. hotness = %6d", maxTemp);
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
  1027
      } else {
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
  1028
        avgTemp = 0;
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
  1029
        ast->print_cr("No hotness data available");
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
  1030
      }
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1031
      STRINGSTREAM_FLUSH("\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1032
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1033
      // This loop is intentionally printing directly to "out".
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1034
      out->print("Verifying collected data...");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1035
      size_t granule_segs = granule_size>>log2_seg_size;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1036
      for (unsigned int ix = 0; ix < granules; ix++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1037
        if (StatArray[ix].t1_count   > granule_segs) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1038
          out->print_cr("t1_count[%d]   = %d", ix, StatArray[ix].t1_count);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1039
        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1040
        if (StatArray[ix].t2_count   > granule_segs) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1041
          out->print_cr("t2_count[%d]   = %d", ix, StatArray[ix].t2_count);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1042
        }
51124
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
  1043
        if (StatArray[ix].tx_count   > granule_segs) {
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
  1044
          out->print_cr("tx_count[%d]   = %d", ix, StatArray[ix].tx_count);
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
  1045
        }
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1046
        if (StatArray[ix].stub_count > granule_segs) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1047
          out->print_cr("stub_count[%d] = %d", ix, StatArray[ix].stub_count);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1048
        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1049
        if (StatArray[ix].dead_count > granule_segs) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1050
          out->print_cr("dead_count[%d] = %d", ix, StatArray[ix].dead_count);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1051
        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1052
        if (StatArray[ix].t1_space   > granule_segs) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1053
          out->print_cr("t1_space[%d]   = %d", ix, StatArray[ix].t1_space);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1054
        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1055
        if (StatArray[ix].t2_space   > granule_segs) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1056
          out->print_cr("t2_space[%d]   = %d", ix, StatArray[ix].t2_space);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1057
        }
51124
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
  1058
        if (StatArray[ix].tx_space   > granule_segs) {
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
  1059
          out->print_cr("tx_space[%d]   = %d", ix, StatArray[ix].tx_space);
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
  1060
        }
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1061
        if (StatArray[ix].stub_space > granule_segs) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1062
          out->print_cr("stub_space[%d] = %d", ix, StatArray[ix].stub_space);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1063
        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1064
        if (StatArray[ix].dead_space > granule_segs) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1065
          out->print_cr("dead_space[%d] = %d", ix, StatArray[ix].dead_space);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1066
        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1067
        //   this cast is awful! I need it because NT/Intel reports a signed/unsigned mismatch.
51124
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
  1068
        if ((size_t)(StatArray[ix].t1_count+StatArray[ix].t2_count+StatArray[ix].tx_count+StatArray[ix].stub_count+StatArray[ix].dead_count) > granule_segs) {
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
  1069
          out->print_cr("t1_count[%d] = %d, t2_count[%d] = %d, tx_count[%d] = %d, stub_count[%d] = %d", ix, StatArray[ix].t1_count, ix, StatArray[ix].t2_count, ix, StatArray[ix].tx_count, ix, StatArray[ix].stub_count);
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1070
        }
51124
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
  1071
        if ((size_t)(StatArray[ix].t1_space+StatArray[ix].t2_space+StatArray[ix].tx_space+StatArray[ix].stub_space+StatArray[ix].dead_space) > granule_segs) {
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
  1072
          out->print_cr("t1_space[%d] = %d, t2_space[%d] = %d, tx_space[%d] = %d, stub_space[%d] = %d", ix, StatArray[ix].t1_space, ix, StatArray[ix].t2_space, ix, StatArray[ix].tx_space, ix, StatArray[ix].stub_space);
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1073
        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1074
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1075
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1076
      // This loop is intentionally printing directly to "out".
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1077
      if (used_topSizeBlocks > 0) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1078
        unsigned int j = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1079
        if (TopSizeArray[0].len != currMax) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1080
          out->print_cr("currMax(%d) differs from TopSizeArray[0].len(%d)", currMax, TopSizeArray[0].len);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1081
        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1082
        for (unsigned int i = 0; (TopSizeArray[i].index != tsbStopper) && (j++ < alloc_topSizeBlocks); i = TopSizeArray[i].index) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1083
          if (TopSizeArray[i].len < TopSizeArray[TopSizeArray[i].index].len) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1084
            out->print_cr("sort error at index %d: %d !>= %d", i, TopSizeArray[i].len, TopSizeArray[TopSizeArray[i].index].len);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1085
          }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1086
        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1087
        if (j >= alloc_topSizeBlocks) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1088
          out->print_cr("Possible loop in TopSizeArray chaining!\n  allocBlocks = %d, usedBlocks = %d", alloc_topSizeBlocks, used_topSizeBlocks);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1089
          for (unsigned int i = 0; i < alloc_topSizeBlocks; i++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1090
            out->print_cr("  TopSizeArray[%d].index = %d, len = %d", i, TopSizeArray[i].index, TopSizeArray[i].len);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1091
          }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1092
        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1093
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1094
      out->print_cr("...done\n\n");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1095
    } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1096
      // insane heap state detected. Analysis data incomplete. Just throw it away.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1097
      discard_StatArray(out);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1098
      discard_TopSizeArray(out);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1099
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1100
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1101
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1102
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1103
  done        = false;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1104
  while (!done && (nBlocks_free > 0)) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1105
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1106
    printBox(ast, '=', "C O D E   H E A P   A N A L Y S I S   (free blocks) for segment ", heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1107
    ast->print_cr("   The aggregate step collects information about all free blocks in CodeHeap.\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1108
                  "   Subsequent print functions create their output based on this snapshot.\n");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1109
    ast->print_cr("   Free space in %s is distributed over %d free blocks.", heapName, nBlocks_free);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1110
    ast->print_cr("   Each free block takes " SIZE_FORMAT " bytes of C heap for statistics data, that is " SIZE_FORMAT "K in total.", sizeof(FreeBlk), (sizeof(FreeBlk)*nBlocks_free)/K);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1111
    STRINGSTREAM_FLUSH("\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1112
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1113
    //----------------------------------------
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1114
    //--  Prepare the FreeArray of FreeBlks --
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1115
    //----------------------------------------
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1116
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1117
    //---< discard old array if size does not match  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1118
    if (nBlocks_free != alloc_freeBlocks) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1119
      discard_FreeArray(out);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1120
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1121
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1122
    prepare_FreeArray(out, nBlocks_free, heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1123
    if (FreeArray == NULL) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1124
      done = true;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1125
      continue;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1126
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1127
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1128
    //----------------------------------------
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1129
    //--  Collect all FreeBlks in FreeArray --
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1130
    //----------------------------------------
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1131
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1132
    unsigned int ix = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1133
    FreeBlock* cur  = heap->freelist();
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1134
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1135
    while (cur != NULL) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1136
      if (ix < alloc_freeBlocks) { // don't index out of bounds if _freelist has more blocks than anticipated
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1137
        FreeArray[ix].start = cur;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1138
        FreeArray[ix].len   = (unsigned int)(cur->length()<<log2_seg_size);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1139
        FreeArray[ix].index = ix;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1140
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1141
      cur  = cur->link();
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1142
      ix++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1143
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1144
    if (ix != alloc_freeBlocks) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1145
      ast->print_cr("Free block count mismatch. Expected %d free blocks, but found %d.", alloc_freeBlocks, ix);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1146
      ast->print_cr("I will update the counter and retry data collection");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1147
      STRINGSTREAM_FLUSH("\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1148
      nBlocks_free = ix;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1149
      continue;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1150
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1151
    done = true;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1152
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1153
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1154
  if (!done || (nBlocks_free == 0)) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1155
    if (nBlocks_free == 0) {
51124
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
  1156
      printBox(ast, '-', "no free blocks found in ", heapName);
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1157
    } else if (!done) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1158
      ast->print_cr("Free block count mismatch could not be resolved.");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1159
      ast->print_cr("Try to run \"aggregate\" function to update counters");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1160
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1161
    STRINGSTREAM_FLUSH("")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1162
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1163
    //---< discard old array and update global values  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1164
    discard_FreeArray(out);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1165
    set_HeapStatGlobals(out, heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1166
    return;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1167
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1168
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1169
  //---<  calculate and fill remaining fields  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1170
  if (FreeArray != NULL) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1171
    // This loop is intentionally printing directly to "out".
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1172
    for (unsigned int ix = 0; ix < alloc_freeBlocks-1; ix++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1173
      size_t lenSum = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1174
      FreeArray[ix].gap = (unsigned int)((address)FreeArray[ix+1].start - ((address)FreeArray[ix].start + FreeArray[ix].len));
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1175
      for (HeapBlock *h = heap->next_block(FreeArray[ix].start); (h != NULL) && (h != FreeArray[ix+1].start); h = heap->next_block(h)) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1176
        CodeBlob *cb  = (CodeBlob*)(heap->find_start(h));
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1177
        if ((cb != NULL) && !cb->is_nmethod()) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1178
          FreeArray[ix].stubs_in_gap = true;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1179
        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1180
        FreeArray[ix].n_gapBlocks++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1181
        lenSum += h->length()<<log2_seg_size;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1182
        if (((address)h < ((address)FreeArray[ix].start+FreeArray[ix].len)) || (h >= FreeArray[ix+1].start)) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1183
          out->print_cr("unsorted occupied CodeHeap block found @ %p, gap interval [%p, %p)", h, (address)FreeArray[ix].start+FreeArray[ix].len, FreeArray[ix+1].start);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1184
        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1185
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1186
      if (lenSum != FreeArray[ix].gap) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1187
        out->print_cr("Length mismatch for gap between FreeBlk[%d] and FreeBlk[%d]. Calculated: %d, accumulated: %d.", ix, ix+1, FreeArray[ix].gap, (unsigned int)lenSum);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1188
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1189
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1190
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1191
  set_HeapStatGlobals(out, heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1192
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1193
  printBox(ast, '=', "C O D E   H E A P   A N A L Y S I S   C O M P L E T E   for segment ", heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1194
  STRINGSTREAM_FLUSH("\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1195
}
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1196
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1197
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1198
void CodeHeapState::print_usedSpace(outputStream* out, CodeHeap* heap) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1199
  if (!initialization_complete) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1200
    return;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1201
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1202
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1203
  const char* heapName   = get_heapName(heap);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1204
  get_HeapStatGlobals(out, heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1205
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1206
  if ((StatArray == NULL) || (TopSizeArray == NULL) || (used_topSizeBlocks == 0)) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1207
    return;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1208
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1209
  STRINGSTREAM_DECL(ast, out)
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1210
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1211
  {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1212
    printBox(ast, '=', "U S E D   S P A C E   S T A T I S T I C S   for ", heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1213
    ast->print_cr("Note: The Top%d list of the largest used blocks associates method names\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1214
                  "      and other identifying information with the block size data.\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1215
                  "\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1216
                  "      Method names are dynamically retrieved from the code cache at print time.\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1217
                  "      Due to the living nature of the code cache and because the CodeCache_lock\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1218
                  "      is not continuously held, the displayed name might be wrong or no name\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1219
                  "      might be found at all. The likelihood for that to happen increases\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1220
                  "      over time passed between analysis and print step.\n", used_topSizeBlocks);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1221
    STRINGSTREAM_FLUSH_LOCKED("\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1222
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1223
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1224
  //----------------------------
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1225
  //--  Print Top Used Blocks --
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1226
  //----------------------------
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1227
  {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1228
    char*     low_bound = heap->low_boundary();
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1229
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1230
    printBox(ast, '-', "Largest Used Blocks in ", heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1231
    print_blobType_legend(ast);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1232
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1233
    ast->fill_to(51);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1234
    ast->print("%4s", "blob");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1235
    ast->fill_to(56);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1236
    ast->print("%9s", "compiler");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1237
    ast->fill_to(66);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1238
    ast->print_cr("%6s", "method");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1239
    ast->print_cr("%18s %13s %17s %4s %9s  %5s %s",      "Addr(module)      ", "offset", "size", "type", " type lvl", " temp", "Name");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1240
    STRINGSTREAM_FLUSH_LOCKED("")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1241
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1242
    //---<  print Top Ten Used Blocks  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1243
    if (used_topSizeBlocks > 0) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1244
      unsigned int printed_topSizeBlocks = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1245
      for (unsigned int i = 0; i != tsbStopper; i = TopSizeArray[i].index) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1246
        printed_topSizeBlocks++;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1247
        CodeBlob*   this_blob = (CodeBlob*)(heap->find_start(TopSizeArray[i].start));
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1248
        nmethod*           nm = NULL;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1249
        const char* blob_name = "unnamed blob";
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1250
        if (this_blob != NULL) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1251
          blob_name = this_blob->name();
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1252
          nm        = this_blob->as_nmethod_or_null();
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1253
          //---<  blob address  >---
49825
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  1254
          ast->print(INTPTR_FORMAT, p2i(this_blob));
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1255
          ast->fill_to(19);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1256
          //---<  blob offset from CodeHeap begin  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1257
          ast->print("(+" PTR32_FORMAT ")", (unsigned int)((char*)this_blob-low_bound));
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1258
          ast->fill_to(33);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1259
        } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1260
          //---<  block address  >---
49825
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  1261
          ast->print(INTPTR_FORMAT, p2i(TopSizeArray[i].start));
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1262
          ast->fill_to(19);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1263
          //---<  block offset from CodeHeap begin  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1264
          ast->print("(+" PTR32_FORMAT ")", (unsigned int)((char*)TopSizeArray[i].start-low_bound));
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1265
          ast->fill_to(33);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1266
        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1267
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1268
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1269
        //---<  print size, name, and signature (for nMethods)  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1270
        if ((nm != NULL) && (nm->method() != NULL)) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1271
          ResourceMark rm;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1272
          //---<  nMethod size in hex  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1273
          unsigned int total_size = nm->total_size();
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1274
          ast->print(PTR32_FORMAT, total_size);
49624
cfde7ece3113 8200297: Build failures after JDK-8198691 (CodeHeap State Analytics)
stuefe
parents: 49611
diff changeset
  1275
          ast->print("(" SIZE_FORMAT_W(4) "K)", total_size/K);
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1276
          ast->fill_to(51);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1277
          ast->print("  %c", blobTypeChar[TopSizeArray[i].type]);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1278
          //---<  compiler information  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1279
          ast->fill_to(56);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1280
          ast->print("%5s %3d", compTypeName[TopSizeArray[i].compiler], TopSizeArray[i].level);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1281
          //---<  method temperature  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1282
          ast->fill_to(67);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1283
          ast->print("%5d", nm->hotness_counter());
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1284
          //---<  name and signature  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1285
          ast->fill_to(67+6);
51124
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
  1286
          if (nm->is_in_use())        {blob_name = nm->method()->name_and_sig_as_C_string(); }
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
  1287
          if (nm->is_not_entrant())   {blob_name = nm->method()->name_and_sig_as_C_string(); }
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
  1288
          if (nm->is_not_installed()) {ast->print("%s", " not (yet) installed method "); }
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
  1289
          if (nm->is_zombie())        {ast->print("%s", " zombie method "); }
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1290
          ast->print("%s", blob_name);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1291
        } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1292
          //---<  block size in hex  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1293
          ast->print(PTR32_FORMAT, (unsigned int)(TopSizeArray[i].len<<log2_seg_size));
49624
cfde7ece3113 8200297: Build failures after JDK-8198691 (CodeHeap State Analytics)
stuefe
parents: 49611
diff changeset
  1294
          ast->print("(" SIZE_FORMAT_W(4) "K)", (TopSizeArray[i].len<<log2_seg_size)/K);
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1295
          //---<  no compiler information  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1296
          ast->fill_to(56);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1297
          //---<  name and signature  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1298
          ast->fill_to(67+6);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1299
          ast->print("%s", blob_name);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1300
        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1301
        STRINGSTREAM_FLUSH_LOCKED("\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1302
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1303
      if (used_topSizeBlocks != printed_topSizeBlocks) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1304
        ast->print_cr("used blocks: %d, printed blocks: %d", used_topSizeBlocks, printed_topSizeBlocks);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1305
        STRINGSTREAM_FLUSH("")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1306
        for (unsigned int i = 0; i < alloc_topSizeBlocks; i++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1307
          ast->print_cr("  TopSizeArray[%d].index = %d, len = %d", i, TopSizeArray[i].index, TopSizeArray[i].len);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1308
          STRINGSTREAM_FLUSH("")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1309
        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1310
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1311
      STRINGSTREAM_FLUSH_LOCKED("\n\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1312
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1313
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1314
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1315
  //-----------------------------
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1316
  //--  Print Usage Histogram  --
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1317
  //-----------------------------
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1318
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1319
  if (SizeDistributionArray != NULL) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1320
    unsigned long total_count = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1321
    unsigned long total_size  = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1322
    const unsigned long pctFactor = 200;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1323
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1324
    for (unsigned int i = 0; i < nSizeDistElements; i++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1325
      total_count += SizeDistributionArray[i].count;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1326
      total_size  += SizeDistributionArray[i].lenSum;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1327
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1328
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1329
    if ((total_count > 0) && (total_size > 0)) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1330
      printBox(ast, '-', "Block count histogram for ", heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1331
      ast->print_cr("Note: The histogram indicates how many blocks (as a percentage\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1332
                    "      of all blocks) have a size in the given range.\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1333
                    "      %ld characters are printed per percentage point.\n", pctFactor/100);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1334
      ast->print_cr("total size   of all blocks: %7ldM", (total_size<<log2_seg_size)/M);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1335
      ast->print_cr("total number of all blocks: %7ld\n", total_count);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1336
      STRINGSTREAM_FLUSH_LOCKED("")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1337
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1338
      ast->print_cr("[Size Range)------avg.-size-+----count-+");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1339
      for (unsigned int i = 0; i < nSizeDistElements; i++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1340
        if (SizeDistributionArray[i].rangeStart<<log2_seg_size < K) {
49624
cfde7ece3113 8200297: Build failures after JDK-8198691 (CodeHeap State Analytics)
stuefe
parents: 49611
diff changeset
  1341
          ast->print("[" SIZE_FORMAT_W(5) " .." SIZE_FORMAT_W(5) " ): "
cfde7ece3113 8200297: Build failures after JDK-8198691 (CodeHeap State Analytics)
stuefe
parents: 49611
diff changeset
  1342
                    ,(size_t)(SizeDistributionArray[i].rangeStart<<log2_seg_size)
cfde7ece3113 8200297: Build failures after JDK-8198691 (CodeHeap State Analytics)
stuefe
parents: 49611
diff changeset
  1343
                    ,(size_t)(SizeDistributionArray[i].rangeEnd<<log2_seg_size)
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1344
                    );
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1345
        } else if (SizeDistributionArray[i].rangeStart<<log2_seg_size < M) {
49624
cfde7ece3113 8200297: Build failures after JDK-8198691 (CodeHeap State Analytics)
stuefe
parents: 49611
diff changeset
  1346
          ast->print("[" SIZE_FORMAT_W(5) "K.." SIZE_FORMAT_W(5) "K): "
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1347
                    ,(SizeDistributionArray[i].rangeStart<<log2_seg_size)/K
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1348
                    ,(SizeDistributionArray[i].rangeEnd<<log2_seg_size)/K
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1349
                    );
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1350
        } else {
49624
cfde7ece3113 8200297: Build failures after JDK-8198691 (CodeHeap State Analytics)
stuefe
parents: 49611
diff changeset
  1351
          ast->print("[" SIZE_FORMAT_W(5) "M.." SIZE_FORMAT_W(5) "M): "
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1352
                    ,(SizeDistributionArray[i].rangeStart<<log2_seg_size)/M
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1353
                    ,(SizeDistributionArray[i].rangeEnd<<log2_seg_size)/M
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1354
                    );
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1355
        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1356
        ast->print(" %8d | %8d |",
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1357
                   SizeDistributionArray[i].count > 0 ? (SizeDistributionArray[i].lenSum<<log2_seg_size)/SizeDistributionArray[i].count : 0,
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1358
                   SizeDistributionArray[i].count);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1359
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1360
        unsigned int percent = pctFactor*SizeDistributionArray[i].count/total_count;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1361
        for (unsigned int j = 1; j <= percent; j++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1362
          ast->print("%c", (j%((pctFactor/100)*10) == 0) ? ('0'+j/(((unsigned int)pctFactor/100)*10)) : '*');
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1363
        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1364
        ast->cr();
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1365
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1366
      ast->print_cr("----------------------------+----------+\n\n");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1367
      STRINGSTREAM_FLUSH_LOCKED("\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1368
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1369
      printBox(ast, '-', "Contribution per size range to total size for ", heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1370
      ast->print_cr("Note: The histogram indicates how much space (as a percentage of all\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1371
                    "      occupied space) is used by the blocks in the given size range.\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1372
                    "      %ld characters are printed per percentage point.\n", pctFactor/100);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1373
      ast->print_cr("total size   of all blocks: %7ldM", (total_size<<log2_seg_size)/M);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1374
      ast->print_cr("total number of all blocks: %7ld\n", total_count);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1375
      STRINGSTREAM_FLUSH_LOCKED("")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1376
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1377
      ast->print_cr("[Size Range)------avg.-size-+----count-+");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1378
      for (unsigned int i = 0; i < nSizeDistElements; i++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1379
        if (SizeDistributionArray[i].rangeStart<<log2_seg_size < K) {
49624
cfde7ece3113 8200297: Build failures after JDK-8198691 (CodeHeap State Analytics)
stuefe
parents: 49611
diff changeset
  1380
          ast->print("[" SIZE_FORMAT_W(5) " .." SIZE_FORMAT_W(5) " ): "
cfde7ece3113 8200297: Build failures after JDK-8198691 (CodeHeap State Analytics)
stuefe
parents: 49611
diff changeset
  1381
                    ,(size_t)(SizeDistributionArray[i].rangeStart<<log2_seg_size)
cfde7ece3113 8200297: Build failures after JDK-8198691 (CodeHeap State Analytics)
stuefe
parents: 49611
diff changeset
  1382
                    ,(size_t)(SizeDistributionArray[i].rangeEnd<<log2_seg_size)
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1383
                    );
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1384
        } else if (SizeDistributionArray[i].rangeStart<<log2_seg_size < M) {
49624
cfde7ece3113 8200297: Build failures after JDK-8198691 (CodeHeap State Analytics)
stuefe
parents: 49611
diff changeset
  1385
          ast->print("[" SIZE_FORMAT_W(5) "K.." SIZE_FORMAT_W(5) "K): "
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1386
                    ,(SizeDistributionArray[i].rangeStart<<log2_seg_size)/K
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1387
                    ,(SizeDistributionArray[i].rangeEnd<<log2_seg_size)/K
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1388
                    );
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1389
        } else {
49624
cfde7ece3113 8200297: Build failures after JDK-8198691 (CodeHeap State Analytics)
stuefe
parents: 49611
diff changeset
  1390
          ast->print("[" SIZE_FORMAT_W(5) "M.." SIZE_FORMAT_W(5) "M): "
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1391
                    ,(SizeDistributionArray[i].rangeStart<<log2_seg_size)/M
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1392
                    ,(SizeDistributionArray[i].rangeEnd<<log2_seg_size)/M
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1393
                    );
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1394
        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1395
        ast->print(" %8d | %8d |",
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1396
                   SizeDistributionArray[i].count > 0 ? (SizeDistributionArray[i].lenSum<<log2_seg_size)/SizeDistributionArray[i].count : 0,
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1397
                   SizeDistributionArray[i].count);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1398
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1399
        unsigned int percent = pctFactor*(unsigned long)SizeDistributionArray[i].lenSum/total_size;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1400
        for (unsigned int j = 1; j <= percent; j++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1401
          ast->print("%c", (j%((pctFactor/100)*10) == 0) ? ('0'+j/(((unsigned int)pctFactor/100)*10)) : '*');
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1402
        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1403
        ast->cr();
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1404
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1405
      ast->print_cr("----------------------------+----------+");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1406
      STRINGSTREAM_FLUSH_LOCKED("\n\n\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1407
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1408
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1409
}
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1410
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1411
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1412
void CodeHeapState::print_freeSpace(outputStream* out, CodeHeap* heap) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1413
  if (!initialization_complete) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1414
    return;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1415
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1416
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1417
  const char* heapName   = get_heapName(heap);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1418
  get_HeapStatGlobals(out, heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1419
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1420
  if ((StatArray == NULL) || (FreeArray == NULL) || (alloc_granules == 0)) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1421
    return;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1422
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1423
  STRINGSTREAM_DECL(ast, out)
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1424
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1425
  {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1426
    printBox(ast, '=', "F R E E   S P A C E   S T A T I S T I C S   for ", heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1427
    ast->print_cr("Note: in this context, a gap is the occupied space between two free blocks.\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1428
                  "      Those gaps are of interest if there is a chance that they become\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1429
                  "      unoccupied, e.g. by class unloading. Then, the two adjacent free\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1430
                  "      blocks, together with the now unoccupied space, form a new, large\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1431
                  "      free block.");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1432
    STRINGSTREAM_FLUSH_LOCKED("\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1433
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1434
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1435
  {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1436
    printBox(ast, '-', "List of all Free Blocks in ", heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1437
    STRINGSTREAM_FLUSH_LOCKED("")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1438
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1439
    unsigned int ix = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1440
    for (ix = 0; ix < alloc_freeBlocks-1; ix++) {
49825
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  1441
      ast->print(INTPTR_FORMAT ": Len[%4d] = " HEX32_FORMAT ",", p2i(FreeArray[ix].start), ix, FreeArray[ix].len);
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1442
      ast->fill_to(38);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1443
      ast->print("Gap[%4d..%4d]: " HEX32_FORMAT " bytes,", ix, ix+1, FreeArray[ix].gap);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1444
      ast->fill_to(71);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1445
      ast->print("block count: %6d", FreeArray[ix].n_gapBlocks);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1446
      if (FreeArray[ix].stubs_in_gap) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1447
        ast->print(" !! permanent gap, contains stubs and/or blobs !!");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1448
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1449
      STRINGSTREAM_FLUSH_LOCKED("\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1450
    }
49825
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  1451
    ast->print_cr(INTPTR_FORMAT ": Len[%4d] = " HEX32_FORMAT, p2i(FreeArray[ix].start), ix, FreeArray[ix].len);
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1452
    STRINGSTREAM_FLUSH_LOCKED("\n\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1453
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1454
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1455
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1456
  //-----------------------------------------
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1457
  //--  Find and Print Top Ten Free Blocks --
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1458
  //-----------------------------------------
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1459
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1460
  //---<  find Top Ten Free Blocks  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1461
  const unsigned int nTop = 10;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1462
  unsigned int  currMax10 = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1463
  struct FreeBlk* FreeTopTen[nTop];
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1464
  memset(FreeTopTen, 0, sizeof(FreeTopTen));
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1465
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1466
  for (unsigned int ix = 0; ix < alloc_freeBlocks; ix++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1467
    if (FreeArray[ix].len > currMax10) {  // larger than the ten largest found so far
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1468
      unsigned int currSize = FreeArray[ix].len;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1469
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1470
      unsigned int iy;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1471
      for (iy = 0; iy < nTop && FreeTopTen[iy] != NULL; iy++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1472
        if (FreeTopTen[iy]->len < currSize) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1473
          for (unsigned int iz = nTop-1; iz > iy; iz--) { // make room to insert new free block
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1474
            FreeTopTen[iz] = FreeTopTen[iz-1];
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1475
          }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1476
          FreeTopTen[iy] = &FreeArray[ix];        // insert new free block
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1477
          if (FreeTopTen[nTop-1] != NULL) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1478
            currMax10 = FreeTopTen[nTop-1]->len;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1479
          }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1480
          break; // done with this, check next free block
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1481
        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1482
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1483
      if (iy >= nTop) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1484
        ast->print_cr("Internal logic error. New Max10 = %d detected, but could not be merged. Old Max10 = %d",
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1485
                      currSize, currMax10);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1486
        continue;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1487
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1488
      if (FreeTopTen[iy] == NULL) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1489
        FreeTopTen[iy] = &FreeArray[ix];
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1490
        if (iy == (nTop-1)) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1491
          currMax10 = currSize;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1492
        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1493
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1494
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1495
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1496
  STRINGSTREAM_FLUSH_LOCKED("")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1497
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1498
  {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1499
    printBox(ast, '-', "Top Ten Free Blocks in ", heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1500
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1501
    //---<  print Top Ten Free Blocks  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1502
    for (unsigned int iy = 0; (iy < nTop) && (FreeTopTen[iy] != NULL); iy++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1503
      ast->print("Pos %3d: Block %4d - size " HEX32_FORMAT ",", iy+1, FreeTopTen[iy]->index, FreeTopTen[iy]->len);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1504
      ast->fill_to(39);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1505
      if (FreeTopTen[iy]->index == (alloc_freeBlocks-1)) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1506
        ast->print("last free block in list.");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1507
      } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1508
        ast->print("Gap (to next) " HEX32_FORMAT ",", FreeTopTen[iy]->gap);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1509
        ast->fill_to(63);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1510
        ast->print("#blocks (in gap) %d", FreeTopTen[iy]->n_gapBlocks);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1511
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1512
      ast->cr();
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1513
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1514
    STRINGSTREAM_FLUSH_LOCKED("\n\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1515
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1516
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1517
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1518
  //--------------------------------------------------------
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1519
  //--  Find and Print Top Ten Free-Occupied-Free Triples --
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1520
  //--------------------------------------------------------
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1521
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1522
  //---<  find and print Top Ten Triples (Free-Occupied-Free)  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1523
  currMax10 = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1524
  struct FreeBlk  *FreeTopTenTriple[nTop];
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1525
  memset(FreeTopTenTriple, 0, sizeof(FreeTopTenTriple));
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1526
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1527
  for (unsigned int ix = 0; ix < alloc_freeBlocks-1; ix++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1528
    // If there are stubs in the gap, this gap will never become completely free.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1529
    // The triple will thus never merge to one free block.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1530
    unsigned int lenTriple  = FreeArray[ix].len + (FreeArray[ix].stubs_in_gap ? 0 : FreeArray[ix].gap + FreeArray[ix+1].len);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1531
    FreeArray[ix].len = lenTriple;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1532
    if (lenTriple > currMax10) {  // larger than the ten largest found so far
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1533
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1534
      unsigned int iy;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1535
      for (iy = 0; (iy < nTop) && (FreeTopTenTriple[iy] != NULL); iy++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1536
        if (FreeTopTenTriple[iy]->len < lenTriple) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1537
          for (unsigned int iz = nTop-1; iz > iy; iz--) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1538
            FreeTopTenTriple[iz] = FreeTopTenTriple[iz-1];
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1539
          }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1540
          FreeTopTenTriple[iy] = &FreeArray[ix];
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1541
          if (FreeTopTenTriple[nTop-1] != NULL) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1542
            currMax10 = FreeTopTenTriple[nTop-1]->len;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1543
          }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1544
          break;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1545
        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1546
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1547
      if (iy == nTop) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1548
        ast->print_cr("Internal logic error. New Max10 = %d detected, but could not be merged. Old Max10 = %d",
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1549
                      lenTriple, currMax10);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1550
        continue;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1551
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1552
      if (FreeTopTenTriple[iy] == NULL) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1553
        FreeTopTenTriple[iy] = &FreeArray[ix];
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1554
        if (iy == (nTop-1)) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1555
          currMax10 = lenTriple;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1556
        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1557
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1558
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1559
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1560
  STRINGSTREAM_FLUSH_LOCKED("")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1561
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1562
  {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1563
    printBox(ast, '-', "Top Ten Free-Occupied-Free Triples in ", heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1564
    ast->print_cr("  Use this information to judge how likely it is that a large(r) free block\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1565
                  "  might get created by code cache sweeping.\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1566
                  "  If all the occupied blocks can be swept, the three free blocks will be\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1567
                  "  merged into one (much larger) free block. That would reduce free space\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1568
                  "  fragmentation.\n");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1569
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1570
    //---<  print Top Ten Free-Occupied-Free Triples  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1571
    for (unsigned int iy = 0; (iy < nTop) && (FreeTopTenTriple[iy] != NULL); iy++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1572
      ast->print("Pos %3d: Block %4d - size " HEX32_FORMAT ",", iy+1, FreeTopTenTriple[iy]->index, FreeTopTenTriple[iy]->len);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1573
      ast->fill_to(39);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1574
      ast->print("Gap (to next) " HEX32_FORMAT ",", FreeTopTenTriple[iy]->gap);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1575
      ast->fill_to(63);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1576
      ast->print("#blocks (in gap) %d", FreeTopTenTriple[iy]->n_gapBlocks);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1577
      ast->cr();
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1578
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1579
    STRINGSTREAM_FLUSH_LOCKED("\n\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1580
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1581
}
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1582
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1583
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1584
void CodeHeapState::print_count(outputStream* out, CodeHeap* heap) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1585
  if (!initialization_complete) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1586
    return;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1587
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1588
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1589
  const char* heapName   = get_heapName(heap);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1590
  get_HeapStatGlobals(out, heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1591
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1592
  if ((StatArray == NULL) || (alloc_granules == 0)) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1593
    return;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1594
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1595
  STRINGSTREAM_DECL(ast, out)
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1596
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1597
  unsigned int granules_per_line = 32;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1598
  char*        low_bound         = heap->low_boundary();
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1599
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1600
  {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1601
    printBox(ast, '=', "B L O C K   C O U N T S   for ", heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1602
    ast->print_cr("  Each granule contains an individual number of heap blocks. Large blocks\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1603
                  "  may span multiple granules and are counted for each granule they touch.\n");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1604
    if (segment_granules) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1605
      ast->print_cr("  You have selected granule size to be as small as segment size.\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1606
                    "  As a result, each granule contains exactly one block (or a part of one block)\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1607
                    "  or is displayed as empty (' ') if it's BlobType does not match the selection.\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1608
                    "  Occupied granules show their BlobType character, see legend.\n");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1609
      print_blobType_legend(ast);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1610
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1611
    STRINGSTREAM_FLUSH_LOCKED("")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1612
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1613
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1614
  {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1615
    if (segment_granules) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1616
      printBox(ast, '-', "Total (all types) count for granule size == segment size", NULL);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1617
      STRINGSTREAM_FLUSH_LOCKED("")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1618
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1619
      granules_per_line = 128;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1620
      for (unsigned int ix = 0; ix < alloc_granules; ix++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1621
        print_line_delim(out, ast, low_bound, ix, granules_per_line);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1622
        print_blobType_single(ast, StatArray[ix].type);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1623
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1624
    } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1625
      printBox(ast, '-', "Total (all tiers) count, 0x1..0xf. '*' indicates >= 16 blocks, ' ' indicates empty", NULL);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1626
      STRINGSTREAM_FLUSH_LOCKED("")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1627
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1628
      granules_per_line = 128;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1629
      for (unsigned int ix = 0; ix < alloc_granules; ix++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1630
        print_line_delim(out, ast, low_bound, ix, granules_per_line);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1631
        unsigned int count = StatArray[ix].t1_count   + StatArray[ix].t2_count   + StatArray[ix].tx_count
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1632
                           + StatArray[ix].stub_count + StatArray[ix].dead_count;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1633
        print_count_single(ast, count);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1634
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1635
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1636
    STRINGSTREAM_FLUSH_LOCKED("|\n\n\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1637
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1638
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1639
  {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1640
    if (nBlocks_t1 > 0) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1641
      printBox(ast, '-', "Tier1 nMethod count only, 0x1..0xf. '*' indicates >= 16 blocks, ' ' indicates empty", NULL);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1642
      STRINGSTREAM_FLUSH_LOCKED("")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1643
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1644
      granules_per_line = 128;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1645
      for (unsigned int ix = 0; ix < alloc_granules; ix++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1646
        print_line_delim(out, ast, low_bound, ix, granules_per_line);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1647
        if (segment_granules && StatArray[ix].t1_count > 0) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1648
          print_blobType_single(ast, StatArray[ix].type);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1649
        } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1650
          print_count_single(ast, StatArray[ix].t1_count);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1651
        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1652
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1653
      STRINGSTREAM_FLUSH_LOCKED("|\n\n\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1654
    } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1655
      ast->print("No Tier1 nMethods found in CodeHeap.");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1656
      STRINGSTREAM_FLUSH_LOCKED("\n\n\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1657
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1658
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1659
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1660
  {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1661
    if (nBlocks_t2 > 0) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1662
      printBox(ast, '-', "Tier2 nMethod count only, 0x1..0xf. '*' indicates >= 16 blocks, ' ' indicates empty", NULL);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1663
      STRINGSTREAM_FLUSH_LOCKED("")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1664
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1665
      granules_per_line = 128;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1666
      for (unsigned int ix = 0; ix < alloc_granules; ix++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1667
        print_line_delim(out, ast, low_bound, ix, granules_per_line);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1668
        if (segment_granules && StatArray[ix].t2_count > 0) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1669
          print_blobType_single(ast, StatArray[ix].type);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1670
        } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1671
          print_count_single(ast, StatArray[ix].t2_count);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1672
        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1673
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1674
      STRINGSTREAM_FLUSH_LOCKED("|\n\n\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1675
    } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1676
      ast->print("No Tier2 nMethods found in CodeHeap.");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1677
      STRINGSTREAM_FLUSH_LOCKED("\n\n\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1678
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1679
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1680
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1681
  {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1682
    if (nBlocks_alive > 0) {
51124
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
  1683
      printBox(ast, '-', "not_used/not_entrant/not_installed nMethod count only, 0x1..0xf. '*' indicates >= 16 blocks, ' ' indicates empty", NULL);
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1684
      STRINGSTREAM_FLUSH_LOCKED("")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1685
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1686
      granules_per_line = 128;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1687
      for (unsigned int ix = 0; ix < alloc_granules; ix++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1688
        print_line_delim(out, ast, low_bound, ix, granules_per_line);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1689
        if (segment_granules && StatArray[ix].tx_count > 0) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1690
          print_blobType_single(ast, StatArray[ix].type);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1691
        } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1692
          print_count_single(ast, StatArray[ix].tx_count);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1693
        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1694
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1695
      STRINGSTREAM_FLUSH_LOCKED("|\n\n\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1696
    } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1697
      ast->print("No not_used/not_entrant nMethods found in CodeHeap.");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1698
      STRINGSTREAM_FLUSH_LOCKED("\n\n\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1699
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1700
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1701
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1702
  {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1703
    if (nBlocks_stub > 0) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1704
      printBox(ast, '-', "Stub & Blob count only, 0x1..0xf. '*' indicates >= 16 blocks, ' ' indicates empty", NULL);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1705
      STRINGSTREAM_FLUSH_LOCKED("")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1706
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1707
      granules_per_line = 128;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1708
      for (unsigned int ix = 0; ix < alloc_granules; ix++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1709
        print_line_delim(out, ast, low_bound, ix, granules_per_line);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1710
        if (segment_granules && StatArray[ix].stub_count > 0) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1711
          print_blobType_single(ast, StatArray[ix].type);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1712
        } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1713
          print_count_single(ast, StatArray[ix].stub_count);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1714
        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1715
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1716
      STRINGSTREAM_FLUSH_LOCKED("|\n\n\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1717
    } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1718
      ast->print("No Stubs and Blobs found in CodeHeap.");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1719
      STRINGSTREAM_FLUSH_LOCKED("\n\n\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1720
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1721
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1722
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1723
  {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1724
    if (nBlocks_dead > 0) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1725
      printBox(ast, '-', "Dead nMethod count only, 0x1..0xf. '*' indicates >= 16 blocks, ' ' indicates empty", NULL);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1726
      STRINGSTREAM_FLUSH_LOCKED("")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1727
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1728
      granules_per_line = 128;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1729
      for (unsigned int ix = 0; ix < alloc_granules; ix++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1730
        print_line_delim(out, ast, low_bound, ix, granules_per_line);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1731
        if (segment_granules && StatArray[ix].dead_count > 0) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1732
          print_blobType_single(ast, StatArray[ix].type);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1733
        } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1734
          print_count_single(ast, StatArray[ix].dead_count);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1735
        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1736
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1737
      STRINGSTREAM_FLUSH_LOCKED("|\n\n\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1738
    } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1739
      ast->print("No dead nMethods found in CodeHeap.");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1740
      STRINGSTREAM_FLUSH_LOCKED("\n\n\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1741
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1742
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1743
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1744
  {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1745
    if (!segment_granules) { // Prevent totally redundant printouts
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1746
      printBox(ast, '-', "Count by tier (combined, no dead blocks): <#t1>:<#t2>:<#s>, 0x0..0xf. '*' indicates >= 16 blocks", NULL);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1747
      STRINGSTREAM_FLUSH_LOCKED("")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1748
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1749
      granules_per_line = 24;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1750
      for (unsigned int ix = 0; ix < alloc_granules; ix++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1751
        print_line_delim(out, ast, low_bound, ix, granules_per_line);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1752
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1753
        print_count_single(ast, StatArray[ix].t1_count);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1754
        ast->print(":");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1755
        print_count_single(ast, StatArray[ix].t2_count);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1756
        ast->print(":");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1757
        if (segment_granules && StatArray[ix].stub_count > 0) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1758
          print_blobType_single(ast, StatArray[ix].type);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1759
        } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1760
          print_count_single(ast, StatArray[ix].stub_count);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1761
        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1762
        ast->print(" ");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1763
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1764
      STRINGSTREAM_FLUSH_LOCKED("|\n\n\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1765
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1766
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1767
}
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1768
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1769
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1770
void CodeHeapState::print_space(outputStream* out, CodeHeap* heap) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1771
  if (!initialization_complete) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1772
    return;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1773
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1774
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1775
  const char* heapName   = get_heapName(heap);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1776
  get_HeapStatGlobals(out, heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1777
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1778
  if ((StatArray == NULL) || (alloc_granules == 0)) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1779
    return;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1780
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1781
  STRINGSTREAM_DECL(ast, out)
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1782
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1783
  unsigned int granules_per_line = 32;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1784
  char*        low_bound         = heap->low_boundary();
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1785
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1786
  {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1787
    printBox(ast, '=', "S P A C E   U S A G E  &  F R A G M E N T A T I O N   for ", heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1788
    ast->print_cr("  The heap space covered by one granule is occupied to a various extend.\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1789
                  "  The granule occupancy is displayed by one decimal digit per granule.\n");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1790
    if (segment_granules) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1791
      ast->print_cr("  You have selected granule size to be as small as segment size.\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1792
                    "  As a result, each granule contains exactly one block (or a part of one block)\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1793
                    "  or is displayed as empty (' ') if it's BlobType does not match the selection.\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1794
                    "  Occupied granules show their BlobType character, see legend.\n");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1795
      print_blobType_legend(ast);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1796
    } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1797
      ast->print_cr("  These digits represent a fill percentage range (see legend).\n");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1798
      print_space_legend(ast);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1799
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1800
    STRINGSTREAM_FLUSH_LOCKED("")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1801
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1802
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1803
  {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1804
    if (segment_granules) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1805
      printBox(ast, '-', "Total (all types) space consumption for granule size == segment size", NULL);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1806
      STRINGSTREAM_FLUSH_LOCKED("")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1807
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1808
      granules_per_line = 128;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1809
      for (unsigned int ix = 0; ix < alloc_granules; ix++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1810
        print_line_delim(out, ast, low_bound, ix, granules_per_line);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1811
        print_blobType_single(ast, StatArray[ix].type);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1812
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1813
    } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1814
      printBox(ast, '-', "Total (all types) space consumption. ' ' indicates empty, '*' indicates full.", NULL);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1815
      STRINGSTREAM_FLUSH_LOCKED("")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1816
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1817
      granules_per_line = 128;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1818
      for (unsigned int ix = 0; ix < alloc_granules; ix++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1819
        print_line_delim(out, ast, low_bound, ix, granules_per_line);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1820
        unsigned int space    = StatArray[ix].t1_space   + StatArray[ix].t2_space  + StatArray[ix].tx_space
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1821
                              + StatArray[ix].stub_space + StatArray[ix].dead_space;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1822
        print_space_single(ast, space);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1823
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1824
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1825
    STRINGSTREAM_FLUSH_LOCKED("|\n\n\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1826
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1827
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1828
  {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1829
    if (nBlocks_t1 > 0) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1830
      printBox(ast, '-', "Tier1 space consumption. ' ' indicates empty, '*' indicates full", NULL);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1831
      STRINGSTREAM_FLUSH_LOCKED("")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1832
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1833
      granules_per_line = 128;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1834
      for (unsigned int ix = 0; ix < alloc_granules; ix++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1835
        print_line_delim(out, ast, low_bound, ix, granules_per_line);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1836
        if (segment_granules && StatArray[ix].t1_space > 0) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1837
          print_blobType_single(ast, StatArray[ix].type);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1838
        } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1839
          print_space_single(ast, StatArray[ix].t1_space);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1840
        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1841
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1842
      STRINGSTREAM_FLUSH_LOCKED("|\n\n\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1843
    } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1844
      ast->print("No Tier1 nMethods found in CodeHeap.");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1845
      STRINGSTREAM_FLUSH_LOCKED("\n\n\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1846
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1847
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1848
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1849
  {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1850
    if (nBlocks_t2 > 0) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1851
      printBox(ast, '-', "Tier2 space consumption. ' ' indicates empty, '*' indicates full", NULL);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1852
      STRINGSTREAM_FLUSH_LOCKED("")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1853
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1854
      granules_per_line = 128;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1855
      for (unsigned int ix = 0; ix < alloc_granules; ix++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1856
        print_line_delim(out, ast, low_bound, ix, granules_per_line);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1857
        if (segment_granules && StatArray[ix].t2_space > 0) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1858
          print_blobType_single(ast, StatArray[ix].type);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1859
        } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1860
          print_space_single(ast, StatArray[ix].t2_space);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1861
        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1862
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1863
      STRINGSTREAM_FLUSH_LOCKED("|\n\n\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1864
    } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1865
      ast->print("No Tier2 nMethods found in CodeHeap.");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1866
      STRINGSTREAM_FLUSH_LOCKED("\n\n\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1867
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1868
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1869
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1870
  {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1871
    if (nBlocks_alive > 0) {
51124
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
  1872
      printBox(ast, '-', "not_used/not_entrant/not_installed space consumption. ' ' indicates empty, '*' indicates full", NULL);
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1873
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1874
      granules_per_line = 128;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1875
      for (unsigned int ix = 0; ix < alloc_granules; ix++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1876
        print_line_delim(out, ast, low_bound, ix, granules_per_line);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1877
        if (segment_granules && StatArray[ix].tx_space > 0) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1878
          print_blobType_single(ast, StatArray[ix].type);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1879
        } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1880
          print_space_single(ast, StatArray[ix].tx_space);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1881
        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1882
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1883
      STRINGSTREAM_FLUSH_LOCKED("|\n\n\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1884
    } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1885
      ast->print("No Tier2 nMethods found in CodeHeap.");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1886
      STRINGSTREAM_FLUSH_LOCKED("\n\n\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1887
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1888
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1889
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1890
  {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1891
    if (nBlocks_stub > 0) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1892
      printBox(ast, '-', "Stub and Blob space consumption. ' ' indicates empty, '*' indicates full", NULL);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1893
      STRINGSTREAM_FLUSH_LOCKED("")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1894
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1895
      granules_per_line = 128;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1896
      for (unsigned int ix = 0; ix < alloc_granules; ix++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1897
        print_line_delim(out, ast, low_bound, ix, granules_per_line);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1898
        if (segment_granules && StatArray[ix].stub_space > 0) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1899
          print_blobType_single(ast, StatArray[ix].type);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1900
        } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1901
          print_space_single(ast, StatArray[ix].stub_space);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1902
        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1903
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1904
      STRINGSTREAM_FLUSH_LOCKED("|\n\n\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1905
    } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1906
      ast->print("No Stubs and Blobs found in CodeHeap.");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1907
      STRINGSTREAM_FLUSH_LOCKED("\n\n\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1908
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1909
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1910
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1911
  {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1912
    if (nBlocks_dead > 0) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1913
      printBox(ast, '-', "Dead space consumption. ' ' indicates empty, '*' indicates full", NULL);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1914
      STRINGSTREAM_FLUSH_LOCKED("")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1915
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1916
      granules_per_line = 128;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1917
      for (unsigned int ix = 0; ix < alloc_granules; ix++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1918
        print_line_delim(out, ast, low_bound, ix, granules_per_line);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1919
        print_space_single(ast, StatArray[ix].dead_space);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1920
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1921
      STRINGSTREAM_FLUSH_LOCKED("|\n\n\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1922
    } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1923
      ast->print("No dead nMethods found in CodeHeap.");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1924
      STRINGSTREAM_FLUSH_LOCKED("\n\n\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1925
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1926
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1927
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1928
  {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1929
    if (!segment_granules) { // Prevent totally redundant printouts
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1930
      printBox(ast, '-', "Space consumption by tier (combined): <t1%>:<t2%>:<s%>. ' ' indicates empty, '*' indicates full", NULL);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1931
      STRINGSTREAM_FLUSH_LOCKED("")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1932
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1933
      granules_per_line = 24;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1934
      for (unsigned int ix = 0; ix < alloc_granules; ix++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1935
        print_line_delim(out, ast, low_bound, ix, granules_per_line);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1936
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1937
        if (segment_granules && StatArray[ix].t1_space > 0) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1938
          print_blobType_single(ast, StatArray[ix].type);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1939
        } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1940
          print_space_single(ast, StatArray[ix].t1_space);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1941
        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1942
        ast->print(":");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1943
        if (segment_granules && StatArray[ix].t2_space > 0) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1944
          print_blobType_single(ast, StatArray[ix].type);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1945
        } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1946
          print_space_single(ast, StatArray[ix].t2_space);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1947
        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1948
        ast->print(":");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1949
        if (segment_granules && StatArray[ix].stub_space > 0) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1950
          print_blobType_single(ast, StatArray[ix].type);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1951
        } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1952
          print_space_single(ast, StatArray[ix].stub_space);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1953
        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1954
        ast->print(" ");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1955
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1956
      STRINGSTREAM_FLUSH_LOCKED("|\n\n\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1957
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1958
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1959
}
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1960
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1961
void CodeHeapState::print_age(outputStream* out, CodeHeap* heap) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1962
  if (!initialization_complete) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1963
    return;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1964
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1965
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1966
  const char* heapName   = get_heapName(heap);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1967
  get_HeapStatGlobals(out, heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1968
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1969
  if ((StatArray == NULL) || (alloc_granules == 0)) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1970
    return;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1971
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1972
  STRINGSTREAM_DECL(ast, out)
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1973
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1974
  unsigned int granules_per_line = 32;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1975
  char*        low_bound         = heap->low_boundary();
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1976
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1977
  {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1978
    printBox(ast, '=', "M E T H O D   A G E   by CompileID for ", heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1979
    ast->print_cr("  The age of a compiled method in the CodeHeap is not available as a\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1980
                  "  time stamp. Instead, a relative age is deducted from the method's compilation ID.\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1981
                  "  Age information is available for tier1 and tier2 methods only. There is no\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1982
                  "  age information for stubs and blobs, because they have no compilation ID assigned.\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1983
                  "  Information for the youngest method (highest ID) in the granule is printed.\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1984
                  "  Refer to the legend to learn how method age is mapped to the displayed digit.");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1985
    print_age_legend(ast);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1986
    STRINGSTREAM_FLUSH_LOCKED("")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1987
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1988
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1989
  {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1990
    printBox(ast, '-', "Age distribution. '0' indicates youngest 1/256, '8': oldest half, ' ': no age information", NULL);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1991
    STRINGSTREAM_FLUSH_LOCKED("")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1992
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1993
    granules_per_line = 128;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1994
    for (unsigned int ix = 0; ix < alloc_granules; ix++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1995
      print_line_delim(out, ast, low_bound, ix, granules_per_line);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1996
      unsigned int age1      = StatArray[ix].t1_age;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1997
      unsigned int age2      = StatArray[ix].t2_age;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1998
      unsigned int agex      = StatArray[ix].tx_age;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  1999
      unsigned int age       = age1 > age2 ? age1 : age2;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2000
      age       = age > agex ? age : agex;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2001
      print_age_single(ast, age);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2002
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2003
    STRINGSTREAM_FLUSH_LOCKED("|\n\n\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2004
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2005
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2006
  {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2007
    if (nBlocks_t1 > 0) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2008
      printBox(ast, '-', "Tier1 age distribution. '0' indicates youngest 1/256, '8': oldest half, ' ': no age information", NULL);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2009
      STRINGSTREAM_FLUSH_LOCKED("")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2010
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2011
      granules_per_line = 128;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2012
      for (unsigned int ix = 0; ix < alloc_granules; ix++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2013
        print_line_delim(out, ast, low_bound, ix, granules_per_line);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2014
        print_age_single(ast, StatArray[ix].t1_age);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2015
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2016
      STRINGSTREAM_FLUSH_LOCKED("|\n\n\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2017
    } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2018
      ast->print("No Tier1 nMethods found in CodeHeap.");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2019
      STRINGSTREAM_FLUSH_LOCKED("\n\n\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2020
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2021
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2022
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2023
  {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2024
    if (nBlocks_t2 > 0) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2025
      printBox(ast, '-', "Tier2 age distribution. '0' indicates youngest 1/256, '8': oldest half, ' ': no age information", NULL);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2026
      STRINGSTREAM_FLUSH_LOCKED("")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2027
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2028
      granules_per_line = 128;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2029
      for (unsigned int ix = 0; ix < alloc_granules; ix++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2030
        print_line_delim(out, ast, low_bound, ix, granules_per_line);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2031
        print_age_single(ast, StatArray[ix].t2_age);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2032
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2033
      STRINGSTREAM_FLUSH_LOCKED("|\n\n\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2034
    } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2035
      ast->print("No Tier2 nMethods found in CodeHeap.");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2036
      STRINGSTREAM_FLUSH_LOCKED("\n\n\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2037
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2038
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2039
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2040
  {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2041
    if (nBlocks_alive > 0) {
51124
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
  2042
      printBox(ast, '-', "not_used/not_entrant/not_installed age distribution. '0' indicates youngest 1/256, '8': oldest half, ' ': no age information", NULL);
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2043
      STRINGSTREAM_FLUSH_LOCKED("")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2044
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2045
      granules_per_line = 128;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2046
      for (unsigned int ix = 0; ix < alloc_granules; ix++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2047
        print_line_delim(out, ast, low_bound, ix, granules_per_line);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2048
        print_age_single(ast, StatArray[ix].tx_age);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2049
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2050
      STRINGSTREAM_FLUSH_LOCKED("|\n\n\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2051
    } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2052
      ast->print("No Tier2 nMethods found in CodeHeap.");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2053
      STRINGSTREAM_FLUSH_LOCKED("\n\n\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2054
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2055
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2056
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2057
  {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2058
    if (!segment_granules) { // Prevent totally redundant printouts
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2059
      printBox(ast, '-', "age distribution by tier <a1>:<a2>. '0' indicates youngest 1/256, '8': oldest half, ' ': no age information", NULL);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2060
      STRINGSTREAM_FLUSH_LOCKED("")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2061
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2062
      granules_per_line = 32;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2063
      for (unsigned int ix = 0; ix < alloc_granules; ix++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2064
        print_line_delim(out, ast, low_bound, ix, granules_per_line);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2065
        print_age_single(ast, StatArray[ix].t1_age);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2066
        ast->print(":");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2067
        print_age_single(ast, StatArray[ix].t2_age);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2068
        ast->print(" ");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2069
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2070
      STRINGSTREAM_FLUSH_LOCKED("|\n\n\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2071
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2072
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2073
}
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2074
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2075
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2076
void CodeHeapState::print_names(outputStream* out, CodeHeap* heap) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2077
  if (!initialization_complete) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2078
    return;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2079
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2080
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2081
  const char* heapName   = get_heapName(heap);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2082
  get_HeapStatGlobals(out, heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2083
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2084
  if ((StatArray == NULL) || (alloc_granules == 0)) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2085
    return;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2086
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2087
  STRINGSTREAM_DECL(ast, out)
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2088
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2089
  unsigned int granules_per_line  = 128;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2090
  char*        low_bound          = heap->low_boundary();
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2091
  CodeBlob*    last_blob          = NULL;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2092
  bool         name_in_addr_range = true;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2093
49825
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2094
  //---<  print at least 128K per block (i.e. between headers)  >---
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2095
  if (granules_per_line*granule_size < 128*K) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2096
    granules_per_line = (unsigned int)((128*K)/granule_size);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2097
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2098
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2099
  printBox(ast, '=', "M E T H O D   N A M E S   for ", heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2100
  ast->print_cr("  Method names are dynamically retrieved from the code cache at print time.\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2101
                "  Due to the living nature of the code heap and because the CodeCache_lock\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2102
                "  is not continuously held, the displayed name might be wrong or no name\n"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2103
                "  might be found at all. The likelihood for that to happen increases\n"
49825
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2104
                "  over time passed between aggregtion and print steps.\n");
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2105
  STRINGSTREAM_FLUSH_LOCKED("")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2106
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2107
  for (unsigned int ix = 0; ix < alloc_granules; ix++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2108
    //---<  print a new blob on a new line  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2109
    if (ix%granules_per_line == 0) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2110
      if (!name_in_addr_range) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2111
        ast->print_cr("No methods, blobs, or stubs found in this address range");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2112
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2113
      name_in_addr_range = false;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2114
49825
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2115
      size_t end_ix = (ix+granules_per_line <= alloc_granules) ? ix+granules_per_line : alloc_granules;
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2116
      ast->cr();
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2117
      ast->print_cr("--------------------------------------------------------------------");
49825
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2118
      ast->print_cr("Address range [" INTPTR_FORMAT "," INTPTR_FORMAT "), " SIZE_FORMAT "k", p2i(low_bound+ix*granule_size), p2i(low_bound + end_ix*granule_size), (end_ix - ix)*granule_size/(size_t)K);
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2119
      ast->print_cr("--------------------------------------------------------------------");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2120
      STRINGSTREAM_FLUSH_LOCKED("")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2121
    }
49650
c42db4d81e33 8200366: SIGSEGV in CodeHeapState::print_names()
lucy
parents: 49624
diff changeset
  2122
    // Only check granule if it contains at least one blob.
c42db4d81e33 8200366: SIGSEGV in CodeHeapState::print_names()
lucy
parents: 49624
diff changeset
  2123
    unsigned int nBlobs  = StatArray[ix].t1_count   + StatArray[ix].t2_count + StatArray[ix].tx_count +
c42db4d81e33 8200366: SIGSEGV in CodeHeapState::print_names()
lucy
parents: 49624
diff changeset
  2124
                           StatArray[ix].stub_count + StatArray[ix].dead_count;
49867
9689de1ea3a7 8202070: Cleanup code after JDK-8200450, JDK-8200366
lucy
parents: 49825
diff changeset
  2125
    if (nBlobs > 0 ) {
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2126
    for (unsigned int is = 0; is < granule_size; is+=(unsigned int)seg_size) {
49650
c42db4d81e33 8200366: SIGSEGV in CodeHeapState::print_names()
lucy
parents: 49624
diff changeset
  2127
      // heap->find_start() is safe. Only working with _segmap. Returns NULL or void*. Returned CodeBlob may be uninitialized.
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2128
      CodeBlob* this_blob = (CodeBlob *)(heap->find_start(low_bound+ix*granule_size+is));
49825
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2129
      bool blob_initialized = (this_blob != NULL) && (this_blob->header_size() >= 0) && (this_blob->relocation_size() >= 0) &&
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2130
                              ((address)this_blob + this_blob->header_size() == (address)(this_blob->relocation_begin())) &&
49867
9689de1ea3a7 8202070: Cleanup code after JDK-8200450, JDK-8200366
lucy
parents: 49825
diff changeset
  2131
                              ((address)this_blob + CodeBlob::align_code_offset(this_blob->header_size() + this_blob->relocation_size()) == (address)(this_blob->content_begin())) &&
51139
c95334202a14 8207342: error occurred during error reporting (printing register info)
mdoerr
parents: 51124
diff changeset
  2132
                              os::is_readable_pointer((address)(this_blob->relocation_begin())) &&
c95334202a14 8207342: error occurred during error reporting (printing register info)
mdoerr
parents: 51124
diff changeset
  2133
                              os::is_readable_pointer(this_blob->content_begin());
49867
9689de1ea3a7 8202070: Cleanup code after JDK-8200450, JDK-8200366
lucy
parents: 49825
diff changeset
  2134
      // blob could have been flushed, freed, and merged.
9689de1ea3a7 8202070: Cleanup code after JDK-8200450, JDK-8200366
lucy
parents: 49825
diff changeset
  2135
      // this_blob < last_blob is an indicator for that.
9689de1ea3a7 8202070: Cleanup code after JDK-8200450, JDK-8200366
lucy
parents: 49825
diff changeset
  2136
      if (blob_initialized && (this_blob > last_blob)) {
49825
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2137
        last_blob          = this_blob;
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2138
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2139
        //---<  get type and name  >---
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2140
        blobType       cbType = noType;
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2141
        if (segment_granules) {
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2142
          cbType = (blobType)StatArray[ix].type;
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2143
        } else {
49867
9689de1ea3a7 8202070: Cleanup code after JDK-8200450, JDK-8200366
lucy
parents: 49825
diff changeset
  2144
          cbType = get_cbType(this_blob);
49825
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2145
        }
49867
9689de1ea3a7 8202070: Cleanup code after JDK-8200450, JDK-8200366
lucy
parents: 49825
diff changeset
  2146
        // this_blob->name() could return NULL if no name was given to CTOR. Inlined, maybe invisible on stack
49825
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2147
        const char* blob_name = this_blob->name();
51139
c95334202a14 8207342: error occurred during error reporting (printing register info)
mdoerr
parents: 51124
diff changeset
  2148
        if ((blob_name == NULL) || !os::is_readable_pointer(blob_name)) {
49825
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2149
          blob_name = "<unavailable>";
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2150
        }
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2151
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2152
        //---<  print table header for new print range  >---
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2153
        if (!name_in_addr_range) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2154
          name_in_addr_range = true;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2155
          ast->fill_to(51);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2156
          ast->print("%9s", "compiler");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2157
          ast->fill_to(61);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2158
          ast->print_cr("%6s", "method");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2159
          ast->print_cr("%18s %13s %17s %9s  %5s %18s  %s", "Addr(module)      ", "offset", "size", " type lvl", " temp", "blobType          ", "Name");
49825
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2160
          STRINGSTREAM_FLUSH_LOCKED("")
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2161
        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2162
49825
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2163
        //---<  print line prefix (address and offset from CodeHeap start)  >---
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2164
        ast->print(INTPTR_FORMAT, p2i(this_blob));
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2165
        ast->fill_to(19);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2166
        ast->print("(+" PTR32_FORMAT ")", (unsigned int)((char*)this_blob-low_bound));
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2167
        ast->fill_to(33);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2168
49825
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2169
        // this_blob->as_nmethod_or_null() is safe. Inlined, maybe invisible on stack.
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2170
        nmethod*    nm     = this_blob->as_nmethod_or_null();
51591
9183040e34d8 8209950: SIGBUS in CodeHeapState::print_names()
lucy
parents: 51139
diff changeset
  2171
        if (CompiledMethod::nmethod_access_is_safe(nm)) {
9183040e34d8 8209950: SIGBUS in CodeHeapState::print_names()
lucy
parents: 51139
diff changeset
  2172
          Method* method = nm->method();
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2173
          ResourceMark rm;
49825
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2174
          //---<  collect all data to locals as quickly as possible  >---
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2175
          unsigned int total_size = nm->total_size();
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2176
          int          hotness    = nm->hotness_counter();
49867
9689de1ea3a7 8202070: Cleanup code after JDK-8200450, JDK-8200366
lucy
parents: 49825
diff changeset
  2177
          bool         get_name   = (cbType == nMethod_inuse) || (cbType == nMethod_notused);
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2178
          //---<  nMethod size in hex  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2179
          ast->print(PTR32_FORMAT, total_size);
49624
cfde7ece3113 8200297: Build failures after JDK-8198691 (CodeHeap State Analytics)
stuefe
parents: 49611
diff changeset
  2180
          ast->print("(" SIZE_FORMAT_W(4) "K)", total_size/K);
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2181
          //---<  compiler information  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2182
          ast->fill_to(51);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2183
          ast->print("%5s %3d", compTypeName[StatArray[ix].compiler], StatArray[ix].level);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2184
          //---<  method temperature  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2185
          ast->fill_to(62);
49825
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2186
          ast->print("%5d", hotness);
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2187
          //---<  name and signature  >---
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2188
          ast->fill_to(62+6);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2189
          ast->print("%s", blobTypeName[cbType]);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2190
          ast->fill_to(82+6);
49867
9689de1ea3a7 8202070: Cleanup code after JDK-8200450, JDK-8200366
lucy
parents: 49825
diff changeset
  2191
          if (cbType == nMethod_dead) {
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2192
            ast->print("%14s", " zombie method");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2193
          }
49825
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2194
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2195
          if (get_name) {
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2196
            Symbol* methName  = method->name();
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2197
            const char*   methNameS = (methName == NULL) ? NULL : methName->as_C_string();
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2198
            methNameS = (methNameS == NULL) ? "<method name unavailable>" : methNameS;
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2199
            Symbol* methSig   = method->signature();
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2200
            const char*   methSigS  = (methSig  == NULL) ? NULL : methSig->as_C_string();
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2201
            methSigS  = (methSigS  == NULL) ? "<method signature unavailable>" : methSigS;
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2202
            ast->print("%s", methNameS);
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2203
            ast->print("%s", methSigS);
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2204
          } else {
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2205
            ast->print("%s", blob_name);
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2206
          }
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2207
        } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2208
          ast->fill_to(62+6);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2209
          ast->print("%s", blobTypeName[cbType]);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2210
          ast->fill_to(82+6);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2211
          ast->print("%s", blob_name);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2212
        }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2213
        STRINGSTREAM_FLUSH_LOCKED("\n")
49825
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2214
      } else if (!blob_initialized && (this_blob != last_blob) && (this_blob != NULL)) {
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2215
        last_blob          = this_blob;
49825
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2216
        STRINGSTREAM_FLUSH_LOCKED("\n")
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2217
      }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2218
    }
49825
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2219
    } // nBlobs > 0
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2220
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2221
  STRINGSTREAM_FLUSH_LOCKED("\n\n")
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2222
}
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2223
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2224
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2225
void CodeHeapState::printBox(outputStream* ast, const char border, const char* text1, const char* text2) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2226
  unsigned int lineLen = 1 + 2 + 2 + 1;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2227
  char edge, frame;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2228
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2229
  if (text1 != NULL) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2230
    lineLen += (unsigned int)strlen(text1); // text1 is much shorter than MAX_INT chars.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2231
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2232
  if (text2 != NULL) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2233
    lineLen += (unsigned int)strlen(text2); // text2 is much shorter than MAX_INT chars.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2234
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2235
  if (border == '-') {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2236
    edge  = '+';
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2237
    frame = '|';
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2238
  } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2239
    edge  = border;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2240
    frame = border;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2241
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2242
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2243
  ast->print("%c", edge);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2244
  for (unsigned int i = 0; i < lineLen-2; i++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2245
    ast->print("%c", border);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2246
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2247
  ast->print_cr("%c", edge);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2248
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2249
  ast->print("%c  ", frame);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2250
  if (text1 != NULL) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2251
    ast->print("%s", text1);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2252
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2253
  if (text2 != NULL) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2254
    ast->print("%s", text2);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2255
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2256
  ast->print_cr("  %c", frame);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2257
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2258
  ast->print("%c", edge);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2259
  for (unsigned int i = 0; i < lineLen-2; i++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2260
    ast->print("%c", border);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2261
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2262
  ast->print_cr("%c", edge);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2263
}
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2264
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2265
void CodeHeapState::print_blobType_legend(outputStream* out) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2266
  out->cr();
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2267
  printBox(out, '-', "Block types used in the following CodeHeap dump", NULL);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2268
  for (int type = noType; type < lastType; type += 1) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2269
    out->print_cr("  %c - %s", blobTypeChar[type], blobTypeName[type]);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2270
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2271
  out->print_cr("  -----------------------------------------------------");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2272
  out->cr();
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2273
}
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2274
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2275
void CodeHeapState::print_space_legend(outputStream* out) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2276
  unsigned int indicator = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2277
  unsigned int age_range = 256;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2278
  unsigned int range_beg = latest_compilation_id;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2279
  out->cr();
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2280
  printBox(out, '-', "Space ranges, based on granule occupancy", NULL);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2281
  out->print_cr("    -   0%% == occupancy");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2282
  for (int i=0; i<=9; i++) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2283
    out->print_cr("  %d - %3d%% < occupancy < %3d%%", i, 10*i, 10*(i+1));
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2284
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2285
  out->print_cr("  * - 100%% == occupancy");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2286
  out->print_cr("  ----------------------------------------------");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2287
  out->cr();
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2288
}
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2289
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2290
void CodeHeapState::print_age_legend(outputStream* out) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2291
  unsigned int indicator = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2292
  unsigned int age_range = 256;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2293
  unsigned int range_beg = latest_compilation_id;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2294
  out->cr();
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2295
  printBox(out, '-', "Age ranges, based on compilation id", NULL);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2296
  while (age_range > 0) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2297
    out->print_cr("  %d - %6d to %6d", indicator, range_beg, latest_compilation_id - latest_compilation_id/age_range);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2298
    range_beg = latest_compilation_id - latest_compilation_id/age_range;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2299
    age_range /= 2;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2300
    indicator += 1;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2301
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2302
  out->print_cr("  -----------------------------------------");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2303
  out->cr();
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2304
}
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2305
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2306
void CodeHeapState::print_blobType_single(outputStream* out, u2 /* blobType */ type) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2307
  out->print("%c", blobTypeChar[type]);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2308
}
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2309
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2310
void CodeHeapState::print_count_single(outputStream* out, unsigned short count) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2311
  if (count >= 16)    out->print("*");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2312
  else if (count > 0) out->print("%1.1x", count);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2313
  else                out->print(" ");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2314
}
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2315
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2316
void CodeHeapState::print_space_single(outputStream* out, unsigned short space) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2317
  size_t  space_in_bytes = ((unsigned int)space)<<log2_seg_size;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2318
  char    fraction       = (space == 0) ? ' ' : (space_in_bytes >= granule_size-1) ? '*' : char('0'+10*space_in_bytes/granule_size);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2319
  out->print("%c", fraction);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2320
}
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2321
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2322
void CodeHeapState::print_age_single(outputStream* out, unsigned int age) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2323
  unsigned int indicator = 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2324
  unsigned int age_range = 256;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2325
  if (age > 0) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2326
    while ((age_range > 0) && (latest_compilation_id-age > latest_compilation_id/age_range)) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2327
      age_range /= 2;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2328
      indicator += 1;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2329
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2330
    out->print("%c", char('0'+indicator));
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2331
  } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2332
    out->print(" ");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2333
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2334
}
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2335
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2336
void CodeHeapState::print_line_delim(outputStream* out, outputStream* ast, char* low_bound, unsigned int ix, unsigned int gpl) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2337
  if (ix % gpl == 0) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2338
    if (ix > 0) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2339
      ast->print("|");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2340
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2341
    ast->cr();
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2342
    assert(out == ast, "must use the same stream!");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2343
49825
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2344
    ast->print(INTPTR_FORMAT, p2i(low_bound + ix*granule_size));
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2345
    ast->fill_to(19);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2346
    ast->print("(+" PTR32_FORMAT "): |", (unsigned int)(ix*granule_size));
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2347
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2348
}
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2349
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2350
void CodeHeapState::print_line_delim(outputStream* out, bufferedStream* ast, char* low_bound, unsigned int ix, unsigned int gpl) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2351
  assert(out != ast, "must not use the same stream!");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2352
  if (ix % gpl == 0) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2353
    if (ix > 0) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2354
      ast->print("|");
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2355
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2356
    ast->cr();
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2357
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2358
    { // can't use STRINGSTREAM_FLUSH_LOCKED("") here.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2359
      ttyLocker ttyl;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2360
      out->print("%s", ast->as_string());
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2361
      ast->reset();
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2362
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2363
49825
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49650
diff changeset
  2364
    ast->print(INTPTR_FORMAT, p2i(low_bound + ix*granule_size));
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2365
    ast->fill_to(19);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2366
    ast->print("(+" PTR32_FORMAT "): |", (unsigned int)(ix*granule_size));
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2367
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2368
}
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2369
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2370
CodeHeapState::blobType CodeHeapState::get_cbType(CodeBlob* cb) {
51139
c95334202a14 8207342: error occurred during error reporting (printing register info)
mdoerr
parents: 51124
diff changeset
  2371
  if ((cb != NULL) && os::is_readable_pointer(cb)) {
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2372
    if (cb->is_runtime_stub())                return runtimeStub;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2373
    if (cb->is_deoptimization_stub())         return deoptimizationStub;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2374
    if (cb->is_uncommon_trap_stub())          return uncommonTrapStub;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2375
    if (cb->is_exception_stub())              return exceptionStub;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2376
    if (cb->is_safepoint_stub())              return safepointStub;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2377
    if (cb->is_adapter_blob())                return adapterBlob;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2378
    if (cb->is_method_handles_adapter_blob()) return mh_adapterBlob;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2379
    if (cb->is_buffer_blob())                 return bufferBlob;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2380
49867
9689de1ea3a7 8202070: Cleanup code after JDK-8200450, JDK-8200366
lucy
parents: 49825
diff changeset
  2381
    nmethod*  nm = cb->as_nmethod_or_null();
9689de1ea3a7 8202070: Cleanup code after JDK-8200450, JDK-8200366
lucy
parents: 49825
diff changeset
  2382
    if (nm != NULL) { // no is_readable check required, nm = (nmethod*)cb.
51124
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
  2383
      if (nm->is_not_installed()) return nMethod_inconstruction;
49867
9689de1ea3a7 8202070: Cleanup code after JDK-8200450, JDK-8200366
lucy
parents: 49825
diff changeset
  2384
      if (nm->is_zombie())        return nMethod_dead;
9689de1ea3a7 8202070: Cleanup code after JDK-8200450, JDK-8200366
lucy
parents: 49825
diff changeset
  2385
      if (nm->is_unloaded())      return nMethod_unloaded;
51124
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49867
diff changeset
  2386
      if (nm->is_in_use())        return nMethod_inuse;
49867
9689de1ea3a7 8202070: Cleanup code after JDK-8200450, JDK-8200366
lucy
parents: 49825
diff changeset
  2387
      if (nm->is_alive() && !(nm->is_not_entrant()))   return nMethod_notused;
9689de1ea3a7 8202070: Cleanup code after JDK-8200450, JDK-8200366
lucy
parents: 49825
diff changeset
  2388
      if (nm->is_alive())         return nMethod_alive;
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2389
      return nMethod_dead;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2390
    }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2391
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2392
  return noType;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
  2393
}