src/hotspot/share/memory/metaspace.hpp
author stuefe
Mon, 01 Jul 2019 16:28:17 +0200
changeset 55586 014c8cd323af
parent 55576 4d193e40e7af
child 57464 32e61f51ee09
child 57875 427b38332f20
permissions -rw-r--r--
8227032: MetaspaceUtils::print_report crashes when called before initialization Reviewed-by: tschatzl, goetz
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52925
diff changeset
     2
 * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     4
 *
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     7
 * published by the Free Software Foundation.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     8
 *
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    13
 * accompanied this code).
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    14
 *
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    18
 *
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    21
 * questions.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    22
 *
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    23
 */
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52925
diff changeset
    24
#ifndef SHARE_MEMORY_METASPACE_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52925
diff changeset
    25
#define SHARE_MEMORY_METASPACE_HPP
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    26
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    27
#include "memory/allocation.hpp"
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    28
#include "memory/memRegion.hpp"
23470
ff2a7ea4225d 8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents: 23469
diff changeset
    29
#include "memory/metaspaceChunkFreeListSummary.hpp"
30291
54cdc5c1a9cb 8068352: Move virtualspace.* out of src/share/vm/runtime to memory directory
coleenp
parents: 26938
diff changeset
    30
#include "memory/virtualspace.hpp"
55576
4d193e40e7af 8223575: add subspace transitions to gc+metaspace=info log lines
tonyp
parents: 54842
diff changeset
    31
#include "memory/metaspace/metaspaceSizesSnapshot.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    32
#include "utilities/exceptions.hpp"
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    33
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    34
// Metaspace
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    35
//
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    36
// Metaspaces are Arenas for the VM's metadata.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    37
// They are allocated one per class loader object, and one for the null
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    38
// bootstrap class loader
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    39
//
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    40
//    block X ---+       +-------------------+
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    41
//               |       |  Virtualspace     |
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    42
//               |       |                   |
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    43
//               |       |                   |
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    44
//               |       |-------------------|
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    45
//               |       || Chunk            |
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    46
//               |       ||                  |
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    47
//               |       ||----------        |
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    48
//               +------>||| block 0 |       |
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    49
//                       ||----------        |
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    50
//                       ||| block 1 |       |
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    51
//                       ||----------        |
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    52
//                       ||                  |
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    53
//                       |-------------------|
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    54
//                       |                   |
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    55
//                       |                   |
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    56
//                       +-------------------+
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    57
//
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    58
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    59
class ClassLoaderData;
23465
14790e4d53ec 8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents: 22872
diff changeset
    60
class MetaspaceTracer;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    61
class Mutex;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    62
class outputStream;
50193
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents: 50119
diff changeset
    63
49449
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 49401
diff changeset
    64
class CollectedHeap;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    65
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
    66
namespace metaspace {
50193
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents: 50119
diff changeset
    67
  class ChunkManager;
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
    68
  class ClassLoaderMetaspaceStatistics;
50193
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents: 50119
diff changeset
    69
  class Metablock;
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents: 50119
diff changeset
    70
  class Metachunk;
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents: 50119
diff changeset
    71
  class PrintCLDMetaspaceInfoClosure;
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents: 50119
diff changeset
    72
  class SpaceManager;
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents: 50119
diff changeset
    73
  class VirtualSpaceList;
52014
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51444
diff changeset
    74
  class VirtualSpaceNode;
50193
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents: 50119
diff changeset
    75
}
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
    76
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    77
// Metaspaces each have a  SpaceManager and allocations
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    78
// are done by the SpaceManager.  Allocations are done
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    79
// out of the current Metachunk.  When the current Metachunk
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    80
// is exhausted, the SpaceManager gets a new one from
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    81
// the current VirtualSpace.  When the VirtualSpace is exhausted
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    82
// the SpaceManager gets a new one.  The SpaceManager
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    83
// also manages freelists of available Chunks.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    84
//
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    85
// Currently the space manager maintains the list of
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    86
// virtual spaces and the list of chunks in use.  Its
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    87
// allocate() method returns a block for use as a
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    88
// quantum of metadata.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    89
49401
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
    90
// Namespace for important central static functions
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
    91
// (auxiliary stuff goes into MetaspaceUtils)
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
    92
class Metaspace : public AllStatic {
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
    93
46746
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46324
diff changeset
    94
  friend class MetaspaceShared;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    95
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    96
 public:
20406
934f0b12daa9 8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents: 20306
diff changeset
    97
  enum MetadataType {
934f0b12daa9 8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents: 20306
diff changeset
    98
    ClassType,
934f0b12daa9 8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents: 20306
diff changeset
    99
    NonClassType,
934f0b12daa9 8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents: 20306
diff changeset
   100
    MetadataTypeCount
17628
481e0280aed3 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 17109
diff changeset
   101
  };
15086
2bfd799e9147 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 14842
diff changeset
   102
  enum MetaspaceType {
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   103
    ZeroMetaspaceType = 0,
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   104
    StandardMetaspaceType = ZeroMetaspaceType,
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   105
    BootMetaspaceType = StandardMetaspaceType + 1,
51444
3e5d28e6de32 8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents: 50525
diff changeset
   106
    UnsafeAnonymousMetaspaceType = BootMetaspaceType + 1,
3e5d28e6de32 8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents: 50525
diff changeset
   107
    ReflectionMetaspaceType = UnsafeAnonymousMetaspaceType + 1,
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   108
    MetaspaceTypeCount
15086
2bfd799e9147 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 14842
diff changeset
   109
  };
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   110
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   111
 private:
20081
e26536e86a5c 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 19989
diff changeset
   112
15086
2bfd799e9147 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 14842
diff changeset
   113
  // Align up the word size to the allocation word size
2bfd799e9147 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 14842
diff changeset
   114
  static size_t align_word_size_up(size_t);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   115
19319
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18025
diff changeset
   116
  // Aligned size of the metaspace.
21188
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 21186
diff changeset
   117
  static size_t _compressed_class_space_size;
19319
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18025
diff changeset
   118
21188
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 21186
diff changeset
   119
  static size_t compressed_class_space_size() {
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 21186
diff changeset
   120
    return _compressed_class_space_size;
19319
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18025
diff changeset
   121
  }
22853
308672304981 8028767: PPC64: (part 121): smaller shared changes needed to build C2
goetz
parents: 21188
diff changeset
   122
21188
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 21186
diff changeset
   123
  static void set_compressed_class_space_size(size_t size) {
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 21186
diff changeset
   124
    _compressed_class_space_size = size;
19319
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18025
diff changeset
   125
  }
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18025
diff changeset
   126
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   127
  static size_t _first_chunk_word_size;
15086
2bfd799e9147 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 14842
diff changeset
   128
  static size_t _first_class_chunk_word_size;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   129
20406
934f0b12daa9 8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents: 20306
diff changeset
   130
  static size_t _commit_alignment;
934f0b12daa9 8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents: 20306
diff changeset
   131
  static size_t _reserve_alignment;
46746
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46324
diff changeset
   132
  DEBUG_ONLY(static bool   _frozen;)
20406
934f0b12daa9 8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents: 20306
diff changeset
   133
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   134
  // Virtual Space lists for both classes and other metadata
50193
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents: 50119
diff changeset
   135
  static metaspace::VirtualSpaceList* _space_list;
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents: 50119
diff changeset
   136
  static metaspace::VirtualSpaceList* _class_space_list;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   137
50193
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents: 50119
diff changeset
   138
  static metaspace::ChunkManager* _chunk_manager_metadata;
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents: 50119
diff changeset
   139
  static metaspace::ChunkManager* _chunk_manager_class;
20081
e26536e86a5c 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 19989
diff changeset
   140
23465
14790e4d53ec 8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents: 22872
diff changeset
   141
  static const MetaspaceTracer* _tracer;
14790e4d53ec 8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents: 22872
diff changeset
   142
55586
014c8cd323af 8227032: MetaspaceUtils::print_report crashes when called before initialization
stuefe
parents: 55576
diff changeset
   143
  static bool _initialized;
014c8cd323af 8227032: MetaspaceUtils::print_report crashes when called before initialization
stuefe
parents: 55576
diff changeset
   144
20081
e26536e86a5c 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 19989
diff changeset
   145
 public:
50193
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents: 50119
diff changeset
   146
  static metaspace::VirtualSpaceList* space_list()       { return _space_list; }
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents: 50119
diff changeset
   147
  static metaspace::VirtualSpaceList* class_space_list() { return _class_space_list; }
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents: 50119
diff changeset
   148
  static metaspace::VirtualSpaceList* get_space_list(MetadataType mdtype) {
19322
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 19319
diff changeset
   149
    assert(mdtype != MetadataTypeCount, "MetadaTypeCount can't be used as mdtype");
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 19319
diff changeset
   150
    return mdtype == ClassType ? class_space_list() : space_list();
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 19319
diff changeset
   151
  }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   152
50193
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents: 50119
diff changeset
   153
  static metaspace::ChunkManager* chunk_manager_metadata() { return _chunk_manager_metadata; }
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents: 50119
diff changeset
   154
  static metaspace::ChunkManager* chunk_manager_class()    { return _chunk_manager_class; }
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents: 50119
diff changeset
   155
  static metaspace::ChunkManager* get_chunk_manager(MetadataType mdtype) {
20081
e26536e86a5c 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 19989
diff changeset
   156
    assert(mdtype != MetadataTypeCount, "MetadaTypeCount can't be used as mdtype");
e26536e86a5c 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 19989
diff changeset
   157
    return mdtype == ClassType ? chunk_manager_class() : chunk_manager_metadata();
e26536e86a5c 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 19989
diff changeset
   158
  }
e26536e86a5c 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 19989
diff changeset
   159
49365
825f006619e5 8198423: Improve metaspace chunk allocation
stuefe
parents: 49045
diff changeset
   160
  // convenience function
50193
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents: 50119
diff changeset
   161
  static metaspace::ChunkManager* get_chunk_manager(bool is_class) {
49365
825f006619e5 8198423: Improve metaspace chunk allocation
stuefe
parents: 49045
diff changeset
   162
    return is_class ? chunk_manager_class() : chunk_manager_metadata();
825f006619e5 8198423: Improve metaspace chunk allocation
stuefe
parents: 49045
diff changeset
   163
  }
825f006619e5 8198423: Improve metaspace chunk allocation
stuefe
parents: 49045
diff changeset
   164
23465
14790e4d53ec 8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents: 22872
diff changeset
   165
  static const MetaspaceTracer* tracer() { return _tracer; }
46746
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46324
diff changeset
   166
  static void freeze() {
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46324
diff changeset
   167
    assert(DumpSharedSpaces, "sanity");
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46324
diff changeset
   168
    DEBUG_ONLY(_frozen = true;)
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46324
diff changeset
   169
  }
49401
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   170
  static void assert_not_frozen() {
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   171
    assert(!_frozen, "sanity");
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   172
  }
47599
0fb1d501c408 8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents: 47553
diff changeset
   173
#ifdef _LP64
0fb1d501c408 8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents: 47553
diff changeset
   174
  static void allocate_metaspace_compressed_klass_ptrs(char* requested_addr, address cds_base);
0fb1d501c408 8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents: 47553
diff changeset
   175
#endif
0fb1d501c408 8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents: 47553
diff changeset
   176
20081
e26536e86a5c 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 19989
diff changeset
   177
 private:
17858
c292f8791cca 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 17628
diff changeset
   178
19319
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18025
diff changeset
   179
#ifdef _LP64
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18025
diff changeset
   180
  static void set_narrow_klass_base_and_shift(address metaspace_base, address cds_base);
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18025
diff changeset
   181
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18025
diff changeset
   182
  // Returns true if can use CDS with metaspace allocated as specified address.
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18025
diff changeset
   183
  static bool can_use_cds_with_metaspace_addr(char* metaspace_base, address cds_base);
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18025
diff changeset
   184
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18025
diff changeset
   185
  static void initialize_class_space(ReservedSpace rs);
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18025
diff changeset
   186
#endif
21186
db851068711f 8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents: 20729
diff changeset
   187
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   188
 public:
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   189
20406
934f0b12daa9 8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents: 20306
diff changeset
   190
  static void ergo_initialize();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   191
  static void global_initialize();
24847
37c354b113fe 8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents: 24457
diff changeset
   192
  static void post_initialize();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   193
49401
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   194
  static void verify_global_initialization();
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   195
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   196
  static size_t first_chunk_word_size() { return _first_chunk_word_size; }
15086
2bfd799e9147 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 14842
diff changeset
   197
  static size_t first_class_chunk_word_size() { return _first_class_chunk_word_size; }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   198
20406
934f0b12daa9 8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents: 20306
diff changeset
   199
  static size_t reserve_alignment()       { return _reserve_alignment; }
934f0b12daa9 8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents: 20306
diff changeset
   200
  static size_t reserve_alignment_words() { return _reserve_alignment / BytesPerWord; }
934f0b12daa9 8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents: 20306
diff changeset
   201
  static size_t commit_alignment()        { return _commit_alignment; }
934f0b12daa9 8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents: 20306
diff changeset
   202
  static size_t commit_alignment_words()  { return _commit_alignment / BytesPerWord; }
934f0b12daa9 8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents: 20306
diff changeset
   203
20729
0a687ee7097d 8026391: The Metachunk header wastes memory
stefank
parents: 20406
diff changeset
   204
  static MetaWord* allocate(ClassLoaderData* loader_data, size_t word_size,
46746
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46324
diff changeset
   205
                            MetaspaceObj::Type type, TRAPS);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   206
24457
0e20b36df5c4 8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents: 23854
diff changeset
   207
  static bool contains(const void* ptr);
46324
8764956ec928 8005165: Remove CPU-dependent code in self-patching vtables
iklam
parents: 42615
diff changeset
   208
  static bool contains_non_shared(const void* ptr);
24457
0e20b36df5c4 8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents: 23854
diff changeset
   209
17101
3a82a58d9aa9 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 16453
diff changeset
   210
  // Free empty virtualspaces
20081
e26536e86a5c 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 19989
diff changeset
   211
  static void purge(MetadataType mdtype);
17101
3a82a58d9aa9 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 16453
diff changeset
   212
  static void purge();
3a82a58d9aa9 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 16453
diff changeset
   213
20406
934f0b12daa9 8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents: 20306
diff changeset
   214
  static void report_metadata_oome(ClassLoaderData* loader_data, size_t word_size,
23469
0a4d02776968 8036701: Add trace event when a metaspace throws out of memory error
ehelin
parents: 23468
diff changeset
   215
                                   MetaspaceObj::Type type, MetadataType mdtype, TRAPS);
20406
934f0b12daa9 8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents: 20306
diff changeset
   216
23468
6bb416a59349 8036699: Add trace event when a metaspace allocation fails
ehelin
parents: 23465
diff changeset
   217
  static const char* metadata_type_name(Metaspace::MetadataType mdtype);
6bb416a59349 8036699: Add trace event when a metaspace allocation fails
ehelin
parents: 23465
diff changeset
   218
32397
d1ad9a7c4a41 8133984: print_compressed_class_space() is only defined in 64-bit VM
kvn
parents: 31335
diff changeset
   219
  static void print_compressed_class_space(outputStream* st, const char* requested_addr = 0) NOT_LP64({});
31335
60081f497e75 8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents: 30291
diff changeset
   220
46746
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46324
diff changeset
   221
  // Return TRUE only if UseCompressedClassPointers is True.
19319
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18025
diff changeset
   222
  static bool using_class_space() {
46746
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46324
diff changeset
   223
    return NOT_LP64(false) LP64_ONLY(UseCompressedClassPointers);
19319
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18025
diff changeset
   224
  }
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18025
diff changeset
   225
20306
f6805e2a0dd8 8025279: metaspace/flags/maxMetaspaceSize throws OOM: out of Compressed Klass space
mgerdin
parents: 20081
diff changeset
   226
  static bool is_class_space_allocation(MetadataType mdType) {
f6805e2a0dd8 8025279: metaspace/flags/maxMetaspaceSize throws OOM: out of Compressed Klass space
mgerdin
parents: 20081
diff changeset
   227
    return mdType == ClassType && using_class_space();
f6805e2a0dd8 8025279: metaspace/flags/maxMetaspaceSize throws OOM: out of Compressed Klass space
mgerdin
parents: 20081
diff changeset
   228
  }
21186
db851068711f 8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents: 20729
diff changeset
   229
55586
014c8cd323af 8227032: MetaspaceUtils::print_report crashes when called before initialization
stuefe
parents: 55576
diff changeset
   230
  static bool initialized() { return _initialized; }
014c8cd323af 8227032: MetaspaceUtils::print_report crashes when called before initialization
stuefe
parents: 55576
diff changeset
   231
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   232
};
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   233
49401
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   234
// Manages the metaspace portion belonging to a class loader
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   235
class ClassLoaderMetaspace : public CHeapObj<mtClass> {
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   236
  friend class CollectedHeap; // For expand_and_allocate()
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents: 50309
diff changeset
   237
  friend class ZCollectedHeap; // For expand_and_allocate()
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52014
diff changeset
   238
  friend class ShenandoahHeap; // For expand_and_allocate()
49401
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   239
  friend class Metaspace;
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   240
  friend class MetaspaceUtils;
50193
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents: 50119
diff changeset
   241
  friend class metaspace::PrintCLDMetaspaceInfoClosure;
49401
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   242
  friend class VM_CollectForMetadataAllocation; // For expand_and_allocate()
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   243
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   244
 private:
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   245
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   246
  void initialize(Mutex* lock, Metaspace::MetaspaceType type);
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   247
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   248
  // Initialize the first chunk for a Metaspace.  Used for
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   249
  // special cases such as the boot class loader, reflection
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   250
  // class loader and anonymous class loader.
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   251
  void initialize_first_chunk(Metaspace::MetaspaceType type, Metaspace::MetadataType mdtype);
50193
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents: 50119
diff changeset
   252
  metaspace::Metachunk* get_initialization_chunk(Metaspace::MetaspaceType type, Metaspace::MetadataType mdtype);
49401
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   253
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   254
  const Metaspace::MetaspaceType _space_type;
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   255
  Mutex* const  _lock;
50193
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents: 50119
diff changeset
   256
  metaspace::SpaceManager* _vsm;
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents: 50119
diff changeset
   257
  metaspace::SpaceManager* _class_vsm;
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   258
50193
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents: 50119
diff changeset
   259
  metaspace::SpaceManager* vsm() const { return _vsm; }
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents: 50119
diff changeset
   260
  metaspace::SpaceManager* class_vsm() const { return _class_vsm; }
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents: 50119
diff changeset
   261
  metaspace::SpaceManager* get_space_manager(Metaspace::MetadataType mdtype) {
49401
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   262
    assert(mdtype != Metaspace::MetadataTypeCount, "MetadaTypeCount can't be used as mdtype");
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   263
    return mdtype == Metaspace::ClassType ? class_vsm() : vsm();
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   264
  }
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   265
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   266
  Mutex* lock() const { return _lock; }
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   267
49401
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   268
  MetaWord* expand_and_allocate(size_t size, Metaspace::MetadataType mdtype);
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   269
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   270
  size_t class_chunk_size(size_t word_size);
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   271
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   272
  // Adds to the given statistic object. Must be locked with CLD metaspace lock.
50193
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents: 50119
diff changeset
   273
  void add_to_statistics_locked(metaspace::ClassLoaderMetaspaceStatistics* out) const;
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents: 50119
diff changeset
   274
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents: 50119
diff changeset
   275
  Metaspace::MetaspaceType space_type() const { return _space_type; }
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   276
49401
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   277
 public:
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   278
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   279
  ClassLoaderMetaspace(Mutex* lock, Metaspace::MetaspaceType type);
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   280
  ~ClassLoaderMetaspace();
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   281
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   282
  // Allocate space for metadata of type mdtype. This is space
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   283
  // within a Metachunk and is used by
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   284
  //   allocate(ClassLoaderData*, size_t, bool, MetadataType, TRAPS)
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   285
  MetaWord* allocate(size_t word_size, Metaspace::MetadataType mdtype);
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   286
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   287
  size_t allocated_blocks_bytes() const;
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   288
  size_t allocated_chunks_bytes() const;
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   289
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   290
  void deallocate(MetaWord* ptr, size_t byte_size, bool is_class);
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   291
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   292
  void print_on(outputStream* st) const;
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   293
  // Debugging support
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   294
  void verify();
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   295
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   296
  // Adds to the given statistic object. Will lock with CLD metaspace lock.
50193
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents: 50119
diff changeset
   297
  void add_to_statistics(metaspace::ClassLoaderMetaspaceStatistics* out) const;
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   298
49401
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   299
}; // ClassLoaderMetaspace
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   300
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   301
class MetaspaceUtils : AllStatic {
49401
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 49389
diff changeset
   302
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   303
  // Spacemanager updates running counters.
50193
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents: 50119
diff changeset
   304
  friend class metaspace::SpaceManager;
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   305
52014
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51444
diff changeset
   306
  // Special access for error reporting (checks without locks).
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51444
diff changeset
   307
  friend class oopDesc;
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51444
diff changeset
   308
  friend class Klass;
1aa9beac610e 8210754: print_location is not reliable enough (printing register info)
mdoerr
parents: 51444
diff changeset
   309
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   310
  // Running counters for statistics concerning in-use chunks.
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   311
  // Note: capacity = used + free + waste + overhead. Note that we do not
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   312
  // count free and waste. Their sum can be deduces from the three other values.
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   313
  // For more details, one should call print_report() from within a safe point.
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   314
  static size_t _capacity_words [Metaspace:: MetadataTypeCount];
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   315
  static size_t _overhead_words [Metaspace:: MetadataTypeCount];
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   316
  static volatile size_t _used_words [Metaspace:: MetadataTypeCount];
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   317
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   318
  // Atomically decrement or increment in-use statistic counters
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   319
  static void dec_capacity(Metaspace::MetadataType mdtype, size_t words);
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   320
  static void inc_capacity(Metaspace::MetadataType mdtype, size_t words);
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   321
  static void dec_used(Metaspace::MetadataType mdtype, size_t words);
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   322
  static void inc_used(Metaspace::MetadataType mdtype, size_t words);
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   323
  static void dec_overhead(Metaspace::MetadataType mdtype, size_t words);
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   324
  static void inc_overhead(Metaspace::MetadataType mdtype, size_t words);
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   325
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   326
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   327
  // Getters for the in-use counters.
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   328
  static size_t capacity_words(Metaspace::MetadataType mdtype)        { return _capacity_words[mdtype]; }
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   329
  static size_t used_words(Metaspace::MetadataType mdtype)            { return _used_words[mdtype]; }
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   330
  static size_t overhead_words(Metaspace::MetadataType mdtype)        { return _overhead_words[mdtype]; }
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   331
19988
2b100c528806 8023476: Metaspace capacity > reserved
ehelin
parents: 19979
diff changeset
   332
  static size_t free_chunks_total_words(Metaspace::MetadataType mdtype);
17109
90e6c31bbbe4 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 17101
diff changeset
   333
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   334
  // Helper for print_xx_report.
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   335
  static void print_vs(outputStream* out, size_t scale);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   336
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   337
public:
17109
90e6c31bbbe4 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 17101
diff changeset
   338
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   339
  // Collect used metaspace statistics. This involves walking the CLDG. The resulting
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   340
  // output will be the accumulated values for all live metaspaces.
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   341
  // Note: method does not do any locking.
50193
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents: 50119
diff changeset
   342
  static void collect_statistics(metaspace::ClassLoaderMetaspaceStatistics* out);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   343
17109
90e6c31bbbe4 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 17101
diff changeset
   344
  // Used by MetaspaceCounters
19988
2b100c528806 8023476: Metaspace capacity > reserved
ehelin
parents: 19979
diff changeset
   345
  static size_t free_chunks_total_words();
2b100c528806 8023476: Metaspace capacity > reserved
ehelin
parents: 19979
diff changeset
   346
  static size_t free_chunks_total_bytes();
2b100c528806 8023476: Metaspace capacity > reserved
ehelin
parents: 19979
diff changeset
   347
  static size_t free_chunks_total_bytes(Metaspace::MetadataType mdtype);
17109
90e6c31bbbe4 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 17101
diff changeset
   348
23854
50f7f89b34e0 8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents: 23470
diff changeset
   349
  static size_t capacity_words() {
50f7f89b34e0 8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents: 23470
diff changeset
   350
    return capacity_words(Metaspace::NonClassType) +
50f7f89b34e0 8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents: 23470
diff changeset
   351
           capacity_words(Metaspace::ClassType);
17628
481e0280aed3 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 17109
diff changeset
   352
  }
23854
50f7f89b34e0 8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents: 23470
diff changeset
   353
  static size_t capacity_bytes(Metaspace::MetadataType mdtype) {
50f7f89b34e0 8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents: 23470
diff changeset
   354
    return capacity_words(mdtype) * BytesPerWord;
17109
90e6c31bbbe4 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 17101
diff changeset
   355
  }
23854
50f7f89b34e0 8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents: 23470
diff changeset
   356
  static size_t capacity_bytes() {
50f7f89b34e0 8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents: 23470
diff changeset
   357
    return capacity_words() * BytesPerWord;
17109
90e6c31bbbe4 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 17101
diff changeset
   358
  }
90e6c31bbbe4 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 17101
diff changeset
   359
23854
50f7f89b34e0 8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents: 23470
diff changeset
   360
  static size_t used_words() {
50f7f89b34e0 8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents: 23470
diff changeset
   361
    return used_words(Metaspace::NonClassType) +
50f7f89b34e0 8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents: 23470
diff changeset
   362
           used_words(Metaspace::ClassType);
17628
481e0280aed3 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 17109
diff changeset
   363
  }
23854
50f7f89b34e0 8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents: 23470
diff changeset
   364
  static size_t used_bytes(Metaspace::MetadataType mdtype) {
50f7f89b34e0 8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents: 23470
diff changeset
   365
    return used_words(mdtype) * BytesPerWord;
17109
90e6c31bbbe4 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 17101
diff changeset
   366
  }
23854
50f7f89b34e0 8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents: 23470
diff changeset
   367
  static size_t used_bytes() {
50f7f89b34e0 8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents: 23470
diff changeset
   368
    return used_words() * BytesPerWord;
17109
90e6c31bbbe4 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 17101
diff changeset
   369
  }
90e6c31bbbe4 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 17101
diff changeset
   370
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   371
  // Space committed but yet unclaimed by any class loader.
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   372
  static size_t free_in_vs_bytes();
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   373
  static size_t free_in_vs_bytes(Metaspace::MetadataType mdtype);
17109
90e6c31bbbe4 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 17101
diff changeset
   374
19988
2b100c528806 8023476: Metaspace capacity > reserved
ehelin
parents: 19979
diff changeset
   375
  static size_t reserved_bytes(Metaspace::MetadataType mdtype);
2b100c528806 8023476: Metaspace capacity > reserved
ehelin
parents: 19979
diff changeset
   376
  static size_t reserved_bytes() {
2b100c528806 8023476: Metaspace capacity > reserved
ehelin
parents: 19979
diff changeset
   377
    return reserved_bytes(Metaspace::ClassType) +
2b100c528806 8023476: Metaspace capacity > reserved
ehelin
parents: 19979
diff changeset
   378
           reserved_bytes(Metaspace::NonClassType);
14842
4cdc5a61a7c2 8005108: NPG: MetaspaceAux::used_in_bytes(), capacity_in_bytes() and reserved_in_bytes() return inconsistent numbers
stefank
parents: 14590
diff changeset
   379
  }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   380
19989
0fc247fb59bc 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 19988
diff changeset
   381
  static size_t committed_bytes(Metaspace::MetadataType mdtype);
0fc247fb59bc 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 19988
diff changeset
   382
  static size_t committed_bytes() {
0fc247fb59bc 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 19988
diff changeset
   383
    return committed_bytes(Metaspace::ClassType) +
0fc247fb59bc 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 19988
diff changeset
   384
           committed_bytes(Metaspace::NonClassType);
0fc247fb59bc 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 19988
diff changeset
   385
  }
0fc247fb59bc 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 19988
diff changeset
   386
19988
2b100c528806 8023476: Metaspace capacity > reserved
ehelin
parents: 19979
diff changeset
   387
  static size_t min_chunk_size_words();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   388
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   389
  // Flags for print_report().
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   390
  enum ReportFlag {
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   391
    // Show usage by class loader.
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   392
    rf_show_loaders                 = (1 << 0),
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   393
    // Breaks report down by chunk type (small, medium, ...).
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   394
    rf_break_down_by_chunktype      = (1 << 1),
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   395
    // Breaks report down by space type (anonymous, reflection, ...).
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   396
    rf_break_down_by_spacetype      = (1 << 2),
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   397
    // Print details about the underlying virtual spaces.
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   398
    rf_show_vslist                  = (1 << 3),
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   399
    // Print metaspace map.
50309
37ebfe8bac7f 8203219: VM.metaspace jcmd should optionally show loaded classes for loaders
stuefe
parents: 50193
diff changeset
   400
    rf_show_vsmap                   = (1 << 4),
37ebfe8bac7f 8203219: VM.metaspace jcmd should optionally show loaded classes for loaders
stuefe
parents: 50193
diff changeset
   401
    // If show_loaders: show loaded classes for each loader.
37ebfe8bac7f 8203219: VM.metaspace jcmd should optionally show loaded classes for loaders
stuefe
parents: 50193
diff changeset
   402
    rf_show_classes                 = (1 << 5)
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   403
  };
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   404
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   405
  // This will print out a basic metaspace usage report but
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   406
  // unlike print_report() is guaranteed not to lock or to walk the CLDG.
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   407
  static void print_basic_report(outputStream* st, size_t scale);
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   408
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   409
  // Prints a report about the current metaspace state.
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   410
  // Optional parts can be enabled via flags.
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   411
  // Function will walk the CLDG and will lock the expand lock; if that is not
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   412
  // convenient, use print_basic_report() instead.
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   413
  static void print_report(outputStream* out, size_t scale = 0, int flags = 0);
47802
18dccdc438d7 8189688: NMT: Report per-class load metadata information
zgu
parents: 47599
diff changeset
   414
23470
ff2a7ea4225d 8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents: 23469
diff changeset
   415
  static bool has_chunk_free_list(Metaspace::MetadataType mdtype);
ff2a7ea4225d 8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents: 23469
diff changeset
   416
  static MetaspaceChunkFreeListSummary chunk_free_list_summary(Metaspace::MetadataType mdtype);
ff2a7ea4225d 8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents: 23469
diff changeset
   417
55576
4d193e40e7af 8223575: add subspace transitions to gc+metaspace=info log lines
tonyp
parents: 54842
diff changeset
   418
  // Log change in used metadata.
4d193e40e7af 8223575: add subspace transitions to gc+metaspace=info log lines
tonyp
parents: 54842
diff changeset
   419
  static void print_metaspace_change(const metaspace::MetaspaceSizesSnapshot& pre_meta_values);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   420
  static void print_on(outputStream * out);
47808
57752bd5d1b4 8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents: 47802
diff changeset
   421
57752bd5d1b4 8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents: 47802
diff changeset
   422
  // Prints an ASCII representation of the given space.
57752bd5d1b4 8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents: 47802
diff changeset
   423
  static void print_metaspace_map(outputStream* out, Metaspace::MetadataType mdtype);
57752bd5d1b4 8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents: 47802
diff changeset
   424
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   425
  static void dump(outputStream* out);
14474
4154f1817a75 7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents: 14123
diff changeset
   426
  static void verify_free_chunks();
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49449
diff changeset
   427
  // Check internal counters (capacity, used).
17109
90e6c31bbbe4 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 17101
diff changeset
   428
  static void verify_metrics();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   429
};
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   430
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   431
// Metaspace are deallocated when their class loader are GC'ed.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   432
// This class implements a policy for inducing GC's to recover
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   433
// Metaspaces.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   434
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   435
class MetaspaceGC : AllStatic {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   436
20406
934f0b12daa9 8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents: 20306
diff changeset
   437
  // The current high-water-mark for inducing a GC.
934f0b12daa9 8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents: 20306
diff changeset
   438
  // When committed memory of all metaspaces reaches this value,
934f0b12daa9 8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents: 20306
diff changeset
   439
  // a GC is induced and the value is increased. Size is in bytes.
50119
bf9177eac58d 8189271: Metaspace::_capacity_until_GC should be size_t
aharlap
parents: 49980
diff changeset
   440
  static volatile size_t _capacity_until_GC;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   441
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   442
  // For a CMS collection, signal that a concurrent collection should
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   443
  // be started.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   444
  static bool _should_concurrent_collect;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   445
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   446
  static uint _shrink_factor;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   447
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   448
  static size_t shrink_factor() { return _shrink_factor; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   449
  void set_shrink_factor(uint v) { _shrink_factor = v; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   450
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   451
 public:
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   452
24847
37c354b113fe 8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents: 24457
diff changeset
   453
  static void initialize();
37c354b113fe 8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents: 24457
diff changeset
   454
  static void post_initialize();
20406
934f0b12daa9 8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents: 20306
diff changeset
   455
934f0b12daa9 8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents: 20306
diff changeset
   456
  static size_t capacity_until_GC();
26938
e0b35f8104a7 8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents: 26934
diff changeset
   457
  static bool inc_capacity_until_GC(size_t v,
e0b35f8104a7 8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents: 26934
diff changeset
   458
                                    size_t* new_cap_until_GC = NULL,
53602
d1282cd2c1fc 8217432: MetaspaceGC::_capacity_until_GC exceeds MaxMetaspaceSize
ysuenaga
parents: 53547
diff changeset
   459
                                    size_t* old_cap_until_GC = NULL,
d1282cd2c1fc 8217432: MetaspaceGC::_capacity_until_GC exceeds MaxMetaspaceSize
ysuenaga
parents: 53547
diff changeset
   460
                                    bool* can_retry = NULL);
20406
934f0b12daa9 8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents: 20306
diff changeset
   461
  static size_t dec_capacity_until_GC(size_t v);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   462
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   463
  static bool should_concurrent_collect() { return _should_concurrent_collect; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   464
  static void set_should_concurrent_collect(bool v) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   465
    _should_concurrent_collect = v;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   466
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   467
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   468
  // The amount to increase the high-water-mark (_capacity_until_GC)
20406
934f0b12daa9 8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents: 20306
diff changeset
   469
  static size_t delta_capacity_until_GC(size_t bytes);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   470
20406
934f0b12daa9 8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents: 20306
diff changeset
   471
  // Tells if we have can expand metaspace without hitting set limits.
934f0b12daa9 8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents: 20306
diff changeset
   472
  static bool can_expand(size_t words, bool is_class);
934f0b12daa9 8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents: 20306
diff changeset
   473
934f0b12daa9 8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents: 20306
diff changeset
   474
  // Returns amount that we can expand without hitting a GC,
934f0b12daa9 8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents: 20306
diff changeset
   475
  // measured in words.
934f0b12daa9 8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents: 20306
diff changeset
   476
  static size_t allowed_expansion();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   477
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   478
  // Calculate the new high-water mark at which to induce
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   479
  // a GC.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   480
  static void compute_new_size();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   481
};
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   482
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52925
diff changeset
   483
#endif // SHARE_MEMORY_METASPACE_HPP