Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/memory/metaspace/metaspaceArenaGrowthPolicy.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/metaspaceArenaGrowthPolicy.hpp"
28
#include "utilities/globalDefinitions.hpp"
29
30
namespace metaspace {
31
32
// hard-coded chunk allocation sequences for various space types
33
// (Note: when modifying this, don't add jumps of more than double the
34
// last chunk size. There is a gtest testing this, see test_arenagrowthpolicy.cpp)
35
36
static const chunklevel_t g_sequ_standard_non_class[] = {
37
chunklevel::CHUNK_LEVEL_4K,
38
chunklevel::CHUNK_LEVEL_4K,
39
chunklevel::CHUNK_LEVEL_4K,
40
chunklevel::CHUNK_LEVEL_8K,
41
chunklevel::CHUNK_LEVEL_16K
42
// .. repeat last
43
};
44
45
static const chunklevel_t g_sequ_standard_class[] = {
46
chunklevel::CHUNK_LEVEL_2K,
47
chunklevel::CHUNK_LEVEL_2K,
48
chunklevel::CHUNK_LEVEL_4K,
49
chunklevel::CHUNK_LEVEL_8K,
50
chunklevel::CHUNK_LEVEL_16K
51
// .. repeat last
52
};
53
54
static const chunklevel_t g_sequ_anon_non_class[] = {
55
chunklevel::CHUNK_LEVEL_1K,
56
// .. repeat last
57
};
58
59
static const chunklevel_t g_sequ_anon_class[] = {
60
chunklevel::CHUNK_LEVEL_1K,
61
// .. repeat last
62
};
63
64
static const chunklevel_t g_sequ_refl_non_class[] = {
65
chunklevel::CHUNK_LEVEL_2K,
66
chunklevel::CHUNK_LEVEL_1K
67
// .. repeat last
68
};
69
70
static const chunklevel_t g_sequ_refl_class[] = {
71
chunklevel::CHUNK_LEVEL_1K,
72
// .. repeat last
73
};
74
75
// Boot class loader: give it large chunks: beyond commit granule size
76
// (typically 64K) the costs for large chunks largely diminishes since
77
// they are committed on the fly.
78
static const chunklevel_t g_sequ_boot_non_class[] = {
79
chunklevel::CHUNK_LEVEL_4M,
80
chunklevel::CHUNK_LEVEL_1M
81
// .. repeat last
82
};
83
84
static const chunklevel_t g_sequ_boot_class[] = {
85
chunklevel::CHUNK_LEVEL_256K
86
// .. repeat last
87
};
88
89
const ArenaGrowthPolicy* ArenaGrowthPolicy::policy_for_space_type(Metaspace::MetaspaceType space_type, bool is_class) {
90
91
#define DEFINE_CLASS_FOR_ARRAY(what) \
92
static ArenaGrowthPolicy chunk_alloc_sequence_##what (g_sequ_##what, sizeof(g_sequ_##what)/sizeof(chunklevel_t));
93
94
DEFINE_CLASS_FOR_ARRAY(standard_non_class)
95
DEFINE_CLASS_FOR_ARRAY(standard_class)
96
DEFINE_CLASS_FOR_ARRAY(anon_non_class)
97
DEFINE_CLASS_FOR_ARRAY(anon_class)
98
DEFINE_CLASS_FOR_ARRAY(refl_non_class)
99
DEFINE_CLASS_FOR_ARRAY(refl_class)
100
DEFINE_CLASS_FOR_ARRAY(boot_non_class)
101
DEFINE_CLASS_FOR_ARRAY(boot_class)
102
103
if (is_class) {
104
switch(space_type) {
105
case Metaspace::StandardMetaspaceType: return &chunk_alloc_sequence_standard_class;
106
case Metaspace::ReflectionMetaspaceType: return &chunk_alloc_sequence_refl_class;
107
case Metaspace::ClassMirrorHolderMetaspaceType: return &chunk_alloc_sequence_anon_class;
108
case Metaspace::BootMetaspaceType: return &chunk_alloc_sequence_boot_class;
109
default: ShouldNotReachHere();
110
}
111
} else {
112
switch(space_type) {
113
case Metaspace::StandardMetaspaceType: return &chunk_alloc_sequence_standard_non_class;
114
case Metaspace::ReflectionMetaspaceType: return &chunk_alloc_sequence_refl_non_class;
115
case Metaspace::ClassMirrorHolderMetaspaceType: return &chunk_alloc_sequence_anon_non_class;
116
case Metaspace::BootMetaspaceType: return &chunk_alloc_sequence_boot_non_class;
117
default: ShouldNotReachHere();
118
}
119
}
120
121
return NULL;
122
123
}
124
125
} // namespace
126
127
128