Mercurial > hg > graal-compiler
annotate src/share/vm/memory/metaspace.cpp @ 9809:a8a5d5832def
first step towards extensibility of the escape analysis phase
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Fri, 17 May 2013 16:47:13 +0200 |
parents | 6574f999e0cf |
children | df254344edf1 |
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" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
38 #include "runtime/mutex.hpp" |
7176
59c790074993
8003635: NPG: AsynchGetCallTrace broken by Method* virtual call
coleenp
parents:
6969
diff
changeset
|
39 #include "runtime/orderAccess.hpp" |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
40 #include "services/memTracker.hpp" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
41 #include "utilities/copy.hpp" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
42 #include "utilities/debug.hpp" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
43 |
6885 | 44 typedef BinaryTreeDictionary<Metablock, FreeList> BlockTreeDictionary; |
45 typedef BinaryTreeDictionary<Metachunk, FreeList> ChunkTreeDictionary; | |
6969
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
46 // 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
|
47 // the free chunk lists |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
48 const bool metaspace_slow_verify = false; |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
49 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
50 |
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 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
58 // Used in declarations in SpaceManager and ChunkManager |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
59 enum ChunkIndex { |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
60 ZeroIndex = 0, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
61 SpecializedIndex = ZeroIndex, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
62 SmallIndex = SpecializedIndex + 1, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
63 MediumIndex = SmallIndex + 1, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
64 HumongousIndex = MediumIndex + 1, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
65 NumberOfFreeLists = 3, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
66 NumberOfInUseLists = 4 |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
67 }; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
68 |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
69 enum ChunkSizes { // in words. |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
70 ClassSpecializedChunk = 128, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
71 SpecializedChunk = 128, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
72 ClassSmallChunk = 256, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
73 SmallChunk = 512, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
74 ClassMediumChunk = 1 * K, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
75 MediumChunk = 8 * K, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
76 HumongousChunkGranularity = 8 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
77 }; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
78 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
79 static ChunkIndex next_chunk_index(ChunkIndex i) { |
6885 | 80 assert(i < NumberOfInUseLists, "Out of bound"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
81 return (ChunkIndex) (i+1); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
82 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
83 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
84 // 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
|
85 // the default MetaspaceSize before argument processing was being |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
86 // 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
|
87 // 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
|
88 // now. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
89 size_t MetaspaceGC::_capacity_until_GC = 0; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
90 bool MetaspaceGC::_expand_after_GC = false; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
91 uint MetaspaceGC::_shrink_factor = 0; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
92 bool MetaspaceGC::_should_concurrent_collect = false; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
93 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
94 // 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
|
95 // |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
96 // Metachunk are allocated out of MetadataVirtualspaces and once |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
97 // 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
|
98 // the MetadataVirtualspaces from which it was allocated. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
99 // |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
100 // Each SpaceManager maintains a |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
101 // 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
|
102 // 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
|
103 // 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
|
104 // reused from there. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
105 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
106 // Pointer to list of Metachunks. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
107 class ChunkList VALUE_OBJ_CLASS_SPEC { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
108 // List of free chunks |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
109 Metachunk* _head; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
110 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
111 public: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
112 // Constructor |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
113 ChunkList() : _head(NULL) {} |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
114 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
115 // Accessors |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
116 Metachunk* head() { return _head; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
117 void set_head(Metachunk* v) { _head = v; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
118 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
119 // Link at head of the list |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
120 void add_at_head(Metachunk* head, Metachunk* tail); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
121 void add_at_head(Metachunk* head); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
122 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
123 size_t sum_list_size(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
124 size_t sum_list_count(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
125 size_t sum_list_capacity(); |
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 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
128 // Manages the global free lists of chunks. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
129 // 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
|
130 // count that includes all three |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
131 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
132 class ChunkManager VALUE_OBJ_CLASS_SPEC { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
133 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
134 // Free list of chunks of different sizes. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
135 // SmallChunk |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
136 // MediumChunk |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
137 // HumongousChunk |
6885 | 138 ChunkList _free_chunks[NumberOfFreeLists]; |
139 | |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
140 |
6885 | 141 // HumongousChunk |
142 ChunkTreeDictionary _humongous_dictionary; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
143 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
144 // ChunkManager in all lists of this type |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
145 size_t _free_chunks_total; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
146 size_t _free_chunks_count; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
147 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
148 void dec_free_chunks_total(size_t v) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
149 assert(_free_chunks_count > 0 && |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
150 _free_chunks_total > 0, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
151 "About to go negative"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
152 Atomic::add_ptr(-1, &_free_chunks_count); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
153 jlong minus_v = (jlong) - (jlong) v; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
154 Atomic::add_ptr(minus_v, &_free_chunks_total); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
155 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
156 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
157 // Debug support |
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 size_t sum_free_chunks(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
160 size_t sum_free_chunks_count(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
161 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
162 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
|
163 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
|
164 if (metaspace_slow_verify) { |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
165 locked_verify_free_chunks_total(); |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
166 } |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
167 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
168 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
|
169 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
|
170 if (metaspace_slow_verify) { |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
171 locked_verify_free_chunks_count(); |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
172 } |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
173 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
174 void verify_free_chunks_count(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
175 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
176 public: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
177 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
178 ChunkManager() : _free_chunks_total(0), _free_chunks_count(0) {} |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
179 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
180 // 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
|
181 Metachunk* chunk_freelist_allocate(size_t word_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
182 void chunk_freelist_deallocate(Metachunk* chunk); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
183 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
184 // 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
|
185 // for special, small, medium, and humongous chunks. |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
186 static ChunkIndex list_index(size_t size); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
187 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
188 // Total of the space in the free chunks list |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
189 size_t free_chunks_total(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
190 size_t free_chunks_total_in_bytes(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
191 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
192 // Number of chunks in the free chunks list |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
193 size_t free_chunks_count(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
194 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
195 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
|
196 Atomic::add_ptr(count, &_free_chunks_count); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
197 Atomic::add_ptr(v, &_free_chunks_total); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
198 } |
6885 | 199 ChunkTreeDictionary* humongous_dictionary() { |
200 return &_humongous_dictionary; | |
201 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
202 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
203 ChunkList* free_chunks(ChunkIndex index); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
204 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
205 // Returns the list for the given chunk word size. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
206 ChunkList* find_free_chunks_list(size_t word_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
207 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
208 // Add and remove from a list by size. Selects |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
209 // list based on size of chunk. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
210 void free_chunks_put(Metachunk* chuck); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
211 Metachunk* free_chunks_get(size_t chunk_word_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
212 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
213 // Debug support |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
214 void verify(); |
6969
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
215 void slow_verify() { |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
216 if (metaspace_slow_verify) { |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
217 verify(); |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
218 } |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
219 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
220 void locked_verify(); |
6969
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
221 void slow_locked_verify() { |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
222 if (metaspace_slow_verify) { |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
223 locked_verify(); |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
224 } |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
225 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
226 void verify_free_chunks_total(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
227 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
228 void locked_print_free_chunks(outputStream* st); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
229 void locked_print_sum_free_chunks(outputStream* st); |
6885 | 230 |
231 void print_on(outputStream* st); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
232 }; |
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 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
235 // 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
|
236 // to the allocation of a quantum of metadata). |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
237 class BlockFreelist VALUE_OBJ_CLASS_SPEC { |
6885 | 238 BlockTreeDictionary* _dictionary; |
239 static Metablock* initialize_free_chunk(MetaWord* p, size_t word_size); | |
240 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
241 // Accessors |
6885 | 242 BlockTreeDictionary* dictionary() const { return _dictionary; } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
243 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
244 public: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
245 BlockFreelist(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
246 ~BlockFreelist(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
247 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
248 // Get and return a block to the free list |
6885 | 249 MetaWord* get_block(size_t word_size); |
250 void return_block(MetaWord* p, size_t word_size); | |
251 | |
252 size_t total_size() { | |
253 if (dictionary() == NULL) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
254 return 0; |
6885 | 255 } else { |
256 return dictionary()->total_size(); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
257 } |
6885 | 258 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
259 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
260 void print_on(outputStream* st) const; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
261 }; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
262 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
263 class VirtualSpaceNode : public CHeapObj<mtClass> { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
264 friend class VirtualSpaceList; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
265 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
266 // Link to next VirtualSpaceNode |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
267 VirtualSpaceNode* _next; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
268 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
269 // total in the VirtualSpace |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
270 MemRegion _reserved; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
271 ReservedSpace _rs; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
272 VirtualSpace _virtual_space; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
273 MetaWord* _top; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
274 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
275 // Convenience functions for logical bottom and end |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
276 MetaWord* bottom() const { return (MetaWord*) _virtual_space.low(); } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
277 MetaWord* end() const { return (MetaWord*) _virtual_space.high(); } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
278 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
279 // Convenience functions to access the _virtual_space |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
280 char* low() const { return virtual_space()->low(); } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
281 char* high() const { return virtual_space()->high(); } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
282 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
283 public: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
284 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
285 VirtualSpaceNode(size_t byte_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
286 VirtualSpaceNode(ReservedSpace rs) : _top(NULL), _next(NULL), _rs(rs) {} |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
287 ~VirtualSpaceNode(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
288 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
289 // address of next available space in _virtual_space; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
290 // Accessors |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
291 VirtualSpaceNode* next() { return _next; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
292 void set_next(VirtualSpaceNode* v) { _next = v; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
293 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
294 void set_reserved(MemRegion const v) { _reserved = v; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
295 void set_top(MetaWord* v) { _top = v; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
296 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
297 // Accessors |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
298 MemRegion* reserved() { return &_reserved; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
299 VirtualSpace* virtual_space() const { return (VirtualSpace*) &_virtual_space; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
300 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
301 // Returns true if "word_size" is available in the virtual space |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
302 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
|
303 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
304 MetaWord* top() const { return _top; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
305 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
|
306 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
307 // 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
|
308 size_t used_words_in_vs() const; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
309 size_t capacity_words_in_vs() const; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
310 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
311 bool initialize(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
312 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
313 // get space from the virtual space |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
314 Metachunk* take_from_committed(size_t chunk_word_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
315 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
316 // 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
|
317 Metachunk* get_chunk_vs(size_t chunk_word_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
318 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
|
319 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
320 // 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
|
321 // to Virtualspace |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
322 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
|
323 bool shrink_by(size_t words); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
324 |
7185
90273fc0a981
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
6969
diff
changeset
|
325 #ifdef ASSERT |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
326 // Debug support |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
327 static void verify_virtual_space_total(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
328 static void verify_virtual_space_count(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
329 void mangle(); |
7185
90273fc0a981
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
6969
diff
changeset
|
330 #endif |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
331 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
332 void print_on(outputStream* st) const; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
333 }; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
334 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
335 // byte_size is the size of the associated virtualspace. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
336 VirtualSpaceNode::VirtualSpaceNode(size_t byte_size) : _top(NULL), _next(NULL), _rs(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
|
337 // 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
|
338 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
|
339 |
8804
91bf0bdae37b
8008217: CDS: Class data sharing limits the malloc heap on Solaris
coleenp
parents:
8754
diff
changeset
|
340 // 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
|
341 // 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
|
342 // memory addresses don't conflict. |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
343 if (DumpSharedSpaces) { |
8804
91bf0bdae37b
8008217: CDS: Class data sharing limits the malloc heap on Solaris
coleenp
parents:
8754
diff
changeset
|
344 char* shared_base = (char*)SharedBaseAddress; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
345 _rs = ReservedSpace(byte_size, 0, false, shared_base, 0); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
346 if (_rs.is_reserved()) { |
8804
91bf0bdae37b
8008217: CDS: Class data sharing limits the malloc heap on Solaris
coleenp
parents:
8754
diff
changeset
|
347 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
|
348 } else { |
8804
91bf0bdae37b
8008217: CDS: Class data sharing limits the malloc heap on Solaris
coleenp
parents:
8754
diff
changeset
|
349 // 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
|
350 _rs = ReservedSpace(byte_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
351 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
352 MetaspaceShared::set_shared_rs(&_rs); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
353 } else { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
354 _rs = ReservedSpace(byte_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
355 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
356 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
357 MemTracker::record_virtual_memory_type((address)_rs.base(), mtClass); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
358 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
359 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
360 // List of VirtualSpaces for metadata allocation. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
361 // 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
|
362 // for total space in the VirtualSpace. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
363 class VirtualSpaceList : public CHeapObj<mtClass> { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
364 friend class VirtualSpaceNode; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
365 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
366 enum VirtualSpaceSizes { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
367 VirtualSpaceSize = 256 * K |
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 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
370 // Global list of virtual spaces |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
371 // Head of the list |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
372 VirtualSpaceNode* _virtual_space_list; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
373 // virtual space currently being used for allocations |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
374 VirtualSpaceNode* _current_virtual_space; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
375 // Free chunk list for all other metadata |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
376 ChunkManager _chunk_manager; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
377 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
378 // 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
|
379 // 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
|
380 bool _is_class; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
381 bool can_grow() const { return !is_class() || !UseCompressedKlassPointers; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
382 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
383 // 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
|
384 size_t _virtual_space_total; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
385 size_t _virtual_space_count; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
386 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
387 ~VirtualSpaceList(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
388 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
389 VirtualSpaceNode* virtual_space_list() const { return _virtual_space_list; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
390 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
391 void set_virtual_space_list(VirtualSpaceNode* v) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
392 _virtual_space_list = v; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
393 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
394 void set_current_virtual_space(VirtualSpaceNode* v) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
395 _current_virtual_space = v; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
396 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
397 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
398 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
|
399 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
400 // 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
|
401 // 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
|
402 // 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
|
403 bool grow_vs(size_t vs_word_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
404 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
405 public: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
406 VirtualSpaceList(size_t word_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
407 VirtualSpaceList(ReservedSpace rs); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
408 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
409 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
|
410 size_t grow_chunks_by_words, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
411 size_t medium_chunk_bunch); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
412 |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
413 // 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
|
414 // 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
|
415 // class loader and anonymous class loader. |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
416 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
|
417 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
418 VirtualSpaceNode* current_virtual_space() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
419 return _current_virtual_space; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
420 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
421 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
422 ChunkManager* chunk_manager() { return &_chunk_manager; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
423 bool is_class() const { return _is_class; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
424 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
425 // Allocate the first virtualspace. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
426 void initialize(size_t word_size); |
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 size_t virtual_space_total() { return _virtual_space_total; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
429 void inc_virtual_space_total(size_t v) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
430 Atomic::add_ptr(v, &_virtual_space_total); |
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 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
433 size_t virtual_space_count() { return _virtual_space_count; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
434 void inc_virtual_space_count() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
435 Atomic::inc_ptr(&_virtual_space_count); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
436 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
437 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
438 // 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
|
439 // These are global values shared by all Metaspaces |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
440 size_t capacity_words_sum(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
441 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
|
442 size_t used_words_sum(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
443 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
|
444 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
445 bool contains(const void *ptr); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
446 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
447 void print_on(outputStream* st) const; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
448 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
449 class VirtualSpaceListIterator : public StackObj { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
450 VirtualSpaceNode* _virtual_spaces; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
451 public: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
452 VirtualSpaceListIterator(VirtualSpaceNode* virtual_spaces) : |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
453 _virtual_spaces(virtual_spaces) {} |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
454 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
455 bool repeat() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
456 return _virtual_spaces != NULL; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
457 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
458 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
459 VirtualSpaceNode* get_next() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
460 VirtualSpaceNode* result = _virtual_spaces; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
461 if (_virtual_spaces != NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
462 _virtual_spaces = _virtual_spaces->next(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
463 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
464 return result; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
465 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
466 }; |
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 class Metadebug : AllStatic { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
470 // Debugging support for Metaspaces |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
471 static int _deallocate_block_a_lot_count; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
472 static int _deallocate_chunk_a_lot_count; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
473 static int _allocation_fail_alot_count; |
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 public: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
476 static int deallocate_block_a_lot_count() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
477 return _deallocate_block_a_lot_count; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
478 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
479 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
|
480 _deallocate_block_a_lot_count = v; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
481 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
482 static void inc_deallocate_block_a_lot_count() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
483 _deallocate_block_a_lot_count++; |
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 static int deallocate_chunk_a_lot_count() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
486 return _deallocate_chunk_a_lot_count; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
487 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
488 static void reset_deallocate_chunk_a_lot_count() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
489 _deallocate_chunk_a_lot_count = 1; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
490 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
491 static void inc_deallocate_chunk_a_lot_count() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
492 _deallocate_chunk_a_lot_count++; |
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 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
495 static void init_allocation_fail_alot_count(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
496 #ifdef ASSERT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
497 static bool test_metadata_failure(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
498 #endif |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
499 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
500 static void deallocate_chunk_a_lot(SpaceManager* sm, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
501 size_t chunk_word_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
502 static void deallocate_block_a_lot(SpaceManager* sm, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
503 size_t chunk_word_size); |
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 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
507 int Metadebug::_deallocate_block_a_lot_count = 0; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
508 int Metadebug::_deallocate_chunk_a_lot_count = 0; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
509 int Metadebug::_allocation_fail_alot_count = 0; |
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 // SpaceManager - used by Metaspace to handle allocations |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
512 class SpaceManager : public CHeapObj<mtClass> { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
513 friend class Metaspace; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
514 friend class Metadebug; |
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 private: |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
517 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
518 // protects allocations and contains. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
519 Mutex* const _lock; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
520 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
521 // Chunk related size |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
522 size_t _medium_chunk_bunch; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
523 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
524 // List of chunks in use by this SpaceManager. Allocations |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
525 // 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
|
526 // chunks when the SpaceManager is freed. |
6885 | 527 Metachunk* _chunks_in_use[NumberOfInUseLists]; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
528 Metachunk* _current_chunk; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
529 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
530 // Virtual space where allocation comes from. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
531 VirtualSpaceList* _vs_list; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
532 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
533 // Number of small chunks to allocate to a manager |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
534 // If class space manager, small chunks are unlimited |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
535 static uint const _small_chunk_limit; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
536 bool has_small_chunk_limit() { return !vs_list()->is_class(); } |
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 // Sum of all space in allocated chunks |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
539 size_t _allocation_total; |
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 // Free lists of blocks are per SpaceManager since they |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
542 // 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
|
543 // 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
|
544 // the class loader using the SpaceManager is collected. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
545 BlockFreelist _block_freelists; |
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 // protects virtualspace and chunk expansions |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
548 static const char* _expand_lock_name; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
549 static const int _expand_lock_rank; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
550 static Mutex* const _expand_lock; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
551 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
552 private: |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
553 // Accessors |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
554 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
|
555 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
|
556 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
557 BlockFreelist* block_freelists() const { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
558 return (BlockFreelist*) &_block_freelists; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
559 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
560 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
561 VirtualSpaceList* vs_list() const { return _vs_list; } |
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 Metachunk* current_chunk() const { return _current_chunk; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
564 void set_current_chunk(Metachunk* v) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
565 _current_chunk = v; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
566 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
567 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
568 Metachunk* find_current_chunk(size_t word_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
569 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
570 // Add chunk to the list of chunks in use |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
571 void add_chunk(Metachunk* v, bool make_current); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
572 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
573 Mutex* lock() const { return _lock; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
574 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
575 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
|
576 |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
577 protected: |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
578 void initialize(); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
579 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
580 public: |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
581 SpaceManager(Mutex* lock, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
582 VirtualSpaceList* vs_list); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
583 ~SpaceManager(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
584 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
585 enum ChunkMultiples { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
586 MediumChunkMultiple = 4 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
587 }; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
588 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
589 // Accessors |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
590 size_t specialized_chunk_size() { return SpecializedChunk; } |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
591 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
|
592 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
|
593 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
|
594 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
595 size_t allocation_total() const { return _allocation_total; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
596 void inc_allocation_total(size_t v) { Atomic::add_ptr(v, &_allocation_total); } |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
597 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
|
598 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
599 static Mutex* expand_lock() { return _expand_lock; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
600 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
601 // Set the sizes for the initial chunks. |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
602 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
|
603 size_t* chunk_word_size, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
604 size_t* class_chunk_word_size); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
605 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
606 size_t sum_capacity_in_chunks_in_use() const; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
607 size_t sum_used_in_chunks_in_use() const; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
608 size_t sum_free_in_chunks_in_use() const; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
609 size_t sum_waste_in_chunks_in_use() const; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
610 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
|
611 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
612 size_t sum_count_in_chunks_in_use(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
613 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
|
614 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
615 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
|
616 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
617 // Block allocation and deallocation. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
618 // Allocates a block from the current chunk |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
619 MetaWord* allocate(size_t word_size); |
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 // Helper for allocations |
6885 | 622 MetaWord* allocate_work(size_t word_size); |
6725
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 // Returns a block to the per manager freelist |
6885 | 625 void deallocate(MetaWord* p, size_t word_size); |
6725
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 // 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
|
628 // returned chunk size (for expanding space for chunk allocation). |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
629 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
|
630 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
631 // Called when an allocation from the current chunk fails. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
632 // 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
|
633 // and allocates from that chunk. |
6885 | 634 MetaWord* grow_and_allocate(size_t word_size); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
635 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
636 // debugging support. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
637 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
638 void dump(outputStream* const out) const; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
639 void print_on(outputStream* st) const; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
640 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
|
641 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
642 void verify(); |
7208
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
7187
diff
changeset
|
643 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
|
644 NOT_PRODUCT(void mangle_freed_chunks();) |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
645 #ifdef ASSERT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
646 void verify_allocation_total(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
647 #endif |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
648 }; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
649 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
650 uint const SpaceManager::_small_chunk_limit = 4; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
651 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
652 const char* SpaceManager::_expand_lock_name = |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
653 "SpaceManager chunk allocation lock"; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
654 const int SpaceManager::_expand_lock_rank = Monitor::leaf - 1; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
655 Mutex* const SpaceManager::_expand_lock = |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
656 new Mutex(SpaceManager::_expand_lock_rank, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
657 SpaceManager::_expand_lock_name, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
658 Mutex::_allow_vm_block_flag); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
659 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
660 // BlockFreelist methods |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
661 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
662 BlockFreelist::BlockFreelist() : _dictionary(NULL) {} |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
663 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
664 BlockFreelist::~BlockFreelist() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
665 if (_dictionary != NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
666 if (Verbose && TraceMetadataChunkAllocation) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
667 _dictionary->print_free_lists(gclog_or_tty); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
668 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
669 delete _dictionary; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
670 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
671 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
672 |
6885 | 673 Metablock* BlockFreelist::initialize_free_chunk(MetaWord* p, size_t word_size) { |
674 Metablock* block = (Metablock*) p; | |
675 block->set_word_size(word_size); | |
676 block->set_prev(NULL); | |
677 block->set_next(NULL); | |
678 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
679 return block; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
680 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
681 |
6885 | 682 void BlockFreelist::return_block(MetaWord* p, size_t word_size) { |
683 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
|
684 if (dictionary() == NULL) { |
6885 | 685 _dictionary = new BlockTreeDictionary(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
686 } |
6885 | 687 dictionary()->return_chunk(free_chunk); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
688 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
689 |
6885 | 690 MetaWord* BlockFreelist::get_block(size_t word_size) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
691 if (dictionary() == NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
692 return NULL; |
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 |
6885 | 695 if (word_size < TreeChunk<Metablock, FreeList>::min_size()) { |
696 // Dark matter. Too small for dictionary. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
697 return NULL; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
698 } |
6885 | 699 |
700 Metablock* free_block = | |
701 dictionary()->get_chunk(word_size, FreeBlockDictionary<Metablock>::exactly); | |
702 if (free_block == NULL) { | |
703 return NULL; | |
704 } | |
705 | |
706 return (MetaWord*) free_block; | |
6725
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 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
709 void BlockFreelist::print_on(outputStream* st) const { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
710 if (dictionary() == NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
711 return; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
712 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
713 dictionary()->print_free_lists(st); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
714 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
715 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
716 // VirtualSpaceNode methods |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
717 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
718 VirtualSpaceNode::~VirtualSpaceNode() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
719 _rs.release(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
720 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
721 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
722 size_t VirtualSpaceNode::used_words_in_vs() const { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
723 return pointer_delta(top(), bottom(), sizeof(MetaWord)); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
724 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
725 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
726 // Space committed in the VirtualSpace |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
727 size_t VirtualSpaceNode::capacity_words_in_vs() const { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
728 return pointer_delta(end(), bottom(), sizeof(MetaWord)); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
729 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
730 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
731 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
732 // Allocates the chunk from the virtual space only. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
733 // 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
|
734 // chunks removed here are necessarily used for allocation. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
735 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
|
736 // Bottom of the new chunk |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
737 MetaWord* chunk_limit = top(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
738 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
|
739 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
740 if (!is_available(chunk_word_size)) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
741 if (TraceMetadataChunkAllocation) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
742 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
|
743 // 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
|
744 print_on(tty); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
745 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
746 return NULL; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
747 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
748 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
749 // 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
|
750 inc_top(chunk_word_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
751 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
752 // Point the chunk at the space |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
753 Metachunk* result = Metachunk::initialize(chunk_limit, chunk_word_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
754 return result; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
755 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
756 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
757 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
758 // 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
|
759 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
|
760 size_t bytes = words * BytesPerWord; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
761 bool result = virtual_space()->expand_by(bytes, pre_touch); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
762 if (TraceMetavirtualspaceAllocation && !result) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
763 gclog_or_tty->print_cr("VirtualSpaceNode::expand_by() failed " |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
764 "for byte size " SIZE_FORMAT, bytes); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
765 virtual_space()->print(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
766 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
767 return result; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
768 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
769 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
770 // 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
|
771 bool VirtualSpaceNode::shrink_by(size_t words) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
772 size_t bytes = words * BytesPerWord; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
773 virtual_space()->shrink_by(bytes); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
774 return true; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
775 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
776 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
777 // Add another chunk to the chunk list. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
778 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
779 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
|
780 assert_lock_strong(SpaceManager::expand_lock()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
781 Metachunk* result = NULL; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
782 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
783 return take_from_committed(chunk_word_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
784 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
785 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
786 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
|
787 assert_lock_strong(SpaceManager::expand_lock()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
788 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
789 Metachunk* new_chunk = get_chunk_vs(chunk_word_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
790 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
791 if (new_chunk == NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
792 // 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
|
793 // allocated so committing more here can be expected. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
794 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
|
795 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
|
796 page_size_words); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
797 expand_by(aligned_expand_vs_by_words, false); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
798 new_chunk = get_chunk_vs(chunk_word_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
799 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
800 return new_chunk; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
801 } |
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 bool VirtualSpaceNode::initialize() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
804 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
805 if (!_rs.is_reserved()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
806 return false; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
807 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
808 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
809 // 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
|
810 // 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
|
811 // space. |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
812 size_t committed_byte_size = 0; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
813 bool result = virtual_space()->initialize(_rs, committed_byte_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
814 if (result) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
815 set_top((MetaWord*)virtual_space()->low()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
816 set_reserved(MemRegion((HeapWord*)_rs.base(), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
817 (HeapWord*)(_rs.base() + _rs.size()))); |
6726
03049e0e8544
7195823: NPG: CMS reserved() doesn't match _rs.base().
coleenp
parents:
6725
diff
changeset
|
818 |
03049e0e8544
7195823: NPG: CMS reserved() doesn't match _rs.base().
coleenp
parents:
6725
diff
changeset
|
819 assert(reserved()->start() == (HeapWord*) _rs.base(), |
03049e0e8544
7195823: NPG: CMS reserved() doesn't match _rs.base().
coleenp
parents:
6725
diff
changeset
|
820 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
|
821 " != " PTR_FORMAT, reserved()->start(), _rs.base())); |
03049e0e8544
7195823: NPG: CMS reserved() doesn't match _rs.base().
coleenp
parents:
6725
diff
changeset
|
822 assert(reserved()->word_size() == _rs.size() / BytesPerWord, |
03049e0e8544
7195823: NPG: CMS reserved() doesn't match _rs.base().
coleenp
parents:
6725
diff
changeset
|
823 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
|
824 " != " SIZE_FORMAT, reserved()->word_size(), |
03049e0e8544
7195823: NPG: CMS reserved() doesn't match _rs.base().
coleenp
parents:
6725
diff
changeset
|
825 _rs.size() / BytesPerWord)); |
6725
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 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
828 return result; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
829 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
830 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
831 void VirtualSpaceNode::print_on(outputStream* st) const { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
832 size_t used = used_words_in_vs(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
833 size_t capacity = capacity_words_in_vs(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
834 VirtualSpace* vs = virtual_space(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
835 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
|
836 "[" PTR_FORMAT ", " PTR_FORMAT ", " |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
837 PTR_FORMAT ", " PTR_FORMAT ")", |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
838 vs, capacity / K, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
839 capacity == 0 ? 0 : used * 100 / capacity, |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
840 bottom(), top(), end(), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
841 vs->high_boundary()); |
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 |
7185
90273fc0a981
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
6969
diff
changeset
|
844 #ifdef ASSERT |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
845 void VirtualSpaceNode::mangle() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
846 size_t word_size = capacity_words_in_vs(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
847 Copy::fill_to_words((HeapWord*) low(), word_size, 0xf1f1f1f1); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
848 } |
7185
90273fc0a981
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
6969
diff
changeset
|
849 #endif // ASSERT |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
850 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
851 // VirtualSpaceList methods |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
852 // Space allocated from the VirtualSpace |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
853 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
854 VirtualSpaceList::~VirtualSpaceList() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
855 VirtualSpaceListIterator iter(virtual_space_list()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
856 while (iter.repeat()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
857 VirtualSpaceNode* vsl = iter.get_next(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
858 delete vsl; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
859 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
860 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
861 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
862 size_t VirtualSpaceList::used_words_sum() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
863 size_t allocated_by_vs = 0; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
864 VirtualSpaceListIterator iter(virtual_space_list()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
865 while (iter.repeat()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
866 VirtualSpaceNode* vsl = iter.get_next(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
867 // Sum used region [bottom, top) in each virtualspace |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
868 allocated_by_vs += vsl->used_words_in_vs(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
869 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
870 assert(allocated_by_vs >= chunk_manager()->free_chunks_total(), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
871 err_msg("Total in free chunks " SIZE_FORMAT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
872 " greater than total from virtual_spaces " SIZE_FORMAT, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
873 allocated_by_vs, chunk_manager()->free_chunks_total())); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
874 size_t used = |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
875 allocated_by_vs - chunk_manager()->free_chunks_total(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
876 return used; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
877 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
878 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
879 // Space available in all MetadataVirtualspaces allocated |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
880 // 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
|
881 // of chunks allocated out of all the MetadataVirtualspaces. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
882 size_t VirtualSpaceList::capacity_words_sum() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
883 size_t capacity = 0; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
884 VirtualSpaceListIterator iter(virtual_space_list()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
885 while (iter.repeat()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
886 VirtualSpaceNode* vsl = iter.get_next(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
887 capacity += vsl->capacity_words_in_vs(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
888 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
889 return capacity; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
890 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
891 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
892 VirtualSpaceList::VirtualSpaceList(size_t word_size ) : |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
893 _is_class(false), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
894 _virtual_space_list(NULL), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
895 _current_virtual_space(NULL), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
896 _virtual_space_total(0), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
897 _virtual_space_count(0) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
898 MutexLockerEx cl(SpaceManager::expand_lock(), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
899 Mutex::_no_safepoint_check_flag); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
900 bool initialization_succeeded = grow_vs(word_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
901 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
902 assert(initialization_succeeded, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
903 " VirtualSpaceList initialization should not fail"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
904 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
905 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
906 VirtualSpaceList::VirtualSpaceList(ReservedSpace rs) : |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
907 _is_class(true), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
908 _virtual_space_list(NULL), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
909 _current_virtual_space(NULL), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
910 _virtual_space_total(0), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
911 _virtual_space_count(0) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
912 MutexLockerEx cl(SpaceManager::expand_lock(), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
913 Mutex::_no_safepoint_check_flag); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
914 VirtualSpaceNode* class_entry = new VirtualSpaceNode(rs); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
915 bool succeeded = class_entry->initialize(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
916 assert(succeeded, " VirtualSpaceList initialization should not fail"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
917 link_vs(class_entry, rs.size()/BytesPerWord); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
918 } |
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 // 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
|
921 bool VirtualSpaceList::grow_vs(size_t vs_word_size) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
922 assert_lock_strong(SpaceManager::expand_lock()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
923 if (vs_word_size == 0) { |
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 // Reserve the space |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
927 size_t vs_byte_size = vs_word_size * BytesPerWord; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
928 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
|
929 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
930 // Allocate the meta virtual space and initialize it. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
931 VirtualSpaceNode* new_entry = new VirtualSpaceNode(vs_byte_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
932 if (!new_entry->initialize()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
933 delete new_entry; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
934 return false; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
935 } else { |
7176
59c790074993
8003635: NPG: AsynchGetCallTrace broken by Method* virtual call
coleenp
parents:
6969
diff
changeset
|
936 // ensure lock-free iteration sees fully initialized node |
59c790074993
8003635: NPG: AsynchGetCallTrace broken by Method* virtual call
coleenp
parents:
6969
diff
changeset
|
937 OrderAccess::storestore(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
938 link_vs(new_entry, vs_word_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
939 return true; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
940 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
941 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
942 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
943 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
|
944 if (virtual_space_list() == NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
945 set_virtual_space_list(new_entry); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
946 } else { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
947 current_virtual_space()->set_next(new_entry); |
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 set_current_virtual_space(new_entry); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
950 inc_virtual_space_total(vs_word_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
951 inc_virtual_space_count(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
952 #ifdef ASSERT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
953 new_entry->mangle(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
954 #endif |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
955 if (TraceMetavirtualspaceAllocation && Verbose) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
956 VirtualSpaceNode* vsl = current_virtual_space(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
957 vsl->print_on(tty); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
958 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
959 } |
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 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
|
962 size_t grow_chunks_by_words, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
963 size_t medium_chunk_bunch) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
964 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
965 // Get a chunk from the chunk freelist |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
966 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
|
967 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
968 // Allocate a chunk out of the current virtual space. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
969 if (next == NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
970 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
|
971 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
972 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
973 if (next == NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
974 // 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
|
975 // more space. |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
976 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
|
977 grow_chunks_by_words); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
978 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
|
979 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
|
980 page_size_words); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
981 bool vs_expanded = |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
982 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
|
983 if (!vs_expanded) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
984 // Should the capacity of the metaspaces be expanded for |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
985 // 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
|
986 // 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
|
987 if (can_grow() && MetaspaceGC::should_expand(this, word_size)) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
988 // Get another virtual space. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
989 size_t grow_vs_words = |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
990 MAX2((size_t)VirtualSpaceSize, aligned_expand_vs_by_words); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
991 if (grow_vs(grow_vs_words)) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
992 // 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
|
993 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
|
994 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
995 } else { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
996 // Allocation will fail and induce a GC |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
997 if (TraceMetadataChunkAllocation && Verbose) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
998 gclog_or_tty->print_cr("VirtualSpaceList::get_new_chunk():" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
999 " Fail instead of expand the metaspace"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1000 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1001 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1002 } else { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1003 // The virtual space expanded, get a new chunk |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1004 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
|
1005 assert(next != NULL, "Just expanded, should succeed"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1006 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1007 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1008 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1009 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
|
1010 "New chunk is still on some list"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1011 return next; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1012 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1013 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1014 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
|
1015 size_t chunk_bunch) { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1016 // Get a chunk from the chunk freelist |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1017 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
|
1018 chunk_word_size, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1019 chunk_bunch); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1020 return new_chunk; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1021 } |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1022 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1023 void VirtualSpaceList::print_on(outputStream* st) const { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1024 if (TraceMetadataChunkAllocation && Verbose) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1025 VirtualSpaceListIterator iter(virtual_space_list()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1026 while (iter.repeat()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1027 VirtualSpaceNode* node = iter.get_next(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1028 node->print_on(st); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1029 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1030 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1031 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1032 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1033 bool VirtualSpaceList::contains(const void *ptr) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1034 VirtualSpaceNode* list = virtual_space_list(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1035 VirtualSpaceListIterator iter(list); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1036 while (iter.repeat()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1037 VirtualSpaceNode* node = iter.get_next(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1038 if (node->reserved()->contains(ptr)) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1039 return true; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1040 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1041 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1042 return false; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1043 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1044 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1045 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1046 // MetaspaceGC methods |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1047 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1048 // VM_CollectForMetadataAllocation is the vm operation used to GC. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1049 // 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
|
1050 // 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
|
1051 // 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
|
1052 // 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
|
1053 // gen had bounds, MinMetaspaceExpansion and MaxMetaspaceExpansion. The |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1054 // 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
|
1055 // |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1056 // 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
|
1057 // resize the capacity of the metaspaces. The current implementation |
8040
a83cd101fd62
8005452: NPG: Create new flags for Metaspace resizing policy
jmasa
parents:
8007
diff
changeset
|
1058 // is based on the flags MinMetaspaceFreeRatio and MaxHeapFreeRatio used |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1059 // to resize the Java heap by some GC's. New flags can be implemented |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1060 // if really needed. MinHeapFreeRatio is used to calculate how much |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1061 // 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
|
1062 // 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
|
1063 // 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
|
1064 // the HWM. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1065 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1066 // 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
|
1067 // Increase by a minimum amount (MinMetaspaceExpansion) so that |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1068 // 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
|
1069 // 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
|
1070 // allocation), increase by MaxMetaspaceExpansion. If that is still |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1071 // 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
|
1072 // some. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1073 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
|
1074 size_t before_inc = MetaspaceGC::capacity_until_GC(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1075 size_t min_delta_words = MinMetaspaceExpansion / BytesPerWord; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1076 size_t max_delta_words = MaxMetaspaceExpansion / BytesPerWord; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1077 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
|
1078 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
|
1079 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
|
1080 if (delta_words > min_delta_words) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1081 // 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
|
1082 // allocation so make the delta greater than just enough |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1083 // for this allocation. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1084 delta_words = MAX2(delta_words, max_delta_words); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1085 if (delta_words > max_delta_words) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1086 // 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
|
1087 // so increase by the minimum. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1088 delta_words = delta_words + min_delta_words; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1089 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1090 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1091 return delta_words; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1092 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1093 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1094 bool MetaspaceGC::should_expand(VirtualSpaceList* vsl, size_t word_size) { |
8790
7f0cb32dd233
8004241: NPG: Metaspace occupies more memory than specified by -XX:MaxMetaspaceSize option
mgerdin
parents:
8786
diff
changeset
|
1095 // If the user wants a limit, impose one. |
7f0cb32dd233
8004241: NPG: Metaspace occupies more memory than specified by -XX:MaxMetaspaceSize option
mgerdin
parents:
8786
diff
changeset
|
1096 if (!FLAG_IS_DEFAULT(MaxMetaspaceSize) && |
7f0cb32dd233
8004241: NPG: Metaspace occupies more memory than specified by -XX:MaxMetaspaceSize option
mgerdin
parents:
8786
diff
changeset
|
1097 MetaspaceAux::reserved_in_bytes() >= MaxMetaspaceSize) { |
7f0cb32dd233
8004241: NPG: Metaspace occupies more memory than specified by -XX:MaxMetaspaceSize option
mgerdin
parents:
8786
diff
changeset
|
1098 return false; |
7f0cb32dd233
8004241: NPG: Metaspace occupies more memory than specified by -XX:MaxMetaspaceSize option
mgerdin
parents:
8786
diff
changeset
|
1099 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1100 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1101 // 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
|
1102 // metadata virtual space. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1103 if (vsl == Metaspace::class_space_list()) return true; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1104 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1105 // 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
|
1106 // unconditionally. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1107 if(MetaspaceGC::expand_after_GC()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1108 return true; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1109 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1110 |
8790
7f0cb32dd233
8004241: NPG: Metaspace occupies more memory than specified by -XX:MaxMetaspaceSize option
mgerdin
parents:
8786
diff
changeset
|
1111 size_t metaspace_size_words = MetaspaceSize / BytesPerWord; |
7f0cb32dd233
8004241: NPG: Metaspace occupies more memory than specified by -XX:MaxMetaspaceSize option
mgerdin
parents:
8786
diff
changeset
|
1112 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1113 // 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
|
1114 // 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
|
1115 // 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
|
1116 // until that minimum capacity is exceeded. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1117 if (vsl->capacity_words_sum() < metaspace_size_words || |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1118 capacity_until_GC() == 0) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1119 set_capacity_until_GC(metaspace_size_words); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1120 return true; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1121 } else { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1122 if (vsl->capacity_words_sum() < capacity_until_GC()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1123 return true; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1124 } else { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1125 if (TraceMetadataChunkAllocation && Verbose) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1126 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
|
1127 " capacity_until_GC " SIZE_FORMAT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1128 " capacity_words_sum " SIZE_FORMAT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1129 " used_words_sum " SIZE_FORMAT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1130 " free chunks " SIZE_FORMAT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1131 " free chunks count %d", |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1132 word_size, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1133 capacity_until_GC(), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1134 vsl->capacity_words_sum(), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1135 vsl->used_words_sum(), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1136 vsl->chunk_manager()->free_chunks_total(), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1137 vsl->chunk_manager()->free_chunks_count()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1138 } |
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 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1141 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1142 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1143 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1144 // Variables are in bytes |
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 void MetaspaceGC::compute_new_size() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1147 assert(_shrink_factor <= 100, "invalid shrink factor"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1148 uint current_shrink_factor = _shrink_factor; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1149 _shrink_factor = 0; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1150 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1151 VirtualSpaceList *vsl = Metaspace::space_list(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1152 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1153 size_t capacity_after_gc = vsl->capacity_bytes_sum(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1154 // Check to see if these two can be calculated without walking the CLDG |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1155 size_t used_after_gc = vsl->used_bytes_sum(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1156 size_t capacity_until_GC = vsl->capacity_bytes_sum(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1157 size_t free_after_gc = capacity_until_GC - used_after_gc; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1158 |
8040
a83cd101fd62
8005452: NPG: Create new flags for Metaspace resizing policy
jmasa
parents:
8007
diff
changeset
|
1159 const double minimum_free_percentage = MinMetaspaceFreeRatio / 100.0; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1160 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
|
1161 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1162 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
|
1163 size_t minimum_desired_capacity = |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1164 (size_t)MIN2(min_tmp, double(max_uintx)); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1165 // Don't shrink less than the initial generation size |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1166 minimum_desired_capacity = MAX2(minimum_desired_capacity, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1167 MetaspaceSize); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1168 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1169 if (PrintGCDetails && Verbose) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1170 const double free_percentage = ((double)free_after_gc) / capacity_until_GC; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1171 gclog_or_tty->print_cr("\nMetaspaceGC::compute_new_size: "); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1172 gclog_or_tty->print_cr(" " |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1173 " minimum_free_percentage: %6.2f" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1174 " maximum_used_percentage: %6.2f", |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1175 minimum_free_percentage, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1176 maximum_used_percentage); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1177 double d_free_after_gc = free_after_gc / (double) K; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1178 gclog_or_tty->print_cr(" " |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1179 " free_after_gc : %6.1fK" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1180 " used_after_gc : %6.1fK" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1181 " capacity_after_gc : %6.1fK" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1182 " metaspace HWM : %6.1fK", |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1183 free_after_gc / (double) K, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1184 used_after_gc / (double) K, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1185 capacity_after_gc / (double) K, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1186 capacity_until_GC / (double) K); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1187 gclog_or_tty->print_cr(" " |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1188 " free_percentage: %6.2f", |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1189 free_percentage); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1190 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1191 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1192 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1193 if (capacity_until_GC < minimum_desired_capacity) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1194 // 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
|
1195 // increment the HWM. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1196 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
|
1197 // Don't expand unless it's significant |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1198 if (expand_bytes >= MinMetaspaceExpansion) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1199 size_t expand_words = expand_bytes / BytesPerWord; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1200 MetaspaceGC::inc_capacity_until_GC(expand_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 if (PrintGCDetails && Verbose) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1203 size_t new_capacity_until_GC = MetaspaceGC::capacity_until_GC_in_bytes(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1204 gclog_or_tty->print_cr(" expanding:" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1205 " minimum_desired_capacity: %6.1fK" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1206 " expand_words: %6.1fK" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1207 " MinMetaspaceExpansion: %6.1fK" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1208 " new metaspace HWM: %6.1fK", |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1209 minimum_desired_capacity / (double) K, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1210 expand_bytes / (double) K, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1211 MinMetaspaceExpansion / (double) K, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1212 new_capacity_until_GC / (double) K); |
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 return; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1215 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1216 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1217 // No expansion, now see if we want to shrink |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1218 size_t shrink_words = 0; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1219 // We would never want to shrink more than this |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1220 size_t max_shrink_words = capacity_until_GC - minimum_desired_capacity; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1221 assert(max_shrink_words >= 0, err_msg("max_shrink_words " SIZE_FORMAT, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1222 max_shrink_words)); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1223 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1224 // Should shrinking be considered? |
8040
a83cd101fd62
8005452: NPG: Create new flags for Metaspace resizing policy
jmasa
parents:
8007
diff
changeset
|
1225 if (MaxMetaspaceFreeRatio < 100) { |
a83cd101fd62
8005452: NPG: Create new flags for Metaspace resizing policy
jmasa
parents:
8007
diff
changeset
|
1226 const double maximum_free_percentage = MaxMetaspaceFreeRatio / 100.0; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1227 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
|
1228 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
|
1229 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
|
1230 maximum_desired_capacity = MAX2(maximum_desired_capacity, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1231 MetaspaceSize); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1232 if (PrintGC && Verbose) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1233 gclog_or_tty->print_cr(" " |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1234 " maximum_free_percentage: %6.2f" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1235 " minimum_used_percentage: %6.2f", |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1236 maximum_free_percentage, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1237 minimum_used_percentage); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1238 gclog_or_tty->print_cr(" " |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1239 " capacity_until_GC: %6.1fK" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1240 " minimum_desired_capacity: %6.1fK" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1241 " maximum_desired_capacity: %6.1fK", |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1242 capacity_until_GC / (double) K, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1243 minimum_desired_capacity / (double) K, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1244 maximum_desired_capacity / (double) K); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1245 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1246 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1247 assert(minimum_desired_capacity <= maximum_desired_capacity, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1248 "sanity check"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1249 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1250 if (capacity_until_GC > maximum_desired_capacity) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1251 // Capacity too large, compute shrinking size |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1252 shrink_words = capacity_until_GC - maximum_desired_capacity; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1253 // 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
|
1254 // 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
|
1255 // 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
|
1256 // 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
|
1257 // 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
|
1258 // size without shrinking, it goes back to 0%. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1259 shrink_words = shrink_words / 100 * current_shrink_factor; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1260 assert(shrink_words <= max_shrink_words, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1261 err_msg("invalid shrink size " SIZE_FORMAT " not <= " SIZE_FORMAT, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1262 shrink_words, max_shrink_words)); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1263 if (current_shrink_factor == 0) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1264 _shrink_factor = 10; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1265 } else { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1266 _shrink_factor = MIN2(current_shrink_factor * 4, (uint) 100); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1267 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1268 if (PrintGCDetails && Verbose) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1269 gclog_or_tty->print_cr(" " |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1270 " shrinking:" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1271 " initSize: %.1fK" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1272 " maximum_desired_capacity: %.1fK", |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1273 MetaspaceSize / (double) K, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1274 maximum_desired_capacity / (double) K); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1275 gclog_or_tty->print_cr(" " |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1276 " shrink_words: %.1fK" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1277 " current_shrink_factor: %d" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1278 " new shrink factor: %d" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1279 " MinMetaspaceExpansion: %.1fK", |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1280 shrink_words / (double) K, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1281 current_shrink_factor, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1282 _shrink_factor, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1283 MinMetaspaceExpansion / (double) K); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1284 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1285 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1286 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1287 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1288 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1289 // Don't shrink unless it's significant |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1290 if (shrink_words >= MinMetaspaceExpansion) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1291 VirtualSpaceNode* csp = vsl->current_virtual_space(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1292 size_t available_to_shrink = csp->capacity_words_in_vs() - |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1293 csp->used_words_in_vs(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1294 shrink_words = MIN2(shrink_words, available_to_shrink); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1295 csp->shrink_by(shrink_words); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1296 MetaspaceGC::dec_capacity_until_GC(shrink_words); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1297 if (PrintGCDetails && Verbose) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1298 size_t new_capacity_until_GC = MetaspaceGC::capacity_until_GC_in_bytes(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1299 gclog_or_tty->print_cr(" metaspace HWM: %.1fK", new_capacity_until_GC / (double) K); |
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 } |
8784
79af1312fc2c
8005602: NPG: classunloading does not happen while CMS GC with -XX:+CMSClassUnloadingEnabled is used
mgerdin
parents:
8738
diff
changeset
|
1302 assert(used_after_gc <= vsl->capacity_bytes_sum(), |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1303 "sanity check"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1304 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1305 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1306 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1307 // Metadebug methods |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1308 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1309 void Metadebug::deallocate_chunk_a_lot(SpaceManager* sm, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1310 size_t chunk_word_size){ |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1311 #ifdef ASSERT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1312 VirtualSpaceList* vsl = sm->vs_list(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1313 if (MetaDataDeallocateALot && |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1314 Metadebug::deallocate_chunk_a_lot_count() % MetaDataDeallocateALotInterval == 0 ) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1315 Metadebug::reset_deallocate_chunk_a_lot_count(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1316 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
|
1317 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
|
1318 if (dummy_chunk == NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1319 break; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1320 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1321 vsl->chunk_manager()->chunk_freelist_deallocate(dummy_chunk); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1322 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1323 if (TraceMetadataChunkAllocation && Verbose) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1324 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
|
1325 sm->sum_count_in_chunks_in_use()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1326 dummy_chunk->print_on(gclog_or_tty); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1327 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
|
1328 vsl->chunk_manager()->free_chunks_total(), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1329 vsl->chunk_manager()->free_chunks_count()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1330 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1331 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1332 } else { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1333 Metadebug::inc_deallocate_chunk_a_lot_count(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1334 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1335 #endif |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1336 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1337 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1338 void Metadebug::deallocate_block_a_lot(SpaceManager* sm, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1339 size_t raw_word_size){ |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1340 #ifdef ASSERT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1341 if (MetaDataDeallocateALot && |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1342 Metadebug::deallocate_block_a_lot_count() % MetaDataDeallocateALotInterval == 0 ) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1343 Metadebug::set_deallocate_block_a_lot_count(0); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1344 for (uint i = 0; i < metadata_deallocate_a_lot_block; i++) { |
6885 | 1345 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
|
1346 if (dummy_block == 0) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1347 break; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1348 } |
6885 | 1349 sm->deallocate(dummy_block, raw_word_size); |
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 } else { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1352 Metadebug::inc_deallocate_block_a_lot_count(); |
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 #endif |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1355 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1356 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1357 void Metadebug::init_allocation_fail_alot_count() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1358 if (MetadataAllocationFailALot) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1359 _allocation_fail_alot_count = |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1360 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
|
1361 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1362 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1363 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1364 #ifdef ASSERT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1365 bool Metadebug::test_metadata_failure() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1366 if (MetadataAllocationFailALot && |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1367 Threads::is_vm_complete()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1368 if (_allocation_fail_alot_count > 0) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1369 _allocation_fail_alot_count--; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1370 } else { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1371 if (TraceMetadataChunkAllocation && Verbose) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1372 gclog_or_tty->print_cr("Metadata allocation failing for " |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1373 "MetadataAllocationFailALot"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1374 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1375 init_allocation_fail_alot_count(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1376 return true; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1377 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1378 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1379 return false; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1380 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1381 #endif |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1382 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1383 // ChunkList methods |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1384 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1385 size_t ChunkList::sum_list_size() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1386 size_t result = 0; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1387 Metachunk* cur = head(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1388 while (cur != NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1389 result += cur->word_size(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1390 cur = cur->next(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1391 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1392 return result; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1393 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1394 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1395 size_t ChunkList::sum_list_count() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1396 size_t result = 0; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1397 Metachunk* cur = head(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1398 while (cur != NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1399 result++; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1400 cur = cur->next(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1401 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1402 return result; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1403 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1404 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1405 size_t ChunkList::sum_list_capacity() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1406 size_t result = 0; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1407 Metachunk* cur = head(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1408 while (cur != NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1409 result += cur->capacity_word_size(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1410 cur = cur->next(); |
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 result; |
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 void ChunkList::add_at_head(Metachunk* head, Metachunk* tail) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1416 assert_lock_strong(SpaceManager::expand_lock()); |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1417 assert(head == tail || tail->next() == NULL, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1418 "Not the tail or the head has already been added to a list"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1419 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1420 if (TraceMetadataChunkAllocation && Verbose) { |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1421 gclog_or_tty->print("ChunkList::add_at_head(head, tail): "); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1422 Metachunk* cur = head; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1423 while (cur != NULL) { |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1424 gclog_or_tty->print(PTR_FORMAT " (" SIZE_FORMAT ") ", cur, cur->word_size()); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1425 cur = cur->next(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1426 } |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1427 gclog_or_tty->print_cr(""); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1428 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1429 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1430 if (tail != NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1431 tail->set_next(_head); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1432 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1433 set_head(head); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1434 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1435 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1436 void ChunkList::add_at_head(Metachunk* list) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1437 if (list == NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1438 // Nothing to add |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1439 return; |
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 assert_lock_strong(SpaceManager::expand_lock()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1442 Metachunk* head = list; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1443 Metachunk* tail = list; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1444 Metachunk* cur = head->next(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1445 // Search for the tail since it is not passed. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1446 while (cur != NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1447 tail = cur; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1448 cur = cur->next(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1449 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1450 add_at_head(head, tail); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1451 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1452 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1453 // ChunkManager methods |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1454 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1455 // Verification of _free_chunks_total and _free_chunks_count does not |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1456 // work with the CMS collector because its use of additional locks |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1457 // complicate the mutex deadlock detection but it can still be useful |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1458 // for detecting errors in the chunk accounting with other collectors. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1459 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1460 size_t ChunkManager::free_chunks_total() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1461 #ifdef ASSERT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1462 if (!UseConcMarkSweepGC && !SpaceManager::expand_lock()->is_locked()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1463 MutexLockerEx cl(SpaceManager::expand_lock(), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1464 Mutex::_no_safepoint_check_flag); |
6969
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
1465 slow_locked_verify_free_chunks_total(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1466 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1467 #endif |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1468 return _free_chunks_total; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1469 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1470 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1471 size_t ChunkManager::free_chunks_total_in_bytes() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1472 return free_chunks_total() * BytesPerWord; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1473 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1474 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1475 size_t ChunkManager::free_chunks_count() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1476 #ifdef ASSERT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1477 if (!UseConcMarkSweepGC && !SpaceManager::expand_lock()->is_locked()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1478 MutexLockerEx cl(SpaceManager::expand_lock(), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1479 Mutex::_no_safepoint_check_flag); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1480 // 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
|
1481 // 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
|
1482 slow_locked_verify_free_chunks_count(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1483 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1484 #endif |
6969
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
1485 return _free_chunks_count; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1486 } |
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 void ChunkManager::locked_verify_free_chunks_total() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1489 assert_lock_strong(SpaceManager::expand_lock()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1490 assert(sum_free_chunks() == _free_chunks_total, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1491 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
|
1492 " same as sum " SIZE_FORMAT, _free_chunks_total, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1493 sum_free_chunks())); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1494 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1495 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1496 void ChunkManager::verify_free_chunks_total() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1497 MutexLockerEx cl(SpaceManager::expand_lock(), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1498 Mutex::_no_safepoint_check_flag); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1499 locked_verify_free_chunks_total(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1500 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1501 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1502 void ChunkManager::locked_verify_free_chunks_count() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1503 assert_lock_strong(SpaceManager::expand_lock()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1504 assert(sum_free_chunks_count() == _free_chunks_count, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1505 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
|
1506 " same as sum " SIZE_FORMAT, _free_chunks_count, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1507 sum_free_chunks_count())); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1508 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1509 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1510 void ChunkManager::verify_free_chunks_count() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1511 #ifdef ASSERT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1512 MutexLockerEx cl(SpaceManager::expand_lock(), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1513 Mutex::_no_safepoint_check_flag); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1514 locked_verify_free_chunks_count(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1515 #endif |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1516 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1517 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1518 void ChunkManager::verify() { |
6969
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
1519 MutexLockerEx cl(SpaceManager::expand_lock(), |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
1520 Mutex::_no_safepoint_check_flag); |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
1521 locked_verify(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1522 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1523 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1524 void ChunkManager::locked_verify() { |
6885 | 1525 locked_verify_free_chunks_count(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1526 locked_verify_free_chunks_total(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1527 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1528 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1529 void ChunkManager::locked_print_free_chunks(outputStream* st) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1530 assert_lock_strong(SpaceManager::expand_lock()); |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1531 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
|
1532 _free_chunks_total, _free_chunks_count); |
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 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1535 void ChunkManager::locked_print_sum_free_chunks(outputStream* st) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1536 assert_lock_strong(SpaceManager::expand_lock()); |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1537 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
|
1538 sum_free_chunks(), sum_free_chunks_count()); |
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 ChunkList* ChunkManager::free_chunks(ChunkIndex index) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1541 return &_free_chunks[index]; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1542 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1543 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1544 // 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
|
1545 // methods that are used in product builds. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1546 size_t ChunkManager::sum_free_chunks() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1547 assert_lock_strong(SpaceManager::expand_lock()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1548 size_t result = 0; |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1549 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
|
1550 ChunkList* list = free_chunks(i); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1551 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1552 if (list == NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1553 continue; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1554 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1555 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1556 result = result + list->sum_list_capacity(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1557 } |
6885 | 1558 result = result + humongous_dictionary()->total_size(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1559 return result; |
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 size_t ChunkManager::sum_free_chunks_count() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1563 assert_lock_strong(SpaceManager::expand_lock()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1564 size_t count = 0; |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1565 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
|
1566 ChunkList* list = free_chunks(i); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1567 if (list == NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1568 continue; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1569 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1570 count = count + list->sum_list_count(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1571 } |
6885 | 1572 count = count + humongous_dictionary()->total_free_blocks(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1573 return count; |
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 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
|
1577 ChunkIndex index = list_index(word_size); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1578 assert(index < HumongousIndex, "No humongous list"); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1579 return free_chunks(index); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1580 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1581 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1582 void ChunkManager::free_chunks_put(Metachunk* chunk) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1583 assert_lock_strong(SpaceManager::expand_lock()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1584 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
|
1585 chunk->set_next(free_list->head()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1586 free_list->set_head(chunk); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1587 // chunk is being returned to the chunk free list |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1588 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
|
1589 slow_locked_verify(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1590 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1591 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1592 void ChunkManager::chunk_freelist_deallocate(Metachunk* chunk) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1593 // The deallocation of a chunk originates in the freelist |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1594 // 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
|
1595 // lock. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1596 assert(chunk != NULL, "Deallocating NULL"); |
6969
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
1597 assert_lock_strong(SpaceManager::expand_lock()); |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
1598 slow_locked_verify(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1599 if (TraceMetadataChunkAllocation) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1600 tty->print_cr("ChunkManager::chunk_freelist_deallocate: chunk " |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1601 PTR_FORMAT " size " SIZE_FORMAT, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1602 chunk, chunk->word_size()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1603 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1604 free_chunks_put(chunk); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1605 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1606 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1607 Metachunk* ChunkManager::free_chunks_get(size_t word_size) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1608 assert_lock_strong(SpaceManager::expand_lock()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1609 |
6969
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
1610 slow_locked_verify(); |
6885 | 1611 |
1612 Metachunk* chunk = NULL; | |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1613 if (list_index(word_size) != HumongousIndex) { |
6885 | 1614 ChunkList* free_list = find_free_chunks_list(word_size); |
1615 assert(free_list != NULL, "Sanity check"); | |
1616 | |
1617 chunk = free_list->head(); | |
1618 debug_only(Metachunk* debug_head = chunk;) | |
1619 | |
1620 if (chunk == NULL) { | |
1621 return NULL; | |
1622 } | |
1623 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1624 // Remove the chunk as the head of the list. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1625 free_list->set_head(chunk->next()); |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1626 |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1627 // Chunk is being removed from the chunks free list. |
6885 | 1628 dec_free_chunks_total(chunk->capacity_word_size()); |
6725
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 if (TraceMetadataChunkAllocation && Verbose) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1631 tty->print_cr("ChunkManager::free_chunks_get: free_list " |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1632 PTR_FORMAT " head " PTR_FORMAT " size " SIZE_FORMAT, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1633 free_list, chunk, chunk->word_size()); |
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 } else { |
6885 | 1636 chunk = humongous_dictionary()->get_chunk( |
1637 word_size, | |
1638 FreeBlockDictionary<Metachunk>::atLeast); | |
1639 | |
1640 if (chunk != NULL) { | |
1641 if (TraceMetadataHumongousAllocation) { | |
1642 size_t waste = chunk->word_size() - word_size; | |
1643 tty->print_cr("Free list allocate humongous chunk size " SIZE_FORMAT | |
1644 " for requested size " SIZE_FORMAT | |
1645 " waste " SIZE_FORMAT, | |
1646 chunk->word_size(), word_size, waste); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1647 } |
6885 | 1648 // Chunk is being removed from the chunks free list. |
1649 dec_free_chunks_total(chunk->capacity_word_size()); | |
1650 #ifdef ASSERT | |
1651 chunk->set_is_free(false); | |
1652 #endif | |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1653 } else { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1654 return NULL; |
6885 | 1655 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1656 } |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1657 |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1658 // 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
|
1659 chunk->set_next(NULL); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1660 chunk->set_prev(NULL); |
6969
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
1661 slow_locked_verify(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1662 return chunk; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1663 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1664 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1665 Metachunk* ChunkManager::chunk_freelist_allocate(size_t word_size) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1666 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
|
1667 slow_locked_verify(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1668 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1669 // Take from the beginning of the list |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1670 Metachunk* chunk = free_chunks_get(word_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1671 if (chunk == NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1672 return NULL; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1673 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1674 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1675 assert((word_size <= chunk->word_size()) || |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1676 list_index(chunk->word_size() == HumongousIndex), |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1677 "Non-humongous variable sized chunk"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1678 if (TraceMetadataChunkAllocation) { |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1679 size_t list_count; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1680 if (list_index(word_size) < HumongousIndex) { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1681 ChunkList* list = find_free_chunks_list(word_size); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1682 list_count = list->sum_list_count(); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1683 } else { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1684 list_count = humongous_dictionary()->total_count(); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1685 } |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1686 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
|
1687 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
|
1688 this, chunk, chunk->word_size(), list_count); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1689 locked_print_free_chunks(tty); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1690 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1691 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1692 return chunk; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1693 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1694 |
6885 | 1695 void ChunkManager::print_on(outputStream* out) { |
1696 if (PrintFLSStatistics != 0) { | |
1697 humongous_dictionary()->report_statistics(); | |
1698 } | |
1699 } | |
1700 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1701 // SpaceManager methods |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1702 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1703 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
|
1704 size_t* chunk_word_size, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1705 size_t* class_chunk_word_size) { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1706 switch (type) { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1707 case Metaspace::BootMetaspaceType: |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1708 *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
|
1709 *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
|
1710 break; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1711 case Metaspace::ROMetaspaceType: |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1712 *chunk_word_size = SharedReadOnlySize / wordSize; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1713 *class_chunk_word_size = ClassSpecializedChunk; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1714 break; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1715 case Metaspace::ReadWriteMetaspaceType: |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1716 *chunk_word_size = SharedReadWriteSize / wordSize; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1717 *class_chunk_word_size = ClassSpecializedChunk; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1718 break; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1719 case Metaspace::AnonymousMetaspaceType: |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1720 case Metaspace::ReflectionMetaspaceType: |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1721 *chunk_word_size = SpecializedChunk; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1722 *class_chunk_word_size = ClassSpecializedChunk; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1723 break; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1724 default: |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1725 *chunk_word_size = SmallChunk; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1726 *class_chunk_word_size = ClassSmallChunk; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1727 break; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1728 } |
8007
d9058e388631
8007257: NPG: metaspace.cpp: Incorrect arguments in calls to err_msg
mikael
parents:
7447
diff
changeset
|
1729 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
|
1730 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
|
1731 " class " SIZE_FORMAT, |
8007
d9058e388631
8007257: NPG: metaspace.cpp: Incorrect arguments in calls to err_msg
mikael
parents:
7447
diff
changeset
|
1732 *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
|
1733 } |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1734 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1735 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
|
1736 MutexLockerEx cl(lock(), Mutex::_no_safepoint_check_flag); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1737 size_t free = 0; |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1738 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
|
1739 Metachunk* chunk = chunks_in_use(i); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1740 while (chunk != NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1741 free += chunk->free_word_size(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1742 chunk = chunk->next(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1743 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1744 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1745 return free; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1746 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1747 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1748 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
|
1749 MutexLockerEx cl(lock(), Mutex::_no_safepoint_check_flag); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1750 size_t result = 0; |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1751 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
|
1752 result += sum_waste_in_chunks_in_use(i); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1753 } |
6885 | 1754 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1755 return result; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1756 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1757 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1758 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
|
1759 size_t result = 0; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1760 Metachunk* chunk = chunks_in_use(index); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1761 // 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
|
1762 // current chunk from which allocations are still being done. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1763 if (chunk != NULL) { |
6885 | 1764 Metachunk* prev = chunk; |
1765 while (chunk != NULL && chunk != current_chunk()) { | |
1766 result += chunk->free_word_size(); | |
1767 prev = chunk; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1768 chunk = chunk->next(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1769 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1770 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1771 return result; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1772 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1773 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1774 size_t SpaceManager::sum_capacity_in_chunks_in_use() const { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1775 MutexLockerEx cl(lock(), Mutex::_no_safepoint_check_flag); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1776 size_t sum = 0; |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1777 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
|
1778 Metachunk* chunk = chunks_in_use(i); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1779 while (chunk != NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1780 // Just changed this sum += chunk->capacity_word_size(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1781 // sum += chunk->word_size() - Metachunk::overhead(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1782 sum += chunk->capacity_word_size(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1783 chunk = chunk->next(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1784 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1785 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1786 return sum; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1787 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1788 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1789 size_t SpaceManager::sum_count_in_chunks_in_use() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1790 size_t count = 0; |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1791 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
|
1792 count = count + sum_count_in_chunks_in_use(i); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1793 } |
6885 | 1794 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1795 return count; |
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 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1798 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
|
1799 size_t count = 0; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1800 Metachunk* chunk = chunks_in_use(i); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1801 while (chunk != NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1802 count++; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1803 chunk = chunk->next(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1804 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1805 return count; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1806 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1807 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1808 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1809 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
|
1810 MutexLockerEx cl(lock(), Mutex::_no_safepoint_check_flag); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1811 size_t used = 0; |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1812 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
|
1813 Metachunk* chunk = chunks_in_use(i); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1814 while (chunk != NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1815 used += chunk->used_word_size(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1816 chunk = chunk->next(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1817 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1818 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1819 return used; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1820 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1821 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1822 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
|
1823 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1824 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
|
1825 Metachunk* chunk = chunks_in_use(i); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1826 st->print("SpaceManager: %s " PTR_FORMAT, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1827 chunk_size_name(i), chunk); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1828 if (chunk != NULL) { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1829 st->print_cr(" free " SIZE_FORMAT, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1830 chunk->free_word_size()); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1831 } else { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1832 st->print_cr(""); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1833 } |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1834 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1835 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1836 vs_list()->chunk_manager()->locked_print_free_chunks(st); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1837 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
|
1838 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1839 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1840 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
|
1841 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1842 // 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
|
1843 // _small_chunk_limit small chunks can be allocated but |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1844 // 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
|
1845 // chunks will be allocated. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1846 size_t chunk_word_size; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1847 if (chunks_in_use(MediumIndex) == NULL && |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1848 (!has_small_chunk_limit() || |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1849 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
|
1850 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
|
1851 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
|
1852 chunk_word_size = medium_chunk_size(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1853 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1854 } else { |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1855 chunk_word_size = medium_chunk_size(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1856 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1857 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1858 // 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
|
1859 // eight word granularity to facilitate reuse (some |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1860 // wastage but better chance of reuse). |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1861 size_t if_humongous_sized_chunk = |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1862 align_size_up(word_size + Metachunk::overhead(), |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1863 HumongousChunkGranularity); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1864 chunk_word_size = |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1865 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
|
1866 |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1867 assert(!SpaceManager::is_humongous(word_size) || |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1868 chunk_word_size == if_humongous_sized_chunk, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1869 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
|
1870 " chunk_word_size " SIZE_FORMAT, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1871 word_size, chunk_word_size)); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1872 if (TraceMetadataHumongousAllocation && |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1873 SpaceManager::is_humongous(word_size)) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1874 gclog_or_tty->print_cr("Metadata humongous allocation:"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1875 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
|
1876 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
|
1877 chunk_word_size); |
6885 | 1878 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
|
1879 Metachunk::overhead()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1880 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1881 return chunk_word_size; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1882 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1883 |
6885 | 1884 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
|
1885 assert(vs_list()->current_virtual_space() != NULL, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1886 "Should have been set"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1887 assert(current_chunk() == NULL || |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1888 current_chunk()->allocate(word_size) == NULL, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1889 "Don't need to expand"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1890 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
|
1891 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1892 if (TraceMetadataChunkAllocation && Verbose) { |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1893 size_t words_left = 0; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1894 size_t words_used = 0; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1895 if (current_chunk() != NULL) { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1896 words_left = current_chunk()->free_word_size(); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1897 words_used = current_chunk()->used_word_size(); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1898 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1899 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
|
1900 " words " SIZE_FORMAT " words used " SIZE_FORMAT |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1901 " words left", |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1902 word_size, words_used, words_left); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1903 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1904 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1905 // Get another chunk out of the virtual space |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1906 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
|
1907 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
|
1908 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1909 // 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
|
1910 // and do an allocation from it. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1911 if (next != NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1912 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
|
1913 // 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
|
1914 add_chunk(next, false); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1915 return next->allocate(word_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1916 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1917 return NULL; |
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 void SpaceManager::print_on(outputStream* st) const { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1921 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1922 for (ChunkIndex i = ZeroIndex; |
6885 | 1923 i < NumberOfInUseLists ; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1924 i = next_chunk_index(i) ) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1925 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
|
1926 chunks_in_use(i), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1927 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
|
1928 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1929 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
|
1930 " Humongous " SIZE_FORMAT, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1931 sum_waste_in_chunks_in_use(SmallIndex), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1932 sum_waste_in_chunks_in_use(MediumIndex), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1933 sum_waste_in_chunks_in_use(HumongousIndex)); |
6885 | 1934 // block free lists |
1935 if (block_freelists() != NULL) { | |
1936 st->print_cr("total in block free lists " SIZE_FORMAT, | |
1937 block_freelists()->total_size()); | |
1938 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1939 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1940 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1941 SpaceManager::SpaceManager(Mutex* lock, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1942 VirtualSpaceList* vs_list) : |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1943 _vs_list(vs_list), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1944 _allocation_total(0), |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1945 _lock(lock) |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1946 { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1947 initialize(); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1948 } |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1949 |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1950 void SpaceManager::initialize() { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1951 Metadebug::init_allocation_fail_alot_count(); |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1952 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
|
1953 _chunks_in_use[i] = NULL; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1954 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1955 _current_chunk = NULL; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1956 if (TraceMetadataChunkAllocation && Verbose) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1957 gclog_or_tty->print_cr("SpaceManager(): " PTR_FORMAT, this); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1958 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1959 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1960 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1961 SpaceManager::~SpaceManager() { |
8784
79af1312fc2c
8005602: NPG: classunloading does not happen while CMS GC with -XX:+CMSClassUnloadingEnabled is used
mgerdin
parents:
8738
diff
changeset
|
1962 // This call this->_lock which can't be done while holding expand_lock() |
79af1312fc2c
8005602: NPG: classunloading does not happen while CMS GC with -XX:+CMSClassUnloadingEnabled is used
mgerdin
parents:
8738
diff
changeset
|
1963 const size_t in_use_before = sum_capacity_in_chunks_in_use(); |
79af1312fc2c
8005602: NPG: classunloading does not happen while CMS GC with -XX:+CMSClassUnloadingEnabled is used
mgerdin
parents:
8738
diff
changeset
|
1964 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1965 MutexLockerEx fcl(SpaceManager::expand_lock(), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1966 Mutex::_no_safepoint_check_flag); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1967 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1968 ChunkManager* chunk_manager = vs_list()->chunk_manager(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1969 |
6969
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
1970 chunk_manager->slow_locked_verify(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1971 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1972 if (TraceMetadataChunkAllocation && Verbose) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1973 gclog_or_tty->print_cr("~SpaceManager(): " PTR_FORMAT, this); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1974 locked_print_chunks_in_use_on(gclog_or_tty); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1975 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1976 |
7185
90273fc0a981
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
6969
diff
changeset
|
1977 // Mangle freed memory. |
90273fc0a981
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
6969
diff
changeset
|
1978 NOT_PRODUCT(mangle_freed_chunks();) |
90273fc0a981
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
6969
diff
changeset
|
1979 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1980 // 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
|
1981 // below. |
8784
79af1312fc2c
8005602: NPG: classunloading does not happen while CMS GC with -XX:+CMSClassUnloadingEnabled is used
mgerdin
parents:
8738
diff
changeset
|
1982 chunk_manager->inc_free_chunks_total(in_use_before, |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1983 sum_count_in_chunks_in_use()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1984 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1985 // 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
|
1986 // to the global list of free chunks. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1987 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1988 // 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
|
1989 // free lists. Each list is NULL terminated. |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1990 |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1991 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
|
1992 if (TraceMetadataChunkAllocation && Verbose) { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1993 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
|
1994 sum_count_in_chunks_in_use(i), |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1995 chunk_size_name(i)); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1996 } |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1997 Metachunk* chunks = chunks_in_use(i); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1998 chunk_manager->free_chunks(i)->add_at_head(chunks); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1999 set_chunks_in_use(i, NULL); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2000 if (TraceMetadataChunkAllocation && Verbose) { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2001 gclog_or_tty->print_cr("updated freelist count %d %s", |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2002 chunk_manager->free_chunks(i)->sum_list_count(), |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2003 chunk_size_name(i)); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2004 } |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2005 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
|
2006 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2007 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2008 // 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
|
2009 // 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
|
2010 // 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
|
2011 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2012 // Humongous chunks |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2013 if (TraceMetadataChunkAllocation && Verbose) { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2014 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
|
2015 sum_count_in_chunks_in_use(HumongousIndex), |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2016 chunk_size_name(HumongousIndex)); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2017 gclog_or_tty->print("Humongous chunk dictionary: "); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2018 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2019 // Humongous chunks are never the current chunk. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2020 Metachunk* humongous_chunks = chunks_in_use(HumongousIndex); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2021 |
6885 | 2022 while (humongous_chunks != NULL) { |
2023 #ifdef ASSERT | |
2024 humongous_chunks->set_is_free(true); | |
2025 #endif | |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2026 if (TraceMetadataChunkAllocation && Verbose) { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2027 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
|
2028 humongous_chunks, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2029 humongous_chunks->word_size()); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2030 } |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2031 assert(humongous_chunks->word_size() == (size_t) |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2032 align_size_up(humongous_chunks->word_size(), |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2033 HumongousChunkGranularity), |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2034 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
|
2035 " granularity %d", |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2036 humongous_chunks->word_size(), HumongousChunkGranularity)); |
6885 | 2037 Metachunk* next_humongous_chunks = humongous_chunks->next(); |
2038 chunk_manager->humongous_dictionary()->return_chunk(humongous_chunks); | |
2039 humongous_chunks = next_humongous_chunks; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2040 } |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2041 if (TraceMetadataChunkAllocation && Verbose) { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2042 gclog_or_tty->print_cr(""); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2043 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
|
2044 chunk_manager->humongous_dictionary()->total_count(), |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2045 chunk_size_name(HumongousIndex)); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2046 } |
6885 | 2047 set_chunks_in_use(HumongousIndex, NULL); |
6969
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
2048 chunk_manager->slow_locked_verify(); |
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 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2051 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
|
2052 switch (index) { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2053 case SpecializedIndex: |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2054 return "Specialized"; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2055 case SmallIndex: |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2056 return "Small"; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2057 case MediumIndex: |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2058 return "Medium"; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2059 case HumongousIndex: |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2060 return "Humongous"; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2061 default: |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2062 return NULL; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2063 } |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2064 } |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2065 |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2066 ChunkIndex ChunkManager::list_index(size_t size) { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2067 switch (size) { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2068 case SpecializedChunk: |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2069 assert(SpecializedChunk == ClassSpecializedChunk, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2070 "Need branch for ClassSpecializedChunk"); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2071 return SpecializedIndex; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2072 case SmallChunk: |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2073 case ClassSmallChunk: |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2074 return SmallIndex; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2075 case MediumChunk: |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2076 case ClassMediumChunk: |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2077 return MediumIndex; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2078 default: |
7447
1de1b145f6bc
8005486: NPG: Incorrect assertion in ChunkManager::list_index()
jmasa
parents:
7446
diff
changeset
|
2079 assert(size > MediumChunk || size > ClassMediumChunk, |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2080 "Not a humongous chunk"); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2081 return HumongousIndex; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2082 } |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2083 } |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2084 |
6885 | 2085 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
|
2086 assert_lock_strong(_lock); |
6885 | 2087 size_t min_size = TreeChunk<Metablock, FreeList>::min_size(); |
2088 assert(word_size >= min_size, | |
2089 err_msg("Should not deallocate dark matter " SIZE_FORMAT, word_size)); | |
2090 block_freelists()->return_block(p, word_size); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2091 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2092 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2093 // 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
|
2094 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
|
2095 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2096 assert(new_chunk != NULL, "Should not be NULL"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2097 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
|
2098 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2099 new_chunk->reset_empty(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2100 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2101 // Find the correct list and and set the current |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2102 // chunk for that list. |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2103 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
|
2104 |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2105 if (index != HumongousIndex) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2106 set_current_chunk(new_chunk); |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2107 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
|
2108 set_chunks_in_use(index, new_chunk); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2109 } else { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2110 // 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
|
2111 // 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
|
2112 // chunk. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2113 if (make_current) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2114 // 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
|
2115 set_current_chunk(new_chunk); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2116 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2117 // 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
|
2118 // 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
|
2119 // 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
|
2120 // of the humongous chunks list. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2121 new_chunk->set_next(chunks_in_use(HumongousIndex)); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2122 set_chunks_in_use(HumongousIndex, new_chunk); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2123 |
7447
1de1b145f6bc
8005486: NPG: Incorrect assertion in ChunkManager::list_index()
jmasa
parents:
7446
diff
changeset
|
2124 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
|
2125 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2126 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2127 assert(new_chunk->is_empty(), "Not ready for reuse"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2128 if (TraceMetadataChunkAllocation && Verbose) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2129 gclog_or_tty->print("SpaceManager::add_chunk: %d) ", |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2130 sum_count_in_chunks_in_use()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2131 new_chunk->print_on(gclog_or_tty); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2132 vs_list()->chunk_manager()->locked_print_free_chunks(tty); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2133 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2134 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2135 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2136 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
|
2137 size_t grow_chunks_by_words) { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2138 |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2139 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
|
2140 grow_chunks_by_words, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2141 medium_chunk_bunch()); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2142 |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2143 if (TraceMetadataHumongousAllocation && |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2144 SpaceManager::is_humongous(next->word_size())) { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2145 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
|
2146 next->word_size()); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2147 } |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2148 |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2149 return next; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2150 } |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2151 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2152 MetaWord* SpaceManager::allocate(size_t word_size) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2153 MutexLockerEx cl(lock(), Mutex::_no_safepoint_check_flag); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2154 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2155 // If only the dictionary is going to be used (i.e., no |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2156 // indexed free list), then there is a minimum size requirement. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2157 // MinChunkSize is a placeholder for the real minimum size JJJ |
6885 | 2158 size_t byte_size = word_size * BytesPerWord; |
2159 | |
2160 size_t byte_size_with_overhead = byte_size + Metablock::overhead(); | |
2161 | |
2162 size_t raw_bytes_size = MAX2(byte_size_with_overhead, | |
2163 Metablock::min_block_byte_size()); | |
2164 raw_bytes_size = ARENA_ALIGN(raw_bytes_size); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2165 size_t raw_word_size = raw_bytes_size / BytesPerWord; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2166 assert(raw_word_size * BytesPerWord == raw_bytes_size, "Size problem"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2167 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2168 BlockFreelist* fl = block_freelists(); |
6885 | 2169 MetaWord* p = NULL; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2170 // 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
|
2171 // 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
|
2172 // 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
|
2173 // 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
|
2174 // for allocations. Do some profiling. JJJ |
6885 | 2175 if (fl->total_size() > allocation_from_dictionary_limit) { |
2176 p = fl->get_block(raw_word_size); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2177 } |
6885 | 2178 if (p == NULL) { |
2179 p = allocate_work(raw_word_size); | |
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 Metadebug::deallocate_block_a_lot(this, raw_word_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2182 |
6885 | 2183 return p; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2184 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2185 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2186 // Returns the address of spaced allocated for "word_size". |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2187 // This methods does not know about blocks (Metablocks) |
6885 | 2188 MetaWord* SpaceManager::allocate_work(size_t word_size) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2189 assert_lock_strong(_lock); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2190 #ifdef ASSERT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2191 if (Metadebug::test_metadata_failure()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2192 return NULL; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2193 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2194 #endif |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2195 // Is there space in the current chunk? |
6885 | 2196 MetaWord* result = NULL; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2197 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2198 // 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
|
2199 // 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
|
2200 // of memory if this returns null. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2201 if (DumpSharedSpaces) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2202 assert(current_chunk() != NULL, "should never happen"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2203 inc_allocation_total(word_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2204 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
|
2205 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2206 if (current_chunk() != NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2207 result = current_chunk()->allocate(word_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2208 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2209 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2210 if (result == NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2211 result = grow_and_allocate(word_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2212 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2213 if (result > 0) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2214 inc_allocation_total(word_size); |
6885 | 2215 assert(result != (MetaWord*) chunks_in_use(MediumIndex), |
2216 "Head of the list is being allocated"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2217 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2218 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2219 return result; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2220 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2221 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2222 void SpaceManager::verify() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2223 // If there are blocks in the dictionary, then |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2224 // verfication of chunks does not work since |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2225 // being in the dictionary alters a chunk. |
6885 | 2226 if (block_freelists()->total_size() == 0) { |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2227 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
|
2228 Metachunk* curr = chunks_in_use(i); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2229 while (curr != NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2230 curr->verify(); |
7208
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
7187
diff
changeset
|
2231 verify_chunk_size(curr); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2232 curr = curr->next(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2233 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2234 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2235 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2236 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2237 |
7208
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
7187
diff
changeset
|
2238 void SpaceManager::verify_chunk_size(Metachunk* chunk) { |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
7187
diff
changeset
|
2239 assert(is_humongous(chunk->word_size()) || |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2240 chunk->word_size() == medium_chunk_size() || |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2241 chunk->word_size() == small_chunk_size() || |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2242 chunk->word_size() == specialized_chunk_size(), |
7208
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
7187
diff
changeset
|
2243 "Chunk size is wrong"); |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
7187
diff
changeset
|
2244 return; |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
7187
diff
changeset
|
2245 } |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
7187
diff
changeset
|
2246 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2247 #ifdef ASSERT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2248 void SpaceManager::verify_allocation_total() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2249 // Verification is only guaranteed at a safepoint. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2250 if (SafepointSynchronize::is_at_safepoint()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2251 gclog_or_tty->print_cr("Chunk " PTR_FORMAT " allocation_total " SIZE_FORMAT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2252 " sum_used_in_chunks_in_use " SIZE_FORMAT, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2253 this, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2254 allocation_total(), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2255 sum_used_in_chunks_in_use()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2256 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2257 MutexLockerEx cl(lock(), Mutex::_no_safepoint_check_flag); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2258 assert(allocation_total() == sum_used_in_chunks_in_use(), |
8007
d9058e388631
8007257: NPG: metaspace.cpp: Incorrect arguments in calls to err_msg
mikael
parents:
7447
diff
changeset
|
2259 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
|
2260 " vs " SIZE_FORMAT, |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2261 allocation_total(), sum_used_in_chunks_in_use())); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2262 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2263 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2264 #endif |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2265 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2266 void SpaceManager::dump(outputStream* const out) const { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2267 size_t curr_total = 0; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2268 size_t waste = 0; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2269 uint i = 0; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2270 size_t used = 0; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2271 size_t capacity = 0; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2272 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2273 // 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
|
2274 for (ChunkIndex index = ZeroIndex; |
6885 | 2275 index < NumberOfInUseLists; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2276 index = next_chunk_index(index)) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2277 for (Metachunk* curr = chunks_in_use(index); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2278 curr != NULL; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2279 curr = curr->next()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2280 out->print("%d) ", i++); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2281 curr->print_on(out); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2282 if (TraceMetadataChunkAllocation && Verbose) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2283 block_freelists()->print_on(out); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2284 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2285 curr_total += curr->word_size(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2286 used += curr->used_word_size(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2287 capacity += curr->capacity_word_size(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2288 waste += curr->free_word_size() + curr->overhead();; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2289 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2290 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2291 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2292 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
|
2293 // Free space isn't wasted. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2294 waste -= free; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2295 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2296 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
|
2297 " free " SIZE_FORMAT " capacity " SIZE_FORMAT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2298 " waste " SIZE_FORMAT, curr_total, used, free, capacity, waste); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2299 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2300 |
7185
90273fc0a981
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
6969
diff
changeset
|
2301 #ifndef PRODUCT |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2302 void SpaceManager::mangle_freed_chunks() { |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2303 for (ChunkIndex index = ZeroIndex; |
6885 | 2304 index < NumberOfInUseLists; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2305 index = next_chunk_index(index)) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2306 for (Metachunk* curr = chunks_in_use(index); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2307 curr != NULL; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2308 curr = curr->next()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2309 curr->mangle(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2310 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2311 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2312 } |
7185
90273fc0a981
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
6969
diff
changeset
|
2313 #endif // PRODUCT |
6725
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 // MetaspaceAux |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2316 |
6734 | 2317 size_t MetaspaceAux::used_in_bytes(Metaspace::MetadataType mdtype) { |
6730
5d2156bcb78b
7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents:
6726
diff
changeset
|
2318 size_t used = 0; |
5d2156bcb78b
7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents:
6726
diff
changeset
|
2319 ClassLoaderDataGraphMetaspaceIterator iter; |
5d2156bcb78b
7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents:
6726
diff
changeset
|
2320 while (iter.repeat()) { |
5d2156bcb78b
7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents:
6726
diff
changeset
|
2321 Metaspace* msp = iter.get_next(); |
5d2156bcb78b
7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents:
6726
diff
changeset
|
2322 // Sum allocation_total for each metaspace |
5d2156bcb78b
7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents:
6726
diff
changeset
|
2323 if (msp != NULL) { |
5d2156bcb78b
7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents:
6726
diff
changeset
|
2324 used += msp->used_words(mdtype); |
5d2156bcb78b
7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents:
6726
diff
changeset
|
2325 } |
5d2156bcb78b
7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents:
6726
diff
changeset
|
2326 } |
5d2156bcb78b
7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents:
6726
diff
changeset
|
2327 return used * BytesPerWord; |
5d2156bcb78b
7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents:
6726
diff
changeset
|
2328 } |
5d2156bcb78b
7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents:
6726
diff
changeset
|
2329 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2330 size_t MetaspaceAux::free_in_bytes(Metaspace::MetadataType mdtype) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2331 size_t free = 0; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2332 ClassLoaderDataGraphMetaspaceIterator iter; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2333 while (iter.repeat()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2334 Metaspace* msp = iter.get_next(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2335 if (msp != NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2336 free += msp->free_words(mdtype); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2337 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2338 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2339 return free * BytesPerWord; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2340 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2341 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2342 size_t MetaspaceAux::capacity_in_bytes(Metaspace::MetadataType mdtype) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2343 size_t capacity = free_chunks_total(mdtype); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2344 ClassLoaderDataGraphMetaspaceIterator iter; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2345 while (iter.repeat()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2346 Metaspace* msp = iter.get_next(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2347 if (msp != NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2348 capacity += msp->capacity_words(mdtype); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2349 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2350 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2351 return capacity * BytesPerWord; |
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 size_t MetaspaceAux::reserved_in_bytes(Metaspace::MetadataType mdtype) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2355 size_t reserved = (mdtype == Metaspace::ClassType) ? |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2356 Metaspace::class_space_list()->virtual_space_total() : |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2357 Metaspace::space_list()->virtual_space_total(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2358 return reserved * BytesPerWord; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2359 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2360 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2361 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
|
2362 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2363 size_t MetaspaceAux::free_chunks_total(Metaspace::MetadataType mdtype) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2364 ChunkManager* chunk = (mdtype == Metaspace::ClassType) ? |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2365 Metaspace::class_space_list()->chunk_manager() : |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2366 Metaspace::space_list()->chunk_manager(); |
6969
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
2367 chunk->slow_verify(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2368 return chunk->free_chunks_total(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2369 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2370 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2371 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
|
2372 return free_chunks_total(mdtype) * BytesPerWord; |
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 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2375 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
|
2376 gclog_or_tty->print(", [Metaspace:"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2377 if (PrintGCDetails && Verbose) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2378 gclog_or_tty->print(" " SIZE_FORMAT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2379 "->" SIZE_FORMAT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2380 "(" SIZE_FORMAT "/" SIZE_FORMAT ")", |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2381 prev_metadata_used, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2382 used_in_bytes(), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2383 capacity_in_bytes(), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2384 reserved_in_bytes()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2385 } else { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2386 gclog_or_tty->print(" " SIZE_FORMAT "K" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2387 "->" SIZE_FORMAT "K" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2388 "(" SIZE_FORMAT "K/" SIZE_FORMAT "K)", |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2389 prev_metadata_used / K, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2390 used_in_bytes()/ K, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2391 capacity_in_bytes()/K, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2392 reserved_in_bytes()/ K); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2393 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2394 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2395 gclog_or_tty->print("]"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2396 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2397 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2398 // This is printed when PrintGCDetails |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2399 void MetaspaceAux::print_on(outputStream* out) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2400 Metaspace::MetadataType ct = Metaspace::ClassType; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2401 Metaspace::MetadataType nct = Metaspace::NonClassType; |
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 out->print_cr(" Metaspace total " |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2404 SIZE_FORMAT "K, used " SIZE_FORMAT "K," |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2405 " reserved " SIZE_FORMAT "K", |
6734 | 2406 capacity_in_bytes()/K, used_in_bytes()/K, reserved_in_bytes()/K); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2407 out->print_cr(" data space " |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2408 SIZE_FORMAT "K, used " SIZE_FORMAT "K," |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2409 " reserved " SIZE_FORMAT "K", |
6734 | 2410 capacity_in_bytes(nct)/K, used_in_bytes(nct)/K, reserved_in_bytes(nct)/K); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2411 out->print_cr(" class space " |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2412 SIZE_FORMAT "K, used " SIZE_FORMAT "K," |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2413 " reserved " SIZE_FORMAT "K", |
6734 | 2414 capacity_in_bytes(ct)/K, used_in_bytes(ct)/K, reserved_in_bytes(ct)/K); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2415 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2416 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2417 // Print information for class space and data space separately. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2418 // This is almost the same as above. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2419 void MetaspaceAux::print_on(outputStream* out, Metaspace::MetadataType mdtype) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2420 size_t free_chunks_capacity_bytes = free_chunks_total_in_bytes(mdtype); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2421 size_t capacity_bytes = capacity_in_bytes(mdtype); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2422 size_t used_bytes = used_in_bytes(mdtype); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2423 size_t free_bytes = free_in_bytes(mdtype); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2424 size_t used_and_free = used_bytes + free_bytes + |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2425 free_chunks_capacity_bytes; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2426 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
|
2427 "K + unused in chunks " SIZE_FORMAT "K + " |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2428 " capacity in free chunks " SIZE_FORMAT "K = " SIZE_FORMAT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2429 "K capacity in allocated chunks " SIZE_FORMAT "K", |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2430 used_bytes / K, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2431 free_bytes / K, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2432 free_chunks_capacity_bytes / K, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2433 used_and_free / K, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2434 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
|
2435 // 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
|
2436 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
|
2437 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2438 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2439 // Print total fragmentation for class and data metaspaces separately |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2440 void MetaspaceAux::print_waste(outputStream* out) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2441 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2442 size_t specialized_waste = 0, small_waste = 0, medium_waste = 0, large_waste = 0; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2443 size_t specialized_count = 0, small_count = 0, medium_count = 0, large_count = 0; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2444 size_t cls_specialized_waste = 0, cls_small_waste = 0, cls_medium_waste = 0, cls_large_waste = 0; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2445 size_t cls_specialized_count = 0, cls_small_count = 0, cls_medium_count = 0, cls_large_count = 0; |
6725
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 ClassLoaderDataGraphMetaspaceIterator iter; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2448 while (iter.repeat()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2449 Metaspace* msp = iter.get_next(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2450 if (msp != NULL) { |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2451 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
|
2452 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
|
2453 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
|
2454 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
|
2455 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
|
2456 medium_count += msp->vsm()->sum_count_in_chunks_in_use(MediumIndex); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2457 large_waste += msp->vsm()->sum_waste_in_chunks_in_use(HumongousIndex); |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2458 large_count += msp->vsm()->sum_count_in_chunks_in_use(HumongousIndex); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2459 |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2460 cls_specialized_waste += msp->class_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
|
2461 cls_specialized_count += msp->class_vsm()->sum_count_in_chunks_in_use(SpecializedIndex); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2462 cls_small_waste += msp->class_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
|
2463 cls_small_count += msp->class_vsm()->sum_count_in_chunks_in_use(SmallIndex); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2464 cls_medium_waste += msp->class_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
|
2465 cls_medium_count += msp->class_vsm()->sum_count_in_chunks_in_use(MediumIndex); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2466 cls_large_waste += msp->class_vsm()->sum_waste_in_chunks_in_use(HumongousIndex); |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2467 cls_large_count += msp->class_vsm()->sum_count_in_chunks_in_use(HumongousIndex); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2468 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2469 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2470 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
|
2471 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
|
2472 SIZE_FORMAT " small(s) " SIZE_FORMAT ", " |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2473 SIZE_FORMAT " medium(s) " SIZE_FORMAT, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2474 specialized_count, specialized_waste, small_count, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2475 small_waste, medium_count, medium_waste); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2476 out->print_cr(" class: " SIZE_FORMAT " specialized(s) " SIZE_FORMAT ", " |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2477 SIZE_FORMAT " small(s) " SIZE_FORMAT, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2478 cls_specialized_count, cls_specialized_waste, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2479 cls_small_count, cls_small_waste); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2480 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2481 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2482 // Dump global metaspace things from the end of ClassLoaderDataGraph |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2483 void MetaspaceAux::dump(outputStream* out) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2484 out->print_cr("All Metaspace:"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2485 out->print("data space: "); print_on(out, Metaspace::NonClassType); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2486 out->print("class space: "); print_on(out, Metaspace::ClassType); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2487 print_waste(out); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2488 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2489 |
6969
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
2490 void MetaspaceAux::verify_free_chunks() { |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
2491 Metaspace::space_list()->chunk_manager()->verify(); |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
2492 Metaspace::class_space_list()->chunk_manager()->verify(); |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
2493 } |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
2494 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2495 // Metaspace methods |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2496 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2497 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
|
2498 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
|
2499 |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2500 Metaspace::Metaspace(Mutex* lock, MetaspaceType type) { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2501 initialize(lock, type); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2502 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2503 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2504 Metaspace::~Metaspace() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2505 delete _vsm; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2506 delete _class_vsm; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2507 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2508 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2509 VirtualSpaceList* Metaspace::_space_list = NULL; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2510 VirtualSpaceList* Metaspace::_class_space_list = NULL; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2511 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2512 #define VIRTUALSPACEMULTIPLIER 2 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2513 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2514 void Metaspace::global_initialize() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2515 // Initialize the alignment for shared spaces. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2516 int max_alignment = os::vm_page_size(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2517 MetaspaceShared::set_max_alignment(max_alignment); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2518 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2519 if (DumpSharedSpaces) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2520 SharedReadOnlySize = align_size_up(SharedReadOnlySize, max_alignment); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2521 SharedReadWriteSize = align_size_up(SharedReadWriteSize, max_alignment); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2522 SharedMiscDataSize = align_size_up(SharedMiscDataSize, max_alignment); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2523 SharedMiscCodeSize = align_size_up(SharedMiscCodeSize, max_alignment); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2524 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2525 // 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
|
2526 // 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
|
2527 // remainder is the misc code and data chunks. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2528 size_t total = align_size_up(SharedReadOnlySize + SharedReadWriteSize + |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2529 SharedMiscDataSize + SharedMiscCodeSize, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2530 os::vm_allocation_granularity()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2531 size_t word_size = total/wordSize; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2532 _space_list = new VirtualSpaceList(word_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2533 } else { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2534 // 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
|
2535 // 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
|
2536 // the addresses don't conflict) |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2537 if (UseSharedSpaces) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2538 FileMapInfo* mapinfo = new FileMapInfo(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2539 memset(mapinfo, 0, sizeof(FileMapInfo)); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2540 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2541 // 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
|
2542 // initialization fails, shared spaces [UseSharedSpaces] are |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2543 // disabled and the file is closed. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2544 // Map in spaces now also |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2545 if (mapinfo->initialize() && MetaspaceShared::map_shared_spaces(mapinfo)) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2546 FileMapInfo::set_current_info(mapinfo); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2547 } else { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2548 assert(!mapinfo->is_open() && !UseSharedSpaces, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2549 "archive file not closed or shared spaces not disabled."); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2550 } |
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 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2553 // Initialize these before initializing the VirtualSpaceList |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2554 _first_chunk_word_size = InitialBootClassLoaderMetaspaceSize / BytesPerWord; |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2555 _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
|
2556 // 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
|
2557 // 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
|
2558 // from there. This size calculated by -version. |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2559 _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
|
2560 (ClassMetaspaceSize/BytesPerWord)*2); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2561 _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
|
2562 // Arbitrarily set the initial virtual space to a multiple |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2563 // of the boot class loader size. |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2564 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
|
2565 // Initialize the list of virtual spaces. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2566 _space_list = new VirtualSpaceList(word_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2567 } |
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 // For UseCompressedKlassPointers the class space is reserved as a piece of the |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2571 // Java heap because the compression algorithm is the same for each. The |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2572 // argument passed in is at the top of the compressed space |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2573 void Metaspace::initialize_class_space(ReservedSpace rs) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2574 // The reserved space size may be bigger because of alignment, esp with UseLargePages |
8007
d9058e388631
8007257: NPG: metaspace.cpp: Incorrect arguments in calls to err_msg
mikael
parents:
7447
diff
changeset
|
2575 assert(rs.size() >= ClassMetaspaceSize, |
d9058e388631
8007257: NPG: metaspace.cpp: Incorrect arguments in calls to err_msg
mikael
parents:
7447
diff
changeset
|
2576 err_msg(SIZE_FORMAT " != " UINTX_FORMAT, rs.size(), ClassMetaspaceSize)); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2577 _class_space_list = new VirtualSpaceList(rs); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2578 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2579 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2580 void Metaspace::initialize(Mutex* lock, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2581 MetaspaceType type) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2582 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2583 assert(space_list() != NULL, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2584 "Metadata VirtualSpaceList has not been initialized"); |
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 _vsm = new SpaceManager(lock, space_list()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2587 if (_vsm == NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2588 return; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2589 } |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2590 size_t word_size; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2591 size_t class_word_size; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2592 vsm()->get_initial_chunk_sizes(type, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2593 &word_size, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2594 &class_word_size); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2595 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2596 assert(class_space_list() != NULL, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2597 "Class VirtualSpaceList has not been initialized"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2598 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2599 // Allocate SpaceManager for classes. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2600 _class_vsm = new SpaceManager(lock, class_space_list()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2601 if (_class_vsm == NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2602 return; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2603 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2604 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2605 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
|
2606 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2607 // Allocate chunk for metadata objects |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2608 Metachunk* new_chunk = |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2609 space_list()->get_initialization_chunk(word_size, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2610 vsm()->medium_chunk_bunch()); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2611 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
|
2612 if (new_chunk != NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2613 // 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
|
2614 vsm()->add_chunk(new_chunk, true); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2615 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2616 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2617 // Allocate chunk for class metadata objects |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2618 Metachunk* class_chunk = |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2619 class_space_list()->get_initialization_chunk(class_word_size, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2620 class_vsm()->medium_chunk_bunch()); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2621 if (class_chunk != NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2622 class_vsm()->add_chunk(class_chunk, true); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2623 } |
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 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2626 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
|
2627 size_t byte_size = word_size * wordSize; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2628 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
|
2629 } |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2630 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2631 MetaWord* Metaspace::allocate(size_t word_size, MetadataType mdtype) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2632 // DumpSharedSpaces doesn't use class metadata area (yet) |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2633 if (mdtype == ClassType && !DumpSharedSpaces) { |
6885 | 2634 return class_vsm()->allocate(word_size); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2635 } else { |
6885 | 2636 return vsm()->allocate(word_size); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2637 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2638 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2639 |
6753
8da5e203b993
7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
jmasa
parents:
6736
diff
changeset
|
2640 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
|
2641 MetaWord* result; |
8da5e203b993
7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
jmasa
parents:
6736
diff
changeset
|
2642 MetaspaceGC::set_expand_after_GC(true); |
8da5e203b993
7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
jmasa
parents:
6736
diff
changeset
|
2643 size_t before_inc = MetaspaceGC::capacity_until_GC(); |
8da5e203b993
7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
jmasa
parents:
6736
diff
changeset
|
2644 size_t delta_words = MetaspaceGC::delta_capacity_until_GC(word_size); |
8da5e203b993
7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
jmasa
parents:
6736
diff
changeset
|
2645 MetaspaceGC::inc_capacity_until_GC(delta_words); |
8da5e203b993
7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
jmasa
parents:
6736
diff
changeset
|
2646 if (PrintGCDetails && Verbose) { |
8da5e203b993
7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
jmasa
parents:
6736
diff
changeset
|
2647 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
|
2648 " 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
|
2649 } |
6885 | 2650 |
6753
8da5e203b993
7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
jmasa
parents:
6736
diff
changeset
|
2651 result = allocate(word_size, mdtype); |
8da5e203b993
7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
jmasa
parents:
6736
diff
changeset
|
2652 |
8da5e203b993
7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
jmasa
parents:
6736
diff
changeset
|
2653 return result; |
8da5e203b993
7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
jmasa
parents:
6736
diff
changeset
|
2654 } |
8da5e203b993
7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
jmasa
parents:
6736
diff
changeset
|
2655 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2656 // Space allocated in the Metaspace. This may |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2657 // be across several metadata virtual spaces. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2658 char* Metaspace::bottom() const { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2659 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
|
2660 return (char*)vsm()->current_chunk()->bottom(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2661 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2662 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2663 size_t Metaspace::used_words(MetadataType mdtype) const { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2664 // return vsm()->allocation_total(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2665 return mdtype == ClassType ? class_vsm()->sum_used_in_chunks_in_use() : |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2666 vsm()->sum_used_in_chunks_in_use(); // includes overhead! |
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 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2669 size_t Metaspace::free_words(MetadataType mdtype) const { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2670 return mdtype == ClassType ? class_vsm()->sum_free_in_chunks_in_use() : |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2671 vsm()->sum_free_in_chunks_in_use(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2672 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2673 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2674 // Space capacity in the Metaspace. It includes |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2675 // space in the list of chunks from which allocations |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2676 // 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
|
2677 // in the space available in the dictionary which |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2678 // is already counted in some chunk. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2679 size_t Metaspace::capacity_words(MetadataType mdtype) const { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2680 return mdtype == ClassType ? class_vsm()->sum_capacity_in_chunks_in_use() : |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2681 vsm()->sum_capacity_in_chunks_in_use(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2682 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2683 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2684 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
|
2685 if (SafepointSynchronize::is_at_safepoint()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2686 assert(Thread::current()->is_VM_thread(), "should be the VM thread"); |
6885 | 2687 // Don't take Heap_lock |
2688 MutexLocker ml(vsm()->lock()); | |
2689 if (word_size < TreeChunk<Metablock, FreeList>::min_size()) { | |
2690 // Dark matter. Too small for dictionary. | |
2691 #ifdef ASSERT | |
2692 Copy::fill_to_words((HeapWord*)ptr, word_size, 0xf5f5f5f5); | |
2693 #endif | |
2694 return; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2695 } |
6885 | 2696 if (is_class) { |
2697 class_vsm()->deallocate(ptr, word_size); | |
2698 } else { | |
2699 vsm()->deallocate(ptr, word_size); | |
2700 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2701 } else { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2702 MutexLocker ml(vsm()->lock()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2703 |
6885 | 2704 if (word_size < TreeChunk<Metablock, FreeList>::min_size()) { |
2705 // Dark matter. Too small for dictionary. | |
2706 #ifdef ASSERT | |
2707 Copy::fill_to_words((HeapWord*)ptr, word_size, 0xf5f5f5f5); | |
2708 #endif | |
2709 return; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2710 } |
6885 | 2711 if (is_class) { |
2712 class_vsm()->deallocate(ptr, word_size); | |
2713 } else { | |
2714 vsm()->deallocate(ptr, word_size); | |
2715 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2716 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2717 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2718 |
6885 | 2719 Metablock* Metaspace::allocate(ClassLoaderData* loader_data, size_t word_size, |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2720 bool read_only, MetadataType mdtype, TRAPS) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2721 if (HAS_PENDING_EXCEPTION) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2722 assert(false, "Should not allocate with exception pending"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2723 return NULL; // caller does a CHECK_NULL too |
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 // 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
|
2727 MetaWord* result = NULL; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2728 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2729 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
|
2730 "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
|
2731 // 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
|
2732 // 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
|
2733 // to revisit this for application class data sharing. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2734 if (DumpSharedSpaces) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2735 if (read_only) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2736 result = loader_data->ro_metaspace()->allocate(word_size, NonClassType); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2737 } else { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2738 result = loader_data->rw_metaspace()->allocate(word_size, NonClassType); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2739 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2740 if (result == NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2741 report_out_of_shared_space(read_only ? SharedReadOnly : SharedReadWrite); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2742 } |
6885 | 2743 return Metablock::initialize(result, word_size); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2744 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2745 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2746 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
|
2747 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2748 if (result == NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2749 // Try to clean out some memory and retry. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2750 result = |
6885 | 2751 Universe::heap()->collector_policy()->satisfy_failed_metadata_allocation( |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2752 loader_data, word_size, mdtype); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2753 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2754 // 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
|
2755 if (result == NULL) { |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2756 if (Verbose && TraceMetadataChunkAllocation) { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2757 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
|
2758 SIZE_FORMAT, word_size); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2759 if (loader_data->metaspace_or_null() != NULL) loader_data->metaspace_or_null()->dump(gclog_or_tty); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2760 MetaspaceAux::dump(gclog_or_tty); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2761 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2762 // -XX:+HeapDumpOnOutOfMemoryError and -XX:OnOutOfMemoryError support |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2763 report_java_out_of_memory("Metadata space"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2764 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2765 if (JvmtiExport::should_post_resource_exhausted()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2766 JvmtiExport::post_resource_exhausted( |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2767 JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2768 "Metadata space"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2769 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2770 THROW_OOP_0(Universe::out_of_memory_error_perm_gen()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2771 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2772 } |
6885 | 2773 return Metablock::initialize(result, word_size); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2774 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2775 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2776 void Metaspace::print_on(outputStream* out) const { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2777 // Print both class virtual space counts and metaspace. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2778 if (Verbose) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2779 vsm()->print_on(out); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2780 class_vsm()->print_on(out); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2781 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2782 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2783 |
7176
59c790074993
8003635: NPG: AsynchGetCallTrace broken by Method* virtual call
coleenp
parents:
6969
diff
changeset
|
2784 bool Metaspace::contains(const void * ptr) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2785 if (MetaspaceShared::is_in_shared_space(ptr)) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2786 return true; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2787 } |
7176
59c790074993
8003635: NPG: AsynchGetCallTrace broken by Method* virtual call
coleenp
parents:
6969
diff
changeset
|
2788 // 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
|
2789 // 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
|
2790 // 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
|
2791 // 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
|
2792 // caller in MetaspaceObj::is_metadata() function. |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2793 return space_list()->contains(ptr) || class_space_list()->contains(ptr); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2794 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2795 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2796 void Metaspace::verify() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2797 vsm()->verify(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2798 class_vsm()->verify(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2799 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2800 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2801 void Metaspace::dump(outputStream* const out) const { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2802 if (UseMallocOnly) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2803 // Just print usage for now |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2804 out->print_cr("usage %d", used_words(Metaspace::NonClassType)); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2805 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2806 out->print_cr("\nVirtual space manager: " INTPTR_FORMAT, vsm()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2807 vsm()->dump(out); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2808 out->print_cr("\nClass space manager: " INTPTR_FORMAT, class_vsm()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2809 class_vsm()->dump(out); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2810 } |