Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/memory/metaspace/metaspaceDCmd.cpp
40957 views
1
/*
2
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
3
* Copyright (c) 2018, 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.hpp"
28
#include "memory/metaspace/metaspaceDCmd.hpp"
29
#include "memory/metaspace/metaspaceReporter.hpp"
30
#include "memory/metaspaceUtils.hpp"
31
#include "memory/resourceArea.hpp"
32
#include "runtime/vmOperations.hpp"
33
#include "services/diagnosticCommand.hpp"
34
#include "services/nmtCommon.hpp"
35
36
namespace metaspace {
37
38
MetaspaceDCmd::MetaspaceDCmd(outputStream* output, bool heap) :
39
DCmdWithParser(output, heap),
40
_basic("basic", "Prints a basic summary (does not need a safepoint).", "BOOLEAN", false, "false"),
41
_show_loaders("show-loaders", "Shows usage by class loader.", "BOOLEAN", false, "false"),
42
_by_spacetype("by-spacetype", "Break down numbers by loader type.", "BOOLEAN", false, "false"),
43
_by_chunktype("by-chunktype", "Break down numbers by chunk type.", "BOOLEAN", false, "false"),
44
_show_vslist("vslist", "Shows details about the underlying virtual space.", "BOOLEAN", false, "false"),
45
_scale("scale", "Memory usage in which to scale. Valid values are: 1, KB, MB or GB (fixed scale) "
46
"or \"dynamic\" for a dynamically choosen scale.",
47
"STRING", false, "dynamic"),
48
_show_classes("show-classes", "If show-loaders is set, shows loaded classes for each loader.", "BOOLEAN", false, "false")
49
{
50
_dcmdparser.add_dcmd_option(&_basic);
51
_dcmdparser.add_dcmd_option(&_show_loaders);
52
_dcmdparser.add_dcmd_option(&_show_classes);
53
_dcmdparser.add_dcmd_option(&_by_chunktype);
54
_dcmdparser.add_dcmd_option(&_by_spacetype);
55
_dcmdparser.add_dcmd_option(&_show_vslist);
56
_dcmdparser.add_dcmd_option(&_scale);
57
}
58
59
int MetaspaceDCmd::num_arguments() {
60
ResourceMark rm;
61
MetaspaceDCmd* dcmd = new MetaspaceDCmd(NULL, false);
62
if (dcmd != NULL) {
63
DCmdMark mark(dcmd);
64
return dcmd->_dcmdparser.num_arguments();
65
} else {
66
return 0;
67
}
68
}
69
70
void MetaspaceDCmd::execute(DCmdSource source, TRAPS) {
71
// Parse scale value.
72
const char* scale_value = _scale.value();
73
size_t scale = 0;
74
if (scale_value != NULL) {
75
if (strcasecmp("dynamic", scale_value) == 0) {
76
scale = 0;
77
} else {
78
scale = NMT_ONLY(NMTUtil::scale_from_name(scale_value)) NOT_NMT(0);
79
if (scale == 0) {
80
output()->print_cr("Invalid scale: \"%s\". Will use dynamic scaling.", scale_value);
81
}
82
}
83
}
84
if (_basic.value() == true) {
85
if (_show_loaders.value() || _by_chunktype.value() || _by_spacetype.value() ||
86
_show_vslist.value()) {
87
// Basic mode. Just print essentials. Does not need to be at a safepoint.
88
output()->print_cr("In basic mode, additional arguments are ignored.");
89
}
90
MetaspaceUtils::print_basic_report(output(), scale);
91
} else {
92
// Full mode. Requires safepoint.
93
int flags = 0;
94
if (_show_loaders.value()) flags |= (int)MetaspaceReporter::Option::ShowLoaders;
95
if (_show_classes.value()) flags |= (int)MetaspaceReporter::Option::ShowClasses;
96
if (_by_chunktype.value()) flags |= (int)MetaspaceReporter::Option::BreakDownByChunkType;
97
if (_by_spacetype.value()) flags |= (int)MetaspaceReporter::Option::BreakDownBySpaceType;
98
if (_show_vslist.value()) flags |= (int)MetaspaceReporter::Option::ShowVSList;
99
VM_PrintMetadata op(output(), scale, flags);
100
VMThread::execute(&op);
101
}
102
}
103
104
} // namespace metaspace
105
106
107