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