LLVM  12.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 */
26 typedef 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 
65 typedef 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 */
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 
132 typedef 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 
148 typedef 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) */
157  char* method_name;
159 
160 /* structures for the events:
161  * iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED
162  */
163 
164 typedef 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 
174 typedef 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  */
182  char* method_name;
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 */
208  void* user_data;
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
220 extern "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 */
238 typedef void (*iJIT_ModeChangedEx)(void *UserData, iJIT_ModeFlags Flags);
239 
240 int JITAPI iJIT_NotifyEvent(iJIT_JVM_EVENT event_type, void *EventSpecificData);
241 
242 /* The new mode call back routine */
243 void JITAPI iJIT_RegisterCallbackEx(void *userdata,
244  iJIT_ModeChangedEx NewModeCallBackFuncEx);
245 
247 
248 void JITAPI FinalizeThread(void);
249 
250 void JITAPI FinalizeProcess(void);
251 
252 unsigned int JITAPI iJIT_GetNewMethodID(void);
253 
254 #ifdef __cplusplus
255 }
256 #endif
257 
258 #endif /* __JITPROFILING_H__ */
iJIT_jvm_event
Definition: jitprofiling.h:26
struct _iJIT_Method_NIDS iJIT_Method_NIDS
unsigned int LineNumber
Definition: jitprofiling.h:170
unsigned int Offset
Definition: jitprofiling.h:167
struct _iJIT_Method_Load iJIT_Method_Load
#define JITAPI
Definition: jitprofiling.h:235
void JITAPI FinalizeThread(void)
Definition: jitprofiling.c:419
unsigned int class_id
Definition: jitprofiling.h:199
_iJIT_ModeFlags
Definition: jitprofiling.h:65
enum iJIT_jvm_event iJIT_JVM_EVENT
iJDEnvironmentType env
Definition: jitprofiling.h:214
pLineNumberInfo line_number_table
Definition: jitprofiling.h:196
struct _iJIT_Method_Id * piJIT_Method_Id
void JITAPI FinalizeProcess(void)
Definition: jitprofiling.c:447
void(* iJIT_ModeChangedEx)(void *UserData, iJIT_ModeFlags Flags)
Definition: jitprofiling.h:238
struct _iJIT_Method_Load * piJIT_Method_Load
unsigned int method_id
Definition: jitprofiling.h:137
void * method_load_address
Definition: jitprofiling.h:187
unsigned int user_data_size
Definition: jitprofiling.h:211
enum _iJDEnvironmentType iJDEnvironmentType
unsigned int method_id
Definition: jitprofiling.h:177
unsigned int JITAPI iJIT_GetNewMethodID(void)
Definition: jitprofiling.c:472
unsigned int stack_id
Definition: jitprofiling.h:154
int JITAPI iJIT_NotifyEvent(iJIT_JVM_EVENT event_type, void *EventSpecificData)
Definition: jitprofiling.c:112
unsigned int line_number_size
Definition: jitprofiling.h:193
struct _LineNumberInfo LineNumberInfo
_iJIT_IsProfilingActiveFlags
Definition: jitprofiling.h:103
enum _iJIT_ModeFlags iJIT_ModeFlags
_iJDEnvironmentType
Definition: jitprofiling.h:119
unsigned int method_size
Definition: jitprofiling.h:190
void JITAPI iJIT_RegisterCallbackEx(void *userdata, iJIT_ModeChangedEx NewModeCallBackFuncEx)
Definition: jitprofiling.c:243
iJIT_IsProfilingActiveFlags JITAPI iJIT_IsProfilingActive(void)
Definition: jitprofiling.c:261
unsigned int method_id
Definition: jitprofiling.h:151
struct _iJIT_Method_Id iJIT_Method_Id
struct _iJIT_Method_NIDS * piJIT_Method_NIDS
enum _iJIT_IsProfilingActiveFlags iJIT_IsProfilingActiveFlags
struct _LineNumberInfo * pLineNumberInfo