]> git.proxmox.com Git - rustc.git/blob - src/llvm/lib/ExecutionEngine/IntelJITEvents/jitprofiling.h
Imported Upstream version 0.6
[rustc.git] / src / llvm / lib / ExecutionEngine / IntelJITEvents / jitprofiling.h
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 *===----------------------------------------------------------------------===*/
14 #ifndef __JITPROFILING_H__
15 #define __JITPROFILING_H__
16
17 /*
18 * Various constants used by functions
19 */
20
21 /* event notification */
22 typedef enum iJIT_jvm_event
23 {
24
25 /* shutdown */
26
27 /*
28 * Program exiting EventSpecificData NA
29 */
30 iJVM_EVENT_TYPE_SHUTDOWN = 2,
31
32 /* JIT profiling */
33
34 /*
35 * issued after method code jitted into memory but before code is executed
36 * EventSpecificData is an iJIT_Method_Load
37 */
38 iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED=13,
39
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
43 */
44 iJVM_EVENT_TYPE_METHOD_UNLOAD_START,
45
46 /* Method Profiling */
47
48 /* method name, Id and stack is supplied
49 * issued when a method is about to be entered EventSpecificData is
50 * iJIT_Method_NIDS
51 */
52 iJVM_EVENT_TYPE_ENTER_NIDS = 19,
53
54 /* method name, Id and stack is supplied
55 * issued when a method is about to be left EventSpecificData is
56 * iJIT_Method_NIDS
57 */
58 iJVM_EVENT_TYPE_LEAVE_NIDS
59 } iJIT_JVM_EVENT;
60
61 typedef enum _iJIT_ModeFlags
62 {
63 /* No need to Notify VTune, since VTune is not running */
64 iJIT_NO_NOTIFICATIONS = 0x0000,
65
66 /* when turned on the jit must call
67 * iJIT_NotifyEvent
68 * (
69 * iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED,
70 * )
71 * for all the method already jitted
72 */
73 iJIT_BE_NOTIFY_ON_LOAD = 0x0001,
74
75 /* when turned on the jit must call
76 * iJIT_NotifyEvent
77 * (
78 * iJVM_EVENT_TYPE_METHOD_UNLOAD_FINISHED,
79 * ) for all the method that are unloaded
80 */
81 iJIT_BE_NOTIFY_ON_UNLOAD = 0x0002,
82
83 /* when turned on the jit must instrument all
84 * the currently jited code with calls on
85 * method entries
86 */
87 iJIT_BE_NOTIFY_ON_METHOD_ENTRY = 0x0004,
88
89 /* when turned on the jit must instrument all
90 * the currently jited code with calls
91 * on method exit
92 */
93 iJIT_BE_NOTIFY_ON_METHOD_EXIT = 0x0008
94
95 } iJIT_ModeFlags;
96
97
98 /* Flags used by iJIT_IsProfilingActive() */
99 typedef enum _iJIT_IsProfilingActiveFlags
100 {
101 /* No profiler is running. Currently not used */
102 iJIT_NOTHING_RUNNING = 0x0000,
103
104 /* Sampling is running. This is the default value
105 * returned by iJIT_IsProfilingActive()
106 */
107 iJIT_SAMPLING_ON = 0x0001,
108
109 /* Call Graph is running */
110 iJIT_CALLGRAPH_ON = 0x0002
111
112 } iJIT_IsProfilingActiveFlags;
113
114 /* Enumerator for the environment of methods*/
115 typedef enum _iJDEnvironmentType
116 {
117 iJDE_JittingAPI = 2
118 } iJDEnvironmentType;
119
120 /**********************************
121 * Data structures for the events *
122 **********************************/
123
124 /* structure for the events:
125 * iJVM_EVENT_TYPE_METHOD_UNLOAD_START
126 */
127
128 typedef struct _iJIT_Method_Id
129 {
130 /* Id of the method (same as the one passed in
131 * the iJIT_Method_Load struct
132 */
133 unsigned int method_id;
134
135 } *piJIT_Method_Id, iJIT_Method_Id;
136
137
138 /* structure for the events:
139 * iJVM_EVENT_TYPE_ENTER_NIDS,
140 * iJVM_EVENT_TYPE_LEAVE_NIDS,
141 * iJVM_EVENT_TYPE_EXCEPTION_OCCURRED_NIDS
142 */
143
144 typedef struct _iJIT_Method_NIDS
145 {
146 /* unique method ID */
147 unsigned int method_id;
148
149 /* NOTE: no need to fill this field, it's filled by VTune */
150 unsigned int stack_id;
151
152 /* method name (just the method, without the class) */
153 char* method_name;
154 } *piJIT_Method_NIDS, iJIT_Method_NIDS;
155
156 /* structures for the events:
157 * iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED
158 */
159
160 typedef struct _LineNumberInfo
161 {
162 /* x86 Offset from the begining of the method*/
163 unsigned int Offset;
164
165 /* source line number from the begining of the source file */
166 unsigned int LineNumber;
167
168 } *pLineNumberInfo, LineNumberInfo;
169
170 typedef struct _iJIT_Method_Load
171 {
172 /* unique method ID - can be any unique value, (except 0 - 999) */
173 unsigned int method_id;
174
175 /* method name (can be with or without the class and signature, in any case
176 * the class name will be added to it)
177 */
178 char* method_name;
179
180 /* virtual address of that method - This determines the method range for the
181 * iJVM_EVENT_TYPE_ENTER/LEAVE_METHOD_ADDR events
182 */
183 void* method_load_address;
184
185 /* Size in memory - Must be exact */
186 unsigned int method_size;
187
188 /* Line Table size in number of entries - Zero if none */
189 unsigned int line_number_size;
190
191 /* Pointer to the begining of the line numbers info array */
192 pLineNumberInfo line_number_table;
193
194 /* unique class ID */
195 unsigned int class_id;
196
197 /* class file name */
198 char* class_file_name;
199
200 /* source file name */
201 char* source_file_name;
202
203 /* bits supplied by the user for saving in the JIT file */
204 void* user_data;
205
206 /* the size of the user data buffer */
207 unsigned int user_data_size;
208
209 /* NOTE: no need to fill this field, it's filled by VTune */
210 iJDEnvironmentType env;
211
212 } *piJIT_Method_Load, iJIT_Method_Load;
213
214 /* API Functions */
215 #ifdef __cplusplus
216 extern "C" {
217 #endif
218
219 #ifndef CDECL
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 */
229 #endif /* CDECL */
230
231 #define JITAPI CDECL
232
233 /* called when the settings are changed with new settings */
234 typedef void (*iJIT_ModeChangedEx)(void *UserData, iJIT_ModeFlags Flags);
235
236 int JITAPI iJIT_NotifyEvent(iJIT_JVM_EVENT event_type, void *EventSpecificData);
237
238 /* The new mode call back routine */
239 void JITAPI iJIT_RegisterCallbackEx(void *userdata,
240 iJIT_ModeChangedEx NewModeCallBackFuncEx);
241
242 iJIT_IsProfilingActiveFlags JITAPI iJIT_IsProfilingActive(void);
243
244 void JITAPI FinalizeThread(void);
245
246 void JITAPI FinalizeProcess(void);
247
248 unsigned int JITAPI iJIT_GetNewMethodID(void);
249
250 #ifdef __cplusplus
251 }
252 #endif
253
254 #endif /* __JITPROFILING_H__ */