annotate src/share/vm/runtime/fprofiler.hpp @ 7212:291ffc492eb6

Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/
author Doug Simon <doug.simon@oracle.com>
date Fri, 14 Dec 2012 14:35:13 +0100
parents f34d701e952e
children db9981fd3124
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 196
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 196
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 196
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #ifndef SHARE_VM_RUNTIME_FPROFILER_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_RUNTIME_FPROFILER_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "runtime/timer.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29
0
a61af66fc99e Initial load
duke
parents:
diff changeset
30 // a simple flat profiler for Java
a61af66fc99e Initial load
duke
parents:
diff changeset
31
a61af66fc99e Initial load
duke
parents:
diff changeset
32
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // Forward declaration of classes defined in this header file
a61af66fc99e Initial load
duke
parents:
diff changeset
34 class ThreadProfiler;
a61af66fc99e Initial load
duke
parents:
diff changeset
35 class ThreadProfilerMark;
a61af66fc99e Initial load
duke
parents:
diff changeset
36 class FlatProfiler;
a61af66fc99e Initial load
duke
parents:
diff changeset
37 class IntervalData;
a61af66fc99e Initial load
duke
parents:
diff changeset
38
a61af66fc99e Initial load
duke
parents:
diff changeset
39 // Declarations of classes defined only in the implementation.
a61af66fc99e Initial load
duke
parents:
diff changeset
40 class ProfilerNode;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 class FlatProfilerTask;
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 enum TickPosition {
a61af66fc99e Initial load
duke
parents:
diff changeset
44 tp_code,
a61af66fc99e Initial load
duke
parents:
diff changeset
45 tp_native
a61af66fc99e Initial load
duke
parents:
diff changeset
46 };
a61af66fc99e Initial load
duke
parents:
diff changeset
47
a61af66fc99e Initial load
duke
parents:
diff changeset
48 // One of these guys is constructed as we enter interesting regions
a61af66fc99e Initial load
duke
parents:
diff changeset
49 // and destructed as we exit the region. While we are in the region
a61af66fc99e Initial load
duke
parents:
diff changeset
50 // ticks are allotted to the region.
a61af66fc99e Initial load
duke
parents:
diff changeset
51 class ThreadProfilerMark: public StackObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
52 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // For now, the only thread-specific region is the class loader.
a61af66fc99e Initial load
duke
parents:
diff changeset
54 enum Region { noRegion, classLoaderRegion, extraRegion, maxRegion };
a61af66fc99e Initial load
duke
parents:
diff changeset
55
6854
fb19af007ffc 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 6725
diff changeset
56 ThreadProfilerMark(Region) NOT_FPROF_RETURN;
fb19af007ffc 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 6725
diff changeset
57 ~ThreadProfilerMark() NOT_FPROF_RETURN;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
58
a61af66fc99e Initial load
duke
parents:
diff changeset
59 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
60 ThreadProfiler* _pp;
a61af66fc99e Initial load
duke
parents:
diff changeset
61 Region _r;
a61af66fc99e Initial load
duke
parents:
diff changeset
62 };
a61af66fc99e Initial load
duke
parents:
diff changeset
63
6854
fb19af007ffc 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 6725
diff changeset
64 #if INCLUDE_FPROF
0
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 class IntervalData VALUE_OBJ_CLASS_SPEC {
a61af66fc99e Initial load
duke
parents:
diff changeset
67 // Just to keep these things all together
a61af66fc99e Initial load
duke
parents:
diff changeset
68 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
69 int _interpreted;
a61af66fc99e Initial load
duke
parents:
diff changeset
70 int _compiled;
a61af66fc99e Initial load
duke
parents:
diff changeset
71 int _native;
a61af66fc99e Initial load
duke
parents:
diff changeset
72 int _compiling;
a61af66fc99e Initial load
duke
parents:
diff changeset
73 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
74 int interpreted() {
a61af66fc99e Initial load
duke
parents:
diff changeset
75 return _interpreted;
a61af66fc99e Initial load
duke
parents:
diff changeset
76 }
a61af66fc99e Initial load
duke
parents:
diff changeset
77 int compiled() {
a61af66fc99e Initial load
duke
parents:
diff changeset
78 return _compiled;
a61af66fc99e Initial load
duke
parents:
diff changeset
79 }
a61af66fc99e Initial load
duke
parents:
diff changeset
80 int native() {
a61af66fc99e Initial load
duke
parents:
diff changeset
81 return _native;
a61af66fc99e Initial load
duke
parents:
diff changeset
82 }
a61af66fc99e Initial load
duke
parents:
diff changeset
83 int compiling() {
a61af66fc99e Initial load
duke
parents:
diff changeset
84 return _compiling;
a61af66fc99e Initial load
duke
parents:
diff changeset
85 }
a61af66fc99e Initial load
duke
parents:
diff changeset
86 int total() {
a61af66fc99e Initial load
duke
parents:
diff changeset
87 return (interpreted() + compiled() + native() + compiling());
a61af66fc99e Initial load
duke
parents:
diff changeset
88 }
a61af66fc99e Initial load
duke
parents:
diff changeset
89 void inc_interpreted() {
a61af66fc99e Initial load
duke
parents:
diff changeset
90 _interpreted += 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
91 }
a61af66fc99e Initial load
duke
parents:
diff changeset
92 void inc_compiled() {
a61af66fc99e Initial load
duke
parents:
diff changeset
93 _compiled += 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
94 }
a61af66fc99e Initial load
duke
parents:
diff changeset
95 void inc_native() {
a61af66fc99e Initial load
duke
parents:
diff changeset
96 _native += 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
97 }
a61af66fc99e Initial load
duke
parents:
diff changeset
98 void inc_compiling() {
a61af66fc99e Initial load
duke
parents:
diff changeset
99 _compiling += 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
100 }
a61af66fc99e Initial load
duke
parents:
diff changeset
101 void reset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
102 _interpreted = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
103 _compiled = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
104 _native = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
105 _compiling = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
106 }
a61af66fc99e Initial load
duke
parents:
diff changeset
107 static void print_header(outputStream* st);
a61af66fc99e Initial load
duke
parents:
diff changeset
108 void print_data(outputStream* st);
a61af66fc99e Initial load
duke
parents:
diff changeset
109 };
6854
fb19af007ffc 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 6725
diff changeset
110 #endif // INCLUDE_FPROF
0
a61af66fc99e Initial load
duke
parents:
diff changeset
111
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 3960
diff changeset
112 class ThreadProfiler: public CHeapObj<mtInternal> {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
113 public:
6854
fb19af007ffc 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 6725
diff changeset
114 ThreadProfiler() NOT_FPROF_RETURN;
fb19af007ffc 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 6725
diff changeset
115 ~ThreadProfiler() NOT_FPROF_RETURN;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
116
a61af66fc99e Initial load
duke
parents:
diff changeset
117 // Resets the profiler
6854
fb19af007ffc 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 6725
diff changeset
118 void reset() NOT_FPROF_RETURN;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
119
a61af66fc99e Initial load
duke
parents:
diff changeset
120 // Activates the profiler for a certain thread
6854
fb19af007ffc 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 6725
diff changeset
121 void engage() NOT_FPROF_RETURN;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 // Deactivates the profiler
6854
fb19af007ffc 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 6725
diff changeset
124 void disengage() NOT_FPROF_RETURN;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 // Prints the collected profiling information
6854
fb19af007ffc 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 6725
diff changeset
127 void print(const char* thread_name) NOT_FPROF_RETURN;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
128
a61af66fc99e Initial load
duke
parents:
diff changeset
129 // Garbage Collection Support
6854
fb19af007ffc 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 6725
diff changeset
130 void oops_do(OopClosure* f) NOT_FPROF_RETURN;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
131
6854
fb19af007ffc 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 6725
diff changeset
132 #if INCLUDE_FPROF
0
a61af66fc99e Initial load
duke
parents:
diff changeset
133 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
134 // for recording ticks.
a61af66fc99e Initial load
duke
parents:
diff changeset
135 friend class ProfilerNode;
a61af66fc99e Initial load
duke
parents:
diff changeset
136 char* area_bottom; // preallocated area for pnodes
a61af66fc99e Initial load
duke
parents:
diff changeset
137 char* area_top;
a61af66fc99e Initial load
duke
parents:
diff changeset
138 char* area_limit;
a61af66fc99e Initial load
duke
parents:
diff changeset
139 static int table_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
140 ProfilerNode** table;
a61af66fc99e Initial load
duke
parents:
diff changeset
141
a61af66fc99e Initial load
duke
parents:
diff changeset
142 private:
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
143 void record_interpreted_tick(JavaThread* thread, frame fr, TickPosition where, int* ticks);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
144 void record_compiled_tick (JavaThread* thread, frame fr, TickPosition where);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
145 void interpreted_update(Method* method, TickPosition where);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
146 void compiled_update (Method* method, TickPosition where);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
147 void stub_update (Method* method, const char* name, TickPosition where);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
148 void adapter_update (TickPosition where);
a61af66fc99e Initial load
duke
parents:
diff changeset
149
a61af66fc99e Initial load
duke
parents:
diff changeset
150 void runtime_stub_update(const CodeBlob* stub, const char* name, TickPosition where);
a61af66fc99e Initial load
duke
parents:
diff changeset
151 void unknown_compiled_update (const CodeBlob* cb, TickPosition where);
a61af66fc99e Initial load
duke
parents:
diff changeset
152
a61af66fc99e Initial load
duke
parents:
diff changeset
153 void vm_update (TickPosition where);
a61af66fc99e Initial load
duke
parents:
diff changeset
154 void vm_update (const char* name, TickPosition where);
a61af66fc99e Initial load
duke
parents:
diff changeset
155
a61af66fc99e Initial load
duke
parents:
diff changeset
156 void record_tick_for_running_frame(JavaThread* thread, frame fr);
a61af66fc99e Initial load
duke
parents:
diff changeset
157 void record_tick_for_calling_frame(JavaThread* thread, frame fr);
a61af66fc99e Initial load
duke
parents:
diff changeset
158
a61af66fc99e Initial load
duke
parents:
diff changeset
159 void initialize();
a61af66fc99e Initial load
duke
parents:
diff changeset
160
a61af66fc99e Initial load
duke
parents:
diff changeset
161 static int entry(int value);
a61af66fc99e Initial load
duke
parents:
diff changeset
162
a61af66fc99e Initial load
duke
parents:
diff changeset
163
a61af66fc99e Initial load
duke
parents:
diff changeset
164 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
165 friend class FlatProfiler;
a61af66fc99e Initial load
duke
parents:
diff changeset
166 void record_tick(JavaThread* thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
167 bool engaged;
a61af66fc99e Initial load
duke
parents:
diff changeset
168 // so we can do percentages for this thread, and quick checks for activity
a61af66fc99e Initial load
duke
parents:
diff changeset
169 int thread_ticks;
a61af66fc99e Initial load
duke
parents:
diff changeset
170 int compiler_ticks;
a61af66fc99e Initial load
duke
parents:
diff changeset
171 int interpreter_ticks;
a61af66fc99e Initial load
duke
parents:
diff changeset
172
a61af66fc99e Initial load
duke
parents:
diff changeset
173 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
174 void inc_thread_ticks() { thread_ticks += 1; }
a61af66fc99e Initial load
duke
parents:
diff changeset
175
a61af66fc99e Initial load
duke
parents:
diff changeset
176 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
177 friend class ThreadProfilerMark;
a61af66fc99e Initial load
duke
parents:
diff changeset
178 // counters for thread-specific regions
a61af66fc99e Initial load
duke
parents:
diff changeset
179 bool region_flag[ThreadProfilerMark::maxRegion];
a61af66fc99e Initial load
duke
parents:
diff changeset
180 int class_loader_ticks;
a61af66fc99e Initial load
duke
parents:
diff changeset
181 int extra_ticks;
a61af66fc99e Initial load
duke
parents:
diff changeset
182
a61af66fc99e Initial load
duke
parents:
diff changeset
183 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
184 // other thread-specific regions
a61af66fc99e Initial load
duke
parents:
diff changeset
185 int blocked_ticks;
a61af66fc99e Initial load
duke
parents:
diff changeset
186 enum UnknownTickSites {
a61af66fc99e Initial load
duke
parents:
diff changeset
187 ut_null_method,
a61af66fc99e Initial load
duke
parents:
diff changeset
188 ut_vtable_stubs,
a61af66fc99e Initial load
duke
parents:
diff changeset
189 ut_running_frame,
a61af66fc99e Initial load
duke
parents:
diff changeset
190 ut_calling_frame,
a61af66fc99e Initial load
duke
parents:
diff changeset
191 ut_no_pc,
a61af66fc99e Initial load
duke
parents:
diff changeset
192 ut_no_last_Java_frame,
a61af66fc99e Initial load
duke
parents:
diff changeset
193 ut_unknown_thread_state,
a61af66fc99e Initial load
duke
parents:
diff changeset
194 ut_end
a61af66fc99e Initial load
duke
parents:
diff changeset
195 };
a61af66fc99e Initial load
duke
parents:
diff changeset
196 int unknown_ticks_array[ut_end];
a61af66fc99e Initial load
duke
parents:
diff changeset
197 int unknown_ticks() {
a61af66fc99e Initial load
duke
parents:
diff changeset
198 int result = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
199 for (int ut = 0; ut < ut_end; ut += 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
200 result += unknown_ticks_array[ut];
a61af66fc99e Initial load
duke
parents:
diff changeset
201 }
a61af66fc99e Initial load
duke
parents:
diff changeset
202 return result;
a61af66fc99e Initial load
duke
parents:
diff changeset
203 }
a61af66fc99e Initial load
duke
parents:
diff changeset
204
a61af66fc99e Initial load
duke
parents:
diff changeset
205 elapsedTimer timer;
a61af66fc99e Initial load
duke
parents:
diff changeset
206
a61af66fc99e Initial load
duke
parents:
diff changeset
207 // For interval timing
a61af66fc99e Initial load
duke
parents:
diff changeset
208 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
209 IntervalData _interval_data;
a61af66fc99e Initial load
duke
parents:
diff changeset
210 IntervalData interval_data() {
a61af66fc99e Initial load
duke
parents:
diff changeset
211 return _interval_data;
a61af66fc99e Initial load
duke
parents:
diff changeset
212 }
a61af66fc99e Initial load
duke
parents:
diff changeset
213 IntervalData* interval_data_ref() {
a61af66fc99e Initial load
duke
parents:
diff changeset
214 return &_interval_data;
a61af66fc99e Initial load
duke
parents:
diff changeset
215 }
6854
fb19af007ffc 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 6725
diff changeset
216 #endif // INCLUDE_FPROF
0
a61af66fc99e Initial load
duke
parents:
diff changeset
217 };
a61af66fc99e Initial load
duke
parents:
diff changeset
218
a61af66fc99e Initial load
duke
parents:
diff changeset
219 class FlatProfiler: AllStatic {
a61af66fc99e Initial load
duke
parents:
diff changeset
220 public:
6854
fb19af007ffc 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 6725
diff changeset
221 static void reset() NOT_FPROF_RETURN ;
fb19af007ffc 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 6725
diff changeset
222 static void engage(JavaThread* mainThread, bool fullProfile) NOT_FPROF_RETURN ;
fb19af007ffc 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 6725
diff changeset
223 static void disengage() NOT_FPROF_RETURN ;
fb19af007ffc 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 6725
diff changeset
224 static void print(int unused) NOT_FPROF_RETURN ;
fb19af007ffc 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 6725
diff changeset
225 static bool is_active() NOT_FPROF_RETURN_(false) ;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
226
a61af66fc99e Initial load
duke
parents:
diff changeset
227 // This is NULL if each thread has its own thread profiler,
a61af66fc99e Initial load
duke
parents:
diff changeset
228 // else this is the single thread profiler used by all threads.
a61af66fc99e Initial load
duke
parents:
diff changeset
229 // In particular it makes a difference during garbage collection,
a61af66fc99e Initial load
duke
parents:
diff changeset
230 // where you only want to traverse each thread profiler once.
6854
fb19af007ffc 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 6725
diff changeset
231 static ThreadProfiler* get_thread_profiler() NOT_FPROF_RETURN_(NULL);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
232
a61af66fc99e Initial load
duke
parents:
diff changeset
233 // Garbage Collection Support
6854
fb19af007ffc 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 6725
diff changeset
234 static void oops_do(OopClosure* f) NOT_FPROF_RETURN ;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
235
a61af66fc99e Initial load
duke
parents:
diff changeset
236 // Support for disassembler to inspect the PCRecorder
a61af66fc99e Initial load
duke
parents:
diff changeset
237
a61af66fc99e Initial load
duke
parents:
diff changeset
238 // Returns the start address for a given pc
a61af66fc99e Initial load
duke
parents:
diff changeset
239 // NULL is returned if the PCRecorder is inactive
6854
fb19af007ffc 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 6725
diff changeset
240 static address bucket_start_for(address pc) NOT_FPROF_RETURN_(NULL);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
241
a61af66fc99e Initial load
duke
parents:
diff changeset
242 enum { MillisecsPerTick = 10 }; // ms per profiling ticks
a61af66fc99e Initial load
duke
parents:
diff changeset
243
a61af66fc99e Initial load
duke
parents:
diff changeset
244 // Returns the number of ticks recorded for the bucket
a61af66fc99e Initial load
duke
parents:
diff changeset
245 // pc belongs to.
6854
fb19af007ffc 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 6725
diff changeset
246 static int bucket_count_for(address pc) NOT_FPROF_RETURN_(0);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
247
6854
fb19af007ffc 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 6725
diff changeset
248 #if INCLUDE_FPROF
0
a61af66fc99e Initial load
duke
parents:
diff changeset
249
a61af66fc99e Initial load
duke
parents:
diff changeset
250 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
251 static bool full_profile() {
a61af66fc99e Initial load
duke
parents:
diff changeset
252 return full_profile_flag;
a61af66fc99e Initial load
duke
parents:
diff changeset
253 }
a61af66fc99e Initial load
duke
parents:
diff changeset
254
a61af66fc99e Initial load
duke
parents:
diff changeset
255 friend class ThreadProfiler;
a61af66fc99e Initial load
duke
parents:
diff changeset
256 // the following group of ticks cover everything that's not attributed to individual Java methods
a61af66fc99e Initial load
duke
parents:
diff changeset
257 static int received_gc_ticks; // ticks during which gc was active
a61af66fc99e Initial load
duke
parents:
diff changeset
258 static int vm_operation_ticks; // total ticks in vm_operations other than GC
a61af66fc99e Initial load
duke
parents:
diff changeset
259 static int threads_lock_ticks; // the number of times we couldn't get the Threads_lock without blocking
a61af66fc99e Initial load
duke
parents:
diff changeset
260 static int blocked_ticks; // ticks when the thread was blocked.
a61af66fc99e Initial load
duke
parents:
diff changeset
261 static int class_loader_ticks; // total ticks in class loader
a61af66fc99e Initial load
duke
parents:
diff changeset
262 static int extra_ticks; // total ticks an extra temporary measuring
a61af66fc99e Initial load
duke
parents:
diff changeset
263 static int compiler_ticks; // total ticks in compilation
a61af66fc99e Initial load
duke
parents:
diff changeset
264 static int interpreter_ticks; // ticks in unknown interpreted method
a61af66fc99e Initial load
duke
parents:
diff changeset
265 static int deopt_ticks; // ticks in deoptimization
a61af66fc99e Initial load
duke
parents:
diff changeset
266 static int unknown_ticks; // ticks that cannot be categorized
a61af66fc99e Initial load
duke
parents:
diff changeset
267 static int received_ticks; // ticks that were received by task
a61af66fc99e Initial load
duke
parents:
diff changeset
268 static int delivered_ticks; // ticks that were delivered by task
a61af66fc99e Initial load
duke
parents:
diff changeset
269 static int non_method_ticks() {
a61af66fc99e Initial load
duke
parents:
diff changeset
270 return
a61af66fc99e Initial load
duke
parents:
diff changeset
271 ( received_gc_ticks
a61af66fc99e Initial load
duke
parents:
diff changeset
272 + vm_operation_ticks
a61af66fc99e Initial load
duke
parents:
diff changeset
273 + deopt_ticks
a61af66fc99e Initial load
duke
parents:
diff changeset
274 + threads_lock_ticks
a61af66fc99e Initial load
duke
parents:
diff changeset
275 + blocked_ticks
a61af66fc99e Initial load
duke
parents:
diff changeset
276 + compiler_ticks
a61af66fc99e Initial load
duke
parents:
diff changeset
277 + interpreter_ticks
a61af66fc99e Initial load
duke
parents:
diff changeset
278 + unknown_ticks );
a61af66fc99e Initial load
duke
parents:
diff changeset
279 }
a61af66fc99e Initial load
duke
parents:
diff changeset
280 static elapsedTimer timer;
a61af66fc99e Initial load
duke
parents:
diff changeset
281
a61af66fc99e Initial load
duke
parents:
diff changeset
282 // Counts of each of the byte codes
a61af66fc99e Initial load
duke
parents:
diff changeset
283 static int* bytecode_ticks;
a61af66fc99e Initial load
duke
parents:
diff changeset
284 static int* bytecode_ticks_stub;
a61af66fc99e Initial load
duke
parents:
diff changeset
285 static void print_byte_code_statistics();
a61af66fc99e Initial load
duke
parents:
diff changeset
286
a61af66fc99e Initial load
duke
parents:
diff changeset
287 // the ticks below are for continuous profiling (to adjust recompilation, etc.)
a61af66fc99e Initial load
duke
parents:
diff changeset
288 static int all_ticks; // total count of ticks received so far
a61af66fc99e Initial load
duke
parents:
diff changeset
289 static int all_int_ticks; // ticks in interpreter
a61af66fc99e Initial load
duke
parents:
diff changeset
290 static int all_comp_ticks; // ticks in compiled code (+ native)
a61af66fc99e Initial load
duke
parents:
diff changeset
291 static bool full_profile_flag; // collecting full profile?
a61af66fc99e Initial load
duke
parents:
diff changeset
292
a61af66fc99e Initial load
duke
parents:
diff changeset
293 // to accumulate thread-specific data
a61af66fc99e Initial load
duke
parents:
diff changeset
294 // if we aren't profiling individual threads.
a61af66fc99e Initial load
duke
parents:
diff changeset
295 static ThreadProfiler* thread_profiler;
a61af66fc99e Initial load
duke
parents:
diff changeset
296 static ThreadProfiler* vm_thread_profiler;
a61af66fc99e Initial load
duke
parents:
diff changeset
297
a61af66fc99e Initial load
duke
parents:
diff changeset
298 static void allocate_table();
a61af66fc99e Initial load
duke
parents:
diff changeset
299
a61af66fc99e Initial load
duke
parents:
diff changeset
300 // The task that periodically interrupts things.
a61af66fc99e Initial load
duke
parents:
diff changeset
301 friend class FlatProfilerTask;
a61af66fc99e Initial load
duke
parents:
diff changeset
302 static FlatProfilerTask* task;
a61af66fc99e Initial load
duke
parents:
diff changeset
303 static void record_vm_operation();
a61af66fc99e Initial load
duke
parents:
diff changeset
304 static void record_vm_tick();
a61af66fc99e Initial load
duke
parents:
diff changeset
305 static void record_thread_ticks();
a61af66fc99e Initial load
duke
parents:
diff changeset
306
a61af66fc99e Initial load
duke
parents:
diff changeset
307 // For interval analysis
a61af66fc99e Initial load
duke
parents:
diff changeset
308 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
309 static int interval_ticks_previous; // delivered_ticks from the last interval
a61af66fc99e Initial load
duke
parents:
diff changeset
310 static void interval_record_thread(ThreadProfiler* tp); // extract ticks from ThreadProfiler.
a61af66fc99e Initial load
duke
parents:
diff changeset
311 static void interval_print(); // print interval data.
a61af66fc99e Initial load
duke
parents:
diff changeset
312 static void interval_reset(); // reset interval data.
a61af66fc99e Initial load
duke
parents:
diff changeset
313 enum {interval_print_size = 10};
a61af66fc99e Initial load
duke
parents:
diff changeset
314 static IntervalData* interval_data;
6854
fb19af007ffc 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 6725
diff changeset
315 #endif // INCLUDE_FPROF
0
a61af66fc99e Initial load
duke
parents:
diff changeset
316 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
317
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
318 #endif // SHARE_VM_RUNTIME_FPROFILER_HPP