1 /*===-- jitprofiling.h - JIT Profiling API-------------------------*- C -*-===*
3 * The LLVM Compiler Infrastructure
5 * This file is distributed under the University of Illinois Open Source
6 * License. See LICENSE.TXT for details.
8 *===----------------------------------------------------------------------===*
10 * This file provides Intel(R) Performance Analyzer JIT (Just-In-Time)
11 * Profiling API declaration.
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.
18 *===----------------------------------------------------------------------===*/
19 #ifndef __JITPROFILING_H__
20 #define __JITPROFILING_H__
23 * Various constants used by functions
26 /* event notification */
27 typedef enum iJIT_jvm_event
33 * Program exiting EventSpecificData NA
35 iJVM_EVENT_TYPE_SHUTDOWN = 2,
40 * issued after method code jitted into memory but before code is executed
41 * EventSpecificData is an iJIT_Method_Load
43 iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED=13,
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
49 iJVM_EVENT_TYPE_METHOD_UNLOAD_START,
51 /* Method Profiling */
53 /* method name, Id and stack is supplied
54 * issued when a method is about to be entered EventSpecificData is
57 iJVM_EVENT_TYPE_ENTER_NIDS = 19,
59 /* method name, Id and stack is supplied
60 * issued when a method is about to be left EventSpecificData is
63 iJVM_EVENT_TYPE_LEAVE_NIDS
66 typedef enum _iJIT_ModeFlags
68 /* No need to Notify VTune, since VTune is not running */
69 iJIT_NO_NOTIFICATIONS = 0x0000,
71 /* when turned on the jit must call
74 * iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED,
76 * for all the method already jitted
78 iJIT_BE_NOTIFY_ON_LOAD = 0x0001,
80 /* when turned on the jit must call
83 * iJVM_EVENT_TYPE_METHOD_UNLOAD_FINISHED,
84 * ) for all the method that are unloaded
86 iJIT_BE_NOTIFY_ON_UNLOAD = 0x0002,
88 /* when turned on the jit must instrument all
89 * the currently jited code with calls on
92 iJIT_BE_NOTIFY_ON_METHOD_ENTRY = 0x0004,
94 /* when turned on the jit must instrument all
95 * the currently jited code with calls
98 iJIT_BE_NOTIFY_ON_METHOD_EXIT = 0x0008
103 /* Flags used by iJIT_IsProfilingActive() */
104 typedef enum _iJIT_IsProfilingActiveFlags
106 /* No profiler is running. Currently not used */
107 iJIT_NOTHING_RUNNING = 0x0000,
109 /* Sampling is running. This is the default value
110 * returned by iJIT_IsProfilingActive()
112 iJIT_SAMPLING_ON = 0x0001,
114 /* Call Graph is running */
115 iJIT_CALLGRAPH_ON = 0x0002
117 } iJIT_IsProfilingActiveFlags;
119 /* Enumerator for the environment of methods*/
120 typedef enum _iJDEnvironmentType
123 } iJDEnvironmentType;
125 /**********************************
126 * Data structures for the events *
127 **********************************/
129 /* structure for the events:
130 * iJVM_EVENT_TYPE_METHOD_UNLOAD_START
133 typedef struct _iJIT_Method_Id
135 /* Id of the method (same as the one passed in
136 * the iJIT_Method_Load struct
138 unsigned int method_id;
140 } *piJIT_Method_Id, iJIT_Method_Id;
143 /* structure for the events:
144 * iJVM_EVENT_TYPE_ENTER_NIDS,
145 * iJVM_EVENT_TYPE_LEAVE_NIDS,
146 * iJVM_EVENT_TYPE_EXCEPTION_OCCURRED_NIDS
149 typedef struct _iJIT_Method_NIDS
151 /* unique method ID */
152 unsigned int method_id;
154 /* NOTE: no need to fill this field, it's filled by VTune */
155 unsigned int stack_id;
157 /* method name (just the method, without the class) */
159 } *piJIT_Method_NIDS, iJIT_Method_NIDS;
161 /* structures for the events:
162 * iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED
165 typedef struct _LineNumberInfo
167 /* x86 Offset from the begining of the method*/
170 /* source line number from the begining of the source file */
171 unsigned int LineNumber;
173 } *pLineNumberInfo, LineNumberInfo;
175 typedef struct _iJIT_Method_Load
177 /* unique method ID - can be any unique value, (except 0 - 999) */
178 unsigned int method_id;
180 /* method name (can be with or without the class and signature, in any case
181 * the class name will be added to it)
185 /* virtual address of that method - This determines the method range for the
186 * iJVM_EVENT_TYPE_ENTER/LEAVE_METHOD_ADDR events
188 void* method_load_address;
190 /* Size in memory - Must be exact */
191 unsigned int method_size;
193 /* Line Table size in number of entries - Zero if none */
194 unsigned int line_number_size;
196 /* Pointer to the begining of the line numbers info array */
197 pLineNumberInfo line_number_table;
199 /* unique class ID */
200 unsigned int class_id;
202 /* class file name */
203 char* class_file_name;
205 /* source file name */
206 char* source_file_name;
208 /* bits supplied by the user for saving in the JIT file */
211 /* the size of the user data buffer */
212 unsigned int user_data_size;
214 /* NOTE: no need to fill this field, it's filled by VTune */
215 iJDEnvironmentType env;
217 } *piJIT_Method_Load, iJIT_Method_Load;
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 */
238 /* called when the settings are changed with new settings */
239 typedef void (*iJIT_ModeChangedEx)(void *UserData, iJIT_ModeFlags Flags);
241 int JITAPI iJIT_NotifyEvent(iJIT_JVM_EVENT event_type, void *EventSpecificData);
243 /* The new mode call back routine */
244 void JITAPI iJIT_RegisterCallbackEx(void *userdata,
245 iJIT_ModeChangedEx NewModeCallBackFuncEx);
247 iJIT_IsProfilingActiveFlags JITAPI iJIT_IsProfilingActive(void);
249 void JITAPI FinalizeThread(void);
251 void JITAPI FinalizeProcess(void);
253 unsigned int JITAPI iJIT_GetNewMethodID(void);
259 #endif /* __JITPROFILING_H__ */