src/share/vm/services/runtimeService.cpp

Wed, 31 Jan 2018 19:24:57 -0500

author
dbuck
date
Wed, 31 Jan 2018 19:24:57 -0500
changeset 9289
427b2fb1944f
parent 7326
6f06ebb09080
child 7535
7ae4e26cb1e0
permissions
-rw-r--r--

8189170: Add option to disable stack overflow checking in primordial thread for use with JNI_CreateJavaJVM
Reviewed-by: dcubed

duke@435 1 /*
hseigel@5891 2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #include "precompiled.hpp"
stefank@2314 26 #include "classfile/classLoader.hpp"
stefank@2314 27 #include "services/attachListener.hpp"
stefank@2314 28 #include "services/management.hpp"
stefank@2314 29 #include "services/runtimeService.hpp"
stefank@2314 30 #include "utilities/dtrace.hpp"
stefank@2314 31 #include "utilities/exceptions.hpp"
jprovino@4542 32 #include "utilities/macros.hpp"
duke@435 33
dcubed@3202 34 #ifndef USDT2
duke@435 35 HS_DTRACE_PROBE_DECL(hs_private, safepoint__begin);
duke@435 36 HS_DTRACE_PROBE_DECL(hs_private, safepoint__end);
dcubed@3202 37 #endif /* !USDT2 */
duke@435 38
jprovino@4165 39 #if INCLUDE_MANAGEMENT
duke@435 40 TimeStamp RuntimeService::_app_timer;
duke@435 41 TimeStamp RuntimeService::_safepoint_timer;
duke@435 42 PerfCounter* RuntimeService::_sync_time_ticks = NULL;
duke@435 43 PerfCounter* RuntimeService::_total_safepoints = NULL;
duke@435 44 PerfCounter* RuntimeService::_safepoint_time_ticks = NULL;
duke@435 45 PerfCounter* RuntimeService::_application_time_ticks = NULL;
duke@435 46 PerfCounter* RuntimeService::_thread_interrupt_signaled_count = NULL;
duke@435 47 PerfCounter* RuntimeService::_interrupted_before_count = NULL;
duke@435 48 PerfCounter* RuntimeService::_interrupted_during_count = NULL;
vkempik@7326 49 double RuntimeService::_last_safepoint_sync_time_sec = 0.0;
duke@435 50
duke@435 51 void RuntimeService::init() {
duke@435 52 // Make sure the VM version is initialized
duke@435 53 Abstract_VM_Version::initialize();
duke@435 54
duke@435 55 if (UsePerfData) {
duke@435 56 EXCEPTION_MARK;
duke@435 57
duke@435 58 _sync_time_ticks =
duke@435 59 PerfDataManager::create_counter(SUN_RT, "safepointSyncTime",
duke@435 60 PerfData::U_Ticks, CHECK);
duke@435 61
duke@435 62 _total_safepoints =
duke@435 63 PerfDataManager::create_counter(SUN_RT, "safepoints",
duke@435 64 PerfData::U_Events, CHECK);
duke@435 65
duke@435 66 _safepoint_time_ticks =
duke@435 67 PerfDataManager::create_counter(SUN_RT, "safepointTime",
duke@435 68 PerfData::U_Ticks, CHECK);
duke@435 69
duke@435 70 _application_time_ticks =
duke@435 71 PerfDataManager::create_counter(SUN_RT, "applicationTime",
duke@435 72 PerfData::U_Ticks, CHECK);
duke@435 73
duke@435 74
duke@435 75 // create performance counters for jvm_version and its capabilities
duke@435 76 PerfDataManager::create_constant(SUN_RT, "jvmVersion", PerfData::U_None,
duke@435 77 (jlong) Abstract_VM_Version::jvm_version(), CHECK);
duke@435 78
duke@435 79 // I/O interruption related counters
duke@435 80
duke@435 81 // thread signaling via os::interrupt()
duke@435 82
duke@435 83 _thread_interrupt_signaled_count =
duke@435 84 PerfDataManager::create_counter(SUN_RT,
duke@435 85 "threadInterruptSignaled", PerfData::U_Events, CHECK);
duke@435 86
duke@435 87 // OS_INTRPT via "check before" in _INTERRUPTIBLE
duke@435 88
duke@435 89 _interrupted_before_count =
duke@435 90 PerfDataManager::create_counter(SUN_RT, "interruptedBeforeIO",
duke@435 91 PerfData::U_Events, CHECK);
duke@435 92
duke@435 93 // OS_INTRPT via "check during" in _INTERRUPTIBLE
duke@435 94
duke@435 95 _interrupted_during_count =
duke@435 96 PerfDataManager::create_counter(SUN_RT, "interruptedDuringIO",
duke@435 97 PerfData::U_Events, CHECK);
duke@435 98
duke@435 99 // The capabilities counter is a binary representation of the VM capabilities in string.
duke@435 100 // This string respresentation simplifies the implementation of the client side
duke@435 101 // to parse the value.
duke@435 102 char capabilities[65];
duke@435 103 size_t len = sizeof(capabilities);
duke@435 104 memset((void*) capabilities, '0', len);
duke@435 105 capabilities[len-1] = '\0';
duke@435 106 capabilities[0] = AttachListener::is_attach_supported() ? '1' : '0';
jprovino@4165 107 #if INCLUDE_SERVICES
duke@435 108 capabilities[1] = '1';
jprovino@4165 109 #endif // INCLUDE_SERVICES
duke@435 110 PerfDataManager::create_string_constant(SUN_RT, "jvmCapabilities",
duke@435 111 capabilities, CHECK);
duke@435 112 }
duke@435 113 }
duke@435 114
duke@435 115 void RuntimeService::record_safepoint_begin() {
dcubed@3202 116 #ifndef USDT2
duke@435 117 HS_DTRACE_PROBE(hs_private, safepoint__begin);
dcubed@3202 118 #else /* USDT2 */
dcubed@3202 119 HS_PRIVATE_SAFEPOINT_BEGIN();
dcubed@3202 120 #endif /* USDT2 */
johnc@1695 121
johnc@1695 122 // Print the time interval in which the app was executing
hseigel@5891 123 if (PrintGCApplicationConcurrentTime && _app_timer.is_updated()) {
brutisso@4934 124 gclog_or_tty->date_stamp(PrintGCDateStamps);
brutisso@4934 125 gclog_or_tty->stamp(PrintGCTimeStamps);
johnc@1695 126 gclog_or_tty->print_cr("Application time: %3.7f seconds",
johnc@1695 127 last_application_time_sec());
johnc@1695 128 }
johnc@1695 129
duke@435 130 // update the time stamp to begin recording safepoint time
duke@435 131 _safepoint_timer.update();
vkempik@7326 132 _last_safepoint_sync_time_sec = 0.0;
duke@435 133 if (UsePerfData) {
duke@435 134 _total_safepoints->inc();
duke@435 135 if (_app_timer.is_updated()) {
duke@435 136 _application_time_ticks->inc(_app_timer.ticks_since_update());
duke@435 137 }
duke@435 138 }
duke@435 139 }
duke@435 140
duke@435 141 void RuntimeService::record_safepoint_synchronized() {
duke@435 142 if (UsePerfData) {
duke@435 143 _sync_time_ticks->inc(_safepoint_timer.ticks_since_update());
duke@435 144 }
vkempik@7326 145 if (PrintGCApplicationStoppedTime) {
vkempik@7326 146 _last_safepoint_sync_time_sec = last_safepoint_time_sec();
vkempik@7326 147 }
duke@435 148 }
duke@435 149
duke@435 150 void RuntimeService::record_safepoint_end() {
dcubed@3202 151 #ifndef USDT2
duke@435 152 HS_DTRACE_PROBE(hs_private, safepoint__end);
dcubed@3202 153 #else /* USDT2 */
dcubed@3202 154 HS_PRIVATE_SAFEPOINT_END();
dcubed@3202 155 #endif /* USDT2 */
johnc@1695 156
johnc@1695 157 // Print the time interval for which the app was stopped
johnc@1695 158 // during the current safepoint operation.
johnc@1695 159 if (PrintGCApplicationStoppedTime) {
brutisso@4934 160 gclog_or_tty->date_stamp(PrintGCDateStamps);
brutisso@4934 161 gclog_or_tty->stamp(PrintGCTimeStamps);
johnc@1695 162 gclog_or_tty->print_cr("Total time for which application threads "
vkempik@7326 163 "were stopped: %3.7f seconds, "
vkempik@7326 164 "Stopping threads took: %3.7f seconds",
vkempik@7326 165 last_safepoint_time_sec(),
vkempik@7326 166 _last_safepoint_sync_time_sec);
johnc@1695 167 }
johnc@1695 168
duke@435 169 // update the time stamp to begin recording app time
duke@435 170 _app_timer.update();
duke@435 171 if (UsePerfData) {
duke@435 172 _safepoint_time_ticks->inc(_safepoint_timer.ticks_since_update());
duke@435 173 }
duke@435 174 }
duke@435 175
duke@435 176 void RuntimeService::record_application_start() {
duke@435 177 // update the time stamp to begin recording app time
duke@435 178 _app_timer.update();
duke@435 179 }
duke@435 180
duke@435 181 // Don't need to record application end because we currently
duke@435 182 // exit at a safepoint and record_safepoint_begin() handles updating
duke@435 183 // the application time counter at VM exit.
duke@435 184
duke@435 185 jlong RuntimeService::safepoint_sync_time_ms() {
duke@435 186 return UsePerfData ?
duke@435 187 Management::ticks_to_ms(_sync_time_ticks->get_value()) : -1;
duke@435 188 }
duke@435 189
duke@435 190 jlong RuntimeService::safepoint_count() {
duke@435 191 return UsePerfData ?
duke@435 192 _total_safepoints->get_value() : -1;
duke@435 193 }
duke@435 194 jlong RuntimeService::safepoint_time_ms() {
duke@435 195 return UsePerfData ?
duke@435 196 Management::ticks_to_ms(_safepoint_time_ticks->get_value()) : -1;
duke@435 197 }
duke@435 198
duke@435 199 jlong RuntimeService::application_time_ms() {
duke@435 200 return UsePerfData ?
duke@435 201 Management::ticks_to_ms(_application_time_ticks->get_value()) : -1;
duke@435 202 }
duke@435 203
duke@435 204 void RuntimeService::record_interrupted_before_count() {
duke@435 205 if (UsePerfData) {
duke@435 206 _interrupted_before_count->inc();
duke@435 207 }
duke@435 208 }
duke@435 209
duke@435 210 void RuntimeService::record_interrupted_during_count() {
duke@435 211 if (UsePerfData) {
duke@435 212 _interrupted_during_count->inc();
duke@435 213 }
duke@435 214 }
duke@435 215
duke@435 216 void RuntimeService::record_thread_interrupt_signaled_count() {
duke@435 217 if (UsePerfData) {
duke@435 218 _thread_interrupt_signaled_count->inc();
duke@435 219 }
duke@435 220 }
jprovino@4165 221
jprovino@4165 222 #endif // INCLUDE_MANAGEMENT

mercurial