1 | /* <copyright> |
2 | |
3 | Contact Information: |
4 | http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/ |
5 | |
6 | BSD LICENSE |
7 | |
8 | Copyright (c) 2005-2014 Intel Corporation. All rights reserved. |
9 | All rights reserved. |
10 | |
11 | Redistribution and use in source and binary forms, with or without |
12 | modification, are permitted provided that the following conditions |
13 | are met: |
14 | |
15 | * Redistributions of source code must retain the above copyright |
16 | notice, this list of conditions and the following disclaimer. |
17 | * Redistributions in binary form must reproduce the above copyright |
18 | notice, this list of conditions and the following disclaimer in |
19 | the documentation and/or other materials provided with the |
20 | distribution. |
21 | * Neither the name of Intel Corporation nor the names of its |
22 | contributors may be used to endorse or promote products derived |
23 | from this software without specific prior written permission. |
24 | |
25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
26 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
27 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
28 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
29 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
30 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
31 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
32 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
33 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
34 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
35 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
36 | </copyright> */ |
37 | |
38 | #ifndef __JITPROFILING_H__ |
39 | #define __JITPROFILING_H__ |
40 | |
41 | /** |
42 | * @brief JIT Profiling APIs |
43 | * |
44 | * The JIT Profiling API is used to report information about just-in-time |
45 | * generated code that can be used by performance tools. The user inserts |
46 | * calls in the code generator to report information before JIT-compiled |
47 | * code goes to execution. This information is collected at runtime and used |
48 | * by tools like Intel(R) VTune(TM) Amplifier to display performance metrics |
49 | * associated with JIT-compiled code. |
50 | * |
51 | * These APIs can be used to\n |
52 | * - **Profile trace-based and method-based JIT-compiled |
53 | * code**. Some examples of environments that you can profile with these APIs: |
54 | * dynamic JIT compilation of JavaScript code traces, JIT execution in OpenCL(TM) |
55 | * software technology, Java/.NET managed execution environments, and custom |
56 | * ISV JIT engines. |
57 | * @code |
58 | * #include <jitprofiling.h> |
59 | * |
60 | * if (iJIT_IsProfilingActive != iJIT_SAMPLING_ON) { |
61 | * return; |
62 | * } |
63 | * |
64 | * iJIT_Method_Load jmethod = {0}; |
65 | * jmethod.method_id = iJIT_GetNewMethodID(); |
66 | * jmethod.method_name = "method_name"; |
67 | * jmethod.class_file_name = "class_name"; |
68 | * jmethod.source_file_name = "source_file_name"; |
69 | * jmethod.method_load_address = code_addr; |
70 | * jmethod.method_size = code_size; |
71 | * |
72 | * iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED, (void*)&jmethod); |
73 | * iJIT_NotifyEvent(iJVM_EVENT_TYPE_SHUTDOWN, NULL); |
74 | * @endcode |
75 | * |
76 | * * Expected behavior: |
77 | * * If any iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED event overwrites an |
78 | * already reported method, then such a method becomes invalid and its |
79 | * memory region is treated as unloaded. VTune Amplifier displays the metrics |
80 | * collected by the method until it is overwritten. |
81 | * * If supplied line number information contains multiple source lines for |
82 | * the same assembly instruction (code location), then VTune Amplifier picks up |
83 | * the first line number. |
84 | * * Dynamically generated code can be associated with a module name. |
85 | * Use the iJIT_Method_Load_V2 structure.\n |
86 | * Clarification of some cases: |
87 | * * If you register a function with the same method ID multiple times, |
88 | * specifying different module names, then the VTune Amplifier picks up |
89 | * the module name registered first. If you want to distinguish the same |
90 | * function between different JIT engines, supply different method IDs for |
91 | * each function. Other symbolic information (for example, source file) |
92 | * can be identical. |
93 | * |
94 | * - **Analyze split functions** (multiple joint or disjoint code regions |
95 | * belonging to the same function) **including re-JIT** |
96 | * with potential overlapping of code regions in time, which is common in |
97 | * resource-limited environments. |
98 | * @code |
99 | * #include <jitprofiling.h> |
100 | * |
101 | * unsigned int method_id = iJIT_GetNewMethodID(); |
102 | * |
103 | * iJIT_Method_Load a = {0}; |
104 | * a.method_id = method_id; |
105 | * a.method_load_address = 0x100; |
106 | * a.method_size = 0x20; |
107 | * |
108 | * iJIT_Method_Load b = {0}; |
109 | * b.method_id = method_id; |
110 | * b.method_load_address = 0x200; |
111 | * b.method_size = 0x30; |
112 | * |
113 | * iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED, (void*)&a); |
114 | * iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED, (void*)&b); |
115 | * @endcode |
116 | * |
117 | * * Expected behaviour: |
118 | * * If a iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED event overwrites an |
119 | * already reported method, then such a method becomes invalid and |
120 | * its memory region is treated as unloaded. |
121 | * * All code regions reported with the same method ID are considered as |
122 | * belonging to the same method. Symbolic information (method name, |
123 | * source file name) will be taken from the first notification, and all |
124 | * subsequent notifications with the same method ID will be processed |
125 | * only for line number table information. So, the VTune Amplifier will map |
126 | * samples to a source line using the line number table from the current |
127 | * notification while taking the source file name from the very first one.\n |
128 | * Clarification of some cases:\n |
129 | * * If you register a second code region with a different source file |
130 | * name and the same method ID, then this information will be saved and |
131 | * will not be considered as an extension of the first code region, but |
132 | * VTune Amplifier will use the source file of the first code region and map |
133 | * performance metrics incorrectly. |
134 | * * If you register a second code region with the same source file as |
135 | * for the first region and the same method ID, then the source file will be |
136 | * discarded but VTune Amplifier will map metrics to the source file correctly. |
137 | * * If you register a second code region with a null source file and |
138 | * the same method ID, then provided line number info will be associated |
139 | * with the source file of the first code region. |
140 | * |
141 | * - **Explore inline functions** including multi-level hierarchy of |
142 | * nested inline methods which shows how performance metrics are distributed through them. |
143 | * @code |
144 | * #include <jitprofiling.h> |
145 | * |
146 | * // method_id parent_id |
147 | * // [-- c --] 3000 2000 |
148 | * // [---- d -----] 2001 1000 |
149 | * // [---- b ----] 2000 1000 |
150 | * // [------------ a ----------------] 1000 n/a |
151 | * |
152 | * iJIT_Method_Load a = {0}; |
153 | * a.method_id = 1000; |
154 | * |
155 | * iJIT_Method_Inline_Load b = {0}; |
156 | * b.method_id = 2000; |
157 | * b.parent_method_id = 1000; |
158 | * |
159 | * iJIT_Method_Inline_Load c = {0}; |
160 | * c.method_id = 3000; |
161 | * c.parent_method_id = 2000; |
162 | * |
163 | * iJIT_Method_Inline_Load d = {0}; |
164 | * d.method_id = 2001; |
165 | * d.parent_method_id = 1000; |
166 | * |
167 | * iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED, (void*)&a); |
168 | * iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_INLINE_LOAD_FINISHED, (void*)&b); |
169 | * iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_INLINE_LOAD_FINISHED, (void*)&c); |
170 | * iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_INLINE_LOAD_FINISHED, (void*)&d); |
171 | * @endcode |
172 | * |
173 | * * Requirements: |
174 | * * Each inline (iJIT_Method_Inline_Load) method should be associated |
175 | * with two method IDs: one for itself; one for its immediate parent. |
176 | * * Address regions of inline methods of the same parent method cannot |
177 | * overlap each other. |
178 | * * Execution of the parent method must not be started until it and all |
179 | * its inline methods are reported. |
180 | * * Expected behaviour: |
181 | * * In case of nested inline methods an order of |
182 | * iJVM_EVENT_TYPE_METHOD_INLINE_LOAD_FINISHED events is not important. |
183 | * * If any event overwrites either inline method or top parent method, |
184 | * then the parent, including inline methods, becomes invalid and its memory |
185 | * region is treated as unloaded. |
186 | * |
187 | * **Life time of allocated data**\n |
188 | * The client sends an event notification to the agent with event-specific |
189 | * data, which is a structure. The pointers in the structure refer to memory |
190 | * allocated by the client, which responsible for releasing it. The pointers are |
191 | * used by the iJIT_NotifyEvent method to copy client's data in a trace file, |
192 | * and they are not used after the iJIT_NotifyEvent method returns. |
193 | */ |
194 | |
195 | /** |
196 | * @defgroup jitapi JIT Profiling |
197 | * @ingroup internal |
198 | * @{ |
199 | */ |
200 | |
201 | /** |
202 | * @brief Enumerator for the types of notifications |
203 | */ |
204 | typedef enum iJIT_jvm_event |
205 | { |
206 | iJVM_EVENT_TYPE_SHUTDOWN = 2, /**<\brief Send this to shutdown the agent. |
207 | * Use NULL for event data. */ |
208 | |
209 | iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED = 13, /**<\brief Send when dynamic code is |
210 | * JIT compiled and loaded into |
211 | * memory by the JIT engine, but |
212 | * before the code is executed. |
213 | * Use iJIT_Method_Load as event |
214 | * data. */ |
215 | /** @cond exclude_from_documentation */ |
216 | iJVM_EVENT_TYPE_METHOD_UNLOAD_START, /**<\brief Send when compiled dynamic |
217 | * code is being unloaded from memory. |
218 | * Use iJIT_Method_Load as event data.*/ |
219 | /** @endcond */ |
220 | |
221 | iJVM_EVENT_TYPE_METHOD_UPDATE, /**<\brief Send to provide new content for |
222 | * a previously reported dynamic code. |
223 | * The previous content will be invalidated |
224 | * starting from the time of the notification. |
225 | * Use iJIT_Method_Load as event data but |
226 | * required fields are following: |
227 | * - method_id identify the code to update. |
228 | * - method_load_address specify start address |
229 | * within identified code range |
230 | * where update should be started. |
231 | * - method_size specify length of updated code |
232 | * range. */ |
233 | |
234 | |
235 | iJVM_EVENT_TYPE_METHOD_INLINE_LOAD_FINISHED, /**<\brief Send when an inline dynamic |
236 | * code is JIT compiled and loaded |
237 | * into memory by the JIT engine, |
238 | * but before the parent code region |
239 | * starts executing. |
240 | * Use iJIT_Method_Inline_Load as event data.*/ |
241 | |
242 | /** @cond exclude_from_documentation */ |
243 | iJVM_EVENT_TYPE_METHOD_UPDATE_V2, |
244 | /** @endcond */ |
245 | |
246 | iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED_V2 = 21, /**<\brief Send when a dynamic code is |
247 | * JIT compiled and loaded into |
248 | * memory by the JIT engine, but |
249 | * before the code is executed. |
250 | * Use iJIT_Method_Load_V2 as event data. */ |
251 | |
252 | iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED_V3 /**<\brief Send when a dynamic code is |
253 | * JIT compiled and loaded into |
254 | * memory by the JIT engine, but |
255 | * before the code is executed. |
256 | * Use iJIT_Method_Load_V3 as event data. */ |
257 | } iJIT_JVM_EVENT; |
258 | |
259 | /** |
260 | * @brief Enumerator for the agent's mode |
261 | */ |
262 | typedef enum _iJIT_IsProfilingActiveFlags |
263 | { |
264 | iJIT_NOTHING_RUNNING = 0x0000, /**<\brief The agent is not running; |
265 | * iJIT_NotifyEvent calls will |
266 | * not be processed. */ |
267 | iJIT_SAMPLING_ON = 0x0001, /**<\brief The agent is running and |
268 | * ready to process notifications. */ |
269 | } iJIT_IsProfilingActiveFlags; |
270 | |
271 | /** |
272 | * @brief Description of a single entry in the line number information of a code region. |
273 | * @details A table of line number entries gives information about how the reported code region |
274 | * is mapped to source file. |
275 | * Intel(R) VTune(TM) Amplifier uses line number information to attribute |
276 | * the samples (virtual address) to a line number. \n |
277 | * It is acceptable to report different code addresses for the same source line: |
278 | * @code |
279 | * Offset LineNumber |
280 | * 1 2 |
281 | * 12 4 |
282 | * 15 2 |
283 | * 18 1 |
284 | * 21 30 |
285 | * |
286 | * VTune Amplifier constructs the following table using the client data |
287 | * |
288 | * Code subrange Line number |
289 | * 0-1 2 |
290 | * 1-12 4 |
291 | * 12-15 2 |
292 | * 15-18 1 |
293 | * 18-21 30 |
294 | * @endcode |
295 | */ |
296 | typedef struct _LineNumberInfo |
297 | { |
298 | unsigned int Offset; /**<\brief Offset from the begining of the code region. */ |
299 | unsigned int LineNumber; /**<\brief Matching source line number offset (from beginning of source file). */ |
300 | |
301 | } *pLineNumberInfo, LineNumberInfo; |
302 | |
303 | /** |
304 | * @brief Enumerator for the code architecture. |
305 | */ |
306 | typedef enum _iJIT_CodeArchitecture |
307 | { |
308 | iJIT_CA_NATIVE = 0, /**<\brief Native to the process architecture that is calling it. */ |
309 | |
310 | iJIT_CA_32, /**<\brief 32-bit machine code. */ |
311 | |
312 | iJIT_CA_64 /**<\brief 64-bit machine code. */ |
313 | |
314 | } iJIT_CodeArchitecture; |
315 | |
316 | #pragma pack(push, 8) |
317 | |
318 | /** |
319 | * @brief Description of a JIT-compiled method |
320 | * @details When you use the iJIT_Method_Load structure to describe |
321 | * the JIT compiled method, use iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED |
322 | * as an event type to report it. |
323 | */ |
324 | typedef struct _iJIT_Method_Load |
325 | { |
326 | unsigned int method_id; /**<\brief Unique method ID. Cannot be 0. |
327 | * You must either use the API function |
328 | * iJIT_GetNewMethodID to get a valid and unique |
329 | * method ID, or else manage ID uniqueness |
330 | * and correct range by yourself.\n |
331 | * You must use the same method ID for all code |
332 | * regions of the same method, otherwise different |
333 | * method IDs specify different methods. */ |
334 | |
335 | char* method_name; /**<\brief The name of the method. It can be optionally |
336 | * prefixed with its class name and appended with |
337 | * its complete signature. Can't be NULL. */ |
338 | |
339 | void* method_load_address; /**<\brief The start virtual address of the method code |
340 | * region. If NULL, data provided with |
341 | * event are not accepted. */ |
342 | |
343 | unsigned int method_size; /**<\brief The code size of the method in memory. |
344 | * If 0, then data provided with the event are not |
345 | * accepted. */ |
346 | |
347 | unsigned int line_number_size; /**<\brief The number of entries in the line number |
348 | * table.0 if none. */ |
349 | |
350 | pLineNumberInfo line_number_table; /**<\brief Pointer to the line numbers info |
351 | * array. Can be NULL if |
352 | * line_number_size is 0. See |
353 | * LineNumberInfo Structure for a |
354 | * description of a single entry in |
355 | * the line number info array */ |
356 | |
357 | unsigned int class_id; /**<\brief This field is obsolete. */ |
358 | |
359 | char* class_file_name; /**<\brief Class name. Can be NULL.*/ |
360 | |
361 | char* source_file_name; /**<\brief Source file name. Can be NULL.*/ |
362 | |
363 | } *piJIT_Method_Load, iJIT_Method_Load; |
364 | |
365 | /** |
366 | * @brief Description of a JIT-compiled method |
367 | * @details When you use the iJIT_Method_Load_V2 structure to describe |
368 | * the JIT compiled method, use iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED_V2 |
369 | * as an event type to report it. |
370 | */ |
371 | typedef struct _iJIT_Method_Load_V2 |
372 | { |
373 | unsigned int method_id; /**<\brief Unique method ID. Cannot be 0. |
374 | * You must either use the API function |
375 | * iJIT_GetNewMethodID to get a valid and unique |
376 | * method ID, or else manage ID uniqueness |
377 | * and correct range by yourself.\n |
378 | * You must use the same method ID for all code |
379 | * regions of the same method, otherwise different |
380 | * method IDs specify different methods. */ |
381 | |
382 | char* method_name; /**<\brief The name of the method. It can be optionally |
383 | * prefixed with its class name and appended with |
384 | * its complete signature. Can't be NULL. */ |
385 | |
386 | void* method_load_address; /**<\brief The start virtual address of the method code |
387 | * region. If NULL, then data provided with the |
388 | * event are not accepted. */ |
389 | |
390 | unsigned int method_size; /**<\brief The code size of the method in memory. |
391 | * If 0, then data provided with the event are not |
392 | * accepted. */ |
393 | |
394 | unsigned int line_number_size; /**<\brief The number of entries in the line number |
395 | * table. 0 if none. */ |
396 | |
397 | pLineNumberInfo line_number_table; /**<\brief Pointer to the line numbers info |
398 | * array. Can be NULL if |
399 | * line_number_size is 0. See |
400 | * LineNumberInfo Structure for a |
401 | * description of a single entry in |
402 | * the line number info array. */ |
403 | |
404 | char* class_file_name; /**<\brief Class name. Can be NULL. */ |
405 | |
406 | char* source_file_name; /**<\brief Source file name. Can be NULL. */ |
407 | |
408 | char* module_name; /**<\brief Module name. Can be NULL. |
409 | The module name can be useful for distinguishing among |
410 | different JIT engines. VTune Amplifier will display |
411 | reported methods grouped by specific module. */ |
412 | |
413 | } *piJIT_Method_Load_V2, iJIT_Method_Load_V2; |
414 | |
415 | /** |
416 | * @brief Description of a JIT-compiled method |
417 | * @details The iJIT_Method_Load_V3 structure is the same as iJIT_Method_Load_V2 |
418 | * with a newly introduced 'arch' field that specifies architecture of the code region. |
419 | * When you use the iJIT_Method_Load_V3 structure to describe |
420 | * the JIT compiled method, use iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED_V3 |
421 | * as an event type to report it. |
422 | */ |
423 | typedef struct _iJIT_Method_Load_V3 |
424 | { |
425 | unsigned int method_id; /**<\brief Unique method ID. Cannot be 0. |
426 | * You must either use the API function |
427 | * iJIT_GetNewMethodID to get a valid and unique |
428 | * method ID, or manage ID uniqueness |
429 | * and correct range by yourself.\n |
430 | * You must use the same method ID for all code |
431 | * regions of the same method, otherwise they are |
432 | * treated as regions of different methods. */ |
433 | |
434 | char* method_name; /**<\brief The name of the method. It can be optionally |
435 | * prefixed with its class name and appended with |
436 | * its complete signature. Cannot be NULL. */ |
437 | |
438 | void* method_load_address; /**<\brief The start virtual address of the method code |
439 | * region. If NULL, then data provided with the |
440 | * event are not accepted. */ |
441 | |
442 | unsigned int method_size; /**<\brief The code size of the method in memory. |
443 | * If 0, then data provided with the event are not |
444 | * accepted. */ |
445 | |
446 | unsigned int line_number_size; /**<\brief The number of entries in the line number |
447 | * table. 0 if none. */ |
448 | |
449 | pLineNumberInfo line_number_table; /**<\brief Pointer to the line numbers info |
450 | * array. Can be NULL if |
451 | * line_number_size is 0. See |
452 | * LineNumberInfo Structure for a |
453 | * description of a single entry in |
454 | * the line number info array. */ |
455 | |
456 | char* class_file_name; /**<\brief Class name. Can be NULL. */ |
457 | |
458 | char* source_file_name; /**<\brief Source file name. Can be NULL. */ |
459 | |
460 | char* module_name; /**<\brief Module name. Can be NULL. |
461 | * The module name can be useful for distinguishing among |
462 | * different JIT engines. VTune Amplifier will display |
463 | * reported methods grouped by specific module. */ |
464 | |
465 | iJIT_CodeArchitecture module_arch; /**<\brief Architecture of the method's code region. |
466 | * By default, it is the same as the process |
467 | * architecture that is calling it. |
468 | * For example, you can use it if your 32-bit JIT |
469 | * engine generates 64-bit code. |
470 | * |
471 | * If JIT engine reports both 32-bit and 64-bit types |
472 | * of methods then VTune Amplifier splits the methods |
473 | * with the same module name but with different |
474 | * architectures in two different modules. VTune Amplifier |
475 | * modifies the original name provided with a 64-bit method |
476 | * version by ending it with '(64)' */ |
477 | |
478 | } *piJIT_Method_Load_V3, iJIT_Method_Load_V3; |
479 | |
480 | /** |
481 | * @brief Description of an inline JIT-compiled method |
482 | * @details When you use the_iJIT_Method_Inline_Load structure to describe |
483 | * the JIT compiled method, use iJVM_EVENT_TYPE_METHOD_INLINE_LOAD_FINISHED |
484 | * as an event type to report it. |
485 | */ |
486 | typedef struct _iJIT_Method_Inline_Load |
487 | { |
488 | unsigned int method_id; /**<\brief Unique method ID. Cannot be 0. |
489 | * You must either use the API function |
490 | * iJIT_GetNewMethodID to get a valid and unique |
491 | * method ID, or else manage ID uniqueness |
492 | * and correct range by yourself. */ |
493 | |
494 | unsigned int parent_method_id; /**<\brief Unique immediate parent's method ID. |
495 | * Cannot be 0. |
496 | * You must either use the API function |
497 | * iJIT_GetNewMethodID to get a valid and unique |
498 | * method ID, or else manage ID uniqueness |
499 | * and correct range by yourself. */ |
500 | |
501 | char* method_name; /**<\brief The name of the method. It can be optionally |
502 | * prefixed with its class name and appended with |
503 | * its complete signature. Can't be NULL. */ |
504 | |
505 | void* method_load_address; /** <\brief The virtual address on which the method |
506 | * is inlined. If NULL, then data provided with |
507 | * the event are not accepted. */ |
508 | |
509 | unsigned int method_size; /**<\brief The code size of the method in memory. |
510 | * If 0, then data provided with the event are not |
511 | * accepted. */ |
512 | |
513 | unsigned int line_number_size; /**<\brief The number of entries in the line number |
514 | * table. 0 if none. */ |
515 | |
516 | pLineNumberInfo line_number_table; /**<\brief Pointer to the line numbers info |
517 | * array. Can be NULL if |
518 | * line_number_size is 0. See |
519 | * LineNumberInfo Structure for a |
520 | * description of a single entry in |
521 | * the line number info array */ |
522 | |
523 | char* class_file_name; /**<\brief Class name. Can be NULL.*/ |
524 | |
525 | char* source_file_name; /**<\brief Source file name. Can be NULL.*/ |
526 | |
527 | } *piJIT_Method_Inline_Load, iJIT_Method_Inline_Load; |
528 | |
529 | /** @cond exclude_from_documentation */ |
530 | /** |
531 | * @brief Description of a segment type |
532 | * @details Use the segment type to specify a type of data supplied |
533 | * with the iJVM_EVENT_TYPE_METHOD_UPDATE_V2 event to be applied to |
534 | * a certain code trace. |
535 | */ |
536 | typedef enum _iJIT_SegmentType |
537 | { |
538 | iJIT_CT_UNKNOWN = 0, |
539 | |
540 | iJIT_CT_CODE, /**<\brief Executable code. */ |
541 | |
542 | iJIT_CT_DATA, /**<\brief Data (not executable code). |
543 | * VTune Amplifier uses the format string |
544 | * (see iJIT_Method_Update) to represent |
545 | * this data in the VTune Amplifier GUI */ |
546 | |
547 | iJIT_CT_KEEP, /**<\brief Use the previous markup for the trace. |
548 | * Can be used for the following |
549 | * iJVM_EVENT_TYPE_METHOD_UPDATE_V2 events, |
550 | * if the type of the previously reported segment |
551 | * type is the same. */ |
552 | iJIT_CT_EOF |
553 | } iJIT_SegmentType; |
554 | |
555 | /** |
556 | * @brief Description of a dynamic update of the content within JIT-compiled method |
557 | * @details The JIT engine may generate the methods that are updated at runtime |
558 | * partially by mixed (data + executable code) content. When you use the iJIT_Method_Update |
559 | * structure to describe the update of the content within a JIT-compiled method, |
560 | * use iJVM_EVENT_TYPE_METHOD_UPDATE_V2 as an event type to report it. |
561 | * |
562 | * On the first Update event, VTune Amplifier copies the original code range reported by |
563 | * the iJVM_EVENT_TYPE_METHOD_LOAD event, then modifies it with the supplied bytes and |
564 | * adds the modified range to the original method. For next update events, VTune Amplifier |
565 | * does the same but it uses the latest modified version of a code region for update. |
566 | * Eventually, VTune Amplifier GUI displays multiple code ranges for the method reported by |
567 | * the iJVM_EVENT_TYPE_METHOD_LOAD event. |
568 | * Notes: |
569 | * - Multiple update events with different types for the same trace are allowed |
570 | * but they must be reported for the same code ranges. |
571 | * Example, |
572 | * @code |
573 | * [-- data---] Allowed |
574 | * [-- code --] Allowed |
575 | * [code] Ignored |
576 | * [-- data---] Allowed |
577 | * [-- code --] Allowed |
578 | * [------------ trace ---------] |
579 | * @endcode |
580 | * - The types of previously reported events can be changed but they must be reported |
581 | * for the same code ranges. |
582 | * Example, |
583 | * @code |
584 | * [-- data---] Allowed |
585 | * [-- code --] Allowed |
586 | * [-- data---] Allowed |
587 | * [-- code --] Allowed |
588 | * [------------ trace ---------] |
589 | * @endcode |
590 | */ |
591 | |
592 | typedef struct _iJIT_Method_Update |
593 | { |
594 | void* load_address; /**<\brief Start address of the update within a method */ |
595 | |
596 | unsigned int size; /**<\brief The update size */ |
597 | |
598 | iJIT_SegmentType type; /**<\brief Type of the update */ |
599 | |
600 | const char* data_format; /**<\brief C string that contains a format string |
601 | * that follows the same specifications as format in printf. |
602 | * The format string is used for iJIT_CT_CODE only |
603 | * and cannot be NULL. |
604 | * Format can be changed on the fly. */ |
605 | } *piJIT_Method_Update, iJIT_Method_Update; |
606 | |
607 | /** @endcond */ |
608 | |
609 | #pragma pack(pop) |
610 | |
611 | /** @cond exclude_from_documentation */ |
612 | #ifdef __cplusplus |
613 | extern "C" { |
614 | #endif /* __cplusplus */ |
615 | |
616 | #ifndef JITAPI_CDECL |
617 | # if defined WIN32 || defined _WIN32 |
618 | # define JITAPI_CDECL __cdecl |
619 | # else /* defined WIN32 || defined _WIN32 */ |
620 | # if defined _M_IX86 || defined __i386__ |
621 | # define JITAPI_CDECL __attribute__ ((cdecl)) |
622 | # else /* _M_IX86 || __i386__ */ |
623 | # define JITAPI_CDECL /* actual only on x86_64 platform */ |
624 | # endif /* _M_IX86 || __i386__ */ |
625 | # endif /* defined WIN32 || defined _WIN32 */ |
626 | #endif /* JITAPI_CDECL */ |
627 | |
628 | #define JITAPI JITAPI_CDECL |
629 | /** @endcond */ |
630 | |
631 | /** |
632 | * @brief Generates a new unique method ID. |
633 | * |
634 | * You must use this API to obtain unique and valid method IDs for methods or |
635 | * traces reported to the agent if you don't have your own mechanism to generate |
636 | * unique method IDs. |
637 | * |
638 | * @return a new unique method ID. When out of unique method IDs, this API |
639 | * returns 0, which is not an accepted value. |
640 | */ |
641 | unsigned int JITAPI iJIT_GetNewMethodID(void); |
642 | |
643 | /** |
644 | * @brief Returns the current mode of the agent. |
645 | * |
646 | * @return iJIT_SAMPLING_ON, indicating that agent is running, or |
647 | * iJIT_NOTHING_RUNNING if no agent is running. |
648 | */ |
649 | iJIT_IsProfilingActiveFlags JITAPI iJIT_IsProfilingActive(void); |
650 | |
651 | /** |
652 | * @brief Reports infomation about JIT-compiled code to the agent. |
653 | * |
654 | * The reported information is used to attribute samples obtained from any |
655 | * Intel(R) VTune(TM) Amplifier collector. This API needs to be called |
656 | * after JIT compilation and before the first entry into the JIT-compiled |
657 | * code. |
658 | * |
659 | * @param[in] event_type - type of the data sent to the agent |
660 | * @param[in] EventSpecificData - pointer to event-specific data |
661 | * |
662 | * @returns 1 on success, otherwise 0. |
663 | */ |
664 | int JITAPI iJIT_NotifyEvent(iJIT_JVM_EVENT event_type, void *EventSpecificData); |
665 | |
666 | #ifdef __cplusplus |
667 | } |
668 | #endif /* __cplusplus */ |
669 | /** @endcond */ |
670 | |
671 | /** @} jitapi group */ |
672 | |
673 | #endif /* __JITPROFILING_H__ */ |
674 | |