src/share/vm/services/runtimeService.cpp

Tue, 11 May 2010 14:35:43 -0700

author
prr
date
Tue, 11 May 2010 14:35:43 -0700
changeset 1840
fb57d4cf76c2
parent 1695
8859772195c6
child 1907
c18cbe5936b8
permissions
-rw-r--r--

6931180: Migration to recent versions of MS Platform SDK
6951582: Build problems on win64
Summary: Changes to enable building JDK7 with Microsoft Visual Studio 2010
Reviewed-by: ohair, art, ccheung, dcubed

duke@435 1 /*
johnc@1695 2 * Copyright 2003-2010 Sun Microsystems, Inc. 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 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 # include "incls/_precompiled.incl"
duke@435 26 # include "incls/_runtimeService.cpp.incl"
duke@435 27
duke@435 28 HS_DTRACE_PROBE_DECL(hs_private, safepoint__begin);
duke@435 29 HS_DTRACE_PROBE_DECL(hs_private, safepoint__end);
duke@435 30
duke@435 31 TimeStamp RuntimeService::_app_timer;
duke@435 32 TimeStamp RuntimeService::_safepoint_timer;
duke@435 33 PerfCounter* RuntimeService::_sync_time_ticks = NULL;
duke@435 34 PerfCounter* RuntimeService::_total_safepoints = NULL;
duke@435 35 PerfCounter* RuntimeService::_safepoint_time_ticks = NULL;
duke@435 36 PerfCounter* RuntimeService::_application_time_ticks = NULL;
duke@435 37 PerfCounter* RuntimeService::_thread_interrupt_signaled_count = NULL;
duke@435 38 PerfCounter* RuntimeService::_interrupted_before_count = NULL;
duke@435 39 PerfCounter* RuntimeService::_interrupted_during_count = NULL;
duke@435 40
duke@435 41 void RuntimeService::init() {
duke@435 42 // Make sure the VM version is initialized
duke@435 43 Abstract_VM_Version::initialize();
duke@435 44
duke@435 45 if (UsePerfData) {
duke@435 46 EXCEPTION_MARK;
duke@435 47
duke@435 48 _sync_time_ticks =
duke@435 49 PerfDataManager::create_counter(SUN_RT, "safepointSyncTime",
duke@435 50 PerfData::U_Ticks, CHECK);
duke@435 51
duke@435 52 _total_safepoints =
duke@435 53 PerfDataManager::create_counter(SUN_RT, "safepoints",
duke@435 54 PerfData::U_Events, CHECK);
duke@435 55
duke@435 56 _safepoint_time_ticks =
duke@435 57 PerfDataManager::create_counter(SUN_RT, "safepointTime",
duke@435 58 PerfData::U_Ticks, CHECK);
duke@435 59
duke@435 60 _application_time_ticks =
duke@435 61 PerfDataManager::create_counter(SUN_RT, "applicationTime",
duke@435 62 PerfData::U_Ticks, CHECK);
duke@435 63
duke@435 64
duke@435 65 // create performance counters for jvm_version and its capabilities
duke@435 66 PerfDataManager::create_constant(SUN_RT, "jvmVersion", PerfData::U_None,
duke@435 67 (jlong) Abstract_VM_Version::jvm_version(), CHECK);
duke@435 68
duke@435 69 // I/O interruption related counters
duke@435 70
duke@435 71 // thread signaling via os::interrupt()
duke@435 72
duke@435 73 _thread_interrupt_signaled_count =
duke@435 74 PerfDataManager::create_counter(SUN_RT,
duke@435 75 "threadInterruptSignaled", PerfData::U_Events, CHECK);
duke@435 76
duke@435 77 // OS_INTRPT via "check before" in _INTERRUPTIBLE
duke@435 78
duke@435 79 _interrupted_before_count =
duke@435 80 PerfDataManager::create_counter(SUN_RT, "interruptedBeforeIO",
duke@435 81 PerfData::U_Events, CHECK);
duke@435 82
duke@435 83 // OS_INTRPT via "check during" in _INTERRUPTIBLE
duke@435 84
duke@435 85 _interrupted_during_count =
duke@435 86 PerfDataManager::create_counter(SUN_RT, "interruptedDuringIO",
duke@435 87 PerfData::U_Events, CHECK);
duke@435 88
duke@435 89 // The capabilities counter is a binary representation of the VM capabilities in string.
duke@435 90 // This string respresentation simplifies the implementation of the client side
duke@435 91 // to parse the value.
duke@435 92 char capabilities[65];
duke@435 93 size_t len = sizeof(capabilities);
duke@435 94 memset((void*) capabilities, '0', len);
duke@435 95 capabilities[len-1] = '\0';
duke@435 96 capabilities[0] = AttachListener::is_attach_supported() ? '1' : '0';
duke@435 97 #ifdef KERNEL
duke@435 98 capabilities[1] = '1';
duke@435 99 #endif // KERNEL
duke@435 100 PerfDataManager::create_string_constant(SUN_RT, "jvmCapabilities",
duke@435 101 capabilities, CHECK);
duke@435 102 }
duke@435 103 }
duke@435 104
duke@435 105 void RuntimeService::record_safepoint_begin() {
duke@435 106 HS_DTRACE_PROBE(hs_private, safepoint__begin);
johnc@1695 107
johnc@1695 108 // Print the time interval in which the app was executing
johnc@1695 109 if (PrintGCApplicationConcurrentTime) {
johnc@1695 110 gclog_or_tty->print_cr("Application time: %3.7f seconds",
johnc@1695 111 last_application_time_sec());
johnc@1695 112 }
johnc@1695 113
duke@435 114 // update the time stamp to begin recording safepoint time
duke@435 115 _safepoint_timer.update();
duke@435 116 if (UsePerfData) {
duke@435 117 _total_safepoints->inc();
duke@435 118 if (_app_timer.is_updated()) {
duke@435 119 _application_time_ticks->inc(_app_timer.ticks_since_update());
duke@435 120 }
duke@435 121 }
duke@435 122 }
duke@435 123
duke@435 124 void RuntimeService::record_safepoint_synchronized() {
duke@435 125 if (UsePerfData) {
duke@435 126 _sync_time_ticks->inc(_safepoint_timer.ticks_since_update());
duke@435 127 }
duke@435 128 }
duke@435 129
duke@435 130 void RuntimeService::record_safepoint_end() {
duke@435 131 HS_DTRACE_PROBE(hs_private, safepoint__end);
johnc@1695 132
johnc@1695 133 // Print the time interval for which the app was stopped
johnc@1695 134 // during the current safepoint operation.
johnc@1695 135 if (PrintGCApplicationStoppedTime) {
johnc@1695 136 gclog_or_tty->print_cr("Total time for which application threads "
johnc@1695 137 "were stopped: %3.7f seconds",
johnc@1695 138 last_safepoint_time_sec());
johnc@1695 139 }
johnc@1695 140
duke@435 141 // update the time stamp to begin recording app time
duke@435 142 _app_timer.update();
duke@435 143 if (UsePerfData) {
duke@435 144 _safepoint_time_ticks->inc(_safepoint_timer.ticks_since_update());
duke@435 145 }
duke@435 146 }
duke@435 147
duke@435 148 void RuntimeService::record_application_start() {
duke@435 149 // update the time stamp to begin recording app time
duke@435 150 _app_timer.update();
duke@435 151 }
duke@435 152
duke@435 153 // Don't need to record application end because we currently
duke@435 154 // exit at a safepoint and record_safepoint_begin() handles updating
duke@435 155 // the application time counter at VM exit.
duke@435 156
duke@435 157 jlong RuntimeService::safepoint_sync_time_ms() {
duke@435 158 return UsePerfData ?
duke@435 159 Management::ticks_to_ms(_sync_time_ticks->get_value()) : -1;
duke@435 160 }
duke@435 161
duke@435 162 jlong RuntimeService::safepoint_count() {
duke@435 163 return UsePerfData ?
duke@435 164 _total_safepoints->get_value() : -1;
duke@435 165 }
duke@435 166 jlong RuntimeService::safepoint_time_ms() {
duke@435 167 return UsePerfData ?
duke@435 168 Management::ticks_to_ms(_safepoint_time_ticks->get_value()) : -1;
duke@435 169 }
duke@435 170
duke@435 171 jlong RuntimeService::application_time_ms() {
duke@435 172 return UsePerfData ?
duke@435 173 Management::ticks_to_ms(_application_time_ticks->get_value()) : -1;
duke@435 174 }
duke@435 175
duke@435 176 void RuntimeService::record_interrupted_before_count() {
duke@435 177 if (UsePerfData) {
duke@435 178 _interrupted_before_count->inc();
duke@435 179 }
duke@435 180 }
duke@435 181
duke@435 182 void RuntimeService::record_interrupted_during_count() {
duke@435 183 if (UsePerfData) {
duke@435 184 _interrupted_during_count->inc();
duke@435 185 }
duke@435 186 }
duke@435 187
duke@435 188 void RuntimeService::record_thread_interrupt_signaled_count() {
duke@435 189 if (UsePerfData) {
duke@435 190 _thread_interrupt_signaled_count->inc();
duke@435 191 }
duke@435 192 }

mercurial