Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/cds/dumpAllocStats.cpp
41144 views
1
/*
2
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*
23
*/
24
25
#include "precompiled.hpp"
26
#include "cds/dumpAllocStats.hpp"
27
#include "logging/log.hpp"
28
#include "logging/logMessage.hpp"
29
30
void DumpAllocStats::print_stats(int ro_all, int rw_all) {
31
// symbols
32
_counts[RO][SymbolHashentryType] = _symbol_stats.hashentry_count;
33
_bytes [RO][SymbolHashentryType] = _symbol_stats.hashentry_bytes;
34
35
_counts[RO][SymbolBucketType] = _symbol_stats.bucket_count;
36
_bytes [RO][SymbolBucketType] = _symbol_stats.bucket_bytes;
37
38
// strings
39
_counts[RO][StringHashentryType] = _string_stats.hashentry_count;
40
_bytes [RO][StringHashentryType] = _string_stats.hashentry_bytes;
41
42
_counts[RO][StringBucketType] = _string_stats.bucket_count;
43
_bytes [RO][StringBucketType] = _string_stats.bucket_bytes;
44
45
// prevent divide-by-zero
46
if (ro_all < 1) {
47
ro_all = 1;
48
}
49
if (rw_all < 1) {
50
rw_all = 1;
51
}
52
53
int all_ro_count = 0;
54
int all_ro_bytes = 0;
55
int all_rw_count = 0;
56
int all_rw_bytes = 0;
57
58
// To make fmt_stats be a syntactic constant (for format warnings), use #define.
59
#define fmt_stats "%-20s: %8d %10d %5.1f | %8d %10d %5.1f | %8d %10d %5.1f"
60
const char *sep = "--------------------+---------------------------+---------------------------+--------------------------";
61
const char *hdr = " ro_cnt ro_bytes % | rw_cnt rw_bytes % | all_cnt all_bytes %";
62
63
LogMessage(cds) msg;
64
65
msg.debug("Detailed metadata info (excluding heap regions):");
66
msg.debug("%s", hdr);
67
msg.debug("%s", sep);
68
for (int type = 0; type < int(_number_of_types); type ++) {
69
const char *name = type_name((Type)type);
70
int ro_count = _counts[RO][type];
71
int ro_bytes = _bytes [RO][type];
72
int rw_count = _counts[RW][type];
73
int rw_bytes = _bytes [RW][type];
74
int count = ro_count + rw_count;
75
int bytes = ro_bytes + rw_bytes;
76
77
double ro_perc = percent_of(ro_bytes, ro_all);
78
double rw_perc = percent_of(rw_bytes, rw_all);
79
double perc = percent_of(bytes, ro_all + rw_all);
80
81
msg.debug(fmt_stats, name,
82
ro_count, ro_bytes, ro_perc,
83
rw_count, rw_bytes, rw_perc,
84
count, bytes, perc);
85
86
all_ro_count += ro_count;
87
all_ro_bytes += ro_bytes;
88
all_rw_count += rw_count;
89
all_rw_bytes += rw_bytes;
90
}
91
92
int all_count = all_ro_count + all_rw_count;
93
int all_bytes = all_ro_bytes + all_rw_bytes;
94
95
double all_ro_perc = percent_of(all_ro_bytes, ro_all);
96
double all_rw_perc = percent_of(all_rw_bytes, rw_all);
97
double all_perc = percent_of(all_bytes, ro_all + rw_all);
98
99
msg.debug("%s", sep);
100
msg.debug(fmt_stats, "Total",
101
all_ro_count, all_ro_bytes, all_ro_perc,
102
all_rw_count, all_rw_bytes, all_rw_perc,
103
all_count, all_bytes, all_perc);
104
105
assert(all_ro_bytes == ro_all, "everything should have been counted");
106
assert(all_rw_bytes == rw_all, "everything should have been counted");
107
108
#undef fmt_stats
109
}
110
111