Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/services/runtimeService.cpp
41145 views
1
/*
2
* Copyright (c) 2003, 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 "logging/log.hpp"
27
#include "logging/logStream.hpp"
28
#include "runtime/vm_version.hpp"
29
#include "services/attachListener.hpp"
30
#include "services/management.hpp"
31
#include "services/runtimeService.hpp"
32
#include "utilities/dtrace.hpp"
33
#include "utilities/exceptions.hpp"
34
#include "utilities/macros.hpp"
35
36
#if INCLUDE_MANAGEMENT
37
PerfCounter* RuntimeService::_sync_time_ticks = NULL;
38
PerfCounter* RuntimeService::_total_safepoints = NULL;
39
PerfCounter* RuntimeService::_safepoint_time_ticks = NULL;
40
PerfCounter* RuntimeService::_application_time_ticks = NULL;
41
42
void RuntimeService::init() {
43
if (UsePerfData) {
44
EXCEPTION_MARK;
45
46
_sync_time_ticks =
47
PerfDataManager::create_counter(SUN_RT, "safepointSyncTime",
48
PerfData::U_Ticks, CHECK);
49
50
_total_safepoints =
51
PerfDataManager::create_counter(SUN_RT, "safepoints",
52
PerfData::U_Events, CHECK);
53
54
_safepoint_time_ticks =
55
PerfDataManager::create_counter(SUN_RT, "safepointTime",
56
PerfData::U_Ticks, CHECK);
57
58
_application_time_ticks =
59
PerfDataManager::create_counter(SUN_RT, "applicationTime",
60
PerfData::U_Ticks, CHECK);
61
62
63
// create performance counters for jvm_version and its capabilities
64
PerfDataManager::create_constant(SUN_RT, "jvmVersion", PerfData::U_None,
65
(jlong) VM_Version::jvm_version(), CHECK);
66
67
// The capabilities counter is a binary representation of the VM capabilities in string.
68
// This string respresentation simplifies the implementation of the client side
69
// to parse the value.
70
char capabilities[65];
71
size_t len = sizeof(capabilities);
72
memset((void*) capabilities, '0', len);
73
capabilities[len-1] = '\0';
74
capabilities[0] = AttachListener::is_attach_supported() ? '1' : '0';
75
#if INCLUDE_SERVICES
76
capabilities[1] = '1';
77
#endif // INCLUDE_SERVICES
78
PerfDataManager::create_string_constant(SUN_RT, "jvmCapabilities",
79
capabilities, CHECK);
80
}
81
}
82
83
void RuntimeService::record_safepoint_begin(jlong app_ticks) {
84
HS_PRIVATE_SAFEPOINT_BEGIN();
85
if (UsePerfData) {
86
_total_safepoints->inc();
87
_application_time_ticks->inc(app_ticks);
88
}
89
}
90
91
void RuntimeService::record_safepoint_synchronized(jlong sync_ticks) {
92
if (UsePerfData) {
93
_sync_time_ticks->inc(sync_ticks);
94
}
95
}
96
97
void RuntimeService::record_safepoint_end(jlong safepoint_ticks) {
98
HS_PRIVATE_SAFEPOINT_END();
99
if (UsePerfData) {
100
_safepoint_time_ticks->inc(safepoint_ticks);
101
}
102
}
103
104
jlong RuntimeService::safepoint_sync_time_ms() {
105
return UsePerfData ?
106
Management::ticks_to_ms(_sync_time_ticks->get_value()) : -1;
107
}
108
109
jlong RuntimeService::safepoint_count() {
110
return UsePerfData ?
111
_total_safepoints->get_value() : -1;
112
}
113
jlong RuntimeService::safepoint_time_ms() {
114
return UsePerfData ?
115
Management::ticks_to_ms(_safepoint_time_ticks->get_value()) : -1;
116
}
117
118
jlong RuntimeService::application_time_ms() {
119
return UsePerfData ?
120
Management::ticks_to_ms(_application_time_ticks->get_value()) : -1;
121
}
122
123
#endif // INCLUDE_MANAGEMENT
124
125