author | stuefe |
Tue, 10 Sep 2019 09:24:05 +0200 | |
branch | stuefe-new-metaspace-branch |
changeset 58063 | bdf136b8ae0e |
parent 54623 | 1126f0607c70 |
child 58099 | 5aeb07390c74 |
permissions | -rw-r--r-- |
50193 | 1 |
/* |
54623
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
54437
diff
changeset
|
2 |
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. |
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
3 |
* Copyright (c) 2018, 2019 SAP SE. All rights reserved. |
51525 | 4 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5 |
* |
|
6 |
* This code is free software; you can redistribute it and/or modify it |
|
7 |
* under the terms of the GNU General Public License version 2 only, as |
|
8 |
* published by the Free Software Foundation. |
|
50193 | 9 |
* |
51525 | 10 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
14 |
* accompanied this code). |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License version |
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
19 |
* |
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
21 |
* or visit www.oracle.com if you need additional information or have any |
|
22 |
* questions. |
|
23 |
* |
|
50193 | 24 |
*/ |
25 |
||
26 |
||
27 |
#include "precompiled.hpp" |
|
28 |
#include "logging/log.hpp" |
|
29 |
#include "memory/metaspace.hpp" |
|
30 |
#include "memory/metaspace/chunkManager.hpp" |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
31 |
#include "memory/metaspace/counter.hpp" |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
32 |
#include "memory/metaspace/commitLimiter.hpp" |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
33 |
#include "memory/metaspace/counter.hpp" |
50193 | 34 |
#include "memory/metaspace/virtualSpaceList.hpp" |
35 |
#include "memory/metaspace/virtualSpaceNode.hpp" |
|
36 |
#include "runtime/mutexLocker.hpp" |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
37 |
|
50193 | 38 |
|
39 |
namespace metaspace { |
|
40 |
||
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
41 |
static int next_node_id = 0; |
50193 | 42 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
43 |
// Create a new, empty, expandable list. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
44 |
VirtualSpaceList::VirtualSpaceList(const char* name, CommitLimiter* commit_limiter) |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
45 |
: _name(name), |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
46 |
_first_node(NULL), |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
47 |
_can_expand(true), |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
48 |
_can_purge(true), |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
49 |
_commit_limiter(commit_limiter), |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
50 |
_reserved_words_counter(), |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
51 |
_committed_words_counter() |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
52 |
{ |
50193 | 53 |
} |
54 |
||
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
55 |
// Create a new list. The list will contain one node only, which uses the given ReservedSpace. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
56 |
// It will be not expandable beyond that first node. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
57 |
VirtualSpaceList::VirtualSpaceList(const char* name, ReservedSpace rs, CommitLimiter* commit_limiter) |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
58 |
: _name(name), |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
59 |
_first_node(NULL), |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
60 |
_can_expand(false), |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
61 |
_can_purge(false), |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
62 |
_commit_limiter(commit_limiter), |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
63 |
_reserved_words_counter(), |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
64 |
_committed_words_counter() |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
65 |
{ |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
66 |
// Create the first node spanning the existing ReservedSpace. This will be the only node created |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
67 |
// for this list since we cannot expand. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
68 |
VirtualSpaceNode* vsn = VirtualSpaceNode::create_node(next_node_id++, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
69 |
rs, _commit_limiter, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
70 |
&_reserved_words_counter, &_committed_words_counter); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
71 |
assert(vsn != NULL, "node creation failed"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
72 |
_first_node = vsn; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
73 |
_first_node->set_next(NULL); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
74 |
_nodes_counter.increment(); |
50193 | 75 |
} |
76 |
||
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
77 |
VirtualSpaceList::~VirtualSpaceList() { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
78 |
// Note: normally, there is no reason ever to delete a vslist since they are |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
79 |
// global objects, but for gtests it makes sense to allow this. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
80 |
VirtualSpaceNode* vsn = _first_node; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
81 |
VirtualSpaceNode* vsn2 = vsn; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
82 |
while (vsn != NULL) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
83 |
vsn2 = vsn->next(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
84 |
delete vsn; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
85 |
vsn = vsn2; |
50193 | 86 |
} |
87 |
} |
|
88 |
||
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
89 |
// Create a new node and append it to the list. After |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
90 |
// this function, _current_node shall point to a new empty node. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
91 |
// List must be expandable for this to work. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
92 |
void VirtualSpaceList::create_new_node() { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
93 |
assert(_can_expand, "List is not expandable"); |
50193 | 94 |
assert_lock_strong(MetaspaceExpand_lock); |
95 |
||
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
96 |
VirtualSpaceNode* vsn = VirtualSpaceNode::create_node(next_node_id ++, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
97 |
Settings::virtual_space_node_default_word_size(), |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
98 |
_commit_limiter, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
99 |
&_reserved_words_counter, &_committed_words_counter); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
100 |
assert(vsn != NULL, "node creation failed"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
101 |
vsn->set_next(_first_node); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
102 |
_first_node = vsn; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
103 |
_nodes_counter.increment(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
104 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
105 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
106 |
// Allocate a root chunk from this list. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
107 |
// Note: this just returns a chunk whose memory is reserved; no memory is committed yet. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
108 |
// Hence, before using this chunk, it must be committed. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
109 |
// Also, no limits are checked, since no committing takes place. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
110 |
Metachunk* VirtualSpaceList::allocate_root_chunk() { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
111 |
assert_lock_strong(MetaspaceExpand_lock); |
50193 | 112 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
113 |
log_debug(metaspace)("VirtualSpaceList %s: allocate root chunk.", _name); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
114 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
115 |
if (_first_node == NULL || |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
116 |
_first_node->free_words() == 0) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
117 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
118 |
// The current node is fully used up. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
119 |
log_debug(metaspace)("VirtualSpaceList %s: need new node.", _name); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
120 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
121 |
// Since all allocations from a VirtualSpaceNode happen in |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
122 |
// root-chunk-size units, and the node size must be root-chunk-size aligned, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
123 |
// we should never have left-over space. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
124 |
assert(_first_node == NULL || |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
125 |
_first_node->free_words() == 0, "Sanity"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
126 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
127 |
if (_can_expand) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
128 |
create_new_node(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
129 |
} else { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
130 |
return NULL; // We cannot expand this list. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
131 |
} |
50193 | 132 |
} |
133 |
||
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
134 |
Metachunk* c = _first_node->allocate_root_chunk(); |
50193 | 135 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
136 |
assert(c != NULL, "This should have worked"); |
54437
2ae93028bef3
8221539: [metaspace] Improve MetaspaceObj::is_metaspace_obj() and friends
stuefe
parents:
53970
diff
changeset
|
137 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
138 |
return c; |
54437
2ae93028bef3
8221539: [metaspace] Improve MetaspaceObj::is_metaspace_obj() and friends
stuefe
parents:
53970
diff
changeset
|
139 |
|
50193 | 140 |
} |
141 |
||
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
142 |
// Attempts to purge nodes. This will remove and delete nodes which only contain free chunks. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
143 |
// The free chunks are removed from the freelists before the nodes are deleted. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
144 |
// Return number of purged nodes. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
145 |
int VirtualSpaceList::purge(MetachunkListCluster* freelists) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
146 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
147 |
// Note: I am not sure all that purging business is even necessary anymore |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
148 |
// since we have a good reclaim mechanism in place. Need to measure. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
149 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
150 |
assert_lock_strong(MetaspaceExpand_lock); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
151 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
152 |
if (_can_purge == false) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
153 |
log_debug(metaspace)("VirtualSpaceList %s: cannot purge this list.", _name); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
154 |
return 0; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
155 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
156 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
157 |
log_debug(metaspace)("VirtualSpaceList %s: purging...", _name); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
158 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
159 |
VirtualSpaceNode* vsn = _first_node; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
160 |
VirtualSpaceNode* prev_vsn = NULL; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
161 |
int num = 0, num_purged = 0; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
162 |
while (vsn != NULL) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
163 |
VirtualSpaceNode* next_vsn = vsn->next(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
164 |
bool purged = vsn->attempt_purge(freelists); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
165 |
if (purged) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
166 |
// Note: from now on do not dereference vsn! |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
167 |
log_debug(metaspace)("VirtualSpaceList %s: purged node @" PTR_FORMAT, _name, p2i(vsn)); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
168 |
if (_first_node == vsn) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
169 |
_first_node = next_vsn; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
170 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
171 |
DEBUG_ONLY(vsn = (VirtualSpaceNode*)0xdeadbeef;) |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
172 |
if (prev_vsn != NULL) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
173 |
prev_vsn->set_next(next_vsn); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
174 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
175 |
num_purged ++; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
176 |
_nodes_counter.decrement(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
177 |
} else { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
178 |
prev_vsn = vsn; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
179 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
180 |
vsn = next_vsn; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
181 |
num ++; |
50193 | 182 |
} |
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
183 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
184 |
log_debug(metaspace)("VirtualSpaceList %s: purged %d/%d nodes.", _name, num_purged, num); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
185 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
186 |
return num_purged; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
187 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
188 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
189 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
190 |
// Print all nodes in this space list. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
191 |
void VirtualSpaceList::print_on(outputStream* st) const { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
192 |
MutexLocker fcl(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
193 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
194 |
st->print_cr("vsl %s:", _name); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
195 |
const VirtualSpaceNode* vsn = _first_node; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
196 |
int n = 0; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
197 |
while (vsn != NULL) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
198 |
st->print("- node #%d: ", n); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
199 |
vsn->print_on(st); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
200 |
vsn = vsn->next(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
201 |
n ++; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
202 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
203 |
st->print_cr("- total %d nodes, " SIZE_FORMAT " reserved words, " SIZE_FORMAT " committed words.", |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
204 |
n, reserved_words(), committed_words()); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
205 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
206 |
|
50193 | 207 |
#ifdef ASSERT |
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
208 |
void VirtualSpaceList::verify_locked(bool slow) const { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
209 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
210 |
assert_lock_strong(MetaspaceExpand_lock); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
211 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
212 |
assert(_name != NULL, "Sanity"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
213 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
214 |
int n = 0; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
215 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
216 |
if (_first_node != NULL) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
217 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
218 |
size_t total_reserved_words = 0; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
219 |
size_t total_committed_words = 0; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
220 |
const VirtualSpaceNode* vsn = _first_node; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
221 |
while (vsn != NULL) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
222 |
n ++; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
223 |
vsn->verify(slow); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
224 |
total_reserved_words += vsn->word_size(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
225 |
total_committed_words += vsn->committed_words(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
226 |
vsn = vsn->next(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
227 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
228 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
229 |
_nodes_counter.check(n); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
230 |
_reserved_words_counter.check(total_reserved_words); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
231 |
_committed_words_counter.check(total_committed_words); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
232 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
233 |
} else { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
234 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
235 |
_reserved_words_counter.check(0); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
236 |
_committed_words_counter.check(0); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
237 |
|
50193 | 238 |
} |
239 |
} |
|
240 |
||
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
241 |
void VirtualSpaceList::verify(bool slow) const { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
242 |
MutexLocker fcl(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
243 |
verify_locked(slow); |
50193 | 244 |
} |
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
245 |
#endif |
50193 | 246 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
247 |
// Returns true if this pointer is contained in one of our nodes. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
248 |
bool VirtualSpaceList::contains(const MetaWord* p) const { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
249 |
const VirtualSpaceNode* vsn = _first_node; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
250 |
while (vsn != NULL) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
251 |
if (vsn->contains(p)) { |
50193 | 252 |
return true; |
253 |
} |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
254 |
vsn = vsn->next(); |
50193 | 255 |
} |
256 |
return false; |
|
257 |
} |
|
258 |
||
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
259 |
VirtualSpaceList* VirtualSpaceList::_vslist_class = NULL; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
260 |
VirtualSpaceList* VirtualSpaceList::_vslist_nonclass = NULL; |
50193 | 261 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
262 |
void VirtualSpaceList::set_vslist_class(VirtualSpaceList* vsl) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
263 |
assert(_vslist_class == NULL, "Sanity"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
264 |
_vslist_class = vsl; |
50193 | 265 |
} |
266 |
||
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
267 |
void VirtualSpaceList::set_vslist_nonclass(VirtualSpaceList* vsl) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
268 |
assert(_vslist_nonclass == NULL, "Sanity"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54623
diff
changeset
|
269 |
_vslist_nonclass = vsl; |
54437
2ae93028bef3
8221539: [metaspace] Improve MetaspaceObj::is_metaspace_obj() and friends
stuefe
parents:
53970
diff
changeset
|
270 |
} |
2ae93028bef3
8221539: [metaspace] Improve MetaspaceObj::is_metaspace_obj() and friends
stuefe
parents:
53970
diff
changeset
|
271 |
|
50193 | 272 |
} // namespace metaspace |
273 |