author | stuefe |
Tue, 13 Mar 2018 20:06:34 +0100 | |
changeset 49386 | d89e98d85841 |
parent 49372 | 3bb8b00832d0 |
child 49389 | 9ef2eee8ca7c |
permissions | -rw-r--r-- |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1 |
/* |
48794
ea0d0781c63c
8178351: Simplify MetaspaceShared::is_in_shared_space and MetaspaceObj::is_shared
iklam
parents:
48387
diff
changeset
|
2 |
* Copyright (c) 2011, 2018, 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 |
*/ |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
24 |
#include "precompiled.hpp" |
42650 | 25 |
#include "aot/aotLoader.hpp" |
30764 | 26 |
#include "gc/shared/collectedHeap.hpp" |
27 |
#include "gc/shared/collectorPolicy.hpp" |
|
28 |
#include "gc/shared/gcLocker.hpp" |
|
35061 | 29 |
#include "logging/log.hpp" |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46674
diff
changeset
|
30 |
#include "logging/logStream.hpp" |
20081
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
31 |
#include "memory/allocation.hpp" |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
32 |
#include "memory/binaryTreeDictionary.hpp" |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
33 |
#include "memory/filemap.hpp" |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
34 |
#include "memory/freeList.hpp" |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
35 |
#include "memory/metachunk.hpp" |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
36 |
#include "memory/metaspace.hpp" |
23465
14790e4d53ec
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
22884
diff
changeset
|
37 |
#include "memory/metaspaceGCThresholdUpdater.hpp" |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
38 |
#include "memory/metaspaceShared.hpp" |
23465
14790e4d53ec
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
22884
diff
changeset
|
39 |
#include "memory/metaspaceTracer.hpp" |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
40 |
#include "memory/resourceArea.hpp" |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
41 |
#include "memory/universe.hpp" |
40655
9f644073d3a0
8157907: Incorrect inclusion of atomic.hpp instead of atomic.inline.hpp
dholmes
parents:
39986
diff
changeset
|
42 |
#include "runtime/atomic.hpp" |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
43 |
#include "runtime/globals.hpp" |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
44 |
#include "runtime/init.hpp" |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
45 |
#include "runtime/java.hpp" |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
46 |
#include "runtime/mutex.hpp" |
24351
61b33cc6d3cf
8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents:
23854
diff
changeset
|
47 |
#include "runtime/orderAccess.inline.hpp" |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
48 |
#include "services/memTracker.hpp" |
20407
68e215ce8944
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
20406
diff
changeset
|
49 |
#include "services/memoryService.hpp" |
46625 | 50 |
#include "utilities/align.hpp" |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
51 |
#include "utilities/copy.hpp" |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
52 |
#include "utilities/debug.hpp" |
27683
1d5707553fff
8064580: Move INCLUDE_CDS include section to the end of the include list
stefank
parents:
27404
diff
changeset
|
53 |
#include "utilities/macros.hpp" |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
54 |
|
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
55 |
typedef BinaryTreeDictionary<Metablock, FreeList<Metablock> > BlockTreeDictionary; |
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
56 |
typedef BinaryTreeDictionary<Metachunk, FreeList<Metachunk> > ChunkTreeDictionary; |
20729 | 57 |
|
58 |
// Set this constant to enable slow integrity checking of the free chunk lists |
|
14474
4154f1817a75
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
14123
diff
changeset
|
59 |
const bool metaspace_slow_verify = false; |
4154f1817a75
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
14123
diff
changeset
|
60 |
|
49365 | 61 |
// Helper function that does a bunch of checks for a chunk. |
62 |
DEBUG_ONLY(static void do_verify_chunk(Metachunk* chunk);) |
|
63 |
||
64 |
// Given a Metachunk, update its in-use information (both in the |
|
65 |
// chunk and the occupancy map). |
|
66 |
static void do_update_in_use_info_for_chunk(Metachunk* chunk, bool inuse); |
|
67 |
||
19984
ba033739c8fe
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
19979
diff
changeset
|
68 |
size_t const allocation_from_dictionary_limit = 4 * K; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
69 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
70 |
MetaWord* last_allocated = 0; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
71 |
|
21188
d053e4e8f901
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
21186
diff
changeset
|
72 |
size_t Metaspace::_compressed_class_space_size; |
23465
14790e4d53ec
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
22884
diff
changeset
|
73 |
const MetaspaceTracer* Metaspace::_tracer = NULL; |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
74 |
|
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
75 |
DEBUG_ONLY(bool Metaspace::_frozen = false;) |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
76 |
|
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
77 |
enum ChunkSizes { // in words. |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
78 |
ClassSpecializedChunk = 128, |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
79 |
SpecializedChunk = 128, |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
80 |
ClassSmallChunk = 256, |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
81 |
SmallChunk = 512, |
18491
dd63ba6b0ee4
8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents:
17858
diff
changeset
|
82 |
ClassMediumChunk = 4 * K, |
21112
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
83 |
MediumChunk = 8 * K |
13728
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 |
|
49365 | 86 |
// Returns size of this chunk type. |
87 |
size_t get_size_for_nonhumongous_chunktype(ChunkIndex chunktype, bool is_class) { |
|
88 |
assert(is_valid_nonhumongous_chunktype(chunktype), "invalid chunk type."); |
|
89 |
size_t size = 0; |
|
90 |
if (is_class) { |
|
91 |
switch(chunktype) { |
|
92 |
case SpecializedIndex: size = ClassSpecializedChunk; break; |
|
93 |
case SmallIndex: size = ClassSmallChunk; break; |
|
94 |
case MediumIndex: size = ClassMediumChunk; break; |
|
95 |
default: |
|
96 |
ShouldNotReachHere(); |
|
97 |
} |
|
98 |
} else { |
|
99 |
switch(chunktype) { |
|
100 |
case SpecializedIndex: size = SpecializedChunk; break; |
|
101 |
case SmallIndex: size = SmallChunk; break; |
|
102 |
case MediumIndex: size = MediumChunk; break; |
|
103 |
default: |
|
104 |
ShouldNotReachHere(); |
|
105 |
} |
|
106 |
} |
|
107 |
return size; |
|
108 |
} |
|
109 |
||
110 |
ChunkIndex get_chunk_type_by_size(size_t size, bool is_class) { |
|
111 |
if (is_class) { |
|
112 |
if (size == ClassSpecializedChunk) { |
|
113 |
return SpecializedIndex; |
|
114 |
} else if (size == ClassSmallChunk) { |
|
115 |
return SmallIndex; |
|
116 |
} else if (size == ClassMediumChunk) { |
|
117 |
return MediumIndex; |
|
118 |
} else if (size > ClassMediumChunk) { |
|
119 |
assert(is_aligned(size, ClassSpecializedChunk), "Invalid chunk size"); |
|
120 |
return HumongousIndex; |
|
121 |
} |
|
122 |
} else { |
|
123 |
if (size == SpecializedChunk) { |
|
124 |
return SpecializedIndex; |
|
125 |
} else if (size == SmallChunk) { |
|
126 |
return SmallIndex; |
|
127 |
} else if (size == MediumChunk) { |
|
128 |
return MediumIndex; |
|
129 |
} else if (size > MediumChunk) { |
|
130 |
assert(is_aligned(size, SpecializedChunk), "Invalid chunk size"); |
|
131 |
return HumongousIndex; |
|
132 |
} |
|
133 |
} |
|
134 |
ShouldNotReachHere(); |
|
135 |
return (ChunkIndex)-1; |
|
136 |
} |
|
137 |
||
138 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
139 |
static ChunkIndex next_chunk_index(ChunkIndex i) { |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
140 |
assert(i < NumberOfInUseLists, "Out of bound"); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
141 |
return (ChunkIndex) (i+1); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
142 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
143 |
|
49365 | 144 |
static ChunkIndex prev_chunk_index(ChunkIndex i) { |
145 |
assert(i > ZeroIndex, "Out of bound"); |
|
146 |
return (ChunkIndex) (i-1); |
|
147 |
} |
|
148 |
||
47802
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
149 |
static const char* scale_unit(size_t scale) { |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
150 |
switch(scale) { |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
151 |
case 1: return "BYTES"; |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
152 |
case K: return "KB"; |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
153 |
case M: return "MB"; |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
154 |
case G: return "GB"; |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
155 |
default: |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
156 |
ShouldNotReachHere(); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
157 |
return NULL; |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
158 |
} |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
159 |
} |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
160 |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
161 |
volatile intptr_t MetaspaceGC::_capacity_until_GC = 0; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
162 |
uint MetaspaceGC::_shrink_factor = 0; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
163 |
bool MetaspaceGC::_should_concurrent_collect = false; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
164 |
|
16996
e699388c6dd8
8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents:
16439
diff
changeset
|
165 |
typedef class FreeList<Metachunk> ChunkList; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
166 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
167 |
// Manages the global free lists of chunks. |
20081
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
168 |
class ChunkManager : public CHeapObj<mtInternal> { |
21112
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
169 |
friend class TestVirtualSpaceNodeTest; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
170 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
171 |
// Free list of chunks of different sizes. |
17101 | 172 |
// SpecializedChunk |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
173 |
// SmallChunk |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
174 |
// MediumChunk |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
175 |
ChunkList _free_chunks[NumberOfFreeLists]; |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
176 |
|
49365 | 177 |
// Whether or not this is the class chunkmanager. |
178 |
const bool _is_class; |
|
179 |
||
46333
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
180 |
// Return non-humongous chunk list by its index. |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
181 |
ChunkList* free_chunks(ChunkIndex index); |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
182 |
|
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
183 |
// Returns non-humongous chunk list for the given chunk word size. |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
184 |
ChunkList* find_free_chunks_list(size_t word_size); |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
185 |
|
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
186 |
// HumongousChunk |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
187 |
ChunkTreeDictionary _humongous_dictionary; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
188 |
|
46333
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
189 |
// Returns the humongous chunk dictionary. |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
190 |
ChunkTreeDictionary* humongous_dictionary() { |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
191 |
return &_humongous_dictionary; |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
192 |
} |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
193 |
|
46360
c753322134b0
8170520: Make Metaspace ChunkManager counters non-atomic
stuefe
parents:
46333
diff
changeset
|
194 |
// Size, in metaspace words, of all chunks managed by this ChunkManager |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
195 |
size_t _free_chunks_total; |
46360
c753322134b0
8170520: Make Metaspace ChunkManager counters non-atomic
stuefe
parents:
46333
diff
changeset
|
196 |
// Number of chunks in this ChunkManager |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
197 |
size_t _free_chunks_count; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
198 |
|
46360
c753322134b0
8170520: Make Metaspace ChunkManager counters non-atomic
stuefe
parents:
46333
diff
changeset
|
199 |
// Update counters after a chunk was added or removed removed. |
c753322134b0
8170520: Make Metaspace ChunkManager counters non-atomic
stuefe
parents:
46333
diff
changeset
|
200 |
void account_for_added_chunk(const Metachunk* c); |
c753322134b0
8170520: Make Metaspace ChunkManager counters non-atomic
stuefe
parents:
46333
diff
changeset
|
201 |
void account_for_removed_chunk(const Metachunk* c); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
202 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
203 |
// Debug support |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
204 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
205 |
size_t sum_free_chunks(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
206 |
size_t sum_free_chunks_count(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
207 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
208 |
void locked_verify_free_chunks_total(); |
14474
4154f1817a75
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
14123
diff
changeset
|
209 |
void slow_locked_verify_free_chunks_total() { |
4154f1817a75
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
14123
diff
changeset
|
210 |
if (metaspace_slow_verify) { |
4154f1817a75
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
14123
diff
changeset
|
211 |
locked_verify_free_chunks_total(); |
4154f1817a75
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
14123
diff
changeset
|
212 |
} |
4154f1817a75
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
14123
diff
changeset
|
213 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
214 |
void locked_verify_free_chunks_count(); |
14474
4154f1817a75
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
14123
diff
changeset
|
215 |
void slow_locked_verify_free_chunks_count() { |
4154f1817a75
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
14123
diff
changeset
|
216 |
if (metaspace_slow_verify) { |
4154f1817a75
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
14123
diff
changeset
|
217 |
locked_verify_free_chunks_count(); |
4154f1817a75
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
14123
diff
changeset
|
218 |
} |
4154f1817a75
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
14123
diff
changeset
|
219 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
220 |
void verify_free_chunks_count(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
221 |
|
49365 | 222 |
// Given a pointer to a chunk, attempts to merge it with neighboring |
223 |
// free chunks to form a bigger chunk. Returns true if successful. |
|
224 |
bool attempt_to_coalesce_around_chunk(Metachunk* chunk, ChunkIndex target_chunk_type); |
|
225 |
||
226 |
// Helper for chunk merging: |
|
227 |
// Given an address range with 1-n chunks which are all supposed to be |
|
228 |
// free and hence currently managed by this ChunkManager, remove them |
|
229 |
// from this ChunkManager and mark them as invalid. |
|
230 |
// - This does not correct the occupancy map. |
|
231 |
// - This does not adjust the counters in ChunkManager. |
|
232 |
// - Does not adjust container count counter in containing VirtualSpaceNode. |
|
233 |
// Returns number of chunks removed. |
|
234 |
int remove_chunks_in_area(MetaWord* p, size_t word_size); |
|
235 |
||
236 |
// Helper for chunk splitting: given a target chunk size and a larger free chunk, |
|
237 |
// split up the larger chunk into n smaller chunks, at least one of which should be |
|
238 |
// the target chunk of target chunk size. The smaller chunks, including the target |
|
239 |
// chunk, are returned to the freelist. The pointer to the target chunk is returned. |
|
240 |
// Note that this chunk is supposed to be removed from the freelist right away. |
|
241 |
Metachunk* split_chunk(size_t target_chunk_word_size, Metachunk* chunk); |
|
242 |
||
243 |
public: |
|
244 |
||
46709
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
245 |
struct ChunkManagerStatistics { |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
246 |
size_t num_by_type[NumberOfFreeLists]; |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
247 |
size_t single_size_by_type[NumberOfFreeLists]; |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
248 |
size_t total_size_by_type[NumberOfFreeLists]; |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
249 |
size_t num_humongous_chunks; |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
250 |
size_t total_size_humongous_chunks; |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
251 |
}; |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
252 |
|
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
253 |
void locked_get_statistics(ChunkManagerStatistics* stat) const; |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
254 |
void get_statistics(ChunkManagerStatistics* stat) const; |
47802
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
255 |
static void print_statistics(const ChunkManagerStatistics* stat, outputStream* out, size_t scale); |
46709
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
256 |
|
49365 | 257 |
|
258 |
ChunkManager(bool is_class) |
|
259 |
: _is_class(is_class), _free_chunks_total(0), _free_chunks_count(0) { |
|
260 |
_free_chunks[SpecializedIndex].set_size(get_size_for_nonhumongous_chunktype(SpecializedIndex, is_class)); |
|
261 |
_free_chunks[SmallIndex].set_size(get_size_for_nonhumongous_chunktype(SmallIndex, is_class)); |
|
262 |
_free_chunks[MediumIndex].set_size(get_size_for_nonhumongous_chunktype(MediumIndex, is_class)); |
|
263 |
} |
|
264 |
||
265 |
// Add or delete (return) a chunk to the global freelist. |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
266 |
Metachunk* chunk_freelist_allocate(size_t word_size); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
267 |
|
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
268 |
// Map a size to a list index assuming that there are lists |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
269 |
// for special, small, medium, and humongous chunks. |
42621
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
270 |
ChunkIndex list_index(size_t size); |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
271 |
|
46333
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
272 |
// Map a given index to the chunk size. |
46709
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
273 |
size_t size_by_index(ChunkIndex index) const; |
46333
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
274 |
|
49365 | 275 |
bool is_class() const { return _is_class; } |
276 |
||
277 |
// Convenience accessors. |
|
278 |
size_t medium_chunk_word_size() const { return size_by_index(MediumIndex); } |
|
279 |
size_t small_chunk_word_size() const { return size_by_index(SmallIndex); } |
|
280 |
size_t specialized_chunk_word_size() const { return size_by_index(SpecializedIndex); } |
|
281 |
||
46333
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
282 |
// Take a chunk from the ChunkManager. The chunk is expected to be in |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
283 |
// the chunk manager (the freelist if non-humongous, the dictionary if |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
284 |
// humongous). |
17101 | 285 |
void remove_chunk(Metachunk* chunk); |
286 |
||
46333
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
287 |
// Return a single chunk of type index to the ChunkManager. |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
288 |
void return_single_chunk(ChunkIndex index, Metachunk* chunk); |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
289 |
|
16996
e699388c6dd8
8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents:
16439
diff
changeset
|
290 |
// Add the simple linked list of chunks to the freelist of chunks |
e699388c6dd8
8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents:
16439
diff
changeset
|
291 |
// of type index. |
46333
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
292 |
void return_chunk_list(ChunkIndex index, Metachunk* chunk); |
16996
e699388c6dd8
8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents:
16439
diff
changeset
|
293 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
294 |
// Total of the space in the free chunks list |
19988 | 295 |
size_t free_chunks_total_words(); |
296 |
size_t free_chunks_total_bytes(); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
297 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
298 |
// Number of chunks in the free chunks list |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
299 |
size_t free_chunks_count(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
300 |
|
20733
8dead86921fe
8026715: Remove the MetaDataDeallocateALot develop flag
stefank
parents:
20729
diff
changeset
|
301 |
// Remove from a list by size. Selects list based on size of chunk. |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
302 |
Metachunk* free_chunks_get(size_t chunk_word_size); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
303 |
|
23470
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
304 |
#define index_bounds_check(index) \ |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
305 |
assert(index == SpecializedIndex || \ |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
306 |
index == SmallIndex || \ |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
307 |
index == MediumIndex || \ |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
308 |
index == HumongousIndex, "Bad index: %d", (int) index) |
23470
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
309 |
|
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
310 |
size_t num_free_chunks(ChunkIndex index) const { |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
311 |
index_bounds_check(index); |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
312 |
|
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
313 |
if (index == HumongousIndex) { |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
314 |
return _humongous_dictionary.total_free_blocks(); |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
315 |
} |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
316 |
|
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
317 |
ssize_t count = _free_chunks[index].count(); |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
318 |
return count == -1 ? 0 : (size_t) count; |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
319 |
} |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
320 |
|
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
321 |
size_t size_free_chunks_in_bytes(ChunkIndex index) const { |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
322 |
index_bounds_check(index); |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
323 |
|
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
324 |
size_t word_size = 0; |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
325 |
if (index == HumongousIndex) { |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
326 |
word_size = _humongous_dictionary.total_size(); |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
327 |
} else { |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
328 |
const size_t size_per_chunk_in_words = _free_chunks[index].size(); |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
329 |
word_size = size_per_chunk_in_words * num_free_chunks(index); |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
330 |
} |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
331 |
|
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
332 |
return word_size * BytesPerWord; |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
333 |
} |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
334 |
|
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
335 |
MetaspaceChunkFreeListSummary chunk_free_list_summary() const { |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
336 |
return MetaspaceChunkFreeListSummary(num_free_chunks(SpecializedIndex), |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
337 |
num_free_chunks(SmallIndex), |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
338 |
num_free_chunks(MediumIndex), |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
339 |
num_free_chunks(HumongousIndex), |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
340 |
size_free_chunks_in_bytes(SpecializedIndex), |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
341 |
size_free_chunks_in_bytes(SmallIndex), |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
342 |
size_free_chunks_in_bytes(MediumIndex), |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
343 |
size_free_chunks_in_bytes(HumongousIndex)); |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
344 |
} |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
345 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
346 |
// Debug support |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
347 |
void verify(); |
14474
4154f1817a75
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
14123
diff
changeset
|
348 |
void slow_verify() { |
4154f1817a75
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
14123
diff
changeset
|
349 |
if (metaspace_slow_verify) { |
4154f1817a75
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
14123
diff
changeset
|
350 |
verify(); |
4154f1817a75
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
14123
diff
changeset
|
351 |
} |
4154f1817a75
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
14123
diff
changeset
|
352 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
353 |
void locked_verify(); |
14474
4154f1817a75
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
14123
diff
changeset
|
354 |
void slow_locked_verify() { |
4154f1817a75
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
14123
diff
changeset
|
355 |
if (metaspace_slow_verify) { |
4154f1817a75
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
14123
diff
changeset
|
356 |
locked_verify(); |
4154f1817a75
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
14123
diff
changeset
|
357 |
} |
4154f1817a75
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
14123
diff
changeset
|
358 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
359 |
void verify_free_chunks_total(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
360 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
361 |
void locked_print_free_chunks(outputStream* st); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
362 |
void locked_print_sum_free_chunks(outputStream* st); |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
363 |
|
20081
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
364 |
void print_on(outputStream* st) const; |
46709
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
365 |
|
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
366 |
// Prints composition for both non-class and (if available) |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
367 |
// class chunk manager. |
47802
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
368 |
static void print_all_chunkmanagers(outputStream* out, size_t scale = 1); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
369 |
}; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
370 |
|
41727
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
371 |
class SmallBlocks : public CHeapObj<mtClass> { |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
372 |
const static uint _small_block_max_size = sizeof(TreeChunk<Metablock, FreeList<Metablock> >)/HeapWordSize; |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
373 |
const static uint _small_block_min_size = sizeof(Metablock)/HeapWordSize; |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
374 |
|
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
375 |
private: |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
376 |
FreeList<Metablock> _small_lists[_small_block_max_size - _small_block_min_size]; |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
377 |
|
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
378 |
FreeList<Metablock>& list_at(size_t word_size) { |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
379 |
assert(word_size >= _small_block_min_size, "There are no metaspace objects less than %u words", _small_block_min_size); |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
380 |
return _small_lists[word_size - _small_block_min_size]; |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
381 |
} |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
382 |
|
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
383 |
public: |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
384 |
SmallBlocks() { |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
385 |
for (uint i = _small_block_min_size; i < _small_block_max_size; i++) { |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
386 |
uint k = i - _small_block_min_size; |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
387 |
_small_lists[k].set_size(i); |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
388 |
} |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
389 |
} |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
390 |
|
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
391 |
size_t total_size() const { |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
392 |
size_t result = 0; |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
393 |
for (uint i = _small_block_min_size; i < _small_block_max_size; i++) { |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
394 |
uint k = i - _small_block_min_size; |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
395 |
result = result + _small_lists[k].count() * _small_lists[k].size(); |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
396 |
} |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
397 |
return result; |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
398 |
} |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
399 |
|
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
400 |
static uint small_block_max_size() { return _small_block_max_size; } |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
401 |
static uint small_block_min_size() { return _small_block_min_size; } |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
402 |
|
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
403 |
MetaWord* get_block(size_t word_size) { |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
404 |
if (list_at(word_size).count() > 0) { |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
405 |
MetaWord* new_block = (MetaWord*) list_at(word_size).get_chunk_at_head(); |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
406 |
return new_block; |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
407 |
} else { |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
408 |
return NULL; |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
409 |
} |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
410 |
} |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
411 |
void return_block(Metablock* free_chunk, size_t word_size) { |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
412 |
list_at(word_size).return_chunk_at_head(free_chunk, false); |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
413 |
assert(list_at(word_size).count() > 0, "Should have a chunk"); |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
414 |
} |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
415 |
|
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
416 |
void print_on(outputStream* st) const { |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
417 |
st->print_cr("SmallBlocks:"); |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
418 |
for (uint i = _small_block_min_size; i < _small_block_max_size; i++) { |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
419 |
uint k = i - _small_block_min_size; |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
420 |
st->print_cr("small_lists size " SIZE_FORMAT " count " SIZE_FORMAT, _small_lists[k].size(), _small_lists[k].count()); |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
421 |
} |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
422 |
} |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
423 |
}; |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
424 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
425 |
// Used to manage the free list of Metablocks (a block corresponds |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
426 |
// to the allocation of a quantum of metadata). |
41727
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
427 |
class BlockFreelist : public CHeapObj<mtClass> { |
30580
394471b86a83
8079091: Remove dictionary NULL check on common path of BlockFreeList methods
jwha
parents:
29806
diff
changeset
|
428 |
BlockTreeDictionary* const _dictionary; |
41727
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
429 |
SmallBlocks* _small_blocks; |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
430 |
|
19984
ba033739c8fe
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
19979
diff
changeset
|
431 |
// Only allocate and split from freelist if the size of the allocation |
ba033739c8fe
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
19979
diff
changeset
|
432 |
// is at least 1/4th the size of the available block. |
ba033739c8fe
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
19979
diff
changeset
|
433 |
const static int WasteMultiplier = 4; |
ba033739c8fe
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
19979
diff
changeset
|
434 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
435 |
// Accessors |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
436 |
BlockTreeDictionary* dictionary() const { return _dictionary; } |
41727
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
437 |
SmallBlocks* small_blocks() { |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
438 |
if (_small_blocks == NULL) { |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
439 |
_small_blocks = new SmallBlocks(); |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
440 |
} |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
441 |
return _small_blocks; |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
442 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
443 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
444 |
public: |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
445 |
BlockFreelist(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
446 |
~BlockFreelist(); |
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 |
// Get and return a block to the free list |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
449 |
MetaWord* get_block(size_t word_size); |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
450 |
void return_block(MetaWord* p, size_t word_size); |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
451 |
|
41727
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
452 |
size_t total_size() const { |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
453 |
size_t result = dictionary()->total_size(); |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
454 |
if (_small_blocks != NULL) { |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
455 |
result = result + _small_blocks->total_size(); |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
456 |
} |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
457 |
return result; |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
458 |
} |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
459 |
|
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
460 |
static size_t min_dictionary_size() { return TreeChunk<Metablock, FreeList<Metablock> >::min_size(); } |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
461 |
void print_on(outputStream* st) const; |
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 |
|
49365 | 464 |
// Helper for Occupancy Bitmap. A type trait to give an all-bits-are-one-unsigned constant. |
465 |
template <typename T> struct all_ones { static const T value; }; |
|
466 |
template <> struct all_ones <uint64_t> { static const uint64_t value = 0xFFFFFFFFFFFFFFFFULL; }; |
|
467 |
template <> struct all_ones <uint32_t> { static const uint32_t value = 0xFFFFFFFF; }; |
|
468 |
||
469 |
// The OccupancyMap is a bitmap which, for a given VirtualSpaceNode, |
|
470 |
// keeps information about |
|
471 |
// - where a chunk starts |
|
472 |
// - whether a chunk is in-use or free |
|
473 |
// A bit in this bitmap represents one range of memory in the smallest |
|
474 |
// chunk size (SpecializedChunk or ClassSpecializedChunk). |
|
475 |
class OccupancyMap : public CHeapObj<mtInternal> { |
|
476 |
||
477 |
// The address range this map covers. |
|
478 |
const MetaWord* const _reference_address; |
|
479 |
const size_t _word_size; |
|
480 |
||
481 |
// The word size of a specialized chunk, aka the number of words one |
|
482 |
// bit in this map represents. |
|
483 |
const size_t _smallest_chunk_word_size; |
|
484 |
||
485 |
// map data |
|
486 |
// Data are organized in two bit layers: |
|
487 |
// The first layer is the chunk-start-map. Here, a bit is set to mark |
|
488 |
// the corresponding region as the head of a chunk. |
|
489 |
// The second layer is the in-use-map. Here, a set bit indicates that |
|
490 |
// the corresponding belongs to a chunk which is in use. |
|
491 |
uint8_t* _map[2]; |
|
492 |
||
493 |
enum { layer_chunk_start_map = 0, layer_in_use_map = 1 }; |
|
494 |
||
495 |
// length, in bytes, of bitmap data |
|
496 |
size_t _map_size; |
|
497 |
||
498 |
// Returns true if bit at position pos at bit-layer layer is set. |
|
499 |
bool get_bit_at_position(unsigned pos, unsigned layer) const { |
|
500 |
assert(layer == 0 || layer == 1, "Invalid layer %d", layer); |
|
501 |
const unsigned byteoffset = pos / 8; |
|
502 |
assert(byteoffset < _map_size, |
|
503 |
"invalid byte offset (%u), map size is " SIZE_FORMAT ".", byteoffset, _map_size); |
|
504 |
const unsigned mask = 1 << (pos % 8); |
|
505 |
return (_map[layer][byteoffset] & mask) > 0; |
|
506 |
} |
|
507 |
||
508 |
// Changes bit at position pos at bit-layer layer to value v. |
|
509 |
void set_bit_at_position(unsigned pos, unsigned layer, bool v) { |
|
510 |
assert(layer == 0 || layer == 1, "Invalid layer %d", layer); |
|
511 |
const unsigned byteoffset = pos / 8; |
|
512 |
assert(byteoffset < _map_size, |
|
513 |
"invalid byte offset (%u), map size is " SIZE_FORMAT ".", byteoffset, _map_size); |
|
514 |
const unsigned mask = 1 << (pos % 8); |
|
515 |
if (v) { |
|
516 |
_map[layer][byteoffset] |= mask; |
|
517 |
} else { |
|
518 |
_map[layer][byteoffset] &= ~mask; |
|
519 |
} |
|
520 |
} |
|
521 |
||
522 |
// Optimized case of is_any_bit_set_in_region for 32/64bit aligned access: |
|
523 |
// pos is 32/64 aligned and num_bits is 32/64. |
|
524 |
// This is the typical case when coalescing to medium chunks, whose size is |
|
525 |
// 32 or 64 times the specialized chunk size (depending on class or non class |
|
526 |
// case), so they occupy 64 bits which should be 64bit aligned, because |
|
527 |
// chunks are chunk-size aligned. |
|
528 |
template <typename T> |
|
529 |
bool is_any_bit_set_in_region_3264(unsigned pos, unsigned num_bits, unsigned layer) const { |
|
530 |
assert(_map_size > 0, "not initialized"); |
|
531 |
assert(layer == 0 || layer == 1, "Invalid layer %d.", layer); |
|
532 |
assert(pos % (sizeof(T) * 8) == 0, "Bit position must be aligned (%u).", pos); |
|
533 |
assert(num_bits == (sizeof(T) * 8), "Number of bits incorrect (%u).", num_bits); |
|
534 |
const size_t byteoffset = pos / 8; |
|
535 |
assert(byteoffset <= (_map_size - sizeof(T)), |
|
536 |
"Invalid byte offset (" SIZE_FORMAT "), map size is " SIZE_FORMAT ".", byteoffset, _map_size); |
|
537 |
const T w = *(T*)(_map[layer] + byteoffset); |
|
538 |
return w > 0 ? true : false; |
|
539 |
} |
|
540 |
||
541 |
// Returns true if any bit in region [pos1, pos1 + num_bits) is set in bit-layer layer. |
|
542 |
bool is_any_bit_set_in_region(unsigned pos, unsigned num_bits, unsigned layer) const { |
|
543 |
if (pos % 32 == 0 && num_bits == 32) { |
|
544 |
return is_any_bit_set_in_region_3264<uint32_t>(pos, num_bits, layer); |
|
545 |
} else if (pos % 64 == 0 && num_bits == 64) { |
|
546 |
return is_any_bit_set_in_region_3264<uint64_t>(pos, num_bits, layer); |
|
547 |
} else { |
|
548 |
for (unsigned n = 0; n < num_bits; n ++) { |
|
549 |
if (get_bit_at_position(pos + n, layer)) { |
|
550 |
return true; |
|
551 |
} |
|
552 |
} |
|
553 |
} |
|
554 |
return false; |
|
555 |
} |
|
556 |
||
557 |
// Returns true if any bit in region [p, p+word_size) is set in bit-layer layer. |
|
558 |
bool is_any_bit_set_in_region(MetaWord* p, size_t word_size, unsigned layer) const { |
|
559 |
assert(word_size % _smallest_chunk_word_size == 0, |
|
560 |
"Region size " SIZE_FORMAT " not a multiple of smallest chunk size.", word_size); |
|
561 |
const unsigned pos = get_bitpos_for_address(p); |
|
562 |
const unsigned num_bits = (unsigned) (word_size / _smallest_chunk_word_size); |
|
563 |
return is_any_bit_set_in_region(pos, num_bits, layer); |
|
564 |
} |
|
565 |
||
566 |
// Optimized case of set_bits_of_region for 32/64bit aligned access: |
|
567 |
// pos is 32/64 aligned and num_bits is 32/64. |
|
568 |
// This is the typical case when coalescing to medium chunks, whose size |
|
569 |
// is 32 or 64 times the specialized chunk size (depending on class or non |
|
570 |
// class case), so they occupy 64 bits which should be 64bit aligned, |
|
571 |
// because chunks are chunk-size aligned. |
|
572 |
template <typename T> |
|
573 |
void set_bits_of_region_T(unsigned pos, unsigned num_bits, unsigned layer, bool v) { |
|
574 |
assert(pos % (sizeof(T) * 8) == 0, "Bit position must be aligned to %u (%u).", |
|
575 |
(unsigned)(sizeof(T) * 8), pos); |
|
576 |
assert(num_bits == (sizeof(T) * 8), "Number of bits incorrect (%u), expected %u.", |
|
577 |
num_bits, (unsigned)(sizeof(T) * 8)); |
|
578 |
const size_t byteoffset = pos / 8; |
|
579 |
assert(byteoffset <= (_map_size - sizeof(T)), |
|
580 |
"invalid byte offset (" SIZE_FORMAT "), map size is " SIZE_FORMAT ".", byteoffset, _map_size); |
|
581 |
T* const pw = (T*)(_map[layer] + byteoffset); |
|
582 |
*pw = v ? all_ones<T>::value : (T) 0; |
|
583 |
} |
|
584 |
||
585 |
// Set all bits in a region starting at pos to a value. |
|
586 |
void set_bits_of_region(unsigned pos, unsigned num_bits, unsigned layer, bool v) { |
|
587 |
assert(_map_size > 0, "not initialized"); |
|
588 |
assert(layer == 0 || layer == 1, "Invalid layer %d.", layer); |
|
589 |
if (pos % 32 == 0 && num_bits == 32) { |
|
590 |
set_bits_of_region_T<uint32_t>(pos, num_bits, layer, v); |
|
591 |
} else if (pos % 64 == 0 && num_bits == 64) { |
|
592 |
set_bits_of_region_T<uint64_t>(pos, num_bits, layer, v); |
|
593 |
} else { |
|
594 |
for (unsigned n = 0; n < num_bits; n ++) { |
|
595 |
set_bit_at_position(pos + n, layer, v); |
|
596 |
} |
|
597 |
} |
|
598 |
} |
|
599 |
||
600 |
// Helper: sets all bits in a region [p, p+word_size). |
|
601 |
void set_bits_of_region(MetaWord* p, size_t word_size, unsigned layer, bool v) { |
|
602 |
assert(word_size % _smallest_chunk_word_size == 0, |
|
603 |
"Region size " SIZE_FORMAT " not a multiple of smallest chunk size.", word_size); |
|
604 |
const unsigned pos = get_bitpos_for_address(p); |
|
605 |
const unsigned num_bits = (unsigned) (word_size / _smallest_chunk_word_size); |
|
606 |
set_bits_of_region(pos, num_bits, layer, v); |
|
607 |
} |
|
608 |
||
609 |
// Helper: given an address, return the bit position representing that address. |
|
610 |
unsigned get_bitpos_for_address(const MetaWord* p) const { |
|
611 |
assert(_reference_address != NULL, "not initialized"); |
|
612 |
assert(p >= _reference_address && p < _reference_address + _word_size, |
|
613 |
"Address %p out of range for occupancy map [%p..%p).", |
|
614 |
p, _reference_address, _reference_address + _word_size); |
|
615 |
assert(is_aligned(p, _smallest_chunk_word_size * sizeof(MetaWord)), |
|
616 |
"Address not aligned (%p).", p); |
|
617 |
const ptrdiff_t d = (p - _reference_address) / _smallest_chunk_word_size; |
|
618 |
assert(d >= 0 && (size_t)d < _map_size * 8, "Sanity."); |
|
619 |
return (unsigned) d; |
|
620 |
} |
|
621 |
||
622 |
public: |
|
623 |
||
624 |
OccupancyMap(const MetaWord* reference_address, size_t word_size, size_t smallest_chunk_word_size) : |
|
625 |
_reference_address(reference_address), _word_size(word_size), |
|
626 |
_smallest_chunk_word_size(smallest_chunk_word_size) { |
|
627 |
assert(reference_address != NULL, "invalid reference address"); |
|
628 |
assert(is_aligned(reference_address, smallest_chunk_word_size), |
|
629 |
"Reference address not aligned to smallest chunk size."); |
|
630 |
assert(is_aligned(word_size, smallest_chunk_word_size), |
|
631 |
"Word_size shall be a multiple of the smallest chunk size."); |
|
632 |
// Calculate bitmap size: one bit per smallest_chunk_word_size'd area. |
|
633 |
size_t num_bits = word_size / smallest_chunk_word_size; |
|
634 |
_map_size = (num_bits + 7) / 8; |
|
635 |
assert(_map_size * 8 >= num_bits, "sanity"); |
|
636 |
_map[0] = (uint8_t*) os::malloc(_map_size, mtInternal); |
|
637 |
_map[1] = (uint8_t*) os::malloc(_map_size, mtInternal); |
|
638 |
assert(_map[0] != NULL && _map[1] != NULL, "Occupancy Map: allocation failed."); |
|
639 |
memset(_map[1], 0, _map_size); |
|
640 |
memset(_map[0], 0, _map_size); |
|
641 |
// Sanity test: the first respectively last possible chunk start address in |
|
642 |
// the covered range shall map to the first and last bit in the bitmap. |
|
643 |
assert(get_bitpos_for_address(reference_address) == 0, |
|
644 |
"First chunk address in range must map to fist bit in bitmap."); |
|
645 |
assert(get_bitpos_for_address(reference_address + word_size - smallest_chunk_word_size) == num_bits - 1, |
|
646 |
"Last chunk address in range must map to last bit in bitmap."); |
|
647 |
} |
|
648 |
||
649 |
~OccupancyMap() { |
|
650 |
os::free(_map[0]); |
|
651 |
os::free(_map[1]); |
|
652 |
} |
|
653 |
||
654 |
// Returns true if at address x a chunk is starting. |
|
655 |
bool chunk_starts_at_address(MetaWord* p) const { |
|
656 |
const unsigned pos = get_bitpos_for_address(p); |
|
657 |
return get_bit_at_position(pos, layer_chunk_start_map); |
|
658 |
} |
|
659 |
||
660 |
void set_chunk_starts_at_address(MetaWord* p, bool v) { |
|
661 |
const unsigned pos = get_bitpos_for_address(p); |
|
662 |
set_bit_at_position(pos, layer_chunk_start_map, v); |
|
663 |
} |
|
664 |
||
665 |
// Removes all chunk-start-bits inside a region, typically as a |
|
666 |
// result of a chunk merge. |
|
667 |
void wipe_chunk_start_bits_in_region(MetaWord* p, size_t word_size) { |
|
668 |
set_bits_of_region(p, word_size, layer_chunk_start_map, false); |
|
669 |
} |
|
670 |
||
671 |
// Returns true if there are life (in use) chunks in the region limited |
|
672 |
// by [p, p+word_size). |
|
673 |
bool is_region_in_use(MetaWord* p, size_t word_size) const { |
|
674 |
return is_any_bit_set_in_region(p, word_size, layer_in_use_map); |
|
675 |
} |
|
676 |
||
677 |
// Marks the region starting at p with the size word_size as in use |
|
678 |
// or free, depending on v. |
|
679 |
void set_region_in_use(MetaWord* p, size_t word_size, bool v) { |
|
680 |
set_bits_of_region(p, word_size, layer_in_use_map, v); |
|
681 |
} |
|
682 |
||
683 |
#ifdef ASSERT |
|
684 |
// Verify occupancy map for the address range [from, to). |
|
685 |
// We need to tell it the address range, because the memory the |
|
686 |
// occupancy map is covering may not be fully comitted yet. |
|
687 |
void verify(MetaWord* from, MetaWord* to) { |
|
688 |
Metachunk* chunk = NULL; |
|
689 |
int nth_bit_for_chunk = 0; |
|
690 |
MetaWord* chunk_end = NULL; |
|
691 |
for (MetaWord* p = from; p < to; p += _smallest_chunk_word_size) { |
|
692 |
const unsigned pos = get_bitpos_for_address(p); |
|
693 |
// Check the chunk-starts-info: |
|
694 |
if (get_bit_at_position(pos, layer_chunk_start_map)) { |
|
695 |
// Chunk start marked in bitmap. |
|
696 |
chunk = (Metachunk*) p; |
|
697 |
if (chunk_end != NULL) { |
|
698 |
assert(chunk_end == p, "Unexpected chunk start found at %p (expected " |
|
699 |
"the next chunk to start at %p).", p, chunk_end); |
|
700 |
} |
|
701 |
assert(chunk->is_valid_sentinel(), "Invalid chunk at address %p.", p); |
|
702 |
if (chunk->get_chunk_type() != HumongousIndex) { |
|
703 |
guarantee(is_aligned(p, chunk->word_size()), "Chunk %p not aligned.", p); |
|
704 |
} |
|
705 |
chunk_end = p + chunk->word_size(); |
|
706 |
nth_bit_for_chunk = 0; |
|
707 |
assert(chunk_end <= to, "Chunk end overlaps test address range."); |
|
708 |
} else { |
|
709 |
// No chunk start marked in bitmap. |
|
710 |
assert(chunk != NULL, "Chunk should start at start of address range."); |
|
711 |
assert(p < chunk_end, "Did not find expected chunk start at %p.", p); |
|
712 |
nth_bit_for_chunk ++; |
|
713 |
} |
|
714 |
// Check the in-use-info: |
|
715 |
const bool in_use_bit = get_bit_at_position(pos, layer_in_use_map); |
|
716 |
if (in_use_bit) { |
|
717 |
assert(!chunk->is_tagged_free(), "Chunk %p: marked in-use in map but is free (bit %u).", |
|
718 |
chunk, nth_bit_for_chunk); |
|
719 |
} else { |
|
720 |
assert(chunk->is_tagged_free(), "Chunk %p: marked free in map but is in use (bit %u).", |
|
721 |
chunk, nth_bit_for_chunk); |
|
722 |
} |
|
723 |
} |
|
724 |
} |
|
725 |
||
726 |
// Verify that a given chunk is correctly accounted for in the bitmap. |
|
727 |
void verify_for_chunk(Metachunk* chunk) { |
|
728 |
assert(chunk_starts_at_address((MetaWord*) chunk), |
|
729 |
"No chunk start marked in map for chunk %p.", chunk); |
|
730 |
// For chunks larger than the minimal chunk size, no other chunk |
|
731 |
// must start in its area. |
|
732 |
if (chunk->word_size() > _smallest_chunk_word_size) { |
|
733 |
assert(!is_any_bit_set_in_region(((MetaWord*) chunk) + _smallest_chunk_word_size, |
|
734 |
chunk->word_size() - _smallest_chunk_word_size, layer_chunk_start_map), |
|
735 |
"No chunk must start within another chunk."); |
|
736 |
} |
|
737 |
if (!chunk->is_tagged_free()) { |
|
738 |
assert(is_region_in_use((MetaWord*)chunk, chunk->word_size()), |
|
739 |
"Chunk %p is in use but marked as free in map (%d %d).", |
|
740 |
chunk, chunk->get_chunk_type(), chunk->get_origin()); |
|
741 |
} else { |
|
742 |
assert(!is_region_in_use((MetaWord*)chunk, chunk->word_size()), |
|
743 |
"Chunk %p is free but marked as in-use in map (%d %d).", |
|
744 |
chunk, chunk->get_chunk_type(), chunk->get_origin()); |
|
745 |
} |
|
746 |
} |
|
747 |
||
748 |
#endif // ASSERT |
|
749 |
||
750 |
}; |
|
751 |
||
20729 | 752 |
// A VirtualSpaceList node. |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
753 |
class VirtualSpaceNode : public CHeapObj<mtClass> { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
754 |
friend class VirtualSpaceList; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
755 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
756 |
// Link to next VirtualSpaceNode |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
757 |
VirtualSpaceNode* _next; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
758 |
|
49365 | 759 |
// Whether this node is contained in class or metaspace. |
760 |
const bool _is_class; |
|
761 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
762 |
// total in the VirtualSpace |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
763 |
MemRegion _reserved; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
764 |
ReservedSpace _rs; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
765 |
VirtualSpace _virtual_space; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
766 |
MetaWord* _top; |
17101 | 767 |
// count of chunks contained in this VirtualSpace |
768 |
uintx _container_count; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
769 |
|
49365 | 770 |
OccupancyMap* _occupancy_map; |
771 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
772 |
// Convenience functions to access the _virtual_space |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
773 |
char* low() const { return virtual_space()->low(); } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
774 |
char* high() const { return virtual_space()->high(); } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
775 |
|
17101 | 776 |
// The first Metachunk will be allocated at the bottom of the |
777 |
// VirtualSpace |
|
778 |
Metachunk* first_chunk() { return (Metachunk*) bottom(); } |
|
779 |
||
21112
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
780 |
// Committed but unused space in the virtual space |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
781 |
size_t free_words_in_vs() const; |
49365 | 782 |
|
783 |
// True if this node belongs to class metaspace. |
|
784 |
bool is_class() const { return _is_class; } |
|
785 |
||
786 |
// Helper function for take_from_committed: allocate padding chunks |
|
787 |
// until top is at the given address. |
|
788 |
void allocate_padding_chunks_until_top_is_at(MetaWord* target_top); |
|
789 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
790 |
public: |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
791 |
|
49365 | 792 |
VirtualSpaceNode(bool is_class, size_t byte_size); |
793 |
VirtualSpaceNode(bool is_class, ReservedSpace rs) : |
|
794 |
_is_class(is_class), _top(NULL), _next(NULL), _rs(rs), _container_count(0), _occupancy_map(NULL) {} |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
795 |
~VirtualSpaceNode(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
796 |
|
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
797 |
// Convenience functions for logical bottom and end |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
798 |
MetaWord* bottom() const { return (MetaWord*) _virtual_space.low(); } |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
799 |
MetaWord* end() const { return (MetaWord*) _virtual_space.high(); } |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
800 |
|
49365 | 801 |
const OccupancyMap* occupancy_map() const { return _occupancy_map; } |
802 |
OccupancyMap* occupancy_map() { return _occupancy_map; } |
|
803 |
||
24457
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
804 |
bool contains(const void* ptr) { return ptr >= low() && ptr < high(); } |
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
805 |
|
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
806 |
size_t reserved_words() const { return _virtual_space.reserved_size() / BytesPerWord; } |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
807 |
size_t committed_words() const { return _virtual_space.actual_committed_size() / BytesPerWord; } |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
808 |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
809 |
bool is_pre_committed() const { return _virtual_space.special(); } |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
810 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
811 |
// address of next available space in _virtual_space; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
812 |
// Accessors |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
813 |
VirtualSpaceNode* next() { return _next; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
814 |
void set_next(VirtualSpaceNode* v) { _next = v; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
815 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
816 |
void set_reserved(MemRegion const v) { _reserved = v; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
817 |
void set_top(MetaWord* v) { _top = v; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
818 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
819 |
// Accessors |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
820 |
MemRegion* reserved() { return &_reserved; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
821 |
VirtualSpace* virtual_space() const { return (VirtualSpace*) &_virtual_space; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
822 |
|
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
823 |
// Returns true if "word_size" is available in the VirtualSpace |
22222
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
824 |
bool is_available(size_t word_size) { return word_size <= pointer_delta(end(), _top, sizeof(MetaWord)); } |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
825 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
826 |
MetaWord* top() const { return _top; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
827 |
void inc_top(size_t word_size) { _top += word_size; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
828 |
|
17101 | 829 |
uintx container_count() { return _container_count; } |
20081
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
830 |
void inc_container_count(); |
17101 | 831 |
void dec_container_count(); |
832 |
#ifdef ASSERT |
|
29806
64aa40385bdd
8076173: VirtualSpaceNode container_count() and container_count_slow() have different return types
david
parents:
29800
diff
changeset
|
833 |
uintx container_count_slow(); |
17101 | 834 |
void verify_container_count(); |
835 |
#endif |
|
836 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
837 |
// used and capacity in this single entry in the list |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
838 |
size_t used_words_in_vs() const; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
839 |
size_t capacity_words_in_vs() const; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
840 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
841 |
bool initialize(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
842 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
843 |
// get space from the virtual space |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
844 |
Metachunk* take_from_committed(size_t chunk_word_size); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
845 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
846 |
// Allocate a chunk from the virtual space and return it. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
847 |
Metachunk* get_chunk_vs(size_t chunk_word_size); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
848 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
849 |
// Expands/shrinks the committed space in a virtual space. Delegates |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
850 |
// to Virtualspace |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
851 |
bool expand_by(size_t min_words, size_t preferred_words); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
852 |
|
17101 | 853 |
// In preparation for deleting this node, remove all the chunks |
854 |
// in the node from any freelist. |
|
855 |
void purge(ChunkManager* chunk_manager); |
|
856 |
||
21112
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
857 |
// If an allocation doesn't fit in the current node a new node is created. |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
858 |
// Allocate chunks out of the remaining committed space in this node |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
859 |
// to avoid wasting that memory. |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
860 |
// This always adds up because all the chunk sizes are multiples of |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
861 |
// the smallest chunk size. |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
862 |
void retire(ChunkManager* chunk_manager); |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
863 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
864 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
865 |
void print_on(outputStream* st) const; |
47808
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
866 |
void print_map(outputStream* st, bool is_class) const; |
49365 | 867 |
|
868 |
// Debug support |
|
869 |
DEBUG_ONLY(void mangle();) |
|
870 |
// Verify counters, all chunks in this list node and the occupancy map. |
|
871 |
DEBUG_ONLY(void verify();) |
|
872 |
// Verify that all free chunks in this node are ideally merged |
|
873 |
// (there not should be multiple small chunks where a large chunk could exist.) |
|
874 |
DEBUG_ONLY(void verify_free_chunks_are_ideally_merged();) |
|
875 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
876 |
}; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
877 |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
878 |
#define assert_is_aligned(value, alignment) \ |
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
879 |
assert(is_aligned((value), (alignment)), \ |
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
880 |
SIZE_FORMAT_HEX " is not aligned to " \ |
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
881 |
SIZE_FORMAT, (size_t)(uintptr_t)value, (alignment)) |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
882 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
883 |
// Decide if large pages should be committed when the memory is reserved. |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
884 |
static bool should_commit_large_pages_when_reserving(size_t bytes) { |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
885 |
if (UseLargePages && UseLargePagesInMetaspace && !os::can_commit_large_page_memory()) { |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
886 |
size_t words = bytes / BytesPerWord; |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
887 |
bool is_class = false; // We never reserve large pages for the class space. |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
888 |
if (MetaspaceGC::can_expand(words, is_class) && |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
889 |
MetaspaceGC::allowed_expansion() >= words) { |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
890 |
return true; |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
891 |
} |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
892 |
} |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
893 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
894 |
return false; |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
895 |
} |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
896 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
897 |
// byte_size is the size of the associated virtualspace. |
49365 | 898 |
VirtualSpaceNode::VirtualSpaceNode(bool is_class, size_t bytes) : |
899 |
_is_class(is_class), _top(NULL), _next(NULL), _rs(), _container_count(0), _occupancy_map(NULL) { |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
900 |
assert_is_aligned(bytes, Metaspace::reserve_alignment()); |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
901 |
bool large_pages = should_commit_large_pages_when_reserving(bytes); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
902 |
_rs = ReservedSpace(bytes, Metaspace::reserve_alignment(), large_pages); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
903 |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
904 |
if (_rs.is_reserved()) { |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
905 |
assert(_rs.base() != NULL, "Catch if we get a NULL address"); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
906 |
assert(_rs.size() != 0, "Catch if we get a 0 size"); |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
907 |
assert_is_aligned(_rs.base(), Metaspace::reserve_alignment()); |
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
908 |
assert_is_aligned(_rs.size(), Metaspace::reserve_alignment()); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
909 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
910 |
MemTracker::record_virtual_memory_type((address)_rs.base(), mtClass); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
911 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
912 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
913 |
|
17101 | 914 |
void VirtualSpaceNode::purge(ChunkManager* chunk_manager) { |
49365 | 915 |
DEBUG_ONLY(this->verify();) |
17101 | 916 |
Metachunk* chunk = first_chunk(); |
917 |
Metachunk* invalid_chunk = (Metachunk*) top(); |
|
918 |
while (chunk < invalid_chunk ) { |
|
20729 | 919 |
assert(chunk->is_tagged_free(), "Should be tagged free"); |
920 |
MetaWord* next = ((MetaWord*)chunk) + chunk->word_size(); |
|
921 |
chunk_manager->remove_chunk(chunk); |
|
49365 | 922 |
chunk->remove_sentinel(); |
20729 | 923 |
assert(chunk->next() == NULL && |
924 |
chunk->prev() == NULL, |
|
925 |
"Was not removed from its list"); |
|
926 |
chunk = (Metachunk*) next; |
|
17101 | 927 |
} |
928 |
} |
|
929 |
||
47808
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
930 |
void VirtualSpaceNode::print_map(outputStream* st, bool is_class) const { |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
931 |
|
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
932 |
if (bottom() == top()) { |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
933 |
return; |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
934 |
} |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
935 |
|
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
936 |
const size_t spec_chunk_size = is_class ? ClassSpecializedChunk : SpecializedChunk; |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
937 |
const size_t small_chunk_size = is_class ? ClassSmallChunk : SmallChunk; |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
938 |
const size_t med_chunk_size = is_class ? ClassMediumChunk : MediumChunk; |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
939 |
|
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
940 |
int line_len = 100; |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
941 |
const size_t section_len = align_up(spec_chunk_size * line_len, med_chunk_size); |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
942 |
line_len = (int)(section_len / spec_chunk_size); |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
943 |
|
49365 | 944 |
static const int NUM_LINES = 4; |
945 |
||
946 |
char* lines[NUM_LINES]; |
|
947 |
for (int i = 0; i < NUM_LINES; i ++) { |
|
948 |
lines[i] = (char*)os::malloc(line_len, mtInternal); |
|
949 |
} |
|
47808
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
950 |
int pos = 0; |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
951 |
const MetaWord* p = bottom(); |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
952 |
const Metachunk* chunk = (const Metachunk*)p; |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
953 |
const MetaWord* chunk_end = p + chunk->word_size(); |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
954 |
while (p < top()) { |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
955 |
if (pos == line_len) { |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
956 |
pos = 0; |
49365 | 957 |
for (int i = 0; i < NUM_LINES; i ++) { |
958 |
st->fill_to(22); |
|
959 |
st->print_raw(lines[i], line_len); |
|
960 |
st->cr(); |
|
961 |
} |
|
47808
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
962 |
} |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
963 |
if (pos == 0) { |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
964 |
st->print(PTR_FORMAT ":", p2i(p)); |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
965 |
} |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
966 |
if (p == chunk_end) { |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
967 |
chunk = (Metachunk*)p; |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
968 |
chunk_end = p + chunk->word_size(); |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
969 |
} |
49365 | 970 |
// line 1: chunk starting points (a dot if that area is a chunk start). |
971 |
lines[0][pos] = p == (const MetaWord*)chunk ? '.' : ' '; |
|
972 |
||
47808
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
973 |
// Line 2: chunk type (x=spec, s=small, m=medium, h=humongous), uppercase if |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
974 |
// chunk is in use. |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
975 |
const bool chunk_is_free = ((Metachunk*)chunk)->is_tagged_free(); |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
976 |
if (chunk->word_size() == spec_chunk_size) { |
49365 | 977 |
lines[1][pos] = chunk_is_free ? 'x' : 'X'; |
47808
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
978 |
} else if (chunk->word_size() == small_chunk_size) { |
49365 | 979 |
lines[1][pos] = chunk_is_free ? 's' : 'S'; |
47808
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
980 |
} else if (chunk->word_size() == med_chunk_size) { |
49365 | 981 |
lines[1][pos] = chunk_is_free ? 'm' : 'M'; |
982 |
} else if (chunk->word_size() > med_chunk_size) { |
|
983 |
lines[1][pos] = chunk_is_free ? 'h' : 'H'; |
|
47808
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
984 |
} else { |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
985 |
ShouldNotReachHere(); |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
986 |
} |
49365 | 987 |
|
988 |
// Line 3: chunk origin |
|
989 |
const ChunkOrigin origin = chunk->get_origin(); |
|
990 |
lines[2][pos] = origin == origin_normal ? ' ' : '0' + (int) origin; |
|
991 |
||
992 |
// Line 4: Virgin chunk? Virgin chunks are chunks created as a byproduct of padding or splitting, |
|
993 |
// but were never used. |
|
994 |
lines[3][pos] = chunk->get_use_count() > 0 ? ' ' : 'v'; |
|
995 |
||
47808
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
996 |
p += spec_chunk_size; |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
997 |
pos ++; |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
998 |
} |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
999 |
if (pos > 0) { |
49365 | 1000 |
for (int i = 0; i < NUM_LINES; i ++) { |
1001 |
st->fill_to(22); |
|
1002 |
st->print_raw(lines[i], line_len); |
|
1003 |
st->cr(); |
|
1004 |
} |
|
1005 |
} |
|
1006 |
for (int i = 0; i < NUM_LINES; i ++) { |
|
1007 |
os::free(lines[i]); |
|
1008 |
} |
|
47808
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
1009 |
} |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
1010 |
|
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
1011 |
|
17101 | 1012 |
#ifdef ASSERT |
29806
64aa40385bdd
8076173: VirtualSpaceNode container_count() and container_count_slow() have different return types
david
parents:
29800
diff
changeset
|
1013 |
uintx VirtualSpaceNode::container_count_slow() { |
64aa40385bdd
8076173: VirtualSpaceNode container_count() and container_count_slow() have different return types
david
parents:
29800
diff
changeset
|
1014 |
uintx count = 0; |
17101 | 1015 |
Metachunk* chunk = first_chunk(); |
1016 |
Metachunk* invalid_chunk = (Metachunk*) top(); |
|
1017 |
while (chunk < invalid_chunk ) { |
|
1018 |
MetaWord* next = ((MetaWord*)chunk) + chunk->word_size(); |
|
49365 | 1019 |
do_verify_chunk(chunk); |
17101 | 1020 |
// Don't count the chunks on the free lists. Those are |
1021 |
// still part of the VirtualSpaceNode but not currently |
|
1022 |
// counted. |
|
20729 | 1023 |
if (!chunk->is_tagged_free()) { |
17101 | 1024 |
count++; |
1025 |
} |
|
1026 |
chunk = (Metachunk*) next; |
|
1027 |
} |
|
1028 |
return count; |
|
1029 |
} |
|
1030 |
#endif |
|
1031 |
||
49365 | 1032 |
#ifdef ASSERT |
1033 |
// Verify counters, all chunks in this list node and the occupancy map. |
|
1034 |
void VirtualSpaceNode::verify() { |
|
1035 |
uintx num_in_use_chunks = 0; |
|
1036 |
Metachunk* chunk = first_chunk(); |
|
1037 |
Metachunk* invalid_chunk = (Metachunk*) top(); |
|
1038 |
||
1039 |
// Iterate the chunks in this node and verify each chunk. |
|
1040 |
while (chunk < invalid_chunk ) { |
|
1041 |
DEBUG_ONLY(do_verify_chunk(chunk);) |
|
1042 |
if (!chunk->is_tagged_free()) { |
|
1043 |
num_in_use_chunks ++; |
|
1044 |
} |
|
1045 |
MetaWord* next = ((MetaWord*)chunk) + chunk->word_size(); |
|
1046 |
chunk = (Metachunk*) next; |
|
1047 |
} |
|
1048 |
assert(_container_count == num_in_use_chunks, "Container count mismatch (real: " UINTX_FORMAT |
|
1049 |
", counter: " UINTX_FORMAT ".", num_in_use_chunks, _container_count); |
|
1050 |
// Also verify the occupancy map. |
|
1051 |
occupancy_map()->verify(this->bottom(), this->top()); |
|
1052 |
} |
|
1053 |
#endif // ASSERT |
|
1054 |
||
1055 |
#ifdef ASSERT |
|
1056 |
// Verify that all free chunks in this node are ideally merged |
|
1057 |
// (there not should be multiple small chunks where a large chunk could exist.) |
|
1058 |
void VirtualSpaceNode::verify_free_chunks_are_ideally_merged() { |
|
1059 |
Metachunk* chunk = first_chunk(); |
|
1060 |
Metachunk* invalid_chunk = (Metachunk*) top(); |
|
1061 |
// Shorthands. |
|
1062 |
const size_t size_med = (is_class() ? ClassMediumChunk : MediumChunk) * BytesPerWord; |
|
1063 |
const size_t size_small = (is_class() ? ClassSmallChunk : SmallChunk) * BytesPerWord; |
|
1064 |
int num_free_chunks_since_last_med_boundary = -1; |
|
1065 |
int num_free_chunks_since_last_small_boundary = -1; |
|
1066 |
while (chunk < invalid_chunk ) { |
|
1067 |
// Test for missed chunk merge opportunities: count number of free chunks since last chunk boundary. |
|
1068 |
// Reset the counter when encountering a non-free chunk. |
|
1069 |
if (chunk->get_chunk_type() != HumongousIndex) { |
|
1070 |
if (chunk->is_tagged_free()) { |
|
1071 |
// Count successive free, non-humongous chunks. |
|
1072 |
if (is_aligned(chunk, size_small)) { |
|
1073 |
assert(num_free_chunks_since_last_small_boundary <= 1, |
|
1074 |
"Missed chunk merge opportunity at " PTR_FORMAT " for chunk size " SIZE_FORMAT_HEX ".", p2i(chunk) - size_small, size_small); |
|
1075 |
num_free_chunks_since_last_small_boundary = 0; |
|
1076 |
} else if (num_free_chunks_since_last_small_boundary != -1) { |
|
1077 |
num_free_chunks_since_last_small_boundary ++; |
|
1078 |
} |
|
1079 |
if (is_aligned(chunk, size_med)) { |
|
1080 |
assert(num_free_chunks_since_last_med_boundary <= 1, |
|
1081 |
"Missed chunk merge opportunity at " PTR_FORMAT " for chunk size " SIZE_FORMAT_HEX ".", p2i(chunk) - size_med, size_med); |
|
1082 |
num_free_chunks_since_last_med_boundary = 0; |
|
1083 |
} else if (num_free_chunks_since_last_med_boundary != -1) { |
|
1084 |
num_free_chunks_since_last_med_boundary ++; |
|
1085 |
} |
|
1086 |
} else { |
|
1087 |
// Encountering a non-free chunk, reset counters. |
|
1088 |
num_free_chunks_since_last_med_boundary = -1; |
|
1089 |
num_free_chunks_since_last_small_boundary = -1; |
|
1090 |
} |
|
1091 |
} else { |
|
1092 |
// One cannot merge areas with a humongous chunk in the middle. Reset counters. |
|
1093 |
num_free_chunks_since_last_med_boundary = -1; |
|
1094 |
num_free_chunks_since_last_small_boundary = -1; |
|
1095 |
} |
|
1096 |
||
1097 |
MetaWord* next = ((MetaWord*)chunk) + chunk->word_size(); |
|
1098 |
chunk = (Metachunk*) next; |
|
1099 |
} |
|
1100 |
} |
|
1101 |
#endif // ASSERT |
|
1102 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1103 |
// List of VirtualSpaces for metadata allocation. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1104 |
class VirtualSpaceList : public CHeapObj<mtClass> { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1105 |
friend class VirtualSpaceNode; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1106 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1107 |
enum VirtualSpaceSizes { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1108 |
VirtualSpaceSize = 256 * K |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1109 |
}; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1110 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1111 |
// Head of the list |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1112 |
VirtualSpaceNode* _virtual_space_list; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1113 |
// virtual space currently being used for allocations |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1114 |
VirtualSpaceNode* _current_virtual_space; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1115 |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1116 |
// Is this VirtualSpaceList used for the compressed class space |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1117 |
bool _is_class; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1118 |
|
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
1119 |
// Sum of reserved and committed memory in the virtual spaces |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
1120 |
size_t _reserved_words; |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
1121 |
size_t _committed_words; |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
1122 |
|
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
1123 |
// Number of virtual spaces |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1124 |
size_t _virtual_space_count; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1125 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1126 |
~VirtualSpaceList(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1127 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1128 |
VirtualSpaceNode* virtual_space_list() const { return _virtual_space_list; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1129 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1130 |
void set_virtual_space_list(VirtualSpaceNode* v) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1131 |
_virtual_space_list = v; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1132 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1133 |
void set_current_virtual_space(VirtualSpaceNode* v) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1134 |
_current_virtual_space = v; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1135 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1136 |
|
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
1137 |
void link_vs(VirtualSpaceNode* new_entry); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1138 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1139 |
// Get another virtual space and add it to the list. This |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1140 |
// is typically prompted by a failed attempt to allocate a chunk |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1141 |
// and is typically followed by the allocation of a chunk. |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1142 |
bool create_new_virtual_space(size_t vs_word_size); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1143 |
|
21112
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
1144 |
// Chunk up the unused committed space in the current |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
1145 |
// virtual space and add the chunks to the free list. |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
1146 |
void retire_current_virtual_space(); |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
1147 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1148 |
public: |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1149 |
VirtualSpaceList(size_t word_size); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1150 |
VirtualSpaceList(ReservedSpace rs); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1151 |
|
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
1152 |
size_t free_bytes(); |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
1153 |
|
42615
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
1154 |
Metachunk* get_new_chunk(size_t chunk_word_size, |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
1155 |
size_t suggested_commit_granularity); |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
1156 |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1157 |
bool expand_node_by(VirtualSpaceNode* node, |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1158 |
size_t min_words, |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1159 |
size_t preferred_words); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1160 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1161 |
bool expand_by(size_t min_words, |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1162 |
size_t preferred_words); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1163 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1164 |
VirtualSpaceNode* current_virtual_space() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1165 |
return _current_virtual_space; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1166 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1167 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1168 |
bool is_class() const { return _is_class; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1169 |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1170 |
bool initialization_succeeded() { return _virtual_space_list != NULL; } |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1171 |
|
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
1172 |
size_t reserved_words() { return _reserved_words; } |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
1173 |
size_t reserved_bytes() { return reserved_words() * BytesPerWord; } |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
1174 |
size_t committed_words() { return _committed_words; } |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
1175 |
size_t committed_bytes() { return committed_words() * BytesPerWord; } |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
1176 |
|
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
1177 |
void inc_reserved_words(size_t v); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
1178 |
void dec_reserved_words(size_t v); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
1179 |
void inc_committed_words(size_t v); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
1180 |
void dec_committed_words(size_t v); |
17101 | 1181 |
void inc_virtual_space_count(); |
1182 |
void dec_virtual_space_count(); |
|
1183 |
||
24457
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
1184 |
bool contains(const void* ptr); |
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
1185 |
|
17101 | 1186 |
// Unlink empty VirtualSpaceNodes and free it. |
20081
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
1187 |
void purge(ChunkManager* chunk_manager); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1188 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1189 |
void print_on(outputStream* st) const; |
47808
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
1190 |
void print_map(outputStream* st) const; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1191 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1192 |
class VirtualSpaceListIterator : public StackObj { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1193 |
VirtualSpaceNode* _virtual_spaces; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1194 |
public: |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1195 |
VirtualSpaceListIterator(VirtualSpaceNode* virtual_spaces) : |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1196 |
_virtual_spaces(virtual_spaces) {} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1197 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1198 |
bool repeat() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1199 |
return _virtual_spaces != NULL; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1200 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1201 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1202 |
VirtualSpaceNode* get_next() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1203 |
VirtualSpaceNode* result = _virtual_spaces; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1204 |
if (_virtual_spaces != NULL) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1205 |
_virtual_spaces = _virtual_spaces->next(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1206 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1207 |
return result; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1208 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1209 |
}; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1210 |
}; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1211 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1212 |
class Metadebug : AllStatic { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1213 |
// Debugging support for Metaspaces |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1214 |
static int _allocation_fail_alot_count; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1215 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1216 |
public: |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1217 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1218 |
static void init_allocation_fail_alot_count(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1219 |
#ifdef ASSERT |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1220 |
static bool test_metadata_failure(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1221 |
#endif |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1222 |
}; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1223 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1224 |
int Metadebug::_allocation_fail_alot_count = 0; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1225 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1226 |
// SpaceManager - used by Metaspace to handle allocations |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1227 |
class SpaceManager : public CHeapObj<mtClass> { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1228 |
friend class Metaspace; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1229 |
friend class Metadebug; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1230 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1231 |
private: |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
1232 |
|
22201
9c2ccfa3a5fe
8029178: Parallel class loading test anonymous-simple gets SIGSEGV in Metaspace::contains
coleenp
parents:
21569
diff
changeset
|
1233 |
// protects allocations |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1234 |
Mutex* const _lock; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1235 |
|
17628
481e0280aed3
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
17117
diff
changeset
|
1236 |
// Type of metadata allocated. |
48148
385bed268108
8190729: Adjustment to anonymous metadata space chunk allocation algorithm
zgu
parents:
47808
diff
changeset
|
1237 |
const Metaspace::MetadataType _mdtype; |
385bed268108
8190729: Adjustment to anonymous metadata space chunk allocation algorithm
zgu
parents:
47808
diff
changeset
|
1238 |
|
385bed268108
8190729: Adjustment to anonymous metadata space chunk allocation algorithm
zgu
parents:
47808
diff
changeset
|
1239 |
// Type of metaspace |
385bed268108
8190729: Adjustment to anonymous metadata space chunk allocation algorithm
zgu
parents:
47808
diff
changeset
|
1240 |
const Metaspace::MetaspaceType _space_type; |
17628
481e0280aed3
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
17117
diff
changeset
|
1241 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1242 |
// List of chunks in use by this SpaceManager. Allocations |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1243 |
// are done from the current chunk. The list is used for deallocating |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1244 |
// chunks when the SpaceManager is freed. |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
1245 |
Metachunk* _chunks_in_use[NumberOfInUseLists]; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1246 |
Metachunk* _current_chunk; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1247 |
|
31028
8c5b4d489c41
8081508: metaspace/shrink_grow/CompressedClassSpaceSize fails with OOM: Compressed class space
jprovino
parents:
30764
diff
changeset
|
1248 |
// Maximum number of small chunks to allocate to a SpaceManager |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1249 |
static uint const _small_chunk_limit; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1250 |
|
48148
385bed268108
8190729: Adjustment to anonymous metadata space chunk allocation algorithm
zgu
parents:
47808
diff
changeset
|
1251 |
// Maximum number of specialize chunks to allocate for anonymous |
385bed268108
8190729: Adjustment to anonymous metadata space chunk allocation algorithm
zgu
parents:
47808
diff
changeset
|
1252 |
// metadata space to a SpaceManager |
385bed268108
8190729: Adjustment to anonymous metadata space chunk allocation algorithm
zgu
parents:
47808
diff
changeset
|
1253 |
static uint const _anon_metadata_specialize_chunk_limit; |
385bed268108
8190729: Adjustment to anonymous metadata space chunk allocation algorithm
zgu
parents:
47808
diff
changeset
|
1254 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1255 |
// Sum of all space in allocated chunks |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
1256 |
size_t _allocated_blocks_words; |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
1257 |
|
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
1258 |
// Sum of all allocated chunks |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
1259 |
size_t _allocated_chunks_words; |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
1260 |
size_t _allocated_chunks_count; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1261 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1262 |
// Free lists of blocks are per SpaceManager since they |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1263 |
// are assumed to be in chunks in use by the SpaceManager |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1264 |
// and all chunks in use by a SpaceManager are freed when |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1265 |
// the class loader using the SpaceManager is collected. |
41727
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1266 |
BlockFreelist* _block_freelists; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1267 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1268 |
// protects virtualspace and chunk expansions |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1269 |
static const char* _expand_lock_name; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1270 |
static const int _expand_lock_rank; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1271 |
static Mutex* const _expand_lock; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1272 |
|
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
1273 |
private: |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1274 |
// Accessors |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1275 |
Metachunk* chunks_in_use(ChunkIndex index) const { return _chunks_in_use[index]; } |
22201
9c2ccfa3a5fe
8029178: Parallel class loading test anonymous-simple gets SIGSEGV in Metaspace::contains
coleenp
parents:
21569
diff
changeset
|
1276 |
void set_chunks_in_use(ChunkIndex index, Metachunk* v) { |
9c2ccfa3a5fe
8029178: Parallel class loading test anonymous-simple gets SIGSEGV in Metaspace::contains
coleenp
parents:
21569
diff
changeset
|
1277 |
_chunks_in_use[index] = v; |
9c2ccfa3a5fe
8029178: Parallel class loading test anonymous-simple gets SIGSEGV in Metaspace::contains
coleenp
parents:
21569
diff
changeset
|
1278 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1279 |
|
41727
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1280 |
BlockFreelist* block_freelists() const { return _block_freelists; } |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1281 |
|
17628
481e0280aed3
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
17117
diff
changeset
|
1282 |
Metaspace::MetadataType mdtype() { return _mdtype; } |
20081
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
1283 |
|
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
1284 |
VirtualSpaceList* vs_list() const { return Metaspace::get_space_list(_mdtype); } |
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
1285 |
ChunkManager* chunk_manager() const { return Metaspace::get_chunk_manager(_mdtype); } |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1286 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1287 |
Metachunk* current_chunk() const { return _current_chunk; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1288 |
void set_current_chunk(Metachunk* v) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1289 |
_current_chunk = v; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1290 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1291 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1292 |
Metachunk* find_current_chunk(size_t word_size); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1293 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1294 |
// Add chunk to the list of chunks in use |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1295 |
void add_chunk(Metachunk* v, bool make_current); |
19984
ba033739c8fe
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
19979
diff
changeset
|
1296 |
void retire_current_chunk(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1297 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1298 |
Mutex* lock() const { return _lock; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1299 |
|
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
1300 |
protected: |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
1301 |
void initialize(); |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
1302 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1303 |
public: |
17628
481e0280aed3
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
17117
diff
changeset
|
1304 |
SpaceManager(Metaspace::MetadataType mdtype, |
48148
385bed268108
8190729: Adjustment to anonymous metadata space chunk allocation algorithm
zgu
parents:
47808
diff
changeset
|
1305 |
Metaspace::MetaspaceType space_type, |
20081
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
1306 |
Mutex* lock); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1307 |
~SpaceManager(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1308 |
|
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
1309 |
enum ChunkMultiples { |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
1310 |
MediumChunkMultiple = 4 |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1311 |
}; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1312 |
|
42615
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
1313 |
static size_t specialized_chunk_size(bool is_class) { return is_class ? ClassSpecializedChunk : SpecializedChunk; } |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
1314 |
static size_t small_chunk_size(bool is_class) { return is_class ? ClassSmallChunk : SmallChunk; } |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
1315 |
static size_t medium_chunk_size(bool is_class) { return is_class ? ClassMediumChunk : MediumChunk; } |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
1316 |
|
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
1317 |
static size_t smallest_chunk_size(bool is_class) { return specialized_chunk_size(is_class); } |
20081
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
1318 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1319 |
// Accessors |
42615
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
1320 |
bool is_class() const { return _mdtype == Metaspace::ClassType; } |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
1321 |
|
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
1322 |
size_t specialized_chunk_size() const { return specialized_chunk_size(is_class()); } |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
1323 |
size_t small_chunk_size() const { return small_chunk_size(is_class()); } |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
1324 |
size_t medium_chunk_size() const { return medium_chunk_size(is_class()); } |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
1325 |
|
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
1326 |
size_t smallest_chunk_size() const { return smallest_chunk_size(is_class()); } |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
1327 |
|
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
1328 |
size_t medium_chunk_bunch() const { return medium_chunk_size() * MediumChunkMultiple; } |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
1329 |
|
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
1330 |
size_t allocated_blocks_words() const { return _allocated_blocks_words; } |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
1331 |
size_t allocated_blocks_bytes() const { return _allocated_blocks_words * BytesPerWord; } |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
1332 |
size_t allocated_chunks_words() const { return _allocated_chunks_words; } |
25051
8110ec6e7340
8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
24665
diff
changeset
|
1333 |
size_t allocated_chunks_bytes() const { return _allocated_chunks_words * BytesPerWord; } |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
1334 |
size_t allocated_chunks_count() const { return _allocated_chunks_count; } |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
1335 |
|
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
1336 |
bool is_humongous(size_t word_size) { return word_size > medium_chunk_size(); } |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1337 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1338 |
static Mutex* expand_lock() { return _expand_lock; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1339 |
|
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
1340 |
// Increment the per Metaspace and global running sums for Metachunks |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
1341 |
// by the given size. This is used when a Metachunk to added to |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
1342 |
// the in-use list. |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
1343 |
void inc_size_metrics(size_t words); |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
1344 |
// Increment the per Metaspace and global running sums Metablocks by the given |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
1345 |
// size. This is used when a Metablock is allocated. |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
1346 |
void inc_used_metrics(size_t words); |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
1347 |
// Delete the portion of the running sums for this SpaceManager. That is, |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
1348 |
// the globals running sums for the Metachunks and Metablocks are |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
1349 |
// decremented for all the Metachunks in-use by this SpaceManager. |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
1350 |
void dec_total_from_size_metrics(); |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
1351 |
|
42615
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
1352 |
// Adjust the initial chunk size to match one of the fixed chunk list sizes, |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
1353 |
// or return the unadjusted size if the requested size is humongous. |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
1354 |
static size_t adjust_initial_chunk_size(size_t requested, bool is_class_space); |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
1355 |
size_t adjust_initial_chunk_size(size_t requested) const; |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
1356 |
|
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
1357 |
// Get the initial chunks size for this metaspace type. |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
1358 |
size_t get_initial_chunk_size(Metaspace::MetaspaceType type) const; |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
1359 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1360 |
size_t sum_capacity_in_chunks_in_use() const; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1361 |
size_t sum_used_in_chunks_in_use() const; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1362 |
size_t sum_free_in_chunks_in_use() const; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1363 |
size_t sum_waste_in_chunks_in_use() const; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1364 |
size_t sum_waste_in_chunks_in_use(ChunkIndex index ) const; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1365 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1366 |
size_t sum_count_in_chunks_in_use(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1367 |
size_t sum_count_in_chunks_in_use(ChunkIndex i); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1368 |
|
42615
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
1369 |
Metachunk* get_new_chunk(size_t chunk_word_size); |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
1370 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1371 |
// Block allocation and deallocation. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1372 |
// Allocates a block from the current chunk |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1373 |
MetaWord* allocate(size_t word_size); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1374 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1375 |
// Helper for allocations |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
1376 |
MetaWord* allocate_work(size_t word_size); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1377 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1378 |
// Returns a block to the per manager freelist |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
1379 |
void deallocate(MetaWord* p, size_t word_size); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1380 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1381 |
// Based on the allocation size and a minimum chunk size, |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1382 |
// returned chunk size (for expanding space for chunk allocation). |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1383 |
size_t calc_chunk_size(size_t allocation_word_size); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1384 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1385 |
// Called when an allocation from the current chunk fails. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1386 |
// Gets a new chunk (may require getting a new virtual space), |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1387 |
// and allocates from that chunk. |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
1388 |
MetaWord* grow_and_allocate(size_t word_size); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1389 |
|
20407
68e215ce8944
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
20406
diff
changeset
|
1390 |
// Notify memory usage to MemoryService. |
68e215ce8944
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
20406
diff
changeset
|
1391 |
void track_metaspace_memory_usage(); |
68e215ce8944
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
20406
diff
changeset
|
1392 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1393 |
// debugging support. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1394 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1395 |
void dump(outputStream* const out) const; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1396 |
void print_on(outputStream* st) const; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1397 |
void locked_print_chunks_in_use_on(outputStream* st) const; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1398 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1399 |
void verify(); |
14635
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
14590
diff
changeset
|
1400 |
void verify_chunk_size(Metachunk* chunk); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1401 |
#ifdef ASSERT |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
1402 |
void verify_allocated_blocks_words(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1403 |
#endif |
17858
c292f8791cca
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
17628
diff
changeset
|
1404 |
|
41727
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1405 |
// This adjusts the size given to be greater than the minimum allocation size in |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1406 |
// words for data in metaspace. Esentially the minimum size is currently 3 words. |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1407 |
size_t get_allocation_word_size(size_t word_size) { |
17858
c292f8791cca
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
17628
diff
changeset
|
1408 |
size_t byte_size = word_size * BytesPerWord; |
c292f8791cca
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
17628
diff
changeset
|
1409 |
|
20729 | 1410 |
size_t raw_bytes_size = MAX2(byte_size, sizeof(Metablock)); |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
1411 |
raw_bytes_size = align_up(raw_bytes_size, Metachunk::object_alignment()); |
20729 | 1412 |
|
17858
c292f8791cca
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
17628
diff
changeset
|
1413 |
size_t raw_word_size = raw_bytes_size / BytesPerWord; |
c292f8791cca
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
17628
diff
changeset
|
1414 |
assert(raw_word_size * BytesPerWord == raw_bytes_size, "Size problem"); |
c292f8791cca
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
17628
diff
changeset
|
1415 |
|
c292f8791cca
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
17628
diff
changeset
|
1416 |
return raw_word_size; |
c292f8791cca
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
17628
diff
changeset
|
1417 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1418 |
}; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1419 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1420 |
uint const SpaceManager::_small_chunk_limit = 4; |
48148
385bed268108
8190729: Adjustment to anonymous metadata space chunk allocation algorithm
zgu
parents:
47808
diff
changeset
|
1421 |
uint const SpaceManager::_anon_metadata_specialize_chunk_limit = 4; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1422 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1423 |
const char* SpaceManager::_expand_lock_name = |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1424 |
"SpaceManager chunk allocation lock"; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1425 |
const int SpaceManager::_expand_lock_rank = Monitor::leaf - 1; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1426 |
Mutex* const SpaceManager::_expand_lock = |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1427 |
new Mutex(SpaceManager::_expand_lock_rank, |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1428 |
SpaceManager::_expand_lock_name, |
28163
322d55d167be
8047290: Make Mutex::_no_safepoint_check_flag locks verify that this lock never checks for safepoint
coleenp
parents:
28023
diff
changeset
|
1429 |
Mutex::_allow_vm_block_flag, |
322d55d167be
8047290: Make Mutex::_no_safepoint_check_flag locks verify that this lock never checks for safepoint
coleenp
parents:
28023
diff
changeset
|
1430 |
Monitor::_safepoint_check_never); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1431 |
|
17101 | 1432 |
void VirtualSpaceNode::inc_container_count() { |
1433 |
assert_lock_strong(SpaceManager::expand_lock()); |
|
1434 |
_container_count++; |
|
1435 |
} |
|
1436 |
||
1437 |
void VirtualSpaceNode::dec_container_count() { |
|
1438 |
assert_lock_strong(SpaceManager::expand_lock()); |
|
1439 |
_container_count--; |
|
1440 |
} |
|
1441 |
||
1442 |
#ifdef ASSERT |
|
1443 |
void VirtualSpaceNode::verify_container_count() { |
|
1444 |
assert(_container_count == container_count_slow(), |
|
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
1445 |
"Inconsistency in container_count _container_count " UINTX_FORMAT |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
1446 |
" container_count_slow() " UINTX_FORMAT, _container_count, container_count_slow()); |
17101 | 1447 |
} |
1448 |
#endif |
|
1449 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1450 |
// BlockFreelist methods |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1451 |
|
41727
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1452 |
BlockFreelist::BlockFreelist() : _dictionary(new BlockTreeDictionary()), _small_blocks(NULL) {} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1453 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1454 |
BlockFreelist::~BlockFreelist() { |
30580
394471b86a83
8079091: Remove dictionary NULL check on common path of BlockFreeList methods
jwha
parents:
29806
diff
changeset
|
1455 |
delete _dictionary; |
41727
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1456 |
if (_small_blocks != NULL) { |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1457 |
delete _small_blocks; |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1458 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1459 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1460 |
|
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
1461 |
void BlockFreelist::return_block(MetaWord* p, size_t word_size) { |
41727
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1462 |
assert(word_size >= SmallBlocks::small_block_min_size(), "never return dark matter"); |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1463 |
|
20729 | 1464 |
Metablock* free_chunk = ::new (p) Metablock(word_size); |
41727
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1465 |
if (word_size < SmallBlocks::small_block_max_size()) { |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1466 |
small_blocks()->return_block(free_chunk, word_size); |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1467 |
} else { |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
1468 |
dictionary()->return_chunk(free_chunk); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1469 |
} |
41727
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1470 |
log_trace(gc, metaspace, freelist, blocks)("returning block at " INTPTR_FORMAT " size = " |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1471 |
SIZE_FORMAT, p2i(free_chunk), word_size); |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1472 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1473 |
|
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
1474 |
MetaWord* BlockFreelist::get_block(size_t word_size) { |
41727
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1475 |
assert(word_size >= SmallBlocks::small_block_min_size(), "never get dark matter"); |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1476 |
|
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1477 |
// Try small_blocks first. |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1478 |
if (word_size < SmallBlocks::small_block_max_size()) { |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1479 |
// Don't create small_blocks() until needed. small_blocks() allocates the small block list for |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1480 |
// this space manager. |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1481 |
MetaWord* new_block = (MetaWord*) small_blocks()->get_block(word_size); |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1482 |
if (new_block != NULL) { |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1483 |
log_trace(gc, metaspace, freelist, blocks)("getting block at " INTPTR_FORMAT " size = " SIZE_FORMAT, |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1484 |
p2i(new_block), word_size); |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1485 |
return new_block; |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1486 |
} |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1487 |
} |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1488 |
|
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1489 |
if (word_size < BlockFreelist::min_dictionary_size()) { |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1490 |
// If allocation in small blocks fails, this is Dark Matter. Too small for dictionary. |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1491 |
return NULL; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1492 |
} |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
1493 |
|
46674
a9e42ff6158f
8183923: Get rid of FreeBlockDictionary and dithering
mgerdin
parents:
46625
diff
changeset
|
1494 |
Metablock* free_block = dictionary()->get_chunk(word_size); |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
1495 |
if (free_block == NULL) { |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
1496 |
return NULL; |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
1497 |
} |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
1498 |
|
19984
ba033739c8fe
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
19979
diff
changeset
|
1499 |
const size_t block_size = free_block->size(); |
ba033739c8fe
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
19979
diff
changeset
|
1500 |
if (block_size > WasteMultiplier * word_size) { |
ba033739c8fe
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
19979
diff
changeset
|
1501 |
return_block((MetaWord*)free_block, block_size); |
ba033739c8fe
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
19979
diff
changeset
|
1502 |
return NULL; |
ba033739c8fe
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
19979
diff
changeset
|
1503 |
} |
ba033739c8fe
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
19979
diff
changeset
|
1504 |
|
ba033739c8fe
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
19979
diff
changeset
|
1505 |
MetaWord* new_block = (MetaWord*)free_block; |
ba033739c8fe
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
19979
diff
changeset
|
1506 |
assert(block_size >= word_size, "Incorrect size of block from freelist"); |
ba033739c8fe
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
19979
diff
changeset
|
1507 |
const size_t unused = block_size - word_size; |
41727
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1508 |
if (unused >= SmallBlocks::small_block_min_size()) { |
19984
ba033739c8fe
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
19979
diff
changeset
|
1509 |
return_block(new_block + word_size, unused); |
ba033739c8fe
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
19979
diff
changeset
|
1510 |
} |
ba033739c8fe
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
19979
diff
changeset
|
1511 |
|
41727
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1512 |
log_trace(gc, metaspace, freelist, blocks)("getting block at " INTPTR_FORMAT " size = " SIZE_FORMAT, |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1513 |
p2i(new_block), word_size); |
19984
ba033739c8fe
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
19979
diff
changeset
|
1514 |
return new_block; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1515 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1516 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1517 |
void BlockFreelist::print_on(outputStream* st) const { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1518 |
dictionary()->print_free_lists(st); |
41727
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1519 |
if (_small_blocks != NULL) { |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1520 |
_small_blocks->print_on(st); |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1521 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1522 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1523 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1524 |
// VirtualSpaceNode methods |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1525 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1526 |
VirtualSpaceNode::~VirtualSpaceNode() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1527 |
_rs.release(); |
49365 | 1528 |
if (_occupancy_map != NULL) { |
1529 |
delete _occupancy_map; |
|
1530 |
} |
|
17101 | 1531 |
#ifdef ASSERT |
1532 |
size_t word_size = sizeof(*this) / BytesPerWord; |
|
1533 |
Copy::fill_to_words((HeapWord*) this, word_size, 0xf1f1f1f1); |
|
1534 |
#endif |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1535 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1536 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1537 |
size_t VirtualSpaceNode::used_words_in_vs() const { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1538 |
return pointer_delta(top(), bottom(), sizeof(MetaWord)); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1539 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1540 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1541 |
// Space committed in the VirtualSpace |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1542 |
size_t VirtualSpaceNode::capacity_words_in_vs() const { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1543 |
return pointer_delta(end(), bottom(), sizeof(MetaWord)); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1544 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1545 |
|
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
1546 |
size_t VirtualSpaceNode::free_words_in_vs() const { |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
1547 |
return pointer_delta(end(), top(), sizeof(MetaWord)); |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
1548 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1549 |
|
49365 | 1550 |
// Given an address larger than top(), allocate padding chunks until top is at the given address. |
1551 |
void VirtualSpaceNode::allocate_padding_chunks_until_top_is_at(MetaWord* target_top) { |
|
1552 |
||
1553 |
assert(target_top > top(), "Sanity"); |
|
1554 |
||
1555 |
// Padding chunks are added to the freelist. |
|
1556 |
ChunkManager* const chunk_manager = Metaspace::get_chunk_manager(this->is_class()); |
|
1557 |
||
1558 |
// shorthands |
|
1559 |
const size_t spec_word_size = chunk_manager->specialized_chunk_word_size(); |
|
1560 |
const size_t small_word_size = chunk_manager->small_chunk_word_size(); |
|
1561 |
const size_t med_word_size = chunk_manager->medium_chunk_word_size(); |
|
1562 |
||
1563 |
while (top() < target_top) { |
|
1564 |
||
1565 |
// We could make this coding more generic, but right now we only deal with two possible chunk sizes |
|
1566 |
// for padding chunks, so it is not worth it. |
|
1567 |
size_t padding_chunk_word_size = small_word_size; |
|
1568 |
if (is_aligned(top(), small_word_size * sizeof(MetaWord)) == false) { |
|
1569 |
assert_is_aligned(top(), spec_word_size * sizeof(MetaWord)); // Should always hold true. |
|
1570 |
padding_chunk_word_size = spec_word_size; |
|
1571 |
} |
|
1572 |
MetaWord* here = top(); |
|
1573 |
assert_is_aligned(here, padding_chunk_word_size * sizeof(MetaWord)); |
|
1574 |
inc_top(padding_chunk_word_size); |
|
1575 |
||
1576 |
// Create new padding chunk. |
|
1577 |
ChunkIndex padding_chunk_type = get_chunk_type_by_size(padding_chunk_word_size, is_class()); |
|
1578 |
assert(padding_chunk_type == SpecializedIndex || padding_chunk_type == SmallIndex, "sanity"); |
|
1579 |
||
1580 |
Metachunk* const padding_chunk = |
|
1581 |
::new (here) Metachunk(padding_chunk_type, is_class(), padding_chunk_word_size, this); |
|
1582 |
assert(padding_chunk == (Metachunk*)here, "Sanity"); |
|
1583 |
DEBUG_ONLY(padding_chunk->set_origin(origin_pad);) |
|
1584 |
log_trace(gc, metaspace, freelist)("Created padding chunk in %s at " |
|
1585 |
PTR_FORMAT ", size " SIZE_FORMAT_HEX ".", |
|
1586 |
(is_class() ? "class space " : "metaspace"), |
|
1587 |
p2i(padding_chunk), padding_chunk->word_size() * sizeof(MetaWord)); |
|
1588 |
||
1589 |
// Mark chunk start in occupancy map. |
|
1590 |
occupancy_map()->set_chunk_starts_at_address((MetaWord*)padding_chunk, true); |
|
1591 |
||
1592 |
// Chunks are born as in-use (see MetaChunk ctor). So, before returning |
|
1593 |
// the padding chunk to its chunk manager, mark it as in use (ChunkManager |
|
1594 |
// will assert that). |
|
1595 |
do_update_in_use_info_for_chunk(padding_chunk, true); |
|
1596 |
||
1597 |
// Return Chunk to freelist. |
|
1598 |
inc_container_count(); |
|
1599 |
chunk_manager->return_single_chunk(padding_chunk_type, padding_chunk); |
|
1600 |
// Please note: at this point, ChunkManager::return_single_chunk() |
|
1601 |
// may already have merged the padding chunk with neighboring chunks, so |
|
1602 |
// it may have vanished at this point. Do not reference the padding |
|
1603 |
// chunk beyond this point. |
|
1604 |
} |
|
1605 |
||
1606 |
assert(top() == target_top, "Sanity"); |
|
1607 |
||
1608 |
} // allocate_padding_chunks_until_top_is_at() |
|
1609 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1610 |
// Allocates the chunk from the virtual space only. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1611 |
// This interface is also used internally for debugging. Not all |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1612 |
// chunks removed here are necessarily used for allocation. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1613 |
Metachunk* VirtualSpaceNode::take_from_committed(size_t chunk_word_size) { |
49365 | 1614 |
// Non-humongous chunks are to be allocated aligned to their chunk |
1615 |
// size. So, start addresses of medium chunks are aligned to medium |
|
1616 |
// chunk size, those of small chunks to small chunk size and so |
|
1617 |
// forth. This facilitates merging of free chunks and reduces |
|
1618 |
// fragmentation. Chunk sizes are spec < small < medium, with each |
|
1619 |
// larger chunk size being a multiple of the next smaller chunk |
|
1620 |
// size. |
|
1621 |
// Because of this alignment, me may need to create a number of padding |
|
1622 |
// chunks. These chunks are created and added to the freelist. |
|
1623 |
||
1624 |
// The chunk manager to which we will give our padding chunks. |
|
1625 |
ChunkManager* const chunk_manager = Metaspace::get_chunk_manager(this->is_class()); |
|
1626 |
||
1627 |
// shorthands |
|
1628 |
const size_t spec_word_size = chunk_manager->specialized_chunk_word_size(); |
|
1629 |
const size_t small_word_size = chunk_manager->small_chunk_word_size(); |
|
1630 |
const size_t med_word_size = chunk_manager->medium_chunk_word_size(); |
|
1631 |
||
1632 |
assert(chunk_word_size == spec_word_size || chunk_word_size == small_word_size || |
|
1633 |
chunk_word_size >= med_word_size, "Invalid chunk size requested."); |
|
1634 |
||
1635 |
// Chunk alignment (in bytes) == chunk size unless humongous. |
|
1636 |
// Humongous chunks are aligned to the smallest chunk size (spec). |
|
1637 |
const size_t required_chunk_alignment = (chunk_word_size > med_word_size ? |
|
1638 |
spec_word_size : chunk_word_size) * sizeof(MetaWord); |
|
1639 |
||
1640 |
// Do we have enough space to create the requested chunk plus |
|
1641 |
// any padding chunks needed? |
|
1642 |
MetaWord* const next_aligned = |
|
1643 |
static_cast<MetaWord*>(align_up(top(), required_chunk_alignment)); |
|
1644 |
if (!is_available((next_aligned - top()) + chunk_word_size)) { |
|
1645 |
return NULL; |
|
1646 |
} |
|
1647 |
||
1648 |
// Before allocating the requested chunk, allocate padding chunks if necessary. |
|
1649 |
// We only need to do this for small or medium chunks: specialized chunks are the |
|
1650 |
// smallest size, hence always aligned. Homungous chunks are allocated unaligned |
|
1651 |
// (implicitly, also aligned to smallest chunk size). |
|
1652 |
if ((chunk_word_size == med_word_size || chunk_word_size == small_word_size) && next_aligned > top()) { |
|
1653 |
log_trace(gc, metaspace, freelist)("Creating padding chunks in %s between %p and %p...", |
|
1654 |
(is_class() ? "class space " : "metaspace"), |
|
1655 |
top(), next_aligned); |
|
1656 |
allocate_padding_chunks_until_top_is_at(next_aligned); |
|
1657 |
// Now, top should be aligned correctly. |
|
1658 |
assert_is_aligned(top(), required_chunk_alignment); |
|
1659 |
} |
|
1660 |
||
1661 |
// Now, top should be aligned correctly. |
|
1662 |
assert_is_aligned(top(), required_chunk_alignment); |
|
1663 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1664 |
// Bottom of the new chunk |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1665 |
MetaWord* chunk_limit = top(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1666 |
assert(chunk_limit != NULL, "Not safe to call this method"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1667 |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1668 |
// The virtual spaces are always expanded by the |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1669 |
// commit granularity to enforce the following condition. |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1670 |
// Without this the is_available check will not work correctly. |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1671 |
assert(_virtual_space.committed_size() == _virtual_space.actual_committed_size(), |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1672 |
"The committed memory doesn't match the expanded memory."); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1673 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1674 |
if (!is_available(chunk_word_size)) { |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46674
diff
changeset
|
1675 |
LogTarget(Debug, gc, metaspace, freelist) lt; |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46674
diff
changeset
|
1676 |
if (lt.is_enabled()) { |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46674
diff
changeset
|
1677 |
LogStream ls(lt); |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46674
diff
changeset
|
1678 |
ls.print("VirtualSpaceNode::take_from_committed() not available " SIZE_FORMAT " words ", chunk_word_size); |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46674
diff
changeset
|
1679 |
// Dump some information about the virtual space that is nearly full |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46674
diff
changeset
|
1680 |
print_on(&ls); |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46674
diff
changeset
|
1681 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1682 |
return NULL; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1683 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1684 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1685 |
// Take the space (bump top on the current virtual space). |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1686 |
inc_top(chunk_word_size); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1687 |
|
17101 | 1688 |
// Initialize the chunk |
49365 | 1689 |
ChunkIndex chunk_type = get_chunk_type_by_size(chunk_word_size, is_class()); |
1690 |
Metachunk* result = ::new (chunk_limit) Metachunk(chunk_type, is_class(), chunk_word_size, this); |
|
1691 |
assert(result == (Metachunk*)chunk_limit, "Sanity"); |
|
1692 |
occupancy_map()->set_chunk_starts_at_address((MetaWord*)result, true); |
|
1693 |
do_update_in_use_info_for_chunk(result, true); |
|
1694 |
||
1695 |
inc_container_count(); |
|
1696 |
||
49386
d89e98d85841
8199518: test/hotspot/jtreg/runtime/SelectionResolution tests take a lot longer to run with fastdebug after JDK-8198423
stuefe
parents:
49372
diff
changeset
|
1697 |
if (metaspace_slow_verify) { |
d89e98d85841
8199518: test/hotspot/jtreg/runtime/SelectionResolution tests take a lot longer to run with fastdebug after JDK-8198423
stuefe
parents:
49372
diff
changeset
|
1698 |
DEBUG_ONLY(chunk_manager->locked_verify()); |
d89e98d85841
8199518: test/hotspot/jtreg/runtime/SelectionResolution tests take a lot longer to run with fastdebug after JDK-8198423
stuefe
parents:
49372
diff
changeset
|
1699 |
DEBUG_ONLY(this->verify()); |
d89e98d85841
8199518: test/hotspot/jtreg/runtime/SelectionResolution tests take a lot longer to run with fastdebug after JDK-8198423
stuefe
parents:
49372
diff
changeset
|
1700 |
} |
d89e98d85841
8199518: test/hotspot/jtreg/runtime/SelectionResolution tests take a lot longer to run with fastdebug after JDK-8198423
stuefe
parents:
49372
diff
changeset
|
1701 |
|
49365 | 1702 |
DEBUG_ONLY(do_verify_chunk(result)); |
1703 |
||
1704 |
result->inc_use_count(); |
|
1705 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1706 |
return result; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1707 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1708 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1709 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1710 |
// Expand the virtual space (commit more of the reserved space) |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1711 |
bool VirtualSpaceNode::expand_by(size_t min_words, size_t preferred_words) { |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1712 |
size_t min_bytes = min_words * BytesPerWord; |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1713 |
size_t preferred_bytes = preferred_words * BytesPerWord; |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1714 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1715 |
size_t uncommitted = virtual_space()->reserved_size() - virtual_space()->actual_committed_size(); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1716 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1717 |
if (uncommitted < min_bytes) { |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1718 |
return false; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1719 |
} |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1720 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1721 |
size_t commit = MIN2(preferred_bytes, uncommitted); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1722 |
bool result = virtual_space()->expand_by(commit, false); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1723 |
|
49365 | 1724 |
if (result) { |
1725 |
log_trace(gc, metaspace, freelist)("Expanded %s virtual space list node by " SIZE_FORMAT " words.", |
|
1726 |
(is_class() ? "class" : "non-class"), commit); |
|
1727 |
} else { |
|
1728 |
log_trace(gc, metaspace, freelist)("Failed to expand %s virtual space list node by " SIZE_FORMAT " words.", |
|
1729 |
(is_class() ? "class" : "non-class"), commit); |
|
1730 |
} |
|
1731 |
||
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1732 |
assert(result, "Failed to commit memory"); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1733 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1734 |
return result; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1735 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1736 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1737 |
Metachunk* VirtualSpaceNode::get_chunk_vs(size_t chunk_word_size) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1738 |
assert_lock_strong(SpaceManager::expand_lock()); |
17101 | 1739 |
Metachunk* result = take_from_committed(chunk_word_size); |
1740 |
return result; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1741 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1742 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1743 |
bool VirtualSpaceNode::initialize() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1744 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1745 |
if (!_rs.is_reserved()) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1746 |
return false; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1747 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1748 |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1749 |
// These are necessary restriction to make sure that the virtual space always |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1750 |
// grows in steps of Metaspace::commit_alignment(). If both base and size are |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1751 |
// aligned only the middle alignment of the VirtualSpace is used. |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
1752 |
assert_is_aligned(_rs.base(), Metaspace::commit_alignment()); |
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
1753 |
assert_is_aligned(_rs.size(), Metaspace::commit_alignment()); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1754 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1755 |
// ReservedSpaces marked as special will have the entire memory |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1756 |
// pre-committed. Setting a committed size will make sure that |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1757 |
// committed_size and actual_committed_size agrees. |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1758 |
size_t pre_committed_size = _rs.special() ? _rs.size() : 0; |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1759 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1760 |
bool result = virtual_space()->initialize_with_granularity(_rs, pre_committed_size, |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1761 |
Metaspace::commit_alignment()); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1762 |
if (result) { |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1763 |
assert(virtual_space()->committed_size() == virtual_space()->actual_committed_size(), |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1764 |
"Checking that the pre-committed memory was registered by the VirtualSpace"); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1765 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1766 |
set_top((MetaWord*)virtual_space()->low()); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1767 |
set_reserved(MemRegion((HeapWord*)_rs.base(), |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1768 |
(HeapWord*)(_rs.base() + _rs.size()))); |
13729
3826a6124401
7195823: NPG: CMS reserved() doesn't match _rs.base().
coleenp
parents:
13728
diff
changeset
|
1769 |
|
3826a6124401
7195823: NPG: CMS reserved() doesn't match _rs.base().
coleenp
parents:
13728
diff
changeset
|
1770 |
assert(reserved()->start() == (HeapWord*) _rs.base(), |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
1771 |
"Reserved start was not set properly " PTR_FORMAT |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
1772 |
" != " PTR_FORMAT, p2i(reserved()->start()), p2i(_rs.base())); |
13729
3826a6124401
7195823: NPG: CMS reserved() doesn't match _rs.base().
coleenp
parents:
13728
diff
changeset
|
1773 |
assert(reserved()->word_size() == _rs.size() / BytesPerWord, |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
1774 |
"Reserved size was not set properly " SIZE_FORMAT |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
1775 |
" != " SIZE_FORMAT, reserved()->word_size(), |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
1776 |
_rs.size() / BytesPerWord); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1777 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1778 |
|
49365 | 1779 |
// Initialize Occupancy Map. |
1780 |
const size_t smallest_chunk_size = is_class() ? ClassSpecializedChunk : SpecializedChunk; |
|
1781 |
_occupancy_map = new OccupancyMap(bottom(), reserved_words(), smallest_chunk_size); |
|
1782 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1783 |
return result; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1784 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1785 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1786 |
void VirtualSpaceNode::print_on(outputStream* st) const { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1787 |
size_t used = used_words_in_vs(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1788 |
size_t capacity = capacity_words_in_vs(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1789 |
VirtualSpace* vs = virtual_space(); |
29800
fa5f7a2bf717
8076073: shared: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
29697
diff
changeset
|
1790 |
st->print_cr(" space @ " PTR_FORMAT " " SIZE_FORMAT "K, " SIZE_FORMAT_W(3) "%% used " |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1791 |
"[" PTR_FORMAT ", " PTR_FORMAT ", " |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1792 |
PTR_FORMAT ", " PTR_FORMAT ")", |
29800
fa5f7a2bf717
8076073: shared: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
29697
diff
changeset
|
1793 |
p2i(vs), capacity / K, |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
1794 |
capacity == 0 ? 0 : used * 100 / capacity, |
29800
fa5f7a2bf717
8076073: shared: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
29697
diff
changeset
|
1795 |
p2i(bottom()), p2i(top()), p2i(end()), |
fa5f7a2bf717
8076073: shared: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
29697
diff
changeset
|
1796 |
p2i(vs->high_boundary())); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1797 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1798 |
|
14588
8ec26d2d9339
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
14474
diff
changeset
|
1799 |
#ifdef ASSERT |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1800 |
void VirtualSpaceNode::mangle() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1801 |
size_t word_size = capacity_words_in_vs(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1802 |
Copy::fill_to_words((HeapWord*) low(), word_size, 0xf1f1f1f1); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1803 |
} |
14588
8ec26d2d9339
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
14474
diff
changeset
|
1804 |
#endif // ASSERT |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1805 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1806 |
// VirtualSpaceList methods |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1807 |
// Space allocated from the VirtualSpace |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1808 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1809 |
VirtualSpaceList::~VirtualSpaceList() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1810 |
VirtualSpaceListIterator iter(virtual_space_list()); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1811 |
while (iter.repeat()) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1812 |
VirtualSpaceNode* vsl = iter.get_next(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1813 |
delete vsl; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1814 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1815 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1816 |
|
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
1817 |
void VirtualSpaceList::inc_reserved_words(size_t v) { |
17101 | 1818 |
assert_lock_strong(SpaceManager::expand_lock()); |
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
1819 |
_reserved_words = _reserved_words + v; |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
1820 |
} |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
1821 |
void VirtualSpaceList::dec_reserved_words(size_t v) { |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
1822 |
assert_lock_strong(SpaceManager::expand_lock()); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
1823 |
_reserved_words = _reserved_words - v; |
17101 | 1824 |
} |
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
1825 |
|
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
1826 |
#define assert_committed_below_limit() \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
1827 |
assert(MetaspaceAux::committed_bytes() <= MaxMetaspaceSize, \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
1828 |
"Too much committed memory. Committed: " SIZE_FORMAT \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
1829 |
" limit (MaxMetaspaceSize): " SIZE_FORMAT, \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
1830 |
MetaspaceAux::committed_bytes(), MaxMetaspaceSize); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1831 |
|
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
1832 |
void VirtualSpaceList::inc_committed_words(size_t v) { |
17101 | 1833 |
assert_lock_strong(SpaceManager::expand_lock()); |
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
1834 |
_committed_words = _committed_words + v; |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1835 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1836 |
assert_committed_below_limit(); |
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
1837 |
} |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
1838 |
void VirtualSpaceList::dec_committed_words(size_t v) { |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
1839 |
assert_lock_strong(SpaceManager::expand_lock()); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
1840 |
_committed_words = _committed_words - v; |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1841 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1842 |
assert_committed_below_limit(); |
17101 | 1843 |
} |
1844 |
||
1845 |
void VirtualSpaceList::inc_virtual_space_count() { |
|
1846 |
assert_lock_strong(SpaceManager::expand_lock()); |
|
1847 |
_virtual_space_count++; |
|
1848 |
} |
|
1849 |
void VirtualSpaceList::dec_virtual_space_count() { |
|
1850 |
assert_lock_strong(SpaceManager::expand_lock()); |
|
1851 |
_virtual_space_count--; |
|
1852 |
} |
|
1853 |
||
1854 |
void ChunkManager::remove_chunk(Metachunk* chunk) { |
|
1855 |
size_t word_size = chunk->word_size(); |
|
1856 |
ChunkIndex index = list_index(word_size); |
|
1857 |
if (index != HumongousIndex) { |
|
1858 |
free_chunks(index)->remove_chunk(chunk); |
|
1859 |
} else { |
|
1860 |
humongous_dictionary()->remove_chunk(chunk); |
|
1861 |
} |
|
1862 |
||
46360
c753322134b0
8170520: Make Metaspace ChunkManager counters non-atomic
stuefe
parents:
46333
diff
changeset
|
1863 |
// Chunk has been removed from the chunks free list, update counters. |
c753322134b0
8170520: Make Metaspace ChunkManager counters non-atomic
stuefe
parents:
46333
diff
changeset
|
1864 |
account_for_removed_chunk(chunk); |
17101 | 1865 |
} |
1866 |
||
49365 | 1867 |
bool ChunkManager::attempt_to_coalesce_around_chunk(Metachunk* chunk, ChunkIndex target_chunk_type) { |
1868 |
assert_lock_strong(SpaceManager::expand_lock()); |
|
1869 |
assert(chunk != NULL, "invalid chunk pointer"); |
|
1870 |
// Check for valid merge combinations. |
|
1871 |
assert((chunk->get_chunk_type() == SpecializedIndex && |
|
1872 |
(target_chunk_type == SmallIndex || target_chunk_type == MediumIndex)) || |
|
1873 |
(chunk->get_chunk_type() == SmallIndex && target_chunk_type == MediumIndex), |
|
1874 |
"Invalid chunk merge combination."); |
|
1875 |
||
1876 |
const size_t target_chunk_word_size = |
|
1877 |
get_size_for_nonhumongous_chunktype(target_chunk_type, this->is_class()); |
|
1878 |
||
1879 |
// [ prospective merge region ) |
|
1880 |
MetaWord* const p_merge_region_start = |
|
1881 |
(MetaWord*) align_down(chunk, target_chunk_word_size * sizeof(MetaWord)); |
|
1882 |
MetaWord* const p_merge_region_end = |
|
1883 |
p_merge_region_start + target_chunk_word_size; |
|
1884 |
||
1885 |
// We need the VirtualSpaceNode containing this chunk and its occupancy map. |
|
1886 |
VirtualSpaceNode* const vsn = chunk->container(); |
|
1887 |
OccupancyMap* const ocmap = vsn->occupancy_map(); |
|
1888 |
||
1889 |
// The prospective chunk merge range must be completely contained by the |
|
1890 |
// committed range of the virtual space node. |
|
1891 |
if (p_merge_region_start < vsn->bottom() || p_merge_region_end > vsn->top()) { |
|
1892 |
return false; |
|
1893 |
} |
|
1894 |
||
1895 |
// Only attempt to merge this range if at its start a chunk starts and at its end |
|
1896 |
// a chunk ends. If a chunk (can only be humongous) straddles either start or end |
|
1897 |
// of that range, we cannot merge. |
|
1898 |
if (!ocmap->chunk_starts_at_address(p_merge_region_start)) { |
|
1899 |
return false; |
|
1900 |
} |
|
1901 |
if (p_merge_region_end < vsn->top() && |
|
1902 |
!ocmap->chunk_starts_at_address(p_merge_region_end)) { |
|
1903 |
return false; |
|
1904 |
} |
|
1905 |
||
1906 |
// Now check if the prospective merge area contains live chunks. If it does we cannot merge. |
|
1907 |
if (ocmap->is_region_in_use(p_merge_region_start, target_chunk_word_size)) { |
|
1908 |
return false; |
|
1909 |
} |
|
1910 |
||
1911 |
// Success! Remove all chunks in this region... |
|
1912 |
log_trace(gc, metaspace, freelist)("%s: coalescing chunks in area [%p-%p)...", |
|
1913 |
(is_class() ? "class space" : "metaspace"), |
|
1914 |
p_merge_region_start, p_merge_region_end); |
|
1915 |
||
1916 |
const int num_chunks_removed = |
|
1917 |
remove_chunks_in_area(p_merge_region_start, target_chunk_word_size); |
|
1918 |
||
1919 |
// ... and create a single new bigger chunk. |
|
1920 |
Metachunk* const p_new_chunk = |
|
1921 |
::new (p_merge_region_start) Metachunk(target_chunk_type, is_class(), target_chunk_word_size, vsn); |
|
1922 |
assert(p_new_chunk == (Metachunk*)p_merge_region_start, "Sanity"); |
|
1923 |
p_new_chunk->set_origin(origin_merge); |
|
1924 |
||
1925 |
log_trace(gc, metaspace, freelist)("%s: created coalesced chunk at %p, size " SIZE_FORMAT_HEX ".", |
|
1926 |
(is_class() ? "class space" : "metaspace"), |
|
1927 |
p_new_chunk, p_new_chunk->word_size() * sizeof(MetaWord)); |
|
1928 |
||
1929 |
// Fix occupancy map: remove old start bits of the small chunks and set new start bit. |
|
1930 |
ocmap->wipe_chunk_start_bits_in_region(p_merge_region_start, target_chunk_word_size); |
|
1931 |
ocmap->set_chunk_starts_at_address(p_merge_region_start, true); |
|
1932 |
||
1933 |
// Mark chunk as free. Note: it is not necessary to update the occupancy |
|
1934 |
// map in-use map, because the old chunks were also free, so nothing |
|
1935 |
// should have changed. |
|
1936 |
p_new_chunk->set_is_tagged_free(true); |
|
1937 |
||
1938 |
// Add new chunk to its freelist. |
|
1939 |
ChunkList* const list = free_chunks(target_chunk_type); |
|
1940 |
list->return_chunk_at_head(p_new_chunk); |
|
1941 |
||
1942 |
// And adjust ChunkManager:: _free_chunks_count (_free_chunks_total |
|
1943 |
// should not have changed, because the size of the space should be the same) |
|
1944 |
_free_chunks_count -= num_chunks_removed; |
|
1945 |
_free_chunks_count ++; |
|
1946 |
||
1947 |
// VirtualSpaceNode::container_count does not have to be modified: |
|
1948 |
// it means "number of active (non-free) chunks", so merging free chunks |
|
1949 |
// should not affect that count. |
|
1950 |
||
1951 |
// At the end of a chunk merge, run verification tests. |
|
49386
d89e98d85841
8199518: test/hotspot/jtreg/runtime/SelectionResolution tests take a lot longer to run with fastdebug after JDK-8198423
stuefe
parents:
49372
diff
changeset
|
1952 |
if (metaspace_slow_verify) { |
d89e98d85841
8199518: test/hotspot/jtreg/runtime/SelectionResolution tests take a lot longer to run with fastdebug after JDK-8198423
stuefe
parents:
49372
diff
changeset
|
1953 |
DEBUG_ONLY(this->locked_verify()); |
d89e98d85841
8199518: test/hotspot/jtreg/runtime/SelectionResolution tests take a lot longer to run with fastdebug after JDK-8198423
stuefe
parents:
49372
diff
changeset
|
1954 |
DEBUG_ONLY(vsn->verify()); |
d89e98d85841
8199518: test/hotspot/jtreg/runtime/SelectionResolution tests take a lot longer to run with fastdebug after JDK-8198423
stuefe
parents:
49372
diff
changeset
|
1955 |
} |
49365 | 1956 |
|
1957 |
return true; |
|
1958 |
} |
|
1959 |
||
1960 |
// Remove all chunks in the given area - the chunks are supposed to be free - |
|
1961 |
// from their corresponding freelists. Mark them as invalid. |
|
1962 |
// - This does not correct the occupancy map. |
|
1963 |
// - This does not adjust the counters in ChunkManager. |
|
1964 |
// - Does not adjust container count counter in containing VirtualSpaceNode |
|
1965 |
// Returns number of chunks removed. |
|
1966 |
int ChunkManager::remove_chunks_in_area(MetaWord* p, size_t word_size) { |
|
1967 |
assert(p != NULL && word_size > 0, "Invalid range."); |
|
1968 |
const size_t smallest_chunk_size = get_size_for_nonhumongous_chunktype(SpecializedIndex, is_class()); |
|
1969 |
assert_is_aligned(word_size, smallest_chunk_size); |
|
1970 |
||
1971 |
Metachunk* const start = (Metachunk*) p; |
|
1972 |
const Metachunk* const end = (Metachunk*)(p + word_size); |
|
1973 |
Metachunk* cur = start; |
|
1974 |
int num_removed = 0; |
|
1975 |
while (cur < end) { |
|
1976 |
Metachunk* next = (Metachunk*)(((MetaWord*)cur) + cur->word_size()); |
|
1977 |
DEBUG_ONLY(do_verify_chunk(cur)); |
|
1978 |
assert(cur->get_chunk_type() != HumongousIndex, "Unexpected humongous chunk found at %p.", cur); |
|
1979 |
assert(cur->is_tagged_free(), "Chunk expected to be free (%p)", cur); |
|
1980 |
log_trace(gc, metaspace, freelist)("%s: removing chunk %p, size " SIZE_FORMAT_HEX ".", |
|
1981 |
(is_class() ? "class space" : "metaspace"), |
|
1982 |
cur, cur->word_size() * sizeof(MetaWord)); |
|
1983 |
cur->remove_sentinel(); |
|
1984 |
// Note: cannot call ChunkManager::remove_chunk, because that |
|
1985 |
// modifies the counters in ChunkManager, which we do not want. So |
|
1986 |
// we call remove_chunk on the freelist directly (see also the |
|
1987 |
// splitting function which does the same). |
|
1988 |
ChunkList* const list = free_chunks(list_index(cur->word_size())); |
|
1989 |
list->remove_chunk(cur); |
|
1990 |
num_removed ++; |
|
1991 |
cur = next; |
|
1992 |
} |
|
1993 |
return num_removed; |
|
1994 |
} |
|
1995 |
||
17101 | 1996 |
// Walk the list of VirtualSpaceNodes and delete |
1997 |
// nodes with a 0 container_count. Remove Metachunks in |
|
1998 |
// the node from their respective freelists. |
|
20081
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
1999 |
void VirtualSpaceList::purge(ChunkManager* chunk_manager) { |
24457
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
2000 |
assert(SafepointSynchronize::is_at_safepoint(), "must be called at safepoint for contains to work"); |
17101 | 2001 |
assert_lock_strong(SpaceManager::expand_lock()); |
2002 |
// Don't use a VirtualSpaceListIterator because this |
|
2003 |
// list is being changed and a straightforward use of an iterator is not safe. |
|
2004 |
VirtualSpaceNode* purged_vsl = NULL; |
|
2005 |
VirtualSpaceNode* prev_vsl = virtual_space_list(); |
|
2006 |
VirtualSpaceNode* next_vsl = prev_vsl; |
|
2007 |
while (next_vsl != NULL) { |
|
2008 |
VirtualSpaceNode* vsl = next_vsl; |
|
36177
b2b76aba8e42
8149643: Remove check of counters in VirtualSpaceNode::inc_container_count
jmasa
parents:
35905
diff
changeset
|
2009 |
DEBUG_ONLY(vsl->verify_container_count();) |
17101 | 2010 |
next_vsl = vsl->next(); |
2011 |
// Don't free the current virtual space since it will likely |
|
2012 |
// be needed soon. |
|
2013 |
if (vsl->container_count() == 0 && vsl != current_virtual_space()) { |
|
49365 | 2014 |
log_trace(gc, metaspace, freelist)("Purging VirtualSpaceNode " PTR_FORMAT " (capacity: " SIZE_FORMAT |
2015 |
", used: " SIZE_FORMAT ").", p2i(vsl), vsl->capacity_words_in_vs(), vsl->used_words_in_vs()); |
|
17101 | 2016 |
// Unlink it from the list |
2017 |
if (prev_vsl == vsl) { |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2018 |
// This is the case of the current node being the first node. |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2019 |
assert(vsl == virtual_space_list(), "Expected to be the first node"); |
17101 | 2020 |
set_virtual_space_list(vsl->next()); |
2021 |
} else { |
|
2022 |
prev_vsl->set_next(vsl->next()); |
|
2023 |
} |
|
2024 |
||
20081
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
2025 |
vsl->purge(chunk_manager); |
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
2026 |
dec_reserved_words(vsl->reserved_words()); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
2027 |
dec_committed_words(vsl->committed_words()); |
17101 | 2028 |
dec_virtual_space_count(); |
2029 |
purged_vsl = vsl; |
|
2030 |
delete vsl; |
|
2031 |
} else { |
|
2032 |
prev_vsl = vsl; |
|
2033 |
} |
|
2034 |
} |
|
2035 |
#ifdef ASSERT |
|
2036 |
if (purged_vsl != NULL) { |
|
24457
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
2037 |
// List should be stable enough to use an iterator here. |
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
2038 |
VirtualSpaceListIterator iter(virtual_space_list()); |
17101 | 2039 |
while (iter.repeat()) { |
2040 |
VirtualSpaceNode* vsl = iter.get_next(); |
|
2041 |
assert(vsl != purged_vsl, "Purge of vsl failed"); |
|
2042 |
} |
|
2043 |
} |
|
2044 |
#endif |
|
2045 |
} |
|
2046 |
||
24457
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
2047 |
|
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
2048 |
// This function looks at the mmap regions in the metaspace without locking. |
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
2049 |
// The chunks are added with store ordering and not deleted except for at |
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
2050 |
// unloading time during a safepoint. |
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
2051 |
bool VirtualSpaceList::contains(const void* ptr) { |
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
2052 |
// List should be stable enough to use an iterator here because removing virtual |
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
2053 |
// space nodes is only allowed at a safepoint. |
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
2054 |
VirtualSpaceListIterator iter(virtual_space_list()); |
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
2055 |
while (iter.repeat()) { |
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
2056 |
VirtualSpaceNode* vsn = iter.get_next(); |
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
2057 |
if (vsn->contains(ptr)) { |
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
2058 |
return true; |
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
2059 |
} |
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
2060 |
} |
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
2061 |
return false; |
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
2062 |
} |
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
2063 |
|
21112
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
2064 |
void VirtualSpaceList::retire_current_virtual_space() { |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
2065 |
assert_lock_strong(SpaceManager::expand_lock()); |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
2066 |
|
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
2067 |
VirtualSpaceNode* vsn = current_virtual_space(); |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
2068 |
|
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
2069 |
ChunkManager* cm = is_class() ? Metaspace::chunk_manager_class() : |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
2070 |
Metaspace::chunk_manager_metadata(); |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
2071 |
|
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
2072 |
vsn->retire(cm); |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
2073 |
} |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
2074 |
|
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
2075 |
void VirtualSpaceNode::retire(ChunkManager* chunk_manager) { |
36177
b2b76aba8e42
8149643: Remove check of counters in VirtualSpaceNode::inc_container_count
jmasa
parents:
35905
diff
changeset
|
2076 |
DEBUG_ONLY(verify_container_count();) |
49365 | 2077 |
assert(this->is_class() == chunk_manager->is_class(), "Wrong ChunkManager?"); |
21112
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
2078 |
for (int i = (int)MediumIndex; i >= (int)ZeroIndex; --i) { |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
2079 |
ChunkIndex index = (ChunkIndex)i; |
46333
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
2080 |
size_t chunk_size = chunk_manager->size_by_index(index); |
21112
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
2081 |
|
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
2082 |
while (free_words_in_vs() >= chunk_size) { |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
2083 |
Metachunk* chunk = get_chunk_vs(chunk_size); |
49365 | 2084 |
// Chunk will be allocated aligned, so allocation may require |
2085 |
// additional padding chunks. That may cause above allocation to |
|
2086 |
// fail. Just ignore the failed allocation and continue with the |
|
2087 |
// next smaller chunk size. As the VirtualSpaceNode comitted |
|
2088 |
// size should be a multiple of the smallest chunk size, we |
|
2089 |
// should always be able to fill the VirtualSpace completely. |
|
2090 |
if (chunk == NULL) { |
|
2091 |
break; |
|
2092 |
} |
|
46333
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
2093 |
chunk_manager->return_single_chunk(index, chunk); |
21112
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
2094 |
} |
36177
b2b76aba8e42
8149643: Remove check of counters in VirtualSpaceNode::inc_container_count
jmasa
parents:
35905
diff
changeset
|
2095 |
DEBUG_ONLY(verify_container_count();) |
21112
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
2096 |
} |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
2097 |
assert(free_words_in_vs() == 0, "should be empty now"); |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
2098 |
} |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
2099 |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2100 |
VirtualSpaceList::VirtualSpaceList(size_t word_size) : |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2101 |
_is_class(false), |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2102 |
_virtual_space_list(NULL), |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2103 |
_current_virtual_space(NULL), |
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
2104 |
_reserved_words(0), |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
2105 |
_committed_words(0), |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2106 |
_virtual_space_count(0) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2107 |
MutexLockerEx cl(SpaceManager::expand_lock(), |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2108 |
Mutex::_no_safepoint_check_flag); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2109 |
create_new_virtual_space(word_size); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2110 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2111 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2112 |
VirtualSpaceList::VirtualSpaceList(ReservedSpace rs) : |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2113 |
_is_class(true), |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2114 |
_virtual_space_list(NULL), |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2115 |
_current_virtual_space(NULL), |
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
2116 |
_reserved_words(0), |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
2117 |
_committed_words(0), |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2118 |
_virtual_space_count(0) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2119 |
MutexLockerEx cl(SpaceManager::expand_lock(), |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2120 |
Mutex::_no_safepoint_check_flag); |
49365 | 2121 |
VirtualSpaceNode* class_entry = new VirtualSpaceNode(is_class(), rs); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2122 |
bool succeeded = class_entry->initialize(); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2123 |
if (succeeded) { |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2124 |
link_vs(class_entry); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2125 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2126 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2127 |
|
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
2128 |
size_t VirtualSpaceList::free_bytes() { |
47543
198cb8e20aef
8187331: VirtualSpaceList tracks free space on wrong node
zgu
parents:
47216
diff
changeset
|
2129 |
return current_virtual_space()->free_words_in_vs() * BytesPerWord; |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
2130 |
} |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
2131 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2132 |
// Allocate another meta virtual space and add it to the list. |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2133 |
bool VirtualSpaceList::create_new_virtual_space(size_t vs_word_size) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2134 |
assert_lock_strong(SpaceManager::expand_lock()); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2135 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2136 |
if (is_class()) { |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2137 |
assert(false, "We currently don't support more than one VirtualSpace for" |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2138 |
" the compressed class space. The initialization of the" |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2139 |
" CCS uses another code path and should not hit this path."); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2140 |
return false; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2141 |
} |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2142 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2143 |
if (vs_word_size == 0) { |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2144 |
assert(false, "vs_word_size should always be at least _reserve_alignment large."); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2145 |
return false; |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2146 |
} |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2147 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2148 |
// Reserve the space |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2149 |
size_t vs_byte_size = vs_word_size * BytesPerWord; |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
2150 |
assert_is_aligned(vs_byte_size, Metaspace::reserve_alignment()); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2151 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2152 |
// Allocate the meta virtual space and initialize it. |
49365 | 2153 |
VirtualSpaceNode* new_entry = new VirtualSpaceNode(is_class(), vs_byte_size); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2154 |
if (!new_entry->initialize()) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2155 |
delete new_entry; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2156 |
return false; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2157 |
} else { |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2158 |
assert(new_entry->reserved_words() == vs_word_size, |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2159 |
"Reserved memory size differs from requested memory size"); |
24457
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
2160 |
// ensure lock-free iteration sees fully initialized node |
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
2161 |
OrderAccess::storestore(); |
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
2162 |
link_vs(new_entry); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2163 |
return true; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2164 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2165 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2166 |
|
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
2167 |
void VirtualSpaceList::link_vs(VirtualSpaceNode* new_entry) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2168 |
if (virtual_space_list() == NULL) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2169 |
set_virtual_space_list(new_entry); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2170 |
} else { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2171 |
current_virtual_space()->set_next(new_entry); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2172 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2173 |
set_current_virtual_space(new_entry); |
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
2174 |
inc_reserved_words(new_entry->reserved_words()); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
2175 |
inc_committed_words(new_entry->committed_words()); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2176 |
inc_virtual_space_count(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2177 |
#ifdef ASSERT |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2178 |
new_entry->mangle(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2179 |
#endif |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46674
diff
changeset
|
2180 |
LogTarget(Trace, gc, metaspace) lt; |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46674
diff
changeset
|
2181 |
if (lt.is_enabled()) { |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46674
diff
changeset
|
2182 |
LogStream ls(lt); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2183 |
VirtualSpaceNode* vsl = current_virtual_space(); |
35061 | 2184 |
ResourceMark rm; |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46674
diff
changeset
|
2185 |
vsl->print_on(&ls); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2186 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2187 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2188 |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2189 |
bool VirtualSpaceList::expand_node_by(VirtualSpaceNode* node, |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2190 |
size_t min_words, |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2191 |
size_t preferred_words) { |
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
2192 |
size_t before = node->committed_words(); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
2193 |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2194 |
bool result = node->expand_by(min_words, preferred_words); |
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
2195 |
|
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
2196 |
size_t after = node->committed_words(); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
2197 |
|
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
2198 |
// after and before can be the same if the memory was pre-committed. |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2199 |
assert(after >= before, "Inconsistency"); |
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
2200 |
inc_committed_words(after - before); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
2201 |
|
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
2202 |
return result; |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
2203 |
} |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
2204 |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2205 |
bool VirtualSpaceList::expand_by(size_t min_words, size_t preferred_words) { |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
2206 |
assert_is_aligned(min_words, Metaspace::commit_alignment_words()); |
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
2207 |
assert_is_aligned(preferred_words, Metaspace::commit_alignment_words()); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2208 |
assert(min_words <= preferred_words, "Invalid arguments"); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2209 |
|
49365 | 2210 |
const char* const class_or_not = (is_class() ? "class" : "non-class"); |
2211 |
||
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2212 |
if (!MetaspaceGC::can_expand(min_words, this->is_class())) { |
49365 | 2213 |
log_trace(gc, metaspace, freelist)("Cannot expand %s virtual space list.", |
2214 |
class_or_not); |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2215 |
return false; |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2216 |
} |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2217 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2218 |
size_t allowed_expansion_words = MetaspaceGC::allowed_expansion(); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2219 |
if (allowed_expansion_words < min_words) { |
49365 | 2220 |
log_trace(gc, metaspace, freelist)("Cannot expand %s virtual space list (must try gc first).", |
2221 |
class_or_not); |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2222 |
return false; |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2223 |
} |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2224 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2225 |
size_t max_expansion_words = MIN2(preferred_words, allowed_expansion_words); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2226 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2227 |
// Commit more memory from the the current virtual space. |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2228 |
bool vs_expanded = expand_node_by(current_virtual_space(), |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2229 |
min_words, |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2230 |
max_expansion_words); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2231 |
if (vs_expanded) { |
49365 | 2232 |
log_trace(gc, metaspace, freelist)("Expanded %s virtual space list.", |
2233 |
class_or_not); |
|
2234 |
return true; |
|
2235 |
} |
|
2236 |
log_trace(gc, metaspace, freelist)("%s virtual space list: retire current node.", |
|
2237 |
class_or_not); |
|
21112
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
2238 |
retire_current_virtual_space(); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2239 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2240 |
// Get another virtual space. |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2241 |
size_t grow_vs_words = MAX2((size_t)VirtualSpaceSize, preferred_words); |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
2242 |
grow_vs_words = align_up(grow_vs_words, Metaspace::reserve_alignment_words()); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2243 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2244 |
if (create_new_virtual_space(grow_vs_words)) { |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2245 |
if (current_virtual_space()->is_pre_committed()) { |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2246 |
// The memory was pre-committed, so we are done here. |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2247 |
assert(min_words <= current_virtual_space()->committed_words(), |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2248 |
"The new VirtualSpace was pre-committed, so it" |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2249 |
"should be large enough to fit the alloc request."); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2250 |
return true; |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2251 |
} |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2252 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2253 |
return expand_node_by(current_virtual_space(), |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2254 |
min_words, |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2255 |
max_expansion_words); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2256 |
} |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2257 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2258 |
return false; |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2259 |
} |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2260 |
|
49365 | 2261 |
// Given a chunk, calculate the largest possible padding space which |
2262 |
// could be required when allocating it. |
|
2263 |
static size_t largest_possible_padding_size_for_chunk(size_t chunk_word_size, bool is_class) { |
|
2264 |
const ChunkIndex chunk_type = get_chunk_type_by_size(chunk_word_size, is_class); |
|
2265 |
if (chunk_type != HumongousIndex) { |
|
2266 |
// Normal, non-humongous chunks are allocated at chunk size |
|
2267 |
// boundaries, so the largest padding space required would be that |
|
2268 |
// minus the smallest chunk size. |
|
2269 |
const size_t smallest_chunk_size = is_class ? ClassSpecializedChunk : SpecializedChunk; |
|
2270 |
return chunk_word_size - smallest_chunk_size; |
|
2271 |
} else { |
|
2272 |
// Humongous chunks are allocated at smallest-chunksize |
|
2273 |
// boundaries, so there is no padding required. |
|
2274 |
return 0; |
|
2275 |
} |
|
2276 |
} |
|
2277 |
||
2278 |
||
42615
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
2279 |
Metachunk* VirtualSpaceList::get_new_chunk(size_t chunk_word_size, size_t suggested_commit_granularity) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2280 |
|
20081
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
2281 |
// Allocate a chunk out of the current virtual space. |
42615
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
2282 |
Metachunk* next = current_virtual_space()->get_chunk_vs(chunk_word_size); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2283 |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2284 |
if (next != NULL) { |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2285 |
return next; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2286 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2287 |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2288 |
// The expand amount is currently only determined by the requested sizes |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2289 |
// and not how much committed memory is left in the current virtual space. |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2290 |
|
49365 | 2291 |
// We must have enough space for the requested size and any |
2292 |
// additional reqired padding chunks. |
|
2293 |
const size_t size_for_padding = largest_possible_padding_size_for_chunk(chunk_word_size, this->is_class()); |
|
2294 |
||
2295 |
size_t min_word_size = align_up(chunk_word_size + size_for_padding, Metaspace::commit_alignment_words()); |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
2296 |
size_t preferred_word_size = align_up(suggested_commit_granularity, Metaspace::commit_alignment_words()); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2297 |
if (min_word_size >= preferred_word_size) { |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2298 |
// Can happen when humongous chunks are allocated. |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2299 |
preferred_word_size = min_word_size; |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2300 |
} |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2301 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2302 |
bool expanded = expand_by(min_word_size, preferred_word_size); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2303 |
if (expanded) { |
42615
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
2304 |
next = current_virtual_space()->get_chunk_vs(chunk_word_size); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2305 |
assert(next != NULL, "The allocation was expected to succeed after the expansion"); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2306 |
} |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2307 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2308 |
return next; |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
2309 |
} |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
2310 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2311 |
void VirtualSpaceList::print_on(outputStream* st) const { |
35061 | 2312 |
VirtualSpaceListIterator iter(virtual_space_list()); |
2313 |
while (iter.repeat()) { |
|
2314 |
VirtualSpaceNode* node = iter.get_next(); |
|
2315 |
node->print_on(st); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2316 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2317 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2318 |
|
47808
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
2319 |
void VirtualSpaceList::print_map(outputStream* st) const { |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
2320 |
VirtualSpaceNode* list = virtual_space_list(); |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
2321 |
VirtualSpaceListIterator iter(list); |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
2322 |
unsigned i = 0; |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
2323 |
while (iter.repeat()) { |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
2324 |
st->print_cr("Node %u:", i); |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
2325 |
VirtualSpaceNode* node = iter.get_next(); |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
2326 |
node->print_map(st, this->is_class()); |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
2327 |
i ++; |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
2328 |
} |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
2329 |
} |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
2330 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2331 |
// MetaspaceGC methods |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2332 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2333 |
// VM_CollectForMetadataAllocation is the vm operation used to GC. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2334 |
// Within the VM operation after the GC the attempt to allocate the metadata |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2335 |
// should succeed. If the GC did not free enough space for the metaspace |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2336 |
// allocation, the HWM is increased so that another virtualspace will be |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2337 |
// allocated for the metadata. With perm gen the increase in the perm |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2338 |
// gen had bounds, MinMetaspaceExpansion and MaxMetaspaceExpansion. The |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2339 |
// metaspace policy uses those as the small and large steps for the HWM. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2340 |
// |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2341 |
// After the GC the compute_new_size() for MetaspaceGC is called to |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2342 |
// resize the capacity of the metaspaces. The current implementation |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
2343 |
// is based on the flags MinMetaspaceFreeRatio and MaxMetaspaceFreeRatio used |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2344 |
// to resize the Java heap by some GC's. New flags can be implemented |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
2345 |
// if really needed. MinMetaspaceFreeRatio is used to calculate how much |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2346 |
// free space is desirable in the metaspace capacity to decide how much |
15610
528d799702c7
8005452: NPG: Create new flags for Metaspace resizing policy
jmasa
parents:
15488
diff
changeset
|
2347 |
// to increase the HWM. MaxMetaspaceFreeRatio is used to decide how much |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2348 |
// free space is desirable in the metaspace capacity before decreasing |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2349 |
// the HWM. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2350 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2351 |
// Calculate the amount to increase the high water mark (HWM). |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2352 |
// Increase by a minimum amount (MinMetaspaceExpansion) so that |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2353 |
// another expansion is not requested too soon. If that is not |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2354 |
// enough to satisfy the allocation, increase by MaxMetaspaceExpansion. |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2355 |
// If that is still not enough, expand by the size of the allocation |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2356 |
// plus some. |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2357 |
size_t MetaspaceGC::delta_capacity_until_GC(size_t bytes) { |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2358 |
size_t min_delta = MinMetaspaceExpansion; |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2359 |
size_t max_delta = MaxMetaspaceExpansion; |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
2360 |
size_t delta = align_up(bytes, Metaspace::commit_alignment()); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2361 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2362 |
if (delta <= min_delta) { |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2363 |
delta = min_delta; |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2364 |
} else if (delta <= max_delta) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2365 |
// Don't want to hit the high water mark on the next |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2366 |
// allocation so make the delta greater than just enough |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2367 |
// for this allocation. |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2368 |
delta = max_delta; |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2369 |
} else { |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2370 |
// This allocation is large but the next ones are probably not |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2371 |
// so increase by the minimum. |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2372 |
delta = delta + min_delta; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2373 |
} |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2374 |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
2375 |
assert_is_aligned(delta, Metaspace::commit_alignment()); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2376 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2377 |
return delta; |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2378 |
} |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2379 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2380 |
size_t MetaspaceGC::capacity_until_GC() { |
47634
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47599
diff
changeset
|
2381 |
size_t value = OrderAccess::load_acquire(&_capacity_until_GC); |
27693
3eee985a97e7
8059492: Wrong spelling in assert: "Not initialied properly?"
aharlap
parents:
27683
diff
changeset
|
2382 |
assert(value >= MetaspaceSize, "Not initialized properly?"); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2383 |
return value; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2384 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2385 |
|
26938
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
2386 |
bool MetaspaceGC::inc_capacity_until_GC(size_t v, size_t* new_cap_until_GC, size_t* old_cap_until_GC) { |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
2387 |
assert_is_aligned(v, Metaspace::commit_alignment()); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2388 |
|
47634
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47599
diff
changeset
|
2389 |
intptr_t capacity_until_GC = _capacity_until_GC; |
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47599
diff
changeset
|
2390 |
intptr_t new_value = capacity_until_GC + v; |
26938
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
2391 |
|
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
2392 |
if (new_value < capacity_until_GC) { |
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
2393 |
// The addition wrapped around, set new_value to aligned max value. |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
2394 |
new_value = align_down(max_uintx, Metaspace::commit_alignment()); |
26938
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
2395 |
} |
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
2396 |
|
47634
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47599
diff
changeset
|
2397 |
intptr_t expected = _capacity_until_GC; |
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47599
diff
changeset
|
2398 |
intptr_t actual = Atomic::cmpxchg(new_value, &_capacity_until_GC, expected); |
26938
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
2399 |
|
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
2400 |
if (expected != actual) { |
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
2401 |
return false; |
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
2402 |
} |
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
2403 |
|
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
2404 |
if (new_cap_until_GC != NULL) { |
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
2405 |
*new_cap_until_GC = new_value; |
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
2406 |
} |
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
2407 |
if (old_cap_until_GC != NULL) { |
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
2408 |
*old_cap_until_GC = capacity_until_GC; |
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
2409 |
} |
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
2410 |
return true; |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2411 |
} |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2412 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2413 |
size_t MetaspaceGC::dec_capacity_until_GC(size_t v) { |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
2414 |
assert_is_aligned(v, Metaspace::commit_alignment()); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2415 |
|
47634
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47599
diff
changeset
|
2416 |
return (size_t)Atomic::sub((intptr_t)v, &_capacity_until_GC); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2417 |
} |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2418 |
|
24847
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
2419 |
void MetaspaceGC::initialize() { |
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
2420 |
// Set the high-water mark to MaxMetapaceSize during VM initializaton since |
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
2421 |
// we can't do a GC during initialization. |
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
2422 |
_capacity_until_GC = MaxMetaspaceSize; |
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
2423 |
} |
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
2424 |
|
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
2425 |
void MetaspaceGC::post_initialize() { |
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
2426 |
// Reset the high-water mark once the VM initialization is done. |
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
2427 |
_capacity_until_GC = MAX2(MetaspaceAux::committed_bytes(), MetaspaceSize); |
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
2428 |
} |
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
2429 |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2430 |
bool MetaspaceGC::can_expand(size_t word_size, bool is_class) { |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2431 |
// Check if the compressed class space is full. |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2432 |
if (is_class && Metaspace::using_class_space()) { |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2433 |
size_t class_committed = MetaspaceAux::committed_bytes(Metaspace::ClassType); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2434 |
if (class_committed + word_size * BytesPerWord > CompressedClassSpaceSize) { |
49365 | 2435 |
log_trace(gc, metaspace, freelist)("Cannot expand %s metaspace by " SIZE_FORMAT " words (CompressedClassSpaceSize = " SIZE_FORMAT " words)", |
2436 |
(is_class ? "class" : "non-class"), word_size, CompressedClassSpaceSize / sizeof(MetaWord)); |
|
18491
dd63ba6b0ee4
8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents:
17858
diff
changeset
|
2437 |
return false; |
dd63ba6b0ee4
8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents:
17858
diff
changeset
|
2438 |
} |
16391
7bf8a7699f5f
8004241: NPG: Metaspace occupies more memory than specified by -XX:MaxMetaspaceSize option
mgerdin
parents:
16387
diff
changeset
|
2439 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2440 |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2441 |
// Check if the user has imposed a limit on the metaspace memory. |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2442 |
size_t committed_bytes = MetaspaceAux::committed_bytes(); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2443 |
if (committed_bytes + word_size * BytesPerWord > MaxMetaspaceSize) { |
49365 | 2444 |
log_trace(gc, metaspace, freelist)("Cannot expand %s metaspace by " SIZE_FORMAT " words (MaxMetaspaceSize = " SIZE_FORMAT " words)", |
2445 |
(is_class ? "class" : "non-class"), word_size, MaxMetaspaceSize / sizeof(MetaWord)); |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2446 |
return false; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2447 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2448 |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2449 |
return true; |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2450 |
} |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2451 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2452 |
size_t MetaspaceGC::allowed_expansion() { |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2453 |
size_t committed_bytes = MetaspaceAux::committed_bytes(); |
24847
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
2454 |
size_t capacity_until_gc = capacity_until_GC(); |
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
2455 |
|
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
2456 |
assert(capacity_until_gc >= committed_bytes, |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
2457 |
"capacity_until_gc: " SIZE_FORMAT " < committed_bytes: " SIZE_FORMAT, |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
2458 |
capacity_until_gc, committed_bytes); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2459 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2460 |
size_t left_until_max = MaxMetaspaceSize - committed_bytes; |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2461 |
size_t left_until_GC = capacity_until_gc - committed_bytes; |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2462 |
size_t left_to_commit = MIN2(left_until_GC, left_until_max); |
49365 | 2463 |
log_trace(gc, metaspace, freelist)("allowed expansion words: " SIZE_FORMAT |
2464 |
" (left_until_max: " SIZE_FORMAT ", left_until_GC: " SIZE_FORMAT ".", |
|
2465 |
left_to_commit / BytesPerWord, left_until_max / BytesPerWord, left_until_GC / BytesPerWord); |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2466 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2467 |
return left_to_commit / BytesPerWord; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2468 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2469 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2470 |
void MetaspaceGC::compute_new_size() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2471 |
assert(_shrink_factor <= 100, "invalid shrink factor"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2472 |
uint current_shrink_factor = _shrink_factor; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2473 |
_shrink_factor = 0; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2474 |
|
24847
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
2475 |
// Using committed_bytes() for used_after_gc is an overestimation, since the |
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
2476 |
// chunk free lists are included in committed_bytes() and the memory in an |
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
2477 |
// un-fragmented chunk free list is available for future allocations. |
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
2478 |
// However, if the chunk free lists becomes fragmented, then the memory may |
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
2479 |
// not be available for future allocations and the memory is therefore "in use". |
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
2480 |
// Including the chunk free lists in the definition of "in use" is therefore |
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
2481 |
// necessary. Not including the chunk free lists can cause capacity_until_GC to |
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
2482 |
// shrink below committed_bytes() and this has caused serious bugs in the past. |
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
2483 |
const size_t used_after_gc = MetaspaceAux::committed_bytes(); |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
2484 |
const size_t capacity_until_GC = MetaspaceGC::capacity_until_GC(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2485 |
|
15610
528d799702c7
8005452: NPG: Create new flags for Metaspace resizing policy
jmasa
parents:
15488
diff
changeset
|
2486 |
const double minimum_free_percentage = MinMetaspaceFreeRatio / 100.0; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2487 |
const double maximum_used_percentage = 1.0 - minimum_free_percentage; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2488 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2489 |
const double min_tmp = used_after_gc / maximum_used_percentage; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2490 |
size_t minimum_desired_capacity = |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2491 |
(size_t)MIN2(min_tmp, double(max_uintx)); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2492 |
// Don't shrink less than the initial generation size |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2493 |
minimum_desired_capacity = MAX2(minimum_desired_capacity, |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2494 |
MetaspaceSize); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2495 |
|
35061 | 2496 |
log_trace(gc, metaspace)("MetaspaceGC::compute_new_size: "); |
2497 |
log_trace(gc, metaspace)(" minimum_free_percentage: %6.2f maximum_used_percentage: %6.2f", |
|
2498 |
minimum_free_percentage, maximum_used_percentage); |
|
2499 |
log_trace(gc, metaspace)(" used_after_gc : %6.1fKB", used_after_gc / (double) K); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2500 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2501 |
|
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
2502 |
size_t shrink_bytes = 0; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2503 |
if (capacity_until_GC < minimum_desired_capacity) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2504 |
// If we have less capacity below the metaspace HWM, then |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2505 |
// increment the HWM. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2506 |
size_t expand_bytes = minimum_desired_capacity - capacity_until_GC; |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
2507 |
expand_bytes = align_up(expand_bytes, Metaspace::commit_alignment()); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2508 |
// Don't expand unless it's significant |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2509 |
if (expand_bytes >= MinMetaspaceExpansion) { |
26938
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
2510 |
size_t new_capacity_until_GC = 0; |
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
2511 |
bool succeeded = MetaspaceGC::inc_capacity_until_GC(expand_bytes, &new_capacity_until_GC); |
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
2512 |
assert(succeeded, "Should always succesfully increment HWM when at safepoint"); |
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
2513 |
|
23465
14790e4d53ec
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
22884
diff
changeset
|
2514 |
Metaspace::tracer()->report_gc_threshold(capacity_until_GC, |
14790e4d53ec
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
22884
diff
changeset
|
2515 |
new_capacity_until_GC, |
14790e4d53ec
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
22884
diff
changeset
|
2516 |
MetaspaceGCThresholdUpdater::ComputeNewSize); |
35061 | 2517 |
log_trace(gc, metaspace)(" expanding: minimum_desired_capacity: %6.1fKB expand_bytes: %6.1fKB MinMetaspaceExpansion: %6.1fKB new metaspace HWM: %6.1fKB", |
2518 |
minimum_desired_capacity / (double) K, |
|
2519 |
expand_bytes / (double) K, |
|
2520 |
MinMetaspaceExpansion / (double) K, |
|
2521 |
new_capacity_until_GC / (double) K); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2522 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2523 |
return; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2524 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2525 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2526 |
// No expansion, now see if we want to shrink |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2527 |
// We would never want to shrink more than this |
22499 | 2528 |
assert(capacity_until_GC >= minimum_desired_capacity, |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
2529 |
SIZE_FORMAT " >= " SIZE_FORMAT, |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
2530 |
capacity_until_GC, minimum_desired_capacity); |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
2531 |
size_t max_shrink_bytes = capacity_until_GC - minimum_desired_capacity; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2532 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2533 |
// Should shrinking be considered? |
15610
528d799702c7
8005452: NPG: Create new flags for Metaspace resizing policy
jmasa
parents:
15488
diff
changeset
|
2534 |
if (MaxMetaspaceFreeRatio < 100) { |
528d799702c7
8005452: NPG: Create new flags for Metaspace resizing policy
jmasa
parents:
15488
diff
changeset
|
2535 |
const double maximum_free_percentage = MaxMetaspaceFreeRatio / 100.0; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2536 |
const double minimum_used_percentage = 1.0 - maximum_free_percentage; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2537 |
const double max_tmp = used_after_gc / minimum_used_percentage; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2538 |
size_t maximum_desired_capacity = (size_t)MIN2(max_tmp, double(max_uintx)); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2539 |
maximum_desired_capacity = MAX2(maximum_desired_capacity, |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2540 |
MetaspaceSize); |
35061 | 2541 |
log_trace(gc, metaspace)(" maximum_free_percentage: %6.2f minimum_used_percentage: %6.2f", |
2542 |
maximum_free_percentage, minimum_used_percentage); |
|
2543 |
log_trace(gc, metaspace)(" minimum_desired_capacity: %6.1fKB maximum_desired_capacity: %6.1fKB", |
|
2544 |
minimum_desired_capacity / (double) K, maximum_desired_capacity / (double) K); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2545 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2546 |
assert(minimum_desired_capacity <= maximum_desired_capacity, |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2547 |
"sanity check"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2548 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2549 |
if (capacity_until_GC > maximum_desired_capacity) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2550 |
// Capacity too large, compute shrinking size |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
2551 |
shrink_bytes = capacity_until_GC - maximum_desired_capacity; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2552 |
// We don't want shrink all the way back to initSize if people call |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2553 |
// System.gc(), because some programs do that between "phases" and then |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2554 |
// we'd just have to grow the heap up again for the next phase. So we |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2555 |
// damp the shrinking: 0% on the first call, 10% on the second call, 40% |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2556 |
// on the third call, and 100% by the fourth call. But if we recompute |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2557 |
// size without shrinking, it goes back to 0%. |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
2558 |
shrink_bytes = shrink_bytes / 100 * current_shrink_factor; |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2559 |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
2560 |
shrink_bytes = align_down(shrink_bytes, Metaspace::commit_alignment()); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2561 |
|
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
2562 |
assert(shrink_bytes <= max_shrink_bytes, |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
2563 |
"invalid shrink size " SIZE_FORMAT " not <= " SIZE_FORMAT, |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
2564 |
shrink_bytes, max_shrink_bytes); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2565 |
if (current_shrink_factor == 0) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2566 |
_shrink_factor = 10; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2567 |
} else { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2568 |
_shrink_factor = MIN2(current_shrink_factor * 4, (uint) 100); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2569 |
} |
37151
bcda1fb89431
8151845: Comment in globals.hpp for MetaspaceSize is incorrect.
jmasa
parents:
37139
diff
changeset
|
2570 |
log_trace(gc, metaspace)(" shrinking: initThreshold: %.1fK maximum_desired_capacity: %.1fK", |
35061 | 2571 |
MetaspaceSize / (double) K, maximum_desired_capacity / (double) K); |
2572 |
log_trace(gc, metaspace)(" shrink_bytes: %.1fK current_shrink_factor: %d new shrink factor: %d MinMetaspaceExpansion: %.1fK", |
|
2573 |
shrink_bytes / (double) K, current_shrink_factor, _shrink_factor, MinMetaspaceExpansion / (double) K); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2574 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2575 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2576 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2577 |
// Don't shrink unless it's significant |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
2578 |
if (shrink_bytes >= MinMetaspaceExpansion && |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
2579 |
((capacity_until_GC - shrink_bytes) >= MetaspaceSize)) { |
23465
14790e4d53ec
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
22884
diff
changeset
|
2580 |
size_t new_capacity_until_GC = MetaspaceGC::dec_capacity_until_GC(shrink_bytes); |
14790e4d53ec
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
22884
diff
changeset
|
2581 |
Metaspace::tracer()->report_gc_threshold(capacity_until_GC, |
14790e4d53ec
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
22884
diff
changeset
|
2582 |
new_capacity_until_GC, |
14790e4d53ec
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
22884
diff
changeset
|
2583 |
MetaspaceGCThresholdUpdater::ComputeNewSize); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2584 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2585 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2586 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2587 |
// Metadebug methods |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2588 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2589 |
void Metadebug::init_allocation_fail_alot_count() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2590 |
if (MetadataAllocationFailALot) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2591 |
_allocation_fail_alot_count = |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2592 |
1+(long)((double)MetadataAllocationFailALotInterval*os::random()/(max_jint+1.0)); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2593 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2594 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2595 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2596 |
#ifdef ASSERT |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2597 |
bool Metadebug::test_metadata_failure() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2598 |
if (MetadataAllocationFailALot && |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2599 |
Threads::is_vm_complete()) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2600 |
if (_allocation_fail_alot_count > 0) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2601 |
_allocation_fail_alot_count--; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2602 |
} else { |
35061 | 2603 |
log_trace(gc, metaspace, freelist)("Metadata allocation failing for MetadataAllocationFailALot"); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2604 |
init_allocation_fail_alot_count(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2605 |
return true; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2606 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2607 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2608 |
return false; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2609 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2610 |
#endif |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2611 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2612 |
// ChunkManager methods |
19988 | 2613 |
size_t ChunkManager::free_chunks_total_words() { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2614 |
return _free_chunks_total; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2615 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2616 |
|
19988 | 2617 |
size_t ChunkManager::free_chunks_total_bytes() { |
2618 |
return free_chunks_total_words() * BytesPerWord; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2619 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2620 |
|
46360
c753322134b0
8170520: Make Metaspace ChunkManager counters non-atomic
stuefe
parents:
46333
diff
changeset
|
2621 |
// Update internal accounting after a chunk was added |
c753322134b0
8170520: Make Metaspace ChunkManager counters non-atomic
stuefe
parents:
46333
diff
changeset
|
2622 |
void ChunkManager::account_for_added_chunk(const Metachunk* c) { |
c753322134b0
8170520: Make Metaspace ChunkManager counters non-atomic
stuefe
parents:
46333
diff
changeset
|
2623 |
assert_lock_strong(SpaceManager::expand_lock()); |
c753322134b0
8170520: Make Metaspace ChunkManager counters non-atomic
stuefe
parents:
46333
diff
changeset
|
2624 |
_free_chunks_count ++; |
c753322134b0
8170520: Make Metaspace ChunkManager counters non-atomic
stuefe
parents:
46333
diff
changeset
|
2625 |
_free_chunks_total += c->word_size(); |
c753322134b0
8170520: Make Metaspace ChunkManager counters non-atomic
stuefe
parents:
46333
diff
changeset
|
2626 |
} |
c753322134b0
8170520: Make Metaspace ChunkManager counters non-atomic
stuefe
parents:
46333
diff
changeset
|
2627 |
|
c753322134b0
8170520: Make Metaspace ChunkManager counters non-atomic
stuefe
parents:
46333
diff
changeset
|
2628 |
// Update internal accounting after a chunk was removed |
c753322134b0
8170520: Make Metaspace ChunkManager counters non-atomic
stuefe
parents:
46333
diff
changeset
|
2629 |
void ChunkManager::account_for_removed_chunk(const Metachunk* c) { |
c753322134b0
8170520: Make Metaspace ChunkManager counters non-atomic
stuefe
parents:
46333
diff
changeset
|
2630 |
assert_lock_strong(SpaceManager::expand_lock()); |
c753322134b0
8170520: Make Metaspace ChunkManager counters non-atomic
stuefe
parents:
46333
diff
changeset
|
2631 |
assert(_free_chunks_count >= 1, |
c753322134b0
8170520: Make Metaspace ChunkManager counters non-atomic
stuefe
parents:
46333
diff
changeset
|
2632 |
"ChunkManager::_free_chunks_count: about to go negative (" SIZE_FORMAT ").", _free_chunks_count); |
c753322134b0
8170520: Make Metaspace ChunkManager counters non-atomic
stuefe
parents:
46333
diff
changeset
|
2633 |
assert(_free_chunks_total >= c->word_size(), |
c753322134b0
8170520: Make Metaspace ChunkManager counters non-atomic
stuefe
parents:
46333
diff
changeset
|
2634 |
"ChunkManager::_free_chunks_total: about to go negative" |
c753322134b0
8170520: Make Metaspace ChunkManager counters non-atomic
stuefe
parents:
46333
diff
changeset
|
2635 |
"(now: " SIZE_FORMAT ", decrement value: " SIZE_FORMAT ").", _free_chunks_total, c->word_size()); |
c753322134b0
8170520: Make Metaspace ChunkManager counters non-atomic
stuefe
parents:
46333
diff
changeset
|
2636 |
_free_chunks_count --; |
c753322134b0
8170520: Make Metaspace ChunkManager counters non-atomic
stuefe
parents:
46333
diff
changeset
|
2637 |
_free_chunks_total -= c->word_size(); |
c753322134b0
8170520: Make Metaspace ChunkManager counters non-atomic
stuefe
parents:
46333
diff
changeset
|
2638 |
} |
c753322134b0
8170520: Make Metaspace ChunkManager counters non-atomic
stuefe
parents:
46333
diff
changeset
|
2639 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2640 |
size_t ChunkManager::free_chunks_count() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2641 |
#ifdef ASSERT |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2642 |
if (!UseConcMarkSweepGC && !SpaceManager::expand_lock()->is_locked()) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2643 |
MutexLockerEx cl(SpaceManager::expand_lock(), |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2644 |
Mutex::_no_safepoint_check_flag); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2645 |
// This lock is only needed in debug because the verification |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2646 |
// of the _free_chunks_totals walks the list of free chunks |
14474
4154f1817a75
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
14123
diff
changeset
|
2647 |
slow_locked_verify_free_chunks_count(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2648 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2649 |
#endif |
14474
4154f1817a75
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
14123
diff
changeset
|
2650 |
return _free_chunks_count; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2651 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2652 |
|
46333
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
2653 |
ChunkIndex ChunkManager::list_index(size_t size) { |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
2654 |
if (size_by_index(SpecializedIndex) == size) { |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
2655 |
return SpecializedIndex; |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
2656 |
} |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
2657 |
if (size_by_index(SmallIndex) == size) { |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
2658 |
return SmallIndex; |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
2659 |
} |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
2660 |
const size_t med_size = size_by_index(MediumIndex); |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
2661 |
if (med_size == size) { |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
2662 |
return MediumIndex; |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
2663 |
} |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
2664 |
|
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
2665 |
assert(size > med_size, "Not a humongous chunk"); |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
2666 |
return HumongousIndex; |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
2667 |
} |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
2668 |
|
46709
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
2669 |
size_t ChunkManager::size_by_index(ChunkIndex index) const { |
46333
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
2670 |
index_bounds_check(index); |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
2671 |
assert(index != HumongousIndex, "Do not call for humongous chunks."); |
46709
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
2672 |
return _free_chunks[index].size(); |
46333
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
2673 |
} |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
2674 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2675 |
void ChunkManager::locked_verify_free_chunks_total() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2676 |
assert_lock_strong(SpaceManager::expand_lock()); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2677 |
assert(sum_free_chunks() == _free_chunks_total, |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
2678 |
"_free_chunks_total " SIZE_FORMAT " is not the" |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
2679 |
" same as sum " SIZE_FORMAT, _free_chunks_total, |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
2680 |
sum_free_chunks()); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2681 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2682 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2683 |
void ChunkManager::verify_free_chunks_total() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2684 |
MutexLockerEx cl(SpaceManager::expand_lock(), |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2685 |
Mutex::_no_safepoint_check_flag); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2686 |
locked_verify_free_chunks_total(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2687 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2688 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2689 |
void ChunkManager::locked_verify_free_chunks_count() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2690 |
assert_lock_strong(SpaceManager::expand_lock()); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2691 |
assert(sum_free_chunks_count() == _free_chunks_count, |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
2692 |
"_free_chunks_count " SIZE_FORMAT " is not the" |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
2693 |
" same as sum " SIZE_FORMAT, _free_chunks_count, |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
2694 |
sum_free_chunks_count()); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2695 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2696 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2697 |
void ChunkManager::verify_free_chunks_count() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2698 |
#ifdef ASSERT |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2699 |
MutexLockerEx cl(SpaceManager::expand_lock(), |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2700 |
Mutex::_no_safepoint_check_flag); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2701 |
locked_verify_free_chunks_count(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2702 |
#endif |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2703 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2704 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2705 |
void ChunkManager::verify() { |
14474
4154f1817a75
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
14123
diff
changeset
|
2706 |
MutexLockerEx cl(SpaceManager::expand_lock(), |
4154f1817a75
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
14123
diff
changeset
|
2707 |
Mutex::_no_safepoint_check_flag); |
4154f1817a75
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
14123
diff
changeset
|
2708 |
locked_verify(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2709 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2710 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2711 |
void ChunkManager::locked_verify() { |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
2712 |
locked_verify_free_chunks_count(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2713 |
locked_verify_free_chunks_total(); |
49365 | 2714 |
for (ChunkIndex i = ZeroIndex; i < NumberOfFreeLists; i = next_chunk_index(i)) { |
2715 |
ChunkList* list = free_chunks(i); |
|
2716 |
if (list != NULL) { |
|
2717 |
Metachunk* chunk = list->head(); |
|
2718 |
while (chunk) { |
|
2719 |
DEBUG_ONLY(do_verify_chunk(chunk);) |
|
2720 |
assert(chunk->is_tagged_free(), "Chunk should be tagged as free."); |
|
2721 |
chunk = chunk->next(); |
|
2722 |
} |
|
2723 |
} |
|
2724 |
} |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2725 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2726 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2727 |
void ChunkManager::locked_print_free_chunks(outputStream* st) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2728 |
assert_lock_strong(SpaceManager::expand_lock()); |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
2729 |
st->print_cr("Free chunk total " SIZE_FORMAT " count " SIZE_FORMAT, |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2730 |
_free_chunks_total, _free_chunks_count); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2731 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2732 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2733 |
void ChunkManager::locked_print_sum_free_chunks(outputStream* st) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2734 |
assert_lock_strong(SpaceManager::expand_lock()); |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
2735 |
st->print_cr("Sum free chunk total " SIZE_FORMAT " count " SIZE_FORMAT, |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2736 |
sum_free_chunks(), sum_free_chunks_count()); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2737 |
} |
42621
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
2738 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2739 |
ChunkList* ChunkManager::free_chunks(ChunkIndex index) { |
42621
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
2740 |
assert(index == SpecializedIndex || index == SmallIndex || index == MediumIndex, |
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
2741 |
"Bad index: %d", (int)index); |
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
2742 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2743 |
return &_free_chunks[index]; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2744 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2745 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2746 |
// These methods that sum the free chunk lists are used in printing |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2747 |
// methods that are used in product builds. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2748 |
size_t ChunkManager::sum_free_chunks() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2749 |
assert_lock_strong(SpaceManager::expand_lock()); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2750 |
size_t result = 0; |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
2751 |
for (ChunkIndex i = ZeroIndex; i < NumberOfFreeLists; i = next_chunk_index(i)) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2752 |
ChunkList* list = free_chunks(i); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2753 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2754 |
if (list == NULL) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2755 |
continue; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2756 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2757 |
|
16996
e699388c6dd8
8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents:
16439
diff
changeset
|
2758 |
result = result + list->count() * list->size(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2759 |
} |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
2760 |
result = result + humongous_dictionary()->total_size(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2761 |
return result; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2762 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2763 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2764 |
size_t ChunkManager::sum_free_chunks_count() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2765 |
assert_lock_strong(SpaceManager::expand_lock()); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2766 |
size_t count = 0; |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
2767 |
for (ChunkIndex i = ZeroIndex; i < NumberOfFreeLists; i = next_chunk_index(i)) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2768 |
ChunkList* list = free_chunks(i); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2769 |
if (list == NULL) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2770 |
continue; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2771 |
} |
16996
e699388c6dd8
8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents:
16439
diff
changeset
|
2772 |
count = count + list->count(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2773 |
} |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
2774 |
count = count + humongous_dictionary()->total_free_blocks(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2775 |
return count; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2776 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2777 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2778 |
ChunkList* ChunkManager::find_free_chunks_list(size_t word_size) { |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
2779 |
ChunkIndex index = list_index(word_size); |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
2780 |
assert(index < HumongousIndex, "No humongous list"); |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
2781 |
return free_chunks(index); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2782 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2783 |
|
49365 | 2784 |
// Helper for chunk splitting: given a target chunk size and a larger free chunk, |
2785 |
// split up the larger chunk into n smaller chunks, at least one of which should be |
|
2786 |
// the target chunk of target chunk size. The smaller chunks, including the target |
|
2787 |
// chunk, are returned to the freelist. The pointer to the target chunk is returned. |
|
2788 |
// Note that this chunk is supposed to be removed from the freelist right away. |
|
2789 |
Metachunk* ChunkManager::split_chunk(size_t target_chunk_word_size, Metachunk* larger_chunk) { |
|
2790 |
assert(larger_chunk->word_size() > target_chunk_word_size, "Sanity"); |
|
2791 |
||
2792 |
const ChunkIndex larger_chunk_index = larger_chunk->get_chunk_type(); |
|
2793 |
const ChunkIndex target_chunk_index = get_chunk_type_by_size(target_chunk_word_size, is_class()); |
|
2794 |
||
2795 |
MetaWord* const region_start = (MetaWord*)larger_chunk; |
|
2796 |
const size_t region_word_len = larger_chunk->word_size(); |
|
2797 |
MetaWord* const region_end = region_start + region_word_len; |
|
2798 |
VirtualSpaceNode* const vsn = larger_chunk->container(); |
|
2799 |
OccupancyMap* const ocmap = vsn->occupancy_map(); |
|
2800 |
||
2801 |
// Any larger non-humongous chunk size is a multiple of any smaller chunk size. |
|
2802 |
// Since non-humongous chunks are aligned to their chunk size, the larger chunk should start |
|
2803 |
// at an address suitable to place the smaller target chunk. |
|
2804 |
assert_is_aligned(region_start, target_chunk_word_size); |
|
2805 |
||
2806 |
// Remove old chunk. |
|
2807 |
free_chunks(larger_chunk_index)->remove_chunk(larger_chunk); |
|
2808 |
larger_chunk->remove_sentinel(); |
|
2809 |
||
2810 |
// Prevent access to the old chunk from here on. |
|
2811 |
larger_chunk = NULL; |
|
2812 |
// ... and wipe it. |
|
2813 |
DEBUG_ONLY(memset(region_start, 0xfe, region_word_len * BytesPerWord)); |
|
2814 |
||
2815 |
// In its place create first the target chunk... |
|
2816 |
MetaWord* p = region_start; |
|
2817 |
Metachunk* target_chunk = ::new (p) Metachunk(target_chunk_index, is_class(), target_chunk_word_size, vsn); |
|
2818 |
assert(target_chunk == (Metachunk*)p, "Sanity"); |
|
2819 |
target_chunk->set_origin(origin_split); |
|
2820 |
||
2821 |
// Note: we do not need to mark its start in the occupancy map |
|
2822 |
// because it coincides with the old chunk start. |
|
2823 |
||
2824 |
// Mark chunk as free and return to the freelist. |
|
2825 |
do_update_in_use_info_for_chunk(target_chunk, false); |
|
2826 |
free_chunks(target_chunk_index)->return_chunk_at_head(target_chunk); |
|
2827 |
||
2828 |
// This chunk should now be valid and can be verified. |
|
2829 |
DEBUG_ONLY(do_verify_chunk(target_chunk)); |
|
2830 |
||
2831 |
// In the remaining space create the remainder chunks. |
|
2832 |
p += target_chunk->word_size(); |
|
2833 |
assert(p < region_end, "Sanity"); |
|
2834 |
||
2835 |
while (p < region_end) { |
|
2836 |
||
2837 |
// Find the largest chunk size which fits the alignment requirements at address p. |
|
2838 |
ChunkIndex this_chunk_index = prev_chunk_index(larger_chunk_index); |
|
2839 |
size_t this_chunk_word_size = 0; |
|
2840 |
for(;;) { |
|
2841 |
this_chunk_word_size = get_size_for_nonhumongous_chunktype(this_chunk_index, is_class()); |
|
2842 |
if (is_aligned(p, this_chunk_word_size * BytesPerWord)) { |
|
2843 |
break; |
|
2844 |
} else { |
|
2845 |
this_chunk_index = prev_chunk_index(this_chunk_index); |
|
2846 |
assert(this_chunk_index >= target_chunk_index, "Sanity"); |
|
2847 |
} |
|
2848 |
} |
|
2849 |
||
2850 |
assert(this_chunk_word_size >= target_chunk_word_size, "Sanity"); |
|
2851 |
assert(is_aligned(p, this_chunk_word_size * BytesPerWord), "Sanity"); |
|
2852 |
assert(p + this_chunk_word_size <= region_end, "Sanity"); |
|
2853 |
||
2854 |
// Create splitting chunk. |
|
2855 |
Metachunk* this_chunk = ::new (p) Metachunk(this_chunk_index, is_class(), this_chunk_word_size, vsn); |
|
2856 |
assert(this_chunk == (Metachunk*)p, "Sanity"); |
|
2857 |
this_chunk->set_origin(origin_split); |
|
2858 |
ocmap->set_chunk_starts_at_address(p, true); |
|
2859 |
do_update_in_use_info_for_chunk(this_chunk, false); |
|
2860 |
||
2861 |
// This chunk should be valid and can be verified. |
|
2862 |
DEBUG_ONLY(do_verify_chunk(this_chunk)); |
|
2863 |
||
2864 |
// Return this chunk to freelist and correct counter. |
|
2865 |
free_chunks(this_chunk_index)->return_chunk_at_head(this_chunk); |
|
2866 |
_free_chunks_count ++; |
|
2867 |
||
2868 |
log_trace(gc, metaspace, freelist)("Created chunk at " PTR_FORMAT ", word size " |
|
2869 |
SIZE_FORMAT_HEX " (%s), in split region [" PTR_FORMAT "..." PTR_FORMAT ").", |
|
2870 |
p2i(this_chunk), this_chunk->word_size(), chunk_size_name(this_chunk_index), |
|
2871 |
p2i(region_start), p2i(region_end)); |
|
2872 |
||
2873 |
p += this_chunk_word_size; |
|
2874 |
||
2875 |
} |
|
2876 |
||
2877 |
return target_chunk; |
|
2878 |
} |
|
2879 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2880 |
Metachunk* ChunkManager::free_chunks_get(size_t word_size) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2881 |
assert_lock_strong(SpaceManager::expand_lock()); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2882 |
|
14474
4154f1817a75
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
14123
diff
changeset
|
2883 |
slow_locked_verify(); |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
2884 |
|
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
2885 |
Metachunk* chunk = NULL; |
49365 | 2886 |
bool we_did_split_a_chunk = false; |
2887 |
||
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
2888 |
if (list_index(word_size) != HumongousIndex) { |
49365 | 2889 |
|
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
2890 |
ChunkList* free_list = find_free_chunks_list(word_size); |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
2891 |
assert(free_list != NULL, "Sanity check"); |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
2892 |
|
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
2893 |
chunk = free_list->head(); |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
2894 |
|
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
2895 |
if (chunk == NULL) { |
49365 | 2896 |
// Split large chunks into smaller chunks if there are no smaller chunks, just large chunks. |
2897 |
// This is the counterpart of the coalescing-upon-chunk-return. |
|
2898 |
||
2899 |
ChunkIndex target_chunk_index = get_chunk_type_by_size(word_size, is_class()); |
|
2900 |
||
2901 |
// Is there a larger chunk we could split? |
|
2902 |
Metachunk* larger_chunk = NULL; |
|
2903 |
ChunkIndex larger_chunk_index = next_chunk_index(target_chunk_index); |
|
2904 |
while (larger_chunk == NULL && larger_chunk_index < NumberOfFreeLists) { |
|
2905 |
larger_chunk = free_chunks(larger_chunk_index)->head(); |
|
2906 |
if (larger_chunk == NULL) { |
|
2907 |
larger_chunk_index = next_chunk_index(larger_chunk_index); |
|
2908 |
} |
|
2909 |
} |
|
2910 |
||
2911 |
if (larger_chunk != NULL) { |
|
2912 |
assert(larger_chunk->word_size() > word_size, "Sanity"); |
|
2913 |
assert(larger_chunk->get_chunk_type() == larger_chunk_index, "Sanity"); |
|
2914 |
||
2915 |
// We found a larger chunk. Lets split it up: |
|
2916 |
// - remove old chunk |
|
2917 |
// - in its place, create new smaller chunks, with at least one chunk |
|
2918 |
// being of target size, the others sized as large as possible. This |
|
2919 |
// is to make sure the resulting chunks are "as coalesced as possible" |
|
2920 |
// (similar to VirtualSpaceNode::retire()). |
|
2921 |
// Note: during this operation both ChunkManager and VirtualSpaceNode |
|
2922 |
// are temporarily invalid, so be careful with asserts. |
|
2923 |
||
2924 |
log_trace(gc, metaspace, freelist)("%s: splitting chunk " PTR_FORMAT |
|
2925 |
", word size " SIZE_FORMAT_HEX " (%s), to get a chunk of word size " SIZE_FORMAT_HEX " (%s)...", |
|
2926 |
(is_class() ? "class space" : "metaspace"), p2i(larger_chunk), larger_chunk->word_size(), |
|
2927 |
chunk_size_name(larger_chunk_index), word_size, chunk_size_name(target_chunk_index)); |
|
2928 |
||
2929 |
chunk = split_chunk(word_size, larger_chunk); |
|
2930 |
||
2931 |
// This should have worked. |
|
2932 |
assert(chunk != NULL, "Sanity"); |
|
2933 |
assert(chunk->word_size() == word_size, "Sanity"); |
|
2934 |
assert(chunk->is_tagged_free(), "Sanity"); |
|
2935 |
||
2936 |
we_did_split_a_chunk = true; |
|
2937 |
||
2938 |
} |
|
2939 |
} |
|
2940 |
||
2941 |
if (chunk == NULL) { |
|
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
2942 |
return NULL; |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
2943 |
} |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
2944 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2945 |
// Remove the chunk as the head of the list. |
16996
e699388c6dd8
8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents:
16439
diff
changeset
|
2946 |
free_list->remove_chunk(chunk); |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
2947 |
|
49365 | 2948 |
log_trace(gc, metaspace, freelist)("ChunkManager::free_chunks_get: free_list: " PTR_FORMAT " chunks left: " SSIZE_FORMAT ".", |
2949 |
p2i(free_list), free_list->count()); |
|
2950 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2951 |
} else { |
46674
a9e42ff6158f
8183923: Get rid of FreeBlockDictionary and dithering
mgerdin
parents:
46625
diff
changeset
|
2952 |
chunk = humongous_dictionary()->get_chunk(word_size); |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
2953 |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2954 |
if (chunk == NULL) { |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
2955 |
return NULL; |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
2956 |
} |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2957 |
|
35061 | 2958 |
log_debug(gc, metaspace, alloc)("Free list allocate humongous chunk size " SIZE_FORMAT " for requested size " SIZE_FORMAT " waste " SIZE_FORMAT, |
2959 |
chunk->word_size(), word_size, chunk->word_size() - word_size); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2960 |
} |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
2961 |
|
46360
c753322134b0
8170520: Make Metaspace ChunkManager counters non-atomic
stuefe
parents:
46333
diff
changeset
|
2962 |
// Chunk has been removed from the chunk manager; update counters. |
c753322134b0
8170520: Make Metaspace ChunkManager counters non-atomic
stuefe
parents:
46333
diff
changeset
|
2963 |
account_for_removed_chunk(chunk); |
49365 | 2964 |
do_update_in_use_info_for_chunk(chunk, true); |
2965 |
chunk->container()->inc_container_count(); |
|
2966 |
chunk->inc_use_count(); |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
2967 |
|
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
2968 |
// Remove it from the links to this freelist |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
2969 |
chunk->set_next(NULL); |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
2970 |
chunk->set_prev(NULL); |
47808
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
2971 |
|
49365 | 2972 |
// Run some verifications (some more if we did a chunk split) |
2973 |
#ifdef ASSERT |
|
49386
d89e98d85841
8199518: test/hotspot/jtreg/runtime/SelectionResolution tests take a lot longer to run with fastdebug after JDK-8198423
stuefe
parents:
49372
diff
changeset
|
2974 |
if (metaspace_slow_verify) { |
d89e98d85841
8199518: test/hotspot/jtreg/runtime/SelectionResolution tests take a lot longer to run with fastdebug after JDK-8198423
stuefe
parents:
49372
diff
changeset
|
2975 |
locked_verify(); |
d89e98d85841
8199518: test/hotspot/jtreg/runtime/SelectionResolution tests take a lot longer to run with fastdebug after JDK-8198423
stuefe
parents:
49372
diff
changeset
|
2976 |
VirtualSpaceNode* const vsn = chunk->container(); |
d89e98d85841
8199518: test/hotspot/jtreg/runtime/SelectionResolution tests take a lot longer to run with fastdebug after JDK-8198423
stuefe
parents:
49372
diff
changeset
|
2977 |
vsn->verify(); |
d89e98d85841
8199518: test/hotspot/jtreg/runtime/SelectionResolution tests take a lot longer to run with fastdebug after JDK-8198423
stuefe
parents:
49372
diff
changeset
|
2978 |
if (we_did_split_a_chunk) { |
d89e98d85841
8199518: test/hotspot/jtreg/runtime/SelectionResolution tests take a lot longer to run with fastdebug after JDK-8198423
stuefe
parents:
49372
diff
changeset
|
2979 |
vsn->verify_free_chunks_are_ideally_merged(); |
d89e98d85841
8199518: test/hotspot/jtreg/runtime/SelectionResolution tests take a lot longer to run with fastdebug after JDK-8198423
stuefe
parents:
49372
diff
changeset
|
2980 |
} |
49365 | 2981 |
} |
2982 |
#endif |
|
2983 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2984 |
return chunk; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2985 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2986 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2987 |
Metachunk* ChunkManager::chunk_freelist_allocate(size_t word_size) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2988 |
assert_lock_strong(SpaceManager::expand_lock()); |
14474
4154f1817a75
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
14123
diff
changeset
|
2989 |
slow_locked_verify(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2990 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2991 |
// Take from the beginning of the list |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2992 |
Metachunk* chunk = free_chunks_get(word_size); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2993 |
if (chunk == NULL) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2994 |
return NULL; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2995 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2996 |
|
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
2997 |
assert((word_size <= chunk->word_size()) || |
42621
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
2998 |
(list_index(chunk->word_size()) == HumongousIndex), |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
2999 |
"Non-humongous variable sized chunk"); |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46674
diff
changeset
|
3000 |
LogTarget(Debug, gc, metaspace, freelist) lt; |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46674
diff
changeset
|
3001 |
if (lt.is_enabled()) { |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3002 |
size_t list_count; |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3003 |
if (list_index(word_size) < HumongousIndex) { |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3004 |
ChunkList* list = find_free_chunks_list(word_size); |
16996
e699388c6dd8
8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents:
16439
diff
changeset
|
3005 |
list_count = list->count(); |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3006 |
} else { |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3007 |
list_count = humongous_dictionary()->total_count(); |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3008 |
} |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46674
diff
changeset
|
3009 |
LogStream ls(lt); |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46674
diff
changeset
|
3010 |
ls.print("ChunkManager::chunk_freelist_allocate: " PTR_FORMAT " chunk " PTR_FORMAT " size " SIZE_FORMAT " count " SIZE_FORMAT " ", |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46674
diff
changeset
|
3011 |
p2i(this), p2i(chunk), chunk->word_size(), list_count); |
35061 | 3012 |
ResourceMark rm; |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46674
diff
changeset
|
3013 |
locked_print_free_chunks(&ls); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3014 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3015 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3016 |
return chunk; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3017 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3018 |
|
46333
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3019 |
void ChunkManager::return_single_chunk(ChunkIndex index, Metachunk* chunk) { |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3020 |
assert_lock_strong(SpaceManager::expand_lock()); |
49365 | 3021 |
DEBUG_ONLY(do_verify_chunk(chunk);) |
3022 |
assert(chunk->get_chunk_type() == index, "Chunk does not match expected index."); |
|
46333
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3023 |
assert(chunk != NULL, "Expected chunk."); |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3024 |
assert(chunk->container() != NULL, "Container should have been set."); |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3025 |
assert(chunk->is_tagged_free() == false, "Chunk should be in use."); |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3026 |
index_bounds_check(index); |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3027 |
|
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3028 |
// Note: mangle *before* returning the chunk to the freelist or dictionary. It does not |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3029 |
// matter for the freelist (non-humongous chunks), but the humongous chunk dictionary |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3030 |
// keeps tree node pointers in the chunk payload area which mangle will overwrite. |
49365 | 3031 |
DEBUG_ONLY(chunk->mangle(badMetaWordVal);) |
46333
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3032 |
|
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3033 |
if (index != HumongousIndex) { |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3034 |
// Return non-humongous chunk to freelist. |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3035 |
ChunkList* list = free_chunks(index); |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3036 |
assert(list->size() == chunk->word_size(), "Wrong chunk type."); |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3037 |
list->return_chunk_at_head(chunk); |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3038 |
log_trace(gc, metaspace, freelist)("returned one %s chunk at " PTR_FORMAT " to freelist.", |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3039 |
chunk_size_name(index), p2i(chunk)); |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3040 |
} else { |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3041 |
// Return humongous chunk to dictionary. |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3042 |
assert(chunk->word_size() > free_chunks(MediumIndex)->size(), "Wrong chunk type."); |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3043 |
assert(chunk->word_size() % free_chunks(SpecializedIndex)->size() == 0, |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3044 |
"Humongous chunk has wrong alignment."); |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3045 |
_humongous_dictionary.return_chunk(chunk); |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3046 |
log_trace(gc, metaspace, freelist)("returned one %s chunk at " PTR_FORMAT " (word size " SIZE_FORMAT ") to freelist.", |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3047 |
chunk_size_name(index), p2i(chunk), chunk->word_size()); |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3048 |
} |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3049 |
chunk->container()->dec_container_count(); |
49365 | 3050 |
do_update_in_use_info_for_chunk(chunk, false); |
46333
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3051 |
|
46360
c753322134b0
8170520: Make Metaspace ChunkManager counters non-atomic
stuefe
parents:
46333
diff
changeset
|
3052 |
// Chunk has been added; update counters. |
c753322134b0
8170520: Make Metaspace ChunkManager counters non-atomic
stuefe
parents:
46333
diff
changeset
|
3053 |
account_for_added_chunk(chunk); |
c753322134b0
8170520: Make Metaspace ChunkManager counters non-atomic
stuefe
parents:
46333
diff
changeset
|
3054 |
|
49365 | 3055 |
// Attempt coalesce returned chunks with its neighboring chunks: |
3056 |
// if this chunk is small or special, attempt to coalesce to a medium chunk. |
|
3057 |
if (index == SmallIndex || index == SpecializedIndex) { |
|
3058 |
if (!attempt_to_coalesce_around_chunk(chunk, MediumIndex)) { |
|
3059 |
// This did not work. But if this chunk is special, we still may form a small chunk? |
|
3060 |
if (index == SpecializedIndex) { |
|
3061 |
if (!attempt_to_coalesce_around_chunk(chunk, SmallIndex)) { |
|
3062 |
// give up. |
|
3063 |
} |
|
3064 |
} |
|
3065 |
} |
|
3066 |
} |
|
3067 |
||
46333
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3068 |
} |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3069 |
|
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3070 |
void ChunkManager::return_chunk_list(ChunkIndex index, Metachunk* chunks) { |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3071 |
index_bounds_check(index); |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3072 |
if (chunks == NULL) { |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3073 |
return; |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3074 |
} |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3075 |
LogTarget(Trace, gc, metaspace, freelist) log; |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3076 |
if (log.is_enabled()) { // tracing |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3077 |
log.print("returning list of %s chunks...", chunk_size_name(index)); |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3078 |
} |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3079 |
unsigned num_chunks_returned = 0; |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3080 |
size_t size_chunks_returned = 0; |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3081 |
Metachunk* cur = chunks; |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3082 |
while (cur != NULL) { |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3083 |
// Capture the next link before it is changed |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3084 |
// by the call to return_chunk_at_head(); |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3085 |
Metachunk* next = cur->next(); |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3086 |
if (log.is_enabled()) { // tracing |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3087 |
num_chunks_returned ++; |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3088 |
size_chunks_returned += cur->word_size(); |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3089 |
} |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3090 |
return_single_chunk(index, cur); |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3091 |
cur = next; |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3092 |
} |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3093 |
if (log.is_enabled()) { // tracing |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3094 |
log.print("returned %u %s chunks to freelist, total word size " SIZE_FORMAT ".", |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3095 |
num_chunks_returned, chunk_size_name(index), size_chunks_returned); |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3096 |
if (index != HumongousIndex) { |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3097 |
log.print("updated freelist count: " SIZE_FORMAT ".", free_chunks(index)->size()); |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3098 |
} else { |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3099 |
log.print("updated dictionary count " SIZE_FORMAT ".", _humongous_dictionary.total_count()); |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3100 |
} |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3101 |
} |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3102 |
} |
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3103 |
|
20081
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
3104 |
void ChunkManager::print_on(outputStream* out) const { |
46709
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3105 |
_humongous_dictionary.report_statistics(out); |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3106 |
} |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3107 |
|
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3108 |
void ChunkManager::locked_get_statistics(ChunkManagerStatistics* stat) const { |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3109 |
assert_lock_strong(SpaceManager::expand_lock()); |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3110 |
for (ChunkIndex i = ZeroIndex; i < NumberOfFreeLists; i = next_chunk_index(i)) { |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3111 |
stat->num_by_type[i] = num_free_chunks(i); |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3112 |
stat->single_size_by_type[i] = size_by_index(i); |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3113 |
stat->total_size_by_type[i] = size_free_chunks_in_bytes(i); |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3114 |
} |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3115 |
stat->num_humongous_chunks = num_free_chunks(HumongousIndex); |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3116 |
stat->total_size_humongous_chunks = size_free_chunks_in_bytes(HumongousIndex); |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3117 |
} |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3118 |
|
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3119 |
void ChunkManager::get_statistics(ChunkManagerStatistics* stat) const { |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3120 |
MutexLockerEx cl(SpaceManager::expand_lock(), |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3121 |
Mutex::_no_safepoint_check_flag); |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3122 |
locked_get_statistics(stat); |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3123 |
} |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3124 |
|
47802
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
3125 |
void ChunkManager::print_statistics(const ChunkManagerStatistics* stat, outputStream* out, size_t scale) { |
46709
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3126 |
size_t total = 0; |
47802
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
3127 |
assert(scale == 1 || scale == K || scale == M || scale == G, "Invalid scale"); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
3128 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
3129 |
const char* unit = scale_unit(scale); |
46709
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3130 |
for (ChunkIndex i = ZeroIndex; i < NumberOfFreeLists; i = next_chunk_index(i)) { |
47802
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
3131 |
out->print(" " SIZE_FORMAT " %s (" SIZE_FORMAT " bytes) chunks, total ", |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
3132 |
stat->num_by_type[i], chunk_size_name(i), |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
3133 |
stat->single_size_by_type[i]); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
3134 |
if (scale == 1) { |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
3135 |
out->print_cr(SIZE_FORMAT " bytes", stat->total_size_by_type[i]); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
3136 |
} else { |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
3137 |
out->print_cr("%.2f%s", (float)stat->total_size_by_type[i] / scale, unit); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
3138 |
} |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
3139 |
|
46709
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3140 |
total += stat->total_size_by_type[i]; |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3141 |
} |
47802
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
3142 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
3143 |
|
46709
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3144 |
total += stat->total_size_humongous_chunks; |
47802
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
3145 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
3146 |
if (scale == 1) { |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
3147 |
out->print_cr(" " SIZE_FORMAT " humongous chunks, total " SIZE_FORMAT " bytes", |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
3148 |
stat->num_humongous_chunks, stat->total_size_humongous_chunks); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
3149 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
3150 |
out->print_cr(" total size: " SIZE_FORMAT " bytes.", total); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
3151 |
} else { |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
3152 |
out->print_cr(" " SIZE_FORMAT " humongous chunks, total %.2f%s", |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
3153 |
stat->num_humongous_chunks, |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
3154 |
(float)stat->total_size_humongous_chunks / scale, unit); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
3155 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
3156 |
out->print_cr(" total size: %.2f%s.", (float)total / scale, unit); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
3157 |
} |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
3158 |
|
46709
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3159 |
} |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3160 |
|
47802
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
3161 |
void ChunkManager::print_all_chunkmanagers(outputStream* out, size_t scale) { |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
3162 |
assert(scale == 1 || scale == K || scale == M || scale == G, "Invalid scale"); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
3163 |
|
46709
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3164 |
// Note: keep lock protection only to retrieving statistics; keep printing |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3165 |
// out of lock protection |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3166 |
ChunkManagerStatistics stat; |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3167 |
out->print_cr("Chunkmanager (non-class):"); |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3168 |
const ChunkManager* const non_class_cm = Metaspace::chunk_manager_metadata(); |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3169 |
if (non_class_cm != NULL) { |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3170 |
non_class_cm->get_statistics(&stat); |
47802
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
3171 |
ChunkManager::print_statistics(&stat, out, scale); |
46709
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3172 |
} else { |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3173 |
out->print_cr("unavailable."); |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3174 |
} |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3175 |
out->print_cr("Chunkmanager (class):"); |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3176 |
const ChunkManager* const class_cm = Metaspace::chunk_manager_class(); |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3177 |
if (class_cm != NULL) { |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3178 |
class_cm->get_statistics(&stat); |
47802
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
3179 |
ChunkManager::print_statistics(&stat, out, scale); |
46709
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3180 |
} else { |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3181 |
out->print_cr("unavailable."); |
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
3182 |
} |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
3183 |
} |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
3184 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3185 |
// SpaceManager methods |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3186 |
|
42615
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3187 |
size_t SpaceManager::adjust_initial_chunk_size(size_t requested, bool is_class_space) { |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3188 |
size_t chunk_sizes[] = { |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3189 |
specialized_chunk_size(is_class_space), |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3190 |
small_chunk_size(is_class_space), |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3191 |
medium_chunk_size(is_class_space) |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3192 |
}; |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3193 |
|
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3194 |
// Adjust up to one of the fixed chunk sizes ... |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3195 |
for (size_t i = 0; i < ARRAY_SIZE(chunk_sizes); i++) { |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3196 |
if (requested <= chunk_sizes[i]) { |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3197 |
return chunk_sizes[i]; |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3198 |
} |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3199 |
} |
42615
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3200 |
|
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3201 |
// ... or return the size as a humongous chunk. |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3202 |
return requested; |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3203 |
} |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3204 |
|
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3205 |
size_t SpaceManager::adjust_initial_chunk_size(size_t requested) const { |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3206 |
return adjust_initial_chunk_size(requested, is_class()); |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3207 |
} |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3208 |
|
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3209 |
size_t SpaceManager::get_initial_chunk_size(Metaspace::MetaspaceType type) const { |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3210 |
size_t requested; |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3211 |
|
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3212 |
if (is_class()) { |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3213 |
switch (type) { |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3214 |
case Metaspace::BootMetaspaceType: requested = Metaspace::first_class_chunk_word_size(); break; |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3215 |
case Metaspace::AnonymousMetaspaceType: requested = ClassSpecializedChunk; break; |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3216 |
case Metaspace::ReflectionMetaspaceType: requested = ClassSpecializedChunk; break; |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3217 |
default: requested = ClassSmallChunk; break; |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3218 |
} |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3219 |
} else { |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3220 |
switch (type) { |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3221 |
case Metaspace::BootMetaspaceType: requested = Metaspace::first_chunk_word_size(); break; |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3222 |
case Metaspace::AnonymousMetaspaceType: requested = SpecializedChunk; break; |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3223 |
case Metaspace::ReflectionMetaspaceType: requested = SpecializedChunk; break; |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3224 |
default: requested = SmallChunk; break; |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3225 |
} |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3226 |
} |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3227 |
|
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3228 |
// Adjust to one of the fixed chunk sizes (unless humongous) |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3229 |
const size_t adjusted = adjust_initial_chunk_size(requested); |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3230 |
|
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3231 |
assert(adjusted != 0, "Incorrect initial chunk size. Requested: " |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3232 |
SIZE_FORMAT " adjusted: " SIZE_FORMAT, requested, adjusted); |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3233 |
|
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3234 |
return adjusted; |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3235 |
} |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3236 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3237 |
size_t SpaceManager::sum_free_in_chunks_in_use() const { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3238 |
MutexLockerEx cl(lock(), Mutex::_no_safepoint_check_flag); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3239 |
size_t free = 0; |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3240 |
for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3241 |
Metachunk* chunk = chunks_in_use(i); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3242 |
while (chunk != NULL) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3243 |
free += chunk->free_word_size(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3244 |
chunk = chunk->next(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3245 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3246 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3247 |
return free; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3248 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3249 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3250 |
size_t SpaceManager::sum_waste_in_chunks_in_use() const { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3251 |
MutexLockerEx cl(lock(), Mutex::_no_safepoint_check_flag); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3252 |
size_t result = 0; |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3253 |
for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3254 |
result += sum_waste_in_chunks_in_use(i); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3255 |
} |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
3256 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3257 |
return result; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3258 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3259 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3260 |
size_t SpaceManager::sum_waste_in_chunks_in_use(ChunkIndex index) const { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3261 |
size_t result = 0; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3262 |
Metachunk* chunk = chunks_in_use(index); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3263 |
// Count the free space in all the chunk but not the |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3264 |
// current chunk from which allocations are still being done. |
18491
dd63ba6b0ee4
8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents:
17858
diff
changeset
|
3265 |
while (chunk != NULL) { |
dd63ba6b0ee4
8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents:
17858
diff
changeset
|
3266 |
if (chunk != current_chunk()) { |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
3267 |
result += chunk->free_word_size(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3268 |
} |
18491
dd63ba6b0ee4
8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents:
17858
diff
changeset
|
3269 |
chunk = chunk->next(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3270 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3271 |
return result; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3272 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3273 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3274 |
size_t SpaceManager::sum_capacity_in_chunks_in_use() const { |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3275 |
// For CMS use "allocated_chunks_words()" which does not need the |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3276 |
// Metaspace lock. For the other collectors sum over the |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3277 |
// lists. Use both methods as a check that "allocated_chunks_words()" |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3278 |
// is correct. That is, sum_capacity_in_chunks() is too expensive |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3279 |
// to use in the product and allocated_chunks_words() should be used |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3280 |
// but allow for checking that allocated_chunks_words() returns the same |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3281 |
// value as sum_capacity_in_chunks_in_use() which is the definitive |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3282 |
// answer. |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3283 |
if (UseConcMarkSweepGC) { |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3284 |
return allocated_chunks_words(); |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3285 |
} else { |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3286 |
MutexLockerEx cl(lock(), Mutex::_no_safepoint_check_flag); |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3287 |
size_t sum = 0; |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3288 |
for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) { |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3289 |
Metachunk* chunk = chunks_in_use(i); |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3290 |
while (chunk != NULL) { |
20729 | 3291 |
sum += chunk->word_size(); |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3292 |
chunk = chunk->next(); |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3293 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3294 |
} |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3295 |
return sum; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3296 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3297 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3298 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3299 |
size_t SpaceManager::sum_count_in_chunks_in_use() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3300 |
size_t count = 0; |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3301 |
for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3302 |
count = count + sum_count_in_chunks_in_use(i); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3303 |
} |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
3304 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3305 |
return count; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3306 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3307 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3308 |
size_t SpaceManager::sum_count_in_chunks_in_use(ChunkIndex i) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3309 |
size_t count = 0; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3310 |
Metachunk* chunk = chunks_in_use(i); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3311 |
while (chunk != NULL) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3312 |
count++; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3313 |
chunk = chunk->next(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3314 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3315 |
return count; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3316 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3317 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3318 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3319 |
size_t SpaceManager::sum_used_in_chunks_in_use() const { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3320 |
MutexLockerEx cl(lock(), Mutex::_no_safepoint_check_flag); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3321 |
size_t used = 0; |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3322 |
for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3323 |
Metachunk* chunk = chunks_in_use(i); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3324 |
while (chunk != NULL) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3325 |
used += chunk->used_word_size(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3326 |
chunk = chunk->next(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3327 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3328 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3329 |
return used; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3330 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3331 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3332 |
void SpaceManager::locked_print_chunks_in_use_on(outputStream* st) const { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3333 |
|
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3334 |
for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) { |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3335 |
Metachunk* chunk = chunks_in_use(i); |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3336 |
st->print("SpaceManager: %s " PTR_FORMAT, |
29800
fa5f7a2bf717
8076073: shared: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
29697
diff
changeset
|
3337 |
chunk_size_name(i), p2i(chunk)); |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3338 |
if (chunk != NULL) { |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3339 |
st->print_cr(" free " SIZE_FORMAT, |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3340 |
chunk->free_word_size()); |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3341 |
} else { |
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
24351
diff
changeset
|
3342 |
st->cr(); |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3343 |
} |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3344 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3345 |
|
20081
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
3346 |
chunk_manager()->locked_print_free_chunks(st); |
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
3347 |
chunk_manager()->locked_print_sum_free_chunks(st); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3348 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3349 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3350 |
size_t SpaceManager::calc_chunk_size(size_t word_size) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3351 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3352 |
// Decide between a small chunk and a medium chunk. Up to |
31028
8c5b4d489c41
8081508: metaspace/shrink_grow/CompressedClassSpaceSize fails with OOM: Compressed class space
jprovino
parents:
30764
diff
changeset
|
3353 |
// _small_chunk_limit small chunks can be allocated. |
8c5b4d489c41
8081508: metaspace/shrink_grow/CompressedClassSpaceSize fails with OOM: Compressed class space
jprovino
parents:
30764
diff
changeset
|
3354 |
// After that a medium chunk is preferred. |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3355 |
size_t chunk_word_size; |
48148
385bed268108
8190729: Adjustment to anonymous metadata space chunk allocation algorithm
zgu
parents:
47808
diff
changeset
|
3356 |
|
385bed268108
8190729: Adjustment to anonymous metadata space chunk allocation algorithm
zgu
parents:
47808
diff
changeset
|
3357 |
// Special case for anonymous metadata space. |
385bed268108
8190729: Adjustment to anonymous metadata space chunk allocation algorithm
zgu
parents:
47808
diff
changeset
|
3358 |
// Anonymous metadata space is usually small, with majority within 1K - 2K range and |
385bed268108
8190729: Adjustment to anonymous metadata space chunk allocation algorithm
zgu
parents:
47808
diff
changeset
|
3359 |
// rarely about 4K (64-bits JVM). |
385bed268108
8190729: Adjustment to anonymous metadata space chunk allocation algorithm
zgu
parents:
47808
diff
changeset
|
3360 |
// Instead of jumping to SmallChunk after initial chunk exhausted, keeping allocation |
385bed268108
8190729: Adjustment to anonymous metadata space chunk allocation algorithm
zgu
parents:
47808
diff
changeset
|
3361 |
// from SpecializeChunk up to _anon_metadata_specialize_chunk_limit (4) reduces space waste |
385bed268108
8190729: Adjustment to anonymous metadata space chunk allocation algorithm
zgu
parents:
47808
diff
changeset
|
3362 |
// from 60+% to around 30%. |
385bed268108
8190729: Adjustment to anonymous metadata space chunk allocation algorithm
zgu
parents:
47808
diff
changeset
|
3363 |
if (_space_type == Metaspace::AnonymousMetaspaceType && |
385bed268108
8190729: Adjustment to anonymous metadata space chunk allocation algorithm
zgu
parents:
47808
diff
changeset
|
3364 |
_mdtype == Metaspace::NonClassType && |
385bed268108
8190729: Adjustment to anonymous metadata space chunk allocation algorithm
zgu
parents:
47808
diff
changeset
|
3365 |
sum_count_in_chunks_in_use(SpecializedIndex) < _anon_metadata_specialize_chunk_limit && |
385bed268108
8190729: Adjustment to anonymous metadata space chunk allocation algorithm
zgu
parents:
47808
diff
changeset
|
3366 |
word_size + Metachunk::overhead() <= SpecializedChunk) { |
385bed268108
8190729: Adjustment to anonymous metadata space chunk allocation algorithm
zgu
parents:
47808
diff
changeset
|
3367 |
return SpecializedChunk; |
385bed268108
8190729: Adjustment to anonymous metadata space chunk allocation algorithm
zgu
parents:
47808
diff
changeset
|
3368 |
} |
385bed268108
8190729: Adjustment to anonymous metadata space chunk allocation algorithm
zgu
parents:
47808
diff
changeset
|
3369 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3370 |
if (chunks_in_use(MediumIndex) == NULL && |
18491
dd63ba6b0ee4
8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents:
17858
diff
changeset
|
3371 |
sum_count_in_chunks_in_use(SmallIndex) < _small_chunk_limit) { |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3372 |
chunk_word_size = (size_t) small_chunk_size(); |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3373 |
if (word_size + Metachunk::overhead() > small_chunk_size()) { |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3374 |
chunk_word_size = medium_chunk_size(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3375 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3376 |
} else { |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3377 |
chunk_word_size = medium_chunk_size(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3378 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3379 |
|
21112
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
3380 |
// Might still need a humongous chunk. Enforce |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
3381 |
// humongous allocations sizes to be aligned up to |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
3382 |
// the smallest chunk size. |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3383 |
size_t if_humongous_sized_chunk = |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
3384 |
align_up(word_size + Metachunk::overhead(), |
21112
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
3385 |
smallest_chunk_size()); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3386 |
chunk_word_size = |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3387 |
MAX2((size_t) chunk_word_size, if_humongous_sized_chunk); |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3388 |
|
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3389 |
assert(!SpaceManager::is_humongous(word_size) || |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3390 |
chunk_word_size == if_humongous_sized_chunk, |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
3391 |
"Size calculation is wrong, word_size " SIZE_FORMAT |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
3392 |
" chunk_word_size " SIZE_FORMAT, |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
3393 |
word_size, chunk_word_size); |
37242 | 3394 |
Log(gc, metaspace, alloc) log; |
35061 | 3395 |
if (log.is_debug() && SpaceManager::is_humongous(word_size)) { |
3396 |
log.debug("Metadata humongous allocation:"); |
|
3397 |
log.debug(" word_size " PTR_FORMAT, word_size); |
|
3398 |
log.debug(" chunk_word_size " PTR_FORMAT, chunk_word_size); |
|
3399 |
log.debug(" chunk overhead " PTR_FORMAT, Metachunk::overhead()); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3400 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3401 |
return chunk_word_size; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3402 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3403 |
|
20407
68e215ce8944
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
20406
diff
changeset
|
3404 |
void SpaceManager::track_metaspace_memory_usage() { |
68e215ce8944
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
20406
diff
changeset
|
3405 |
if (is_init_completed()) { |
68e215ce8944
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
20406
diff
changeset
|
3406 |
if (is_class()) { |
68e215ce8944
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
20406
diff
changeset
|
3407 |
MemoryService::track_compressed_class_memory_usage(); |
68e215ce8944
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
20406
diff
changeset
|
3408 |
} |
68e215ce8944
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
20406
diff
changeset
|
3409 |
MemoryService::track_metaspace_memory_usage(); |
68e215ce8944
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
20406
diff
changeset
|
3410 |
} |
68e215ce8944
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
20406
diff
changeset
|
3411 |
} |
68e215ce8944
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
20406
diff
changeset
|
3412 |
|
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
3413 |
MetaWord* SpaceManager::grow_and_allocate(size_t word_size) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3414 |
assert(vs_list()->current_virtual_space() != NULL, |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3415 |
"Should have been set"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3416 |
assert(current_chunk() == NULL || |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3417 |
current_chunk()->allocate(word_size) == NULL, |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3418 |
"Don't need to expand"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3419 |
MutexLockerEx cl(SpaceManager::expand_lock(), Mutex::_no_safepoint_check_flag); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3420 |
|
35061 | 3421 |
if (log_is_enabled(Trace, gc, metaspace, freelist)) { |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3422 |
size_t words_left = 0; |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3423 |
size_t words_used = 0; |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3424 |
if (current_chunk() != NULL) { |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3425 |
words_left = current_chunk()->free_word_size(); |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3426 |
words_used = current_chunk()->used_word_size(); |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3427 |
} |
35061 | 3428 |
log_trace(gc, metaspace, freelist)("SpaceManager::grow_and_allocate for " SIZE_FORMAT " words " SIZE_FORMAT " words used " SIZE_FORMAT " words left", |
3429 |
word_size, words_used, words_left); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3430 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3431 |
|
31028
8c5b4d489c41
8081508: metaspace/shrink_grow/CompressedClassSpaceSize fails with OOM: Compressed class space
jprovino
parents:
30764
diff
changeset
|
3432 |
// Get another chunk |
42615
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3433 |
size_t chunk_word_size = calc_chunk_size(word_size); |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3434 |
Metachunk* next = get_new_chunk(chunk_word_size); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3435 |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
3436 |
MetaWord* mem = NULL; |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
3437 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3438 |
// If a chunk was available, add it to the in-use chunk list |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3439 |
// and do an allocation from it. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3440 |
if (next != NULL) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3441 |
// Add to this manager's list of chunks in use. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3442 |
add_chunk(next, false); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
3443 |
mem = next->allocate(word_size); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3444 |
} |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
3445 |
|
20407
68e215ce8944
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
20406
diff
changeset
|
3446 |
// Track metaspace memory usage statistic. |
68e215ce8944
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
20406
diff
changeset
|
3447 |
track_metaspace_memory_usage(); |
68e215ce8944
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
20406
diff
changeset
|
3448 |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
3449 |
return mem; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3450 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3451 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3452 |
void SpaceManager::print_on(outputStream* st) const { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3453 |
|
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3454 |
for (ChunkIndex i = ZeroIndex; |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
3455 |
i < NumberOfInUseLists ; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3456 |
i = next_chunk_index(i) ) { |
29800
fa5f7a2bf717
8076073: shared: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
29697
diff
changeset
|
3457 |
st->print_cr(" chunks_in_use " PTR_FORMAT " chunk size " SIZE_FORMAT, |
fa5f7a2bf717
8076073: shared: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
29697
diff
changeset
|
3458 |
p2i(chunks_in_use(i)), |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3459 |
chunks_in_use(i) == NULL ? 0 : chunks_in_use(i)->word_size()); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3460 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3461 |
st->print_cr(" waste: Small " SIZE_FORMAT " Medium " SIZE_FORMAT |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3462 |
" Humongous " SIZE_FORMAT, |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3463 |
sum_waste_in_chunks_in_use(SmallIndex), |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3464 |
sum_waste_in_chunks_in_use(MediumIndex), |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3465 |
sum_waste_in_chunks_in_use(HumongousIndex)); |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
3466 |
// block free lists |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
3467 |
if (block_freelists() != NULL) { |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
3468 |
st->print_cr("total in block free lists " SIZE_FORMAT, |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
3469 |
block_freelists()->total_size()); |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
3470 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3471 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3472 |
|
17628
481e0280aed3
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
17117
diff
changeset
|
3473 |
SpaceManager::SpaceManager(Metaspace::MetadataType mdtype, |
48148
385bed268108
8190729: Adjustment to anonymous metadata space chunk allocation algorithm
zgu
parents:
47808
diff
changeset
|
3474 |
Metaspace::MetaspaceType space_type, |
20081
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
3475 |
Mutex* lock) : |
17628
481e0280aed3
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
17117
diff
changeset
|
3476 |
_mdtype(mdtype), |
48148
385bed268108
8190729: Adjustment to anonymous metadata space chunk allocation algorithm
zgu
parents:
47808
diff
changeset
|
3477 |
_space_type(space_type), |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3478 |
_allocated_blocks_words(0), |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3479 |
_allocated_chunks_words(0), |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3480 |
_allocated_chunks_count(0), |
41727
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
3481 |
_block_freelists(NULL), |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3482 |
_lock(lock) |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3483 |
{ |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3484 |
initialize(); |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3485 |
} |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3486 |
|
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3487 |
void SpaceManager::inc_size_metrics(size_t words) { |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3488 |
assert_lock_strong(SpaceManager::expand_lock()); |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3489 |
// Total of allocated Metachunks and allocated Metachunks count |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3490 |
// for each SpaceManager |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3491 |
_allocated_chunks_words = _allocated_chunks_words + words; |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3492 |
_allocated_chunks_count++; |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3493 |
// Global total of capacity in allocated Metachunks |
17628
481e0280aed3
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
17117
diff
changeset
|
3494 |
MetaspaceAux::inc_capacity(mdtype(), words); |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3495 |
// Global total of allocated Metablocks. |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3496 |
// used_words_slow() includes the overhead in each |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3497 |
// Metachunk so include it in the used when the |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3498 |
// Metachunk is first added (so only added once per |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3499 |
// Metachunk). |
17628
481e0280aed3
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
17117
diff
changeset
|
3500 |
MetaspaceAux::inc_used(mdtype(), Metachunk::overhead()); |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3501 |
} |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3502 |
|
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3503 |
void SpaceManager::inc_used_metrics(size_t words) { |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3504 |
// Add to the per SpaceManager total |
47634
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47599
diff
changeset
|
3505 |
Atomic::add(words, &_allocated_blocks_words); |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3506 |
// Add to the global total |
17628
481e0280aed3
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
17117
diff
changeset
|
3507 |
MetaspaceAux::inc_used(mdtype(), words); |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3508 |
} |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3509 |
|
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3510 |
void SpaceManager::dec_total_from_size_metrics() { |
17628
481e0280aed3
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
17117
diff
changeset
|
3511 |
MetaspaceAux::dec_capacity(mdtype(), allocated_chunks_words()); |
481e0280aed3
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
17117
diff
changeset
|
3512 |
MetaspaceAux::dec_used(mdtype(), allocated_blocks_words()); |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3513 |
// Also deduct the overhead per Metachunk |
17628
481e0280aed3
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
17117
diff
changeset
|
3514 |
MetaspaceAux::dec_used(mdtype(), allocated_chunks_count() * Metachunk::overhead()); |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3515 |
} |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3516 |
|
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3517 |
void SpaceManager::initialize() { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3518 |
Metadebug::init_allocation_fail_alot_count(); |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3519 |
for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3520 |
_chunks_in_use[i] = NULL; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3521 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3522 |
_current_chunk = NULL; |
35061 | 3523 |
log_trace(gc, metaspace, freelist)("SpaceManager(): " PTR_FORMAT, p2i(this)); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3524 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3525 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3526 |
SpaceManager::~SpaceManager() { |
16385
4a05c6d94b04
8005602: NPG: classunloading does not happen while CMS GC with -XX:+CMSClassUnloadingEnabled is used
mgerdin
parents:
15954
diff
changeset
|
3527 |
// This call this->_lock which can't be done while holding expand_lock() |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3528 |
assert(sum_capacity_in_chunks_in_use() == allocated_chunks_words(), |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
3529 |
"sum_capacity_in_chunks_in_use() " SIZE_FORMAT |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
3530 |
" allocated_chunks_words() " SIZE_FORMAT, |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
3531 |
sum_capacity_in_chunks_in_use(), allocated_chunks_words()); |
16385
4a05c6d94b04
8005602: NPG: classunloading does not happen while CMS GC with -XX:+CMSClassUnloadingEnabled is used
mgerdin
parents:
15954
diff
changeset
|
3532 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3533 |
MutexLockerEx fcl(SpaceManager::expand_lock(), |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3534 |
Mutex::_no_safepoint_check_flag); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3535 |
|
49365 | 3536 |
assert(sum_count_in_chunks_in_use() == allocated_chunks_count(), |
3537 |
"sum_count_in_chunks_in_use() " SIZE_FORMAT |
|
3538 |
" allocated_chunks_count() " SIZE_FORMAT, |
|
3539 |
sum_count_in_chunks_in_use(), allocated_chunks_count()); |
|
3540 |
||
20081
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
3541 |
chunk_manager()->slow_locked_verify(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3542 |
|
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3543 |
dec_total_from_size_metrics(); |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3544 |
|
37242 | 3545 |
Log(gc, metaspace, freelist) log; |
35061 | 3546 |
if (log.is_trace()) { |
3547 |
log.trace("~SpaceManager(): " PTR_FORMAT, p2i(this)); |
|
3548 |
ResourceMark rm; |
|
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46674
diff
changeset
|
3549 |
LogStream ls(log.trace()); |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46674
diff
changeset
|
3550 |
locked_print_chunks_in_use_on(&ls); |
41727
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
3551 |
if (block_freelists() != NULL) { |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46674
diff
changeset
|
3552 |
block_freelists()->print_on(&ls); |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46674
diff
changeset
|
3553 |
} |
41727
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
3554 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3555 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3556 |
// Add all the chunks in use by this space manager |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3557 |
// to the global list of free chunks. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3558 |
|
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3559 |
// Follow each list of chunks-in-use and add them to the |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3560 |
// free lists. Each list is NULL terminated. |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3561 |
|
46333
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3562 |
for (ChunkIndex i = ZeroIndex; i <= HumongousIndex; i = next_chunk_index(i)) { |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3563 |
Metachunk* chunks = chunks_in_use(i); |
46333
cef2c78aaa56
8170933: Cleanup Metaspace Chunk manager: Unify treatment of humongous and non-humongous chunks
stuefe
parents:
46324
diff
changeset
|
3564 |
chunk_manager()->return_chunk_list(i, chunks); |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3565 |
set_chunks_in_use(i, NULL); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3566 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3567 |
|
20081
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
3568 |
chunk_manager()->slow_locked_verify(); |
41727
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
3569 |
|
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
3570 |
if (_block_freelists != NULL) { |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
3571 |
delete _block_freelists; |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
3572 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3573 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3574 |
|
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
3575 |
void SpaceManager::deallocate(MetaWord* p, size_t word_size) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3576 |
assert_lock_strong(_lock); |
41727
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
3577 |
// Allocations and deallocations are in raw_word_size |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
3578 |
size_t raw_word_size = get_allocation_word_size(word_size); |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
3579 |
// Lazily create a block_freelist |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
3580 |
if (block_freelists() == NULL) { |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
3581 |
_block_freelists = new BlockFreelist(); |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
3582 |
} |
18987 | 3583 |
block_freelists()->return_block(p, raw_word_size); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3584 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3585 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3586 |
// Adds a chunk to the list of chunks in use. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3587 |
void SpaceManager::add_chunk(Metachunk* new_chunk, bool make_current) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3588 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3589 |
assert(new_chunk != NULL, "Should not be NULL"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3590 |
assert(new_chunk->next() == NULL, "Should not be on a list"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3591 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3592 |
new_chunk->reset_empty(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3593 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3594 |
// Find the correct list and and set the current |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3595 |
// chunk for that list. |
42621
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
3596 |
ChunkIndex index = chunk_manager()->list_index(new_chunk->word_size()); |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3597 |
|
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3598 |
if (index != HumongousIndex) { |
19984
ba033739c8fe
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
19979
diff
changeset
|
3599 |
retire_current_chunk(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3600 |
set_current_chunk(new_chunk); |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3601 |
new_chunk->set_next(chunks_in_use(index)); |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3602 |
set_chunks_in_use(index, new_chunk); |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3603 |
} else { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3604 |
// For null class loader data and DumpSharedSpaces, the first chunk isn't |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3605 |
// small, so small will be null. Link this first chunk as the current |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3606 |
// chunk. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3607 |
if (make_current) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3608 |
// Set as the current chunk but otherwise treat as a humongous chunk. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3609 |
set_current_chunk(new_chunk); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3610 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3611 |
// Link at head. The _current_chunk only points to a humongous chunk for |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3612 |
// the null class loader metaspace (class and data virtual space managers) |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3613 |
// any humongous chunks so will not point to the tail |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3614 |
// of the humongous chunks list. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3615 |
new_chunk->set_next(chunks_in_use(HumongousIndex)); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3616 |
set_chunks_in_use(HumongousIndex, new_chunk); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3617 |
|
15087
8849ea877278
8005486: NPG: Incorrect assertion in ChunkManager::list_index()
jmasa
parents:
15086
diff
changeset
|
3618 |
assert(new_chunk->word_size() > medium_chunk_size(), "List inconsistency"); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3619 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3620 |
|
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3621 |
// Add to the running sum of capacity |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3622 |
inc_size_metrics(new_chunk->word_size()); |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3623 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3624 |
assert(new_chunk->is_empty(), "Not ready for reuse"); |
37242 | 3625 |
Log(gc, metaspace, freelist) log; |
35061 | 3626 |
if (log.is_trace()) { |
3627 |
log.trace("SpaceManager::add_chunk: " SIZE_FORMAT ") ", sum_count_in_chunks_in_use()); |
|
3628 |
ResourceMark rm; |
|
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46674
diff
changeset
|
3629 |
LogStream ls(log.trace()); |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46674
diff
changeset
|
3630 |
new_chunk->print_on(&ls); |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46674
diff
changeset
|
3631 |
chunk_manager()->locked_print_free_chunks(&ls); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3632 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3633 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3634 |
|
19984
ba033739c8fe
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
19979
diff
changeset
|
3635 |
void SpaceManager::retire_current_chunk() { |
ba033739c8fe
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
19979
diff
changeset
|
3636 |
if (current_chunk() != NULL) { |
ba033739c8fe
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
19979
diff
changeset
|
3637 |
size_t remaining_words = current_chunk()->free_word_size(); |
41727
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
3638 |
if (remaining_words >= BlockFreelist::min_dictionary_size()) { |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
3639 |
MetaWord* ptr = current_chunk()->allocate(remaining_words); |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
3640 |
deallocate(ptr, remaining_words); |
19984
ba033739c8fe
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
19979
diff
changeset
|
3641 |
inc_used_metrics(remaining_words); |
ba033739c8fe
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
19979
diff
changeset
|
3642 |
} |
ba033739c8fe
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
19979
diff
changeset
|
3643 |
} |
ba033739c8fe
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
19979
diff
changeset
|
3644 |
} |
ba033739c8fe
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
19979
diff
changeset
|
3645 |
|
42615
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3646 |
Metachunk* SpaceManager::get_new_chunk(size_t chunk_word_size) { |
20081
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
3647 |
// Get a chunk from the chunk freelist |
42615
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3648 |
Metachunk* next = chunk_manager()->chunk_freelist_allocate(chunk_word_size); |
20081
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
3649 |
|
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
3650 |
if (next == NULL) { |
42615
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
3651 |
next = vs_list()->get_new_chunk(chunk_word_size, |
20081
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
3652 |
medium_chunk_bunch()); |
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
3653 |
} |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3654 |
|
37242 | 3655 |
Log(gc, metaspace, alloc) log; |
35061 | 3656 |
if (log.is_debug() && next != NULL && |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3657 |
SpaceManager::is_humongous(next->word_size())) { |
35061 | 3658 |
log.debug(" new humongous chunk word size " PTR_FORMAT, next->word_size()); |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3659 |
} |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3660 |
|
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3661 |
return next; |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3662 |
} |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3663 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3664 |
MetaWord* SpaceManager::allocate(size_t word_size) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3665 |
MutexLockerEx cl(lock(), Mutex::_no_safepoint_check_flag); |
41727
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
3666 |
size_t raw_word_size = get_allocation_word_size(word_size); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3667 |
BlockFreelist* fl = block_freelists(); |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
3668 |
MetaWord* p = NULL; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3669 |
// Allocation from the dictionary is expensive in the sense that |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3670 |
// the dictionary has to be searched for a size. Don't allocate |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3671 |
// from the dictionary until it starts to get fat. Is this |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3672 |
// a reasonable policy? Maybe an skinny dictionary is fast enough |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3673 |
// for allocations. Do some profiling. JJJ |
41727
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
3674 |
if (fl != NULL && fl->total_size() > allocation_from_dictionary_limit) { |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
3675 |
p = fl->get_block(raw_word_size); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3676 |
} |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
3677 |
if (p == NULL) { |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
3678 |
p = allocate_work(raw_word_size); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3679 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3680 |
|
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
3681 |
return p; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3682 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3683 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3684 |
// Returns the address of spaced allocated for "word_size". |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3685 |
// This methods does not know about blocks (Metablocks) |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
3686 |
MetaWord* SpaceManager::allocate_work(size_t word_size) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3687 |
assert_lock_strong(_lock); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3688 |
#ifdef ASSERT |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3689 |
if (Metadebug::test_metadata_failure()) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3690 |
return NULL; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3691 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3692 |
#endif |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3693 |
// Is there space in the current chunk? |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
3694 |
MetaWord* result = NULL; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3695 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3696 |
if (current_chunk() != NULL) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3697 |
result = current_chunk()->allocate(word_size); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3698 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3699 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3700 |
if (result == NULL) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3701 |
result = grow_and_allocate(word_size); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3702 |
} |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
3703 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
3704 |
if (result != NULL) { |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3705 |
inc_used_metrics(word_size); |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
3706 |
assert(result != (MetaWord*) chunks_in_use(MediumIndex), |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
3707 |
"Head of the list is being allocated"); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3708 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3709 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3710 |
return result; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3711 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3712 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3713 |
void SpaceManager::verify() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3714 |
// If there are blocks in the dictionary, then |
22551 | 3715 |
// verification of chunks does not work since |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3716 |
// being in the dictionary alters a chunk. |
41727
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
3717 |
if (block_freelists() != NULL && block_freelists()->total_size() == 0) { |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3718 |
for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3719 |
Metachunk* curr = chunks_in_use(i); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3720 |
while (curr != NULL) { |
49365 | 3721 |
DEBUG_ONLY(do_verify_chunk(curr);) |
3722 |
assert(curr->is_tagged_free() == false, "Chunk should be tagged as in use."); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3723 |
curr = curr->next(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3724 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3725 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3726 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3727 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3728 |
|
14635
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
14590
diff
changeset
|
3729 |
void SpaceManager::verify_chunk_size(Metachunk* chunk) { |
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
14590
diff
changeset
|
3730 |
assert(is_humongous(chunk->word_size()) || |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3731 |
chunk->word_size() == medium_chunk_size() || |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3732 |
chunk->word_size() == small_chunk_size() || |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3733 |
chunk->word_size() == specialized_chunk_size(), |
14635
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
14590
diff
changeset
|
3734 |
"Chunk size is wrong"); |
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
14590
diff
changeset
|
3735 |
return; |
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
14590
diff
changeset
|
3736 |
} |
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
14590
diff
changeset
|
3737 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3738 |
#ifdef ASSERT |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3739 |
void SpaceManager::verify_allocated_blocks_words() { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3740 |
// Verification is only guaranteed at a safepoint. |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3741 |
assert(SafepointSynchronize::is_at_safepoint() || !Universe::is_fully_initialized(), |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3742 |
"Verification can fail if the applications is running"); |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3743 |
assert(allocated_blocks_words() == sum_used_in_chunks_in_use(), |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
3744 |
"allocation total is not consistent " SIZE_FORMAT |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
3745 |
" vs " SIZE_FORMAT, |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
3746 |
allocated_blocks_words(), sum_used_in_chunks_in_use()); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3747 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3748 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3749 |
#endif |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3750 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3751 |
void SpaceManager::dump(outputStream* const out) const { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3752 |
size_t curr_total = 0; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3753 |
size_t waste = 0; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3754 |
uint i = 0; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3755 |
size_t used = 0; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3756 |
size_t capacity = 0; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3757 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3758 |
// Add up statistics for all chunks in this SpaceManager. |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3759 |
for (ChunkIndex index = ZeroIndex; |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
3760 |
index < NumberOfInUseLists; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3761 |
index = next_chunk_index(index)) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3762 |
for (Metachunk* curr = chunks_in_use(index); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3763 |
curr != NULL; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3764 |
curr = curr->next()) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3765 |
out->print("%d) ", i++); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3766 |
curr->print_on(out); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3767 |
curr_total += curr->word_size(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3768 |
used += curr->used_word_size(); |
20729 | 3769 |
capacity += curr->word_size(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3770 |
waste += curr->free_word_size() + curr->overhead();; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3771 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3772 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3773 |
|
35061 | 3774 |
if (log_is_enabled(Trace, gc, metaspace, freelist)) { |
41727
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
3775 |
if (block_freelists() != NULL) block_freelists()->print_on(out); |
19992 | 3776 |
} |
3777 |
||
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
3778 |
size_t free = current_chunk() == NULL ? 0 : current_chunk()->free_word_size(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3779 |
// Free space isn't wasted. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3780 |
waste -= free; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3781 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3782 |
out->print_cr("total of all chunks " SIZE_FORMAT " used " SIZE_FORMAT |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3783 |
" free " SIZE_FORMAT " capacity " SIZE_FORMAT |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3784 |
" waste " SIZE_FORMAT, curr_total, used, free, capacity, waste); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3785 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3786 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3787 |
// MetaspaceAux |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3788 |
|
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3789 |
|
23854
50f7f89b34e0
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
23503
diff
changeset
|
3790 |
size_t MetaspaceAux::_capacity_words[] = {0, 0}; |
47553
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47543
diff
changeset
|
3791 |
volatile size_t MetaspaceAux::_used_words[] = {0, 0}; |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3792 |
|
19322
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
19319
diff
changeset
|
3793 |
size_t MetaspaceAux::free_bytes(Metaspace::MetadataType mdtype) { |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
19319
diff
changeset
|
3794 |
VirtualSpaceList* list = Metaspace::get_space_list(mdtype); |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
19319
diff
changeset
|
3795 |
return list == NULL ? 0 : list->free_bytes(); |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
19319
diff
changeset
|
3796 |
} |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
19319
diff
changeset
|
3797 |
|
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3798 |
size_t MetaspaceAux::free_bytes() { |
19322
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
19319
diff
changeset
|
3799 |
return free_bytes(Metaspace::ClassType) + free_bytes(Metaspace::NonClassType); |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3800 |
} |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3801 |
|
17628
481e0280aed3
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
17117
diff
changeset
|
3802 |
void MetaspaceAux::dec_capacity(Metaspace::MetadataType mdtype, size_t words) { |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3803 |
assert_lock_strong(SpaceManager::expand_lock()); |
23854
50f7f89b34e0
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
23503
diff
changeset
|
3804 |
assert(words <= capacity_words(mdtype), |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
3805 |
"About to decrement below 0: words " SIZE_FORMAT |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
3806 |
" is greater than _capacity_words[%u] " SIZE_FORMAT, |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
3807 |
words, mdtype, capacity_words(mdtype)); |
23854
50f7f89b34e0
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
23503
diff
changeset
|
3808 |
_capacity_words[mdtype] -= words; |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3809 |
} |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3810 |
|
17628
481e0280aed3
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
17117
diff
changeset
|
3811 |
void MetaspaceAux::inc_capacity(Metaspace::MetadataType mdtype, size_t words) { |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3812 |
assert_lock_strong(SpaceManager::expand_lock()); |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3813 |
// Needs to be atomic |
23854
50f7f89b34e0
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
23503
diff
changeset
|
3814 |
_capacity_words[mdtype] += words; |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3815 |
} |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3816 |
|
17628
481e0280aed3
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
17117
diff
changeset
|
3817 |
void MetaspaceAux::dec_used(Metaspace::MetadataType mdtype, size_t words) { |
23854
50f7f89b34e0
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
23503
diff
changeset
|
3818 |
assert(words <= used_words(mdtype), |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
3819 |
"About to decrement below 0: words " SIZE_FORMAT |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
3820 |
" is greater than _used_words[%u] " SIZE_FORMAT, |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
3821 |
words, mdtype, used_words(mdtype)); |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3822 |
// For CMS deallocation of the Metaspaces occurs during the |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3823 |
// sweep which is a concurrent phase. Protection by the expand_lock() |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3824 |
// is not enough since allocation is on a per Metaspace basis |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3825 |
// and protected by the Metaspace lock. |
47634
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47599
diff
changeset
|
3826 |
Atomic::sub(words, &_used_words[mdtype]); |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3827 |
} |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3828 |
|
17628
481e0280aed3
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
17117
diff
changeset
|
3829 |
void MetaspaceAux::inc_used(Metaspace::MetadataType mdtype, size_t words) { |
23854
50f7f89b34e0
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
23503
diff
changeset
|
3830 |
// _used_words tracks allocations for |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3831 |
// each piece of metadata. Those allocations are |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3832 |
// generally done concurrently by different application |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3833 |
// threads so must be done atomically. |
47634
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47599
diff
changeset
|
3834 |
Atomic::add(words, &_used_words[mdtype]); |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3835 |
} |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3836 |
|
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3837 |
size_t MetaspaceAux::used_bytes_slow(Metaspace::MetadataType mdtype) { |
13733
e41e23ae6758
7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents:
13729
diff
changeset
|
3838 |
size_t used = 0; |
e41e23ae6758
7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents:
13729
diff
changeset
|
3839 |
ClassLoaderDataGraphMetaspaceIterator iter; |
e41e23ae6758
7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents:
13729
diff
changeset
|
3840 |
while (iter.repeat()) { |
e41e23ae6758
7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents:
13729
diff
changeset
|
3841 |
Metaspace* msp = iter.get_next(); |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3842 |
// Sum allocated_blocks_words for each metaspace |
13733
e41e23ae6758
7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents:
13729
diff
changeset
|
3843 |
if (msp != NULL) { |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3844 |
used += msp->used_words_slow(mdtype); |
13733
e41e23ae6758
7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents:
13729
diff
changeset
|
3845 |
} |
e41e23ae6758
7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents:
13729
diff
changeset
|
3846 |
} |
e41e23ae6758
7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents:
13729
diff
changeset
|
3847 |
return used * BytesPerWord; |
e41e23ae6758
7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents:
13729
diff
changeset
|
3848 |
} |
e41e23ae6758
7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents:
13729
diff
changeset
|
3849 |
|
19988 | 3850 |
size_t MetaspaceAux::free_bytes_slow(Metaspace::MetadataType mdtype) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3851 |
size_t free = 0; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3852 |
ClassLoaderDataGraphMetaspaceIterator iter; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3853 |
while (iter.repeat()) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3854 |
Metaspace* msp = iter.get_next(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3855 |
if (msp != NULL) { |
19988 | 3856 |
free += msp->free_words_slow(mdtype); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3857 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3858 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3859 |
return free * BytesPerWord; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3860 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3861 |
|
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3862 |
size_t MetaspaceAux::capacity_bytes_slow(Metaspace::MetadataType mdtype) { |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
3863 |
if ((mdtype == Metaspace::ClassType) && !Metaspace::using_class_space()) { |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
3864 |
return 0; |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
3865 |
} |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3866 |
// Don't count the space in the freelists. That space will be |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3867 |
// added to the capacity calculation as needed. |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3868 |
size_t capacity = 0; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3869 |
ClassLoaderDataGraphMetaspaceIterator iter; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3870 |
while (iter.repeat()) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3871 |
Metaspace* msp = iter.get_next(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3872 |
if (msp != NULL) { |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3873 |
capacity += msp->capacity_words_slow(mdtype); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3874 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3875 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3876 |
return capacity * BytesPerWord; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3877 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3878 |
|
19988 | 3879 |
size_t MetaspaceAux::capacity_bytes_slow() { |
3880 |
#ifdef PRODUCT |
|
23854
50f7f89b34e0
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
23503
diff
changeset
|
3881 |
// Use capacity_bytes() in PRODUCT instead of this function. |
19988 | 3882 |
guarantee(false, "Should not call capacity_bytes_slow() in the PRODUCT"); |
3883 |
#endif |
|
3884 |
size_t class_capacity = capacity_bytes_slow(Metaspace::ClassType); |
|
3885 |
size_t non_class_capacity = capacity_bytes_slow(Metaspace::NonClassType); |
|
23854
50f7f89b34e0
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
23503
diff
changeset
|
3886 |
assert(capacity_bytes() == class_capacity + non_class_capacity, |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
3887 |
"bad accounting: capacity_bytes() " SIZE_FORMAT |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
3888 |
" class_capacity + non_class_capacity " SIZE_FORMAT |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
3889 |
" class_capacity " SIZE_FORMAT " non_class_capacity " SIZE_FORMAT, |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
3890 |
capacity_bytes(), class_capacity + non_class_capacity, |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
3891 |
class_capacity, non_class_capacity); |
19988 | 3892 |
|
3893 |
return class_capacity + non_class_capacity; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3894 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3895 |
|
19988 | 3896 |
size_t MetaspaceAux::reserved_bytes(Metaspace::MetadataType mdtype) { |
3897 |
VirtualSpaceList* list = Metaspace::get_space_list(mdtype); |
|
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
3898 |
return list == NULL ? 0 : list->reserved_bytes(); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
3899 |
} |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
3900 |
|
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
3901 |
size_t MetaspaceAux::committed_bytes(Metaspace::MetadataType mdtype) { |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
3902 |
VirtualSpaceList* list = Metaspace::get_space_list(mdtype); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
3903 |
return list == NULL ? 0 : list->committed_bytes(); |
19988 | 3904 |
} |
3905 |
||
3906 |
size_t MetaspaceAux::min_chunk_size_words() { return Metaspace::first_chunk_word_size(); } |
|
3907 |
||
3908 |
size_t MetaspaceAux::free_chunks_total_words(Metaspace::MetadataType mdtype) { |
|
20081
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
3909 |
ChunkManager* chunk_manager = Metaspace::get_chunk_manager(mdtype); |
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
3910 |
if (chunk_manager == NULL) { |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
3911 |
return 0; |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
3912 |
} |
20081
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
3913 |
chunk_manager->slow_verify(); |
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
3914 |
return chunk_manager->free_chunks_total_words(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3915 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3916 |
|
19988 | 3917 |
size_t MetaspaceAux::free_chunks_total_bytes(Metaspace::MetadataType mdtype) { |
3918 |
return free_chunks_total_words(mdtype) * BytesPerWord; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3919 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3920 |
|
19988 | 3921 |
size_t MetaspaceAux::free_chunks_total_words() { |
3922 |
return free_chunks_total_words(Metaspace::ClassType) + |
|
3923 |
free_chunks_total_words(Metaspace::NonClassType); |
|
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3924 |
} |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3925 |
|
19988 | 3926 |
size_t MetaspaceAux::free_chunks_total_bytes() { |
3927 |
return free_chunks_total_words() * BytesPerWord; |
|
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3928 |
} |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3929 |
|
23470
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
3930 |
bool MetaspaceAux::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
|
3931 |
return Metaspace::get_chunk_manager(mdtype) != NULL; |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
3932 |
} |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
3933 |
|
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
3934 |
MetaspaceChunkFreeListSummary MetaspaceAux::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
|
3935 |
if (!has_chunk_free_list(mdtype)) { |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
3936 |
return MetaspaceChunkFreeListSummary(); |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
3937 |
} |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
3938 |
|
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
3939 |
const ChunkManager* cm = Metaspace::get_chunk_manager(mdtype); |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
3940 |
return cm->chunk_free_list_summary(); |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
3941 |
} |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
3942 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3943 |
void MetaspaceAux::print_metaspace_change(size_t prev_metadata_used) { |
35061 | 3944 |
log_info(gc, metaspace)("Metaspace: " SIZE_FORMAT "K->" SIZE_FORMAT "K(" SIZE_FORMAT "K)", |
3945 |
prev_metadata_used/K, used_bytes()/K, reserved_bytes()/K); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3946 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3947 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3948 |
void MetaspaceAux::print_on(outputStream* out) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3949 |
Metaspace::MetadataType nct = Metaspace::NonClassType; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3950 |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
3951 |
out->print_cr(" Metaspace " |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
3952 |
"used " SIZE_FORMAT "K, " |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
3953 |
"capacity " SIZE_FORMAT "K, " |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
3954 |
"committed " SIZE_FORMAT "K, " |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
3955 |
"reserved " SIZE_FORMAT "K", |
23854
50f7f89b34e0
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
23503
diff
changeset
|
3956 |
used_bytes()/K, |
50f7f89b34e0
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
23503
diff
changeset
|
3957 |
capacity_bytes()/K, |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
3958 |
committed_bytes()/K, |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
3959 |
reserved_bytes()/K); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
3960 |
|
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
3961 |
if (Metaspace::using_class_space()) { |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
3962 |
Metaspace::MetadataType ct = Metaspace::ClassType; |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
3963 |
out->print_cr(" class space " |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
3964 |
"used " SIZE_FORMAT "K, " |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
3965 |
"capacity " SIZE_FORMAT "K, " |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
3966 |
"committed " SIZE_FORMAT "K, " |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
3967 |
"reserved " SIZE_FORMAT "K", |
23854
50f7f89b34e0
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
23503
diff
changeset
|
3968 |
used_bytes(ct)/K, |
50f7f89b34e0
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
23503
diff
changeset
|
3969 |
capacity_bytes(ct)/K, |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
3970 |
committed_bytes(ct)/K, |
19988 | 3971 |
reserved_bytes(ct)/K); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
3972 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3973 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3974 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3975 |
// Print information for class space and data space separately. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3976 |
// This is almost the same as above. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3977 |
void MetaspaceAux::print_on(outputStream* out, Metaspace::MetadataType mdtype) { |
19988 | 3978 |
size_t free_chunks_capacity_bytes = free_chunks_total_bytes(mdtype); |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3979 |
size_t capacity_bytes = capacity_bytes_slow(mdtype); |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
3980 |
size_t used_bytes = used_bytes_slow(mdtype); |
19988 | 3981 |
size_t free_bytes = free_bytes_slow(mdtype); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3982 |
size_t used_and_free = used_bytes + free_bytes + |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3983 |
free_chunks_capacity_bytes; |
47808
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
3984 |
out->print_cr(" Chunk accounting: (used in chunks " SIZE_FORMAT |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3985 |
"K + unused in chunks " SIZE_FORMAT "K + " |
47808
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
3986 |
" capacity in free chunks " SIZE_FORMAT "K) = " SIZE_FORMAT |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3987 |
"K capacity in allocated chunks " SIZE_FORMAT "K", |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3988 |
used_bytes / K, |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3989 |
free_bytes / K, |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3990 |
free_chunks_capacity_bytes / K, |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3991 |
used_and_free / K, |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3992 |
capacity_bytes / K); |
15954
fbcf5f5047c6
8009282: Assertion "assert(used_and_free == capacity_bytes) failed: Accounting is wrong" failed with -XX:+Verbose -XX:+TraceMetadataChunkAllocation
mgerdin
parents:
15610
diff
changeset
|
3993 |
// Accounting can only be correct if we got the values during a safepoint |
fbcf5f5047c6
8009282: Assertion "assert(used_and_free == capacity_bytes) failed: Accounting is wrong" failed with -XX:+Verbose -XX:+TraceMetadataChunkAllocation
mgerdin
parents:
15610
diff
changeset
|
3994 |
assert(!SafepointSynchronize::is_at_safepoint() || used_and_free == capacity_bytes, "Accounting is wrong"); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3995 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3996 |
|
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
3997 |
// Print total fragmentation for class metaspaces |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
3998 |
void MetaspaceAux::print_class_waste(outputStream* out) { |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
3999 |
assert(Metaspace::using_class_space(), "class metaspace not used"); |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4000 |
size_t cls_specialized_waste = 0, cls_small_waste = 0, cls_medium_waste = 0; |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4001 |
size_t cls_specialized_count = 0, cls_small_count = 0, cls_medium_count = 0, cls_humongous_count = 0; |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4002 |
ClassLoaderDataGraphMetaspaceIterator iter; |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4003 |
while (iter.repeat()) { |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4004 |
Metaspace* msp = iter.get_next(); |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4005 |
if (msp != NULL) { |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4006 |
cls_specialized_waste += msp->class_vsm()->sum_waste_in_chunks_in_use(SpecializedIndex); |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4007 |
cls_specialized_count += msp->class_vsm()->sum_count_in_chunks_in_use(SpecializedIndex); |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4008 |
cls_small_waste += msp->class_vsm()->sum_waste_in_chunks_in_use(SmallIndex); |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4009 |
cls_small_count += msp->class_vsm()->sum_count_in_chunks_in_use(SmallIndex); |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4010 |
cls_medium_waste += msp->class_vsm()->sum_waste_in_chunks_in_use(MediumIndex); |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4011 |
cls_medium_count += msp->class_vsm()->sum_count_in_chunks_in_use(MediumIndex); |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4012 |
cls_humongous_count += msp->class_vsm()->sum_count_in_chunks_in_use(HumongousIndex); |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4013 |
} |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4014 |
} |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4015 |
out->print_cr(" class: " SIZE_FORMAT " specialized(s) " SIZE_FORMAT ", " |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4016 |
SIZE_FORMAT " small(s) " SIZE_FORMAT ", " |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4017 |
SIZE_FORMAT " medium(s) " SIZE_FORMAT ", " |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4018 |
"large count " SIZE_FORMAT, |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4019 |
cls_specialized_count, cls_specialized_waste, |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4020 |
cls_small_count, cls_small_waste, |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4021 |
cls_medium_count, cls_medium_waste, cls_humongous_count); |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4022 |
} |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4023 |
|
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4024 |
// Print total fragmentation for data and class metaspaces separately |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4025 |
void MetaspaceAux::print_waste(outputStream* out) { |
18491
dd63ba6b0ee4
8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents:
17858
diff
changeset
|
4026 |
size_t specialized_waste = 0, small_waste = 0, medium_waste = 0; |
dd63ba6b0ee4
8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents:
17858
diff
changeset
|
4027 |
size_t specialized_count = 0, small_count = 0, medium_count = 0, humongous_count = 0; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4028 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4029 |
ClassLoaderDataGraphMetaspaceIterator iter; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4030 |
while (iter.repeat()) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4031 |
Metaspace* msp = iter.get_next(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4032 |
if (msp != NULL) { |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
4033 |
specialized_waste += msp->vsm()->sum_waste_in_chunks_in_use(SpecializedIndex); |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
4034 |
specialized_count += msp->vsm()->sum_count_in_chunks_in_use(SpecializedIndex); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4035 |
small_waste += msp->vsm()->sum_waste_in_chunks_in_use(SmallIndex); |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
4036 |
small_count += msp->vsm()->sum_count_in_chunks_in_use(SmallIndex); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4037 |
medium_waste += msp->vsm()->sum_waste_in_chunks_in_use(MediumIndex); |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
4038 |
medium_count += msp->vsm()->sum_count_in_chunks_in_use(MediumIndex); |
18491
dd63ba6b0ee4
8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents:
17858
diff
changeset
|
4039 |
humongous_count += msp->vsm()->sum_count_in_chunks_in_use(HumongousIndex); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4040 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4041 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4042 |
out->print_cr("Total fragmentation waste (words) doesn't count free space"); |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
4043 |
out->print_cr(" data: " SIZE_FORMAT " specialized(s) " SIZE_FORMAT ", " |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
4044 |
SIZE_FORMAT " small(s) " SIZE_FORMAT ", " |
18491
dd63ba6b0ee4
8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents:
17858
diff
changeset
|
4045 |
SIZE_FORMAT " medium(s) " SIZE_FORMAT ", " |
dd63ba6b0ee4
8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents:
17858
diff
changeset
|
4046 |
"large count " SIZE_FORMAT, |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
4047 |
specialized_count, specialized_waste, small_count, |
18491
dd63ba6b0ee4
8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents:
17858
diff
changeset
|
4048 |
small_waste, medium_count, medium_waste, humongous_count); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4049 |
if (Metaspace::using_class_space()) { |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4050 |
print_class_waste(out); |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4051 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4052 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4053 |
|
49364
601146c66cad
8173070: Remove ValueObj class for allocation subclassing for runtime code
coleenp
parents:
49348
diff
changeset
|
4054 |
class MetadataStats { |
47802
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4055 |
private: |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4056 |
size_t _capacity; |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4057 |
size_t _used; |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4058 |
size_t _free; |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4059 |
size_t _waste; |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4060 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4061 |
public: |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4062 |
MetadataStats() : _capacity(0), _used(0), _free(0), _waste(0) { } |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4063 |
MetadataStats(size_t capacity, size_t used, size_t free, size_t waste) |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4064 |
: _capacity(capacity), _used(used), _free(free), _waste(waste) { } |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4065 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4066 |
void add(const MetadataStats& stats) { |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4067 |
_capacity += stats.capacity(); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4068 |
_used += stats.used(); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4069 |
_free += stats.free(); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4070 |
_waste += stats.waste(); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4071 |
} |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4072 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4073 |
size_t capacity() const { return _capacity; } |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4074 |
size_t used() const { return _used; } |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4075 |
size_t free() const { return _free; } |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4076 |
size_t waste() const { return _waste; } |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4077 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4078 |
void print_on(outputStream* out, size_t scale) const; |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4079 |
}; |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4080 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4081 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4082 |
void MetadataStats::print_on(outputStream* out, size_t scale) const { |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4083 |
const char* unit = scale_unit(scale); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4084 |
out->print_cr("capacity=%10.2f%s used=%10.2f%s free=%10.2f%s waste=%10.2f%s", |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4085 |
(float)capacity() / scale, unit, |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4086 |
(float)used() / scale, unit, |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4087 |
(float)free() / scale, unit, |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4088 |
(float)waste() / scale, unit); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4089 |
} |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4090 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4091 |
class PrintCLDMetaspaceInfoClosure : public CLDClosure { |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4092 |
private: |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4093 |
outputStream* _out; |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4094 |
size_t _scale; |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4095 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4096 |
size_t _total_count; |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4097 |
MetadataStats _total_metadata; |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4098 |
MetadataStats _total_class; |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4099 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4100 |
size_t _total_anon_count; |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4101 |
MetadataStats _total_anon_metadata; |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4102 |
MetadataStats _total_anon_class; |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4103 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4104 |
public: |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4105 |
PrintCLDMetaspaceInfoClosure(outputStream* out, size_t scale = K) |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4106 |
: _out(out), _scale(scale), _total_count(0), _total_anon_count(0) { } |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4107 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4108 |
~PrintCLDMetaspaceInfoClosure() { |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4109 |
print_summary(); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4110 |
} |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4111 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4112 |
void do_cld(ClassLoaderData* cld) { |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4113 |
assert(SafepointSynchronize::is_at_safepoint(), "Must be at a safepoint"); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4114 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4115 |
if (cld->is_unloading()) return; |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4116 |
Metaspace* msp = cld->metaspace_or_null(); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4117 |
if (msp == NULL) { |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4118 |
return; |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4119 |
} |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4120 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4121 |
bool anonymous = false; |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4122 |
if (cld->is_anonymous()) { |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4123 |
_out->print_cr("ClassLoader: for anonymous class"); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4124 |
anonymous = true; |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4125 |
} else { |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4126 |
ResourceMark rm; |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4127 |
_out->print_cr("ClassLoader: %s", cld->loader_name()); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4128 |
} |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4129 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4130 |
print_metaspace(msp, anonymous); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4131 |
_out->cr(); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4132 |
} |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4133 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4134 |
private: |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4135 |
void print_metaspace(Metaspace* msp, bool anonymous); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4136 |
void print_summary() const; |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4137 |
}; |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4138 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4139 |
void PrintCLDMetaspaceInfoClosure::print_metaspace(Metaspace* msp, bool anonymous){ |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4140 |
assert(msp != NULL, "Sanity"); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4141 |
SpaceManager* vsm = msp->vsm(); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4142 |
const char* unit = scale_unit(_scale); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4143 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4144 |
size_t capacity = vsm->sum_capacity_in_chunks_in_use() * BytesPerWord; |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4145 |
size_t used = vsm->sum_used_in_chunks_in_use() * BytesPerWord; |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4146 |
size_t free = vsm->sum_free_in_chunks_in_use() * BytesPerWord; |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4147 |
size_t waste = vsm->sum_waste_in_chunks_in_use() * BytesPerWord; |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4148 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4149 |
_total_count ++; |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4150 |
MetadataStats metadata_stats(capacity, used, free, waste); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4151 |
_total_metadata.add(metadata_stats); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4152 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4153 |
if (anonymous) { |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4154 |
_total_anon_count ++; |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4155 |
_total_anon_metadata.add(metadata_stats); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4156 |
} |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4157 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4158 |
_out->print(" Metadata "); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4159 |
metadata_stats.print_on(_out, _scale); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4160 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4161 |
if (Metaspace::using_class_space()) { |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4162 |
vsm = msp->class_vsm(); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4163 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4164 |
capacity = vsm->sum_capacity_in_chunks_in_use() * BytesPerWord; |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4165 |
used = vsm->sum_used_in_chunks_in_use() * BytesPerWord; |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4166 |
free = vsm->sum_free_in_chunks_in_use() * BytesPerWord; |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4167 |
waste = vsm->sum_waste_in_chunks_in_use() * BytesPerWord; |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4168 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4169 |
MetadataStats class_stats(capacity, used, free, waste); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4170 |
_total_class.add(class_stats); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4171 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4172 |
if (anonymous) { |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4173 |
_total_anon_class.add(class_stats); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4174 |
} |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4175 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4176 |
_out->print(" Class data "); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4177 |
class_stats.print_on(_out, _scale); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4178 |
} |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4179 |
} |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4180 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4181 |
void PrintCLDMetaspaceInfoClosure::print_summary() const { |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4182 |
const char* unit = scale_unit(_scale); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4183 |
_out->cr(); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4184 |
_out->print_cr("Summary:"); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4185 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4186 |
MetadataStats total; |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4187 |
total.add(_total_metadata); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4188 |
total.add(_total_class); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4189 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4190 |
_out->print(" Total class loaders=" SIZE_FORMAT_W(6) " ", _total_count); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4191 |
total.print_on(_out, _scale); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4192 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4193 |
_out->print(" Metadata "); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4194 |
_total_metadata.print_on(_out, _scale); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4195 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4196 |
if (Metaspace::using_class_space()) { |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4197 |
_out->print(" Class data "); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4198 |
_total_class.print_on(_out, _scale); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4199 |
} |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4200 |
_out->cr(); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4201 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4202 |
MetadataStats total_anon; |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4203 |
total_anon.add(_total_anon_metadata); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4204 |
total_anon.add(_total_anon_class); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4205 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4206 |
_out->print("For anonymous classes=" SIZE_FORMAT_W(6) " ", _total_anon_count); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4207 |
total_anon.print_on(_out, _scale); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4208 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4209 |
_out->print(" Metadata "); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4210 |
_total_anon_metadata.print_on(_out, _scale); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4211 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4212 |
if (Metaspace::using_class_space()) { |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4213 |
_out->print(" Class data "); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4214 |
_total_anon_class.print_on(_out, _scale); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4215 |
} |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4216 |
} |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4217 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4218 |
void MetaspaceAux::print_metadata_for_nmt(outputStream* out, size_t scale) { |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4219 |
const char* unit = scale_unit(scale); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4220 |
out->print_cr("Metaspaces:"); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4221 |
out->print_cr(" Metadata space: reserved=" SIZE_FORMAT_W(10) "%s committed=" SIZE_FORMAT_W(10) "%s", |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4222 |
reserved_bytes(Metaspace::NonClassType) / scale, unit, |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4223 |
committed_bytes(Metaspace::NonClassType) / scale, unit); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4224 |
if (Metaspace::using_class_space()) { |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4225 |
out->print_cr(" Class space: reserved=" SIZE_FORMAT_W(10) "%s committed=" SIZE_FORMAT_W(10) "%s", |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4226 |
reserved_bytes(Metaspace::ClassType) / scale, unit, |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4227 |
committed_bytes(Metaspace::ClassType) / scale, unit); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4228 |
} |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4229 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4230 |
out->cr(); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4231 |
ChunkManager::print_all_chunkmanagers(out, scale); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4232 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4233 |
out->cr(); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4234 |
out->print_cr("Per-classloader metadata:"); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4235 |
out->cr(); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4236 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4237 |
PrintCLDMetaspaceInfoClosure cl(out, scale); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4238 |
ClassLoaderDataGraph::cld_do(&cl); |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4239 |
} |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4240 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
4241 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4242 |
// Dump global metaspace things from the end of ClassLoaderDataGraph |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4243 |
void MetaspaceAux::dump(outputStream* out) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4244 |
out->print_cr("All Metaspace:"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4245 |
out->print("data space: "); print_on(out, Metaspace::NonClassType); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4246 |
out->print("class space: "); print_on(out, Metaspace::ClassType); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4247 |
print_waste(out); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4248 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4249 |
|
47808
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
4250 |
// Prints an ASCII representation of the given space. |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
4251 |
void MetaspaceAux::print_metaspace_map(outputStream* out, Metaspace::MetadataType mdtype) { |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
4252 |
MutexLockerEx cl(SpaceManager::expand_lock(), Mutex::_no_safepoint_check_flag); |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
4253 |
const bool for_class = mdtype == Metaspace::ClassType ? true : false; |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
4254 |
VirtualSpaceList* const vsl = for_class ? Metaspace::class_space_list() : Metaspace::space_list(); |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
4255 |
if (vsl != NULL) { |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
4256 |
if (for_class) { |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
4257 |
if (!Metaspace::using_class_space()) { |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
4258 |
out->print_cr("No Class Space."); |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
4259 |
return; |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
4260 |
} |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
4261 |
out->print_raw("---- Metaspace Map (Class Space) ----"); |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
4262 |
} else { |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
4263 |
out->print_raw("---- Metaspace Map (Non-Class Space) ----"); |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
4264 |
} |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
4265 |
// Print legend: |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
4266 |
out->cr(); |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
4267 |
out->print_cr("Chunk Types (uppercase chunks are in use): x-specialized, s-small, m-medium, h-humongous."); |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
4268 |
out->cr(); |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
4269 |
VirtualSpaceList* const vsl = for_class ? Metaspace::class_space_list() : Metaspace::space_list(); |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
4270 |
vsl->print_map(out); |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
4271 |
out->cr(); |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
4272 |
} |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
4273 |
} |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
4274 |
|
14474
4154f1817a75
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
14123
diff
changeset
|
4275 |
void MetaspaceAux::verify_free_chunks() { |
20081
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
4276 |
Metaspace::chunk_manager_metadata()->verify(); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4277 |
if (Metaspace::using_class_space()) { |
20081
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
4278 |
Metaspace::chunk_manager_class()->verify(); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4279 |
} |
14474
4154f1817a75
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
14123
diff
changeset
|
4280 |
} |
4154f1817a75
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
14123
diff
changeset
|
4281 |
|
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
4282 |
void MetaspaceAux::verify_capacity() { |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
4283 |
#ifdef ASSERT |
23854
50f7f89b34e0
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
23503
diff
changeset
|
4284 |
size_t running_sum_capacity_bytes = capacity_bytes(); |
17628
481e0280aed3
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
17117
diff
changeset
|
4285 |
// For purposes of the running sum of capacity, verify against capacity |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
4286 |
size_t capacity_in_use_bytes = capacity_bytes_slow(); |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
4287 |
assert(running_sum_capacity_bytes == capacity_in_use_bytes, |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
4288 |
"capacity_words() * BytesPerWord " SIZE_FORMAT |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
4289 |
" capacity_bytes_slow()" SIZE_FORMAT, |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
4290 |
running_sum_capacity_bytes, capacity_in_use_bytes); |
17628
481e0280aed3
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
17117
diff
changeset
|
4291 |
for (Metaspace::MetadataType i = Metaspace::ClassType; |
481e0280aed3
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
17117
diff
changeset
|
4292 |
i < Metaspace:: MetadataTypeCount; |
481e0280aed3
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
17117
diff
changeset
|
4293 |
i = (Metaspace::MetadataType)(i + 1)) { |
481e0280aed3
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
17117
diff
changeset
|
4294 |
size_t capacity_in_use_bytes = capacity_bytes_slow(i); |
23854
50f7f89b34e0
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
23503
diff
changeset
|
4295 |
assert(capacity_bytes(i) == capacity_in_use_bytes, |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
4296 |
"capacity_bytes(%u) " SIZE_FORMAT |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
4297 |
" capacity_bytes_slow(%u)" SIZE_FORMAT, |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
4298 |
i, capacity_bytes(i), i, capacity_in_use_bytes); |
17628
481e0280aed3
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
17117
diff
changeset
|
4299 |
} |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
4300 |
#endif |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
4301 |
} |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
4302 |
|
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
4303 |
void MetaspaceAux::verify_used() { |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
4304 |
#ifdef ASSERT |
23854
50f7f89b34e0
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
23503
diff
changeset
|
4305 |
size_t running_sum_used_bytes = used_bytes(); |
17628
481e0280aed3
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
17117
diff
changeset
|
4306 |
// For purposes of the running sum of used, verify against used |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
4307 |
size_t used_in_use_bytes = used_bytes_slow(); |
23854
50f7f89b34e0
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
23503
diff
changeset
|
4308 |
assert(used_bytes() == used_in_use_bytes, |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
4309 |
"used_bytes() " SIZE_FORMAT |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
4310 |
" used_bytes_slow()" SIZE_FORMAT, |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
4311 |
used_bytes(), used_in_use_bytes); |
17628
481e0280aed3
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
17117
diff
changeset
|
4312 |
for (Metaspace::MetadataType i = Metaspace::ClassType; |
481e0280aed3
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
17117
diff
changeset
|
4313 |
i < Metaspace:: MetadataTypeCount; |
481e0280aed3
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
17117
diff
changeset
|
4314 |
i = (Metaspace::MetadataType)(i + 1)) { |
481e0280aed3
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
17117
diff
changeset
|
4315 |
size_t used_in_use_bytes = used_bytes_slow(i); |
23854
50f7f89b34e0
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
23503
diff
changeset
|
4316 |
assert(used_bytes(i) == used_in_use_bytes, |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
4317 |
"used_bytes(%u) " SIZE_FORMAT |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
4318 |
" used_bytes_slow(%u)" SIZE_FORMAT, |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
4319 |
i, used_bytes(i), i, used_in_use_bytes); |
17628
481e0280aed3
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
17117
diff
changeset
|
4320 |
} |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
4321 |
#endif |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
4322 |
} |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
4323 |
|
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
4324 |
void MetaspaceAux::verify_metrics() { |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
4325 |
verify_capacity(); |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
4326 |
verify_used(); |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
4327 |
} |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
4328 |
|
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
4329 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4330 |
// Metaspace methods |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4331 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4332 |
size_t Metaspace::_first_chunk_word_size = 0; |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
4333 |
size_t Metaspace::_first_class_chunk_word_size = 0; |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
4334 |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4335 |
size_t Metaspace::_commit_alignment = 0; |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4336 |
size_t Metaspace::_reserve_alignment = 0; |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4337 |
|
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
4338 |
Metaspace::Metaspace(Mutex* lock, MetaspaceType type) { |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
4339 |
initialize(lock, type); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4340 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4341 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4342 |
Metaspace::~Metaspace() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4343 |
delete _vsm; |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4344 |
if (using_class_space()) { |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4345 |
delete _class_vsm; |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4346 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4347 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4348 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4349 |
VirtualSpaceList* Metaspace::_space_list = NULL; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4350 |
VirtualSpaceList* Metaspace::_class_space_list = NULL; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4351 |
|
20081
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
4352 |
ChunkManager* Metaspace::_chunk_manager_metadata = NULL; |
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
4353 |
ChunkManager* Metaspace::_chunk_manager_class = NULL; |
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
4354 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4355 |
#define VIRTUALSPACEMULTIPLIER 2 |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4356 |
|
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4357 |
#ifdef _LP64 |
21188
d053e4e8f901
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
21186
diff
changeset
|
4358 |
static const uint64_t UnscaledClassSpaceMax = (uint64_t(max_juint) + 1); |
d053e4e8f901
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
21186
diff
changeset
|
4359 |
|
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4360 |
void Metaspace::set_narrow_klass_base_and_shift(address metaspace_base, address cds_base) { |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
4361 |
assert(!DumpSharedSpaces, "narrow_klass is set by MetaspaceShared class."); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4362 |
// Figure out the narrow_klass_base and the narrow_klass_shift. The |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4363 |
// narrow_klass_base is the lower of the metaspace base and the cds base |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4364 |
// (if cds is enabled). The narrow_klass_shift depends on the distance |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4365 |
// between the lower base and higher address. |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4366 |
address lower_base; |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4367 |
address higher_address; |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25055
diff
changeset
|
4368 |
#if INCLUDE_CDS |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4369 |
if (UseSharedSpaces) { |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
4370 |
higher_address = MAX2((address)(cds_base + MetaspaceShared::core_spaces_size()), |
21188
d053e4e8f901
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
21186
diff
changeset
|
4371 |
(address)(metaspace_base + compressed_class_space_size())); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4372 |
lower_base = MIN2(metaspace_base, cds_base); |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25055
diff
changeset
|
4373 |
} else |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25055
diff
changeset
|
4374 |
#endif |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25055
diff
changeset
|
4375 |
{ |
21188
d053e4e8f901
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
21186
diff
changeset
|
4376 |
higher_address = metaspace_base + compressed_class_space_size(); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4377 |
lower_base = metaspace_base; |
21188
d053e4e8f901
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
21186
diff
changeset
|
4378 |
|
d053e4e8f901
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
21186
diff
changeset
|
4379 |
uint64_t klass_encoding_max = UnscaledClassSpaceMax << LogKlassAlignmentInBytes; |
d053e4e8f901
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
21186
diff
changeset
|
4380 |
// If compressed class space fits in lower 32G, we don't need a base. |
d053e4e8f901
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
21186
diff
changeset
|
4381 |
if (higher_address <= (address)klass_encoding_max) { |
22551 | 4382 |
lower_base = 0; // Effectively lower base is zero. |
21188
d053e4e8f901
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
21186
diff
changeset
|
4383 |
} |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4384 |
} |
21188
d053e4e8f901
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
21186
diff
changeset
|
4385 |
|
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4386 |
Universe::set_narrow_klass_base(lower_base); |
21188
d053e4e8f901
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
21186
diff
changeset
|
4387 |
|
47599
0fb1d501c408
8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents:
47553
diff
changeset
|
4388 |
// CDS uses LogKlassAlignmentInBytes for narrow_klass_shift. See |
0fb1d501c408
8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents:
47553
diff
changeset
|
4389 |
// MetaspaceShared::initialize_dumptime_shared_and_meta_spaces() for |
0fb1d501c408
8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents:
47553
diff
changeset
|
4390 |
// how dump time narrow_klass_shift is set. Although, CDS can work |
0fb1d501c408
8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents:
47553
diff
changeset
|
4391 |
// with zero-shift mode also, to be consistent with AOT it uses |
0fb1d501c408
8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents:
47553
diff
changeset
|
4392 |
// LogKlassAlignmentInBytes for klass shift so archived java heap objects |
0fb1d501c408
8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents:
47553
diff
changeset
|
4393 |
// can be used at same time as AOT code. |
0fb1d501c408
8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents:
47553
diff
changeset
|
4394 |
if (!UseSharedSpaces |
0fb1d501c408
8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents:
47553
diff
changeset
|
4395 |
&& (uint64_t)(higher_address - lower_base) <= UnscaledClassSpaceMax) { |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4396 |
Universe::set_narrow_klass_shift(0); |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4397 |
} else { |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4398 |
Universe::set_narrow_klass_shift(LogKlassAlignmentInBytes); |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4399 |
} |
42650 | 4400 |
AOTLoader::set_narrow_klass_shift(); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4401 |
} |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4402 |
|
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25055
diff
changeset
|
4403 |
#if INCLUDE_CDS |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4404 |
// Return TRUE if the specified metaspace_base and cds_base are close enough |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4405 |
// to work with compressed klass pointers. |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4406 |
bool Metaspace::can_use_cds_with_metaspace_addr(char* metaspace_base, address cds_base) { |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4407 |
assert(cds_base != 0 && UseSharedSpaces, "Only use with CDS"); |
19979
ebe1dbb6e1aa
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
19546
diff
changeset
|
4408 |
assert(UseCompressedClassPointers, "Only use with CompressedKlassPtrs"); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4409 |
address lower_base = MIN2((address)metaspace_base, cds_base); |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
4410 |
address higher_address = MAX2((address)(cds_base + MetaspaceShared::core_spaces_size()), |
21188
d053e4e8f901
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
21186
diff
changeset
|
4411 |
(address)(metaspace_base + compressed_class_space_size())); |
21518
067dd7967128
8027616: Off by one error in putback for compressed oops nashorn performance improvement
coleenp
parents:
21189
diff
changeset
|
4412 |
return ((uint64_t)(higher_address - lower_base) <= UnscaledClassSpaceMax); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4413 |
} |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25055
diff
changeset
|
4414 |
#endif |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4415 |
|
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4416 |
// Try to allocate the metaspace at the requested addr. |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4417 |
void Metaspace::allocate_metaspace_compressed_klass_ptrs(char* requested_addr, address cds_base) { |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
4418 |
assert(!DumpSharedSpaces, "compress klass space is allocated by MetaspaceShared class."); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4419 |
assert(using_class_space(), "called improperly"); |
19979
ebe1dbb6e1aa
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
19546
diff
changeset
|
4420 |
assert(UseCompressedClassPointers, "Only use with CompressedKlassPtrs"); |
21188
d053e4e8f901
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
21186
diff
changeset
|
4421 |
assert(compressed_class_space_size() < KlassEncodingMetaspaceMax, |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4422 |
"Metaspace size is too big"); |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
4423 |
assert_is_aligned(requested_addr, _reserve_alignment); |
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
4424 |
assert_is_aligned(cds_base, _reserve_alignment); |
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
4425 |
assert_is_aligned(compressed_class_space_size(), _reserve_alignment); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4426 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4427 |
// Don't use large pages for the class space. |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4428 |
bool large_pages = false; |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4429 |
|
39229
8bfc00dd44b6
8159056: [aix] Compressed class space not allocated in lower regions
goetz
parents:
37267
diff
changeset
|
4430 |
#if !(defined(AARCH64) || defined(AIX)) |
21188
d053e4e8f901
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
21186
diff
changeset
|
4431 |
ReservedSpace metaspace_rs = ReservedSpace(compressed_class_space_size(), |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4432 |
_reserve_alignment, |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4433 |
large_pages, |
28372
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28163
diff
changeset
|
4434 |
requested_addr); |
29180 | 4435 |
#else // AARCH64 |
4436 |
ReservedSpace metaspace_rs; |
|
4437 |
||
4438 |
// Our compressed klass pointers may fit nicely into the lower 32 |
|
4439 |
// bits. |
|
4440 |
if ((uint64_t)requested_addr + compressed_class_space_size() < 4*G) { |
|
4441 |
metaspace_rs = ReservedSpace(compressed_class_space_size(), |
|
39229
8bfc00dd44b6
8159056: [aix] Compressed class space not allocated in lower regions
goetz
parents:
37267
diff
changeset
|
4442 |
_reserve_alignment, |
8bfc00dd44b6
8159056: [aix] Compressed class space not allocated in lower regions
goetz
parents:
37267
diff
changeset
|
4443 |
large_pages, |
8bfc00dd44b6
8159056: [aix] Compressed class space not allocated in lower regions
goetz
parents:
37267
diff
changeset
|
4444 |
requested_addr); |
29180 | 4445 |
} |
4446 |
||
4447 |
if (! metaspace_rs.is_reserved()) { |
|
39229
8bfc00dd44b6
8159056: [aix] Compressed class space not allocated in lower regions
goetz
parents:
37267
diff
changeset
|
4448 |
// Aarch64: Try to align metaspace so that we can decode a compressed |
8bfc00dd44b6
8159056: [aix] Compressed class space not allocated in lower regions
goetz
parents:
37267
diff
changeset
|
4449 |
// klass with a single MOVK instruction. We can do this iff the |
29180 | 4450 |
// compressed class base is a multiple of 4G. |
39229
8bfc00dd44b6
8159056: [aix] Compressed class space not allocated in lower regions
goetz
parents:
37267
diff
changeset
|
4451 |
// Aix: Search for a place where we can find memory. If we need to load |
8bfc00dd44b6
8159056: [aix] Compressed class space not allocated in lower regions
goetz
parents:
37267
diff
changeset
|
4452 |
// the base, 4G alignment is helpful, too. |
8bfc00dd44b6
8159056: [aix] Compressed class space not allocated in lower regions
goetz
parents:
37267
diff
changeset
|
4453 |
size_t increment = AARCH64_ONLY(4*)G; |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
4454 |
for (char *a = align_up(requested_addr, increment); |
29180 | 4455 |
a < (char*)(1024*G); |
39229
8bfc00dd44b6
8159056: [aix] Compressed class space not allocated in lower regions
goetz
parents:
37267
diff
changeset
|
4456 |
a += increment) { |
8bfc00dd44b6
8159056: [aix] Compressed class space not allocated in lower regions
goetz
parents:
37267
diff
changeset
|
4457 |
if (a == (char *)(32*G)) { |
8bfc00dd44b6
8159056: [aix] Compressed class space not allocated in lower regions
goetz
parents:
37267
diff
changeset
|
4458 |
// Go faster from here on. Zero-based is no longer possible. |
8bfc00dd44b6
8159056: [aix] Compressed class space not allocated in lower regions
goetz
parents:
37267
diff
changeset
|
4459 |
increment = 4*G; |
8bfc00dd44b6
8159056: [aix] Compressed class space not allocated in lower regions
goetz
parents:
37267
diff
changeset
|
4460 |
} |
29180 | 4461 |
|
4462 |
#if INCLUDE_CDS |
|
4463 |
if (UseSharedSpaces |
|
4464 |
&& ! can_use_cds_with_metaspace_addr(a, cds_base)) { |
|
4465 |
// We failed to find an aligned base that will reach. Fall |
|
4466 |
// back to using our requested addr. |
|
4467 |
metaspace_rs = ReservedSpace(compressed_class_space_size(), |
|
4468 |
_reserve_alignment, |
|
4469 |
large_pages, |
|
29187 | 4470 |
requested_addr); |
29180 | 4471 |
break; |
4472 |
} |
|
4473 |
#endif |
|
4474 |
||
4475 |
metaspace_rs = ReservedSpace(compressed_class_space_size(), |
|
4476 |
_reserve_alignment, |
|
4477 |
large_pages, |
|
29187 | 4478 |
a); |
29180 | 4479 |
if (metaspace_rs.is_reserved()) |
4480 |
break; |
|
4481 |
} |
|
4482 |
} |
|
4483 |
||
4484 |
#endif // AARCH64 |
|
4485 |
||
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4486 |
if (!metaspace_rs.is_reserved()) { |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25055
diff
changeset
|
4487 |
#if INCLUDE_CDS |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4488 |
if (UseSharedSpaces) { |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
4489 |
size_t increment = align_up(1*G, _reserve_alignment); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4490 |
|
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4491 |
// Keep trying to allocate the metaspace, increasing the requested_addr |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4492 |
// by 1GB each time, until we reach an address that will no longer allow |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4493 |
// use of CDS with compressed klass pointers. |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4494 |
char *addr = requested_addr; |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4495 |
while (!metaspace_rs.is_reserved() && (addr + increment > addr) && |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4496 |
can_use_cds_with_metaspace_addr(addr + increment, cds_base)) { |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4497 |
addr = addr + increment; |
21188
d053e4e8f901
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
21186
diff
changeset
|
4498 |
metaspace_rs = ReservedSpace(compressed_class_space_size(), |
28372
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28163
diff
changeset
|
4499 |
_reserve_alignment, large_pages, addr); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4500 |
} |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4501 |
} |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25055
diff
changeset
|
4502 |
#endif |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4503 |
// If no successful allocation then try to allocate the space anywhere. If |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4504 |
// that fails then OOM doom. At this point we cannot try allocating the |
19979
ebe1dbb6e1aa
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
19546
diff
changeset
|
4505 |
// metaspace as if UseCompressedClassPointers is off because too much |
ebe1dbb6e1aa
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
19546
diff
changeset
|
4506 |
// initialization has happened that depends on UseCompressedClassPointers. |
ebe1dbb6e1aa
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
19546
diff
changeset
|
4507 |
// So, UseCompressedClassPointers cannot be turned off at this point. |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4508 |
if (!metaspace_rs.is_reserved()) { |
21188
d053e4e8f901
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
21186
diff
changeset
|
4509 |
metaspace_rs = ReservedSpace(compressed_class_space_size(), |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4510 |
_reserve_alignment, large_pages); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4511 |
if (!metaspace_rs.is_reserved()) { |
29800
fa5f7a2bf717
8076073: shared: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
29697
diff
changeset
|
4512 |
vm_exit_during_initialization(err_msg("Could not allocate metaspace: " SIZE_FORMAT " bytes", |
21188
d053e4e8f901
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
21186
diff
changeset
|
4513 |
compressed_class_space_size())); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4514 |
} |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4515 |
} |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4516 |
} |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4517 |
|
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4518 |
// If we got here then the metaspace got allocated. |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4519 |
MemTracker::record_virtual_memory_type((address)metaspace_rs.base(), mtClass); |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4520 |
|
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25055
diff
changeset
|
4521 |
#if INCLUDE_CDS |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4522 |
// Verify that we can use shared spaces. Otherwise, turn off CDS. |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4523 |
if (UseSharedSpaces && !can_use_cds_with_metaspace_addr(metaspace_rs.base(), cds_base)) { |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4524 |
FileMapInfo::stop_sharing_and_unmap( |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4525 |
"Could not allocate metaspace at a compatible address"); |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4526 |
} |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25055
diff
changeset
|
4527 |
#endif |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4528 |
set_narrow_klass_base_and_shift((address)metaspace_rs.base(), |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4529 |
UseSharedSpaces ? (address)cds_base : 0); |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4530 |
|
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4531 |
initialize_class_space(metaspace_rs); |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4532 |
|
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46674
diff
changeset
|
4533 |
LogTarget(Trace, gc, metaspace) lt; |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46674
diff
changeset
|
4534 |
if (lt.is_enabled()) { |
35061 | 4535 |
ResourceMark rm; |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46674
diff
changeset
|
4536 |
LogStream ls(lt); |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46674
diff
changeset
|
4537 |
print_compressed_class_space(&ls, requested_addr); |
31335
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
31028
diff
changeset
|
4538 |
} |
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
31028
diff
changeset
|
4539 |
} |
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
31028
diff
changeset
|
4540 |
|
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
31028
diff
changeset
|
4541 |
void Metaspace::print_compressed_class_space(outputStream* st, const char* requested_addr) { |
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
31028
diff
changeset
|
4542 |
st->print_cr("Narrow klass base: " PTR_FORMAT ", Narrow klass shift: %d", |
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
31028
diff
changeset
|
4543 |
p2i(Universe::narrow_klass_base()), Universe::narrow_klass_shift()); |
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
31028
diff
changeset
|
4544 |
if (_class_space_list != NULL) { |
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
31028
diff
changeset
|
4545 |
address base = (address)_class_space_list->current_virtual_space()->bottom(); |
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
31028
diff
changeset
|
4546 |
st->print("Compressed class space size: " SIZE_FORMAT " Address: " PTR_FORMAT, |
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
31028
diff
changeset
|
4547 |
compressed_class_space_size(), p2i(base)); |
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
31028
diff
changeset
|
4548 |
if (requested_addr != 0) { |
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
31028
diff
changeset
|
4549 |
st->print(" Req Addr: " PTR_FORMAT, p2i(requested_addr)); |
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
31028
diff
changeset
|
4550 |
} |
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
31028
diff
changeset
|
4551 |
st->cr(); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4552 |
} |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4553 |
} |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4554 |
|
19979
ebe1dbb6e1aa
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
19546
diff
changeset
|
4555 |
// For UseCompressedClassPointers the class space is reserved above the top of |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4556 |
// the Java heap. The argument passed in is at the base of the compressed space. |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4557 |
void Metaspace::initialize_class_space(ReservedSpace rs) { |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4558 |
// The reserved space size may be bigger because of alignment, esp with UseLargePages |
19979
ebe1dbb6e1aa
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
19546
diff
changeset
|
4559 |
assert(rs.size() >= CompressedClassSpaceSize, |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
4560 |
SIZE_FORMAT " != " SIZE_FORMAT, rs.size(), CompressedClassSpaceSize); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4561 |
assert(using_class_space(), "Must be using class space"); |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4562 |
_class_space_list = new VirtualSpaceList(rs); |
49365 | 4563 |
_chunk_manager_class = new ChunkManager(true/*is_class*/); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4564 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4565 |
if (!_class_space_list->initialization_succeeded()) { |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4566 |
vm_exit_during_initialization("Failed to setup compressed class space virtual space list."); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4567 |
} |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4568 |
} |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4569 |
|
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4570 |
#endif |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4571 |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4572 |
void Metaspace::ergo_initialize() { |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4573 |
if (DumpSharedSpaces) { |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4574 |
// Using large pages when dumping the shared archive is currently not implemented. |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4575 |
FLAG_SET_ERGO(bool, UseLargePagesInMetaspace, false); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4576 |
} |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4577 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4578 |
size_t page_size = os::vm_page_size(); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4579 |
if (UseLargePages && UseLargePagesInMetaspace) { |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4580 |
page_size = os::large_page_size(); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4581 |
} |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4582 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4583 |
_commit_alignment = page_size; |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4584 |
_reserve_alignment = MAX2(page_size, (size_t)os::vm_allocation_granularity()); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4585 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4586 |
// Do not use FLAG_SET_ERGO to update MaxMetaspaceSize, since this will |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4587 |
// override if MaxMetaspaceSize was set on the command line or not. |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4588 |
// This information is needed later to conform to the specification of the |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4589 |
// java.lang.management.MemoryUsage API. |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4590 |
// |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4591 |
// Ideally, we would be able to set the default value of MaxMetaspaceSize in |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4592 |
// globals.hpp to the aligned value, but this is not possible, since the |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4593 |
// alignment depends on other flags being parsed. |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
4594 |
MaxMetaspaceSize = align_down_bounded(MaxMetaspaceSize, _reserve_alignment); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4595 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4596 |
if (MetaspaceSize > MaxMetaspaceSize) { |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4597 |
MetaspaceSize = MaxMetaspaceSize; |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4598 |
} |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4599 |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
4600 |
MetaspaceSize = align_down_bounded(MetaspaceSize, _commit_alignment); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4601 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4602 |
assert(MetaspaceSize <= MaxMetaspaceSize, "MetaspaceSize should be limited by MaxMetaspaceSize"); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4603 |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
4604 |
MinMetaspaceExpansion = align_down_bounded(MinMetaspaceExpansion, _commit_alignment); |
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
4605 |
MaxMetaspaceExpansion = align_down_bounded(MaxMetaspaceExpansion, _commit_alignment); |
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
4606 |
|
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
4607 |
CompressedClassSpaceSize = align_down_bounded(CompressedClassSpaceSize, _reserve_alignment); |
47654
dbd1f4f276ba
8087291: InitialBootClassLoaderMetaspaceSize and CompressedClassSpaceSize should be checked consistent from MaxMetaspaceSize
ysuenaga
parents:
47634
diff
changeset
|
4608 |
|
dbd1f4f276ba
8087291: InitialBootClassLoaderMetaspaceSize and CompressedClassSpaceSize should be checked consistent from MaxMetaspaceSize
ysuenaga
parents:
47634
diff
changeset
|
4609 |
// Initial virtual space size will be calculated at global_initialize() |
dbd1f4f276ba
8087291: InitialBootClassLoaderMetaspaceSize and CompressedClassSpaceSize should be checked consistent from MaxMetaspaceSize
ysuenaga
parents:
47634
diff
changeset
|
4610 |
size_t min_metaspace_sz = |
dbd1f4f276ba
8087291: InitialBootClassLoaderMetaspaceSize and CompressedClassSpaceSize should be checked consistent from MaxMetaspaceSize
ysuenaga
parents:
47634
diff
changeset
|
4611 |
VIRTUALSPACEMULTIPLIER * InitialBootClassLoaderMetaspaceSize; |
dbd1f4f276ba
8087291: InitialBootClassLoaderMetaspaceSize and CompressedClassSpaceSize should be checked consistent from MaxMetaspaceSize
ysuenaga
parents:
47634
diff
changeset
|
4612 |
if (UseCompressedClassPointers) { |
dbd1f4f276ba
8087291: InitialBootClassLoaderMetaspaceSize and CompressedClassSpaceSize should be checked consistent from MaxMetaspaceSize
ysuenaga
parents:
47634
diff
changeset
|
4613 |
if ((min_metaspace_sz + CompressedClassSpaceSize) > MaxMetaspaceSize) { |
dbd1f4f276ba
8087291: InitialBootClassLoaderMetaspaceSize and CompressedClassSpaceSize should be checked consistent from MaxMetaspaceSize
ysuenaga
parents:
47634
diff
changeset
|
4614 |
if (min_metaspace_sz >= MaxMetaspaceSize) { |
dbd1f4f276ba
8087291: InitialBootClassLoaderMetaspaceSize and CompressedClassSpaceSize should be checked consistent from MaxMetaspaceSize
ysuenaga
parents:
47634
diff
changeset
|
4615 |
vm_exit_during_initialization("MaxMetaspaceSize is too small."); |
dbd1f4f276ba
8087291: InitialBootClassLoaderMetaspaceSize and CompressedClassSpaceSize should be checked consistent from MaxMetaspaceSize
ysuenaga
parents:
47634
diff
changeset
|
4616 |
} else { |
dbd1f4f276ba
8087291: InitialBootClassLoaderMetaspaceSize and CompressedClassSpaceSize should be checked consistent from MaxMetaspaceSize
ysuenaga
parents:
47634
diff
changeset
|
4617 |
FLAG_SET_ERGO(size_t, CompressedClassSpaceSize, |
dbd1f4f276ba
8087291: InitialBootClassLoaderMetaspaceSize and CompressedClassSpaceSize should be checked consistent from MaxMetaspaceSize
ysuenaga
parents:
47634
diff
changeset
|
4618 |
MaxMetaspaceSize - min_metaspace_sz); |
dbd1f4f276ba
8087291: InitialBootClassLoaderMetaspaceSize and CompressedClassSpaceSize should be checked consistent from MaxMetaspaceSize
ysuenaga
parents:
47634
diff
changeset
|
4619 |
} |
dbd1f4f276ba
8087291: InitialBootClassLoaderMetaspaceSize and CompressedClassSpaceSize should be checked consistent from MaxMetaspaceSize
ysuenaga
parents:
47634
diff
changeset
|
4620 |
} |
dbd1f4f276ba
8087291: InitialBootClassLoaderMetaspaceSize and CompressedClassSpaceSize should be checked consistent from MaxMetaspaceSize
ysuenaga
parents:
47634
diff
changeset
|
4621 |
} else if (min_metaspace_sz >= MaxMetaspaceSize) { |
dbd1f4f276ba
8087291: InitialBootClassLoaderMetaspaceSize and CompressedClassSpaceSize should be checked consistent from MaxMetaspaceSize
ysuenaga
parents:
47634
diff
changeset
|
4622 |
FLAG_SET_ERGO(size_t, InitialBootClassLoaderMetaspaceSize, |
dbd1f4f276ba
8087291: InitialBootClassLoaderMetaspaceSize and CompressedClassSpaceSize should be checked consistent from MaxMetaspaceSize
ysuenaga
parents:
47634
diff
changeset
|
4623 |
min_metaspace_sz); |
dbd1f4f276ba
8087291: InitialBootClassLoaderMetaspaceSize and CompressedClassSpaceSize should be checked consistent from MaxMetaspaceSize
ysuenaga
parents:
47634
diff
changeset
|
4624 |
} |
dbd1f4f276ba
8087291: InitialBootClassLoaderMetaspaceSize and CompressedClassSpaceSize should be checked consistent from MaxMetaspaceSize
ysuenaga
parents:
47634
diff
changeset
|
4625 |
|
48387
7daebcef2e0d
8193386: CompressedClassSize too large with MaxMetaspace
coleenp
parents:
48148
diff
changeset
|
4626 |
set_compressed_class_space_size(CompressedClassSpaceSize); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4627 |
} |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4628 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4629 |
void Metaspace::global_initialize() { |
24847
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
4630 |
MetaspaceGC::initialize(); |
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
4631 |
|
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
4632 |
#if INCLUDE_CDS |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4633 |
if (DumpSharedSpaces) { |
47599
0fb1d501c408
8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents:
47553
diff
changeset
|
4634 |
MetaspaceShared::initialize_dumptime_shared_and_meta_spaces(); |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
4635 |
} else if (UseSharedSpaces) { |
47599
0fb1d501c408
8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents:
47553
diff
changeset
|
4636 |
// If any of the archived space fails to map, UseSharedSpaces |
0fb1d501c408
8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents:
47553
diff
changeset
|
4637 |
// is reset to false. Fall through to the |
0fb1d501c408
8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents:
47553
diff
changeset
|
4638 |
// (!DumpSharedSpaces && !UseSharedSpaces) case to set up class |
0fb1d501c408
8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents:
47553
diff
changeset
|
4639 |
// metaspace. |
0fb1d501c408
8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents:
47553
diff
changeset
|
4640 |
MetaspaceShared::initialize_runtime_shared_and_meta_spaces(); |
0fb1d501c408
8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents:
47553
diff
changeset
|
4641 |
} |
0fb1d501c408
8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents:
47553
diff
changeset
|
4642 |
|
0fb1d501c408
8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents:
47553
diff
changeset
|
4643 |
if (!DumpSharedSpaces && !UseSharedSpaces) |
0fb1d501c408
8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents:
47553
diff
changeset
|
4644 |
#endif // INCLUDE_CDS |
0fb1d501c408
8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents:
47553
diff
changeset
|
4645 |
{ |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4646 |
#ifdef _LP64 |
47599
0fb1d501c408
8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents:
47553
diff
changeset
|
4647 |
if (using_class_space()) { |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
4648 |
char* base = (char*)align_up(Universe::heap()->reserved_region().end(), _reserve_alignment); |
31362
8957ccbb5821
8098821: Crash in system dictionary initialization with shared strings
coleenp
parents:
31345
diff
changeset
|
4649 |
allocate_metaspace_compressed_klass_ptrs(base, 0); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4650 |
} |
47599
0fb1d501c408
8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents:
47553
diff
changeset
|
4651 |
#endif // _LP64 |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
4652 |
} |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4653 |
|
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
4654 |
// Initialize these before initializing the VirtualSpaceList |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
4655 |
_first_chunk_word_size = InitialBootClassLoaderMetaspaceSize / BytesPerWord; |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
4656 |
_first_chunk_word_size = align_word_size_up(_first_chunk_word_size); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
4657 |
// Make the first class chunk bigger than a medium chunk so it's not put |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
4658 |
// on the medium chunk list. The next chunk will be small and progress |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
4659 |
// from there. This size calculated by -version. |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
4660 |
_first_class_chunk_word_size = MIN2((size_t)MediumChunk*6, |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
4661 |
(CompressedClassSpaceSize/BytesPerWord)*2); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
4662 |
_first_class_chunk_word_size = align_word_size_up(_first_class_chunk_word_size); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
4663 |
// Arbitrarily set the initial virtual space to a multiple |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
4664 |
// of the boot class loader size. |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
4665 |
size_t word_size = VIRTUALSPACEMULTIPLIER * _first_chunk_word_size; |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
4666 |
word_size = align_up(word_size, Metaspace::reserve_alignment_words()); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
4667 |
|
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
4668 |
// Initialize the list of virtual spaces. |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
4669 |
_space_list = new VirtualSpaceList(word_size); |
49365 | 4670 |
_chunk_manager_metadata = new ChunkManager(false/*metaspace*/); |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
4671 |
|
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
4672 |
if (!_space_list->initialization_succeeded()) { |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
4673 |
vm_exit_during_initialization("Unable to setup metadata virtual space list.", NULL); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4674 |
} |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4675 |
|
23465
14790e4d53ec
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
22884
diff
changeset
|
4676 |
_tracer = new MetaspaceTracer(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4677 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4678 |
|
24847
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
4679 |
void Metaspace::post_initialize() { |
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
4680 |
MetaspaceGC::post_initialize(); |
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
4681 |
} |
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
4682 |
|
42615
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
4683 |
void Metaspace::initialize_first_chunk(MetaspaceType type, MetadataType mdtype) { |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
4684 |
Metachunk* chunk = get_initialization_chunk(type, mdtype); |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
4685 |
if (chunk != NULL) { |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
4686 |
// Add to this manager's list of chunks in use and current_chunk(). |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
4687 |
get_space_manager(mdtype)->add_chunk(chunk, true); |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
4688 |
} |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
4689 |
} |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
4690 |
|
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
4691 |
Metachunk* Metaspace::get_initialization_chunk(MetaspaceType type, MetadataType mdtype) { |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
4692 |
size_t chunk_word_size = get_space_manager(mdtype)->get_initial_chunk_size(type); |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
4693 |
|
20081
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
4694 |
// Get a chunk from the chunk freelist |
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
4695 |
Metachunk* chunk = get_chunk_manager(mdtype)->chunk_freelist_allocate(chunk_word_size); |
42615
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
4696 |
|
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
4697 |
if (chunk == NULL) { |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
4698 |
chunk = get_space_list(mdtype)->get_new_chunk(chunk_word_size, |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
4699 |
get_space_manager(mdtype)->medium_chunk_bunch()); |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
4700 |
} |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
4701 |
|
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
4702 |
return chunk; |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
4703 |
} |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
4704 |
|
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
4705 |
void Metaspace::verify_global_initialization() { |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
4706 |
assert(space_list() != NULL, "Metadata VirtualSpaceList has not been initialized"); |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
4707 |
assert(chunk_manager_metadata() != NULL, "Metadata ChunkManager has not been initialized"); |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
4708 |
|
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
4709 |
if (using_class_space()) { |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
4710 |
assert(class_space_list() != NULL, "Class VirtualSpaceList has not been initialized"); |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
4711 |
assert(chunk_manager_class() != NULL, "Class ChunkManager has not been initialized"); |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
4712 |
} |
20081
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
4713 |
} |
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
4714 |
|
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4715 |
void Metaspace::initialize(Mutex* lock, MetaspaceType type) { |
42615
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
4716 |
verify_global_initialization(); |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
4717 |
|
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
4718 |
// Allocate SpaceManager for metadata objects. |
48148
385bed268108
8190729: Adjustment to anonymous metadata space chunk allocation algorithm
zgu
parents:
47808
diff
changeset
|
4719 |
_vsm = new SpaceManager(NonClassType, type, lock); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4720 |
|
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4721 |
if (using_class_space()) { |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4722 |
// Allocate SpaceManager for classes. |
48148
385bed268108
8190729: Adjustment to anonymous metadata space chunk allocation algorithm
zgu
parents:
47808
diff
changeset
|
4723 |
_class_vsm = new SpaceManager(ClassType, type, lock); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4724 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4725 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4726 |
MutexLockerEx cl(SpaceManager::expand_lock(), Mutex::_no_safepoint_check_flag); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4727 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4728 |
// Allocate chunk for metadata objects |
42615
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
4729 |
initialize_first_chunk(type, NonClassType); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4730 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4731 |
// Allocate chunk for class metadata objects |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4732 |
if (using_class_space()) { |
42615
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
4733 |
initialize_first_chunk(type, ClassType); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4734 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4735 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4736 |
|
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
4737 |
size_t Metaspace::align_word_size_up(size_t word_size) { |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
4738 |
size_t byte_size = word_size * wordSize; |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
4739 |
return ReservedSpace::allocation_align_size_up(byte_size) / wordSize; |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
4740 |
} |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
4741 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4742 |
MetaWord* Metaspace::allocate(size_t word_size, MetadataType mdtype) { |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
4743 |
assert(!_frozen, "sanity"); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
4744 |
// Don't use class_vsm() unless UseCompressedClassPointers is true. |
20306
f6805e2a0dd8
8025279: metaspace/flags/maxMetaspaceSize throws OOM: out of Compressed Klass space
mgerdin
parents:
20084
diff
changeset
|
4745 |
if (is_class_space_allocation(mdtype)) { |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
4746 |
return class_vsm()->allocate(word_size); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4747 |
} else { |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
4748 |
return vsm()->allocate(word_size); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4749 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4750 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4751 |
|
13755
a00f5de57d30
7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
jmasa
parents:
13739
diff
changeset
|
4752 |
MetaWord* Metaspace::expand_and_allocate(size_t word_size, MetadataType mdtype) { |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
4753 |
assert(!_frozen, "sanity"); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4754 |
size_t delta_bytes = MetaspaceGC::delta_capacity_until_GC(word_size * BytesPerWord); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4755 |
assert(delta_bytes > 0, "Must be"); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4756 |
|
26938
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
4757 |
size_t before = 0; |
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
4758 |
size_t after = 0; |
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
4759 |
MetaWord* res; |
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
4760 |
bool incremented; |
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
4761 |
|
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
4762 |
// Each thread increments the HWM at most once. Even if the thread fails to increment |
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
4763 |
// the HWM, an allocation is still attempted. This is because another thread must then |
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
4764 |
// have incremented the HWM and therefore the allocation might still succeed. |
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
4765 |
do { |
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
4766 |
incremented = MetaspaceGC::inc_capacity_until_GC(delta_bytes, &after, &before); |
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
4767 |
res = allocate(word_size, mdtype); |
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
4768 |
} while (!incremented && res == NULL); |
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
4769 |
|
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
4770 |
if (incremented) { |
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
4771 |
tracer()->report_gc_threshold(before, after, |
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
4772 |
MetaspaceGCThresholdUpdater::ExpandAndAllocate); |
35061 | 4773 |
log_trace(gc, metaspace)("Increase capacity to GC from " SIZE_FORMAT " to " SIZE_FORMAT, before, after); |
13755
a00f5de57d30
7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
jmasa
parents:
13739
diff
changeset
|
4774 |
} |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
13877
diff
changeset
|
4775 |
|
26938
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
4776 |
return res; |
13755
a00f5de57d30
7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
jmasa
parents:
13739
diff
changeset
|
4777 |
} |
a00f5de57d30
7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
jmasa
parents:
13739
diff
changeset
|
4778 |
|
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
4779 |
size_t Metaspace::used_words_slow(MetadataType mdtype) const { |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4780 |
if (mdtype == ClassType) { |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4781 |
return using_class_space() ? class_vsm()->sum_used_in_chunks_in_use() : 0; |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4782 |
} else { |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4783 |
return vsm()->sum_used_in_chunks_in_use(); // includes overhead! |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4784 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4785 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4786 |
|
19988 | 4787 |
size_t Metaspace::free_words_slow(MetadataType mdtype) const { |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
4788 |
assert(!_frozen, "sanity"); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4789 |
if (mdtype == ClassType) { |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4790 |
return using_class_space() ? class_vsm()->sum_free_in_chunks_in_use() : 0; |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4791 |
} else { |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4792 |
return vsm()->sum_free_in_chunks_in_use(); |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4793 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4794 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4795 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4796 |
// Space capacity in the Metaspace. It includes |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4797 |
// space in the list of chunks from which allocations |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4798 |
// have been made. Don't include space in the global freelist and |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4799 |
// in the space available in the dictionary which |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4800 |
// is already counted in some chunk. |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
4801 |
size_t Metaspace::capacity_words_slow(MetadataType mdtype) const { |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4802 |
if (mdtype == ClassType) { |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4803 |
return using_class_space() ? class_vsm()->sum_capacity_in_chunks_in_use() : 0; |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4804 |
} else { |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4805 |
return vsm()->sum_capacity_in_chunks_in_use(); |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4806 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4807 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4808 |
|
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
4809 |
size_t Metaspace::used_bytes_slow(MetadataType mdtype) const { |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
4810 |
return used_words_slow(mdtype) * BytesPerWord; |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
4811 |
} |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
4812 |
|
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
4813 |
size_t Metaspace::capacity_bytes_slow(MetadataType mdtype) const { |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
4814 |
return capacity_words_slow(mdtype) * BytesPerWord; |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
4815 |
} |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
4816 |
|
25051
8110ec6e7340
8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
24665
diff
changeset
|
4817 |
size_t Metaspace::allocated_blocks_bytes() const { |
8110ec6e7340
8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
24665
diff
changeset
|
4818 |
return vsm()->allocated_blocks_bytes() + |
8110ec6e7340
8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
24665
diff
changeset
|
4819 |
(using_class_space() ? class_vsm()->allocated_blocks_bytes() : 0); |
8110ec6e7340
8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
24665
diff
changeset
|
4820 |
} |
8110ec6e7340
8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
24665
diff
changeset
|
4821 |
|
8110ec6e7340
8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
24665
diff
changeset
|
4822 |
size_t Metaspace::allocated_chunks_bytes() const { |
8110ec6e7340
8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
24665
diff
changeset
|
4823 |
return vsm()->allocated_chunks_bytes() + |
8110ec6e7340
8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
24665
diff
changeset
|
4824 |
(using_class_space() ? class_vsm()->allocated_chunks_bytes() : 0); |
8110ec6e7340
8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
24665
diff
changeset
|
4825 |
} |
8110ec6e7340
8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
24665
diff
changeset
|
4826 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4827 |
void Metaspace::deallocate(MetaWord* ptr, size_t word_size, bool is_class) { |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
4828 |
assert(!_frozen, "sanity"); |
23503
84698692e4ef
8037952: Remove code duplication in Metaspace::deallocate
stefank
parents:
23470
diff
changeset
|
4829 |
assert(!SafepointSynchronize::is_at_safepoint() |
84698692e4ef
8037952: Remove code duplication in Metaspace::deallocate
stefank
parents:
23470
diff
changeset
|
4830 |
|| Thread::current()->is_VM_thread(), "should be the VM thread"); |
84698692e4ef
8037952: Remove code duplication in Metaspace::deallocate
stefank
parents:
23470
diff
changeset
|
4831 |
|
84698692e4ef
8037952: Remove code duplication in Metaspace::deallocate
stefank
parents:
23470
diff
changeset
|
4832 |
MutexLockerEx ml(vsm()->lock(), Mutex::_no_safepoint_check_flag); |
84698692e4ef
8037952: Remove code duplication in Metaspace::deallocate
stefank
parents:
23470
diff
changeset
|
4833 |
|
84698692e4ef
8037952: Remove code duplication in Metaspace::deallocate
stefank
parents:
23470
diff
changeset
|
4834 |
if (is_class && using_class_space()) { |
84698692e4ef
8037952: Remove code duplication in Metaspace::deallocate
stefank
parents:
23470
diff
changeset
|
4835 |
class_vsm()->deallocate(ptr, word_size); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4836 |
} else { |
23503
84698692e4ef
8037952: Remove code duplication in Metaspace::deallocate
stefank
parents:
23470
diff
changeset
|
4837 |
vsm()->deallocate(ptr, word_size); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4838 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4839 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4840 |
|
20729 | 4841 |
MetaWord* Metaspace::allocate(ClassLoaderData* loader_data, size_t word_size, |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
4842 |
MetaspaceObj::Type type, TRAPS) { |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
4843 |
assert(!_frozen, "sanity"); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4844 |
if (HAS_PENDING_EXCEPTION) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4845 |
assert(false, "Should not allocate with exception pending"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4846 |
return NULL; // caller does a CHECK_NULL too |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4847 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4848 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4849 |
assert(loader_data != NULL, "Should never pass around a NULL loader_data. " |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4850 |
"ClassLoaderData::the_null_class_loader_data() should have been used."); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4851 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4852 |
MetadataType mdtype = (type == MetaspaceObj::ClassType) ? ClassType : NonClassType; |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4853 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4854 |
// Try to allocate metadata. |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4855 |
MetaWord* result = loader_data->metaspace_non_null()->allocate(word_size, mdtype); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4856 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4857 |
if (result == NULL) { |
49372
3bb8b00832d0
8196626: [Graal] runtime/appcds/UseAppCDS.java crashes with "VM thread using lock Heap_lock (not allowed to block on)"
ccheung
parents:
49366
diff
changeset
|
4858 |
if (DumpSharedSpaces && THREAD->is_VM_thread()) { |
3bb8b00832d0
8196626: [Graal] runtime/appcds/UseAppCDS.java crashes with "VM thread using lock Heap_lock (not allowed to block on)"
ccheung
parents:
49366
diff
changeset
|
4859 |
tty->print_cr("Failed allocating metaspace object type %s of size " SIZE_FORMAT ". CDS dump aborted.", |
3bb8b00832d0
8196626: [Graal] runtime/appcds/UseAppCDS.java crashes with "VM thread using lock Heap_lock (not allowed to block on)"
ccheung
parents:
49366
diff
changeset
|
4860 |
MetaspaceObj::type_name(type), word_size * BytesPerWord); |
3bb8b00832d0
8196626: [Graal] runtime/appcds/UseAppCDS.java crashes with "VM thread using lock Heap_lock (not allowed to block on)"
ccheung
parents:
49366
diff
changeset
|
4861 |
vm_exit(1); |
3bb8b00832d0
8196626: [Graal] runtime/appcds/UseAppCDS.java crashes with "VM thread using lock Heap_lock (not allowed to block on)"
ccheung
parents:
49366
diff
changeset
|
4862 |
} |
3bb8b00832d0
8196626: [Graal] runtime/appcds/UseAppCDS.java crashes with "VM thread using lock Heap_lock (not allowed to block on)"
ccheung
parents:
49366
diff
changeset
|
4863 |
|
23468
6bb416a59349
8036699: Add trace event when a metaspace allocation fails
ehelin
parents:
23465
diff
changeset
|
4864 |
tracer()->report_metaspace_allocation_failure(loader_data, word_size, type, mdtype); |
6bb416a59349
8036699: Add trace event when a metaspace allocation fails
ehelin
parents:
23465
diff
changeset
|
4865 |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4866 |
// Allocation failed. |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4867 |
if (is_init_completed()) { |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4868 |
// Only start a GC if the bootstrapping has completed. |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4869 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4870 |
// Try to clean out some memory and retry. |
49045
9b556b613a07
8198509: Move satisfy_failed_metadata_allocation out from CollectorPolicy
stefank
parents:
48971
diff
changeset
|
4871 |
result = Universe::heap()->satisfy_failed_metadata_allocation(loader_data, word_size, mdtype); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4872 |
} |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4873 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4874 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4875 |
if (result == NULL) { |
49365 | 4876 |
report_metadata_oome(loader_data, word_size, type, mdtype, CHECK_NULL); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4877 |
} |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4878 |
|
20729 | 4879 |
// Zero initialize. |
35898
ddc274f0052f
8145628: hotspot metadata classes shouldn't use HeapWordSize or heap related macros like align_object_size
coleenp
parents:
35231
diff
changeset
|
4880 |
Copy::fill_to_words((HeapWord*)result, word_size, 0); |
20729 | 4881 |
|
4882 |
return result; |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4883 |
} |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4884 |
|
21186
db851068711f
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
20733
diff
changeset
|
4885 |
size_t Metaspace::class_chunk_size(size_t word_size) { |
db851068711f
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
20733
diff
changeset
|
4886 |
assert(using_class_space(), "Has to use class space"); |
db851068711f
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
20733
diff
changeset
|
4887 |
return class_vsm()->calc_chunk_size(word_size); |
db851068711f
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
20733
diff
changeset
|
4888 |
} |
db851068711f
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
20733
diff
changeset
|
4889 |
|
23469
0a4d02776968
8036701: Add trace event when a metaspace throws out of memory error
ehelin
parents:
23468
diff
changeset
|
4890 |
void Metaspace::report_metadata_oome(ClassLoaderData* loader_data, size_t word_size, MetaspaceObj::Type type, MetadataType mdtype, TRAPS) { |
0a4d02776968
8036701: Add trace event when a metaspace throws out of memory error
ehelin
parents:
23468
diff
changeset
|
4891 |
tracer()->report_metadata_oom(loader_data, word_size, type, mdtype); |
0a4d02776968
8036701: Add trace event when a metaspace throws out of memory error
ehelin
parents:
23468
diff
changeset
|
4892 |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4893 |
// If result is still null, we are out of memory. |
37242 | 4894 |
Log(gc, metaspace, freelist) log; |
41727
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
4895 |
if (log.is_info()) { |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
4896 |
log.info("Metaspace (%s) allocation failed for size " SIZE_FORMAT, |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
4897 |
is_class_space_allocation(mdtype) ? "class" : "data", word_size); |
35061 | 4898 |
ResourceMark rm; |
46723
5c418c5fcade
8185262: Keep default logging for Metaspace OOM short and concise
stuefe
parents:
46709
diff
changeset
|
4899 |
if (log.is_debug()) { |
5c418c5fcade
8185262: Keep default logging for Metaspace OOM short and concise
stuefe
parents:
46709
diff
changeset
|
4900 |
if (loader_data->metaspace_or_null() != NULL) { |
5c418c5fcade
8185262: Keep default logging for Metaspace OOM short and concise
stuefe
parents:
46709
diff
changeset
|
4901 |
LogStream ls(log.debug()); |
49348
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49045
diff
changeset
|
4902 |
loader_data->print_value_on(&ls); |
46723
5c418c5fcade
8185262: Keep default logging for Metaspace OOM short and concise
stuefe
parents:
46709
diff
changeset
|
4903 |
} |
5c418c5fcade
8185262: Keep default logging for Metaspace OOM short and concise
stuefe
parents:
46709
diff
changeset
|
4904 |
} |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46674
diff
changeset
|
4905 |
LogStream ls(log.info()); |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46674
diff
changeset
|
4906 |
MetaspaceAux::dump(&ls); |
47808
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
4907 |
MetaspaceAux::print_metaspace_map(&ls, mdtype); |
46709
adaac4b80549
8185033: On Metaspace OOM, ChunkManager composition should be logged.
stuefe
parents:
46701
diff
changeset
|
4908 |
ChunkManager::print_all_chunkmanagers(&ls); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4909 |
} |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4910 |
|
21186
db851068711f
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
20733
diff
changeset
|
4911 |
bool out_of_compressed_class_space = false; |
db851068711f
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
20733
diff
changeset
|
4912 |
if (is_class_space_allocation(mdtype)) { |
db851068711f
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
20733
diff
changeset
|
4913 |
Metaspace* metaspace = loader_data->metaspace_non_null(); |
db851068711f
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
20733
diff
changeset
|
4914 |
out_of_compressed_class_space = |
db851068711f
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
20733
diff
changeset
|
4915 |
MetaspaceAux::committed_bytes(Metaspace::ClassType) + |
db851068711f
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
20733
diff
changeset
|
4916 |
(metaspace->class_chunk_size(word_size) * BytesPerWord) > |
db851068711f
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
20733
diff
changeset
|
4917 |
CompressedClassSpaceSize; |
db851068711f
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
20733
diff
changeset
|
4918 |
} |
db851068711f
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
20733
diff
changeset
|
4919 |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4920 |
// -XX:+HeapDumpOnOutOfMemoryError and -XX:OnOutOfMemoryError support |
21186
db851068711f
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
20733
diff
changeset
|
4921 |
const char* space_string = out_of_compressed_class_space ? |
db851068711f
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
20733
diff
changeset
|
4922 |
"Compressed class space" : "Metaspace"; |
db851068711f
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
20733
diff
changeset
|
4923 |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4924 |
report_java_out_of_memory(space_string); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4925 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4926 |
if (JvmtiExport::should_post_resource_exhausted()) { |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4927 |
JvmtiExport::post_resource_exhausted( |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4928 |
JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR, |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4929 |
space_string); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4930 |
} |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4931 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4932 |
if (!is_init_completed()) { |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4933 |
vm_exit_during_initialization("OutOfMemoryError", space_string); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4934 |
} |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4935 |
|
21186
db851068711f
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
20733
diff
changeset
|
4936 |
if (out_of_compressed_class_space) { |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4937 |
THROW_OOP(Universe::out_of_memory_error_class_metaspace()); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4938 |
} else { |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4939 |
THROW_OOP(Universe::out_of_memory_error_metaspace()); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
4940 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4941 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4942 |
|
23468
6bb416a59349
8036699: Add trace event when a metaspace allocation fails
ehelin
parents:
23465
diff
changeset
|
4943 |
const char* Metaspace::metadata_type_name(Metaspace::MetadataType mdtype) { |
6bb416a59349
8036699: Add trace event when a metaspace allocation fails
ehelin
parents:
23465
diff
changeset
|
4944 |
switch (mdtype) { |
6bb416a59349
8036699: Add trace event when a metaspace allocation fails
ehelin
parents:
23465
diff
changeset
|
4945 |
case Metaspace::ClassType: return "Class"; |
6bb416a59349
8036699: Add trace event when a metaspace allocation fails
ehelin
parents:
23465
diff
changeset
|
4946 |
case Metaspace::NonClassType: return "Metadata"; |
6bb416a59349
8036699: Add trace event when a metaspace allocation fails
ehelin
parents:
23465
diff
changeset
|
4947 |
default: |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
4948 |
assert(false, "Got bad mdtype: %d", (int) mdtype); |
23468
6bb416a59349
8036699: Add trace event when a metaspace allocation fails
ehelin
parents:
23465
diff
changeset
|
4949 |
return NULL; |
6bb416a59349
8036699: Add trace event when a metaspace allocation fails
ehelin
parents:
23465
diff
changeset
|
4950 |
} |
6bb416a59349
8036699: Add trace event when a metaspace allocation fails
ehelin
parents:
23465
diff
changeset
|
4951 |
} |
6bb416a59349
8036699: Add trace event when a metaspace allocation fails
ehelin
parents:
23465
diff
changeset
|
4952 |
|
20081
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
4953 |
void Metaspace::purge(MetadataType mdtype) { |
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
4954 |
get_space_list(mdtype)->purge(get_chunk_manager(mdtype)); |
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
4955 |
} |
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
4956 |
|
17101 | 4957 |
void Metaspace::purge() { |
4958 |
MutexLockerEx cl(SpaceManager::expand_lock(), |
|
4959 |
Mutex::_no_safepoint_check_flag); |
|
20081
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
4960 |
purge(NonClassType); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4961 |
if (using_class_space()) { |
20081
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
4962 |
purge(ClassType); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4963 |
} |
17101 | 4964 |
} |
4965 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4966 |
void Metaspace::print_on(outputStream* out) const { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4967 |
// Print both class virtual space counts and metaspace. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4968 |
if (Verbose) { |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4969 |
vsm()->print_on(out); |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4970 |
if (using_class_space()) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4971 |
class_vsm()->print_on(out); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4972 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4973 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4974 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4975 |
|
22201
9c2ccfa3a5fe
8029178: Parallel class loading test anonymous-simple gets SIGSEGV in Metaspace::contains
coleenp
parents:
21569
diff
changeset
|
4976 |
bool Metaspace::contains(const void* ptr) { |
48794
ea0d0781c63c
8178351: Simplify MetaspaceShared::is_in_shared_space and MetaspaceObj::is_shared
iklam
parents:
48387
diff
changeset
|
4977 |
if (MetaspaceShared::is_in_shared_metaspace(ptr)) { |
24457
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
4978 |
return true; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4979 |
} |
46324
8764956ec928
8005165: Remove CPU-dependent code in self-patching vtables
iklam
parents:
42650
diff
changeset
|
4980 |
return contains_non_shared(ptr); |
8764956ec928
8005165: Remove CPU-dependent code in self-patching vtables
iklam
parents:
42650
diff
changeset
|
4981 |
} |
8764956ec928
8005165: Remove CPU-dependent code in self-patching vtables
iklam
parents:
42650
diff
changeset
|
4982 |
|
8764956ec928
8005165: Remove CPU-dependent code in self-patching vtables
iklam
parents:
42650
diff
changeset
|
4983 |
bool Metaspace::contains_non_shared(const void* ptr) { |
24457
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
4984 |
if (using_class_space() && get_space_list(ClassType)->contains(ptr)) { |
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
4985 |
return true; |
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
4986 |
} |
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
4987 |
|
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
4988 |
return get_space_list(NonClassType)->contains(ptr); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4989 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4990 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4991 |
void Metaspace::verify() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4992 |
vsm()->verify(); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4993 |
if (using_class_space()) { |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4994 |
class_vsm()->verify(); |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
4995 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4996 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4997 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4998 |
void Metaspace::dump(outputStream* const out) const { |
29800
fa5f7a2bf717
8076073: shared: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
29697
diff
changeset
|
4999 |
out->print_cr("\nVirtual space manager: " INTPTR_FORMAT, p2i(vsm())); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
5000 |
vsm()->dump(out); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
5001 |
if (using_class_space()) { |
29800
fa5f7a2bf717
8076073: shared: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
29697
diff
changeset
|
5002 |
out->print_cr("\nClass space manager: " INTPTR_FORMAT, p2i(class_vsm())); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
5003 |
class_vsm()->dump(out); |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
5004 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
5005 |
} |
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5006 |
|
49365 | 5007 |
#ifdef ASSERT |
5008 |
static void do_verify_chunk(Metachunk* chunk) { |
|
5009 |
guarantee(chunk != NULL, "Sanity"); |
|
5010 |
// Verify chunk itself; then verify that it is consistent with the |
|
5011 |
// occupany map of its containing node. |
|
5012 |
chunk->verify(); |
|
5013 |
VirtualSpaceNode* const vsn = chunk->container(); |
|
5014 |
OccupancyMap* const ocmap = vsn->occupancy_map(); |
|
5015 |
ocmap->verify_for_chunk(chunk); |
|
5016 |
} |
|
5017 |
#endif |
|
5018 |
||
5019 |
static void do_update_in_use_info_for_chunk(Metachunk* chunk, bool inuse) { |
|
5020 |
chunk->set_is_tagged_free(!inuse); |
|
5021 |
OccupancyMap* const ocmap = chunk->container()->occupancy_map(); |
|
5022 |
ocmap->set_region_in_use((MetaWord*)chunk, chunk->word_size(), inuse); |
|
5023 |
} |
|
5024 |
||
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5025 |
/////////////// Unit tests /////////////// |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5026 |
|
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5027 |
#ifndef PRODUCT |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5028 |
|
20084
a61ec6d55abc
8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents:
20081
diff
changeset
|
5029 |
class TestMetaspaceAuxTest : AllStatic { |
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5030 |
public: |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5031 |
static void test_reserved() { |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5032 |
size_t reserved = MetaspaceAux::reserved_bytes(); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5033 |
|
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5034 |
assert(reserved > 0, "assert"); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5035 |
|
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5036 |
size_t committed = MetaspaceAux::committed_bytes(); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5037 |
assert(committed <= reserved, "assert"); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5038 |
|
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5039 |
size_t reserved_metadata = MetaspaceAux::reserved_bytes(Metaspace::NonClassType); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5040 |
assert(reserved_metadata > 0, "assert"); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5041 |
assert(reserved_metadata <= reserved, "assert"); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5042 |
|
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5043 |
if (UseCompressedClassPointers) { |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5044 |
size_t reserved_class = MetaspaceAux::reserved_bytes(Metaspace::ClassType); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5045 |
assert(reserved_class > 0, "assert"); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5046 |
assert(reserved_class < reserved, "assert"); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5047 |
} |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5048 |
} |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5049 |
|
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5050 |
static void test_committed() { |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5051 |
size_t committed = MetaspaceAux::committed_bytes(); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5052 |
|
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5053 |
assert(committed > 0, "assert"); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5054 |
|
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5055 |
size_t reserved = MetaspaceAux::reserved_bytes(); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5056 |
assert(committed <= reserved, "assert"); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5057 |
|
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5058 |
size_t committed_metadata = MetaspaceAux::committed_bytes(Metaspace::NonClassType); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5059 |
assert(committed_metadata > 0, "assert"); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5060 |
assert(committed_metadata <= committed, "assert"); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5061 |
|
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5062 |
if (UseCompressedClassPointers) { |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5063 |
size_t committed_class = MetaspaceAux::committed_bytes(Metaspace::ClassType); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5064 |
assert(committed_class > 0, "assert"); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5065 |
assert(committed_class < committed, "assert"); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5066 |
} |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5067 |
} |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5068 |
|
20084
a61ec6d55abc
8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents:
20081
diff
changeset
|
5069 |
static void test_virtual_space_list_large_chunk() { |
a61ec6d55abc
8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents:
20081
diff
changeset
|
5070 |
VirtualSpaceList* vs_list = new VirtualSpaceList(os::vm_allocation_granularity()); |
a61ec6d55abc
8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents:
20081
diff
changeset
|
5071 |
MutexLockerEx cl(SpaceManager::expand_lock(), Mutex::_no_safepoint_check_flag); |
a61ec6d55abc
8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents:
20081
diff
changeset
|
5072 |
// A size larger than VirtualSpaceSize (256k) and add one page to make it _not_ be |
a61ec6d55abc
8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents:
20081
diff
changeset
|
5073 |
// vm_allocation_granularity aligned on Windows. |
a61ec6d55abc
8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents:
20081
diff
changeset
|
5074 |
size_t large_size = (size_t)(2*256*K + (os::vm_page_size()/BytesPerWord)); |
a61ec6d55abc
8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents:
20081
diff
changeset
|
5075 |
large_size += (os::vm_page_size()/BytesPerWord); |
42615
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5076 |
vs_list->get_new_chunk(large_size, 0); |
20084
a61ec6d55abc
8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents:
20081
diff
changeset
|
5077 |
} |
a61ec6d55abc
8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents:
20081
diff
changeset
|
5078 |
|
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5079 |
static void test() { |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5080 |
test_reserved(); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5081 |
test_committed(); |
20084
a61ec6d55abc
8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents:
20081
diff
changeset
|
5082 |
test_virtual_space_list_large_chunk(); |
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5083 |
} |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5084 |
}; |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5085 |
|
20084
a61ec6d55abc
8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents:
20081
diff
changeset
|
5086 |
void TestMetaspaceAux_test() { |
a61ec6d55abc
8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents:
20081
diff
changeset
|
5087 |
TestMetaspaceAuxTest::test(); |
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5088 |
} |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
5089 |
|
21112
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5090 |
class TestVirtualSpaceNodeTest { |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5091 |
static void chunk_up(size_t words_left, size_t& num_medium_chunks, |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5092 |
size_t& num_small_chunks, |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5093 |
size_t& num_specialized_chunks) { |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5094 |
num_medium_chunks = words_left / MediumChunk; |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5095 |
words_left = words_left % MediumChunk; |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5096 |
|
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5097 |
num_small_chunks = words_left / SmallChunk; |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5098 |
words_left = words_left % SmallChunk; |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5099 |
// how many specialized chunks can we get? |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5100 |
num_specialized_chunks = words_left / SpecializedChunk; |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5101 |
assert(words_left % SpecializedChunk == 0, "should be nothing left"); |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5102 |
} |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5103 |
|
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5104 |
public: |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5105 |
static void test() { |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5106 |
MutexLockerEx ml(SpaceManager::expand_lock(), Mutex::_no_safepoint_check_flag); |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5107 |
const size_t vsn_test_size_words = MediumChunk * 4; |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5108 |
const size_t vsn_test_size_bytes = vsn_test_size_words * BytesPerWord; |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5109 |
|
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5110 |
// The chunk sizes must be multiples of eachother, or this will fail |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5111 |
STATIC_ASSERT(MediumChunk % SmallChunk == 0); |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5112 |
STATIC_ASSERT(SmallChunk % SpecializedChunk == 0); |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5113 |
|
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5114 |
{ // No committed memory in VSN |
49365 | 5115 |
ChunkManager cm(false); |
5116 |
VirtualSpaceNode vsn(false, vsn_test_size_bytes); |
|
21112
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5117 |
vsn.initialize(); |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5118 |
vsn.retire(&cm); |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5119 |
assert(cm.sum_free_chunks_count() == 0, "did not commit any memory in the VSN"); |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5120 |
} |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5121 |
|
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5122 |
{ // All of VSN is committed, half is used by chunks |
49365 | 5123 |
ChunkManager cm(false); |
5124 |
VirtualSpaceNode vsn(false, vsn_test_size_bytes); |
|
21112
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5125 |
vsn.initialize(); |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5126 |
vsn.expand_by(vsn_test_size_words, vsn_test_size_words); |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5127 |
vsn.get_chunk_vs(MediumChunk); |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5128 |
vsn.get_chunk_vs(MediumChunk); |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5129 |
vsn.retire(&cm); |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5130 |
assert(cm.sum_free_chunks_count() == 2, "should have been memory left for 2 medium chunks"); |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5131 |
assert(cm.sum_free_chunks() == 2*MediumChunk, "sizes should add up"); |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5132 |
} |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5133 |
|
28497
a7aecf0ffb6b
8067941: [TESTBUG] Fix tests for OS with 64K page size.
goetz
parents:
28372
diff
changeset
|
5134 |
const size_t page_chunks = 4 * (size_t)os::vm_page_size() / BytesPerWord; |
a7aecf0ffb6b
8067941: [TESTBUG] Fix tests for OS with 64K page size.
goetz
parents:
28372
diff
changeset
|
5135 |
// This doesn't work for systems with vm_page_size >= 16K. |
a7aecf0ffb6b
8067941: [TESTBUG] Fix tests for OS with 64K page size.
goetz
parents:
28372
diff
changeset
|
5136 |
if (page_chunks < MediumChunk) { |
a7aecf0ffb6b
8067941: [TESTBUG] Fix tests for OS with 64K page size.
goetz
parents:
28372
diff
changeset
|
5137 |
// 4 pages of VSN is committed, some is used by chunks |
49365 | 5138 |
ChunkManager cm(false); |
5139 |
VirtualSpaceNode vsn(false, vsn_test_size_bytes); |
|
28497
a7aecf0ffb6b
8067941: [TESTBUG] Fix tests for OS with 64K page size.
goetz
parents:
28372
diff
changeset
|
5140 |
|
21112
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5141 |
vsn.initialize(); |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5142 |
vsn.expand_by(page_chunks, page_chunks); |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5143 |
vsn.get_chunk_vs(SmallChunk); |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5144 |
vsn.get_chunk_vs(SpecializedChunk); |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5145 |
vsn.retire(&cm); |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5146 |
|
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5147 |
// committed - used = words left to retire |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5148 |
const size_t words_left = page_chunks - SmallChunk - SpecializedChunk; |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5149 |
|
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5150 |
size_t num_medium_chunks, num_small_chunks, num_spec_chunks; |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5151 |
chunk_up(words_left, num_medium_chunks, num_small_chunks, num_spec_chunks); |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5152 |
|
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5153 |
assert(num_medium_chunks == 0, "should not get any medium chunks"); |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5154 |
assert(cm.sum_free_chunks_count() == (num_small_chunks + num_spec_chunks), "should be space for 3 chunks"); |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5155 |
assert(cm.sum_free_chunks() == words_left, "sizes should add up"); |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5156 |
} |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5157 |
|
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5158 |
{ // Half of VSN is committed, a humongous chunk is used |
49365 | 5159 |
ChunkManager cm(false); |
5160 |
VirtualSpaceNode vsn(false, vsn_test_size_bytes); |
|
21112
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5161 |
vsn.initialize(); |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5162 |
vsn.expand_by(MediumChunk * 2, MediumChunk * 2); |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5163 |
vsn.get_chunk_vs(MediumChunk + SpecializedChunk); // Humongous chunks will be aligned up to MediumChunk + SpecializedChunk |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5164 |
vsn.retire(&cm); |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5165 |
|
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5166 |
const size_t words_left = MediumChunk * 2 - (MediumChunk + SpecializedChunk); |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5167 |
size_t num_medium_chunks, num_small_chunks, num_spec_chunks; |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5168 |
chunk_up(words_left, num_medium_chunks, num_small_chunks, num_spec_chunks); |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5169 |
|
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5170 |
assert(num_medium_chunks == 0, "should not get any medium chunks"); |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5171 |
assert(cm.sum_free_chunks_count() == (num_small_chunks + num_spec_chunks), "should be space for 3 chunks"); |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5172 |
assert(cm.sum_free_chunks() == words_left, "sizes should add up"); |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5173 |
} |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5174 |
|
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5175 |
} |
22222
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5176 |
|
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5177 |
#define assert_is_available_positive(word_size) \ |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5178 |
assert(vsn.is_available(word_size), \ |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
5179 |
#word_size ": " PTR_FORMAT " bytes were not available in " \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
5180 |
"VirtualSpaceNode [" PTR_FORMAT ", " PTR_FORMAT ")", \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
5181 |
(uintptr_t)(word_size * BytesPerWord), p2i(vsn.bottom()), p2i(vsn.end())); |
22222
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5182 |
|
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5183 |
#define assert_is_available_negative(word_size) \ |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5184 |
assert(!vsn.is_available(word_size), \ |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
5185 |
#word_size ": " PTR_FORMAT " bytes should not be available in " \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
5186 |
"VirtualSpaceNode [" PTR_FORMAT ", " PTR_FORMAT ")", \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
5187 |
(uintptr_t)(word_size * BytesPerWord), p2i(vsn.bottom()), p2i(vsn.end())); |
22222
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5188 |
|
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5189 |
static void test_is_available_positive() { |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5190 |
// Reserve some memory. |
49365 | 5191 |
VirtualSpaceNode vsn(false, os::vm_allocation_granularity()); |
22222
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5192 |
assert(vsn.initialize(), "Failed to setup VirtualSpaceNode"); |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5193 |
|
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5194 |
// Commit some memory. |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5195 |
size_t commit_word_size = os::vm_allocation_granularity() / BytesPerWord; |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5196 |
bool expanded = vsn.expand_by(commit_word_size, commit_word_size); |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5197 |
assert(expanded, "Failed to commit"); |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5198 |
|
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5199 |
// Check that is_available accepts the committed size. |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5200 |
assert_is_available_positive(commit_word_size); |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5201 |
|
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5202 |
// Check that is_available accepts half the committed size. |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5203 |
size_t expand_word_size = commit_word_size / 2; |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5204 |
assert_is_available_positive(expand_word_size); |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5205 |
} |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5206 |
|
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5207 |
static void test_is_available_negative() { |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5208 |
// Reserve some memory. |
49365 | 5209 |
VirtualSpaceNode vsn(false, os::vm_allocation_granularity()); |
22222
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5210 |
assert(vsn.initialize(), "Failed to setup VirtualSpaceNode"); |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5211 |
|
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5212 |
// Commit some memory. |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5213 |
size_t commit_word_size = os::vm_allocation_granularity() / BytesPerWord; |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5214 |
bool expanded = vsn.expand_by(commit_word_size, commit_word_size); |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5215 |
assert(expanded, "Failed to commit"); |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5216 |
|
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5217 |
// Check that is_available doesn't accept a too large size. |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5218 |
size_t two_times_commit_word_size = commit_word_size * 2; |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5219 |
assert_is_available_negative(two_times_commit_word_size); |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5220 |
} |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5221 |
|
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5222 |
static void test_is_available_overflow() { |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5223 |
// Reserve some memory. |
49365 | 5224 |
VirtualSpaceNode vsn(false, os::vm_allocation_granularity()); |
22222
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5225 |
assert(vsn.initialize(), "Failed to setup VirtualSpaceNode"); |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5226 |
|
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5227 |
// Commit some memory. |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5228 |
size_t commit_word_size = os::vm_allocation_granularity() / BytesPerWord; |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5229 |
bool expanded = vsn.expand_by(commit_word_size, commit_word_size); |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5230 |
assert(expanded, "Failed to commit"); |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5231 |
|
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5232 |
// Calculate a size that will overflow the virtual space size. |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5233 |
void* virtual_space_max = (void*)(uintptr_t)-1; |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5234 |
size_t bottom_to_max = pointer_delta(virtual_space_max, vsn.bottom(), 1); |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5235 |
size_t overflow_size = bottom_to_max + BytesPerWord; |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5236 |
size_t overflow_word_size = overflow_size / BytesPerWord; |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5237 |
|
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5238 |
// Check that is_available can handle the overflow. |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5239 |
assert_is_available_negative(overflow_word_size); |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5240 |
} |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5241 |
|
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5242 |
static void test_is_available() { |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5243 |
TestVirtualSpaceNodeTest::test_is_available_positive(); |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5244 |
TestVirtualSpaceNodeTest::test_is_available_negative(); |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5245 |
TestVirtualSpaceNodeTest::test_is_available_overflow(); |
45a293a4b895
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
21569
diff
changeset
|
5246 |
} |
21112
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5247 |
}; |
eb9c887bac49
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
20733
diff
changeset
|
5248 |
|
42615
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5249 |
// The following test is placed here instead of a gtest / unittest file |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5250 |
// because the ChunkManager class is only available in this file. |
42621
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
5251 |
void ChunkManager_test_list_index() { |
49365 | 5252 |
ChunkManager manager(true); |
42621
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
5253 |
|
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
5254 |
// Test previous bug where a query for a humongous class metachunk, |
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
5255 |
// incorrectly matched the non-class medium metachunk size. |
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
5256 |
{ |
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
5257 |
assert(MediumChunk > ClassMediumChunk, "Precondition for test"); |
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
5258 |
|
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
5259 |
ChunkIndex index = manager.list_index(MediumChunk); |
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
5260 |
|
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
5261 |
assert(index == HumongousIndex, |
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
5262 |
"Requested size is larger than ClassMediumChunk," |
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
5263 |
" so should return HumongousIndex. Got index: %d", (int)index); |
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
5264 |
} |
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
5265 |
|
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
5266 |
// Check the specified sizes as well. |
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
5267 |
{ |
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
5268 |
ChunkIndex index = manager.list_index(ClassSpecializedChunk); |
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
5269 |
assert(index == SpecializedIndex, "Wrong index returned. Got index: %d", (int)index); |
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
5270 |
} |
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
5271 |
{ |
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
5272 |
ChunkIndex index = manager.list_index(ClassSmallChunk); |
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
5273 |
assert(index == SmallIndex, "Wrong index returned. Got index: %d", (int)index); |
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
5274 |
} |
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
5275 |
{ |
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
5276 |
ChunkIndex index = manager.list_index(ClassMediumChunk); |
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
5277 |
assert(index == MediumIndex, "Wrong index returned. Got index: %d", (int)index); |
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
5278 |
} |
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
5279 |
{ |
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
5280 |
ChunkIndex index = manager.list_index(ClassMediumChunk + 1); |
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
5281 |
assert(index == HumongousIndex, "Wrong index returned. Got index: %d", (int)index); |
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
5282 |
} |
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
5283 |
} |
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
5284 |
|
46602 | 5285 |
#endif // !PRODUCT |
5286 |
||
5287 |
#ifdef ASSERT |
|
5288 |
||
42621
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
5289 |
// The following test is placed here instead of a gtest / unittest file |
f2598e832afa
8170358: [REDO] 8k class metaspace chunks misallocated from 4k chunk freelist
stefank
parents:
42615
diff
changeset
|
5290 |
// because the ChunkManager class is only available in this file. |
42615
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5291 |
class SpaceManagerTest : AllStatic { |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5292 |
friend void SpaceManager_test_adjust_initial_chunk_size(); |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5293 |
|
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5294 |
static void test_adjust_initial_chunk_size(bool is_class) { |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5295 |
const size_t smallest = SpaceManager::smallest_chunk_size(is_class); |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5296 |
const size_t normal = SpaceManager::small_chunk_size(is_class); |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5297 |
const size_t medium = SpaceManager::medium_chunk_size(is_class); |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5298 |
|
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5299 |
#define test_adjust_initial_chunk_size(value, expected, is_class_value) \ |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5300 |
do { \ |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5301 |
size_t v = value; \ |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5302 |
size_t e = expected; \ |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5303 |
assert(SpaceManager::adjust_initial_chunk_size(v, (is_class_value)) == e, \ |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5304 |
"Expected: " SIZE_FORMAT " got: " SIZE_FORMAT, e, v); \ |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5305 |
} while (0) |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5306 |
|
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5307 |
// Smallest (specialized) |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5308 |
test_adjust_initial_chunk_size(1, smallest, is_class); |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5309 |
test_adjust_initial_chunk_size(smallest - 1, smallest, is_class); |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5310 |
test_adjust_initial_chunk_size(smallest, smallest, is_class); |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5311 |
|
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5312 |
// Small |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5313 |
test_adjust_initial_chunk_size(smallest + 1, normal, is_class); |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5314 |
test_adjust_initial_chunk_size(normal - 1, normal, is_class); |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5315 |
test_adjust_initial_chunk_size(normal, normal, is_class); |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5316 |
|
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5317 |
// Medium |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5318 |
test_adjust_initial_chunk_size(normal + 1, medium, is_class); |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5319 |
test_adjust_initial_chunk_size(medium - 1, medium, is_class); |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5320 |
test_adjust_initial_chunk_size(medium, medium, is_class); |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5321 |
|
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5322 |
// Humongous |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5323 |
test_adjust_initial_chunk_size(medium + 1, medium + 1, is_class); |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5324 |
|
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5325 |
#undef test_adjust_initial_chunk_size |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5326 |
} |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5327 |
|
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5328 |
static void test_adjust_initial_chunk_size() { |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5329 |
test_adjust_initial_chunk_size(false); |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5330 |
test_adjust_initial_chunk_size(true); |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5331 |
} |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5332 |
}; |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5333 |
|
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5334 |
void SpaceManager_test_adjust_initial_chunk_size() { |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5335 |
SpaceManagerTest::test_adjust_initial_chunk_size(); |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5336 |
} |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
5337 |
|
46602 | 5338 |
#endif // ASSERT |
49365 | 5339 |
|
5340 |
struct chunkmanager_statistics_t { |
|
5341 |
int num_specialized_chunks; |
|
5342 |
int num_small_chunks; |
|
5343 |
int num_medium_chunks; |
|
5344 |
int num_humongous_chunks; |
|
5345 |
}; |
|
5346 |
||
5347 |
extern void test_metaspace_retrieve_chunkmanager_statistics(Metaspace::MetadataType mdType, chunkmanager_statistics_t* out) { |
|
5348 |
ChunkManager* const chunk_manager = Metaspace::get_chunk_manager(mdType); |
|
5349 |
ChunkManager::ChunkManagerStatistics stat; |
|
5350 |
chunk_manager->get_statistics(&stat); |
|
5351 |
out->num_specialized_chunks = (int)stat.num_by_type[SpecializedIndex]; |
|
5352 |
out->num_small_chunks = (int)stat.num_by_type[SmallIndex]; |
|
5353 |
out->num_medium_chunks = (int)stat.num_by_type[MediumIndex]; |
|
5354 |
out->num_humongous_chunks = (int)stat.num_humongous_chunks; |
|
5355 |
} |
|
5356 |
||
5357 |
struct chunk_geometry_t { |
|
5358 |
size_t specialized_chunk_word_size; |
|
5359 |
size_t small_chunk_word_size; |
|
5360 |
size_t medium_chunk_word_size; |
|
5361 |
}; |
|
5362 |
||
5363 |
extern void test_metaspace_retrieve_chunk_geometry(Metaspace::MetadataType mdType, chunk_geometry_t* out) { |
|
5364 |
if (mdType == Metaspace::NonClassType) { |
|
5365 |
out->specialized_chunk_word_size = SpecializedChunk; |
|
5366 |
out->small_chunk_word_size = SmallChunk; |
|
5367 |
out->medium_chunk_word_size = MediumChunk; |
|
5368 |
} else { |
|
5369 |
out->specialized_chunk_word_size = ClassSpecializedChunk; |
|
5370 |
out->small_chunk_word_size = ClassSmallChunk; |
|
5371 |
out->medium_chunk_word_size = ClassMediumChunk; |
|
5372 |
} |
|
5373 |
} |
|
5374 |