Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/memory/metaspace/commitMask.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/commitMask.hpp"
28
#include "memory/metaspace/metaspaceCommon.hpp"
29
#include "memory/metaspace/metaspaceSettings.hpp"
30
#include "runtime/stubRoutines.hpp"
31
#include "utilities/align.hpp"
32
#include "utilities/debug.hpp"
33
34
namespace metaspace {
35
36
CommitMask::CommitMask(const MetaWord* start, size_t word_size) :
37
CHeapBitMap(mask_size(word_size, Settings::commit_granule_words())),
38
_base(start),
39
_word_size(word_size),
40
_words_per_bit(Settings::commit_granule_words())
41
{
42
assert(_word_size > 0 && _words_per_bit > 0 &&
43
is_aligned(_word_size, _words_per_bit), "Sanity");
44
}
45
46
#ifdef ASSERT
47
48
// Given a pointer, check if it points into the range this bitmap covers.
49
bool CommitMask::is_pointer_valid(const MetaWord* p) const {
50
return p >= _base && p < _base + _word_size;
51
}
52
53
// Given a pointer, check if it points into the range this bitmap covers.
54
void CommitMask::check_pointer(const MetaWord* p) const {
55
assert(is_pointer_valid(p),
56
"Pointer " PTR_FORMAT " not in range of this bitmap [" PTR_FORMAT ", " PTR_FORMAT ").",
57
p2i(p), p2i(_base), p2i(_base + _word_size));
58
}
59
// Given a pointer, check if it points into the range this bitmap covers,
60
// and if it is aligned to commit granule border.
61
void CommitMask::check_pointer_aligned(const MetaWord* p) const {
62
check_pointer(p);
63
assert(is_aligned(p, _words_per_bit * BytesPerWord),
64
"Pointer " PTR_FORMAT " should be aligned to commit granule size " SIZE_FORMAT ".",
65
p2i(p), _words_per_bit * BytesPerWord);
66
}
67
// Given a range, check if it points into the range this bitmap covers,
68
// and if its borders are aligned to commit granule border.
69
void CommitMask::check_range(const MetaWord* start, size_t word_size) const {
70
check_pointer_aligned(start);
71
assert(is_aligned(word_size, _words_per_bit),
72
"Range " SIZE_FORMAT " should be aligned to commit granule size " SIZE_FORMAT ".",
73
word_size, _words_per_bit);
74
check_pointer(start + word_size - 1);
75
}
76
77
void CommitMask::verify() const {
78
// Walk the whole commit mask.
79
// For each 1 bit, check if the associated granule is accessible.
80
// For each 0 bit, check if the associated granule is not accessible. Slow mode only.
81
assert(_base != NULL && _word_size > 0 && _words_per_bit > 0, "Sanity");
82
assert_is_aligned(_base, _words_per_bit * BytesPerWord);
83
assert_is_aligned(_word_size, _words_per_bit);
84
}
85
86
#endif // ASSERT
87
88
void CommitMask::print_on(outputStream* st) const {
89
st->print("commit mask, base " PTR_FORMAT ":", p2i(base()));
90
for (idx_t i = 0; i < size(); i++) {
91
st->print("%c", at(i) ? 'X' : '-');
92
}
93
st->cr();
94
}
95
96
} // namespace metaspace
97
98
99