Mercurial > hg > truffle
annotate src/share/vm/runtime/fprofiler.hpp @ 7666:31540ca73e81
Remove ControlFlowException in SimpleLanguage.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Fri, 01 Feb 2013 19:53:52 +0100 |
parents | f34d701e952e |
children | db9981fd3124 |
rev | line source |
---|---|
0 | 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 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
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 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef SHARE_VM_RUNTIME_FPROFILER_HPP |
26 #define SHARE_VM_RUNTIME_FPROFILER_HPP | |
27 | |
28 #include "runtime/timer.hpp" | |
29 | |
0 | 30 // a simple flat profiler for Java |
31 | |
32 | |
33 // Forward declaration of classes defined in this header file | |
34 class ThreadProfiler; | |
35 class ThreadProfilerMark; | |
36 class FlatProfiler; | |
37 class IntervalData; | |
38 | |
39 // Declarations of classes defined only in the implementation. | |
40 class ProfilerNode; | |
41 class FlatProfilerTask; | |
42 | |
43 enum TickPosition { | |
44 tp_code, | |
45 tp_native | |
46 }; | |
47 | |
48 // One of these guys is constructed as we enter interesting regions | |
49 // and destructed as we exit the region. While we are in the region | |
50 // ticks are allotted to the region. | |
51 class ThreadProfilerMark: public StackObj { | |
52 public: | |
53 // For now, the only thread-specific region is the class loader. | |
54 enum Region { noRegion, classLoaderRegion, extraRegion, maxRegion }; | |
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 | 58 |
59 private: | |
60 ThreadProfiler* _pp; | |
61 Region _r; | |
62 }; | |
63 | |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
64 #if INCLUDE_FPROF |
0 | 65 |
66 class IntervalData VALUE_OBJ_CLASS_SPEC { | |
67 // Just to keep these things all together | |
68 private: | |
69 int _interpreted; | |
70 int _compiled; | |
71 int _native; | |
72 int _compiling; | |
73 public: | |
74 int interpreted() { | |
75 return _interpreted; | |
76 } | |
77 int compiled() { | |
78 return _compiled; | |
79 } | |
80 int native() { | |
81 return _native; | |
82 } | |
83 int compiling() { | |
84 return _compiling; | |
85 } | |
86 int total() { | |
87 return (interpreted() + compiled() + native() + compiling()); | |
88 } | |
89 void inc_interpreted() { | |
90 _interpreted += 1; | |
91 } | |
92 void inc_compiled() { | |
93 _compiled += 1; | |
94 } | |
95 void inc_native() { | |
96 _native += 1; | |
97 } | |
98 void inc_compiling() { | |
99 _compiling += 1; | |
100 } | |
101 void reset() { | |
102 _interpreted = 0; | |
103 _compiled = 0; | |
104 _native = 0; | |
105 _compiling = 0; | |
106 } | |
107 static void print_header(outputStream* st); | |
108 void print_data(outputStream* st); | |
109 }; | |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
110 #endif // INCLUDE_FPROF |
0 | 111 |
6197 | 112 class ThreadProfiler: public CHeapObj<mtInternal> { |
0 | 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 | 116 |
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 | 119 |
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 | 122 |
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 | 125 |
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 | 128 |
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 | 131 |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
132 #if INCLUDE_FPROF |
0 | 133 private: |
134 // for recording ticks. | |
135 friend class ProfilerNode; | |
136 char* area_bottom; // preallocated area for pnodes | |
137 char* area_top; | |
138 char* area_limit; | |
139 static int table_size; | |
140 ProfilerNode** table; | |
141 | |
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 | 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 | 148 void adapter_update (TickPosition where); |
149 | |
150 void runtime_stub_update(const CodeBlob* stub, const char* name, TickPosition where); | |
151 void unknown_compiled_update (const CodeBlob* cb, TickPosition where); | |
152 | |
153 void vm_update (TickPosition where); | |
154 void vm_update (const char* name, TickPosition where); | |
155 | |
156 void record_tick_for_running_frame(JavaThread* thread, frame fr); | |
157 void record_tick_for_calling_frame(JavaThread* thread, frame fr); | |
158 | |
159 void initialize(); | |
160 | |
161 static int entry(int value); | |
162 | |
163 | |
164 private: | |
165 friend class FlatProfiler; | |
166 void record_tick(JavaThread* thread); | |
167 bool engaged; | |
168 // so we can do percentages for this thread, and quick checks for activity | |
169 int thread_ticks; | |
170 int compiler_ticks; | |
171 int interpreter_ticks; | |
172 | |
173 public: | |
174 void inc_thread_ticks() { thread_ticks += 1; } | |
175 | |
176 private: | |
177 friend class ThreadProfilerMark; | |
178 // counters for thread-specific regions | |
179 bool region_flag[ThreadProfilerMark::maxRegion]; | |
180 int class_loader_ticks; | |
181 int extra_ticks; | |
182 | |
183 private: | |
184 // other thread-specific regions | |
185 int blocked_ticks; | |
186 enum UnknownTickSites { | |
187 ut_null_method, | |
188 ut_vtable_stubs, | |
189 ut_running_frame, | |
190 ut_calling_frame, | |
191 ut_no_pc, | |
192 ut_no_last_Java_frame, | |
193 ut_unknown_thread_state, | |
194 ut_end | |
195 }; | |
196 int unknown_ticks_array[ut_end]; | |
197 int unknown_ticks() { | |
198 int result = 0; | |
199 for (int ut = 0; ut < ut_end; ut += 1) { | |
200 result += unknown_ticks_array[ut]; | |
201 } | |
202 return result; | |
203 } | |
204 | |
205 elapsedTimer timer; | |
206 | |
207 // For interval timing | |
208 private: | |
209 IntervalData _interval_data; | |
210 IntervalData interval_data() { | |
211 return _interval_data; | |
212 } | |
213 IntervalData* interval_data_ref() { | |
214 return &_interval_data; | |
215 } | |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
216 #endif // INCLUDE_FPROF |
0 | 217 }; |
218 | |
219 class FlatProfiler: AllStatic { | |
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 | 226 |
227 // This is NULL if each thread has its own thread profiler, | |
228 // else this is the single thread profiler used by all threads. | |
229 // In particular it makes a difference during garbage collection, | |
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 | 232 |
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 | 235 |
236 // Support for disassembler to inspect the PCRecorder | |
237 | |
238 // Returns the start address for a given pc | |
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 | 241 |
242 enum { MillisecsPerTick = 10 }; // ms per profiling ticks | |
243 | |
244 // Returns the number of ticks recorded for the bucket | |
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 | 247 |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
248 #if INCLUDE_FPROF |
0 | 249 |
250 private: | |
251 static bool full_profile() { | |
252 return full_profile_flag; | |
253 } | |
254 | |
255 friend class ThreadProfiler; | |
256 // the following group of ticks cover everything that's not attributed to individual Java methods | |
257 static int received_gc_ticks; // ticks during which gc was active | |
258 static int vm_operation_ticks; // total ticks in vm_operations other than GC | |
259 static int threads_lock_ticks; // the number of times we couldn't get the Threads_lock without blocking | |
260 static int blocked_ticks; // ticks when the thread was blocked. | |
261 static int class_loader_ticks; // total ticks in class loader | |
262 static int extra_ticks; // total ticks an extra temporary measuring | |
263 static int compiler_ticks; // total ticks in compilation | |
264 static int interpreter_ticks; // ticks in unknown interpreted method | |
265 static int deopt_ticks; // ticks in deoptimization | |
266 static int unknown_ticks; // ticks that cannot be categorized | |
267 static int received_ticks; // ticks that were received by task | |
268 static int delivered_ticks; // ticks that were delivered by task | |
269 static int non_method_ticks() { | |
270 return | |
271 ( received_gc_ticks | |
272 + vm_operation_ticks | |
273 + deopt_ticks | |
274 + threads_lock_ticks | |
275 + blocked_ticks | |
276 + compiler_ticks | |
277 + interpreter_ticks | |
278 + unknown_ticks ); | |
279 } | |
280 static elapsedTimer timer; | |
281 | |
282 // Counts of each of the byte codes | |
283 static int* bytecode_ticks; | |
284 static int* bytecode_ticks_stub; | |
285 static void print_byte_code_statistics(); | |
286 | |
287 // the ticks below are for continuous profiling (to adjust recompilation, etc.) | |
288 static int all_ticks; // total count of ticks received so far | |
289 static int all_int_ticks; // ticks in interpreter | |
290 static int all_comp_ticks; // ticks in compiled code (+ native) | |
291 static bool full_profile_flag; // collecting full profile? | |
292 | |
293 // to accumulate thread-specific data | |
294 // if we aren't profiling individual threads. | |
295 static ThreadProfiler* thread_profiler; | |
296 static ThreadProfiler* vm_thread_profiler; | |
297 | |
298 static void allocate_table(); | |
299 | |
300 // The task that periodically interrupts things. | |
301 friend class FlatProfilerTask; | |
302 static FlatProfilerTask* task; | |
303 static void record_vm_operation(); | |
304 static void record_vm_tick(); | |
305 static void record_thread_ticks(); | |
306 | |
307 // For interval analysis | |
308 private: | |
309 static int interval_ticks_previous; // delivered_ticks from the last interval | |
310 static void interval_record_thread(ThreadProfiler* tp); // extract ticks from ThreadProfiler. | |
311 static void interval_print(); // print interval data. | |
312 static void interval_reset(); // reset interval data. | |
313 enum {interval_print_size = 10}; | |
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 | 316 }; |
1972 | 317 |
318 #endif // SHARE_VM_RUNTIME_FPROFILER_HPP |