Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/memory/metaspace/metaspaceArenaGrowthPolicy.hpp
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
#ifndef SHARE_MEMORY_METASPACE_METASPACEARENAGROWTHPOLICY_HPP
27
#define SHARE_MEMORY_METASPACE_METASPACEARENAGROWTHPOLICY_HPP
28
29
#include "memory/metaspace.hpp" // For Metaspace::MetaspaceType
30
#include "memory/metaspace/chunklevel.hpp"
31
#include "utilities/debug.hpp"
32
33
namespace metaspace {
34
35
// ArenaGrowthPolicy encodes the growth policy of a MetaspaceArena.
36
//
37
// These arenas grow in steps (by allocating new chunks). The coarseness of growth
38
// (chunk size, level) depends on what the arena is used for. Used for a class loader
39
// which is expected to load only one or very few classes should grow in tiny steps.
40
// For normal classloaders, it can grow in coarser steps, and arenas used by
41
// the boot loader will grow in even larger steps since we expect it to load a lot of
42
// classes.
43
// Note that when growing in large steps (in steps larger than a commit granule,
44
// by default 64K), costs diminish somewhat since we do not commit the whole space
45
// immediately.
46
47
class ArenaGrowthPolicy {
48
49
// const array specifying chunk level allocation progression (growth steps). Last
50
// chunk is to be an endlessly repeated allocation.
51
const chunklevel_t* const _entries;
52
const int _num_entries;
53
54
public:
55
56
ArenaGrowthPolicy(const chunklevel_t* array, int num_entries) :
57
_entries(array),
58
_num_entries(num_entries)
59
{
60
assert(_num_entries > 0, "must not be empty.");
61
}
62
63
chunklevel_t get_level_at_step(int num_allocated) const {
64
if (num_allocated >= _num_entries) {
65
// Caller shall repeat last allocation
66
return _entries[_num_entries - 1];
67
}
68
return _entries[num_allocated];
69
}
70
71
// Given a space type, return the correct policy to use.
72
// The returned object is static and read only.
73
static const ArenaGrowthPolicy* policy_for_space_type(Metaspace::MetaspaceType space_type, bool is_class);
74
75
};
76
77
} // namespace metaspace
78
79
#endif // SHARE_MEMORY_METASPACE_METASPACEARENAGROWTHPOLICY_HPP
80
81