Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/memory/metaspace/metaspaceContext.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/chunkManager.hpp"
28
#include "memory/metaspace/commitLimiter.hpp"
29
#include "memory/metaspace/metaspaceContext.hpp"
30
#include "memory/metaspace/virtualSpaceList.hpp"
31
#include "utilities/debug.hpp"
32
#include "utilities/globalDefinitions.hpp"
33
#include "utilities/ostream.hpp"
34
35
namespace metaspace {
36
37
MetaspaceContext* MetaspaceContext::_class_space_context = NULL;
38
MetaspaceContext* MetaspaceContext::_nonclass_space_context = NULL;
39
40
// Destroys the context: deletes chunkmanager and virtualspacelist.
41
// If this is a non-expandable context over an existing space, that space remains
42
// untouched, otherwise all memory is unmapped.
43
// Note: the standard metaspace contexts (non-class context and class context) are
44
// never deleted. This code only exists for the sake of tests and for future reuse
45
// of metaspace contexts in different scenarios.
46
MetaspaceContext::~MetaspaceContext() {
47
delete _cm;
48
delete _vslist;
49
}
50
51
// Create a new, empty, expandable metaspace context.
52
MetaspaceContext* MetaspaceContext::create_expandable_context(const char* name, CommitLimiter* commit_limiter) {
53
VirtualSpaceList* vsl = new VirtualSpaceList(name, commit_limiter);
54
ChunkManager* cm = new ChunkManager(name, vsl);
55
return new MetaspaceContext(name, vsl, cm);
56
}
57
58
// Create a new, empty, non-expandable metaspace context atop of an externally provided space.
59
MetaspaceContext* MetaspaceContext::create_nonexpandable_context(const char* name, ReservedSpace rs, CommitLimiter* commit_limiter) {
60
VirtualSpaceList* vsl = new VirtualSpaceList(name, rs, commit_limiter);
61
ChunkManager* cm = new ChunkManager(name, vsl);
62
return new MetaspaceContext(name, vsl, cm);
63
}
64
65
void MetaspaceContext::initialize_class_space_context(ReservedSpace rs) {
66
_class_space_context = create_nonexpandable_context("class-space", rs, CommitLimiter::globalLimiter());
67
}
68
69
void MetaspaceContext::initialize_nonclass_space_context() {
70
_nonclass_space_context = create_expandable_context("non-class-space", CommitLimiter::globalLimiter());
71
}
72
73
void MetaspaceContext::print_on(outputStream* st) const {
74
_vslist->print_on(st);
75
_cm->print_on(st);
76
}
77
78
#ifdef ASSERT
79
void MetaspaceContext::verify() const {
80
_vslist->verify();
81
_cm->verify();
82
}
83
#endif // ASSERT
84
85
} // namespace metaspace
86
87
88