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