LLVM 19.0.0git
jitprofiling.h
Go to the documentation of this file.
1/*===-- jitprofiling.h - JIT Profiling API-------------------------*- C -*-===*
2 *
3 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 * See https://llvm.org/LICENSE.txt for license information.
5 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 *
7 *===----------------------------------------------------------------------===*
8 *
9 * This file provides Intel(R) Performance Analyzer JIT (Just-In-Time)
10 * Profiling API declaration.
11 *
12 * NOTE: This file comes in a style different from the rest of LLVM
13 * source base since this is a piece of code shared from Intel(R)
14 * products. Please do not reformat / re-style this code to make
15 * subsequent merges and contributions from the original source base eaiser.
16 *
17 *===----------------------------------------------------------------------===*/
18#ifndef __JITPROFILING_H__
19#define __JITPROFILING_H__
20
21/*
22 * Various constants used by functions
23 */
24
25/* event notification */
26typedef enum iJIT_jvm_event
27{
28
29 /* shutdown */
30
31 /*
32 * Program exiting EventSpecificData NA
33 */
35
36 /* JIT profiling */
37
38 /*
39 * issued after method code jitted into memory but before code is executed
40 * EventSpecificData is an iJIT_Method_Load
41 */
43
44 /* issued before unload. Method code will no longer be executed, but code
45 * and info are still in memory. The VTune profiler may capture method
46 * code only at this point EventSpecificData is iJIT_Method_Id
47 */
49
50 /* Method Profiling */
51
52 /* method name, Id and stack is supplied
53 * issued when a method is about to be entered EventSpecificData is
54 * iJIT_Method_NIDS
55 */
57
58 /* method name, Id and stack is supplied
59 * issued when a method is about to be left EventSpecificData is
60 * iJIT_Method_NIDS
61 */
64
65typedef enum _iJIT_ModeFlags
66{
67 /* No need to Notify VTune, since VTune is not running */
69
70 /* when turned on the jit must call
71 * iJIT_NotifyEvent
72 * (
73 * iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED,
74 * )
75 * for all the method already jitted
76 */
78
79 /* when turned on the jit must call
80 * iJIT_NotifyEvent
81 * (
82 * iJVM_EVENT_TYPE_METHOD_UNLOAD_FINISHED,
83 * ) for all the method that are unloaded
84 */
86
87 /* when turned on the jit must instrument all
88 * the currently jited code with calls on
89 * method entries
90 */
92
93 /* when turned on the jit must instrument all
94 * the currently jited code with calls
95 * on method exit
96 */
98
100
101
102 /* Flags used by iJIT_IsProfilingActive() */
104{
105 /* No profiler is running. Currently not used */
107
108 /* Sampling is running. This is the default value
109 * returned by iJIT_IsProfilingActive()
110 */
112
113 /* Call Graph is running */
114 iJIT_CALLGRAPH_ON = 0x0002
115
117
118/* Enumerator for the environment of methods*/
120{
123
124/**********************************
125 * Data structures for the events *
126 **********************************/
127
128/* structure for the events:
129 * iJVM_EVENT_TYPE_METHOD_UNLOAD_START
130 */
131
132typedef struct _iJIT_Method_Id
133{
134 /* Id of the method (same as the one passed in
135 * the iJIT_Method_Load struct
136 */
137 unsigned int method_id;
138
140
141
142/* structure for the events:
143 * iJVM_EVENT_TYPE_ENTER_NIDS,
144 * iJVM_EVENT_TYPE_LEAVE_NIDS,
145 * iJVM_EVENT_TYPE_EXCEPTION_OCCURRED_NIDS
146 */
147
148typedef struct _iJIT_Method_NIDS
149{
150 /* unique method ID */
151 unsigned int method_id;
152
153 /* NOTE: no need to fill this field, it's filled by VTune */
154 unsigned int stack_id;
155
156 /* method name (just the method, without the class) */
159
160/* structures for the events:
161 * iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED
162 */
163
164typedef struct _LineNumberInfo
165{
166 /* x86 Offset from the beginning of the method*/
167 unsigned int Offset;
168
169 /* source line number from the beginning of the source file */
170 unsigned int LineNumber;
171
173
174typedef struct _iJIT_Method_Load
175{
176 /* unique method ID - can be any unique value, (except 0 - 999) */
177 unsigned int method_id;
178
179 /* method name (can be with or without the class and signature, in any case
180 * the class name will be added to it)
181 */
183
184 /* virtual address of that method - This determines the method range for the
185 * iJVM_EVENT_TYPE_ENTER/LEAVE_METHOD_ADDR events
186 */
188
189 /* Size in memory - Must be exact */
190 unsigned int method_size;
191
192 /* Line Table size in number of entries - Zero if none */
193 unsigned int line_number_size;
194
195 /* Pointer to the beginning of the line numbers info array */
197
198 /* unique class ID */
199 unsigned int class_id;
200
201 /* class file name */
203
204 /* source file name */
206
207 /* bits supplied by the user for saving in the JIT file */
209
210 /* the size of the user data buffer */
211 unsigned int user_data_size;
212
213 /* NOTE: no need to fill this field, it's filled by VTune */
215
217
218/* API Functions */
219#ifdef __cplusplus
220extern "C" {
221#endif
222
223#ifndef CDECL
224# if defined WIN32 || defined _WIN32
225# define CDECL __cdecl
226# else /* defined WIN32 || defined _WIN32 */
227# if defined _M_X64 || defined _M_AMD64 || defined __x86_64__
228# define CDECL /* not actual on x86_64 platform */
229# else /* _M_X64 || _M_AMD64 || __x86_64__ */
230# define CDECL __attribute__ ((cdecl))
231# endif /* _M_X64 || _M_AMD64 || __x86_64__ */
232# endif /* defined WIN32 || defined _WIN32 */
233#endif /* CDECL */
234
235#define JITAPI CDECL
236
237/* called when the settings are changed with new settings */
238typedef void (*iJIT_ModeChangedEx)(void *UserData, iJIT_ModeFlags Flags);
239
240int JITAPI iJIT_NotifyEvent(iJIT_JVM_EVENT event_type, void *EventSpecificData);
241
242/* The new mode call back routine */
243void JITAPI iJIT_RegisterCallbackEx(void *userdata,
244 iJIT_ModeChangedEx NewModeCallBackFuncEx);
245
247
248void JITAPI FinalizeThread(void);
249
250void JITAPI FinalizeProcess(void);
251
252unsigned int JITAPI iJIT_GetNewMethodID(void);
253
254#ifdef __cplusplus
255}
256#endif
257
258#endif /* __JITPROFILING_H__ */
struct _LineNumberInfo * pLineNumberInfo
int JITAPI iJIT_NotifyEvent(iJIT_JVM_EVENT event_type, void *EventSpecificData)
Definition: jitprofiling.c:112
iJIT_jvm_event
Definition: jitprofiling.h:27
@ iJVM_EVENT_TYPE_ENTER_NIDS
Definition: jitprofiling.h:56
@ iJVM_EVENT_TYPE_LEAVE_NIDS
Definition: jitprofiling.h:62
@ iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED
Definition: jitprofiling.h:42
@ iJVM_EVENT_TYPE_METHOD_UNLOAD_START
Definition: jitprofiling.h:48
@ iJVM_EVENT_TYPE_SHUTDOWN
Definition: jitprofiling.h:34
struct _iJIT_Method_Load * piJIT_Method_Load
_iJIT_ModeFlags
Definition: jitprofiling.h:66
@ iJIT_BE_NOTIFY_ON_METHOD_ENTRY
Definition: jitprofiling.h:91
@ iJIT_BE_NOTIFY_ON_METHOD_EXIT
Definition: jitprofiling.h:97
@ iJIT_BE_NOTIFY_ON_UNLOAD
Definition: jitprofiling.h:85
@ iJIT_BE_NOTIFY_ON_LOAD
Definition: jitprofiling.h:77
@ iJIT_NO_NOTIFICATIONS
Definition: jitprofiling.h:68
unsigned int JITAPI iJIT_GetNewMethodID(void)
Definition: jitprofiling.c:472
void(* iJIT_ModeChangedEx)(void *UserData, iJIT_ModeFlags Flags)
Definition: jitprofiling.h:238
_iJIT_IsProfilingActiveFlags
Definition: jitprofiling.h:104
@ iJIT_NOTHING_RUNNING
Definition: jitprofiling.h:106
@ iJIT_SAMPLING_ON
Definition: jitprofiling.h:111
@ iJIT_CALLGRAPH_ON
Definition: jitprofiling.h:114
#define JITAPI
Definition: jitprofiling.h:235
_iJDEnvironmentType
Definition: jitprofiling.h:120
@ iJDE_JittingAPI
Definition: jitprofiling.h:121
struct _LineNumberInfo LineNumberInfo
enum _iJIT_ModeFlags iJIT_ModeFlags
struct _iJIT_Method_NIDS iJIT_Method_NIDS
void JITAPI FinalizeProcess(void)
Definition: jitprofiling.c:447
enum _iJDEnvironmentType iJDEnvironmentType
struct _iJIT_Method_Id * piJIT_Method_Id
void JITAPI FinalizeThread(void)
Definition: jitprofiling.c:419
enum iJIT_jvm_event iJIT_JVM_EVENT
struct _iJIT_Method_Load iJIT_Method_Load
enum _iJIT_IsProfilingActiveFlags iJIT_IsProfilingActiveFlags
void JITAPI iJIT_RegisterCallbackEx(void *userdata, iJIT_ModeChangedEx NewModeCallBackFuncEx)
Definition: jitprofiling.c:243
struct _iJIT_Method_NIDS * piJIT_Method_NIDS
iJIT_IsProfilingActiveFlags JITAPI iJIT_IsProfilingActive(void)
Definition: jitprofiling.c:261
struct _iJIT_Method_Id iJIT_Method_Id
unsigned int Offset
Definition: jitprofiling.h:167
unsigned int LineNumber
Definition: jitprofiling.h:170
unsigned int method_id
Definition: jitprofiling.h:137
unsigned int line_number_size
Definition: jitprofiling.h:193
iJDEnvironmentType env
Definition: jitprofiling.h:214
unsigned int method_id
Definition: jitprofiling.h:177
unsigned int class_id
Definition: jitprofiling.h:199
pLineNumberInfo line_number_table
Definition: jitprofiling.h:196
unsigned int user_data_size
Definition: jitprofiling.h:211
unsigned int method_size
Definition: jitprofiling.h:190
void * method_load_address
Definition: jitprofiling.h:187
unsigned int method_id
Definition: jitprofiling.h:151
unsigned int stack_id
Definition: jitprofiling.h:154