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 *===----------------------------------------------------------------------===*/
14 #ifndef __JITPROFILING_H__
15 #define __JITPROFILING_H__
18 * Various constants used by functions
21 /* event notification */
22 typedef enum iJIT_jvm_event
28 * Program exiting EventSpecificData NA
30 iJVM_EVENT_TYPE_SHUTDOWN
= 2,
35 * issued after method code jitted into memory but before code is executed
36 * EventSpecificData is an iJIT_Method_Load
38 iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED
=13,
40 /* issued before unload. Method code will no longer be executed, but code
41 * and info are still in memory. The VTune profiler may capture method
42 * code only at this point EventSpecificData is iJIT_Method_Id
44 iJVM_EVENT_TYPE_METHOD_UNLOAD_START
,
46 /* Method Profiling */
48 /* method name, Id and stack is supplied
49 * issued when a method is about to be entered EventSpecificData is
52 iJVM_EVENT_TYPE_ENTER_NIDS
= 19,
54 /* method name, Id and stack is supplied
55 * issued when a method is about to be left EventSpecificData is
58 iJVM_EVENT_TYPE_LEAVE_NIDS
61 typedef enum _iJIT_ModeFlags
63 /* No need to Notify VTune, since VTune is not running */
64 iJIT_NO_NOTIFICATIONS
= 0x0000,
66 /* when turned on the jit must call
69 * iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED,
71 * for all the method already jitted
73 iJIT_BE_NOTIFY_ON_LOAD
= 0x0001,
75 /* when turned on the jit must call
78 * iJVM_EVENT_TYPE_METHOD_UNLOAD_FINISHED,
79 * ) for all the method that are unloaded
81 iJIT_BE_NOTIFY_ON_UNLOAD
= 0x0002,
83 /* when turned on the jit must instrument all
84 * the currently jited code with calls on
87 iJIT_BE_NOTIFY_ON_METHOD_ENTRY
= 0x0004,
89 /* when turned on the jit must instrument all
90 * the currently jited code with calls
93 iJIT_BE_NOTIFY_ON_METHOD_EXIT
= 0x0008
98 /* Flags used by iJIT_IsProfilingActive() */
99 typedef enum _iJIT_IsProfilingActiveFlags
101 /* No profiler is running. Currently not used */
102 iJIT_NOTHING_RUNNING
= 0x0000,
104 /* Sampling is running. This is the default value
105 * returned by iJIT_IsProfilingActive()
107 iJIT_SAMPLING_ON
= 0x0001,
109 /* Call Graph is running */
110 iJIT_CALLGRAPH_ON
= 0x0002
112 } iJIT_IsProfilingActiveFlags
;
114 /* Enumerator for the environment of methods*/
115 typedef enum _iJDEnvironmentType
118 } iJDEnvironmentType
;
120 /**********************************
121 * Data structures for the events *
122 **********************************/
124 /* structure for the events:
125 * iJVM_EVENT_TYPE_METHOD_UNLOAD_START
128 typedef struct _iJIT_Method_Id
130 /* Id of the method (same as the one passed in
131 * the iJIT_Method_Load struct
133 unsigned int method_id
;
135 } *piJIT_Method_Id
, iJIT_Method_Id
;
138 /* structure for the events:
139 * iJVM_EVENT_TYPE_ENTER_NIDS,
140 * iJVM_EVENT_TYPE_LEAVE_NIDS,
141 * iJVM_EVENT_TYPE_EXCEPTION_OCCURRED_NIDS
144 typedef struct _iJIT_Method_NIDS
146 /* unique method ID */
147 unsigned int method_id
;
149 /* NOTE: no need to fill this field, it's filled by VTune */
150 unsigned int stack_id
;
152 /* method name (just the method, without the class) */
154 } *piJIT_Method_NIDS
, iJIT_Method_NIDS
;
156 /* structures for the events:
157 * iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED
160 typedef struct _LineNumberInfo
162 /* x86 Offset from the begining of the method*/
165 /* source line number from the begining of the source file */
166 unsigned int LineNumber
;
168 } *pLineNumberInfo
, LineNumberInfo
;
170 typedef struct _iJIT_Method_Load
172 /* unique method ID - can be any unique value, (except 0 - 999) */
173 unsigned int method_id
;
175 /* method name (can be with or without the class and signature, in any case
176 * the class name will be added to it)
180 /* virtual address of that method - This determines the method range for the
181 * iJVM_EVENT_TYPE_ENTER/LEAVE_METHOD_ADDR events
183 void* method_load_address
;
185 /* Size in memory - Must be exact */
186 unsigned int method_size
;
188 /* Line Table size in number of entries - Zero if none */
189 unsigned int line_number_size
;
191 /* Pointer to the begining of the line numbers info array */
192 pLineNumberInfo line_number_table
;
194 /* unique class ID */
195 unsigned int class_id
;
197 /* class file name */
198 char* class_file_name
;
200 /* source file name */
201 char* source_file_name
;
203 /* bits supplied by the user for saving in the JIT file */
206 /* the size of the user data buffer */
207 unsigned int user_data_size
;
209 /* NOTE: no need to fill this field, it's filled by VTune */
210 iJDEnvironmentType env
;
212 } *piJIT_Method_Load
, iJIT_Method_Load
;
220 # if defined WIN32 || defined _WIN32
221 # define CDECL __cdecl
222 # else /* defined WIN32 || defined _WIN32 */
223 # if defined _M_X64 || defined _M_AMD64 || defined __x86_64__
224 # define CDECL /* not actual on x86_64 platform */
225 # else /* _M_X64 || _M_AMD64 || __x86_64__ */
226 # define CDECL __attribute__ ((cdecl))
227 # endif /* _M_X64 || _M_AMD64 || __x86_64__ */
228 # endif /* defined WIN32 || defined _WIN32 */
233 /* called when the settings are changed with new settings */
234 typedef void (*iJIT_ModeChangedEx
)(void *UserData
, iJIT_ModeFlags Flags
);
236 int JITAPI
iJIT_NotifyEvent(iJIT_JVM_EVENT event_type
, void *EventSpecificData
);
238 /* The new mode call back routine */
239 void JITAPI
iJIT_RegisterCallbackEx(void *userdata
,
240 iJIT_ModeChangedEx NewModeCallBackFuncEx
);
242 iJIT_IsProfilingActiveFlags JITAPI
iJIT_IsProfilingActive(void);
244 void JITAPI
FinalizeThread(void);
246 void JITAPI
FinalizeProcess(void);
248 unsigned int JITAPI
iJIT_GetNewMethodID(void);
254 #endif /* __JITPROFILING_H__ */