src/hotspot/share/code/codeHeapState.hpp
author phh
Sat, 30 Nov 2019 14:33:05 -0800
changeset 59330 5b96c12f909d
parent 55294 3493c1bc59fd
permissions -rw-r--r--
8234541: C1 emits an empty message when it inlines successfully Summary: Use "inline" as the message when successfull Reviewed-by: thartmann, mdoerr Contributed-by: navy.xliu@gmail.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
     1
/*
53353
a6620d37728b 8216314: SIGILL in CodeHeapState::print_names()
lucy
parents: 51139
diff changeset
     2
 * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
a6620d37728b 8216314: SIGILL in CodeHeapState::print_names()
lucy
parents: 51139
diff changeset
     3
 * Copyright (c) 2018, 2019 SAP SE. All rights reserved.
49611
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
#ifndef SHARE_CODE_CODEHEAPSTATE_HPP
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    27
#define SHARE_CODE_CODEHEAPSTATE_HPP
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    28
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    29
#include "memory/heap.hpp"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    30
#include "utilities/debug.hpp"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    31
#include "utilities/globalDefinitions.hpp"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    32
#include "utilities/ostream.hpp"
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    33
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    34
class CodeHeapState : public CHeapObj<mtCode> {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    35
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    36
 public:
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    37
  enum compType {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    38
    noComp = 0,     // must be! due to initialization by memset to zero
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    39
    c1,
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    40
    c2,
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    41
    jvmci,
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    42
    lastComp
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    43
  };
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    44
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    45
  enum blobType {
51124
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49825
diff changeset
    46
    noType = 0,             // must be! due to initialization by memset to zero
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49825
diff changeset
    47
    // The nMethod_* values correspond to the CompiledMethod enum values.
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49825
diff changeset
    48
    // We can't use the CompiledMethod values 1:1 because we depend on noType == 0.
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49825
diff changeset
    49
    nMethod_inconstruction, // under construction. Very soon, the type will transition to "in_use".
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49825
diff changeset
    50
    nMethod_inuse,          // executable. This is the "normal" state for a nmethod.
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49825
diff changeset
    51
    nMethod_notused,        // assumed inactive, marked not entrant. Could be revived if necessary.
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49825
diff changeset
    52
    nMethod_notentrant,     // no new activations allowed, marked for deoptimization. Old activations may still exist.
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49825
diff changeset
    53
                            // Will transition to "zombie" after all activations are gone.
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49825
diff changeset
    54
    nMethod_zombie,         // No more activations exist, ready for purge (remove from code cache).
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49825
diff changeset
    55
    nMethod_unloaded,       // No activations exist, should not be called. Transient state on the way to "zombie".
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49825
diff changeset
    56
    nMethod_alive = nMethod_notentrant, // Combined state: nmethod may have activations, thus can't be purged.
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49825
diff changeset
    57
    nMethod_dead  = nMethod_zombie,     // Combined state: nmethod does not have any activations.
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49825
diff changeset
    58
    runtimeStub   = nMethod_unloaded + 1,
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49825
diff changeset
    59
    ricochetStub,
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49825
diff changeset
    60
    deoptimizationStub,
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49825
diff changeset
    61
    uncommonTrapStub,
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49825
diff changeset
    62
    exceptionStub,
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49825
diff changeset
    63
    safepointStub,
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49825
diff changeset
    64
    adapterBlob,
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49825
diff changeset
    65
    mh_adapterBlob,
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49825
diff changeset
    66
    bufferBlob,
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49825
diff changeset
    67
    lastType
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    68
  };
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    69
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    70
 private:
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    71
  static void prepare_StatArray(outputStream* out, size_t nElem, size_t granularity, const char* heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    72
  static void prepare_FreeArray(outputStream* out, unsigned int nElem, const char* heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    73
  static void prepare_TopSizeArray(outputStream* out, unsigned int nElem, const char* heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    74
  static void prepare_SizeDistArray(outputStream* out, unsigned int nElem, const char* heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    75
  static void discard_StatArray(outputStream* out);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    76
  static void discard_FreeArray(outputStream* out);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    77
  static void discard_TopSizeArray(outputStream* out);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    78
  static void discard_SizeDistArray(outputStream* out);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    79
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    80
  static void update_SizeDistArray(outputStream* out, unsigned int len);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    81
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    82
  static const char* get_heapName(CodeHeap* heap);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    83
  static unsigned int findHeapIndex(outputStream* out, const char* heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    84
  static void get_HeapStatGlobals(outputStream* out, const char* heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    85
  static void set_HeapStatGlobals(outputStream* out, const char* heapName);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    86
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    87
  static void printBox(outputStream* out, const char border, const char* text1, const char* text2);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    88
  static void print_blobType_legend(outputStream* out);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    89
  static void print_space_legend(outputStream* out);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    90
  static void print_age_legend(outputStream* out);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    91
  static void print_blobType_single(outputStream *ast, u2 /* blobType */ type);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    92
  static void print_count_single(outputStream *ast, unsigned short count);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    93
  static void print_space_single(outputStream *ast, unsigned short space);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    94
  static void print_age_single(outputStream *ast, unsigned int age);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    95
  static void print_line_delim(outputStream* out, bufferedStream *sst, char* low_bound, unsigned int ix, unsigned int gpl);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    96
  static void print_line_delim(outputStream* out, outputStream *sst, char* low_bound, unsigned int ix, unsigned int gpl);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    97
  static blobType get_cbType(CodeBlob* cb);
53353
a6620d37728b 8216314: SIGILL in CodeHeapState::print_names()
lucy
parents: 51139
diff changeset
    98
  static bool blob_access_is_safe(CodeBlob* this_blob, CodeBlob* prev_blob);
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
    99
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   100
 public:
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   101
  static void discard(outputStream* out, CodeHeap* heap);
55294
3493c1bc59fd 8225388: Running jcmd Compiler.CodeHeap_Analytics all 0 cause crash.
lmesnik
parents: 53353
diff changeset
   102
  static void aggregate(outputStream* out, CodeHeap* heap, size_t granularity);
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   103
  static void print_usedSpace(outputStream* out, CodeHeap* heap);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   104
  static void print_freeSpace(outputStream* out, CodeHeap* heap);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   105
  static void print_count(outputStream* out, CodeHeap* heap);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   106
  static void print_space(outputStream* out, CodeHeap* heap);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   107
  static void print_age(outputStream* out, CodeHeap* heap);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   108
  static void print_names(outputStream* out, CodeHeap* heap);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   109
};
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   110
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   111
//----------------
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   112
//  StatElement
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   113
//----------------
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   114
//  Each analysis granule is represented by an instance of
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   115
//  this StatElement struct. It collects and aggregates all
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   116
//  information describing the allocated contents of the granule.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   117
//  Free (unallocated) contents is not considered (see FreeBlk for that).
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   118
//  All StatElements of a heap segment are stored in the related StatArray.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   119
//  Current size: 40 bytes + 8 bytes class header.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   120
class StatElement : public CHeapObj<mtCode> {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   121
  public:
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   122
    // A note on ages: The compilation_id easily overflows unsigned short in large systems
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   123
    unsigned int       t1_age;      // oldest compilation_id of tier1 nMethods.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   124
    unsigned int       t2_age;      // oldest compilation_id of tier2 nMethods.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   125
    unsigned int       tx_age;      // oldest compilation_id of inactive/not entrant nMethods.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   126
    unsigned short     t1_space;    // in units of _segment_size to "prevent" overflow
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   127
    unsigned short     t2_space;    // in units of _segment_size to "prevent" overflow
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   128
    unsigned short     tx_space;    // in units of _segment_size to "prevent" overflow
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   129
    unsigned short     dead_space;  // in units of _segment_size to "prevent" overflow
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   130
    unsigned short     stub_space;  // in units of _segment_size to "prevent" overflow
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   131
    unsigned short     t1_count;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   132
    unsigned short     t2_count;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   133
    unsigned short     tx_count;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   134
    unsigned short     dead_count;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   135
    unsigned short     stub_count;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   136
    CompLevel          level;       // optimization level (see globalDefinitions.hpp)
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   137
    //---<  replaced the correct enum typing with u2 to save space.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   138
    u2                 compiler;    // compiler which generated this blob. Type is CodeHeapState::compType
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   139
    u2                 type;        // used only if granularity == segment_size. Type is CodeHeapState::blobType
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   140
};
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   141
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   142
//-----------
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   143
//  FreeBlk
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   144
//-----------
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   145
//  Each free block in the code heap is represented by an instance
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   146
//  of this FreeBlk struct. It collects all information we need to
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   147
//  know about each free block.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   148
//  All FreeBlks of a heap segment are stored in the related FreeArray.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   149
struct FreeBlk : public CHeapObj<mtCode> {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   150
  HeapBlock*     start;       // address of free block
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   151
  unsigned int   len;          // length of free block
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   152
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   153
  unsigned int   gap;          // gap to next free block
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   154
  unsigned int   index;        // sequential number of free block
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   155
  unsigned short n_gapBlocks;  // # used blocks in gap
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   156
  bool           stubs_in_gap; // The occupied space between this and the next free block contains (unmovable) stubs or blobs.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   157
};
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   158
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   159
//--------------
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   160
//  TopSizeBlk
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   161
//--------------
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   162
//  The n largest blocks in the code heap are represented in an instance
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   163
//  of this TopSizeBlk struct. It collects all information we need to
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   164
//  know about those largest blocks.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   165
//  All TopSizeBlks of a heap segment are stored in the related TopSizeArray.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   166
struct TopSizeBlk : public CHeapObj<mtCode> {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   167
  HeapBlock*     start;       // address of block
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   168
  unsigned int   len;          // length of block, in _segment_size units. Will never overflow int.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   169
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   170
  unsigned int   index;        // ordering index, 0 is largest block
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   171
                               // contains array index of next smaller block
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   172
                               // -1 indicates end of list
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   173
  CompLevel      level;        // optimization level (see globalDefinitions.hpp)
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   174
  u2             compiler;     // compiler which generated this blob
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   175
  u2             type;         // blob type
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   176
};
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   177
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   178
//---------------------------
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   179
//  SizeDistributionElement
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   180
//---------------------------
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   181
//  During CodeHeap analysis, each allocated code block is associated with a
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   182
//  SizeDistributionElement according to its size. Later on, the array of
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   183
//  SizeDistributionElements is used to print a size distribution bar graph.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   184
//  All SizeDistributionElements of a heap segment are stored in the related SizeDistributionArray.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   185
struct SizeDistributionElement : public CHeapObj<mtCode> {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   186
                               // Range is [rangeStart..rangeEnd).
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   187
  unsigned int   rangeStart;   // start of length range, in _segment_size units.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   188
  unsigned int   rangeEnd;     // end   of length range, in _segment_size units.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   189
  unsigned int   lenSum;       // length of block, in _segment_size units. Will never overflow int.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   190
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   191
  unsigned int   count;        // number of blocks assigned to this range.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   192
};
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   193
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   194
//----------------
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   195
//  CodeHeapStat
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   196
//----------------
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   197
//  Because we have to deal with multiple CodeHeaps, we need to
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   198
//  collect "global" information in a segment-specific way as well.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   199
//  Thats what the CodeHeapStat and CodeHeapStatArray are used for.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   200
//  Before a heap segment is processed, the contents of the CodeHeapStat
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   201
//  element is copied to the global variables (get_HeapStatGlobals).
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   202
//  When processing is done, the possibly modified global variables are
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   203
//  copied back (set_HeapStatGlobals) to the CodeHeapStat element.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   204
struct CodeHeapStat {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   205
    StatElement*                     StatArray;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   206
    struct FreeBlk*                  FreeArray;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   207
    struct TopSizeBlk*               TopSizeArray;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   208
    struct SizeDistributionElement*  SizeDistributionArray;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   209
    const char*                      heapName;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   210
    size_t                           segment_size;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   211
    // StatElement data
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   212
    size_t        alloc_granules;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   213
    size_t        granule_size;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   214
    bool          segment_granules;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   215
    unsigned int  nBlocks_t1;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   216
    unsigned int  nBlocks_t2;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   217
    unsigned int  nBlocks_alive;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   218
    unsigned int  nBlocks_dead;
51124
40ef1bb91ee8 8206271: CodeHeap State Analytics must digest new method state
lucy
parents: 49825
diff changeset
   219
    unsigned int  nBlocks_inconstr;
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   220
    unsigned int  nBlocks_unloaded;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   221
    unsigned int  nBlocks_stub;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   222
    // FreeBlk data
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   223
    unsigned int  alloc_freeBlocks;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   224
    // UsedBlk data
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   225
    unsigned int  alloc_topSizeBlocks;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   226
    unsigned int  used_topSizeBlocks;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   227
    // method hotness data. Temperature range is [-reset_val..+reset_val]
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   228
    int           avgTemp;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   229
    int           maxTemp;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   230
    int           minTemp;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   231
};
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   232
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents:
diff changeset
   233
#endif // SHARE_CODE_CODEHEAPSTATE_HPP