Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/memory/metaspace/metachunkList.cpp
40957 views
1
/*
2
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
3
* Copyright (c) 2020 SAP SE. All rights reserved.
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.
9
*
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
*
24
*/
25
26
#include "precompiled.hpp"
27
#include "memory/metaspace/metachunkList.hpp"
28
#include "memory/metaspace/metaspaceCommon.hpp"
29
#include "utilities/debug.hpp"
30
#include "utilities/globalDefinitions.hpp"
31
#include "utilities/ostream.hpp"
32
33
namespace metaspace {
34
35
#ifdef ASSERT
36
37
void MetachunkList::verify_does_not_contain(const Metachunk* c) const {
38
SOMETIMES(assert(contains(c) == false, "List contains this chunk.");)
39
}
40
41
bool MetachunkList::contains(const Metachunk* c) const {
42
for (Metachunk* c2 = _first; c2 != NULL; c2 = c2->next()) {
43
if (c == c2) {
44
return true;
45
}
46
}
47
return false;
48
}
49
50
void MetachunkList::verify() const {
51
int num = 0;
52
const Metachunk* last_c = NULL;
53
for (const Metachunk* c = _first; c != NULL; c = c->next()) {
54
num++;
55
assert(c->prev() != c && c->next() != c, "circularity");
56
assert(c->prev() == last_c,
57
"Broken link to predecessor. Chunk " METACHUNK_FULL_FORMAT ".",
58
METACHUNK_FULL_FORMAT_ARGS(c));
59
c->verify();
60
last_c = c;
61
}
62
_num_chunks.check(num);
63
}
64
65
#endif // ASSERT
66
67
size_t MetachunkList::calc_committed_word_size() const {
68
if (_first != NULL && _first->is_dead()) {
69
// list used for chunk header pool; dead chunks have no size.
70
return 0;
71
}
72
size_t s = 0;
73
for (Metachunk* c = _first; c != NULL; c = c->next()) {
74
assert(c->is_dead() == false, "Sanity");
75
s += c->committed_words();
76
}
77
return s;
78
}
79
80
size_t MetachunkList::calc_word_size() const {
81
if (_first != NULL && _first->is_dead()) {
82
// list used for chunk header pool; dead chunks have no size.
83
return 0;
84
}
85
size_t s = 0;
86
for (Metachunk* c = _first; c != NULL; c = c->next()) {
87
assert(c->is_dead() == false, "Sanity");
88
s += c->committed_words();
89
}
90
return s;
91
}
92
93
void MetachunkList::print_on(outputStream* st) const {
94
if (_num_chunks.get() > 0) {
95
for (const Metachunk* c = _first; c != NULL; c = c->next()) {
96
st->print(" - <");
97
c->print_on(st);
98
st->print(">");
99
}
100
st->print(" - total : %d chunks.", _num_chunks.get());
101
} else {
102
st->print("empty");
103
}
104
}
105
106
} // namespace metaspace
107
108
109