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