2007-12-01 00:00:00 +00:00
|
|
|
/*
|
2021-02-13 07:13:22 +00:00
|
|
|
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
|
2007-12-01 00:00:00 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
2010-05-27 19:08:38 -07:00
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
2007-12-01 00:00:00 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "precompiled.hpp"
|
2015-12-10 14:57:55 +01:00
|
|
|
#include "logging/log.hpp"
|
2019-02-22 14:20:06 +01:00
|
|
|
#include "logging/logStream.hpp"
|
2015-02-18 10:28:27 +01:00
|
|
|
#include "runtime/vm_version.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "services/attachListener.hpp"
|
|
|
|
#include "services/management.hpp"
|
|
|
|
#include "services/runtimeService.hpp"
|
|
|
|
#include "utilities/dtrace.hpp"
|
|
|
|
#include "utilities/exceptions.hpp"
|
2013-01-23 13:02:39 -05:00
|
|
|
#include "utilities/macros.hpp"
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2012-10-10 14:35:58 -04:00
|
|
|
#if INCLUDE_MANAGEMENT
|
2007-12-01 00:00:00 +00:00
|
|
|
PerfCounter* RuntimeService::_sync_time_ticks = NULL;
|
|
|
|
PerfCounter* RuntimeService::_total_safepoints = NULL;
|
|
|
|
PerfCounter* RuntimeService::_safepoint_time_ticks = NULL;
|
|
|
|
PerfCounter* RuntimeService::_application_time_ticks = NULL;
|
|
|
|
|
|
|
|
void RuntimeService::init() {
|
|
|
|
if (UsePerfData) {
|
|
|
|
EXCEPTION_MARK;
|
|
|
|
|
|
|
|
_sync_time_ticks =
|
|
|
|
PerfDataManager::create_counter(SUN_RT, "safepointSyncTime",
|
|
|
|
PerfData::U_Ticks, CHECK);
|
|
|
|
|
|
|
|
_total_safepoints =
|
|
|
|
PerfDataManager::create_counter(SUN_RT, "safepoints",
|
|
|
|
PerfData::U_Events, CHECK);
|
|
|
|
|
|
|
|
_safepoint_time_ticks =
|
|
|
|
PerfDataManager::create_counter(SUN_RT, "safepointTime",
|
|
|
|
PerfData::U_Ticks, CHECK);
|
|
|
|
|
|
|
|
_application_time_ticks =
|
|
|
|
PerfDataManager::create_counter(SUN_RT, "applicationTime",
|
|
|
|
PerfData::U_Ticks, CHECK);
|
|
|
|
|
|
|
|
|
|
|
|
// create performance counters for jvm_version and its capabilities
|
|
|
|
PerfDataManager::create_constant(SUN_RT, "jvmVersion", PerfData::U_None,
|
2018-10-16 11:08:46 -04:00
|
|
|
(jlong) VM_Version::jvm_version(), CHECK);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// The capabilities counter is a binary representation of the VM capabilities in string.
|
|
|
|
// This string respresentation simplifies the implementation of the client side
|
|
|
|
// to parse the value.
|
|
|
|
char capabilities[65];
|
|
|
|
size_t len = sizeof(capabilities);
|
|
|
|
memset((void*) capabilities, '0', len);
|
|
|
|
capabilities[len-1] = '\0';
|
|
|
|
capabilities[0] = AttachListener::is_attach_supported() ? '1' : '0';
|
2012-10-10 14:35:58 -04:00
|
|
|
#if INCLUDE_SERVICES
|
2007-12-01 00:00:00 +00:00
|
|
|
capabilities[1] = '1';
|
2012-10-10 14:35:58 -04:00
|
|
|
#endif // INCLUDE_SERVICES
|
2007-12-01 00:00:00 +00:00
|
|
|
PerfDataManager::create_string_constant(SUN_RT, "jvmCapabilities",
|
|
|
|
capabilities, CHECK);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-22 14:20:06 +01:00
|
|
|
void RuntimeService::record_safepoint_begin(jlong app_ticks) {
|
2011-10-13 09:35:42 -07:00
|
|
|
HS_PRIVATE_SAFEPOINT_BEGIN();
|
2007-12-01 00:00:00 +00:00
|
|
|
if (UsePerfData) {
|
|
|
|
_total_safepoints->inc();
|
2019-02-22 14:20:06 +01:00
|
|
|
_application_time_ticks->inc(app_ticks);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-22 14:20:06 +01:00
|
|
|
void RuntimeService::record_safepoint_synchronized(jlong sync_ticks) {
|
2007-12-01 00:00:00 +00:00
|
|
|
if (UsePerfData) {
|
2019-02-22 14:20:06 +01:00
|
|
|
_sync_time_ticks->inc(sync_ticks);
|
2014-10-28 18:41:34 +04:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2019-02-22 14:20:06 +01:00
|
|
|
void RuntimeService::record_safepoint_end(jlong safepoint_ticks) {
|
2011-10-13 09:35:42 -07:00
|
|
|
HS_PRIVATE_SAFEPOINT_END();
|
2007-12-01 00:00:00 +00:00
|
|
|
if (UsePerfData) {
|
2019-02-22 14:20:06 +01:00
|
|
|
_safepoint_time_ticks->inc(safepoint_ticks);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
jlong RuntimeService::safepoint_sync_time_ms() {
|
|
|
|
return UsePerfData ?
|
|
|
|
Management::ticks_to_ms(_sync_time_ticks->get_value()) : -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
jlong RuntimeService::safepoint_count() {
|
|
|
|
return UsePerfData ?
|
|
|
|
_total_safepoints->get_value() : -1;
|
|
|
|
}
|
|
|
|
jlong RuntimeService::safepoint_time_ms() {
|
|
|
|
return UsePerfData ?
|
|
|
|
Management::ticks_to_ms(_safepoint_time_ticks->get_value()) : -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
jlong RuntimeService::application_time_ms() {
|
|
|
|
return UsePerfData ?
|
|
|
|
Management::ticks_to_ms(_application_time_ticks->get_value()) : -1;
|
|
|
|
}
|
|
|
|
|
2012-10-10 14:35:58 -04:00
|
|
|
#endif // INCLUDE_MANAGEMENT
|