Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/contrib/llvm-project/llvm/lib/ExecutionEngine/IntelJITProfiling/jitprofiling.h
35271 views
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
*/
34
iJVM_EVENT_TYPE_SHUTDOWN = 2,
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
*/
42
iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED=13,
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
*/
48
iJVM_EVENT_TYPE_METHOD_UNLOAD_START,
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
*/
56
iJVM_EVENT_TYPE_ENTER_NIDS = 19,
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
*/
62
iJVM_EVENT_TYPE_LEAVE_NIDS
63
} iJIT_JVM_EVENT;
64
65
typedef enum _iJIT_ModeFlags
66
{
67
/* No need to Notify VTune, since VTune is not running */
68
iJIT_NO_NOTIFICATIONS = 0x0000,
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
*/
77
iJIT_BE_NOTIFY_ON_LOAD = 0x0001,
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
*/
85
iJIT_BE_NOTIFY_ON_UNLOAD = 0x0002,
86
87
/* when turned on the jit must instrument all
88
* the currently jited code with calls on
89
* method entries
90
*/
91
iJIT_BE_NOTIFY_ON_METHOD_ENTRY = 0x0004,
92
93
/* when turned on the jit must instrument all
94
* the currently jited code with calls
95
* on method exit
96
*/
97
iJIT_BE_NOTIFY_ON_METHOD_EXIT = 0x0008
98
99
} iJIT_ModeFlags;
100
101
102
/* Flags used by iJIT_IsProfilingActive() */
103
typedef enum _iJIT_IsProfilingActiveFlags
104
{
105
/* No profiler is running. Currently not used */
106
iJIT_NOTHING_RUNNING = 0x0000,
107
108
/* Sampling is running. This is the default value
109
* returned by iJIT_IsProfilingActive()
110
*/
111
iJIT_SAMPLING_ON = 0x0001,
112
113
/* Call Graph is running */
114
iJIT_CALLGRAPH_ON = 0x0002
115
116
} iJIT_IsProfilingActiveFlags;
117
118
/* Enumerator for the environment of methods*/
119
typedef enum _iJDEnvironmentType
120
{
121
iJDE_JittingAPI = 2
122
} iJDEnvironmentType;
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
139
} *piJIT_Method_Id, iJIT_Method_Id;
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;
158
} *piJIT_Method_NIDS, iJIT_Method_NIDS;
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
172
} *pLineNumberInfo, LineNumberInfo;
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
*/
187
void* method_load_address;
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 */
196
pLineNumberInfo line_number_table;
197
198
/* unique class ID */
199
unsigned int class_id;
200
201
/* class file name */
202
char* class_file_name;
203
204
/* source file name */
205
char* 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 */
214
iJDEnvironmentType env;
215
216
} *piJIT_Method_Load, iJIT_Method_Load;
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
246
iJIT_IsProfilingActiveFlags JITAPI iJIT_IsProfilingActive(void);
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__ */
259
260