V8 Project
jitprofiling.h
Go to the documentation of this file.
1 /*
2  This file is provided under a dual BSD/GPLv2 license. When using or
3  redistributing this file, you may do so under either license.
4 
5  GPL LICENSE SUMMARY
6 
7  Copyright (c) 2005-2012 Intel Corporation. All rights reserved.
8 
9  This program is free software; you can redistribute it and/or modify
10  it under the terms of version 2 of the GNU General Public License as
11  published by the Free Software Foundation.
12 
13  This program is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21  The full GNU General Public License is included in this distribution
22  in the file called LICENSE.GPL.
23 
24  Contact Information:
25  http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/
26 
27  BSD LICENSE
28 
29  Copyright (c) 2005-2012 Intel Corporation. All rights reserved.
30  All rights reserved.
31 
32  Redistribution and use in source and binary forms, with or without
33  modification, are permitted provided that the following conditions
34  are met:
35 
36  * Redistributions of source code must retain the above copyright
37  notice, this list of conditions and the following disclaimer.
38  * Redistributions in binary form must reproduce the above copyright
39  notice, this list of conditions and the following disclaimer in
40  the documentation and/or other materials provided with the
41  distribution.
42  * Neither the name of Intel Corporation nor the names of its
43  contributors may be used to endorse or promote products derived
44  from this software without specific prior written permission.
45 
46  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
47  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
48  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
49  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
50  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
51  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
52  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
53  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
54  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
55  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
56  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
57 */
58 #ifndef __JITPROFILING_H__
59 #define __JITPROFILING_H__
60 
61 /*
62  * Various constants used by functions
63  */
64 
65 /* event notification */
66 typedef enum iJIT_jvm_event
67 {
68 
69  /* shutdown */
70 
71  /*
72  * Program exiting EventSpecificData NA
73  */
75 
76  /* JIT profiling */
77 
78  /*
79  * issued after method code jitted into memory but before code is executed
80  * EventSpecificData is an iJIT_Method_Load
81  */
83 
84  /* issued before unload. Method code will no longer be executed, but code
85  * and info are still in memory. The VTune profiler may capture method
86  * code only at this point EventSpecificData is iJIT_Method_Id
87  */
89 
90  /* Method Profiling */
91 
92  /* method name, Id and stack is supplied
93  * issued when a method is about to be entered EventSpecificData is
94  * iJIT_Method_NIDS
95  */
97 
98  /* method name, Id and stack is supplied
99  * issued when a method is about to be left EventSpecificData is
100  * iJIT_Method_NIDS
101  */
104 
105 typedef enum _iJIT_ModeFlags
106 {
107  /* No need to Notify VTune, since VTune is not running */
109 
110  /* when turned on the jit must call
111  * iJIT_NotifyEvent
112  * (
113  * iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED,
114  * )
115  * for all the method already jitted
116  */
118 
119  /* when turned on the jit must call
120  * iJIT_NotifyEvent
121  * (
122  * iJVM_EVENT_TYPE_METHOD_UNLOAD_FINISHED,
123  * ) for all the method that are unloaded
124  */
126 
127  /* when turned on the jit must instrument all
128  * the currently jited code with calls on
129  * method entries
130  */
132 
133  /* when turned on the jit must instrument all
134  * the currently jited code with calls
135  * on method exit
136  */
138 
140 
141 
142  /* Flags used by iJIT_IsProfilingActive() */
144 {
145  /* No profiler is running. Currently not used */
147 
148  /* Sampling is running. This is the default value
149  * returned by iJIT_IsProfilingActive()
150  */
152 
153  /* Call Graph is running */
154  iJIT_CALLGRAPH_ON = 0x0002
155 
157 
158 /* Enumerator for the environment of methods*/
160 {
161  iJDE_JittingAPI = 2
163 
164 /**********************************
165  * Data structures for the events *
166  **********************************/
167 
168 /* structure for the events:
169  * iJVM_EVENT_TYPE_METHOD_UNLOAD_START
170  */
171 
172 typedef struct _iJIT_Method_Id
173 {
174  /* Id of the method (same as the one passed in
175  * the iJIT_Method_Load struct
176  */
177  unsigned int method_id;
178 
180 
181 
182 /* structure for the events:
183  * iJVM_EVENT_TYPE_ENTER_NIDS,
184  * iJVM_EVENT_TYPE_LEAVE_NIDS,
185  * iJVM_EVENT_TYPE_EXCEPTION_OCCURRED_NIDS
186  */
187 
188 typedef struct _iJIT_Method_NIDS
189 {
190  /* unique method ID */
191  unsigned int method_id;
192 
193  /* NOTE: no need to fill this field, it's filled by VTune */
194  unsigned int stack_id;
195 
196  /* method name (just the method, without the class) */
197  char* method_name;
199 
200 /* structures for the events:
201  * iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED
202  */
203 
204 typedef struct _LineNumberInfo
205 {
206  /* x86 Offset from the begining of the method*/
207  unsigned int Offset;
208 
209  /* source line number from the begining of the source file */
210  unsigned int LineNumber;
211 
213 
214 typedef struct _iJIT_Method_Load
215 {
216  /* unique method ID - can be any unique value, (except 0 - 999) */
217  unsigned int method_id;
218 
219  /* method name (can be with or without the class and signature, in any case
220  * the class name will be added to it)
221  */
222  char* method_name;
223 
224  /* virtual address of that method - This determines the method range for the
225  * iJVM_EVENT_TYPE_ENTER/LEAVE_METHOD_ADDR events
226  */
228 
229  /* Size in memory - Must be exact */
230  unsigned int method_size;
231 
232  /* Line Table size in number of entries - Zero if none */
233  unsigned int line_number_size;
234 
235  /* Pointer to the begining of the line numbers info array */
237 
238  /* unique class ID */
239  unsigned int class_id;
240 
241  /* class file name */
243 
244  /* source file name */
246 
247  /* bits supplied by the user for saving in the JIT file */
248  void* user_data;
249 
250  /* the size of the user data buffer */
251  unsigned int user_data_size;
252 
253  /* NOTE: no need to fill this field, it's filled by VTune */
255 
257 
258 /* API Functions */
259 #ifdef __cplusplus
260 extern "C" {
261 #endif
262 
263 #ifndef CDECL
264 # if defined WIN32 || defined _WIN32
265 # define CDECL __cdecl
266 # else /* defined WIN32 || defined _WIN32 */
267 # if defined _M_X64 || defined _M_AMD64 || defined __x86_64__
268 # define CDECL /* not actual on x86_64 platform */
269 # else /* _M_X64 || _M_AMD64 || __x86_64__ */
270 # define CDECL __attribute__ ((cdecl))
271 # endif /* _M_X64 || _M_AMD64 || __x86_64__ */
272 # endif /* defined WIN32 || defined _WIN32 */
273 #endif /* CDECL */
274 
275 #define JITAPI CDECL
276 
277 /* called when the settings are changed with new settings */
278 typedef void (*iJIT_ModeChangedEx)(void *UserData, iJIT_ModeFlags Flags);
279 
280 int JITAPI iJIT_NotifyEvent(iJIT_JVM_EVENT event_type, void *EventSpecificData);
281 
282 /* The new mode call back routine */
283 void JITAPI iJIT_RegisterCallbackEx(void *userdata,
284  iJIT_ModeChangedEx NewModeCallBackFuncEx);
285 
287 
288 void JITAPI FinalizeThread(void);
289 
290 void JITAPI FinalizeProcess(void);
291 
292 unsigned int JITAPI iJIT_GetNewMethodID(void);
293 
294 #ifdef __cplusplus
295 }
296 #endif
297 
298 #endif /* __JITPROFILING_H__ */
struct _LineNumberInfo * pLineNumberInfo
int JITAPI iJIT_NotifyEvent(iJIT_JVM_EVENT event_type, void *EventSpecificData)
iJIT_jvm_event
Definition: jitprofiling.h:67
@ iJVM_EVENT_TYPE_ENTER_NIDS
Definition: jitprofiling.h:96
@ iJVM_EVENT_TYPE_LEAVE_NIDS
Definition: jitprofiling.h:102
@ iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED
Definition: jitprofiling.h:82
@ iJVM_EVENT_TYPE_METHOD_UNLOAD_START
Definition: jitprofiling.h:88
@ iJVM_EVENT_TYPE_SHUTDOWN
Definition: jitprofiling.h:74
struct _iJIT_Method_Load * piJIT_Method_Load
_iJIT_ModeFlags
Definition: jitprofiling.h:106
@ iJIT_BE_NOTIFY_ON_METHOD_ENTRY
Definition: jitprofiling.h:131
@ iJIT_BE_NOTIFY_ON_METHOD_EXIT
Definition: jitprofiling.h:137
@ iJIT_BE_NOTIFY_ON_UNLOAD
Definition: jitprofiling.h:125
@ iJIT_BE_NOTIFY_ON_LOAD
Definition: jitprofiling.h:117
@ iJIT_NO_NOTIFICATIONS
Definition: jitprofiling.h:108
unsigned int JITAPI iJIT_GetNewMethodID(void)
void(* iJIT_ModeChangedEx)(void *UserData, iJIT_ModeFlags Flags)
Definition: jitprofiling.h:278
_iJIT_IsProfilingActiveFlags
Definition: jitprofiling.h:144
@ iJIT_NOTHING_RUNNING
Definition: jitprofiling.h:146
@ iJIT_SAMPLING_ON
Definition: jitprofiling.h:151
@ iJIT_CALLGRAPH_ON
Definition: jitprofiling.h:154
#define JITAPI
Definition: jitprofiling.h:275
_iJDEnvironmentType
Definition: jitprofiling.h:160
@ iJDE_JittingAPI
Definition: jitprofiling.h:161
struct _LineNumberInfo LineNumberInfo
enum _iJIT_ModeFlags iJIT_ModeFlags
struct _iJIT_Method_NIDS iJIT_Method_NIDS
void JITAPI FinalizeProcess(void)
enum _iJDEnvironmentType iJDEnvironmentType
struct _iJIT_Method_Id * piJIT_Method_Id
void JITAPI FinalizeThread(void)
enum iJIT_jvm_event iJIT_JVM_EVENT
struct _iJIT_Method_Load iJIT_Method_Load
enum _iJIT_IsProfilingActiveFlags iJIT_IsProfilingActiveFlags
void JITAPI iJIT_RegisterCallbackEx(void *userdata, iJIT_ModeChangedEx NewModeCallBackFuncEx)
struct _iJIT_Method_NIDS * piJIT_Method_NIDS
iJIT_IsProfilingActiveFlags JITAPI iJIT_IsProfilingActive(void)
struct _iJIT_Method_Id iJIT_Method_Id
unsigned int Offset
Definition: jitprofiling.h:207
unsigned int LineNumber
Definition: jitprofiling.h:210
unsigned int method_id
Definition: jitprofiling.h:177
unsigned int line_number_size
Definition: jitprofiling.h:233
iJDEnvironmentType env
Definition: jitprofiling.h:254
unsigned int method_id
Definition: jitprofiling.h:217
unsigned int class_id
Definition: jitprofiling.h:239
pLineNumberInfo line_number_table
Definition: jitprofiling.h:236
unsigned int user_data_size
Definition: jitprofiling.h:251
unsigned int method_size
Definition: jitprofiling.h:230
void * method_load_address
Definition: jitprofiling.h:227
unsigned int method_id
Definition: jitprofiling.h:191
unsigned int stack_id
Definition: jitprofiling.h:194