author | stuefe |
Mon, 21 Oct 2019 18:15:53 +0200 | |
branch | stuefe-new-metaspace-branch |
changeset 58717 | 5e9e519e5dc9 |
parent 58227 | 0e7d9a23261e |
permissions | -rw-r--r-- |
14635
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
1 |
/* |
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
2 |
* Copyright (c) 2019, SAP SE. All rights reserved. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
3 |
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
14635
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
4 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
5 |
* |
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
6 |
* This code is free software; you can redistribute it and/or modify it |
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
7 |
* under the terms of the GNU General Public License version 2 only, as |
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
8 |
* published by the Free Software Foundation. |
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
9 |
* |
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that |
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
14 |
* accompanied this code). |
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
15 |
* |
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
16 |
* You should have received a copy of the GNU General Public License version |
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation, |
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
19 |
* |
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
21 |
* or visit www.oracle.com if you need additional information or have any |
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
22 |
* questions. |
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
23 |
* |
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
24 |
*/ |
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
25 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
26 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
27 |
#include <memory/metaspace/settings.hpp> |
14635
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
28 |
#include "precompiled.hpp" |
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
29 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
30 |
#include "logging/log.hpp" |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
31 |
#include "memory/metaspace/chunkLevel.hpp" |
50193 | 32 |
#include "memory/metaspace/metachunk.hpp" |
58227 | 33 |
#include "memory/metaspace/metaDebug.hpp" |
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
34 |
#include "memory/metaspace/metaspaceCommon.hpp" |
50193 | 35 |
#include "memory/metaspace/virtualSpaceNode.hpp" |
58227 | 36 |
#include "runtime/mutexLocker.hpp" |
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
37 |
|
46625 | 38 |
#include "utilities/align.hpp" |
14635
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
39 |
#include "utilities/copy.hpp" |
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
40 |
#include "utilities/debug.hpp" |
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
41 |
|
50193 | 42 |
namespace metaspace { |
14635
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
43 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
44 |
// Make sure that the Klass alignment also agree. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
45 |
STATIC_ASSERT(Metachunk::allocation_alignment_bytes == (size_t)KlassAlignmentInBytes); |
20730
59f433c86d9d
8026392: Metachunks and Metablocks are using a too large alignment
stefank
parents:
20729
diff
changeset
|
46 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
47 |
// Return a single char presentation of the state ('f', 'u', 'd') |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
48 |
char Metachunk::get_state_char() const { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
49 |
switch (_state) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
50 |
case state_free: return 'f'; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
51 |
case state_in_use: return 'u'; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
52 |
case state_dead: return 'd'; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
53 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
54 |
return '?'; |
20729 | 55 |
} |
56 |
||
58227 | 57 |
#ifdef ASSERT |
58 |
void Metachunk::assert_have_expand_lock() { |
|
59 |
assert_lock_strong(MetaspaceExpand_lock); |
|
60 |
} |
|
61 |
#endif |
|
62 |
||
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
63 |
// Commit uncommitted section of the chunk. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
64 |
// Fails if we hit a commit limit. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
65 |
bool Metachunk::commit_up_to(size_t new_committed_words) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
66 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
67 |
// Please note: |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
68 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
69 |
// VirtualSpaceNode::ensure_range_is_committed(), when called over a range containing both committed and uncommitted parts, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
70 |
// will replace the whole range with a new mapping, thus erasing the existing content in the committed parts. Therefore |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
71 |
// we must make sure never to call VirtualSpaceNode::ensure_range_is_committed() over a range containing live data. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
72 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
73 |
// Luckily, this cannot happen by design. We have two cases: |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
74 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
75 |
// 1) chunks equal or larger than a commit granule. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
76 |
// In this case, due to chunk geometry, the chunk should cover whole commit granules (in other words, a chunk equal or larger than |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
77 |
// a commit granule will never share a granule with a neighbor). That means whatever we commit or uncommit here does not affect |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
78 |
// neighboring chunks. We only have to take care not to re-commit used parts of ourself. We do this by moving the committed_words |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
79 |
// limit in multiple of commit granules. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
80 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
81 |
// 2) chunks smaller than a commit granule. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
82 |
// In this case, a chunk shares a single commit granule with its neighbors. But this never can be a problem: |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
83 |
// - Either the commit granule is already committed (and maybe the neighbors contain live data). In that case calling |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
84 |
// ensure_range_is_committed() will do nothing. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
85 |
// - Or the commit granule is not committed, but in this case, the neighbors are uncommitted too and cannot contain live data. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
86 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
87 |
#ifdef ASSERT |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
88 |
if (word_size() >= Settings::commit_granule_words()) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
89 |
// case (1) |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
90 |
assert(is_aligned(base(), Settings::commit_granule_bytes()) && |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
91 |
is_aligned(end(), Settings::commit_granule_bytes()), |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
92 |
"Chunks larger than a commit granule must cover whole granules."); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
93 |
assert(is_aligned(_committed_words, Settings::commit_granule_words()), |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
94 |
"The commit boundary must be aligned to commit granule size"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
95 |
assert(_used_words <= _committed_words, "Sanity"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
96 |
} else { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
97 |
// case (2) |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
98 |
assert(_committed_words == 0 || _committed_words == word_size(), "Sanity"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
99 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
100 |
#endif |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
101 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
102 |
// We should hold the expand lock at this point. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
103 |
assert_lock_strong(MetaspaceExpand_lock); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
104 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
105 |
const size_t commit_from = _committed_words; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
106 |
const size_t commit_to = MIN2(align_up(new_committed_words, Settings::commit_granule_words()), word_size()); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
107 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
108 |
assert(commit_from >= used_words(), "Sanity"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
109 |
assert(commit_to <= word_size(), "Sanity"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
110 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
111 |
if (commit_to > commit_from) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
112 |
log_debug(metaspace)("Chunk " METACHUNK_FORMAT ": attempting to move commit line to " |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
113 |
SIZE_FORMAT " words.", METACHUNK_FORMAT_ARGS(this), commit_to); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
114 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
115 |
if (!_vsnode->ensure_range_is_committed(base() + commit_from, commit_to - commit_from)) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
116 |
DEBUG_ONLY(verify(true);) |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
117 |
return false; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
118 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
119 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
120 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
121 |
// Remember how far we have committed. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
122 |
_committed_words = commit_to; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
123 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
124 |
DEBUG_ONLY(verify(true);) |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
125 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
126 |
return true; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
127 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
128 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
129 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
130 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
131 |
// Ensure that chunk is committed up to at least new_committed_words words. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
132 |
// Fails if we hit a commit limit. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
133 |
bool Metachunk::ensure_committed(size_t new_committed_words) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
134 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
135 |
bool rc = true; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
136 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
137 |
if (new_committed_words > committed_words()) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
138 |
MutexLocker cl(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
139 |
rc = commit_up_to(new_committed_words); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
140 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
141 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
142 |
return rc; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
143 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
144 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
145 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
146 |
bool Metachunk::ensure_committed_locked(size_t new_committed_words) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
147 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
148 |
// the .._locked() variant should be called if we own the lock already. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
149 |
assert_lock_strong(MetaspaceExpand_lock); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
150 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
151 |
bool rc = true; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
152 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
153 |
if (new_committed_words > committed_words()) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
154 |
rc = commit_up_to(new_committed_words); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
155 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
156 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
157 |
return rc; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
158 |
|
20729 | 159 |
} |
14635
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
160 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
161 |
// Uncommit chunk area. The area must be a common multiple of the |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
162 |
// commit granule size (in other words, we cannot uncommit chunks smaller than |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
163 |
// a commit granule size). |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
164 |
void Metachunk::uncommit() { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
165 |
MutexLocker cl(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
166 |
uncommit_locked(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
167 |
} |
14635
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
168 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
169 |
void Metachunk::uncommit_locked() { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
170 |
// Only uncommit chunks which are free, have no used words set (extra precaution) and are equal or larger in size than a single commit granule. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
171 |
assert_lock_strong(MetaspaceExpand_lock); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
172 |
assert(_state == state_free && _used_words == 0 && word_size() >= Settings::commit_granule_words(), |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
173 |
"Only free chunks equal or larger than commit granule size can be uncommitted " |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
174 |
"(chunk " METACHUNK_FULL_FORMAT ").", METACHUNK_FULL_FORMAT_ARGS(this)); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
175 |
if (word_size() >= Settings::commit_granule_words()) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
176 |
_vsnode->uncommit_range(base(), word_size()); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
177 |
_committed_words = 0; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
178 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
179 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
180 |
void Metachunk::set_committed_words(size_t v) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
181 |
// Set committed words. Since we know that we only commit whole commit granules, we can round up v here. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
182 |
v = MIN2(align_up(v, Settings::commit_granule_words()), word_size()); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
183 |
_committed_words = v; |
14635
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
184 |
} |
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
185 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
186 |
// Allocate word_size words from this chunk. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
187 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
188 |
// May cause memory to be committed. That may fail if we hit a commit limit. In that case, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
189 |
// NULL is returned and p_did_hit_commit_limit will be set to true. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
190 |
// If the remainder portion of the chunk was too small to hold the allocation, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
191 |
// NULL is returned and p_did_hit_commit_limit will be set to false. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
192 |
MetaWord* Metachunk::allocate(size_t request_word_size, bool* p_did_hit_commit_limit) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
193 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
194 |
assert_is_aligned(request_word_size, allocation_alignment_words); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
195 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
196 |
log_trace(metaspace)("Chunk " METACHUNK_FULL_FORMAT ": allocating " SIZE_FORMAT " words.", |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
197 |
METACHUNK_FULL_FORMAT_ARGS(this), request_word_size); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
198 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
199 |
assert(committed_words() <= word_size(), "Sanity"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
200 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
201 |
if (free_below_committed_words() < request_word_size) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
202 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
203 |
// We may need to expand the comitted area... |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
204 |
if (free_words() < request_word_size) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
205 |
// ... but cannot do this since we ran out of space. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
206 |
*p_did_hit_commit_limit = false; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
207 |
log_trace(metaspace)("Chunk " METACHUNK_FULL_FORMAT ": .. does not fit (remaining space: " |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
208 |
SIZE_FORMAT " words).", METACHUNK_FULL_FORMAT_ARGS(this), free_words()); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
209 |
return NULL; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
210 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
211 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
212 |
log_trace(metaspace)("Chunk " METACHUNK_FULL_FORMAT ": .. attempting to increase committed range.", |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
213 |
METACHUNK_FULL_FORMAT_ARGS(this)); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
214 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
215 |
if (ensure_committed(used_words() + request_word_size) == false) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
216 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
217 |
// Commit failed. We may have hit the commit limit or the gc threshold. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
218 |
*p_did_hit_commit_limit = true; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
219 |
log_trace(metaspace)("Chunk " METACHUNK_FULL_FORMAT ": .. failed, we hit a limit.", |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
220 |
METACHUNK_FULL_FORMAT_ARGS(this)); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
221 |
return NULL; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
222 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
223 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
224 |
|
14635
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
225 |
} |
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
226 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
227 |
assert(committed_words() >= request_word_size, "Sanity"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
228 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
229 |
MetaWord* const p = top(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
230 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
231 |
_used_words += request_word_size; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
232 |
|
58227 | 233 |
SOMETIMES(verify(false);) |
234 |
||
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
235 |
return p; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
236 |
|
14635
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
237 |
} |
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
238 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
239 |
// Given a memory range which may or may not have been allocated from this chunk, attempt |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
240 |
// to roll its allocation back. This can work if this is the very last allocation we did |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
241 |
// from this chunk, in which case we just lower the top pointer again. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
242 |
// Returns true if this succeeded, false if it failed. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
243 |
bool Metachunk::attempt_rollback_allocation(MetaWord* p, size_t word_size) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
244 |
assert(p != NULL && word_size > 0, "Sanity"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
245 |
assert(is_in_use() && base() != NULL, "Sanity"); |
14635
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
246 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
247 |
// Is this allocation at the top? |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
248 |
if (used_words() >= word_size && |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
249 |
base() + (used_words() - word_size) == p) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
250 |
log_trace(metaspace)("Chunk " METACHUNK_FULL_FORMAT ": rolling back allocation...", |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
251 |
METACHUNK_FULL_FORMAT_ARGS(this)); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
252 |
_used_words -= word_size; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
253 |
log_trace(metaspace)("Chunk " METACHUNK_FULL_FORMAT ": rolled back allocation.", |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
254 |
METACHUNK_FULL_FORMAT_ARGS(this)); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
255 |
DEBUG_ONLY(verify(false);) |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
256 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
257 |
return true; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
258 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
259 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
260 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
261 |
return false; |
14635
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
262 |
} |
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
263 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
264 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
265 |
#ifdef ASSERT |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
266 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
267 |
// Zap this structure. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
268 |
void Metachunk::zap_header(uint8_t c) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
269 |
memset(this, c, sizeof(Metachunk)); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
270 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
271 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
272 |
void Metachunk::fill_with_pattern(MetaWord pattern, size_t word_size) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
273 |
assert(word_size <= committed_words(), "Sanity"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
274 |
for (size_t l = 0; l < word_size; l ++) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
275 |
_base[l] = pattern; |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14635
diff
changeset
|
276 |
} |
14635
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
277 |
} |
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
278 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
279 |
void Metachunk::check_pattern(MetaWord pattern, size_t word_size) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
280 |
assert(word_size <= committed_words(), "Sanity"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
281 |
for (size_t l = 0; l < word_size; l ++) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
282 |
assert(_base[l] == pattern, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
283 |
"chunk " METACHUNK_FULL_FORMAT ": pattern change at " PTR_FORMAT ": expected " UINTX_FORMAT " but got " UINTX_FORMAT ".", |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
284 |
METACHUNK_FULL_FORMAT_ARGS(this), p2i(_base + l), (uintx)pattern, (uintx)_base[l]); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
285 |
} |
14635
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
286 |
} |
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
287 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
288 |
|
58227 | 289 |
// Verifies linking with neighbors in virtual space. |
290 |
// Can only be done under expand lock protection. |
|
291 |
void Metachunk::verify_neighborhood() const { |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
292 |
|
58227 | 293 |
assert_lock_strong(MetaspaceExpand_lock); |
294 |
assert(!is_dead(), "Do not call on dead chunks."); |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
295 |
|
58227 | 296 |
if (is_root_chunk()) { |
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
297 |
|
58227 | 298 |
// Root chunks are all alone in the world. |
299 |
assert(next_in_vs() == NULL || prev_in_vs() == NULL, "Root chunks should have no neighbors"); |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
300 |
|
58227 | 301 |
} else { |
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
302 |
|
58227 | 303 |
// Non-root chunks have neighbors, at least one, possibly two. |
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
304 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
305 |
assert(next_in_vs() != NULL || prev_in_vs() != NULL, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
306 |
"A non-root chunk should have neighbors (chunk @" PTR_FORMAT |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
307 |
", base " PTR_FORMAT ", level " CHKLVL_FORMAT ".", |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
308 |
p2i(this), p2i(base()), level()); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
309 |
|
58227 | 310 |
if (prev_in_vs() != NULL) { |
311 |
assert(prev_in_vs()->end() == base(), |
|
312 |
"Chunk " METACHUNK_FULL_FORMAT ": should be adjacent to predecessor: " METACHUNK_FULL_FORMAT ".", |
|
313 |
METACHUNK_FULL_FORMAT_ARGS(this), METACHUNK_FULL_FORMAT_ARGS(prev_in_vs())); |
|
314 |
assert(prev_in_vs()->next_in_vs() == this, |
|
315 |
"Chunk " METACHUNK_FULL_FORMAT ": broken link to left neighbor: " METACHUNK_FULL_FORMAT " (" PTR_FORMAT ").", |
|
316 |
METACHUNK_FULL_FORMAT_ARGS(this), METACHUNK_FULL_FORMAT_ARGS(prev_in_vs()), p2i(prev_in_vs()->next_in_vs())); |
|
317 |
} |
|
318 |
||
319 |
if (next_in_vs() != NULL) { |
|
320 |
assert(end() == next_in_vs()->base(), |
|
321 |
"Chunk " METACHUNK_FULL_FORMAT ": should be adjacent to successor: " METACHUNK_FULL_FORMAT ".", |
|
322 |
METACHUNK_FULL_FORMAT_ARGS(this), METACHUNK_FULL_FORMAT_ARGS(next_in_vs())); |
|
323 |
assert(next_in_vs()->prev_in_vs() == this, |
|
324 |
"Chunk " METACHUNK_FULL_FORMAT ": broken link to right neighbor: " METACHUNK_FULL_FORMAT " (" PTR_FORMAT ").", |
|
325 |
METACHUNK_FULL_FORMAT_ARGS(this), METACHUNK_FULL_FORMAT_ARGS(next_in_vs()), p2i(next_in_vs()->prev_in_vs())); |
|
326 |
} |
|
327 |
||
328 |
// One of the neighbors must be the buddy. It can be whole or splintered. |
|
329 |
||
330 |
// The chunk following us or preceeding us may be our buddy or a splintered part of it. |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
331 |
Metachunk* buddy = is_leader() ? next_in_vs() : prev_in_vs(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
332 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
333 |
assert(buddy != NULL, "Missing neighbor."); |
58227 | 334 |
assert(!buddy->is_dead(), "Invalid buddy state."); |
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
335 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
336 |
// This neighbor is either or buddy (same level) or a splinter of our buddy - hence |
58227 | 337 |
// the level can never be smaller (aka the chunk size cannot be larger). |
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
338 |
assert(buddy->level() >= level(), "Wrong level."); |
58227 | 339 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
340 |
if (buddy->level() == level()) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
341 |
|
58227 | 342 |
// If the buddy is of the same size as us, it is unsplintered. |
343 |
assert(buddy->is_leader() == !is_leader(), |
|
344 |
"Only one chunk can be leader in a pair"); |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
345 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
346 |
// When direct buddies are neighbors, one or both should be in use, otherwise they should |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
347 |
// have been merged. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
348 |
|
58227 | 349 |
// But since we call this verification function from internal functions where we are about to merge or just did split, |
350 |
// do not test this. We have RootChunkArea::verify_area_is_ideally_merged() for testing that. |
|
351 |
||
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
352 |
// assert(buddy->is_in_use() || is_in_use(), "incomplete merging?"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
353 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
354 |
if (is_leader()) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
355 |
assert(buddy->base() == end(), "Sanity"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
356 |
assert(is_aligned(base(), word_size() * 2 * BytesPerWord), "Sanity"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
357 |
} else { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
358 |
assert(buddy->end() == base(), "Sanity"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
359 |
assert(is_aligned(buddy->base(), word_size() * 2 * BytesPerWord), "Sanity"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
360 |
} |
58227 | 361 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
362 |
} else { |
58227 | 363 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
364 |
// Buddy, but splintered, and this is a part of it. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
365 |
if (is_leader()) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
366 |
assert(buddy->base() == end(), "Sanity"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
367 |
} else { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
368 |
assert(buddy->end() > (base() - word_size()), "Sanity"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
369 |
} |
58227 | 370 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
371 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
372 |
} |
58227 | 373 |
} |
374 |
||
375 |
volatile MetaWord dummy = 0; |
|
376 |
||
377 |
void Metachunk::verify(bool slow) const { |
|
378 |
||
379 |
// Note. This should be called under CLD lock protection. |
|
380 |
||
381 |
// We can verify everything except the _prev_in_vs/_next_in_vs pair. |
|
382 |
// This is because neighbor chunks may be added concurrently, so we cannot rely |
|
383 |
// on the content of _next_in_vs/_prev_in_vs unless we have the expand lock. |
|
384 |
||
385 |
assert(!is_dead(), "Do not call on dead chunks."); |
|
386 |
||
387 |
// Note: only call this on a life Metachunk. |
|
388 |
chklvl::check_valid_level(level()); |
|
389 |
||
390 |
assert(base() != NULL, "No base ptr"); |
|
391 |
||
392 |
assert(committed_words() >= used_words(), |
|
393 |
"mismatch: committed: " SIZE_FORMAT ", used: " SIZE_FORMAT ".", |
|
394 |
committed_words(), used_words()); |
|
395 |
||
396 |
assert(word_size() >= committed_words(), |
|
397 |
"mismatch: word_size: " SIZE_FORMAT ", committed: " SIZE_FORMAT ".", |
|
398 |
word_size(), committed_words()); |
|
399 |
||
400 |
// Test base pointer |
|
401 |
assert(base() != NULL, "Base pointer NULL"); |
|
402 |
assert(vsnode() != NULL, "No space"); |
|
403 |
vsnode()->check_pointer(base()); |
|
404 |
||
405 |
// Starting address shall be aligned to chunk size. |
|
406 |
const size_t required_alignment = word_size() * sizeof(MetaWord); |
|
407 |
assert_is_aligned(base(), required_alignment); |
|
49365 | 408 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
409 |
// If slow, test the committed area |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
410 |
if (slow && _committed_words > 0) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
411 |
for (const MetaWord* p = _base; p < _base + _committed_words; p += os::vm_page_size()) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
412 |
dummy = *p; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
413 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
414 |
dummy = *(_base + _committed_words - 1); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
415 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
416 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
417 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
418 |
#endif // ASSERT |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
419 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
420 |
void Metachunk::print_on(outputStream* st) const { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
421 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
422 |
// Note: must also work with invalid/random data. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
423 |
st->print("Chunk @" PTR_FORMAT ", state %c, base " PTR_FORMAT ", " |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
424 |
"level " CHKLVL_FORMAT " (" SIZE_FORMAT " words), " |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
425 |
"used " SIZE_FORMAT " words, committed " SIZE_FORMAT " words.", |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
426 |
p2i(this), get_state_char(), p2i(base()), level(), |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
427 |
(chklvl::is_valid_level(level()) ? chklvl::word_size_for_level(level()) : 0), |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
428 |
used_words(), committed_words()); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
429 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
430 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
431 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
432 |
///////////////////////////////////7 |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
433 |
// MetachunkList |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
434 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
435 |
#ifdef ASSERT |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
436 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
437 |
bool MetachunkList::contains(const Metachunk* c) const { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
438 |
for (Metachunk* c2 = first(); c2 != NULL; c2 = c2->next()) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
439 |
if (c == c2) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
440 |
return true; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
441 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
442 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
443 |
return false; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
444 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
445 |
|
58227 | 446 |
void MetachunkList::verify() const { |
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
447 |
int num = 0; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
448 |
const Metachunk* last_c = NULL; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
449 |
for (const Metachunk* c = first(); c != NULL; c = c->next()) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
450 |
num ++; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
451 |
assert(c->prev() == last_c, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
452 |
"Broken link to predecessor. Chunk " METACHUNK_FULL_FORMAT ".", |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
453 |
METACHUNK_FULL_FORMAT_ARGS(c)); |
58227 | 454 |
c->verify(false); |
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
455 |
last_c = c; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
456 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
457 |
_num.check(num); |
14635
6a3c85b8111c
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
458 |
} |
20729 | 459 |
|
49365 | 460 |
#endif // ASSERT |
461 |
||
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
462 |
void MetachunkList::print_on(outputStream* st) const { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
463 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
464 |
if (_num.get() > 0) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
465 |
for (const Metachunk* c = first(); c != NULL; c = c->next()) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
466 |
st->print(" - <"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
467 |
c->print_on(st); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
468 |
st->print(">"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
469 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
470 |
st->print(" - total : %d chunks.", _num.get()); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
471 |
} else { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
472 |
st->print("empty"); |
49365 | 473 |
} |
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
474 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
475 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
476 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
477 |
///////////////////////////////////7 |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
478 |
// MetachunkListCluster |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
479 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
480 |
#ifdef ASSERT |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
481 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
482 |
bool MetachunkListCluster::contains(const Metachunk* c) const { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
483 |
for (chklvl_t l = chklvl::LOWEST_CHUNK_LEVEL; l <= chklvl::HIGHEST_CHUNK_LEVEL; l ++) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
484 |
if (list_for_level(l)->contains(c)) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
485 |
return true; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
486 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
487 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
488 |
return false; |
49365 | 489 |
} |
50193 | 490 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
491 |
void MetachunkListCluster::verify(bool slow) const { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
492 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
493 |
int num = 0; size_t word_size = 0; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
494 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
495 |
for (chklvl_t l = chklvl::LOWEST_CHUNK_LEVEL; l <= chklvl::HIGHEST_CHUNK_LEVEL; l ++) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
496 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
497 |
// Check, for each chunk in this list, exclusivity. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
498 |
for (const Metachunk* c = first_at_level(l); c != NULL; c = c->next()) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
499 |
assert(c->level() == l, "Chunk in wrong list."); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
500 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
501 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
502 |
// Check each list. |
58227 | 503 |
list_for_level(l)->verify(); |
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
504 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
505 |
num += list_for_level(l)->size(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
506 |
word_size += list_for_level(l)->size() * chklvl::word_size_for_level(l); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
507 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
508 |
_total_num_chunks.check(num); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
509 |
_total_word_size.check(word_size); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
510 |
|
50193 | 511 |
} |
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
512 |
#endif // ASSERT |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
513 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
514 |
void MetachunkListCluster::print_on(outputStream* st) const { |
50193 | 515 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
516 |
for (chklvl_t l = chklvl::LOWEST_CHUNK_LEVEL; l <= chklvl::HIGHEST_CHUNK_LEVEL; l ++) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
517 |
st->print("-- List[" CHKLVL_FORMAT "]: ", l); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
518 |
list_for_level(l)->print_on(st); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
519 |
st->cr(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
520 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
521 |
st->print_cr("total chunks: %d, total word size: " SIZE_FORMAT ".", _total_num_chunks.get(), _total_word_size.get()); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
51334
diff
changeset
|
522 |
|
50193 | 523 |
} |
524 |
||
525 |
} // namespace metaspace |
|
526 |