Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/memory/metaspace/chunklevel.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/chunklevel.hpp"
28
#include "utilities/debug.hpp"
29
#include "utilities/globalDefinitions.hpp"
30
#include "utilities/ostream.hpp"
31
#include "utilities/powerOfTwo.hpp"
32
33
namespace metaspace {
34
35
using namespace chunklevel;
36
37
chunklevel_t chunklevel::level_fitting_word_size(size_t word_size) {
38
assert(MAX_CHUNK_WORD_SIZE >= word_size,
39
SIZE_FORMAT " - too large allocation size.", word_size * BytesPerWord);
40
if (word_size <= MIN_CHUNK_WORD_SIZE) {
41
return HIGHEST_CHUNK_LEVEL;
42
}
43
const size_t v_pow2 = round_up_power_of_2(word_size);
44
const chunklevel_t lvl = (chunklevel_t)(exact_log2(MAX_CHUNK_WORD_SIZE) - exact_log2(v_pow2));
45
return lvl;
46
}
47
48
void chunklevel::print_chunk_size(outputStream* st, chunklevel_t lvl) {
49
if (chunklevel::is_valid_level(lvl)) {
50
const size_t s = chunklevel::word_size_for_level(lvl) * BytesPerWord;
51
if (s < 1 * M) {
52
st->print("%3uk", (unsigned)(s / K));
53
} else {
54
st->print("%3um", (unsigned)(s / M));
55
}
56
} else {
57
st->print("?-?");
58
}
59
}
60
61
} // namespace metaspace
62
63
64