annotate src/share/vm/memory/metaspace.cpp @ 12340:bc918fd1e584

8025279: metaspace/flags/maxMetaspaceSize throws OOM: out of Compressed Klass space Summary: Only put "Compressed class space" as OOM cause if actually using Compressed class space Reviewed-by: jwilhelm, stefank, ehelin, coleenp
author mgerdin
date Fri, 27 Sep 2013 10:23:12 +0200
parents 03f493ce3a71
children 85c1ca43713f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1 /*
8712
3efdfd6ddbf2 8003553: NPG: metaspace objects should be zeroed in constructors
coleenp
parents: 8040
diff changeset
2 * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
6725
da91efe96a93 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.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
4 *
da91efe96a93 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
da91efe96a93 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
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
7 * published by the Free Software Foundation.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
8 *
da91efe96a93 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
da91efe96a93 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
da91efe96a93 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
da91efe96a93 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
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
13 * accompanied this code).
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
14 *
da91efe96a93 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
da91efe96a93 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,
da91efe96a93 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.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
18 *
da91efe96a93 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
da91efe96a93 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
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
21 * questions.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
22 *
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
23 */
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
24 #include "precompiled.hpp"
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
25 #include "gc_interface/collectedHeap.hpp"
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
26 #include "memory/allocation.hpp"
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
27 #include "memory/binaryTreeDictionary.hpp"
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
28 #include "memory/freeList.hpp"
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
29 #include "memory/collectorPolicy.hpp"
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
30 #include "memory/filemap.hpp"
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
31 #include "memory/freeList.hpp"
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
32 #include "memory/metablock.hpp"
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
33 #include "memory/metachunk.hpp"
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
34 #include "memory/metaspace.hpp"
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
35 #include "memory/metaspaceShared.hpp"
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
36 #include "memory/resourceArea.hpp"
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
37 #include "memory/universe.hpp"
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
38 #include "runtime/globals.hpp"
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
39 #include "runtime/java.hpp"
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
40 #include "runtime/mutex.hpp"
7176
59c790074993 8003635: NPG: AsynchGetCallTrace broken by Method* virtual call
coleenp
parents: 6969
diff changeset
41 #include "runtime/orderAccess.hpp"
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
42 #include "services/memTracker.hpp"
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
43 #include "utilities/copy.hpp"
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
44 #include "utilities/debug.hpp"
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
45
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
46 typedef BinaryTreeDictionary<Metablock, FreeList> BlockTreeDictionary;
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
47 typedef BinaryTreeDictionary<Metachunk, FreeList> ChunkTreeDictionary;
6969
6bc207d87e5d 7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents: 6885
diff changeset
48 // Define this macro to enable slow integrity checking of
6bc207d87e5d 7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents: 6885
diff changeset
49 // the free chunk lists
6bc207d87e5d 7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents: 6885
diff changeset
50 const bool metaspace_slow_verify = false;
6bc207d87e5d 7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents: 6885
diff changeset
51
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
52 // Parameters for stress mode testing
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
53 const uint metadata_deallocate_a_lot_block = 10;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
54 const uint metadata_deallocate_a_lock_chunk = 3;
12231
24e87613ee58 8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents: 12226
diff changeset
55 size_t const allocation_from_dictionary_limit = 4 * K;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
56
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
57 MetaWord* last_allocated = 0;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
58
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
59 size_t Metaspace::_class_metaspace_size;
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
60
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
61 // Used in declarations in SpaceManager and ChunkManager
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
62 enum ChunkIndex {
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
63 ZeroIndex = 0,
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
64 SpecializedIndex = ZeroIndex,
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
65 SmallIndex = SpecializedIndex + 1,
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
66 MediumIndex = SmallIndex + 1,
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
67 HumongousIndex = MediumIndex + 1,
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
68 NumberOfFreeLists = 3,
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
69 NumberOfInUseLists = 4
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
70 };
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
71
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
72 enum ChunkSizes { // in words.
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
73 ClassSpecializedChunk = 128,
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
74 SpecializedChunk = 128,
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
75 ClassSmallChunk = 256,
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
76 SmallChunk = 512,
11064
de2d15ce3d4a 8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents: 10376
diff changeset
77 ClassMediumChunk = 4 * K,
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
78 MediumChunk = 8 * K,
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
79 HumongousChunkGranularity = 8
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
80 };
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
81
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
82 static ChunkIndex next_chunk_index(ChunkIndex i) {
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
83 assert(i < NumberOfInUseLists, "Out of bound");
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
84 return (ChunkIndex) (i+1);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
85 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
86
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
87 // Originally _capacity_until_GC was set to MetaspaceSize here but
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
88 // the default MetaspaceSize before argument processing was being
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
89 // used which was not the desired value. See the code
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
90 // in should_expand() to see how the initialization is handled
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
91 // now.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
92 size_t MetaspaceGC::_capacity_until_GC = 0;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
93 bool MetaspaceGC::_expand_after_GC = false;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
94 uint MetaspaceGC::_shrink_factor = 0;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
95 bool MetaspaceGC::_should_concurrent_collect = false;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
96
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
97 // Blocks of space for metadata are allocated out of Metachunks.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
98 //
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
99 // Metachunk are allocated out of MetadataVirtualspaces and once
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
100 // allocated there is no explicit link between a Metachunk and
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
101 // the MetadataVirtualspaces from which it was allocated.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
102 //
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
103 // Each SpaceManager maintains a
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
104 // list of the chunks it is using and the current chunk. The current
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
105 // chunk is the chunk from which allocations are done. Space freed in
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
106 // a chunk is placed on the free list of blocks (BlockFreelist) and
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
107 // reused from there.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
108
10101
df254344edf1 8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents: 8813
diff changeset
109 typedef class FreeList<Metachunk> ChunkList;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
110
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
111 // Manages the global free lists of chunks.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
112 // Has three lists of free chunks, and a total size and
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
113 // count that includes all three
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
114
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
115 class ChunkManager : public CHeapObj<mtInternal> {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
116
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
117 // Free list of chunks of different sizes.
10175
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
118 // SpecializedChunk
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
119 // SmallChunk
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
120 // MediumChunk
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
121 // HumongousChunk
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
122 ChunkList _free_chunks[NumberOfFreeLists];
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
123
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
124
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
125 // HumongousChunk
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
126 ChunkTreeDictionary _humongous_dictionary;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
127
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
128 // ChunkManager in all lists of this type
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
129 size_t _free_chunks_total;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
130 size_t _free_chunks_count;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
131
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
132 void dec_free_chunks_total(size_t v) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
133 assert(_free_chunks_count > 0 &&
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
134 _free_chunks_total > 0,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
135 "About to go negative");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
136 Atomic::add_ptr(-1, &_free_chunks_count);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
137 jlong minus_v = (jlong) - (jlong) v;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
138 Atomic::add_ptr(minus_v, &_free_chunks_total);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
139 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
140
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
141 // Debug support
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
142
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
143 size_t sum_free_chunks();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
144 size_t sum_free_chunks_count();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
145
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
146 void locked_verify_free_chunks_total();
6969
6bc207d87e5d 7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents: 6885
diff changeset
147 void slow_locked_verify_free_chunks_total() {
6bc207d87e5d 7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents: 6885
diff changeset
148 if (metaspace_slow_verify) {
6bc207d87e5d 7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents: 6885
diff changeset
149 locked_verify_free_chunks_total();
6bc207d87e5d 7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents: 6885
diff changeset
150 }
6bc207d87e5d 7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents: 6885
diff changeset
151 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
152 void locked_verify_free_chunks_count();
6969
6bc207d87e5d 7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents: 6885
diff changeset
153 void slow_locked_verify_free_chunks_count() {
6bc207d87e5d 7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents: 6885
diff changeset
154 if (metaspace_slow_verify) {
6bc207d87e5d 7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents: 6885
diff changeset
155 locked_verify_free_chunks_count();
6bc207d87e5d 7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents: 6885
diff changeset
156 }
6bc207d87e5d 7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents: 6885
diff changeset
157 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
158 void verify_free_chunks_count();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
159
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
160 public:
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
161
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
162 ChunkManager(size_t specialized_size, size_t small_size, size_t medium_size)
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
163 : _free_chunks_total(0), _free_chunks_count(0) {
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
164 _free_chunks[SpecializedIndex].set_size(specialized_size);
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
165 _free_chunks[SmallIndex].set_size(small_size);
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
166 _free_chunks[MediumIndex].set_size(medium_size);
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
167 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
168
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
169 // add or delete (return) a chunk to the global freelist.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
170 Metachunk* chunk_freelist_allocate(size_t word_size);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
171 void chunk_freelist_deallocate(Metachunk* chunk);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
172
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
173 // Map a size to a list index assuming that there are lists
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
174 // for special, small, medium, and humongous chunks.
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
175 static ChunkIndex list_index(size_t size);
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
176
10175
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
177 // Remove the chunk from its freelist. It is
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
178 // expected to be on one of the _free_chunks[] lists.
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
179 void remove_chunk(Metachunk* chunk);
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
180
10101
df254344edf1 8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents: 8813
diff changeset
181 // Add the simple linked list of chunks to the freelist of chunks
df254344edf1 8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents: 8813
diff changeset
182 // of type index.
df254344edf1 8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents: 8813
diff changeset
183 void return_chunks(ChunkIndex index, Metachunk* chunks);
df254344edf1 8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents: 8813
diff changeset
184
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
185 // Total of the space in the free chunks list
12235
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
186 size_t free_chunks_total_words();
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
187 size_t free_chunks_total_bytes();
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
188
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
189 // Number of chunks in the free chunks list
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
190 size_t free_chunks_count();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
191
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
192 void inc_free_chunks_total(size_t v, size_t count = 1) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
193 Atomic::add_ptr(count, &_free_chunks_count);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
194 Atomic::add_ptr(v, &_free_chunks_total);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
195 }
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
196 ChunkTreeDictionary* humongous_dictionary() {
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
197 return &_humongous_dictionary;
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
198 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
199
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
200 ChunkList* free_chunks(ChunkIndex index);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
201
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
202 // Returns the list for the given chunk word size.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
203 ChunkList* find_free_chunks_list(size_t word_size);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
204
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
205 // Add and remove from a list by size. Selects
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
206 // list based on size of chunk.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
207 void free_chunks_put(Metachunk* chuck);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
208 Metachunk* free_chunks_get(size_t chunk_word_size);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
209
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
210 // Debug support
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
211 void verify();
6969
6bc207d87e5d 7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents: 6885
diff changeset
212 void slow_verify() {
6bc207d87e5d 7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents: 6885
diff changeset
213 if (metaspace_slow_verify) {
6bc207d87e5d 7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents: 6885
diff changeset
214 verify();
6bc207d87e5d 7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents: 6885
diff changeset
215 }
6bc207d87e5d 7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents: 6885
diff changeset
216 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
217 void locked_verify();
6969
6bc207d87e5d 7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents: 6885
diff changeset
218 void slow_locked_verify() {
6bc207d87e5d 7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents: 6885
diff changeset
219 if (metaspace_slow_verify) {
6bc207d87e5d 7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents: 6885
diff changeset
220 locked_verify();
6bc207d87e5d 7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents: 6885
diff changeset
221 }
6bc207d87e5d 7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents: 6885
diff changeset
222 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
223 void verify_free_chunks_total();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
224
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
225 void locked_print_free_chunks(outputStream* st);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
226 void locked_print_sum_free_chunks(outputStream* st);
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
227
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
228 void print_on(outputStream* st) const;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
229 };
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
230
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
231 // Used to manage the free list of Metablocks (a block corresponds
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
232 // to the allocation of a quantum of metadata).
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
233 class BlockFreelist VALUE_OBJ_CLASS_SPEC {
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
234 BlockTreeDictionary* _dictionary;
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
235 static Metablock* initialize_free_chunk(MetaWord* p, size_t word_size);
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
236
12231
24e87613ee58 8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents: 12226
diff changeset
237 // Only allocate and split from freelist if the size of the allocation
24e87613ee58 8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents: 12226
diff changeset
238 // is at least 1/4th the size of the available block.
24e87613ee58 8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents: 12226
diff changeset
239 const static int WasteMultiplier = 4;
24e87613ee58 8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents: 12226
diff changeset
240
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
241 // Accessors
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
242 BlockTreeDictionary* dictionary() const { return _dictionary; }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
243
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
244 public:
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
245 BlockFreelist();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
246 ~BlockFreelist();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
247
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
248 // Get and return a block to the free list
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
249 MetaWord* get_block(size_t word_size);
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
250 void return_block(MetaWord* p, size_t word_size);
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
251
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
252 size_t total_size() {
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
253 if (dictionary() == NULL) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
254 return 0;
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
255 } else {
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
256 return dictionary()->total_size();
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
257 }
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
258 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
259
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
260 void print_on(outputStream* st) const;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
261 };
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
262
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
263 class VirtualSpaceNode : public CHeapObj<mtClass> {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
264 friend class VirtualSpaceList;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
265
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
266 // Link to next VirtualSpaceNode
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
267 VirtualSpaceNode* _next;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
268
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
269 // total in the VirtualSpace
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
270 MemRegion _reserved;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
271 ReservedSpace _rs;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
272 VirtualSpace _virtual_space;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
273 MetaWord* _top;
10175
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
274 // count of chunks contained in this VirtualSpace
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
275 uintx _container_count;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
276
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
277 // Convenience functions to access the _virtual_space
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
278 char* low() const { return virtual_space()->low(); }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
279 char* high() const { return virtual_space()->high(); }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
280
10175
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
281 // The first Metachunk will be allocated at the bottom of the
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
282 // VirtualSpace
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
283 Metachunk* first_chunk() { return (Metachunk*) bottom(); }
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
284
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
285 public:
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
286
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
287 VirtualSpaceNode(size_t byte_size);
10175
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
288 VirtualSpaceNode(ReservedSpace rs) : _top(NULL), _next(NULL), _rs(rs), _container_count(0) {}
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
289 ~VirtualSpaceNode();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
290
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
291 // Convenience functions for logical bottom and end
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
292 MetaWord* bottom() const { return (MetaWord*) _virtual_space.low(); }
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
293 MetaWord* end() const { return (MetaWord*) _virtual_space.high(); }
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
294
12236
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
295 size_t reserved_words() const { return _virtual_space.reserved_size() / BytesPerWord; }
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
296 size_t expanded_words() const { return _virtual_space.committed_size() / BytesPerWord; }
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
297 size_t committed_words() const { return _virtual_space.actual_committed_size() / BytesPerWord; }
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
298
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
299 // address of next available space in _virtual_space;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
300 // Accessors
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
301 VirtualSpaceNode* next() { return _next; }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
302 void set_next(VirtualSpaceNode* v) { _next = v; }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
303
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
304 void set_reserved(MemRegion const v) { _reserved = v; }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
305 void set_top(MetaWord* v) { _top = v; }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
306
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
307 // Accessors
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
308 MemRegion* reserved() { return &_reserved; }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
309 VirtualSpace* virtual_space() const { return (VirtualSpace*) &_virtual_space; }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
310
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
311 // Returns true if "word_size" is available in the VirtualSpace
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
312 bool is_available(size_t word_size) { return _top + word_size <= end(); }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
313
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
314 MetaWord* top() const { return _top; }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
315 void inc_top(size_t word_size) { _top += word_size; }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
316
10175
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
317 uintx container_count() { return _container_count; }
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
318 void inc_container_count();
10175
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
319 void dec_container_count();
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
320 #ifdef ASSERT
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
321 uint container_count_slow();
10175
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
322 void verify_container_count();
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
323 #endif
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
324
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
325 // used and capacity in this single entry in the list
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
326 size_t used_words_in_vs() const;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
327 size_t capacity_words_in_vs() const;
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
328 size_t free_words_in_vs() const;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
329
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
330 bool initialize();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
331
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
332 // get space from the virtual space
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
333 Metachunk* take_from_committed(size_t chunk_word_size);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
334
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
335 // Allocate a chunk from the virtual space and return it.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
336 Metachunk* get_chunk_vs(size_t chunk_word_size);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
337
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
338 // Expands/shrinks the committed space in a virtual space. Delegates
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
339 // to Virtualspace
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
340 bool expand_by(size_t words, bool pre_touch = false);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
341
10175
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
342 // In preparation for deleting this node, remove all the chunks
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
343 // in the node from any freelist.
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
344 void purge(ChunkManager* chunk_manager);
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
345
7185
90273fc0a981 8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents: 6969
diff changeset
346 #ifdef ASSERT
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
347 // Debug support
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
348 void mangle();
7185
90273fc0a981 8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents: 6969
diff changeset
349 #endif
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
350
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
351 void print_on(outputStream* st) const;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
352 };
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
353
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
354 // byte_size is the size of the associated virtualspace.
12110
4c84d351cca9 8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents: 12063
diff changeset
355 VirtualSpaceNode::VirtualSpaceNode(size_t byte_size) : _top(NULL), _next(NULL), _rs(), _container_count(0) {
8752
82f49e8e2c28 8009614: nsk/split_verifier/stress/ifelse/ifelse002_30 fails with 'assert((size & (granularity - 1)) == 0) failed: size not aligned to os::vm_allocation_granularity()
zgu
parents: 8712
diff changeset
356 // align up to vm allocation granularity
82f49e8e2c28 8009614: nsk/split_verifier/stress/ifelse/ifelse002_30 fails with 'assert((size & (granularity - 1)) == 0) failed: size not aligned to os::vm_allocation_granularity()
zgu
parents: 8712
diff changeset
357 byte_size = align_size_up(byte_size, os::vm_allocation_granularity());
82f49e8e2c28 8009614: nsk/split_verifier/stress/ifelse/ifelse002_30 fails with 'assert((size & (granularity - 1)) == 0) failed: size not aligned to os::vm_allocation_granularity()
zgu
parents: 8712
diff changeset
358
8804
91bf0bdae37b 8008217: CDS: Class data sharing limits the malloc heap on Solaris
coleenp
parents: 8754
diff changeset
359 // This allocates memory with mmap. For DumpSharedspaces, try to reserve
91bf0bdae37b 8008217: CDS: Class data sharing limits the malloc heap on Solaris
coleenp
parents: 8754
diff changeset
360 // configurable address, generally at the top of the Java heap so other
91bf0bdae37b 8008217: CDS: Class data sharing limits the malloc heap on Solaris
coleenp
parents: 8754
diff changeset
361 // memory addresses don't conflict.
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
362 if (DumpSharedSpaces) {
8804
91bf0bdae37b 8008217: CDS: Class data sharing limits the malloc heap on Solaris
coleenp
parents: 8754
diff changeset
363 char* shared_base = (char*)SharedBaseAddress;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
364 _rs = ReservedSpace(byte_size, 0, false, shared_base, 0);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
365 if (_rs.is_reserved()) {
8804
91bf0bdae37b 8008217: CDS: Class data sharing limits the malloc heap on Solaris
coleenp
parents: 8754
diff changeset
366 assert(shared_base == 0 || _rs.base() == shared_base, "should match");
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
367 } else {
8804
91bf0bdae37b 8008217: CDS: Class data sharing limits the malloc heap on Solaris
coleenp
parents: 8754
diff changeset
368 // Get a mmap region anywhere if the SharedBaseAddress fails.
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
369 _rs = ReservedSpace(byte_size);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
370 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
371 MetaspaceShared::set_shared_rs(&_rs);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
372 } else {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
373 _rs = ReservedSpace(byte_size);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
374 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
375
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
376 MemTracker::record_virtual_memory_type((address)_rs.base(), mtClass);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
377 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
378
10175
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
379 void VirtualSpaceNode::purge(ChunkManager* chunk_manager) {
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
380 Metachunk* chunk = first_chunk();
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
381 Metachunk* invalid_chunk = (Metachunk*) top();
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
382 while (chunk < invalid_chunk ) {
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
383 assert(chunk->is_free(), "Should be marked free");
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
384 MetaWord* next = ((MetaWord*)chunk) + chunk->word_size();
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
385 chunk_manager->remove_chunk(chunk);
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
386 assert(chunk->next() == NULL &&
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
387 chunk->prev() == NULL,
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
388 "Was not removed from its list");
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
389 chunk = (Metachunk*) next;
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
390 }
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
391 }
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
392
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
393 #ifdef ASSERT
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
394 uint VirtualSpaceNode::container_count_slow() {
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
395 uint count = 0;
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
396 Metachunk* chunk = first_chunk();
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
397 Metachunk* invalid_chunk = (Metachunk*) top();
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
398 while (chunk < invalid_chunk ) {
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
399 MetaWord* next = ((MetaWord*)chunk) + chunk->word_size();
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
400 // Don't count the chunks on the free lists. Those are
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
401 // still part of the VirtualSpaceNode but not currently
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
402 // counted.
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
403 if (!chunk->is_free()) {
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
404 count++;
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
405 }
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
406 chunk = (Metachunk*) next;
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
407 }
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
408 return count;
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
409 }
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
410 #endif
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
411
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
412 // List of VirtualSpaces for metadata allocation.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
413 // It has a _next link for singly linked list and a MemRegion
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
414 // for total space in the VirtualSpace.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
415 class VirtualSpaceList : public CHeapObj<mtClass> {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
416 friend class VirtualSpaceNode;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
417
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
418 enum VirtualSpaceSizes {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
419 VirtualSpaceSize = 256 * K
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
420 };
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
421
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
422 // Global list of virtual spaces
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
423 // Head of the list
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
424 VirtualSpaceNode* _virtual_space_list;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
425 // virtual space currently being used for allocations
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
426 VirtualSpaceNode* _current_virtual_space;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
427
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
428 // Can this virtual list allocate >1 spaces? Also, used to determine
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
429 // whether to allocate unlimited small chunks in this virtual space
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
430 bool _is_class;
12226
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 12110
diff changeset
431 bool can_grow() const { return !is_class() || !UseCompressedClassPointers; }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
432
12236
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
433 // Sum of reserved and committed memory in the virtual spaces
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
434 size_t _reserved_words;
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
435 size_t _committed_words;
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
436
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
437 // Number of virtual spaces
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
438 size_t _virtual_space_count;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
439
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
440 ~VirtualSpaceList();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
441
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
442 VirtualSpaceNode* virtual_space_list() const { return _virtual_space_list; }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
443
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
444 void set_virtual_space_list(VirtualSpaceNode* v) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
445 _virtual_space_list = v;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
446 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
447 void set_current_virtual_space(VirtualSpaceNode* v) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
448 _current_virtual_space = v;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
449 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
450
12236
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
451 void link_vs(VirtualSpaceNode* new_entry);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
452
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
453 // Get another virtual space and add it to the list. This
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
454 // is typically prompted by a failed attempt to allocate a chunk
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
455 // and is typically followed by the allocation of a chunk.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
456 bool grow_vs(size_t vs_word_size);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
457
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
458 public:
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
459 VirtualSpaceList(size_t word_size);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
460 VirtualSpaceList(ReservedSpace rs);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
461
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
462 size_t free_bytes();
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
463
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
464 Metachunk* get_new_chunk(size_t word_size,
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
465 size_t grow_chunks_by_words,
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
466 size_t medium_chunk_bunch);
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
467
12236
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
468 bool expand_by(VirtualSpaceNode* node, size_t word_size, bool pre_touch = false);
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
469
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
470 // Get the first chunk for a Metaspace. Used for
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
471 // special cases such as the boot class loader, reflection
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
472 // class loader and anonymous class loader.
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
473 Metachunk* get_initialization_chunk(size_t word_size, size_t chunk_bunch);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
474
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
475 VirtualSpaceNode* current_virtual_space() {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
476 return _current_virtual_space;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
477 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
478
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
479 bool is_class() const { return _is_class; }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
480
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
481 // Allocate the first virtualspace.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
482 void initialize(size_t word_size);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
483
12236
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
484 size_t reserved_words() { return _reserved_words; }
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
485 size_t reserved_bytes() { return reserved_words() * BytesPerWord; }
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
486 size_t committed_words() { return _committed_words; }
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
487 size_t committed_bytes() { return committed_words() * BytesPerWord; }
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
488
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
489 void inc_reserved_words(size_t v);
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
490 void dec_reserved_words(size_t v);
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
491 void inc_committed_words(size_t v);
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
492 void dec_committed_words(size_t v);
10175
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
493 void inc_virtual_space_count();
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
494 void dec_virtual_space_count();
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
495
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
496 // Unlink empty VirtualSpaceNodes and free it.
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
497 void purge(ChunkManager* chunk_manager);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
498
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
499 bool contains(const void *ptr);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
500
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
501 void print_on(outputStream* st) const;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
502
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
503 class VirtualSpaceListIterator : public StackObj {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
504 VirtualSpaceNode* _virtual_spaces;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
505 public:
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
506 VirtualSpaceListIterator(VirtualSpaceNode* virtual_spaces) :
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
507 _virtual_spaces(virtual_spaces) {}
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
508
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
509 bool repeat() {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
510 return _virtual_spaces != NULL;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
511 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
512
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
513 VirtualSpaceNode* get_next() {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
514 VirtualSpaceNode* result = _virtual_spaces;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
515 if (_virtual_spaces != NULL) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
516 _virtual_spaces = _virtual_spaces->next();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
517 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
518 return result;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
519 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
520 };
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
521 };
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
522
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
523 class Metadebug : AllStatic {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
524 // Debugging support for Metaspaces
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
525 static int _deallocate_block_a_lot_count;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
526 static int _deallocate_chunk_a_lot_count;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
527 static int _allocation_fail_alot_count;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
528
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
529 public:
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
530 static int deallocate_block_a_lot_count() {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
531 return _deallocate_block_a_lot_count;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
532 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
533 static void set_deallocate_block_a_lot_count(int v) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
534 _deallocate_block_a_lot_count = v;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
535 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
536 static void inc_deallocate_block_a_lot_count() {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
537 _deallocate_block_a_lot_count++;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
538 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
539 static int deallocate_chunk_a_lot_count() {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
540 return _deallocate_chunk_a_lot_count;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
541 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
542 static void reset_deallocate_chunk_a_lot_count() {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
543 _deallocate_chunk_a_lot_count = 1;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
544 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
545 static void inc_deallocate_chunk_a_lot_count() {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
546 _deallocate_chunk_a_lot_count++;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
547 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
548
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
549 static void init_allocation_fail_alot_count();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
550 #ifdef ASSERT
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
551 static bool test_metadata_failure();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
552 #endif
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
553
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
554 static void deallocate_chunk_a_lot(SpaceManager* sm,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
555 size_t chunk_word_size);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
556 static void deallocate_block_a_lot(SpaceManager* sm,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
557 size_t chunk_word_size);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
558
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
559 };
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
560
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
561 int Metadebug::_deallocate_block_a_lot_count = 0;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
562 int Metadebug::_deallocate_chunk_a_lot_count = 0;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
563 int Metadebug::_allocation_fail_alot_count = 0;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
564
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
565 // SpaceManager - used by Metaspace to handle allocations
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
566 class SpaceManager : public CHeapObj<mtClass> {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
567 friend class Metaspace;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
568 friend class Metadebug;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
569
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
570 private:
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
571
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
572 // protects allocations and contains.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
573 Mutex* const _lock;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
574
10330
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
575 // Type of metadata allocated.
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
576 Metaspace::MetadataType _mdtype;
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
577
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
578 // List of chunks in use by this SpaceManager. Allocations
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
579 // are done from the current chunk. The list is used for deallocating
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
580 // chunks when the SpaceManager is freed.
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
581 Metachunk* _chunks_in_use[NumberOfInUseLists];
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
582 Metachunk* _current_chunk;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
583
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
584 // Number of small chunks to allocate to a manager
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
585 // If class space manager, small chunks are unlimited
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
586 static uint const _small_chunk_limit;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
587
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
588 // Sum of all space in allocated chunks
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
589 size_t _allocated_blocks_words;
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
590
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
591 // Sum of all allocated chunks
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
592 size_t _allocated_chunks_words;
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
593 size_t _allocated_chunks_count;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
594
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
595 // Free lists of blocks are per SpaceManager since they
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
596 // are assumed to be in chunks in use by the SpaceManager
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
597 // and all chunks in use by a SpaceManager are freed when
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
598 // the class loader using the SpaceManager is collected.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
599 BlockFreelist _block_freelists;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
600
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
601 // protects virtualspace and chunk expansions
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
602 static const char* _expand_lock_name;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
603 static const int _expand_lock_rank;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
604 static Mutex* const _expand_lock;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
605
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
606 private:
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
607 // Accessors
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
608 Metachunk* chunks_in_use(ChunkIndex index) const { return _chunks_in_use[index]; }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
609 void set_chunks_in_use(ChunkIndex index, Metachunk* v) { _chunks_in_use[index] = v; }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
610
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
611 BlockFreelist* block_freelists() const {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
612 return (BlockFreelist*) &_block_freelists;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
613 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
614
10330
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
615 Metaspace::MetadataType mdtype() { return _mdtype; }
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
616
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
617 VirtualSpaceList* vs_list() const { return Metaspace::get_space_list(_mdtype); }
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
618 ChunkManager* chunk_manager() const { return Metaspace::get_chunk_manager(_mdtype); }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
619
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
620 Metachunk* current_chunk() const { return _current_chunk; }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
621 void set_current_chunk(Metachunk* v) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
622 _current_chunk = v;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
623 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
624
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
625 Metachunk* find_current_chunk(size_t word_size);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
626
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
627 // Add chunk to the list of chunks in use
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
628 void add_chunk(Metachunk* v, bool make_current);
12231
24e87613ee58 8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents: 12226
diff changeset
629 void retire_current_chunk();
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
630
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
631 Mutex* lock() const { return _lock; }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
632
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
633 const char* chunk_size_name(ChunkIndex index) const;
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
634
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
635 protected:
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
636 void initialize();
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
637
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
638 public:
10330
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
639 SpaceManager(Metaspace::MetadataType mdtype,
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
640 Mutex* lock);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
641 ~SpaceManager();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
642
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
643 enum ChunkMultiples {
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
644 MediumChunkMultiple = 4
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
645 };
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
646
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
647 bool is_class() { return _mdtype == Metaspace::ClassType; }
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
648
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
649 // Accessors
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
650 size_t specialized_chunk_size() { return SpecializedChunk; }
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
651 size_t small_chunk_size() { return (size_t) is_class() ? ClassSmallChunk : SmallChunk; }
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
652 size_t medium_chunk_size() { return (size_t) is_class() ? ClassMediumChunk : MediumChunk; }
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
653 size_t medium_chunk_bunch() { return medium_chunk_size() * MediumChunkMultiple; }
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
654
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
655 size_t allocated_blocks_words() const { return _allocated_blocks_words; }
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
656 size_t allocated_blocks_bytes() const { return _allocated_blocks_words * BytesPerWord; }
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
657 size_t allocated_chunks_words() const { return _allocated_chunks_words; }
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
658 size_t allocated_chunks_count() const { return _allocated_chunks_count; }
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
659
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
660 bool is_humongous(size_t word_size) { return word_size > medium_chunk_size(); }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
661
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
662 static Mutex* expand_lock() { return _expand_lock; }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
663
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
664 // Increment the per Metaspace and global running sums for Metachunks
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
665 // by the given size. This is used when a Metachunk to added to
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
666 // the in-use list.
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
667 void inc_size_metrics(size_t words);
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
668 // Increment the per Metaspace and global running sums Metablocks by the given
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
669 // size. This is used when a Metablock is allocated.
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
670 void inc_used_metrics(size_t words);
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
671 // Delete the portion of the running sums for this SpaceManager. That is,
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
672 // the globals running sums for the Metachunks and Metablocks are
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
673 // decremented for all the Metachunks in-use by this SpaceManager.
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
674 void dec_total_from_size_metrics();
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
675
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
676 // Set the sizes for the initial chunks.
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
677 void get_initial_chunk_sizes(Metaspace::MetaspaceType type,
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
678 size_t* chunk_word_size,
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
679 size_t* class_chunk_word_size);
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
680
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
681 size_t sum_capacity_in_chunks_in_use() const;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
682 size_t sum_used_in_chunks_in_use() const;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
683 size_t sum_free_in_chunks_in_use() const;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
684 size_t sum_waste_in_chunks_in_use() const;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
685 size_t sum_waste_in_chunks_in_use(ChunkIndex index ) const;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
686
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
687 size_t sum_count_in_chunks_in_use();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
688 size_t sum_count_in_chunks_in_use(ChunkIndex i);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
689
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
690 Metachunk* get_new_chunk(size_t word_size, size_t grow_chunks_by_words);
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
691
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
692 // Block allocation and deallocation.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
693 // Allocates a block from the current chunk
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
694 MetaWord* allocate(size_t word_size);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
695
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
696 // Helper for allocations
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
697 MetaWord* allocate_work(size_t word_size);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
698
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
699 // Returns a block to the per manager freelist
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
700 void deallocate(MetaWord* p, size_t word_size);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
701
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
702 // Based on the allocation size and a minimum chunk size,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
703 // returned chunk size (for expanding space for chunk allocation).
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
704 size_t calc_chunk_size(size_t allocation_word_size);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
705
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
706 // Called when an allocation from the current chunk fails.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
707 // Gets a new chunk (may require getting a new virtual space),
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
708 // and allocates from that chunk.
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
709 MetaWord* grow_and_allocate(size_t word_size);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
710
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
711 // debugging support.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
712
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
713 void dump(outputStream* const out) const;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
714 void print_on(outputStream* st) const;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
715 void locked_print_chunks_in_use_on(outputStream* st) const;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
716
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
717 void verify();
7208
eade6b2e4782 8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents: 7187
diff changeset
718 void verify_chunk_size(Metachunk* chunk);
7185
90273fc0a981 8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents: 6969
diff changeset
719 NOT_PRODUCT(void mangle_freed_chunks();)
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
720 #ifdef ASSERT
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
721 void verify_allocated_blocks_words();
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
722 #endif
10376
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
723
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
724 size_t get_raw_word_size(size_t word_size) {
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
725 // If only the dictionary is going to be used (i.e., no
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
726 // indexed free list), then there is a minimum size requirement.
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
727 // MinChunkSize is a placeholder for the real minimum size JJJ
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
728 size_t byte_size = word_size * BytesPerWord;
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
729
12237
335b388c4b28 8024651: Remove the incorrect usage of Metablock::overhead()
stefank
parents: 12236
diff changeset
730 size_t raw_bytes_size = MAX2(byte_size,
10376
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
731 Metablock::min_block_byte_size());
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
732 raw_bytes_size = ARENA_ALIGN(raw_bytes_size);
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
733 size_t raw_word_size = raw_bytes_size / BytesPerWord;
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
734 assert(raw_word_size * BytesPerWord == raw_bytes_size, "Size problem");
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
735
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
736 return raw_word_size;
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
737 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
738 };
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
739
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
740 uint const SpaceManager::_small_chunk_limit = 4;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
741
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
742 const char* SpaceManager::_expand_lock_name =
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
743 "SpaceManager chunk allocation lock";
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
744 const int SpaceManager::_expand_lock_rank = Monitor::leaf - 1;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
745 Mutex* const SpaceManager::_expand_lock =
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
746 new Mutex(SpaceManager::_expand_lock_rank,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
747 SpaceManager::_expand_lock_name,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
748 Mutex::_allow_vm_block_flag);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
749
10175
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
750 void VirtualSpaceNode::inc_container_count() {
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
751 assert_lock_strong(SpaceManager::expand_lock());
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
752 _container_count++;
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
753 assert(_container_count == container_count_slow(),
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
754 err_msg("Inconsistency in countainer_count _container_count " SIZE_FORMAT
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
755 " container_count_slow() " SIZE_FORMAT,
10175
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
756 _container_count, container_count_slow()));
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
757 }
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
758
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
759 void VirtualSpaceNode::dec_container_count() {
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
760 assert_lock_strong(SpaceManager::expand_lock());
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
761 _container_count--;
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
762 }
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
763
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
764 #ifdef ASSERT
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
765 void VirtualSpaceNode::verify_container_count() {
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
766 assert(_container_count == container_count_slow(),
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
767 err_msg("Inconsistency in countainer_count _container_count " SIZE_FORMAT
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
768 " container_count_slow() " SIZE_FORMAT, _container_count, container_count_slow()));
10175
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
769 }
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
770 #endif
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
771
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
772 // BlockFreelist methods
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
773
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
774 BlockFreelist::BlockFreelist() : _dictionary(NULL) {}
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
775
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
776 BlockFreelist::~BlockFreelist() {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
777 if (_dictionary != NULL) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
778 if (Verbose && TraceMetadataChunkAllocation) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
779 _dictionary->print_free_lists(gclog_or_tty);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
780 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
781 delete _dictionary;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
782 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
783 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
784
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
785 Metablock* BlockFreelist::initialize_free_chunk(MetaWord* p, size_t word_size) {
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
786 Metablock* block = (Metablock*) p;
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
787 block->set_word_size(word_size);
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
788 block->set_prev(NULL);
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
789 block->set_next(NULL);
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
790
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
791 return block;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
792 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
793
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
794 void BlockFreelist::return_block(MetaWord* p, size_t word_size) {
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
795 Metablock* free_chunk = initialize_free_chunk(p, word_size);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
796 if (dictionary() == NULL) {
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
797 _dictionary = new BlockTreeDictionary();
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
798 }
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
799 dictionary()->return_chunk(free_chunk);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
800 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
801
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
802 MetaWord* BlockFreelist::get_block(size_t word_size) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
803 if (dictionary() == NULL) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
804 return NULL;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
805 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
806
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
807 if (word_size < TreeChunk<Metablock, FreeList>::min_size()) {
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
808 // Dark matter. Too small for dictionary.
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
809 return NULL;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
810 }
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
811
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
812 Metablock* free_block =
12231
24e87613ee58 8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents: 12226
diff changeset
813 dictionary()->get_chunk(word_size, FreeBlockDictionary<Metablock>::atLeast);
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
814 if (free_block == NULL) {
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
815 return NULL;
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
816 }
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
817
12231
24e87613ee58 8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents: 12226
diff changeset
818 const size_t block_size = free_block->size();
24e87613ee58 8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents: 12226
diff changeset
819 if (block_size > WasteMultiplier * word_size) {
24e87613ee58 8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents: 12226
diff changeset
820 return_block((MetaWord*)free_block, block_size);
24e87613ee58 8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents: 12226
diff changeset
821 return NULL;
24e87613ee58 8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents: 12226
diff changeset
822 }
24e87613ee58 8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents: 12226
diff changeset
823
24e87613ee58 8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents: 12226
diff changeset
824 MetaWord* new_block = (MetaWord*)free_block;
24e87613ee58 8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents: 12226
diff changeset
825 assert(block_size >= word_size, "Incorrect size of block from freelist");
24e87613ee58 8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents: 12226
diff changeset
826 const size_t unused = block_size - word_size;
24e87613ee58 8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents: 12226
diff changeset
827 if (unused >= TreeChunk<Metablock, FreeList>::min_size()) {
24e87613ee58 8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents: 12226
diff changeset
828 return_block(new_block + word_size, unused);
24e87613ee58 8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents: 12226
diff changeset
829 }
24e87613ee58 8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents: 12226
diff changeset
830
24e87613ee58 8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents: 12226
diff changeset
831 return new_block;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
832 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
833
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
834 void BlockFreelist::print_on(outputStream* st) const {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
835 if (dictionary() == NULL) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
836 return;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
837 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
838 dictionary()->print_free_lists(st);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
839 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
840
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
841 // VirtualSpaceNode methods
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
842
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
843 VirtualSpaceNode::~VirtualSpaceNode() {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
844 _rs.release();
10175
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
845 #ifdef ASSERT
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
846 size_t word_size = sizeof(*this) / BytesPerWord;
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
847 Copy::fill_to_words((HeapWord*) this, word_size, 0xf1f1f1f1);
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
848 #endif
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
849 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
850
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
851 size_t VirtualSpaceNode::used_words_in_vs() const {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
852 return pointer_delta(top(), bottom(), sizeof(MetaWord));
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
853 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
854
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
855 // Space committed in the VirtualSpace
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
856 size_t VirtualSpaceNode::capacity_words_in_vs() const {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
857 return pointer_delta(end(), bottom(), sizeof(MetaWord));
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
858 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
859
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
860 size_t VirtualSpaceNode::free_words_in_vs() const {
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
861 return pointer_delta(end(), top(), sizeof(MetaWord));
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
862 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
863
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
864 // Allocates the chunk from the virtual space only.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
865 // This interface is also used internally for debugging. Not all
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
866 // chunks removed here are necessarily used for allocation.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
867 Metachunk* VirtualSpaceNode::take_from_committed(size_t chunk_word_size) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
868 // Bottom of the new chunk
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
869 MetaWord* chunk_limit = top();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
870 assert(chunk_limit != NULL, "Not safe to call this method");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
871
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
872 if (!is_available(chunk_word_size)) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
873 if (TraceMetadataChunkAllocation) {
12240
8c5e6482cbfc 8024752: Log TraceMetadata* output to gclog_or_tty instead of tty
stefank
parents: 12239
diff changeset
874 gclog_or_tty->print("VirtualSpaceNode::take_from_committed() not available %d words ", chunk_word_size);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
875 // Dump some information about the virtual space that is nearly full
12240
8c5e6482cbfc 8024752: Log TraceMetadata* output to gclog_or_tty instead of tty
stefank
parents: 12239
diff changeset
876 print_on(gclog_or_tty);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
877 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
878 return NULL;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
879 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
880
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
881 // Take the space (bump top on the current virtual space).
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
882 inc_top(chunk_word_size);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
883
10175
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
884 // Initialize the chunk
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
885 Metachunk* result = ::new (chunk_limit) Metachunk(chunk_word_size, this);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
886 return result;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
887 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
888
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
889
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
890 // Expand the virtual space (commit more of the reserved space)
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
891 bool VirtualSpaceNode::expand_by(size_t words, bool pre_touch) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
892 size_t bytes = words * BytesPerWord;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
893 bool result = virtual_space()->expand_by(bytes, pre_touch);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
894 if (TraceMetavirtualspaceAllocation && !result) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
895 gclog_or_tty->print_cr("VirtualSpaceNode::expand_by() failed "
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
896 "for byte size " SIZE_FORMAT, bytes);
12240
8c5e6482cbfc 8024752: Log TraceMetadata* output to gclog_or_tty instead of tty
stefank
parents: 12239
diff changeset
897 virtual_space()->print_on(gclog_or_tty);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
898 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
899 return result;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
900 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
901
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
902 Metachunk* VirtualSpaceNode::get_chunk_vs(size_t chunk_word_size) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
903 assert_lock_strong(SpaceManager::expand_lock());
10175
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
904 Metachunk* result = take_from_committed(chunk_word_size);
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
905 if (result != NULL) {
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
906 inc_container_count();
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
907 }
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
908 return result;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
909 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
910
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
911 bool VirtualSpaceNode::initialize() {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
912
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
913 if (!_rs.is_reserved()) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
914 return false;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
915 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
916
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
917 // An allocation out of this Virtualspace that is larger
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
918 // than an initial commit size can waste that initial committed
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
919 // space.
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
920 size_t committed_byte_size = 0;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
921 bool result = virtual_space()->initialize(_rs, committed_byte_size);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
922 if (result) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
923 set_top((MetaWord*)virtual_space()->low());
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
924 set_reserved(MemRegion((HeapWord*)_rs.base(),
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
925 (HeapWord*)(_rs.base() + _rs.size())));
6726
03049e0e8544 7195823: NPG: CMS reserved() doesn't match _rs.base().
coleenp
parents: 6725
diff changeset
926
03049e0e8544 7195823: NPG: CMS reserved() doesn't match _rs.base().
coleenp
parents: 6725
diff changeset
927 assert(reserved()->start() == (HeapWord*) _rs.base(),
03049e0e8544 7195823: NPG: CMS reserved() doesn't match _rs.base().
coleenp
parents: 6725
diff changeset
928 err_msg("Reserved start was not set properly " PTR_FORMAT
03049e0e8544 7195823: NPG: CMS reserved() doesn't match _rs.base().
coleenp
parents: 6725
diff changeset
929 " != " PTR_FORMAT, reserved()->start(), _rs.base()));
03049e0e8544 7195823: NPG: CMS reserved() doesn't match _rs.base().
coleenp
parents: 6725
diff changeset
930 assert(reserved()->word_size() == _rs.size() / BytesPerWord,
03049e0e8544 7195823: NPG: CMS reserved() doesn't match _rs.base().
coleenp
parents: 6725
diff changeset
931 err_msg("Reserved size was not set properly " SIZE_FORMAT
03049e0e8544 7195823: NPG: CMS reserved() doesn't match _rs.base().
coleenp
parents: 6725
diff changeset
932 " != " SIZE_FORMAT, reserved()->word_size(),
03049e0e8544 7195823: NPG: CMS reserved() doesn't match _rs.base().
coleenp
parents: 6725
diff changeset
933 _rs.size() / BytesPerWord));
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
934 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
935
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
936 return result;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
937 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
938
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
939 void VirtualSpaceNode::print_on(outputStream* st) const {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
940 size_t used = used_words_in_vs();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
941 size_t capacity = capacity_words_in_vs();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
942 VirtualSpace* vs = virtual_space();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
943 st->print_cr(" space @ " PTR_FORMAT " " SIZE_FORMAT "K, %3d%% used "
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
944 "[" PTR_FORMAT ", " PTR_FORMAT ", "
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
945 PTR_FORMAT ", " PTR_FORMAT ")",
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
946 vs, capacity / K,
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
947 capacity == 0 ? 0 : used * 100 / capacity,
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
948 bottom(), top(), end(),
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
949 vs->high_boundary());
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
950 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
951
7185
90273fc0a981 8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents: 6969
diff changeset
952 #ifdef ASSERT
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
953 void VirtualSpaceNode::mangle() {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
954 size_t word_size = capacity_words_in_vs();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
955 Copy::fill_to_words((HeapWord*) low(), word_size, 0xf1f1f1f1);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
956 }
7185
90273fc0a981 8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents: 6969
diff changeset
957 #endif // ASSERT
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
958
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
959 // VirtualSpaceList methods
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
960 // Space allocated from the VirtualSpace
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
961
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
962 VirtualSpaceList::~VirtualSpaceList() {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
963 VirtualSpaceListIterator iter(virtual_space_list());
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
964 while (iter.repeat()) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
965 VirtualSpaceNode* vsl = iter.get_next();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
966 delete vsl;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
967 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
968 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
969
12236
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
970 void VirtualSpaceList::inc_reserved_words(size_t v) {
10175
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
971 assert_lock_strong(SpaceManager::expand_lock());
12236
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
972 _reserved_words = _reserved_words + v;
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
973 }
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
974 void VirtualSpaceList::dec_reserved_words(size_t v) {
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
975 assert_lock_strong(SpaceManager::expand_lock());
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
976 _reserved_words = _reserved_words - v;
10175
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
977 }
12236
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
978
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
979 void VirtualSpaceList::inc_committed_words(size_t v) {
10175
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
980 assert_lock_strong(SpaceManager::expand_lock());
12236
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
981 _committed_words = _committed_words + v;
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
982 }
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
983 void VirtualSpaceList::dec_committed_words(size_t v) {
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
984 assert_lock_strong(SpaceManager::expand_lock());
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
985 _committed_words = _committed_words - v;
10175
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
986 }
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
987
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
988 void VirtualSpaceList::inc_virtual_space_count() {
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
989 assert_lock_strong(SpaceManager::expand_lock());
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
990 _virtual_space_count++;
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
991 }
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
992 void VirtualSpaceList::dec_virtual_space_count() {
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
993 assert_lock_strong(SpaceManager::expand_lock());
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
994 _virtual_space_count--;
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
995 }
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
996
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
997 void ChunkManager::remove_chunk(Metachunk* chunk) {
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
998 size_t word_size = chunk->word_size();
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
999 ChunkIndex index = list_index(word_size);
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1000 if (index != HumongousIndex) {
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1001 free_chunks(index)->remove_chunk(chunk);
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1002 } else {
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1003 humongous_dictionary()->remove_chunk(chunk);
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1004 }
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1005
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1006 // Chunk is being removed from the chunks free list.
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1007 dec_free_chunks_total(chunk->capacity_word_size());
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1008 }
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1009
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1010 // Walk the list of VirtualSpaceNodes and delete
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1011 // nodes with a 0 container_count. Remove Metachunks in
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1012 // the node from their respective freelists.
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
1013 void VirtualSpaceList::purge(ChunkManager* chunk_manager) {
10175
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1014 assert_lock_strong(SpaceManager::expand_lock());
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1015 // Don't use a VirtualSpaceListIterator because this
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1016 // list is being changed and a straightforward use of an iterator is not safe.
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1017 VirtualSpaceNode* purged_vsl = NULL;
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1018 VirtualSpaceNode* prev_vsl = virtual_space_list();
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1019 VirtualSpaceNode* next_vsl = prev_vsl;
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1020 while (next_vsl != NULL) {
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1021 VirtualSpaceNode* vsl = next_vsl;
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1022 next_vsl = vsl->next();
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1023 // Don't free the current virtual space since it will likely
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1024 // be needed soon.
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1025 if (vsl->container_count() == 0 && vsl != current_virtual_space()) {
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1026 // Unlink it from the list
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1027 if (prev_vsl == vsl) {
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1028 // This is the case of the current note being the first note.
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1029 assert(vsl == virtual_space_list(), "Expected to be the first note");
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1030 set_virtual_space_list(vsl->next());
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1031 } else {
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1032 prev_vsl->set_next(vsl->next());
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1033 }
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1034
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
1035 vsl->purge(chunk_manager);
12236
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
1036 dec_reserved_words(vsl->reserved_words());
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
1037 dec_committed_words(vsl->committed_words());
10175
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1038 dec_virtual_space_count();
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1039 purged_vsl = vsl;
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1040 delete vsl;
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1041 } else {
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1042 prev_vsl = vsl;
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1043 }
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1044 }
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1045 #ifdef ASSERT
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1046 if (purged_vsl != NULL) {
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1047 // List should be stable enough to use an iterator here.
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1048 VirtualSpaceListIterator iter(virtual_space_list());
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1049 while (iter.repeat()) {
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1050 VirtualSpaceNode* vsl = iter.get_next();
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1051 assert(vsl != purged_vsl, "Purge of vsl failed");
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1052 }
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1053 }
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1054 #endif
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1055 }
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1056
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1057 VirtualSpaceList::VirtualSpaceList(size_t word_size ) :
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1058 _is_class(false),
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1059 _virtual_space_list(NULL),
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1060 _current_virtual_space(NULL),
12236
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
1061 _reserved_words(0),
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
1062 _committed_words(0),
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1063 _virtual_space_count(0) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1064 MutexLockerEx cl(SpaceManager::expand_lock(),
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1065 Mutex::_no_safepoint_check_flag);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1066 bool initialization_succeeded = grow_vs(word_size);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1067 assert(initialization_succeeded,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1068 " VirtualSpaceList initialization should not fail");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1069 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1070
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1071 VirtualSpaceList::VirtualSpaceList(ReservedSpace rs) :
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1072 _is_class(true),
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1073 _virtual_space_list(NULL),
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1074 _current_virtual_space(NULL),
12236
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
1075 _reserved_words(0),
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
1076 _committed_words(0),
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1077 _virtual_space_count(0) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1078 MutexLockerEx cl(SpaceManager::expand_lock(),
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1079 Mutex::_no_safepoint_check_flag);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1080 VirtualSpaceNode* class_entry = new VirtualSpaceNode(rs);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1081 bool succeeded = class_entry->initialize();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1082 assert(succeeded, " VirtualSpaceList initialization should not fail");
12236
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
1083 link_vs(class_entry);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1084 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1085
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1086 size_t VirtualSpaceList::free_bytes() {
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1087 return virtual_space_list()->free_words_in_vs() * BytesPerWord;
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1088 }
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1089
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1090 // Allocate another meta virtual space and add it to the list.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1091 bool VirtualSpaceList::grow_vs(size_t vs_word_size) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1092 assert_lock_strong(SpaceManager::expand_lock());
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1093 if (vs_word_size == 0) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1094 return false;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1095 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1096 // Reserve the space
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1097 size_t vs_byte_size = vs_word_size * BytesPerWord;
12306
03f493ce3a71 8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents: 12303
diff changeset
1098 assert(vs_byte_size % os::vm_allocation_granularity() == 0, "Not aligned");
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1099
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1100 // Allocate the meta virtual space and initialize it.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1101 VirtualSpaceNode* new_entry = new VirtualSpaceNode(vs_byte_size);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1102 if (!new_entry->initialize()) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1103 delete new_entry;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1104 return false;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1105 } else {
12236
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
1106 assert(new_entry->reserved_words() == vs_word_size, "Must be");
7176
59c790074993 8003635: NPG: AsynchGetCallTrace broken by Method* virtual call
coleenp
parents: 6969
diff changeset
1107 // ensure lock-free iteration sees fully initialized node
59c790074993 8003635: NPG: AsynchGetCallTrace broken by Method* virtual call
coleenp
parents: 6969
diff changeset
1108 OrderAccess::storestore();
12236
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
1109 link_vs(new_entry);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1110 return true;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1111 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1112 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1113
12236
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
1114 void VirtualSpaceList::link_vs(VirtualSpaceNode* new_entry) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1115 if (virtual_space_list() == NULL) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1116 set_virtual_space_list(new_entry);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1117 } else {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1118 current_virtual_space()->set_next(new_entry);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1119 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1120 set_current_virtual_space(new_entry);
12236
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
1121 inc_reserved_words(new_entry->reserved_words());
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
1122 inc_committed_words(new_entry->committed_words());
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1123 inc_virtual_space_count();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1124 #ifdef ASSERT
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1125 new_entry->mangle();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1126 #endif
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1127 if (TraceMetavirtualspaceAllocation && Verbose) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1128 VirtualSpaceNode* vsl = current_virtual_space();
12240
8c5e6482cbfc 8024752: Log TraceMetadata* output to gclog_or_tty instead of tty
stefank
parents: 12239
diff changeset
1129 vsl->print_on(gclog_or_tty);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1130 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1131 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1132
12236
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
1133 bool VirtualSpaceList::expand_by(VirtualSpaceNode* node, size_t word_size, bool pre_touch) {
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
1134 size_t before = node->committed_words();
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
1135
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
1136 bool result = node->expand_by(word_size, pre_touch);
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
1137
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
1138 size_t after = node->committed_words();
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
1139
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
1140 // after and before can be the same if the memory was pre-committed.
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
1141 assert(after >= before, "Must be");
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
1142 inc_committed_words(after - before);
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
1143
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
1144 return result;
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
1145 }
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
1146
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1147 Metachunk* VirtualSpaceList::get_new_chunk(size_t word_size,
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1148 size_t grow_chunks_by_words,
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1149 size_t medium_chunk_bunch) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1150
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
1151 // Allocate a chunk out of the current virtual space.
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
1152 Metachunk* next = current_virtual_space()->get_chunk_vs(grow_chunks_by_words);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1153
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1154 if (next == NULL) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1155 // Not enough room in current virtual space. Try to commit
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1156 // more space.
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1157 size_t expand_vs_by_words = MAX2(medium_chunk_bunch,
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1158 grow_chunks_by_words);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1159 size_t page_size_words = os::vm_page_size() / BytesPerWord;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1160 size_t aligned_expand_vs_by_words = align_size_up(expand_vs_by_words,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1161 page_size_words);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1162 bool vs_expanded =
12236
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
1163 expand_by(current_virtual_space(), aligned_expand_vs_by_words);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1164 if (!vs_expanded) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1165 // Should the capacity of the metaspaces be expanded for
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1166 // this allocation? If it's the virtual space for classes and is
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1167 // being used for CompressedHeaders, don't allocate a new virtualspace.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1168 if (can_grow() && MetaspaceGC::should_expand(this, word_size)) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1169 // Get another virtual space.
12306
03f493ce3a71 8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents: 12303
diff changeset
1170 size_t allocation_aligned_expand_words =
03f493ce3a71 8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents: 12303
diff changeset
1171 align_size_up(aligned_expand_vs_by_words, os::vm_allocation_granularity() / BytesPerWord);
03f493ce3a71 8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents: 12303
diff changeset
1172 size_t grow_vs_words =
03f493ce3a71 8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents: 12303
diff changeset
1173 MAX2((size_t)VirtualSpaceSize, allocation_aligned_expand_words);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1174 if (grow_vs(grow_vs_words)) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1175 // Got it. It's on the list now. Get a chunk from it.
12236
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
1176 assert(current_virtual_space()->expanded_words() == 0,
12306
03f493ce3a71 8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents: 12303
diff changeset
1177 "New virtual space nodes should not have expanded");
12236
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
1178
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
1179 size_t grow_chunks_by_words_aligned = align_size_up(grow_chunks_by_words,
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
1180 page_size_words);
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
1181 // We probably want to expand by aligned_expand_vs_by_words here.
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
1182 expand_by(current_virtual_space(), grow_chunks_by_words_aligned);
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
1183 next = current_virtual_space()->get_chunk_vs(grow_chunks_by_words);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1184 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1185 } else {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1186 // Allocation will fail and induce a GC
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1187 if (TraceMetadataChunkAllocation && Verbose) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1188 gclog_or_tty->print_cr("VirtualSpaceList::get_new_chunk():"
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1189 " Fail instead of expand the metaspace");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1190 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1191 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1192 } else {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1193 // The virtual space expanded, get a new chunk
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1194 next = current_virtual_space()->get_chunk_vs(grow_chunks_by_words);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1195 assert(next != NULL, "Just expanded, should succeed");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1196 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1197 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1198
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1199 assert(next == NULL || (next->next() == NULL && next->prev() == NULL),
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1200 "New chunk is still on some list");
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1201 return next;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1202 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1203
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1204 Metachunk* VirtualSpaceList::get_initialization_chunk(size_t chunk_word_size,
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1205 size_t chunk_bunch) {
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1206 // Get a chunk from the chunk freelist
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1207 Metachunk* new_chunk = get_new_chunk(chunk_word_size,
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1208 chunk_word_size,
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1209 chunk_bunch);
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1210 return new_chunk;
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1211 }
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1212
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1213 void VirtualSpaceList::print_on(outputStream* st) const {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1214 if (TraceMetadataChunkAllocation && Verbose) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1215 VirtualSpaceListIterator iter(virtual_space_list());
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1216 while (iter.repeat()) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1217 VirtualSpaceNode* node = iter.get_next();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1218 node->print_on(st);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1219 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1220 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1221 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1222
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1223 bool VirtualSpaceList::contains(const void *ptr) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1224 VirtualSpaceNode* list = virtual_space_list();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1225 VirtualSpaceListIterator iter(list);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1226 while (iter.repeat()) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1227 VirtualSpaceNode* node = iter.get_next();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1228 if (node->reserved()->contains(ptr)) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1229 return true;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1230 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1231 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1232 return false;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1233 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1234
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1235
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1236 // MetaspaceGC methods
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1237
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1238 // VM_CollectForMetadataAllocation is the vm operation used to GC.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1239 // Within the VM operation after the GC the attempt to allocate the metadata
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1240 // should succeed. If the GC did not free enough space for the metaspace
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1241 // allocation, the HWM is increased so that another virtualspace will be
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1242 // allocated for the metadata. With perm gen the increase in the perm
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1243 // gen had bounds, MinMetaspaceExpansion and MaxMetaspaceExpansion. The
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1244 // metaspace policy uses those as the small and large steps for the HWM.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1245 //
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1246 // After the GC the compute_new_size() for MetaspaceGC is called to
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1247 // resize the capacity of the metaspaces. The current implementation
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1248 // is based on the flags MinMetaspaceFreeRatio and MaxMetaspaceFreeRatio used
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1249 // to resize the Java heap by some GC's. New flags can be implemented
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1250 // if really needed. MinMetaspaceFreeRatio is used to calculate how much
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1251 // free space is desirable in the metaspace capacity to decide how much
8040
a83cd101fd62 8005452: NPG: Create new flags for Metaspace resizing policy
jmasa
parents: 8007
diff changeset
1252 // to increase the HWM. MaxMetaspaceFreeRatio is used to decide how much
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1253 // free space is desirable in the metaspace capacity before decreasing
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1254 // the HWM.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1255
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1256 // Calculate the amount to increase the high water mark (HWM).
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1257 // Increase by a minimum amount (MinMetaspaceExpansion) so that
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1258 // another expansion is not requested too soon. If that is not
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1259 // enough to satisfy the allocation (i.e. big enough for a word_size
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1260 // allocation), increase by MaxMetaspaceExpansion. If that is still
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1261 // not enough, expand by the size of the allocation (word_size) plus
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1262 // some.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1263 size_t MetaspaceGC::delta_capacity_until_GC(size_t word_size) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1264 size_t before_inc = MetaspaceGC::capacity_until_GC();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1265 size_t min_delta_words = MinMetaspaceExpansion / BytesPerWord;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1266 size_t max_delta_words = MaxMetaspaceExpansion / BytesPerWord;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1267 size_t page_size_words = os::vm_page_size() / BytesPerWord;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1268 size_t size_delta_words = align_size_up(word_size, page_size_words);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1269 size_t delta_words = MAX2(size_delta_words, min_delta_words);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1270 if (delta_words > min_delta_words) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1271 // Don't want to hit the high water mark on the next
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1272 // allocation so make the delta greater than just enough
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1273 // for this allocation.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1274 delta_words = MAX2(delta_words, max_delta_words);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1275 if (delta_words > max_delta_words) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1276 // This allocation is large but the next ones are probably not
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1277 // so increase by the minimum.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1278 delta_words = delta_words + min_delta_words;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1279 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1280 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1281 return delta_words;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1282 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1283
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1284 bool MetaspaceGC::should_expand(VirtualSpaceList* vsl, size_t word_size) {
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1285
8790
7f0cb32dd233 8004241: NPG: Metaspace occupies more memory than specified by -XX:MaxMetaspaceSize option
mgerdin
parents: 8786
diff changeset
1286 // If the user wants a limit, impose one.
11064
de2d15ce3d4a 8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents: 10376
diff changeset
1287 // The reason for someone using this flag is to limit reserved space. So
de2d15ce3d4a 8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents: 10376
diff changeset
1288 // for non-class virtual space, compare against virtual spaces that are reserved.
de2d15ce3d4a 8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents: 10376
diff changeset
1289 // For class virtual space, we only compare against the committed space, not
de2d15ce3d4a 8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents: 10376
diff changeset
1290 // reserved space, because this is a larger space prereserved for compressed
de2d15ce3d4a 8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents: 10376
diff changeset
1291 // class pointers.
de2d15ce3d4a 8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents: 10376
diff changeset
1292 if (!FLAG_IS_DEFAULT(MaxMetaspaceSize)) {
12302
9361de86a50f 8025059: Metspace::should_expand mixes bytes and words in check against MaxMetaspaceSize
stefank
parents: 12240
diff changeset
1293 size_t nonclass_allocated = MetaspaceAux::reserved_bytes(Metaspace::NonClassType);
9361de86a50f 8025059: Metspace::should_expand mixes bytes and words in check against MaxMetaspaceSize
stefank
parents: 12240
diff changeset
1294 size_t class_allocated = MetaspaceAux::allocated_capacity_bytes(Metaspace::ClassType);
9361de86a50f 8025059: Metspace::should_expand mixes bytes and words in check against MaxMetaspaceSize
stefank
parents: 12240
diff changeset
1295 size_t real_allocated = nonclass_allocated + class_allocated;
11064
de2d15ce3d4a 8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents: 10376
diff changeset
1296 if (real_allocated >= MaxMetaspaceSize) {
de2d15ce3d4a 8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents: 10376
diff changeset
1297 return false;
de2d15ce3d4a 8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents: 10376
diff changeset
1298 }
8790
7f0cb32dd233 8004241: NPG: Metaspace occupies more memory than specified by -XX:MaxMetaspaceSize option
mgerdin
parents: 8786
diff changeset
1299 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1300
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1301 // Class virtual space should always be expanded. Call GC for the other
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1302 // metadata virtual space.
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
1303 if (Metaspace::using_class_space() &&
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
1304 (vsl == Metaspace::class_space_list())) return true;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1305
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1306 // If this is part of an allocation after a GC, expand
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1307 // unconditionally.
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1308 if (MetaspaceGC::expand_after_GC()) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1309 return true;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1310 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1311
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1312
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1313 // If the capacity is below the minimum capacity, allow the
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1314 // expansion. Also set the high-water-mark (capacity_until_GC)
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1315 // to that minimum capacity so that a GC will not be induced
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1316 // until that minimum capacity is exceeded.
11064
de2d15ce3d4a 8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents: 10376
diff changeset
1317 size_t committed_capacity_bytes = MetaspaceAux::allocated_capacity_bytes();
de2d15ce3d4a 8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents: 10376
diff changeset
1318 size_t metaspace_size_bytes = MetaspaceSize;
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1319 if (committed_capacity_bytes < metaspace_size_bytes ||
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1320 capacity_until_GC() == 0) {
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1321 set_capacity_until_GC(metaspace_size_bytes);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1322 return true;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1323 } else {
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1324 if (committed_capacity_bytes < capacity_until_GC()) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1325 return true;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1326 } else {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1327 if (TraceMetadataChunkAllocation && Verbose) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1328 gclog_or_tty->print_cr(" allocation request size " SIZE_FORMAT
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1329 " capacity_until_GC " SIZE_FORMAT
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1330 " allocated_capacity_bytes " SIZE_FORMAT,
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1331 word_size,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1332 capacity_until_GC(),
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1333 MetaspaceAux::allocated_capacity_bytes());
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1334 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1335 return false;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1336 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1337 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1338 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1339
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1340
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1341
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1342 void MetaspaceGC::compute_new_size() {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1343 assert(_shrink_factor <= 100, "invalid shrink factor");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1344 uint current_shrink_factor = _shrink_factor;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1345 _shrink_factor = 0;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1346
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1347 // Until a faster way of calculating the "used" quantity is implemented,
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1348 // use "capacity".
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1349 const size_t used_after_gc = MetaspaceAux::allocated_capacity_bytes();
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1350 const size_t capacity_until_GC = MetaspaceGC::capacity_until_GC();
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1351
8040
a83cd101fd62 8005452: NPG: Create new flags for Metaspace resizing policy
jmasa
parents: 8007
diff changeset
1352 const double minimum_free_percentage = MinMetaspaceFreeRatio / 100.0;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1353 const double maximum_used_percentage = 1.0 - minimum_free_percentage;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1354
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1355 const double min_tmp = used_after_gc / maximum_used_percentage;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1356 size_t minimum_desired_capacity =
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1357 (size_t)MIN2(min_tmp, double(max_uintx));
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1358 // Don't shrink less than the initial generation size
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1359 minimum_desired_capacity = MAX2(minimum_desired_capacity,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1360 MetaspaceSize);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1361
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1362 if (PrintGCDetails && Verbose) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1363 gclog_or_tty->print_cr("\nMetaspaceGC::compute_new_size: ");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1364 gclog_or_tty->print_cr(" "
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1365 " minimum_free_percentage: %6.2f"
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1366 " maximum_used_percentage: %6.2f",
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1367 minimum_free_percentage,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1368 maximum_used_percentage);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1369 gclog_or_tty->print_cr(" "
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1370 " used_after_gc : %6.1fKB",
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1371 used_after_gc / (double) K);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1372 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1373
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1374
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1375 size_t shrink_bytes = 0;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1376 if (capacity_until_GC < minimum_desired_capacity) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1377 // If we have less capacity below the metaspace HWM, then
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1378 // increment the HWM.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1379 size_t expand_bytes = minimum_desired_capacity - capacity_until_GC;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1380 // Don't expand unless it's significant
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1381 if (expand_bytes >= MinMetaspaceExpansion) {
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1382 MetaspaceGC::set_capacity_until_GC(capacity_until_GC + expand_bytes);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1383 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1384 if (PrintGCDetails && Verbose) {
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1385 size_t new_capacity_until_GC = capacity_until_GC;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1386 gclog_or_tty->print_cr(" expanding:"
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1387 " minimum_desired_capacity: %6.1fKB"
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1388 " expand_bytes: %6.1fKB"
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1389 " MinMetaspaceExpansion: %6.1fKB"
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1390 " new metaspace HWM: %6.1fKB",
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1391 minimum_desired_capacity / (double) K,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1392 expand_bytes / (double) K,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1393 MinMetaspaceExpansion / (double) K,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1394 new_capacity_until_GC / (double) K);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1395 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1396 return;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1397 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1398
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1399 // No expansion, now see if we want to shrink
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1400 // We would never want to shrink more than this
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1401 size_t max_shrink_bytes = capacity_until_GC - minimum_desired_capacity;
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1402 assert(max_shrink_bytes >= 0, err_msg("max_shrink_bytes " SIZE_FORMAT,
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1403 max_shrink_bytes));
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1404
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1405 // Should shrinking be considered?
8040
a83cd101fd62 8005452: NPG: Create new flags for Metaspace resizing policy
jmasa
parents: 8007
diff changeset
1406 if (MaxMetaspaceFreeRatio < 100) {
a83cd101fd62 8005452: NPG: Create new flags for Metaspace resizing policy
jmasa
parents: 8007
diff changeset
1407 const double maximum_free_percentage = MaxMetaspaceFreeRatio / 100.0;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1408 const double minimum_used_percentage = 1.0 - maximum_free_percentage;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1409 const double max_tmp = used_after_gc / minimum_used_percentage;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1410 size_t maximum_desired_capacity = (size_t)MIN2(max_tmp, double(max_uintx));
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1411 maximum_desired_capacity = MAX2(maximum_desired_capacity,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1412 MetaspaceSize);
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1413 if (PrintGCDetails && Verbose) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1414 gclog_or_tty->print_cr(" "
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1415 " maximum_free_percentage: %6.2f"
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1416 " minimum_used_percentage: %6.2f",
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1417 maximum_free_percentage,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1418 minimum_used_percentage);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1419 gclog_or_tty->print_cr(" "
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1420 " minimum_desired_capacity: %6.1fKB"
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1421 " maximum_desired_capacity: %6.1fKB",
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1422 minimum_desired_capacity / (double) K,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1423 maximum_desired_capacity / (double) K);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1424 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1425
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1426 assert(minimum_desired_capacity <= maximum_desired_capacity,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1427 "sanity check");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1428
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1429 if (capacity_until_GC > maximum_desired_capacity) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1430 // Capacity too large, compute shrinking size
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1431 shrink_bytes = capacity_until_GC - maximum_desired_capacity;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1432 // We don't want shrink all the way back to initSize if people call
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1433 // System.gc(), because some programs do that between "phases" and then
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1434 // we'd just have to grow the heap up again for the next phase. So we
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1435 // damp the shrinking: 0% on the first call, 10% on the second call, 40%
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1436 // on the third call, and 100% by the fourth call. But if we recompute
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1437 // size without shrinking, it goes back to 0%.
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1438 shrink_bytes = shrink_bytes / 100 * current_shrink_factor;
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1439 assert(shrink_bytes <= max_shrink_bytes,
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1440 err_msg("invalid shrink size " SIZE_FORMAT " not <= " SIZE_FORMAT,
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1441 shrink_bytes, max_shrink_bytes));
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1442 if (current_shrink_factor == 0) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1443 _shrink_factor = 10;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1444 } else {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1445 _shrink_factor = MIN2(current_shrink_factor * 4, (uint) 100);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1446 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1447 if (PrintGCDetails && Verbose) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1448 gclog_or_tty->print_cr(" "
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1449 " shrinking:"
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1450 " initSize: %.1fK"
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1451 " maximum_desired_capacity: %.1fK",
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1452 MetaspaceSize / (double) K,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1453 maximum_desired_capacity / (double) K);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1454 gclog_or_tty->print_cr(" "
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1455 " shrink_bytes: %.1fK"
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1456 " current_shrink_factor: %d"
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1457 " new shrink factor: %d"
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1458 " MinMetaspaceExpansion: %.1fK",
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1459 shrink_bytes / (double) K,
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1460 current_shrink_factor,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1461 _shrink_factor,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1462 MinMetaspaceExpansion / (double) K);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1463 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1464 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1465 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1466
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1467 // Don't shrink unless it's significant
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1468 if (shrink_bytes >= MinMetaspaceExpansion &&
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1469 ((capacity_until_GC - shrink_bytes) >= MetaspaceSize)) {
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1470 MetaspaceGC::set_capacity_until_GC(capacity_until_GC - shrink_bytes);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1471 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1472 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1473
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1474 // Metadebug methods
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1475
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1476 void Metadebug::deallocate_chunk_a_lot(SpaceManager* sm,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1477 size_t chunk_word_size){
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1478 #ifdef ASSERT
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1479 VirtualSpaceList* vsl = sm->vs_list();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1480 if (MetaDataDeallocateALot &&
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1481 Metadebug::deallocate_chunk_a_lot_count() % MetaDataDeallocateALotInterval == 0 ) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1482 Metadebug::reset_deallocate_chunk_a_lot_count();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1483 for (uint i = 0; i < metadata_deallocate_a_lock_chunk; i++) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1484 Metachunk* dummy_chunk = vsl->current_virtual_space()->take_from_committed(chunk_word_size);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1485 if (dummy_chunk == NULL) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1486 break;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1487 }
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
1488 sm->chunk_manager()->chunk_freelist_deallocate(dummy_chunk);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1489
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1490 if (TraceMetadataChunkAllocation && Verbose) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1491 gclog_or_tty->print("Metadebug::deallocate_chunk_a_lot: %d) ",
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1492 sm->sum_count_in_chunks_in_use());
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1493 dummy_chunk->print_on(gclog_or_tty);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1494 gclog_or_tty->print_cr(" Free chunks total %d count %d",
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
1495 sm->chunk_manager()->free_chunks_total_words(),
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
1496 sm->chunk_manager()->free_chunks_count());
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1497 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1498 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1499 } else {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1500 Metadebug::inc_deallocate_chunk_a_lot_count();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1501 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1502 #endif
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1503 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1504
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1505 void Metadebug::deallocate_block_a_lot(SpaceManager* sm,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1506 size_t raw_word_size){
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1507 #ifdef ASSERT
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1508 if (MetaDataDeallocateALot &&
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1509 Metadebug::deallocate_block_a_lot_count() % MetaDataDeallocateALotInterval == 0 ) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1510 Metadebug::set_deallocate_block_a_lot_count(0);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1511 for (uint i = 0; i < metadata_deallocate_a_lot_block; i++) {
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
1512 MetaWord* dummy_block = sm->allocate_work(raw_word_size);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1513 if (dummy_block == 0) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1514 break;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1515 }
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
1516 sm->deallocate(dummy_block, raw_word_size);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1517 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1518 } else {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1519 Metadebug::inc_deallocate_block_a_lot_count();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1520 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1521 #endif
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1522 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1523
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1524 void Metadebug::init_allocation_fail_alot_count() {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1525 if (MetadataAllocationFailALot) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1526 _allocation_fail_alot_count =
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1527 1+(long)((double)MetadataAllocationFailALotInterval*os::random()/(max_jint+1.0));
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1528 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1529 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1530
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1531 #ifdef ASSERT
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1532 bool Metadebug::test_metadata_failure() {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1533 if (MetadataAllocationFailALot &&
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1534 Threads::is_vm_complete()) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1535 if (_allocation_fail_alot_count > 0) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1536 _allocation_fail_alot_count--;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1537 } else {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1538 if (TraceMetadataChunkAllocation && Verbose) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1539 gclog_or_tty->print_cr("Metadata allocation failing for "
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1540 "MetadataAllocationFailALot");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1541 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1542 init_allocation_fail_alot_count();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1543 return true;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1544 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1545 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1546 return false;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1547 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1548 #endif
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1549
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1550 // ChunkManager methods
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1551
12235
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
1552 size_t ChunkManager::free_chunks_total_words() {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1553 return _free_chunks_total;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1554 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1555
12235
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
1556 size_t ChunkManager::free_chunks_total_bytes() {
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
1557 return free_chunks_total_words() * BytesPerWord;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1558 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1559
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1560 size_t ChunkManager::free_chunks_count() {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1561 #ifdef ASSERT
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1562 if (!UseConcMarkSweepGC && !SpaceManager::expand_lock()->is_locked()) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1563 MutexLockerEx cl(SpaceManager::expand_lock(),
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1564 Mutex::_no_safepoint_check_flag);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1565 // This lock is only needed in debug because the verification
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1566 // of the _free_chunks_totals walks the list of free chunks
6969
6bc207d87e5d 7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents: 6885
diff changeset
1567 slow_locked_verify_free_chunks_count();
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1568 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1569 #endif
6969
6bc207d87e5d 7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents: 6885
diff changeset
1570 return _free_chunks_count;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1571 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1572
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1573 void ChunkManager::locked_verify_free_chunks_total() {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1574 assert_lock_strong(SpaceManager::expand_lock());
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1575 assert(sum_free_chunks() == _free_chunks_total,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1576 err_msg("_free_chunks_total " SIZE_FORMAT " is not the"
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1577 " same as sum " SIZE_FORMAT, _free_chunks_total,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1578 sum_free_chunks()));
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1579 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1580
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1581 void ChunkManager::verify_free_chunks_total() {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1582 MutexLockerEx cl(SpaceManager::expand_lock(),
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1583 Mutex::_no_safepoint_check_flag);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1584 locked_verify_free_chunks_total();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1585 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1586
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1587 void ChunkManager::locked_verify_free_chunks_count() {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1588 assert_lock_strong(SpaceManager::expand_lock());
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1589 assert(sum_free_chunks_count() == _free_chunks_count,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1590 err_msg("_free_chunks_count " SIZE_FORMAT " is not the"
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1591 " same as sum " SIZE_FORMAT, _free_chunks_count,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1592 sum_free_chunks_count()));
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1593 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1594
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1595 void ChunkManager::verify_free_chunks_count() {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1596 #ifdef ASSERT
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1597 MutexLockerEx cl(SpaceManager::expand_lock(),
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1598 Mutex::_no_safepoint_check_flag);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1599 locked_verify_free_chunks_count();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1600 #endif
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1601 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1602
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1603 void ChunkManager::verify() {
6969
6bc207d87e5d 7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents: 6885
diff changeset
1604 MutexLockerEx cl(SpaceManager::expand_lock(),
6bc207d87e5d 7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents: 6885
diff changeset
1605 Mutex::_no_safepoint_check_flag);
6bc207d87e5d 7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents: 6885
diff changeset
1606 locked_verify();
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1607 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1608
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1609 void ChunkManager::locked_verify() {
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
1610 locked_verify_free_chunks_count();
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1611 locked_verify_free_chunks_total();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1612 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1613
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1614 void ChunkManager::locked_print_free_chunks(outputStream* st) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1615 assert_lock_strong(SpaceManager::expand_lock());
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1616 st->print_cr("Free chunk total " SIZE_FORMAT " count " SIZE_FORMAT,
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1617 _free_chunks_total, _free_chunks_count);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1618 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1619
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1620 void ChunkManager::locked_print_sum_free_chunks(outputStream* st) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1621 assert_lock_strong(SpaceManager::expand_lock());
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1622 st->print_cr("Sum free chunk total " SIZE_FORMAT " count " SIZE_FORMAT,
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1623 sum_free_chunks(), sum_free_chunks_count());
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1624 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1625 ChunkList* ChunkManager::free_chunks(ChunkIndex index) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1626 return &_free_chunks[index];
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1627 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1628
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1629 // These methods that sum the free chunk lists are used in printing
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1630 // methods that are used in product builds.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1631 size_t ChunkManager::sum_free_chunks() {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1632 assert_lock_strong(SpaceManager::expand_lock());
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1633 size_t result = 0;
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1634 for (ChunkIndex i = ZeroIndex; i < NumberOfFreeLists; i = next_chunk_index(i)) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1635 ChunkList* list = free_chunks(i);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1636
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1637 if (list == NULL) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1638 continue;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1639 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1640
10101
df254344edf1 8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents: 8813
diff changeset
1641 result = result + list->count() * list->size();
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1642 }
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
1643 result = result + humongous_dictionary()->total_size();
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1644 return result;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1645 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1646
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1647 size_t ChunkManager::sum_free_chunks_count() {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1648 assert_lock_strong(SpaceManager::expand_lock());
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1649 size_t count = 0;
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1650 for (ChunkIndex i = ZeroIndex; i < NumberOfFreeLists; i = next_chunk_index(i)) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1651 ChunkList* list = free_chunks(i);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1652 if (list == NULL) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1653 continue;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1654 }
10101
df254344edf1 8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents: 8813
diff changeset
1655 count = count + list->count();
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1656 }
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
1657 count = count + humongous_dictionary()->total_free_blocks();
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1658 return count;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1659 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1660
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1661 ChunkList* ChunkManager::find_free_chunks_list(size_t word_size) {
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1662 ChunkIndex index = list_index(word_size);
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1663 assert(index < HumongousIndex, "No humongous list");
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1664 return free_chunks(index);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1665 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1666
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1667 void ChunkManager::free_chunks_put(Metachunk* chunk) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1668 assert_lock_strong(SpaceManager::expand_lock());
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1669 ChunkList* free_list = find_free_chunks_list(chunk->word_size());
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1670 chunk->set_next(free_list->head());
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1671 free_list->set_head(chunk);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1672 // chunk is being returned to the chunk free list
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1673 inc_free_chunks_total(chunk->capacity_word_size());
6969
6bc207d87e5d 7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents: 6885
diff changeset
1674 slow_locked_verify();
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1675 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1676
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1677 void ChunkManager::chunk_freelist_deallocate(Metachunk* chunk) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1678 // The deallocation of a chunk originates in the freelist
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1679 // manangement code for a Metaspace and does not hold the
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1680 // lock.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1681 assert(chunk != NULL, "Deallocating NULL");
6969
6bc207d87e5d 7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents: 6885
diff changeset
1682 assert_lock_strong(SpaceManager::expand_lock());
6bc207d87e5d 7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents: 6885
diff changeset
1683 slow_locked_verify();
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1684 if (TraceMetadataChunkAllocation) {
12240
8c5e6482cbfc 8024752: Log TraceMetadata* output to gclog_or_tty instead of tty
stefank
parents: 12239
diff changeset
1685 gclog_or_tty->print_cr("ChunkManager::chunk_freelist_deallocate: chunk "
8c5e6482cbfc 8024752: Log TraceMetadata* output to gclog_or_tty instead of tty
stefank
parents: 12239
diff changeset
1686 PTR_FORMAT " size " SIZE_FORMAT,
8c5e6482cbfc 8024752: Log TraceMetadata* output to gclog_or_tty instead of tty
stefank
parents: 12239
diff changeset
1687 chunk, chunk->word_size());
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1688 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1689 free_chunks_put(chunk);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1690 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1691
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1692 Metachunk* ChunkManager::free_chunks_get(size_t word_size) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1693 assert_lock_strong(SpaceManager::expand_lock());
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1694
6969
6bc207d87e5d 7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents: 6885
diff changeset
1695 slow_locked_verify();
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
1696
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
1697 Metachunk* chunk = NULL;
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1698 if (list_index(word_size) != HumongousIndex) {
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
1699 ChunkList* free_list = find_free_chunks_list(word_size);
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
1700 assert(free_list != NULL, "Sanity check");
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
1701
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
1702 chunk = free_list->head();
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
1703 debug_only(Metachunk* debug_head = chunk;)
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
1704
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
1705 if (chunk == NULL) {
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
1706 return NULL;
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
1707 }
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
1708
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1709 // Remove the chunk as the head of the list.
10101
df254344edf1 8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents: 8813
diff changeset
1710 free_list->remove_chunk(chunk);
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1711
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1712 // Chunk is being removed from the chunks free list.
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
1713 dec_free_chunks_total(chunk->capacity_word_size());
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1714
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1715 if (TraceMetadataChunkAllocation && Verbose) {
12240
8c5e6482cbfc 8024752: Log TraceMetadata* output to gclog_or_tty instead of tty
stefank
parents: 12239
diff changeset
1716 gclog_or_tty->print_cr("ChunkManager::free_chunks_get: free_list "
8c5e6482cbfc 8024752: Log TraceMetadata* output to gclog_or_tty instead of tty
stefank
parents: 12239
diff changeset
1717 PTR_FORMAT " head " PTR_FORMAT " size " SIZE_FORMAT,
8c5e6482cbfc 8024752: Log TraceMetadata* output to gclog_or_tty instead of tty
stefank
parents: 12239
diff changeset
1718 free_list, chunk, chunk->word_size());
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1719 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1720 } else {
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
1721 chunk = humongous_dictionary()->get_chunk(
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
1722 word_size,
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
1723 FreeBlockDictionary<Metachunk>::atLeast);
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
1724
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
1725 if (chunk != NULL) {
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
1726 if (TraceMetadataHumongousAllocation) {
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
1727 size_t waste = chunk->word_size() - word_size;
12240
8c5e6482cbfc 8024752: Log TraceMetadata* output to gclog_or_tty instead of tty
stefank
parents: 12239
diff changeset
1728 gclog_or_tty->print_cr("Free list allocate humongous chunk size "
8c5e6482cbfc 8024752: Log TraceMetadata* output to gclog_or_tty instead of tty
stefank
parents: 12239
diff changeset
1729 SIZE_FORMAT " for requested size " SIZE_FORMAT
8c5e6482cbfc 8024752: Log TraceMetadata* output to gclog_or_tty instead of tty
stefank
parents: 12239
diff changeset
1730 " waste " SIZE_FORMAT,
8c5e6482cbfc 8024752: Log TraceMetadata* output to gclog_or_tty instead of tty
stefank
parents: 12239
diff changeset
1731 chunk->word_size(), word_size, waste);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1732 }
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
1733 // Chunk is being removed from the chunks free list.
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
1734 dec_free_chunks_total(chunk->capacity_word_size());
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1735 } else {
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1736 return NULL;
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
1737 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1738 }
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1739
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1740 // Remove it from the links to this freelist
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1741 chunk->set_next(NULL);
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1742 chunk->set_prev(NULL);
10175
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1743 #ifdef ASSERT
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1744 // Chunk is no longer on any freelist. Setting to false make container_count_slow()
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1745 // work.
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1746 chunk->set_is_free(false);
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
1747 #endif
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
1748 chunk->container()->inc_container_count();
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
1749
6969
6bc207d87e5d 7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents: 6885
diff changeset
1750 slow_locked_verify();
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1751 return chunk;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1752 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1753
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1754 Metachunk* ChunkManager::chunk_freelist_allocate(size_t word_size) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1755 assert_lock_strong(SpaceManager::expand_lock());
6969
6bc207d87e5d 7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents: 6885
diff changeset
1756 slow_locked_verify();
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1757
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1758 // Take from the beginning of the list
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1759 Metachunk* chunk = free_chunks_get(word_size);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1760 if (chunk == NULL) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1761 return NULL;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1762 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1763
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1764 assert((word_size <= chunk->word_size()) ||
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1765 list_index(chunk->word_size() == HumongousIndex),
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1766 "Non-humongous variable sized chunk");
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1767 if (TraceMetadataChunkAllocation) {
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1768 size_t list_count;
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1769 if (list_index(word_size) < HumongousIndex) {
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1770 ChunkList* list = find_free_chunks_list(word_size);
10101
df254344edf1 8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents: 8813
diff changeset
1771 list_count = list->count();
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1772 } else {
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1773 list_count = humongous_dictionary()->total_count();
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1774 }
12240
8c5e6482cbfc 8024752: Log TraceMetadata* output to gclog_or_tty instead of tty
stefank
parents: 12239
diff changeset
1775 gclog_or_tty->print("ChunkManager::chunk_freelist_allocate: " PTR_FORMAT " chunk "
8c5e6482cbfc 8024752: Log TraceMetadata* output to gclog_or_tty instead of tty
stefank
parents: 12239
diff changeset
1776 PTR_FORMAT " size " SIZE_FORMAT " count " SIZE_FORMAT " ",
8c5e6482cbfc 8024752: Log TraceMetadata* output to gclog_or_tty instead of tty
stefank
parents: 12239
diff changeset
1777 this, chunk, chunk->word_size(), list_count);
8c5e6482cbfc 8024752: Log TraceMetadata* output to gclog_or_tty instead of tty
stefank
parents: 12239
diff changeset
1778 locked_print_free_chunks(gclog_or_tty);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1779 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1780
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1781 return chunk;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1782 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1783
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
1784 void ChunkManager::print_on(outputStream* out) const {
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
1785 if (PrintFLSStatistics != 0) {
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
1786 const_cast<ChunkManager *>(this)->humongous_dictionary()->report_statistics();
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
1787 }
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
1788 }
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
1789
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1790 // SpaceManager methods
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1791
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1792 void SpaceManager::get_initial_chunk_sizes(Metaspace::MetaspaceType type,
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1793 size_t* chunk_word_size,
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1794 size_t* class_chunk_word_size) {
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1795 switch (type) {
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1796 case Metaspace::BootMetaspaceType:
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1797 *chunk_word_size = Metaspace::first_chunk_word_size();
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1798 *class_chunk_word_size = Metaspace::first_class_chunk_word_size();
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1799 break;
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1800 case Metaspace::ROMetaspaceType:
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1801 *chunk_word_size = SharedReadOnlySize / wordSize;
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1802 *class_chunk_word_size = ClassSpecializedChunk;
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1803 break;
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1804 case Metaspace::ReadWriteMetaspaceType:
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1805 *chunk_word_size = SharedReadWriteSize / wordSize;
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1806 *class_chunk_word_size = ClassSpecializedChunk;
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1807 break;
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1808 case Metaspace::AnonymousMetaspaceType:
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1809 case Metaspace::ReflectionMetaspaceType:
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1810 *chunk_word_size = SpecializedChunk;
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1811 *class_chunk_word_size = ClassSpecializedChunk;
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1812 break;
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1813 default:
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1814 *chunk_word_size = SmallChunk;
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1815 *class_chunk_word_size = ClassSmallChunk;
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1816 break;
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1817 }
8007
d9058e388631 8007257: NPG: metaspace.cpp: Incorrect arguments in calls to err_msg
mikael
parents: 7447
diff changeset
1818 assert(*chunk_word_size != 0 && *class_chunk_word_size != 0,
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1819 err_msg("Initial chunks sizes bad: data " SIZE_FORMAT
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1820 " class " SIZE_FORMAT,
8007
d9058e388631 8007257: NPG: metaspace.cpp: Incorrect arguments in calls to err_msg
mikael
parents: 7447
diff changeset
1821 *chunk_word_size, *class_chunk_word_size));
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1822 }
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1823
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1824 size_t SpaceManager::sum_free_in_chunks_in_use() const {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1825 MutexLockerEx cl(lock(), Mutex::_no_safepoint_check_flag);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1826 size_t free = 0;
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1827 for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1828 Metachunk* chunk = chunks_in_use(i);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1829 while (chunk != NULL) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1830 free += chunk->free_word_size();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1831 chunk = chunk->next();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1832 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1833 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1834 return free;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1835 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1836
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1837 size_t SpaceManager::sum_waste_in_chunks_in_use() const {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1838 MutexLockerEx cl(lock(), Mutex::_no_safepoint_check_flag);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1839 size_t result = 0;
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1840 for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1841 result += sum_waste_in_chunks_in_use(i);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1842 }
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
1843
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1844 return result;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1845 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1846
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1847 size_t SpaceManager::sum_waste_in_chunks_in_use(ChunkIndex index) const {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1848 size_t result = 0;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1849 Metachunk* chunk = chunks_in_use(index);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1850 // Count the free space in all the chunk but not the
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1851 // current chunk from which allocations are still being done.
11064
de2d15ce3d4a 8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents: 10376
diff changeset
1852 while (chunk != NULL) {
de2d15ce3d4a 8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents: 10376
diff changeset
1853 if (chunk != current_chunk()) {
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
1854 result += chunk->free_word_size();
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1855 }
11064
de2d15ce3d4a 8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents: 10376
diff changeset
1856 chunk = chunk->next();
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1857 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1858 return result;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1859 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1860
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1861 size_t SpaceManager::sum_capacity_in_chunks_in_use() const {
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1862 // For CMS use "allocated_chunks_words()" which does not need the
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1863 // Metaspace lock. For the other collectors sum over the
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1864 // lists. Use both methods as a check that "allocated_chunks_words()"
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1865 // is correct. That is, sum_capacity_in_chunks() is too expensive
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1866 // to use in the product and allocated_chunks_words() should be used
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1867 // but allow for checking that allocated_chunks_words() returns the same
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1868 // value as sum_capacity_in_chunks_in_use() which is the definitive
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1869 // answer.
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1870 if (UseConcMarkSweepGC) {
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1871 return allocated_chunks_words();
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1872 } else {
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1873 MutexLockerEx cl(lock(), Mutex::_no_safepoint_check_flag);
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1874 size_t sum = 0;
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1875 for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) {
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1876 Metachunk* chunk = chunks_in_use(i);
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1877 while (chunk != NULL) {
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1878 sum += chunk->capacity_word_size();
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1879 chunk = chunk->next();
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1880 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1881 }
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
1882 return sum;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1883 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1884 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1885
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1886 size_t SpaceManager::sum_count_in_chunks_in_use() {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1887 size_t count = 0;
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1888 for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1889 count = count + sum_count_in_chunks_in_use(i);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1890 }
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
1891
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1892 return count;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1893 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1894
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1895 size_t SpaceManager::sum_count_in_chunks_in_use(ChunkIndex i) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1896 size_t count = 0;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1897 Metachunk* chunk = chunks_in_use(i);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1898 while (chunk != NULL) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1899 count++;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1900 chunk = chunk->next();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1901 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1902 return count;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1903 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1904
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1905
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1906 size_t SpaceManager::sum_used_in_chunks_in_use() const {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1907 MutexLockerEx cl(lock(), Mutex::_no_safepoint_check_flag);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1908 size_t used = 0;
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1909 for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1910 Metachunk* chunk = chunks_in_use(i);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1911 while (chunk != NULL) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1912 used += chunk->used_word_size();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1913 chunk = chunk->next();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1914 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1915 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1916 return used;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1917 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1918
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1919 void SpaceManager::locked_print_chunks_in_use_on(outputStream* st) const {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1920
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1921 for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) {
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1922 Metachunk* chunk = chunks_in_use(i);
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1923 st->print("SpaceManager: %s " PTR_FORMAT,
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1924 chunk_size_name(i), chunk);
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1925 if (chunk != NULL) {
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1926 st->print_cr(" free " SIZE_FORMAT,
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1927 chunk->free_word_size());
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1928 } else {
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1929 st->print_cr("");
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1930 }
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1931 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1932
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
1933 chunk_manager()->locked_print_free_chunks(st);
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
1934 chunk_manager()->locked_print_sum_free_chunks(st);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1935 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1936
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1937 size_t SpaceManager::calc_chunk_size(size_t word_size) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1938
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1939 // Decide between a small chunk and a medium chunk. Up to
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1940 // _small_chunk_limit small chunks can be allocated but
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1941 // once a medium chunk has been allocated, no more small
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1942 // chunks will be allocated.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1943 size_t chunk_word_size;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1944 if (chunks_in_use(MediumIndex) == NULL &&
11064
de2d15ce3d4a 8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents: 10376
diff changeset
1945 sum_count_in_chunks_in_use(SmallIndex) < _small_chunk_limit) {
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1946 chunk_word_size = (size_t) small_chunk_size();
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1947 if (word_size + Metachunk::overhead() > small_chunk_size()) {
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1948 chunk_word_size = medium_chunk_size();
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1949 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1950 } else {
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1951 chunk_word_size = medium_chunk_size();
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1952 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1953
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1954 // Might still need a humongous chunk. Enforce an
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1955 // eight word granularity to facilitate reuse (some
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1956 // wastage but better chance of reuse).
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1957 size_t if_humongous_sized_chunk =
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1958 align_size_up(word_size + Metachunk::overhead(),
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1959 HumongousChunkGranularity);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1960 chunk_word_size =
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1961 MAX2((size_t) chunk_word_size, if_humongous_sized_chunk);
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1962
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1963 assert(!SpaceManager::is_humongous(word_size) ||
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1964 chunk_word_size == if_humongous_sized_chunk,
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1965 err_msg("Size calculation is wrong, word_size " SIZE_FORMAT
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1966 " chunk_word_size " SIZE_FORMAT,
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1967 word_size, chunk_word_size));
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1968 if (TraceMetadataHumongousAllocation &&
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1969 SpaceManager::is_humongous(word_size)) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1970 gclog_or_tty->print_cr("Metadata humongous allocation:");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1971 gclog_or_tty->print_cr(" word_size " PTR_FORMAT, word_size);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1972 gclog_or_tty->print_cr(" chunk_word_size " PTR_FORMAT,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1973 chunk_word_size);
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
1974 gclog_or_tty->print_cr(" chunk overhead " PTR_FORMAT,
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1975 Metachunk::overhead());
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1976 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1977 return chunk_word_size;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1978 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1979
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
1980 MetaWord* SpaceManager::grow_and_allocate(size_t word_size) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1981 assert(vs_list()->current_virtual_space() != NULL,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1982 "Should have been set");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1983 assert(current_chunk() == NULL ||
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1984 current_chunk()->allocate(word_size) == NULL,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1985 "Don't need to expand");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1986 MutexLockerEx cl(SpaceManager::expand_lock(), Mutex::_no_safepoint_check_flag);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1987
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1988 if (TraceMetadataChunkAllocation && Verbose) {
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1989 size_t words_left = 0;
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1990 size_t words_used = 0;
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1991 if (current_chunk() != NULL) {
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1992 words_left = current_chunk()->free_word_size();
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1993 words_used = current_chunk()->used_word_size();
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1994 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1995 gclog_or_tty->print_cr("SpaceManager::grow_and_allocate for " SIZE_FORMAT
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1996 " words " SIZE_FORMAT " words used " SIZE_FORMAT
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1997 " words left",
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
1998 word_size, words_used, words_left);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
1999 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2000
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2001 // Get another chunk out of the virtual space
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2002 size_t grow_chunks_by_words = calc_chunk_size(word_size);
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2003 Metachunk* next = get_new_chunk(word_size, grow_chunks_by_words);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2004
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2005 // If a chunk was available, add it to the in-use chunk list
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2006 // and do an allocation from it.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2007 if (next != NULL) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2008 Metadebug::deallocate_chunk_a_lot(this, grow_chunks_by_words);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2009 // Add to this manager's list of chunks in use.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2010 add_chunk(next, false);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2011 return next->allocate(word_size);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2012 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2013 return NULL;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2014 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2015
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2016 void SpaceManager::print_on(outputStream* st) const {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2017
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2018 for (ChunkIndex i = ZeroIndex;
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
2019 i < NumberOfInUseLists ;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2020 i = next_chunk_index(i) ) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2021 st->print_cr(" chunks_in_use " PTR_FORMAT " chunk size " PTR_FORMAT,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2022 chunks_in_use(i),
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2023 chunks_in_use(i) == NULL ? 0 : chunks_in_use(i)->word_size());
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2024 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2025 st->print_cr(" waste: Small " SIZE_FORMAT " Medium " SIZE_FORMAT
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2026 " Humongous " SIZE_FORMAT,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2027 sum_waste_in_chunks_in_use(SmallIndex),
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2028 sum_waste_in_chunks_in_use(MediumIndex),
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2029 sum_waste_in_chunks_in_use(HumongousIndex));
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
2030 // block free lists
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
2031 if (block_freelists() != NULL) {
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
2032 st->print_cr("total in block free lists " SIZE_FORMAT,
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
2033 block_freelists()->total_size());
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
2034 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2035 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2036
10330
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2037 SpaceManager::SpaceManager(Metaspace::MetadataType mdtype,
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
2038 Mutex* lock) :
10330
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2039 _mdtype(mdtype),
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2040 _allocated_blocks_words(0),
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2041 _allocated_chunks_words(0),
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2042 _allocated_chunks_count(0),
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2043 _lock(lock)
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2044 {
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2045 initialize();
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2046 }
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2047
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2048 void SpaceManager::inc_size_metrics(size_t words) {
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2049 assert_lock_strong(SpaceManager::expand_lock());
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2050 // Total of allocated Metachunks and allocated Metachunks count
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2051 // for each SpaceManager
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2052 _allocated_chunks_words = _allocated_chunks_words + words;
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2053 _allocated_chunks_count++;
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2054 // Global total of capacity in allocated Metachunks
10330
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2055 MetaspaceAux::inc_capacity(mdtype(), words);
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2056 // Global total of allocated Metablocks.
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2057 // used_words_slow() includes the overhead in each
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2058 // Metachunk so include it in the used when the
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2059 // Metachunk is first added (so only added once per
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2060 // Metachunk).
10330
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2061 MetaspaceAux::inc_used(mdtype(), Metachunk::overhead());
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2062 }
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2063
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2064 void SpaceManager::inc_used_metrics(size_t words) {
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2065 // Add to the per SpaceManager total
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2066 Atomic::add_ptr(words, &_allocated_blocks_words);
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2067 // Add to the global total
10330
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2068 MetaspaceAux::inc_used(mdtype(), words);
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2069 }
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2070
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2071 void SpaceManager::dec_total_from_size_metrics() {
10330
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2072 MetaspaceAux::dec_capacity(mdtype(), allocated_chunks_words());
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2073 MetaspaceAux::dec_used(mdtype(), allocated_blocks_words());
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2074 // Also deduct the overhead per Metachunk
10330
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2075 MetaspaceAux::dec_used(mdtype(), allocated_chunks_count() * Metachunk::overhead());
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2076 }
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2077
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2078 void SpaceManager::initialize() {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2079 Metadebug::init_allocation_fail_alot_count();
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2080 for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2081 _chunks_in_use[i] = NULL;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2082 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2083 _current_chunk = NULL;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2084 if (TraceMetadataChunkAllocation && Verbose) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2085 gclog_or_tty->print_cr("SpaceManager(): " PTR_FORMAT, this);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2086 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2087 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2088
10101
df254344edf1 8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents: 8813
diff changeset
2089 void ChunkManager::return_chunks(ChunkIndex index, Metachunk* chunks) {
df254344edf1 8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents: 8813
diff changeset
2090 if (chunks == NULL) {
df254344edf1 8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents: 8813
diff changeset
2091 return;
df254344edf1 8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents: 8813
diff changeset
2092 }
df254344edf1 8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents: 8813
diff changeset
2093 ChunkList* list = free_chunks(index);
df254344edf1 8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents: 8813
diff changeset
2094 assert(list->size() == chunks->word_size(), "Mismatch in chunk sizes");
df254344edf1 8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents: 8813
diff changeset
2095 assert_lock_strong(SpaceManager::expand_lock());
df254344edf1 8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents: 8813
diff changeset
2096 Metachunk* cur = chunks;
df254344edf1 8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents: 8813
diff changeset
2097
10175
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
2098 // This returns chunks one at a time. If a new
10101
df254344edf1 8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents: 8813
diff changeset
2099 // class List can be created that is a base class
df254344edf1 8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents: 8813
diff changeset
2100 // of FreeList then something like FreeList::prepend()
df254344edf1 8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents: 8813
diff changeset
2101 // can be used in place of this loop
df254344edf1 8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents: 8813
diff changeset
2102 while (cur != NULL) {
10175
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
2103 assert(cur->container() != NULL, "Container should have been set");
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
2104 cur->container()->dec_container_count();
10101
df254344edf1 8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents: 8813
diff changeset
2105 // Capture the next link before it is changed
df254344edf1 8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents: 8813
diff changeset
2106 // by the call to return_chunk_at_head();
df254344edf1 8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents: 8813
diff changeset
2107 Metachunk* next = cur->next();
df254344edf1 8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents: 8813
diff changeset
2108 cur->set_is_free(true);
df254344edf1 8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents: 8813
diff changeset
2109 list->return_chunk_at_head(cur);
df254344edf1 8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents: 8813
diff changeset
2110 cur = next;
df254344edf1 8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents: 8813
diff changeset
2111 }
df254344edf1 8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents: 8813
diff changeset
2112 }
df254344edf1 8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents: 8813
diff changeset
2113
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2114 SpaceManager::~SpaceManager() {
8784
79af1312fc2c 8005602: NPG: classunloading does not happen while CMS GC with -XX:+CMSClassUnloadingEnabled is used
mgerdin
parents: 8738
diff changeset
2115 // This call this->_lock which can't be done while holding expand_lock()
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2116 assert(sum_capacity_in_chunks_in_use() == allocated_chunks_words(),
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2117 err_msg("sum_capacity_in_chunks_in_use() " SIZE_FORMAT
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2118 " allocated_chunks_words() " SIZE_FORMAT,
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2119 sum_capacity_in_chunks_in_use(), allocated_chunks_words()));
8784
79af1312fc2c 8005602: NPG: classunloading does not happen while CMS GC with -XX:+CMSClassUnloadingEnabled is used
mgerdin
parents: 8738
diff changeset
2120
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2121 MutexLockerEx fcl(SpaceManager::expand_lock(),
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2122 Mutex::_no_safepoint_check_flag);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2123
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
2124 chunk_manager()->slow_locked_verify();
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2125
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2126 dec_total_from_size_metrics();
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2127
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2128 if (TraceMetadataChunkAllocation && Verbose) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2129 gclog_or_tty->print_cr("~SpaceManager(): " PTR_FORMAT, this);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2130 locked_print_chunks_in_use_on(gclog_or_tty);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2131 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2132
10175
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
2133 // Do not mangle freed Metachunks. The chunk size inside Metachunks
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
2134 // is during the freeing of a VirtualSpaceNodes.
7185
90273fc0a981 8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents: 6969
diff changeset
2135
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2136 // Have to update before the chunks_in_use lists are emptied
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2137 // below.
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
2138 chunk_manager()->inc_free_chunks_total(allocated_chunks_words(),
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
2139 sum_count_in_chunks_in_use());
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2140
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2141 // Add all the chunks in use by this space manager
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2142 // to the global list of free chunks.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2143
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2144 // Follow each list of chunks-in-use and add them to the
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2145 // free lists. Each list is NULL terminated.
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2146
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2147 for (ChunkIndex i = ZeroIndex; i < HumongousIndex; i = next_chunk_index(i)) {
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2148 if (TraceMetadataChunkAllocation && Verbose) {
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2149 gclog_or_tty->print_cr("returned %d %s chunks to freelist",
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2150 sum_count_in_chunks_in_use(i),
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2151 chunk_size_name(i));
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2152 }
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2153 Metachunk* chunks = chunks_in_use(i);
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
2154 chunk_manager()->return_chunks(i, chunks);
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2155 set_chunks_in_use(i, NULL);
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2156 if (TraceMetadataChunkAllocation && Verbose) {
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2157 gclog_or_tty->print_cr("updated freelist count %d %s",
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
2158 chunk_manager()->free_chunks(i)->count(),
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2159 chunk_size_name(i));
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2160 }
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2161 assert(i != HumongousIndex, "Humongous chunks are handled explicitly later");
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2162 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2163
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2164 // The medium chunk case may be optimized by passing the head and
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2165 // tail of the medium chunk list to add_at_head(). The tail is often
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2166 // the current chunk but there are probably exceptions.
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2167
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2168 // Humongous chunks
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2169 if (TraceMetadataChunkAllocation && Verbose) {
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2170 gclog_or_tty->print_cr("returned %d %s humongous chunks to dictionary",
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2171 sum_count_in_chunks_in_use(HumongousIndex),
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2172 chunk_size_name(HumongousIndex));
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2173 gclog_or_tty->print("Humongous chunk dictionary: ");
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2174 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2175 // Humongous chunks are never the current chunk.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2176 Metachunk* humongous_chunks = chunks_in_use(HumongousIndex);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2177
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
2178 while (humongous_chunks != NULL) {
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
2179 #ifdef ASSERT
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
2180 humongous_chunks->set_is_free(true);
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
2181 #endif
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2182 if (TraceMetadataChunkAllocation && Verbose) {
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2183 gclog_or_tty->print(PTR_FORMAT " (" SIZE_FORMAT ") ",
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2184 humongous_chunks,
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2185 humongous_chunks->word_size());
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2186 }
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2187 assert(humongous_chunks->word_size() == (size_t)
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2188 align_size_up(humongous_chunks->word_size(),
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2189 HumongousChunkGranularity),
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2190 err_msg("Humongous chunk size is wrong: word size " SIZE_FORMAT
8007
d9058e388631 8007257: NPG: metaspace.cpp: Incorrect arguments in calls to err_msg
mikael
parents: 7447
diff changeset
2191 " granularity %d",
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2192 humongous_chunks->word_size(), HumongousChunkGranularity));
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
2193 Metachunk* next_humongous_chunks = humongous_chunks->next();
10175
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
2194 humongous_chunks->container()->dec_container_count();
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
2195 chunk_manager()->humongous_dictionary()->return_chunk(humongous_chunks);
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
2196 humongous_chunks = next_humongous_chunks;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2197 }
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2198 if (TraceMetadataChunkAllocation && Verbose) {
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2199 gclog_or_tty->print_cr("");
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2200 gclog_or_tty->print_cr("updated dictionary count %d %s",
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
2201 chunk_manager()->humongous_dictionary()->total_count(),
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2202 chunk_size_name(HumongousIndex));
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2203 }
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
2204 chunk_manager()->slow_locked_verify();
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2205 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2206
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2207 const char* SpaceManager::chunk_size_name(ChunkIndex index) const {
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2208 switch (index) {
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2209 case SpecializedIndex:
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2210 return "Specialized";
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2211 case SmallIndex:
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2212 return "Small";
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2213 case MediumIndex:
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2214 return "Medium";
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2215 case HumongousIndex:
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2216 return "Humongous";
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2217 default:
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2218 return NULL;
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2219 }
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2220 }
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2221
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2222 ChunkIndex ChunkManager::list_index(size_t size) {
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2223 switch (size) {
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2224 case SpecializedChunk:
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2225 assert(SpecializedChunk == ClassSpecializedChunk,
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2226 "Need branch for ClassSpecializedChunk");
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2227 return SpecializedIndex;
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2228 case SmallChunk:
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2229 case ClassSmallChunk:
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2230 return SmallIndex;
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2231 case MediumChunk:
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2232 case ClassMediumChunk:
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2233 return MediumIndex;
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2234 default:
7447
1de1b145f6bc 8005486: NPG: Incorrect assertion in ChunkManager::list_index()
jmasa
parents: 7446
diff changeset
2235 assert(size > MediumChunk || size > ClassMediumChunk,
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2236 "Not a humongous chunk");
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2237 return HumongousIndex;
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2238 }
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2239 }
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2240
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
2241 void SpaceManager::deallocate(MetaWord* p, size_t word_size) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2242 assert_lock_strong(_lock);
11966
83ca9dc4564d 8019845: Memory leak during class redefinition
fparain
parents: 11065
diff changeset
2243 size_t raw_word_size = get_raw_word_size(word_size);
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
2244 size_t min_size = TreeChunk<Metablock, FreeList>::min_size();
11966
83ca9dc4564d 8019845: Memory leak during class redefinition
fparain
parents: 11065
diff changeset
2245 assert(raw_word_size >= min_size,
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2246 err_msg("Should not deallocate dark matter " SIZE_FORMAT "<" SIZE_FORMAT, word_size, min_size));
11966
83ca9dc4564d 8019845: Memory leak during class redefinition
fparain
parents: 11065
diff changeset
2247 block_freelists()->return_block(p, raw_word_size);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2248 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2249
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2250 // Adds a chunk to the list of chunks in use.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2251 void SpaceManager::add_chunk(Metachunk* new_chunk, bool make_current) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2252
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2253 assert(new_chunk != NULL, "Should not be NULL");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2254 assert(new_chunk->next() == NULL, "Should not be on a list");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2255
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2256 new_chunk->reset_empty();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2257
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2258 // Find the correct list and and set the current
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2259 // chunk for that list.
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2260 ChunkIndex index = ChunkManager::list_index(new_chunk->word_size());
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2261
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2262 if (index != HumongousIndex) {
12231
24e87613ee58 8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents: 12226
diff changeset
2263 retire_current_chunk();
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2264 set_current_chunk(new_chunk);
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2265 new_chunk->set_next(chunks_in_use(index));
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2266 set_chunks_in_use(index, new_chunk);
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2267 } else {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2268 // For null class loader data and DumpSharedSpaces, the first chunk isn't
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2269 // small, so small will be null. Link this first chunk as the current
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2270 // chunk.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2271 if (make_current) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2272 // Set as the current chunk but otherwise treat as a humongous chunk.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2273 set_current_chunk(new_chunk);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2274 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2275 // Link at head. The _current_chunk only points to a humongous chunk for
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2276 // the null class loader metaspace (class and data virtual space managers)
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2277 // any humongous chunks so will not point to the tail
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2278 // of the humongous chunks list.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2279 new_chunk->set_next(chunks_in_use(HumongousIndex));
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2280 set_chunks_in_use(HumongousIndex, new_chunk);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2281
7447
1de1b145f6bc 8005486: NPG: Incorrect assertion in ChunkManager::list_index()
jmasa
parents: 7446
diff changeset
2282 assert(new_chunk->word_size() > medium_chunk_size(), "List inconsistency");
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2283 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2284
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2285 // Add to the running sum of capacity
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2286 inc_size_metrics(new_chunk->word_size());
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2287
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2288 assert(new_chunk->is_empty(), "Not ready for reuse");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2289 if (TraceMetadataChunkAllocation && Verbose) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2290 gclog_or_tty->print("SpaceManager::add_chunk: %d) ",
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2291 sum_count_in_chunks_in_use());
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2292 new_chunk->print_on(gclog_or_tty);
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
2293 chunk_manager()->locked_print_free_chunks(gclog_or_tty);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2294 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2295 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2296
12231
24e87613ee58 8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents: 12226
diff changeset
2297 void SpaceManager::retire_current_chunk() {
24e87613ee58 8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents: 12226
diff changeset
2298 if (current_chunk() != NULL) {
24e87613ee58 8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents: 12226
diff changeset
2299 size_t remaining_words = current_chunk()->free_word_size();
24e87613ee58 8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents: 12226
diff changeset
2300 if (remaining_words >= TreeChunk<Metablock, FreeList>::min_size()) {
24e87613ee58 8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents: 12226
diff changeset
2301 block_freelists()->return_block(current_chunk()->allocate(remaining_words), remaining_words);
24e87613ee58 8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents: 12226
diff changeset
2302 inc_used_metrics(remaining_words);
24e87613ee58 8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents: 12226
diff changeset
2303 }
24e87613ee58 8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents: 12226
diff changeset
2304 }
24e87613ee58 8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents: 12226
diff changeset
2305 }
24e87613ee58 8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents: 12226
diff changeset
2306
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2307 Metachunk* SpaceManager::get_new_chunk(size_t word_size,
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2308 size_t grow_chunks_by_words) {
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
2309 // Get a chunk from the chunk freelist
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
2310 Metachunk* next = chunk_manager()->chunk_freelist_allocate(grow_chunks_by_words);
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
2311
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
2312 if (next == NULL) {
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
2313 next = vs_list()->get_new_chunk(word_size,
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
2314 grow_chunks_by_words,
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
2315 medium_chunk_bunch());
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
2316 }
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2317
12239
8227700da288 8024751: Fix bugs in TraceMetadata
stefank
parents: 12237
diff changeset
2318 if (TraceMetadataHumongousAllocation && next != NULL &&
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2319 SpaceManager::is_humongous(next->word_size())) {
12239
8227700da288 8024751: Fix bugs in TraceMetadata
stefank
parents: 12237
diff changeset
2320 gclog_or_tty->print_cr(" new humongous chunk word size "
8227700da288 8024751: Fix bugs in TraceMetadata
stefank
parents: 12237
diff changeset
2321 PTR_FORMAT, next->word_size());
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2322 }
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2323
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2324 return next;
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2325 }
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2326
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2327 MetaWord* SpaceManager::allocate(size_t word_size) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2328 MutexLockerEx cl(lock(), Mutex::_no_safepoint_check_flag);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2329
10376
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
2330 size_t raw_word_size = get_raw_word_size(word_size);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2331 BlockFreelist* fl = block_freelists();
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
2332 MetaWord* p = NULL;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2333 // Allocation from the dictionary is expensive in the sense that
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2334 // the dictionary has to be searched for a size. Don't allocate
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2335 // from the dictionary until it starts to get fat. Is this
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2336 // a reasonable policy? Maybe an skinny dictionary is fast enough
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2337 // for allocations. Do some profiling. JJJ
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
2338 if (fl->total_size() > allocation_from_dictionary_limit) {
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
2339 p = fl->get_block(raw_word_size);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2340 }
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
2341 if (p == NULL) {
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
2342 p = allocate_work(raw_word_size);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2343 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2344 Metadebug::deallocate_block_a_lot(this, raw_word_size);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2345
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
2346 return p;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2347 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2348
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2349 // Returns the address of spaced allocated for "word_size".
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2350 // This methods does not know about blocks (Metablocks)
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
2351 MetaWord* SpaceManager::allocate_work(size_t word_size) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2352 assert_lock_strong(_lock);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2353 #ifdef ASSERT
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2354 if (Metadebug::test_metadata_failure()) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2355 return NULL;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2356 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2357 #endif
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2358 // Is there space in the current chunk?
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
2359 MetaWord* result = NULL;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2360
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2361 // For DumpSharedSpaces, only allocate out of the current chunk which is
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2362 // never null because we gave it the size we wanted. Caller reports out
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2363 // of memory if this returns null.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2364 if (DumpSharedSpaces) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2365 assert(current_chunk() != NULL, "should never happen");
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2366 inc_used_metrics(word_size);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2367 return current_chunk()->allocate(word_size); // caller handles null result
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2368 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2369 if (current_chunk() != NULL) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2370 result = current_chunk()->allocate(word_size);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2371 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2372
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2373 if (result == NULL) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2374 result = grow_and_allocate(word_size);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2375 }
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2376 if (result != 0) {
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2377 inc_used_metrics(word_size);
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
2378 assert(result != (MetaWord*) chunks_in_use(MediumIndex),
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
2379 "Head of the list is being allocated");
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2380 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2381
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2382 return result;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2383 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2384
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2385 void SpaceManager::verify() {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2386 // If there are blocks in the dictionary, then
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2387 // verfication of chunks does not work since
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2388 // being in the dictionary alters a chunk.
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
2389 if (block_freelists()->total_size() == 0) {
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2390 for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2391 Metachunk* curr = chunks_in_use(i);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2392 while (curr != NULL) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2393 curr->verify();
7208
eade6b2e4782 8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents: 7187
diff changeset
2394 verify_chunk_size(curr);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2395 curr = curr->next();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2396 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2397 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2398 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2399 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2400
7208
eade6b2e4782 8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents: 7187
diff changeset
2401 void SpaceManager::verify_chunk_size(Metachunk* chunk) {
eade6b2e4782 8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents: 7187
diff changeset
2402 assert(is_humongous(chunk->word_size()) ||
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2403 chunk->word_size() == medium_chunk_size() ||
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2404 chunk->word_size() == small_chunk_size() ||
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2405 chunk->word_size() == specialized_chunk_size(),
7208
eade6b2e4782 8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents: 7187
diff changeset
2406 "Chunk size is wrong");
eade6b2e4782 8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents: 7187
diff changeset
2407 return;
eade6b2e4782 8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents: 7187
diff changeset
2408 }
eade6b2e4782 8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents: 7187
diff changeset
2409
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2410 #ifdef ASSERT
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2411 void SpaceManager::verify_allocated_blocks_words() {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2412 // Verification is only guaranteed at a safepoint.
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2413 assert(SafepointSynchronize::is_at_safepoint() || !Universe::is_fully_initialized(),
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2414 "Verification can fail if the applications is running");
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2415 assert(allocated_blocks_words() == sum_used_in_chunks_in_use(),
8007
d9058e388631 8007257: NPG: metaspace.cpp: Incorrect arguments in calls to err_msg
mikael
parents: 7447
diff changeset
2416 err_msg("allocation total is not consistent " SIZE_FORMAT
d9058e388631 8007257: NPG: metaspace.cpp: Incorrect arguments in calls to err_msg
mikael
parents: 7447
diff changeset
2417 " vs " SIZE_FORMAT,
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2418 allocated_blocks_words(), sum_used_in_chunks_in_use()));
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2419 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2420
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2421 #endif
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2422
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2423 void SpaceManager::dump(outputStream* const out) const {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2424 size_t curr_total = 0;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2425 size_t waste = 0;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2426 uint i = 0;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2427 size_t used = 0;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2428 size_t capacity = 0;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2429
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2430 // Add up statistics for all chunks in this SpaceManager.
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2431 for (ChunkIndex index = ZeroIndex;
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
2432 index < NumberOfInUseLists;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2433 index = next_chunk_index(index)) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2434 for (Metachunk* curr = chunks_in_use(index);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2435 curr != NULL;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2436 curr = curr->next()) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2437 out->print("%d) ", i++);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2438 curr->print_on(out);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2439 curr_total += curr->word_size();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2440 used += curr->used_word_size();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2441 capacity += curr->capacity_word_size();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2442 waste += curr->free_word_size() + curr->overhead();;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2443 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2444 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2445
12239
8227700da288 8024751: Fix bugs in TraceMetadata
stefank
parents: 12237
diff changeset
2446 if (TraceMetadataChunkAllocation && Verbose) {
8227700da288 8024751: Fix bugs in TraceMetadata
stefank
parents: 12237
diff changeset
2447 block_freelists()->print_on(out);
8227700da288 8024751: Fix bugs in TraceMetadata
stefank
parents: 12237
diff changeset
2448 }
8227700da288 8024751: Fix bugs in TraceMetadata
stefank
parents: 12237
diff changeset
2449
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2450 size_t free = current_chunk() == NULL ? 0 : current_chunk()->free_word_size();
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2451 // Free space isn't wasted.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2452 waste -= free;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2453
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2454 out->print_cr("total of all chunks " SIZE_FORMAT " used " SIZE_FORMAT
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2455 " free " SIZE_FORMAT " capacity " SIZE_FORMAT
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2456 " waste " SIZE_FORMAT, curr_total, used, free, capacity, waste);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2457 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2458
7185
90273fc0a981 8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents: 6969
diff changeset
2459 #ifndef PRODUCT
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2460 void SpaceManager::mangle_freed_chunks() {
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2461 for (ChunkIndex index = ZeroIndex;
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
2462 index < NumberOfInUseLists;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2463 index = next_chunk_index(index)) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2464 for (Metachunk* curr = chunks_in_use(index);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2465 curr != NULL;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2466 curr = curr->next()) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2467 curr->mangle();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2468 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2469 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2470 }
7185
90273fc0a981 8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents: 6969
diff changeset
2471 #endif // PRODUCT
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2472
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2473 // MetaspaceAux
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2474
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2475
10330
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2476 size_t MetaspaceAux::_allocated_capacity_words[] = {0, 0};
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2477 size_t MetaspaceAux::_allocated_used_words[] = {0, 0};
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2478
12063
1a8fb39bdbc4 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 12056
diff changeset
2479 size_t MetaspaceAux::free_bytes(Metaspace::MetadataType mdtype) {
1a8fb39bdbc4 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 12056
diff changeset
2480 VirtualSpaceList* list = Metaspace::get_space_list(mdtype);
1a8fb39bdbc4 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 12056
diff changeset
2481 return list == NULL ? 0 : list->free_bytes();
1a8fb39bdbc4 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 12056
diff changeset
2482 }
1a8fb39bdbc4 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 12056
diff changeset
2483
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2484 size_t MetaspaceAux::free_bytes() {
12063
1a8fb39bdbc4 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 12056
diff changeset
2485 return free_bytes(Metaspace::ClassType) + free_bytes(Metaspace::NonClassType);
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2486 }
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2487
10330
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2488 void MetaspaceAux::dec_capacity(Metaspace::MetadataType mdtype, size_t words) {
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2489 assert_lock_strong(SpaceManager::expand_lock());
10330
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2490 assert(words <= allocated_capacity_words(mdtype),
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2491 err_msg("About to decrement below 0: words " SIZE_FORMAT
10330
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2492 " is greater than _allocated_capacity_words[%u] " SIZE_FORMAT,
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2493 words, mdtype, allocated_capacity_words(mdtype)));
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2494 _allocated_capacity_words[mdtype] -= words;
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2495 }
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2496
10330
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2497 void MetaspaceAux::inc_capacity(Metaspace::MetadataType mdtype, size_t words) {
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2498 assert_lock_strong(SpaceManager::expand_lock());
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2499 // Needs to be atomic
10330
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2500 _allocated_capacity_words[mdtype] += words;
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2501 }
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2502
10330
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2503 void MetaspaceAux::dec_used(Metaspace::MetadataType mdtype, size_t words) {
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2504 assert(words <= allocated_used_words(mdtype),
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2505 err_msg("About to decrement below 0: words " SIZE_FORMAT
10330
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2506 " is greater than _allocated_used_words[%u] " SIZE_FORMAT,
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2507 words, mdtype, allocated_used_words(mdtype)));
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2508 // For CMS deallocation of the Metaspaces occurs during the
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2509 // sweep which is a concurrent phase. Protection by the expand_lock()
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2510 // is not enough since allocation is on a per Metaspace basis
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2511 // and protected by the Metaspace lock.
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2512 jlong minus_words = (jlong) - (jlong) words;
10330
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2513 Atomic::add_ptr(minus_words, &_allocated_used_words[mdtype]);
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2514 }
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2515
10330
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2516 void MetaspaceAux::inc_used(Metaspace::MetadataType mdtype, size_t words) {
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2517 // _allocated_used_words tracks allocations for
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2518 // each piece of metadata. Those allocations are
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2519 // generally done concurrently by different application
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2520 // threads so must be done atomically.
10330
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2521 Atomic::add_ptr(words, &_allocated_used_words[mdtype]);
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2522 }
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2523
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2524 size_t MetaspaceAux::used_bytes_slow(Metaspace::MetadataType mdtype) {
6730
5d2156bcb78b 7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents: 6726
diff changeset
2525 size_t used = 0;
5d2156bcb78b 7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents: 6726
diff changeset
2526 ClassLoaderDataGraphMetaspaceIterator iter;
5d2156bcb78b 7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents: 6726
diff changeset
2527 while (iter.repeat()) {
5d2156bcb78b 7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents: 6726
diff changeset
2528 Metaspace* msp = iter.get_next();
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2529 // Sum allocated_blocks_words for each metaspace
6730
5d2156bcb78b 7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents: 6726
diff changeset
2530 if (msp != NULL) {
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2531 used += msp->used_words_slow(mdtype);
6730
5d2156bcb78b 7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents: 6726
diff changeset
2532 }
5d2156bcb78b 7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents: 6726
diff changeset
2533 }
5d2156bcb78b 7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents: 6726
diff changeset
2534 return used * BytesPerWord;
5d2156bcb78b 7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents: 6726
diff changeset
2535 }
5d2156bcb78b 7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents: 6726
diff changeset
2536
12235
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
2537 size_t MetaspaceAux::free_bytes_slow(Metaspace::MetadataType mdtype) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2538 size_t free = 0;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2539 ClassLoaderDataGraphMetaspaceIterator iter;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2540 while (iter.repeat()) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2541 Metaspace* msp = iter.get_next();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2542 if (msp != NULL) {
12235
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
2543 free += msp->free_words_slow(mdtype);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2544 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2545 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2546 return free * BytesPerWord;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2547 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2548
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2549 size_t MetaspaceAux::capacity_bytes_slow(Metaspace::MetadataType mdtype) {
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2550 if ((mdtype == Metaspace::ClassType) && !Metaspace::using_class_space()) {
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2551 return 0;
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2552 }
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2553 // Don't count the space in the freelists. That space will be
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2554 // added to the capacity calculation as needed.
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2555 size_t capacity = 0;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2556 ClassLoaderDataGraphMetaspaceIterator iter;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2557 while (iter.repeat()) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2558 Metaspace* msp = iter.get_next();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2559 if (msp != NULL) {
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2560 capacity += msp->capacity_words_slow(mdtype);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2561 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2562 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2563 return capacity * BytesPerWord;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2564 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2565
12235
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
2566 size_t MetaspaceAux::capacity_bytes_slow() {
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
2567 #ifdef PRODUCT
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
2568 // Use allocated_capacity_bytes() in PRODUCT instead of this function.
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
2569 guarantee(false, "Should not call capacity_bytes_slow() in the PRODUCT");
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
2570 #endif
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
2571 size_t class_capacity = capacity_bytes_slow(Metaspace::ClassType);
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
2572 size_t non_class_capacity = capacity_bytes_slow(Metaspace::NonClassType);
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
2573 assert(allocated_capacity_bytes() == class_capacity + non_class_capacity,
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
2574 err_msg("bad accounting: allocated_capacity_bytes() " SIZE_FORMAT
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
2575 " class_capacity + non_class_capacity " SIZE_FORMAT
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
2576 " class_capacity " SIZE_FORMAT " non_class_capacity " SIZE_FORMAT,
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
2577 allocated_capacity_bytes(), class_capacity + non_class_capacity,
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
2578 class_capacity, non_class_capacity));
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
2579
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
2580 return class_capacity + non_class_capacity;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2581 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2582
12235
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
2583 size_t MetaspaceAux::reserved_bytes(Metaspace::MetadataType mdtype) {
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
2584 VirtualSpaceList* list = Metaspace::get_space_list(mdtype);
12236
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
2585 return list == NULL ? 0 : list->reserved_bytes();
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
2586 }
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
2587
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
2588 size_t MetaspaceAux::committed_bytes(Metaspace::MetadataType mdtype) {
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
2589 VirtualSpaceList* list = Metaspace::get_space_list(mdtype);
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
2590 return list == NULL ? 0 : list->committed_bytes();
12235
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
2591 }
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
2592
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
2593 size_t MetaspaceAux::min_chunk_size_words() { return Metaspace::first_chunk_word_size(); }
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
2594
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
2595 size_t MetaspaceAux::free_chunks_total_words(Metaspace::MetadataType mdtype) {
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
2596 ChunkManager* chunk_manager = Metaspace::get_chunk_manager(mdtype);
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
2597 if (chunk_manager == NULL) {
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2598 return 0;
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2599 }
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
2600 chunk_manager->slow_verify();
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
2601 return chunk_manager->free_chunks_total_words();
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2602 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2603
12235
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
2604 size_t MetaspaceAux::free_chunks_total_bytes(Metaspace::MetadataType mdtype) {
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
2605 return free_chunks_total_words(mdtype) * BytesPerWord;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2606 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2607
12235
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
2608 size_t MetaspaceAux::free_chunks_total_words() {
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
2609 return free_chunks_total_words(Metaspace::ClassType) +
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
2610 free_chunks_total_words(Metaspace::NonClassType);
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2611 }
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2612
12235
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
2613 size_t MetaspaceAux::free_chunks_total_bytes() {
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
2614 return free_chunks_total_words() * BytesPerWord;
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2615 }
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2616
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2617 void MetaspaceAux::print_metaspace_change(size_t prev_metadata_used) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2618 gclog_or_tty->print(", [Metaspace:");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2619 if (PrintGCDetails && Verbose) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2620 gclog_or_tty->print(" " SIZE_FORMAT
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2621 "->" SIZE_FORMAT
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2622 "(" SIZE_FORMAT ")",
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2623 prev_metadata_used,
11037
df7e1c0e3dc1 8014546: MetaspaceAux print_metaspace_change() should print "used" after GC not capacity
jmasa
parents: 10376
diff changeset
2624 allocated_used_bytes(),
12235
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
2625 reserved_bytes());
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2626 } else {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2627 gclog_or_tty->print(" " SIZE_FORMAT "K"
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2628 "->" SIZE_FORMAT "K"
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2629 "(" SIZE_FORMAT "K)",
12235
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
2630 prev_metadata_used/K,
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
2631 allocated_used_bytes()/K,
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
2632 reserved_bytes()/K);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2633 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2634
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2635 gclog_or_tty->print("]");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2636 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2637
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2638 // This is printed when PrintGCDetails
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2639 void MetaspaceAux::print_on(outputStream* out) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2640 Metaspace::MetadataType nct = Metaspace::NonClassType;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2641
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2642 out->print_cr(" Metaspace total "
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2643 SIZE_FORMAT "K, used " SIZE_FORMAT "K,"
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2644 " reserved " SIZE_FORMAT "K",
12235
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
2645 allocated_capacity_bytes()/K, allocated_used_bytes()/K, reserved_bytes()/K);
10330
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2646
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2647 out->print_cr(" data space "
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2648 SIZE_FORMAT "K, used " SIZE_FORMAT "K,"
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2649 " reserved " SIZE_FORMAT "K",
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2650 allocated_capacity_bytes(nct)/K,
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2651 allocated_used_bytes(nct)/K,
12235
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
2652 reserved_bytes(nct)/K);
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2653 if (Metaspace::using_class_space()) {
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2654 Metaspace::MetadataType ct = Metaspace::ClassType;
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2655 out->print_cr(" class space "
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2656 SIZE_FORMAT "K, used " SIZE_FORMAT "K,"
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2657 " reserved " SIZE_FORMAT "K",
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2658 allocated_capacity_bytes(ct)/K,
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2659 allocated_used_bytes(ct)/K,
12235
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
2660 reserved_bytes(ct)/K);
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2661 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2662 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2663
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2664 // Print information for class space and data space separately.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2665 // This is almost the same as above.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2666 void MetaspaceAux::print_on(outputStream* out, Metaspace::MetadataType mdtype) {
12235
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
2667 size_t free_chunks_capacity_bytes = free_chunks_total_bytes(mdtype);
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2668 size_t capacity_bytes = capacity_bytes_slow(mdtype);
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2669 size_t used_bytes = used_bytes_slow(mdtype);
12235
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
2670 size_t free_bytes = free_bytes_slow(mdtype);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2671 size_t used_and_free = used_bytes + free_bytes +
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2672 free_chunks_capacity_bytes;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2673 out->print_cr(" Chunk accounting: used in chunks " SIZE_FORMAT
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2674 "K + unused in chunks " SIZE_FORMAT "K + "
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2675 " capacity in free chunks " SIZE_FORMAT "K = " SIZE_FORMAT
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2676 "K capacity in allocated chunks " SIZE_FORMAT "K",
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2677 used_bytes / K,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2678 free_bytes / K,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2679 free_chunks_capacity_bytes / K,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2680 used_and_free / K,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2681 capacity_bytes / K);
8738
1c88b99a2b01 8009282: Assertion "assert(used_and_free == capacity_bytes) failed: Accounting is wrong" failed with -XX:+Verbose -XX:+TraceMetadataChunkAllocation
mgerdin
parents: 8040
diff changeset
2682 // Accounting can only be correct if we got the values during a safepoint
1c88b99a2b01 8009282: Assertion "assert(used_and_free == capacity_bytes) failed: Accounting is wrong" failed with -XX:+Verbose -XX:+TraceMetadataChunkAllocation
mgerdin
parents: 8040
diff changeset
2683 assert(!SafepointSynchronize::is_at_safepoint() || used_and_free == capacity_bytes, "Accounting is wrong");
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2684 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2685
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2686 // Print total fragmentation for class metaspaces
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2687 void MetaspaceAux::print_class_waste(outputStream* out) {
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2688 assert(Metaspace::using_class_space(), "class metaspace not used");
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2689 size_t cls_specialized_waste = 0, cls_small_waste = 0, cls_medium_waste = 0;
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2690 size_t cls_specialized_count = 0, cls_small_count = 0, cls_medium_count = 0, cls_humongous_count = 0;
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2691 ClassLoaderDataGraphMetaspaceIterator iter;
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2692 while (iter.repeat()) {
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2693 Metaspace* msp = iter.get_next();
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2694 if (msp != NULL) {
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2695 cls_specialized_waste += msp->class_vsm()->sum_waste_in_chunks_in_use(SpecializedIndex);
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2696 cls_specialized_count += msp->class_vsm()->sum_count_in_chunks_in_use(SpecializedIndex);
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2697 cls_small_waste += msp->class_vsm()->sum_waste_in_chunks_in_use(SmallIndex);
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2698 cls_small_count += msp->class_vsm()->sum_count_in_chunks_in_use(SmallIndex);
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2699 cls_medium_waste += msp->class_vsm()->sum_waste_in_chunks_in_use(MediumIndex);
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2700 cls_medium_count += msp->class_vsm()->sum_count_in_chunks_in_use(MediumIndex);
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2701 cls_humongous_count += msp->class_vsm()->sum_count_in_chunks_in_use(HumongousIndex);
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2702 }
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2703 }
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2704 out->print_cr(" class: " SIZE_FORMAT " specialized(s) " SIZE_FORMAT ", "
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2705 SIZE_FORMAT " small(s) " SIZE_FORMAT ", "
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2706 SIZE_FORMAT " medium(s) " SIZE_FORMAT ", "
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2707 "large count " SIZE_FORMAT,
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2708 cls_specialized_count, cls_specialized_waste,
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2709 cls_small_count, cls_small_waste,
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2710 cls_medium_count, cls_medium_waste, cls_humongous_count);
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2711 }
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2712
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2713 // Print total fragmentation for data and class metaspaces separately
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2714 void MetaspaceAux::print_waste(outputStream* out) {
11064
de2d15ce3d4a 8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents: 10376
diff changeset
2715 size_t specialized_waste = 0, small_waste = 0, medium_waste = 0;
de2d15ce3d4a 8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents: 10376
diff changeset
2716 size_t specialized_count = 0, small_count = 0, medium_count = 0, humongous_count = 0;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2717
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2718 ClassLoaderDataGraphMetaspaceIterator iter;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2719 while (iter.repeat()) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2720 Metaspace* msp = iter.get_next();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2721 if (msp != NULL) {
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2722 specialized_waste += msp->vsm()->sum_waste_in_chunks_in_use(SpecializedIndex);
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2723 specialized_count += msp->vsm()->sum_count_in_chunks_in_use(SpecializedIndex);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2724 small_waste += msp->vsm()->sum_waste_in_chunks_in_use(SmallIndex);
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2725 small_count += msp->vsm()->sum_count_in_chunks_in_use(SmallIndex);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2726 medium_waste += msp->vsm()->sum_waste_in_chunks_in_use(MediumIndex);
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2727 medium_count += msp->vsm()->sum_count_in_chunks_in_use(MediumIndex);
11064
de2d15ce3d4a 8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents: 10376
diff changeset
2728 humongous_count += msp->vsm()->sum_count_in_chunks_in_use(HumongousIndex);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2729 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2730 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2731 out->print_cr("Total fragmentation waste (words) doesn't count free space");
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2732 out->print_cr(" data: " SIZE_FORMAT " specialized(s) " SIZE_FORMAT ", "
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2733 SIZE_FORMAT " small(s) " SIZE_FORMAT ", "
11064
de2d15ce3d4a 8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents: 10376
diff changeset
2734 SIZE_FORMAT " medium(s) " SIZE_FORMAT ", "
de2d15ce3d4a 8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents: 10376
diff changeset
2735 "large count " SIZE_FORMAT,
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2736 specialized_count, specialized_waste, small_count,
11064
de2d15ce3d4a 8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents: 10376
diff changeset
2737 small_waste, medium_count, medium_waste, humongous_count);
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2738 if (Metaspace::using_class_space()) {
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2739 print_class_waste(out);
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2740 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2741 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2742
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2743 // Dump global metaspace things from the end of ClassLoaderDataGraph
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2744 void MetaspaceAux::dump(outputStream* out) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2745 out->print_cr("All Metaspace:");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2746 out->print("data space: "); print_on(out, Metaspace::NonClassType);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2747 out->print("class space: "); print_on(out, Metaspace::ClassType);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2748 print_waste(out);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2749 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2750
6969
6bc207d87e5d 7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents: 6885
diff changeset
2751 void MetaspaceAux::verify_free_chunks() {
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
2752 Metaspace::chunk_manager_metadata()->verify();
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2753 if (Metaspace::using_class_space()) {
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
2754 Metaspace::chunk_manager_class()->verify();
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2755 }
6969
6bc207d87e5d 7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents: 6885
diff changeset
2756 }
6bc207d87e5d 7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents: 6885
diff changeset
2757
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2758 void MetaspaceAux::verify_capacity() {
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2759 #ifdef ASSERT
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2760 size_t running_sum_capacity_bytes = allocated_capacity_bytes();
10330
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2761 // For purposes of the running sum of capacity, verify against capacity
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2762 size_t capacity_in_use_bytes = capacity_bytes_slow();
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2763 assert(running_sum_capacity_bytes == capacity_in_use_bytes,
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2764 err_msg("allocated_capacity_words() * BytesPerWord " SIZE_FORMAT
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2765 " capacity_bytes_slow()" SIZE_FORMAT,
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2766 running_sum_capacity_bytes, capacity_in_use_bytes));
10330
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2767 for (Metaspace::MetadataType i = Metaspace::ClassType;
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2768 i < Metaspace:: MetadataTypeCount;
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2769 i = (Metaspace::MetadataType)(i + 1)) {
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2770 size_t capacity_in_use_bytes = capacity_bytes_slow(i);
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2771 assert(allocated_capacity_bytes(i) == capacity_in_use_bytes,
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2772 err_msg("allocated_capacity_bytes(%u) " SIZE_FORMAT
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2773 " capacity_bytes_slow(%u)" SIZE_FORMAT,
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2774 i, allocated_capacity_bytes(i), i, capacity_in_use_bytes));
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2775 }
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2776 #endif
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2777 }
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2778
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2779 void MetaspaceAux::verify_used() {
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2780 #ifdef ASSERT
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2781 size_t running_sum_used_bytes = allocated_used_bytes();
10330
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2782 // For purposes of the running sum of used, verify against used
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2783 size_t used_in_use_bytes = used_bytes_slow();
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2784 assert(allocated_used_bytes() == used_in_use_bytes,
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2785 err_msg("allocated_used_bytes() " SIZE_FORMAT
10330
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2786 " used_bytes_slow()" SIZE_FORMAT,
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2787 allocated_used_bytes(), used_in_use_bytes));
10330
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2788 for (Metaspace::MetadataType i = Metaspace::ClassType;
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2789 i < Metaspace:: MetadataTypeCount;
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2790 i = (Metaspace::MetadataType)(i + 1)) {
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2791 size_t used_in_use_bytes = used_bytes_slow(i);
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2792 assert(allocated_used_bytes(i) == used_in_use_bytes,
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2793 err_msg("allocated_used_bytes(%u) " SIZE_FORMAT
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2794 " used_bytes_slow(%u)" SIZE_FORMAT,
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2795 i, allocated_used_bytes(i), i, used_in_use_bytes));
2b1a9d972fc2 8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents: 10191
diff changeset
2796 }
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2797 #endif
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2798 }
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2799
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2800 void MetaspaceAux::verify_metrics() {
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2801 verify_capacity();
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2802 verify_used();
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2803 }
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2804
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
2805
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2806 // Metaspace methods
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2807
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2808 size_t Metaspace::_first_chunk_word_size = 0;
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2809 size_t Metaspace::_first_class_chunk_word_size = 0;
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2810
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2811 Metaspace::Metaspace(Mutex* lock, MetaspaceType type) {
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
2812 initialize(lock, type);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2813 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2814
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2815 Metaspace::~Metaspace() {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2816 delete _vsm;
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2817 if (using_class_space()) {
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2818 delete _class_vsm;
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2819 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2820 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2821
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2822 VirtualSpaceList* Metaspace::_space_list = NULL;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2823 VirtualSpaceList* Metaspace::_class_space_list = NULL;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2824
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
2825 ChunkManager* Metaspace::_chunk_manager_metadata = NULL;
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
2826 ChunkManager* Metaspace::_chunk_manager_class = NULL;
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
2827
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2828 #define VIRTUALSPACEMULTIPLIER 2
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2829
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2830 #ifdef _LP64
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2831 void Metaspace::set_narrow_klass_base_and_shift(address metaspace_base, address cds_base) {
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2832 // Figure out the narrow_klass_base and the narrow_klass_shift. The
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2833 // narrow_klass_base is the lower of the metaspace base and the cds base
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2834 // (if cds is enabled). The narrow_klass_shift depends on the distance
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2835 // between the lower base and higher address.
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2836 address lower_base;
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2837 address higher_address;
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2838 if (UseSharedSpaces) {
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2839 higher_address = MAX2((address)(cds_base + FileMapInfo::shared_spaces_size()),
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2840 (address)(metaspace_base + class_metaspace_size()));
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2841 lower_base = MIN2(metaspace_base, cds_base);
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2842 } else {
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2843 higher_address = metaspace_base + class_metaspace_size();
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2844 lower_base = metaspace_base;
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2845 }
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2846 Universe::set_narrow_klass_base(lower_base);
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2847 if ((uint64_t)(higher_address - lower_base) < (uint64_t)max_juint) {
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2848 Universe::set_narrow_klass_shift(0);
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2849 } else {
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2850 assert(!UseSharedSpaces, "Cannot shift with UseSharedSpaces");
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2851 Universe::set_narrow_klass_shift(LogKlassAlignmentInBytes);
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2852 }
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2853 }
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2854
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2855 // Return TRUE if the specified metaspace_base and cds_base are close enough
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2856 // to work with compressed klass pointers.
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2857 bool Metaspace::can_use_cds_with_metaspace_addr(char* metaspace_base, address cds_base) {
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2858 assert(cds_base != 0 && UseSharedSpaces, "Only use with CDS");
12226
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 12110
diff changeset
2859 assert(UseCompressedClassPointers, "Only use with CompressedKlassPtrs");
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2860 address lower_base = MIN2((address)metaspace_base, cds_base);
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2861 address higher_address = MAX2((address)(cds_base + FileMapInfo::shared_spaces_size()),
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2862 (address)(metaspace_base + class_metaspace_size()));
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2863 return ((uint64_t)(higher_address - lower_base) < (uint64_t)max_juint);
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2864 }
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2865
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2866 // Try to allocate the metaspace at the requested addr.
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2867 void Metaspace::allocate_metaspace_compressed_klass_ptrs(char* requested_addr, address cds_base) {
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2868 assert(using_class_space(), "called improperly");
12226
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 12110
diff changeset
2869 assert(UseCompressedClassPointers, "Only use with CompressedKlassPtrs");
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2870 assert(class_metaspace_size() < KlassEncodingMetaspaceMax,
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2871 "Metaspace size is too big");
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2872
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2873 ReservedSpace metaspace_rs = ReservedSpace(class_metaspace_size(),
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2874 os::vm_allocation_granularity(),
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2875 false, requested_addr, 0);
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2876 if (!metaspace_rs.is_reserved()) {
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2877 if (UseSharedSpaces) {
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2878 // Keep trying to allocate the metaspace, increasing the requested_addr
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2879 // by 1GB each time, until we reach an address that will no longer allow
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2880 // use of CDS with compressed klass pointers.
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2881 char *addr = requested_addr;
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2882 while (!metaspace_rs.is_reserved() && (addr + 1*G > addr) &&
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2883 can_use_cds_with_metaspace_addr(addr + 1*G, cds_base)) {
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2884 addr = addr + 1*G;
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2885 metaspace_rs = ReservedSpace(class_metaspace_size(),
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2886 os::vm_allocation_granularity(), false, addr, 0);
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2887 }
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2888 }
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2889
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2890 // If no successful allocation then try to allocate the space anywhere. If
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2891 // that fails then OOM doom. At this point we cannot try allocating the
12226
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 12110
diff changeset
2892 // metaspace as if UseCompressedClassPointers is off because too much
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 12110
diff changeset
2893 // initialization has happened that depends on UseCompressedClassPointers.
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 12110
diff changeset
2894 // So, UseCompressedClassPointers cannot be turned off at this point.
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2895 if (!metaspace_rs.is_reserved()) {
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2896 metaspace_rs = ReservedSpace(class_metaspace_size(),
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2897 os::vm_allocation_granularity(), false);
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2898 if (!metaspace_rs.is_reserved()) {
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2899 vm_exit_during_initialization(err_msg("Could not allocate metaspace: %d bytes",
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2900 class_metaspace_size()));
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2901 }
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2902 }
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2903 }
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2904
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2905 // If we got here then the metaspace got allocated.
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2906 MemTracker::record_virtual_memory_type((address)metaspace_rs.base(), mtClass);
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2907
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2908 // Verify that we can use shared spaces. Otherwise, turn off CDS.
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2909 if (UseSharedSpaces && !can_use_cds_with_metaspace_addr(metaspace_rs.base(), cds_base)) {
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2910 FileMapInfo::stop_sharing_and_unmap(
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2911 "Could not allocate metaspace at a compatible address");
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2912 }
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2913
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2914 set_narrow_klass_base_and_shift((address)metaspace_rs.base(),
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2915 UseSharedSpaces ? (address)cds_base : 0);
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2916
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2917 initialize_class_space(metaspace_rs);
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2918
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2919 if (PrintCompressedOopsMode || (PrintMiscellaneous && Verbose)) {
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2920 gclog_or_tty->print_cr("Narrow klass base: " PTR_FORMAT ", Narrow klass shift: " SIZE_FORMAT,
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2921 Universe::narrow_klass_base(), Universe::narrow_klass_shift());
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2922 gclog_or_tty->print_cr("Metaspace Size: " SIZE_FORMAT " Address: " PTR_FORMAT " Req Addr: " PTR_FORMAT,
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2923 class_metaspace_size(), metaspace_rs.base(), requested_addr);
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2924 }
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2925 }
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2926
12226
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 12110
diff changeset
2927 // For UseCompressedClassPointers the class space is reserved above the top of
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2928 // the Java heap. The argument passed in is at the base of the compressed space.
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2929 void Metaspace::initialize_class_space(ReservedSpace rs) {
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2930 // The reserved space size may be bigger because of alignment, esp with UseLargePages
12226
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 12110
diff changeset
2931 assert(rs.size() >= CompressedClassSpaceSize,
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 12110
diff changeset
2932 err_msg(SIZE_FORMAT " != " UINTX_FORMAT, rs.size(), CompressedClassSpaceSize));
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2933 assert(using_class_space(), "Must be using class space");
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2934 _class_space_list = new VirtualSpaceList(rs);
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
2935 _chunk_manager_class = new ChunkManager(SpecializedChunk, ClassSmallChunk, ClassMediumChunk);
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2936 }
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2937
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2938 #endif
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2939
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2940 void Metaspace::global_initialize() {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2941 // Initialize the alignment for shared spaces.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2942 int max_alignment = os::vm_page_size();
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2943 size_t cds_total = 0;
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2944
12226
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 12110
diff changeset
2945 set_class_metaspace_size(align_size_up(CompressedClassSpaceSize,
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2946 os::vm_allocation_granularity()));
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2947
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2948 MetaspaceShared::set_max_alignment(max_alignment);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2949
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2950 if (DumpSharedSpaces) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2951 SharedReadOnlySize = align_size_up(SharedReadOnlySize, max_alignment);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2952 SharedReadWriteSize = align_size_up(SharedReadWriteSize, max_alignment);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2953 SharedMiscDataSize = align_size_up(SharedMiscDataSize, max_alignment);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2954 SharedMiscCodeSize = align_size_up(SharedMiscCodeSize, max_alignment);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2955
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2956 // Initialize with the sum of the shared space sizes. The read-only
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2957 // and read write metaspace chunks will be allocated out of this and the
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2958 // remainder is the misc code and data chunks.
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2959 cds_total = FileMapInfo::shared_spaces_size();
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2960 _space_list = new VirtualSpaceList(cds_total/wordSize);
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
2961 _chunk_manager_metadata = new ChunkManager(SpecializedChunk, SmallChunk, MediumChunk);
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2962
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2963 #ifdef _LP64
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2964 // Set the compressed klass pointer base so that decoding of these pointers works
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2965 // properly when creating the shared archive.
12226
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 12110
diff changeset
2966 assert(UseCompressedOops && UseCompressedClassPointers,
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 12110
diff changeset
2967 "UseCompressedOops and UseCompressedClassPointers must be set");
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2968 Universe::set_narrow_klass_base((address)_space_list->current_virtual_space()->bottom());
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2969 if (TraceMetavirtualspaceAllocation && Verbose) {
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2970 gclog_or_tty->print_cr("Setting_narrow_klass_base to Address: " PTR_FORMAT,
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2971 _space_list->current_virtual_space()->bottom());
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2972 }
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2973
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2974 // Set the shift to zero.
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2975 assert(class_metaspace_size() < (uint64_t)(max_juint) - cds_total,
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2976 "CDS region is too large");
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2977 Universe::set_narrow_klass_shift(0);
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2978 #endif
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2979
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2980 } else {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2981 // If using shared space, open the file that contains the shared space
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2982 // and map in the memory before initializing the rest of metaspace (so
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2983 // the addresses don't conflict)
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2984 address cds_address = NULL;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2985 if (UseSharedSpaces) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2986 FileMapInfo* mapinfo = new FileMapInfo();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2987 memset(mapinfo, 0, sizeof(FileMapInfo));
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2988
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2989 // Open the shared archive file, read and validate the header. If
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2990 // initialization fails, shared spaces [UseSharedSpaces] are
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2991 // disabled and the file is closed.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2992 // Map in spaces now also
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2993 if (mapinfo->initialize() && MetaspaceShared::map_shared_spaces(mapinfo)) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2994 FileMapInfo::set_current_info(mapinfo);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2995 } else {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2996 assert(!mapinfo->is_open() && !UseSharedSpaces,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2997 "archive file not closed or shared spaces not disabled.");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
2998 }
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
2999 cds_total = FileMapInfo::shared_spaces_size();
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3000 cds_address = (address)mapinfo->region_base(0);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3001 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3002
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3003 #ifdef _LP64
12226
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 12110
diff changeset
3004 // If UseCompressedClassPointers is set then allocate the metaspace area
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3005 // above the heap and above the CDS area (if it exists).
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3006 if (using_class_space()) {
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3007 if (UseSharedSpaces) {
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3008 allocate_metaspace_compressed_klass_ptrs((char *)(cds_address + cds_total), cds_address);
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3009 } else {
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3010 allocate_metaspace_compressed_klass_ptrs((char *)CompressedKlassPointersBase, 0);
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3011 }
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3012 }
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3013 #endif
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3014
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
3015 // Initialize these before initializing the VirtualSpaceList
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3016 _first_chunk_word_size = InitialBootClassLoaderMetaspaceSize / BytesPerWord;
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
3017 _first_chunk_word_size = align_word_size_up(_first_chunk_word_size);
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
3018 // Make the first class chunk bigger than a medium chunk so it's not put
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
3019 // on the medium chunk list. The next chunk will be small and progress
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
3020 // from there. This size calculated by -version.
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
3021 _first_class_chunk_word_size = MIN2((size_t)MediumChunk*6,
12226
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 12110
diff changeset
3022 (CompressedClassSpaceSize/BytesPerWord)*2);
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
3023 _first_class_chunk_word_size = align_word_size_up(_first_class_chunk_word_size);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3024 // Arbitrarily set the initial virtual space to a multiple
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3025 // of the boot class loader size.
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
3026 size_t word_size = VIRTUALSPACEMULTIPLIER * first_chunk_word_size();
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3027 // Initialize the list of virtual spaces.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3028 _space_list = new VirtualSpaceList(word_size);
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
3029 _chunk_manager_metadata = new ChunkManager(SpecializedChunk, SmallChunk, MediumChunk);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3030 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3031 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3032
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
3033 Metachunk* Metaspace::get_initialization_chunk(MetadataType mdtype,
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
3034 size_t chunk_word_size,
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
3035 size_t chunk_bunch) {
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
3036 // Get a chunk from the chunk freelist
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
3037 Metachunk* chunk = get_chunk_manager(mdtype)->chunk_freelist_allocate(chunk_word_size);
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
3038 if (chunk != NULL) {
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
3039 return chunk;
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
3040 }
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
3041
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
3042 return get_space_list(mdtype)->get_initialization_chunk(chunk_word_size, chunk_bunch);
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
3043 }
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
3044
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3045 void Metaspace::initialize(Mutex* lock, MetaspaceType type) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3046
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3047 assert(space_list() != NULL,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3048 "Metadata VirtualSpaceList has not been initialized");
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
3049 assert(chunk_manager_metadata() != NULL,
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
3050 "Metadata ChunkManager has not been initialized");
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
3051
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
3052 _vsm = new SpaceManager(NonClassType, lock);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3053 if (_vsm == NULL) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3054 return;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3055 }
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
3056 size_t word_size;
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
3057 size_t class_word_size;
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3058 vsm()->get_initial_chunk_sizes(type, &word_size, &class_word_size);
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3059
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3060 if (using_class_space()) {
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
3061 assert(class_space_list() != NULL,
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
3062 "Class VirtualSpaceList has not been initialized");
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
3063 assert(chunk_manager_class() != NULL,
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
3064 "Class ChunkManager has not been initialized");
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3065
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3066 // Allocate SpaceManager for classes.
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
3067 _class_vsm = new SpaceManager(ClassType, lock);
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3068 if (_class_vsm == NULL) {
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3069 return;
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3070 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3071 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3072
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3073 MutexLockerEx cl(SpaceManager::expand_lock(), Mutex::_no_safepoint_check_flag);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3074
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3075 // Allocate chunk for metadata objects
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
3076 Metachunk* new_chunk = get_initialization_chunk(NonClassType,
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
3077 word_size,
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
3078 vsm()->medium_chunk_bunch());
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3079 assert(!DumpSharedSpaces || new_chunk != NULL, "should have enough space for both chunks");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3080 if (new_chunk != NULL) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3081 // Add to this manager's list of chunks in use and current_chunk().
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3082 vsm()->add_chunk(new_chunk, true);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3083 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3084
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3085 // Allocate chunk for class metadata objects
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3086 if (using_class_space()) {
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
3087 Metachunk* class_chunk = get_initialization_chunk(ClassType,
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
3088 class_word_size,
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
3089 class_vsm()->medium_chunk_bunch());
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3090 if (class_chunk != NULL) {
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3091 class_vsm()->add_chunk(class_chunk, true);
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3092 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3093 }
10376
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3094
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3095 _alloc_record_head = NULL;
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3096 _alloc_record_tail = NULL;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3097 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3098
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
3099 size_t Metaspace::align_word_size_up(size_t word_size) {
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
3100 size_t byte_size = word_size * wordSize;
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
3101 return ReservedSpace::allocation_align_size_up(byte_size) / wordSize;
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
3102 }
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
3103
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3104 MetaWord* Metaspace::allocate(size_t word_size, MetadataType mdtype) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3105 // DumpSharedSpaces doesn't use class metadata area (yet)
12226
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 12110
diff changeset
3106 // Also, don't use class_vsm() unless UseCompressedClassPointers is true.
12340
bc918fd1e584 8025279: metaspace/flags/maxMetaspaceSize throws OOM: out of Compressed Klass space
mgerdin
parents: 12306
diff changeset
3107 if (is_class_space_allocation(mdtype)) {
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
3108 return class_vsm()->allocate(word_size);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3109 } else {
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
3110 return vsm()->allocate(word_size);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3111 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3112 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3113
6753
8da5e203b993 7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
jmasa
parents: 6736
diff changeset
3114 MetaWord* Metaspace::expand_and_allocate(size_t word_size, MetadataType mdtype) {
8da5e203b993 7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
jmasa
parents: 6736
diff changeset
3115 MetaWord* result;
8da5e203b993 7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
jmasa
parents: 6736
diff changeset
3116 MetaspaceGC::set_expand_after_GC(true);
8da5e203b993 7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
jmasa
parents: 6736
diff changeset
3117 size_t before_inc = MetaspaceGC::capacity_until_GC();
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
3118 size_t delta_bytes = MetaspaceGC::delta_capacity_until_GC(word_size) * BytesPerWord;
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
3119 MetaspaceGC::inc_capacity_until_GC(delta_bytes);
6753
8da5e203b993 7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
jmasa
parents: 6736
diff changeset
3120 if (PrintGCDetails && Verbose) {
8da5e203b993 7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
jmasa
parents: 6736
diff changeset
3121 gclog_or_tty->print_cr("Increase capacity to GC from " SIZE_FORMAT
8da5e203b993 7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
jmasa
parents: 6736
diff changeset
3122 " to " SIZE_FORMAT, before_inc, MetaspaceGC::capacity_until_GC());
8da5e203b993 7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
jmasa
parents: 6736
diff changeset
3123 }
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
3124
6753
8da5e203b993 7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
jmasa
parents: 6736
diff changeset
3125 result = allocate(word_size, mdtype);
8da5e203b993 7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
jmasa
parents: 6736
diff changeset
3126
8da5e203b993 7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
jmasa
parents: 6736
diff changeset
3127 return result;
8da5e203b993 7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
jmasa
parents: 6736
diff changeset
3128 }
8da5e203b993 7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
jmasa
parents: 6736
diff changeset
3129
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3130 // Space allocated in the Metaspace. This may
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3131 // be across several metadata virtual spaces.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3132 char* Metaspace::bottom() const {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3133 assert(DumpSharedSpaces, "only useful and valid for dumping shared spaces");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3134 return (char*)vsm()->current_chunk()->bottom();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3135 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3136
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
3137 size_t Metaspace::used_words_slow(MetadataType mdtype) const {
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3138 if (mdtype == ClassType) {
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3139 return using_class_space() ? class_vsm()->sum_used_in_chunks_in_use() : 0;
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3140 } else {
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3141 return vsm()->sum_used_in_chunks_in_use(); // includes overhead!
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3142 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3143 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3144
12235
d6c266999345 8023476: Metaspace capacity > reserved
ehelin
parents: 12231
diff changeset
3145 size_t Metaspace::free_words_slow(MetadataType mdtype) const {
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3146 if (mdtype == ClassType) {
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3147 return using_class_space() ? class_vsm()->sum_free_in_chunks_in_use() : 0;
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3148 } else {
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3149 return vsm()->sum_free_in_chunks_in_use();
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3150 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3151 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3152
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3153 // Space capacity in the Metaspace. It includes
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3154 // space in the list of chunks from which allocations
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3155 // have been made. Don't include space in the global freelist and
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3156 // in the space available in the dictionary which
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3157 // is already counted in some chunk.
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
3158 size_t Metaspace::capacity_words_slow(MetadataType mdtype) const {
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3159 if (mdtype == ClassType) {
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3160 return using_class_space() ? class_vsm()->sum_capacity_in_chunks_in_use() : 0;
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3161 } else {
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3162 return vsm()->sum_capacity_in_chunks_in_use();
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3163 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3164 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3165
10183
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
3166 size_t Metaspace::used_bytes_slow(MetadataType mdtype) const {
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
3167 return used_words_slow(mdtype) * BytesPerWord;
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
3168 }
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
3169
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
3170 size_t Metaspace::capacity_bytes_slow(MetadataType mdtype) const {
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
3171 return capacity_words_slow(mdtype) * BytesPerWord;
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
3172 }
868d87ed63c8 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 10175
diff changeset
3173
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3174 void Metaspace::deallocate(MetaWord* ptr, size_t word_size, bool is_class) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3175 if (SafepointSynchronize::is_at_safepoint()) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3176 assert(Thread::current()->is_VM_thread(), "should be the VM thread");
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
3177 // Don't take Heap_lock
10191
601183f604b2 8013129: Possible deadlock with Metaspace locks due to mixed usage of safepoint aware and non-safepoint aware locking
mgerdin
parents: 10183
diff changeset
3178 MutexLockerEx ml(vsm()->lock(), Mutex::_no_safepoint_check_flag);
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
3179 if (word_size < TreeChunk<Metablock, FreeList>::min_size()) {
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
3180 // Dark matter. Too small for dictionary.
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
3181 #ifdef ASSERT
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
3182 Copy::fill_to_words((HeapWord*)ptr, word_size, 0xf5f5f5f5);
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
3183 #endif
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
3184 return;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3185 }
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3186 if (is_class && using_class_space()) {
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3187 class_vsm()->deallocate(ptr, word_size);
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
3188 } else {
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
3189 vsm()->deallocate(ptr, word_size);
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
3190 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3191 } else {
10191
601183f604b2 8013129: Possible deadlock with Metaspace locks due to mixed usage of safepoint aware and non-safepoint aware locking
mgerdin
parents: 10183
diff changeset
3192 MutexLockerEx ml(vsm()->lock(), Mutex::_no_safepoint_check_flag);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3193
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
3194 if (word_size < TreeChunk<Metablock, FreeList>::min_size()) {
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
3195 // Dark matter. Too small for dictionary.
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
3196 #ifdef ASSERT
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
3197 Copy::fill_to_words((HeapWord*)ptr, word_size, 0xf5f5f5f5);
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
3198 #endif
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
3199 return;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3200 }
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3201 if (is_class && using_class_space()) {
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
3202 class_vsm()->deallocate(ptr, word_size);
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
3203 } else {
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
3204 vsm()->deallocate(ptr, word_size);
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
3205 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3206 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3207 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3208
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
3209 Metablock* Metaspace::allocate(ClassLoaderData* loader_data, size_t word_size,
10376
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3210 bool read_only, MetaspaceObj::Type type, TRAPS) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3211 if (HAS_PENDING_EXCEPTION) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3212 assert(false, "Should not allocate with exception pending");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3213 return NULL; // caller does a CHECK_NULL too
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3214 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3215
10376
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3216 MetadataType mdtype = (type == MetaspaceObj::ClassType) ? ClassType : NonClassType;
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3217
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3218 // SSS: Should we align the allocations and make sure the sizes are aligned.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3219 MetaWord* result = NULL;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3220
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3221 assert(loader_data != NULL, "Should never pass around a NULL loader_data. "
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3222 "ClassLoaderData::the_null_class_loader_data() should have been used.");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3223 // Allocate in metaspaces without taking out a lock, because it deadlocks
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3224 // with the SymbolTable_lock. Dumping is single threaded for now. We'll have
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3225 // to revisit this for application class data sharing.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3226 if (DumpSharedSpaces) {
10376
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3227 assert(type > MetaspaceObj::UnknownType && type < MetaspaceObj::_number_of_types, "sanity");
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3228 Metaspace* space = read_only ? loader_data->ro_metaspace() : loader_data->rw_metaspace();
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3229 result = space->allocate(word_size, NonClassType);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3230 if (result == NULL) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3231 report_out_of_shared_space(read_only ? SharedReadOnly : SharedReadWrite);
10376
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3232 } else {
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3233 space->record_allocation(result, type, space->vsm()->get_raw_word_size(word_size));
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3234 }
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
3235 return Metablock::initialize(result, word_size);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3236 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3237
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3238 result = loader_data->metaspace_non_null()->allocate(word_size, mdtype);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3239
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3240 if (result == NULL) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3241 // Try to clean out some memory and retry.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3242 result =
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
3243 Universe::heap()->collector_policy()->satisfy_failed_metadata_allocation(
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3244 loader_data, word_size, mdtype);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3245
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3246 // If result is still null, we are out of memory.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3247 if (result == NULL) {
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
3248 if (Verbose && TraceMetadataChunkAllocation) {
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
3249 gclog_or_tty->print_cr("Metaspace allocation failed for size "
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
3250 SIZE_FORMAT, word_size);
11064
de2d15ce3d4a 8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents: 10376
diff changeset
3251 if (loader_data->metaspace_or_null() != NULL) loader_data->dump(gclog_or_tty);
7446
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
3252 MetaspaceAux::dump(gclog_or_tty);
e51c9860cf66 8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents: 7435
diff changeset
3253 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3254 // -XX:+HeapDumpOnOutOfMemoryError and -XX:OnOutOfMemoryError support
12340
bc918fd1e584 8025279: metaspace/flags/maxMetaspaceSize throws OOM: out of Compressed Klass space
mgerdin
parents: 12306
diff changeset
3255 const char* space_string = is_class_space_allocation(mdtype) ? "Compressed class space" :
bc918fd1e584 8025279: metaspace/flags/maxMetaspaceSize throws OOM: out of Compressed Klass space
mgerdin
parents: 12306
diff changeset
3256 "Metadata space";
11064
de2d15ce3d4a 8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents: 10376
diff changeset
3257 report_java_out_of_memory(space_string);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3258
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3259 if (JvmtiExport::should_post_resource_exhausted()) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3260 JvmtiExport::post_resource_exhausted(
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3261 JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR,
11064
de2d15ce3d4a 8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents: 10376
diff changeset
3262 space_string);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3263 }
12340
bc918fd1e584 8025279: metaspace/flags/maxMetaspaceSize throws OOM: out of Compressed Klass space
mgerdin
parents: 12306
diff changeset
3264 if (is_class_space_allocation(mdtype)) {
11064
de2d15ce3d4a 8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents: 10376
diff changeset
3265 THROW_OOP_0(Universe::out_of_memory_error_class_metaspace());
de2d15ce3d4a 8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents: 10376
diff changeset
3266 } else {
de2d15ce3d4a 8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents: 10376
diff changeset
3267 THROW_OOP_0(Universe::out_of_memory_error_metaspace());
de2d15ce3d4a 8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents: 10376
diff changeset
3268 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3269 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3270 }
6885
685df3c6f84b 7045397: NPG: Add freelists to class loader arenas.
jmasa
parents: 6786
diff changeset
3271 return Metablock::initialize(result, word_size);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3272 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3273
10376
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3274 void Metaspace::record_allocation(void* ptr, MetaspaceObj::Type type, size_t word_size) {
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3275 assert(DumpSharedSpaces, "sanity");
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3276
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3277 AllocRecord *rec = new AllocRecord((address)ptr, type, (int)word_size * HeapWordSize);
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3278 if (_alloc_record_head == NULL) {
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3279 _alloc_record_head = _alloc_record_tail = rec;
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3280 } else {
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3281 _alloc_record_tail->_next = rec;
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3282 _alloc_record_tail = rec;
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3283 }
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3284 }
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3285
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3286 void Metaspace::iterate(Metaspace::AllocRecordClosure *closure) {
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3287 assert(DumpSharedSpaces, "unimplemented for !DumpSharedSpaces");
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3288
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3289 address last_addr = (address)bottom();
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3290
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3291 for (AllocRecord *rec = _alloc_record_head; rec; rec = rec->_next) {
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3292 address ptr = rec->_ptr;
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3293 if (last_addr < ptr) {
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3294 closure->doit(last_addr, MetaspaceObj::UnknownType, ptr - last_addr);
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3295 }
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3296 closure->doit(ptr, rec->_type, rec->_byte_size);
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3297 last_addr = ptr + rec->_byte_size;
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3298 }
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3299
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3300 address top = ((address)bottom()) + used_bytes_slow(Metaspace::NonClassType);
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3301 if (last_addr < top) {
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3302 closure->doit(last_addr, MetaspaceObj::UnknownType, top - last_addr);
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3303 }
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3304 }
a1ebd310d5c1 8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents: 10330
diff changeset
3305
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
3306 void Metaspace::purge(MetadataType mdtype) {
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
3307 get_space_list(mdtype)->purge(get_chunk_manager(mdtype));
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
3308 }
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
3309
10175
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
3310 void Metaspace::purge() {
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
3311 MutexLockerEx cl(SpaceManager::expand_lock(),
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
3312 Mutex::_no_safepoint_check_flag);
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
3313 purge(NonClassType);
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3314 if (using_class_space()) {
12303
b960c9df4f11 8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents: 12302
diff changeset
3315 purge(ClassType);
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3316 }
10175
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
3317 }
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
3318
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3319 void Metaspace::print_on(outputStream* out) const {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3320 // Print both class virtual space counts and metaspace.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3321 if (Verbose) {
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3322 vsm()->print_on(out);
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3323 if (using_class_space()) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3324 class_vsm()->print_on(out);
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3325 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3326 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3327 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3328
7176
59c790074993 8003635: NPG: AsynchGetCallTrace broken by Method* virtual call
coleenp
parents: 6969
diff changeset
3329 bool Metaspace::contains(const void * ptr) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3330 if (MetaspaceShared::is_in_shared_space(ptr)) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3331 return true;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3332 }
7176
59c790074993 8003635: NPG: AsynchGetCallTrace broken by Method* virtual call
coleenp
parents: 6969
diff changeset
3333 // This is checked while unlocked. As long as the virtualspaces are added
59c790074993 8003635: NPG: AsynchGetCallTrace broken by Method* virtual call
coleenp
parents: 6969
diff changeset
3334 // at the end, the pointer will be in one of them. The virtual spaces
59c790074993 8003635: NPG: AsynchGetCallTrace broken by Method* virtual call
coleenp
parents: 6969
diff changeset
3335 // aren't deleted presently. When they are, some sort of locking might
59c790074993 8003635: NPG: AsynchGetCallTrace broken by Method* virtual call
coleenp
parents: 6969
diff changeset
3336 // be needed. Note, locking this can cause inversion problems with the
59c790074993 8003635: NPG: AsynchGetCallTrace broken by Method* virtual call
coleenp
parents: 6969
diff changeset
3337 // caller in MetaspaceObj::is_metadata() function.
10175
c23dbf0e8ab7 8011268: NPG: Free unused VirtualSpaceNodes
jmasa
parents: 10101
diff changeset
3338 return space_list()->contains(ptr) ||
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3339 (using_class_space() && class_space_list()->contains(ptr));
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3340 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3341
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3342 void Metaspace::verify() {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3343 vsm()->verify();
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3344 if (using_class_space()) {
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3345 class_vsm()->verify();
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3346 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3347 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3348
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3349 void Metaspace::dump(outputStream* const out) const {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3350 out->print_cr("\nVirtual space manager: " INTPTR_FORMAT, vsm());
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3351 vsm()->dump(out);
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3352 if (using_class_space()) {
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3353 out->print_cr("\nClass space manager: " INTPTR_FORMAT, class_vsm());
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3354 class_vsm()->dump(out);
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11966
diff changeset
3355 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
3356 }
12236
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3357
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3358 /////////////// Unit tests ///////////////
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3359
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3360 #ifndef PRODUCT
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3361
12306
03f493ce3a71 8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents: 12303
diff changeset
3362 class TestMetaspaceAuxTest : AllStatic {
12236
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3363 public:
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3364 static void test_reserved() {
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3365 size_t reserved = MetaspaceAux::reserved_bytes();
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3366
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3367 assert(reserved > 0, "assert");
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3368
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3369 size_t committed = MetaspaceAux::committed_bytes();
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3370 assert(committed <= reserved, "assert");
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3371
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3372 size_t reserved_metadata = MetaspaceAux::reserved_bytes(Metaspace::NonClassType);
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3373 assert(reserved_metadata > 0, "assert");
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3374 assert(reserved_metadata <= reserved, "assert");
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3375
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3376 if (UseCompressedClassPointers) {
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3377 size_t reserved_class = MetaspaceAux::reserved_bytes(Metaspace::ClassType);
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3378 assert(reserved_class > 0, "assert");
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3379 assert(reserved_class < reserved, "assert");
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3380 }
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3381 }
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3382
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3383 static void test_committed() {
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3384 size_t committed = MetaspaceAux::committed_bytes();
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3385
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3386 assert(committed > 0, "assert");
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3387
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3388 size_t reserved = MetaspaceAux::reserved_bytes();
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3389 assert(committed <= reserved, "assert");
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3390
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3391 size_t committed_metadata = MetaspaceAux::committed_bytes(Metaspace::NonClassType);
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3392 assert(committed_metadata > 0, "assert");
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3393 assert(committed_metadata <= committed, "assert");
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3394
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3395 if (UseCompressedClassPointers) {
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3396 size_t committed_class = MetaspaceAux::committed_bytes(Metaspace::ClassType);
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3397 assert(committed_class > 0, "assert");
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3398 assert(committed_class < committed, "assert");
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3399 }
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3400 }
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3401
12306
03f493ce3a71 8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents: 12303
diff changeset
3402 static void test_virtual_space_list_large_chunk() {
03f493ce3a71 8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents: 12303
diff changeset
3403 VirtualSpaceList* vs_list = new VirtualSpaceList(os::vm_allocation_granularity());
03f493ce3a71 8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents: 12303
diff changeset
3404 MutexLockerEx cl(SpaceManager::expand_lock(), Mutex::_no_safepoint_check_flag);
03f493ce3a71 8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents: 12303
diff changeset
3405 // A size larger than VirtualSpaceSize (256k) and add one page to make it _not_ be
03f493ce3a71 8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents: 12303
diff changeset
3406 // vm_allocation_granularity aligned on Windows.
03f493ce3a71 8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents: 12303
diff changeset
3407 size_t large_size = (size_t)(2*256*K + (os::vm_page_size()/BytesPerWord));
03f493ce3a71 8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents: 12303
diff changeset
3408 large_size += (os::vm_page_size()/BytesPerWord);
03f493ce3a71 8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents: 12303
diff changeset
3409 vs_list->get_new_chunk(large_size, large_size, 0);
03f493ce3a71 8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents: 12303
diff changeset
3410 }
03f493ce3a71 8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents: 12303
diff changeset
3411
12236
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3412 static void test() {
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3413 test_reserved();
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3414 test_committed();
12306
03f493ce3a71 8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents: 12303
diff changeset
3415 test_virtual_space_list_large_chunk();
12236
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3416 }
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3417 };
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3418
12306
03f493ce3a71 8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents: 12303
diff changeset
3419 void TestMetaspaceAux_test() {
03f493ce3a71 8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents: 12303
diff changeset
3420 TestMetaspaceAuxTest::test();
12236
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3421 }
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3422
c4c768305a8f 8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents: 12235
diff changeset
3423 #endif