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