hotspot/src/share/vm/runtime/fprofiler.hpp
author mgerdin
Thu, 23 Feb 2012 14:58:35 +0100
changeset 12095 cc3d6f08a4c4
parent 10565 dc90c239f4ec
child 13195 be27e1b6a4b9
permissions -rw-r--r--
7148152: Add whitebox testing API to HotSpot Summary: Add an internal testing API to HotSpot to enable more targeted testing of vm functionality Reviewed-by: phh, dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
8921
14bfe81f2a9d 7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass
trims
parents: 8110
diff changeset
     2
 * Copyright (c) 1997, 2011, 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: 670
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 670
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: 670
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
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#ifndef SHARE_VM_RUNTIME_FPROFILER_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_RUNTIME_FPROFILER_HPP
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 "runtime/timer.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#ifdef TARGET_OS_FAMILY_linux
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
# include "thread_linux.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
#endif
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    32
#ifdef TARGET_OS_FAMILY_solaris
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    33
# include "thread_solaris.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    34
#endif
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    35
#ifdef TARGET_OS_FAMILY_windows
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    36
# include "thread_windows.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    37
#endif
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents: 8921
diff changeset
    38
#ifdef TARGET_OS_FAMILY_bsd
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents: 8921
diff changeset
    39
# include "thread_bsd.inline.hpp"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents: 8921
diff changeset
    40
#endif
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    41
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
// a simple flat profiler for Java
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
// Forward declaration of classes defined in this header file
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
class ThreadProfiler;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
class ThreadProfilerMark;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
class FlatProfiler;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
class IntervalData;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
// Declarations of classes defined only in the implementation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
class ProfilerNode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
class FlatProfilerTask;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
enum TickPosition {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  tp_code,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  tp_native
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
// One of these guys is constructed as we enter interesting regions
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
// and destructed as we exit the region.  While we are in the region
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
// ticks are allotted to the region.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
class ThreadProfilerMark: public StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  // For now, the only thread-specific region is the class loader.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  enum Region { noRegion, classLoaderRegion, extraRegion, maxRegion };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  ThreadProfilerMark(Region)  KERNEL_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  ~ThreadProfilerMark()       KERNEL_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  ThreadProfiler* _pp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  Region _r;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
#ifndef FPROF_KERNEL
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
class IntervalData VALUE_OBJ_CLASS_SPEC {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  // Just to keep these things all together
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  int _interpreted;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  int _compiled;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  int _native;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  int _compiling;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  int interpreted() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
    return _interpreted;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  int compiled() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
    return _compiled;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  int native() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
    return _native;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  int compiling() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
    return _compiling;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  int total() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
    return (interpreted() + compiled() + native() + compiling());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  void inc_interpreted() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
    _interpreted += 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  void inc_compiled() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
    _compiled += 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  void inc_native() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
    _native += 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  void inc_compiling() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
    _compiling += 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  void reset() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
    _interpreted = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
    _compiled = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
    _native = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
    _compiling = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  static void print_header(outputStream* st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  void print_data(outputStream* st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
#endif // FPROF_KERNEL
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
class ThreadProfiler: public CHeapObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  ThreadProfiler()    KERNEL_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  ~ThreadProfiler()   KERNEL_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  // Resets the profiler
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  void reset()        KERNEL_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  // Activates the profiler for a certain thread
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  void engage()       KERNEL_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  // Deactivates the profiler
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  void disengage()    KERNEL_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  // Prints the collected profiling information
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  void print(const char* thread_name) KERNEL_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  // Garbage Collection Support
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  void oops_do(OopClosure* f)         KERNEL_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
#ifndef FPROF_KERNEL
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  // for recording ticks.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  friend class ProfilerNode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  char* area_bottom; // preallocated area for pnodes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  char* area_top;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  char* area_limit;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  static int            table_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  ProfilerNode** table;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
private:
354
3b42d6fdcb82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 1
diff changeset
   155
  void record_interpreted_tick(JavaThread* thread, frame fr, TickPosition where, int* ticks);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  void record_compiled_tick   (JavaThread* thread, frame fr, TickPosition where);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  void interpreted_update(methodOop method, TickPosition where);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  void compiled_update   (methodOop method, TickPosition where);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  void stub_update       (methodOop method, const char* name, TickPosition where);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  void adapter_update    (TickPosition where);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  void runtime_stub_update(const CodeBlob* stub, const char* name, TickPosition where);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  void unknown_compiled_update    (const CodeBlob* cb, TickPosition where);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  void vm_update    (TickPosition where);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  void vm_update    (const char* name, TickPosition where);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  void record_tick_for_running_frame(JavaThread* thread, frame fr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  void record_tick_for_calling_frame(JavaThread* thread, frame fr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  void initialize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  static int  entry(int value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  friend class FlatProfiler;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  void record_tick(JavaThread* thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  bool engaged;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  // so we can do percentages for this thread, and quick checks for activity
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  int thread_ticks;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  int compiler_ticks;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  int interpreter_ticks;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  void inc_thread_ticks() { thread_ticks += 1; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  friend class ThreadProfilerMark;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  // counters for thread-specific regions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  bool region_flag[ThreadProfilerMark::maxRegion];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  int class_loader_ticks;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  int extra_ticks;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  // other thread-specific regions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  int blocked_ticks;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  enum UnknownTickSites {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
      ut_null_method,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
      ut_vtable_stubs,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
      ut_running_frame,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
      ut_calling_frame,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
      ut_no_pc,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
      ut_no_last_Java_frame,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
      ut_unknown_thread_state,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
      ut_end
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  int unknown_ticks_array[ut_end];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  int unknown_ticks() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
    int result = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
    for (int ut = 0; ut < ut_end; ut += 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
      result += unknown_ticks_array[ut];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  elapsedTimer timer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  // For interval timing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  IntervalData _interval_data;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  IntervalData interval_data() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
    return _interval_data;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
  IntervalData* interval_data_ref() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
    return &_interval_data;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
#endif // FPROF_KERNEL
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
class FlatProfiler: AllStatic {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  static void reset() KERNEL_RETURN ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  static void engage(JavaThread* mainThread, bool fullProfile) KERNEL_RETURN ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
  static void disengage() KERNEL_RETURN ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
  static void print(int unused) KERNEL_RETURN ;
8110
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7397
diff changeset
   237
  static bool is_active() KERNEL_RETURN_(false) ;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
  // This is NULL if each thread has its own thread profiler,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  // else this is the single thread profiler used by all threads.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  // In particular it makes a difference during garbage collection,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  // where you only want to traverse each thread profiler once.
8110
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7397
diff changeset
   243
  static ThreadProfiler* get_thread_profiler() KERNEL_RETURN_(NULL);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  // Garbage Collection Support
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
  static void oops_do(OopClosure* f) KERNEL_RETURN ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
  // Support for disassembler to inspect the PCRecorder
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
  // Returns the start address for a given pc
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
  // NULL is returned if the PCRecorder is inactive
8110
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7397
diff changeset
   252
  static address bucket_start_for(address pc) KERNEL_RETURN_(NULL);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  enum { MillisecsPerTick = 10 };   // ms per profiling ticks
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  // Returns the number of ticks recorded for the bucket
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  // pc belongs to.
8110
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7397
diff changeset
   258
  static int bucket_count_for(address pc) KERNEL_RETURN_(0);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
#ifndef FPROF_KERNEL
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  static bool full_profile() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
    return full_profile_flag;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
  friend class ThreadProfiler;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
  // the following group of ticks cover everything that's not attributed to individual Java methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
  static int  received_gc_ticks;      // ticks during which gc was active
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
  static int vm_operation_ticks;      // total ticks in vm_operations other than GC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
  static int threads_lock_ticks;      // the number of times we couldn't get the Threads_lock without blocking
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
  static int      blocked_ticks;      // ticks when the thread was blocked.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
  static int class_loader_ticks;      // total ticks in class loader
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
  static int        extra_ticks;      // total ticks an extra temporary measuring
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  static int     compiler_ticks;      // total ticks in compilation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
  static int  interpreter_ticks;      // ticks in unknown interpreted method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
  static int        deopt_ticks;      // ticks in deoptimization
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
  static int      unknown_ticks;      // ticks that cannot be categorized
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
  static int     received_ticks;      // ticks that were received by task
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
  static int    delivered_ticks;      // ticks that were delivered by task
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
  static int non_method_ticks() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
    return
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
      ( received_gc_ticks
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
      + vm_operation_ticks
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
      + deopt_ticks
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
      + threads_lock_ticks
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
      + blocked_ticks
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
      + compiler_ticks
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
      + interpreter_ticks
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
      + unknown_ticks );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
  static elapsedTimer timer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  // Counts of each of the byte codes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
  static int*           bytecode_ticks;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  static int*           bytecode_ticks_stub;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
  static void print_byte_code_statistics();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
  // the ticks below are for continuous profiling (to adjust recompilation, etc.)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
  static int          all_ticks;      // total count of ticks received so far
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
  static int      all_int_ticks;      // ticks in interpreter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
  static int     all_comp_ticks;      // ticks in compiled code (+ native)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
  static bool full_profile_flag;      // collecting full profile?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
  // to accumulate thread-specific data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
  // if we aren't profiling individual threads.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
  static ThreadProfiler* thread_profiler;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
  static ThreadProfiler* vm_thread_profiler;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
  static void allocate_table();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
  // The task that periodically interrupts things.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
  friend class FlatProfilerTask;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
  static FlatProfilerTask* task;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
  static void record_vm_operation();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
  static void record_vm_tick();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
  static void record_thread_ticks();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
  // For interval analysis
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
  static int interval_ticks_previous;  // delivered_ticks from the last interval
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
  static void interval_record_thread(ThreadProfiler* tp); // extract ticks from ThreadProfiler.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
  static void interval_print();       // print interval data.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
  static void interval_reset();       // reset interval data.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
  enum {interval_print_size = 10};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
  static IntervalData* interval_data;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
#endif // FPROF_KERNEL
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   329
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   330
#endif // SHARE_VM_RUNTIME_FPROFILER_HPP