src/share/vm/services/runtimeService.cpp

Thu, 05 Jun 2008 15:57:56 -0700

author
ysr
date
Thu, 05 Jun 2008 15:57:56 -0700
changeset 777
37f87013dfd8
parent 435
a61af66fc99e
child 1695
8859772195c6
permissions
-rw-r--r--

6711316: Open source the Garbage-First garbage collector
Summary: First mercurial integration of the code for the Garbage-First garbage collector.
Reviewed-by: apetrusenko, iveresov, jmasa, sgoldman, tonyp, ysr

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

mercurial