src/hotspot/share/services/threadService.hpp
author ehelin
Wed, 23 Jan 2019 13:40:09 +0100
changeset 53463 b2d1c3b0bd31
parent 53244 9807daeb47c4
child 53507 44a9dd4e4d96
permissions -rw-r--r--
8213231: ThreadSnapshot::_threadObj can become stale Reviewed-by: dcubed, dholmes, rehn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 53123
diff changeset
     2
 * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3795
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3795
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3795
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 53123
diff changeset
    25
#ifndef SHARE_SERVICES_THREADSERVICE_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 53123
diff changeset
    26
#define SHARE_SERVICES_THREADSERVICE_HPP
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "classfile/javaClasses.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "runtime/handles.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "runtime/init.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
#include "runtime/jniHandles.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    32
#include "runtime/objectMonitor.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    33
#include "runtime/perfData.hpp"
52673
61b3b58a1d1d 8214181: safepoint header cleanup
rehn
parents: 52297
diff changeset
    34
#include "runtime/safepoint.hpp"
48105
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47216
diff changeset
    35
#include "runtime/thread.hpp"
48312
2a1413298af0 8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents: 48105
diff changeset
    36
#include "runtime/threadSMR.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    37
#include "services/management.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    38
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
class OopClosure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
class ThreadDumpResult;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
class ThreadStackTrace;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
class ThreadSnapshot;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
class StackFrameInfo;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
class ThreadConcurrentLocks;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
class DeadlockCycle;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
// VM monitoring and management support for the thread and
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
// synchronization subsystem
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
// Thread contention monitoring is disabled by default.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
// When enabled, the VM will begin measuring the accumulated
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
// elapsed time a thread blocked on synchronization.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
class ThreadService : public AllStatic {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  // These counters could be moved to Threads class
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  static PerfCounter*  _total_threads_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  static PerfVariable* _live_threads_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  static PerfVariable* _peak_threads_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  static PerfVariable* _daemon_threads_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
52297
99962c340e73 8021335: Missing synchronization when reading counters for live threads and peak thread count
dlong
parents: 51334
diff changeset
    62
  // These 2 counters are like the above thread counts, but are
99962c340e73 8021335: Missing synchronization when reading counters for live threads and peak thread count
dlong
parents: 51334
diff changeset
    63
  // atomically decremented in ThreadService::current_thread_exiting instead of
99962c340e73 8021335: Missing synchronization when reading counters for live threads and peak thread count
dlong
parents: 51334
diff changeset
    64
  // ThreadService::remove_thread, so that the thread count is updated before
99962c340e73 8021335: Missing synchronization when reading counters for live threads and peak thread count
dlong
parents: 51334
diff changeset
    65
  // Thread.join() returns.
99962c340e73 8021335: Missing synchronization when reading counters for live threads and peak thread count
dlong
parents: 51334
diff changeset
    66
  static volatile int  _atomic_threads_count;
99962c340e73 8021335: Missing synchronization when reading counters for live threads and peak thread count
dlong
parents: 51334
diff changeset
    67
  static volatile int  _atomic_daemon_threads_count;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  static bool          _thread_monitoring_contention_enabled;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  static bool          _thread_cpu_time_enabled;
7724
a92d706dbdd5 7003271: Hotspot should track cumulative Java heap bytes allocated on a per-thread basis
phh
parents: 7397
diff changeset
    71
  static bool          _thread_allocated_memory_enabled;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  // Need to keep the list of thread dump result that
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    74
  // keep references to Method* since thread dump can be
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  // requested by multiple threads concurrently.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  static ThreadDumpResult* _threaddump_list;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
52297
99962c340e73 8021335: Missing synchronization when reading counters for live threads and peak thread count
dlong
parents: 51334
diff changeset
    78
  static void decrement_thread_counts(JavaThread* jt, bool daemon);
99962c340e73 8021335: Missing synchronization when reading counters for live threads and peak thread count
dlong
parents: 51334
diff changeset
    79
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  static void init();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  static void add_thread(JavaThread* thread, bool daemon);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  static void remove_thread(JavaThread* thread, bool daemon);
52297
99962c340e73 8021335: Missing synchronization when reading counters for live threads and peak thread count
dlong
parents: 51334
diff changeset
    84
  static void current_thread_exiting(JavaThread* jt, bool daemon);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  static bool set_thread_monitoring_contention(bool flag);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  static bool is_thread_monitoring_contention() { return _thread_monitoring_contention_enabled; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  static bool set_thread_cpu_time_enabled(bool flag);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  static bool is_thread_cpu_time_enabled()    { return _thread_cpu_time_enabled; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
7724
a92d706dbdd5 7003271: Hotspot should track cumulative Java heap bytes allocated on a per-thread basis
phh
parents: 7397
diff changeset
    92
  static bool set_thread_allocated_memory_enabled(bool flag);
53123
96ce82319e82 8215791: Tiny bug in VM monitoring/management
ghaug
parents: 52673
diff changeset
    93
  static bool is_thread_allocated_memory_enabled() { return _thread_allocated_memory_enabled; }
7724
a92d706dbdd5 7003271: Hotspot should track cumulative Java heap bytes allocated on a per-thread basis
phh
parents: 7397
diff changeset
    94
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  static jlong get_total_thread_count()       { return _total_threads_count->get_value(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  static jlong get_peak_thread_count()        { return _peak_threads_count->get_value(); }
52297
99962c340e73 8021335: Missing synchronization when reading counters for live threads and peak thread count
dlong
parents: 51334
diff changeset
    97
  static jlong get_live_thread_count()        { return _atomic_threads_count; }
99962c340e73 8021335: Missing synchronization when reading counters for live threads and peak thread count
dlong
parents: 51334
diff changeset
    98
  static jlong get_daemon_thread_count()      { return _atomic_daemon_threads_count; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  // Support for thread dump
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  static void   add_thread_dump(ThreadDumpResult* dump);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  static void   remove_thread_dump(ThreadDumpResult* dump);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  static Handle get_current_contended_monitor(JavaThread* thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  // This function is called by JVM_DumpThreads.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  static Handle dump_stack_traces(GrowableArray<instanceHandle>* threads,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
                                  int num_threads, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  static void   reset_peak_thread_count();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  static void   reset_contention_count_stat(JavaThread* thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  static void   reset_contention_time_stat(JavaThread* thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
48105
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47216
diff changeset
   114
  static DeadlockCycle*       find_deadlocks_at_safepoint(ThreadsList * t_list, bool object_monitors_only);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  // GC support
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  static void   oops_do(OopClosure* f);
21735
379ba90c3dc4 8027630: SIGSEGV in const char*Klass::external_name()
sla
parents: 13728
diff changeset
   118
  static void   metadata_do(void f(Metadata*));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
// Per-thread Statistics for synchronization
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 7724
diff changeset
   122
class ThreadStatistics : public CHeapObj<mtInternal> {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  // The following contention statistics are only updated by
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  // the thread owning these statistics when contention occurs.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  jlong        _contended_enter_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  elapsedTimer _contended_enter_timer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  jlong        _monitor_wait_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  elapsedTimer _monitor_wait_timer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  jlong        _sleep_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  elapsedTimer _sleep_timer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  // These two reset flags are set to true when another thread
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  // requests to reset the statistics.  The actual statistics
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  // are reset when the thread contention occurs and attempts
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  // to update the statistics.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  bool         _count_pending_reset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  bool         _timer_pending_reset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  // Keep accurate times for potentially recursive class operations
3575
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1623
diff changeset
   143
  int           _perf_recursion_counts[6];
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1623
diff changeset
   144
  elapsedTimer  _perf_timers[6];
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  // utility functions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  void  check_and_reset_count()            {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
                                             if (!_count_pending_reset) return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
                                             _contended_enter_count = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
                                             _monitor_wait_count = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
                                             _sleep_count = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
                                             _count_pending_reset = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
                                           }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  void  check_and_reset_timer()            {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
                                             if (!_timer_pending_reset) return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
                                             _contended_enter_timer.reset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
                                             _monitor_wait_timer.reset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
                                             _sleep_timer.reset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
                                             _timer_pending_reset = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
                                           }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  ThreadStatistics();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  jlong contended_enter_count()            { return (_count_pending_reset ? 0 : _contended_enter_count); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  jlong contended_enter_ticks()            { return (_timer_pending_reset ? 0 : _contended_enter_timer.active_ticks()); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  jlong monitor_wait_count()               { return (_count_pending_reset ? 0 : _monitor_wait_count); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  jlong monitor_wait_ticks()               { return (_timer_pending_reset ? 0 : _monitor_wait_timer.active_ticks()); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  jlong sleep_count()                      { return (_count_pending_reset ? 0 : _sleep_count); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  jlong sleep_ticks()                      { return (_timer_pending_reset ? 0 : _sleep_timer.active_ticks()); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  void monitor_wait()                      { check_and_reset_count(); _monitor_wait_count++; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  void monitor_wait_begin()                { check_and_reset_timer(); _monitor_wait_timer.start(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  void monitor_wait_end()                  { _monitor_wait_timer.stop(); check_and_reset_timer(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  void thread_sleep()                      { check_and_reset_count(); _sleep_count++; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  void thread_sleep_begin()                { check_and_reset_timer(); _sleep_timer.start(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  void thread_sleep_end()                  { _sleep_timer.stop(); check_and_reset_timer(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  void contended_enter()                   { check_and_reset_count(); _contended_enter_count++; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  void contended_enter_begin()             { check_and_reset_timer(); _contended_enter_timer.start(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  void contended_enter_end()               { _contended_enter_timer.stop(); check_and_reset_timer(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  void reset_count_stat()                  { _count_pending_reset = true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  void reset_time_stat()                   { _timer_pending_reset = true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
3575
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1623
diff changeset
   187
  int* perf_recursion_counts_addr()        { return _perf_recursion_counts; }
224791e7ecab 6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents: 1623
diff changeset
   188
  elapsedTimer* perf_timers_addr()         { return _perf_timers; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
// Thread snapshot to represent the thread state and statistics
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 7724
diff changeset
   192
class ThreadSnapshot : public CHeapObj<mtInternal> {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
private:
48105
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47216
diff changeset
   194
  // This JavaThread* is protected by being stored in objects that are
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47216
diff changeset
   195
  // protected by a ThreadsListSetter (ThreadDumpResult).
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  JavaThread* _thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  oop         _threadObj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  java_lang_Thread::ThreadStatus _thread_status;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  bool    _is_ext_suspended;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  bool    _is_in_native;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  jlong   _contended_enter_ticks;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  jlong   _contended_enter_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  jlong   _monitor_wait_ticks;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  jlong   _monitor_wait_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  jlong   _sleep_ticks;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  jlong   _sleep_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  oop     _blocker_object;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  oop     _blocker_object_owner;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  ThreadStackTrace*      _stack_trace;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  ThreadConcurrentLocks* _concurrent_locks;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
  ThreadSnapshot*        _next;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
53463
b2d1c3b0bd31 8213231: ThreadSnapshot::_threadObj can become stale
ehelin
parents: 53244
diff changeset
   216
  // ThreadSnapshot instances should only be created via
b2d1c3b0bd31 8213231: ThreadSnapshot::_threadObj can become stale
ehelin
parents: 53244
diff changeset
   217
  // ThreadDumpResult::add_thread_snapshot.
b2d1c3b0bd31 8213231: ThreadSnapshot::_threadObj can become stale
ehelin
parents: 53244
diff changeset
   218
  friend class ThreadDumpResult;
51334
cc2c79d22508 8208671: Runtime, JFR, Serviceability changes to allow enabling -Wreorder
tschatzl
parents: 49956
diff changeset
   219
  ThreadSnapshot() : _thread(NULL), _threadObj(NULL),
cc2c79d22508 8208671: Runtime, JFR, Serviceability changes to allow enabling -Wreorder
tschatzl
parents: 49956
diff changeset
   220
                     _blocker_object(NULL), _blocker_object_owner(NULL),
cc2c79d22508 8208671: Runtime, JFR, Serviceability changes to allow enabling -Wreorder
tschatzl
parents: 49956
diff changeset
   221
                     _stack_trace(NULL), _concurrent_locks(NULL), _next(NULL) {};
53463
b2d1c3b0bd31 8213231: ThreadSnapshot::_threadObj can become stale
ehelin
parents: 53244
diff changeset
   222
  void        initialize(ThreadsList * t_list, JavaThread* thread);
b2d1c3b0bd31 8213231: ThreadSnapshot::_threadObj can become stale
ehelin
parents: 53244
diff changeset
   223
b2d1c3b0bd31 8213231: ThreadSnapshot::_threadObj can become stale
ehelin
parents: 53244
diff changeset
   224
public:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
  ~ThreadSnapshot();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
  java_lang_Thread::ThreadStatus thread_status() { return _thread_status; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
  oop         threadObj() const           { return _threadObj; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
  void        set_next(ThreadSnapshot* n) { _next = n; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  bool        is_ext_suspended()          { return _is_ext_suspended; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  bool        is_in_native()              { return _is_in_native; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
  jlong       contended_enter_count()     { return _contended_enter_count; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  jlong       contended_enter_ticks()     { return _contended_enter_ticks; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  jlong       monitor_wait_count()        { return _monitor_wait_count; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
  jlong       monitor_wait_ticks()        { return _monitor_wait_ticks; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  jlong       sleep_count()               { return _sleep_count; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  jlong       sleep_ticks()               { return _sleep_ticks; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  oop         blocker_object()            { return _blocker_object; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  oop         blocker_object_owner()      { return _blocker_object_owner; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  ThreadSnapshot*   next() const          { return _next; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
  ThreadStackTrace* get_stack_trace()     { return _stack_trace; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
  ThreadConcurrentLocks* get_concurrent_locks()     { return _concurrent_locks; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
  void        dump_stack_at_safepoint(int max_depth, bool with_locked_monitors);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
  void        set_concurrent_locks(ThreadConcurrentLocks* l) { _concurrent_locks = l; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
  void        oops_do(OopClosure* f);
21735
379ba90c3dc4 8027630: SIGSEGV in const char*Klass::external_name()
sla
parents: 13728
diff changeset
   254
  void        metadata_do(void f(Metadata*));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 7724
diff changeset
   257
class ThreadStackTrace : public CHeapObj<mtInternal> {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
  JavaThread*                     _thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  int                             _depth;  // number of stack frames added
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
  bool                            _with_locked_monitors;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
  GrowableArray<StackFrameInfo*>* _frames;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  GrowableArray<oop>*             _jni_locked_monitors;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
  ThreadStackTrace(JavaThread* thread, bool with_locked_monitors);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
  ~ThreadStackTrace();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
1428
147c6bcaa316 6306922: Dump dump created by +HeapDumpOnOutOfMemoryError should include stack traces for stack roots
mchung
parents: 1
diff changeset
   270
  JavaThread*     thread()              { return _thread; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
  StackFrameInfo* stack_frame_at(int i) { return _frames->at(i); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
  int             get_stack_depth()     { return _depth; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
  void            add_stack_frame(javaVFrame* jvf);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  void            dump_stack_at_safepoint(int max_depth);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
  Handle          allocate_fill_stack_trace_element_array(TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
  void            oops_do(OopClosure* f);
21735
379ba90c3dc4 8027630: SIGSEGV in const char*Klass::external_name()
sla
parents: 13728
diff changeset
   278
  void            metadata_do(void f(Metadata*));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
  GrowableArray<oop>* jni_locked_monitors() { return _jni_locked_monitors; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
  int             num_jni_locked_monitors() { return (_jni_locked_monitors != NULL ? _jni_locked_monitors->length() : 0); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
  bool            is_owned_monitor_on_stack(oop object);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
  void            add_jni_locked_monitor(oop object) { _jni_locked_monitors->append(object); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   286
// StackFrameInfo for keeping Method* and bci during
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
// stack walking for later construction of StackTraceElement[]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
// Java instances
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 7724
diff changeset
   289
class StackFrameInfo : public CHeapObj<mtInternal> {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
 private:
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   291
  Method*             _method;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
  int                 _bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
  GrowableArray<oop>* _locked_monitors; // list of object monitors locked by this frame
21735
379ba90c3dc4 8027630: SIGSEGV in const char*Klass::external_name()
sla
parents: 13728
diff changeset
   294
  // We need to save the mirrors in the backtrace to keep the class
379ba90c3dc4 8027630: SIGSEGV in const char*Klass::external_name()
sla
parents: 13728
diff changeset
   295
  // from being unloaded while we still have this stack trace.
379ba90c3dc4 8027630: SIGSEGV in const char*Klass::external_name()
sla
parents: 13728
diff changeset
   296
  oop                 _class_holder;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
  StackFrameInfo(javaVFrame* jvf, bool with_locked_monitors);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
  ~StackFrameInfo() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
    if (_locked_monitors != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
      delete _locked_monitors;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
  };
21735
379ba90c3dc4 8027630: SIGSEGV in const char*Klass::external_name()
sla
parents: 13728
diff changeset
   306
  Method*   method() const       { return _method; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
  int       bci()    const       { return _bci; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
  void      oops_do(OopClosure* f);
21735
379ba90c3dc4 8027630: SIGSEGV in const char*Klass::external_name()
sla
parents: 13728
diff changeset
   309
  void      metadata_do(void f(Metadata*));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
  int       num_locked_monitors()       { return (_locked_monitors != NULL ? _locked_monitors->length() : 0); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
  GrowableArray<oop>* locked_monitors() { return _locked_monitors; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
  void      print_on(outputStream* st) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 7724
diff changeset
   317
class ThreadConcurrentLocks : public CHeapObj<mtInternal> {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
  GrowableArray<instanceOop>* _owned_locks;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
  ThreadConcurrentLocks*      _next;
48105
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47216
diff changeset
   321
  // This JavaThread* is protected in one of two different ways
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47216
diff changeset
   322
  // depending on the usage of the ThreadConcurrentLocks object:
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47216
diff changeset
   323
  // 1) by being stored in objects that are only allocated and used at a
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47216
diff changeset
   324
  // safepoint (ConcurrentLocksDump), or 2) by being stored in objects
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47216
diff changeset
   325
  // that are protected by a ThreadsListSetter (ThreadSnapshot inside
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47216
diff changeset
   326
  // ThreadDumpResult).
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
  JavaThread*                 _thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
  ThreadConcurrentLocks(JavaThread* thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
  ~ThreadConcurrentLocks();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
  void                        add_lock(instanceOop o);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
  void                        set_next(ThreadConcurrentLocks* n) { _next = n; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
  ThreadConcurrentLocks*      next() { return _next; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
  JavaThread*                 java_thread()                      { return _thread; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
  GrowableArray<instanceOop>* owned_locks()                      { return _owned_locks; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
  void                        oops_do(OopClosure* f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
class ConcurrentLocksDump : public StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
  ThreadConcurrentLocks* _map;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
  ThreadConcurrentLocks* _last;   // Last ThreadConcurrentLocks in the map
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
  bool                   _retain_map_on_free;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
  void build_map(GrowableArray<oop>* aos_objects);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
  void add_lock(JavaThread* thread, instanceOop o);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
 public:
48105
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47216
diff changeset
   350
  ConcurrentLocksDump(bool retain_map_on_free) : _map(NULL), _last(NULL), _retain_map_on_free(retain_map_on_free) {
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47216
diff changeset
   351
    assert(SafepointSynchronize::is_at_safepoint(), "Must be constructed at a safepoint.");
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47216
diff changeset
   352
  };
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47216
diff changeset
   353
  ConcurrentLocksDump() : _map(NULL), _last(NULL), _retain_map_on_free(false) {
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47216
diff changeset
   354
    assert(SafepointSynchronize::is_at_safepoint(), "Must be constructed at a safepoint.");
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47216
diff changeset
   355
  };
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
  ~ConcurrentLocksDump();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
  void                        dump_at_safepoint();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
  ThreadConcurrentLocks*      thread_concurrent_locks(JavaThread* thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
  void                        print_locks_on(JavaThread* t, outputStream* st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
class ThreadDumpResult : public StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
  int                  _num_threads;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
  int                  _num_snapshots;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
  ThreadSnapshot*      _snapshots;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
  ThreadSnapshot*      _last;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
  ThreadDumpResult*    _next;
48105
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47216
diff changeset
   370
  ThreadsListSetter    _setter;  // Helper to set hazard ptr in the originating thread
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47216
diff changeset
   371
                                 // which protects the JavaThreads in _snapshots.
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47216
diff changeset
   372
53463
b2d1c3b0bd31 8213231: ThreadSnapshot::_threadObj can become stale
ehelin
parents: 53244
diff changeset
   373
  void                 link_thread_snapshot(ThreadSnapshot* ts);
b2d1c3b0bd31 8213231: ThreadSnapshot::_threadObj can become stale
ehelin
parents: 53244
diff changeset
   374
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
  ThreadDumpResult();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
  ThreadDumpResult(int num_threads);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
  ~ThreadDumpResult();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
53463
b2d1c3b0bd31 8213231: ThreadSnapshot::_threadObj can become stale
ehelin
parents: 53244
diff changeset
   380
  ThreadSnapshot*      add_thread_snapshot();
b2d1c3b0bd31 8213231: ThreadSnapshot::_threadObj can become stale
ehelin
parents: 53244
diff changeset
   381
  ThreadSnapshot*      add_thread_snapshot(JavaThread* thread);
b2d1c3b0bd31 8213231: ThreadSnapshot::_threadObj can become stale
ehelin
parents: 53244
diff changeset
   382
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
  void                 set_next(ThreadDumpResult* next) { _next = next; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
  ThreadDumpResult*    next()                           { return _next; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
  int                  num_threads()                    { return _num_threads; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
  int                  num_snapshots()                  { return _num_snapshots; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
  ThreadSnapshot*      snapshots()                      { return _snapshots; }
48105
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47216
diff changeset
   388
  void                 set_t_list()                     { _setter.set(); }
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47216
diff changeset
   389
  ThreadsList*         t_list();
49956
a87f2e7a527c 8191798: redo nested ThreadsListHandle to drop Threads_lock
dcubed
parents: 49480
diff changeset
   390
  bool                 t_list_has_been_set()            { return _setter.is_set(); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
  void                 oops_do(OopClosure* f);
21735
379ba90c3dc4 8027630: SIGSEGV in const char*Klass::external_name()
sla
parents: 13728
diff changeset
   392
  void                 metadata_do(void f(Metadata*));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 7724
diff changeset
   395
class DeadlockCycle : public CHeapObj<mtInternal> {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
  bool _is_deadlock;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
  GrowableArray<JavaThread*>* _threads;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
  DeadlockCycle*              _next;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
  DeadlockCycle();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
  ~DeadlockCycle();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
  DeadlockCycle* next()                     { return _next; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
  void           set_next(DeadlockCycle* d) { _next = d; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
  void           add_thread(JavaThread* t)  { _threads->append(t); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
  void           reset()                    { _is_deadlock = false; _threads->clear(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
  void           set_deadlock(bool value)   { _is_deadlock = value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
  bool           is_deadlock()              { return _is_deadlock; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
  int            num_threads()              { return _threads->length(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
  GrowableArray<JavaThread*>* threads()     { return _threads; }
48105
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47216
diff changeset
   412
  void           print_on_with(ThreadsList * t_list, outputStream* st) const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
// Utility class to get list of java threads.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
class ThreadsListEnumerator : public StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
  GrowableArray<instanceHandle>* _threads_array;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
  ThreadsListEnumerator(Thread* cur_thread,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
                        bool include_jvmti_agent_threads = false,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
                        bool include_jni_attaching_threads = true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
  int            num_threads()            { return _threads_array->length(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
  instanceHandle get_threadObj(int index) { return _threads_array->at(index); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
// abstract utility class to set new thread states, and restore previous after the block exits
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
class JavaThreadStatusChanger : public StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
  java_lang_Thread::ThreadStatus _old_state;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
  JavaThread*  _java_thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
  bool _is_alive;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
  void save_old_state(JavaThread* java_thread) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
    _java_thread  = java_thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
    _is_alive = is_alive(java_thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
    if (is_alive()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
      _old_state = java_lang_Thread::get_thread_status(_java_thread->threadObj());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
  static void set_thread_status(JavaThread* java_thread,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
                                java_lang_Thread::ThreadStatus state) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
    java_lang_Thread::set_thread_status(java_thread->threadObj(), state);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
  void set_thread_status(java_lang_Thread::ThreadStatus state) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
    if (is_alive()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
      set_thread_status(_java_thread, state);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
  JavaThreadStatusChanger(JavaThread* java_thread,
33589
7cbd1b2c139b 8139040: Fix initializations before ShouldNotReachHere() etc. and enable -Wuninitialized on linux.
goetz
parents: 22234
diff changeset
   456
                          java_lang_Thread::ThreadStatus state) : _old_state(java_lang_Thread::NEW) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
    save_old_state(java_thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
    set_thread_status(state);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
33589
7cbd1b2c139b 8139040: Fix initializations before ShouldNotReachHere() etc. and enable -Wuninitialized on linux.
goetz
parents: 22234
diff changeset
   461
  JavaThreadStatusChanger(JavaThread* java_thread) : _old_state(java_lang_Thread::NEW) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
    save_old_state(java_thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
  ~JavaThreadStatusChanger() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
    set_thread_status(_old_state);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
  static bool is_alive(JavaThread* java_thread) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
    return java_thread != NULL && java_thread->threadObj() != NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
  bool is_alive() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
    return _is_alive;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
// Change status to waiting on an object  (timed or indefinite)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
class JavaThreadInObjectWaitState : public JavaThreadStatusChanger {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
  ThreadStatistics* _stat;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
  bool _active;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
  JavaThreadInObjectWaitState(JavaThread *java_thread, bool timed) :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
    JavaThreadStatusChanger(java_thread,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
                            timed ? java_lang_Thread::IN_OBJECT_WAIT_TIMED : java_lang_Thread::IN_OBJECT_WAIT) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
    if (is_alive()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
      _stat = java_thread->get_thread_stat();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
      _active = ThreadService::is_thread_monitoring_contention();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
      _stat->monitor_wait();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
      if (_active) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
        _stat->monitor_wait_begin();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
      _active = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
  ~JavaThreadInObjectWaitState() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
    if (_active) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
      _stat->monitor_wait_end();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
// Change status to parked (timed or indefinite)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
class JavaThreadParkedState : public JavaThreadStatusChanger {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
  ThreadStatistics* _stat;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
  bool _active;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
  JavaThreadParkedState(JavaThread *java_thread, bool timed) :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
    JavaThreadStatusChanger(java_thread,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
                            timed ? java_lang_Thread::PARKED_TIMED : java_lang_Thread::PARKED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
    if (is_alive()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
      _stat = java_thread->get_thread_stat();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
      _active = ThreadService::is_thread_monitoring_contention();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
      _stat->monitor_wait();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
      if (_active) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
        _stat->monitor_wait_begin();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
      _active = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
  ~JavaThreadParkedState() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
    if (_active) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
      _stat->monitor_wait_end();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
// Change status to blocked on (re-)entering a synchronization block
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
class JavaThreadBlockedOnMonitorEnterState : public JavaThreadStatusChanger {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
  ThreadStatistics* _stat;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
  bool _active;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
  static bool contended_enter_begin(JavaThread *java_thread) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
    set_thread_status(java_thread, java_lang_Thread::BLOCKED_ON_MONITOR_ENTER);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
    ThreadStatistics* stat = java_thread->get_thread_stat();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
    stat->contended_enter();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
    bool active = ThreadService::is_thread_monitoring_contention();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
    if (active) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
      stat->contended_enter_begin();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
    return active;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
  // java_thread is waiting thread being blocked on monitor reenter.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
  // Current thread is the notifying thread which holds the monitor.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
  static bool wait_reenter_begin(JavaThread *java_thread, ObjectMonitor *obj_m) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
    assert((java_thread != NULL), "Java thread should not be null here");
33589
7cbd1b2c139b 8139040: Fix initializations before ShouldNotReachHere() etc. and enable -Wuninitialized on linux.
goetz
parents: 22234
diff changeset
   558
    bool active = false;
49476
1f904e305a05 8195109: ServiceUtil::visible_oop is not needed anymore
cjplummer
parents: 48312
diff changeset
   559
    if (is_alive(java_thread)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
      active = contended_enter_begin(java_thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
    return active;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
  static void wait_reenter_end(JavaThread *java_thread, bool active) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
    if (active) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
      java_thread->get_thread_stat()->contended_enter_end();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
    set_thread_status(java_thread, java_lang_Thread::RUNNABLE);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
  JavaThreadBlockedOnMonitorEnterState(JavaThread *java_thread, ObjectMonitor *obj_m) :
51334
cc2c79d22508 8208671: Runtime, JFR, Serviceability changes to allow enabling -Wreorder
tschatzl
parents: 49956
diff changeset
   573
    JavaThreadStatusChanger(java_thread), _stat(NULL), _active(false) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
    assert((java_thread != NULL), "Java thread should not be null here");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
    // Change thread status and collect contended enter stats for monitor contended
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
    // enter done for external java world objects and it is contended. All other cases
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
    // like for vm internal objects and for external objects which are not contended
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
    // thread status is not changed and contended enter stat is not collected.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
    _active = false;
49476
1f904e305a05 8195109: ServiceUtil::visible_oop is not needed anymore
cjplummer
parents: 48312
diff changeset
   580
    if (is_alive() && obj_m->contentions() > 0) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
      _stat = java_thread->get_thread_stat();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
      _active = contended_enter_begin(java_thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
  ~JavaThreadBlockedOnMonitorEnterState() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
    if (_active) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
      _stat->contended_enter_end();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
// Change status to sleeping
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
class JavaThreadSleepState : public JavaThreadStatusChanger {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
  ThreadStatistics* _stat;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
  bool _active;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
  JavaThreadSleepState(JavaThread *java_thread) :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
    JavaThreadStatusChanger(java_thread, java_lang_Thread::SLEEPING) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
    if (is_alive()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
      _stat = java_thread->get_thread_stat();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
      _active = ThreadService::is_thread_monitoring_contention();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
      _stat->thread_sleep();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
      if (_active) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
        _stat->thread_sleep_begin();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
      _active = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
  ~JavaThreadSleepState() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
    if (_active) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
      _stat->thread_sleep_end();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   619
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 53123
diff changeset
   620
#endif // SHARE_SERVICES_THREADSERVICE_HPP