OLD | NEW |
(Empty) | |
| 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 iJVM_EVENT_TYPE_SHUTDOWN = 2, /* Program exiting |
| 71 * EventSpecificData NA |
| 72 */ |
| 73 |
| 74 |
| 75 /* JIT profiling */ |
| 76 iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED=13, /* issued after method code jit
ted |
| 77 * into memory but before code
is executed |
| 78 * EventSpecificData is an iJIT
_Method_Load |
| 79 */ |
| 80 |
| 81 iJVM_EVENT_TYPE_METHOD_UNLOAD_START, /* issued before unload. Method
code will no |
| 82 * longer be executed, but code
and info |
| 83 * are still in memory. The VTu
ne profiler |
| 84 * may capture method code only
at this point |
| 85 * EventSpecificData is iJIT_Me
thod_Id |
| 86 */ |
| 87 |
| 88 /* Method Profiling */ |
| 89 |
| 90 /* method name, Id and stack is supplied */ |
| 91 iJVM_EVENT_TYPE_ENTER_NIDS = 19, /* issued when a method is abou
t to be entered |
| 92 * EventSpecificData is iJIT_Me
thod_NIDS |
| 93 */ |
| 94 |
| 95 /* method name, Id and stack is supplied */ |
| 96 iJVM_EVENT_TYPE_LEAVE_NIDS /* issued when a method is abou
t to be left |
| 97 * EventSpecificData is iJIT_Me
thod_NIDS |
| 98 */ |
| 99 } iJIT_JVM_EVENT; |
| 100 |
| 101 typedef enum _iJIT_ModeFlags |
| 102 { |
| 103 iJIT_NO_NOTIFICATIONS = 0x0000, /* No need to Notify VTune, |
| 104 * Since VTune is not running |
| 105 */ |
| 106 iJIT_BE_NOTIFY_ON_LOAD = 0x0001, /* when turned on the jit must
call |
| 107 * iJIT_NotifyEvent |
| 108 * ( |
| 109 * iJVM_EVENT_TYPE_METHOD_L
OAD_FINISHED, |
| 110 * ) |
| 111 * for all the method already j
itted |
| 112 */ |
| 113 iJIT_BE_NOTIFY_ON_UNLOAD = 0x0002, /* when turned on the jit must
call |
| 114 * iJIT_NotifyEvent |
| 115 * ( |
| 116 * iJVM_EVENT_TYPE_METHOD_U
NLOAD_FINISHED, |
| 117 * ) for all the method that a
re unloaded |
| 118 */ |
| 119 iJIT_BE_NOTIFY_ON_METHOD_ENTRY = 0x0004, /* when turned on the jit must
instrument all |
| 120 * the currently jited code wit
h calls on |
| 121 * method entries |
| 122 */ |
| 123 iJIT_BE_NOTIFY_ON_METHOD_EXIT = 0x0008 /* when turned on the jit must
instrument all |
| 124 * the currently jited code wit
h calls |
| 125 * on method exit |
| 126 */ |
| 127 } iJIT_ModeFlags; |
| 128 |
| 129 |
| 130 /* Flags used by iJIT_IsProfilingActive() */ |
| 131 typedef enum _iJIT_IsProfilingActiveFlags |
| 132 { |
| 133 iJIT_NOTHING_RUNNING = 0x0000, /* No profiler is running. Curr
ently not used */ |
| 134 iJIT_SAMPLING_ON = 0x0001, /* Sampling is running. This is
the default value |
| 135 * returned by iJIT_IsProfiling
Active() |
| 136 */ |
| 137 iJIT_CALLGRAPH_ON = 0x0002 /* Call Graph is running */ |
| 138 } iJIT_IsProfilingActiveFlags; |
| 139 |
| 140 /* Enumerator for the environment of methods*/ |
| 141 typedef enum _iJDEnvironmentType |
| 142 { |
| 143 iJDE_JittingAPI = 2 |
| 144 } iJDEnvironmentType; |
| 145 |
| 146 /********************************** |
| 147 * Data structures for the events * |
| 148 **********************************/ |
| 149 |
| 150 /* structure for the events: |
| 151 * iJVM_EVENT_TYPE_METHOD_UNLOAD_START |
| 152 */ |
| 153 |
| 154 typedef struct _iJIT_Method_Id |
| 155 { |
| 156 unsigned int method_id; /* Id of the method (same as the
one passed in |
| 157 * the iJIT_Method_Load struct |
| 158 */ |
| 159 |
| 160 } *piJIT_Method_Id, iJIT_Method_Id; |
| 161 |
| 162 |
| 163 /* structure for the events: |
| 164 * iJVM_EVENT_TYPE_ENTER_NIDS, |
| 165 * iJVM_EVENT_TYPE_LEAVE_NIDS, |
| 166 * iJVM_EVENT_TYPE_EXCEPTION_OCCURRED_NIDS |
| 167 */ |
| 168 |
| 169 typedef struct _iJIT_Method_NIDS |
| 170 { |
| 171 unsigned int method_id; /* unique method ID */ |
| 172 unsigned int stack_id; /* NOTE: no need to fill this fie
ld, |
| 173 * it's filled by VTune */ |
| 174 char* method_name; /* method name (just the method, |
| 175 * without the class) |
| 176 */ |
| 177 } *piJIT_Method_NIDS, iJIT_Method_NIDS; |
| 178 |
| 179 /* structures for the events: |
| 180 * iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED |
| 181 */ |
| 182 |
| 183 typedef struct _LineNumberInfo |
| 184 { |
| 185 unsigned int Offset; /* x86 Offset from the begining
of the method*/ |
| 186 unsigned int LineNumber; /* source line number from the b
egining of |
| 187 * the source file |
| 188 */ |
| 189 |
| 190 } *pLineNumberInfo, LineNumberInfo; |
| 191 |
| 192 typedef struct _iJIT_Method_Load |
| 193 { |
| 194 unsigned int method_id; /* unique method ID - can be any
unique value, |
| 195 * (except 0 - 999) |
| 196 */ |
| 197 char* method_name; /* method name (can be with or w
ithout |
| 198 * the class and signature, in a
ny case |
| 199 * the class name will be added
to it) |
| 200 */ |
| 201 void* method_load_address; /* virtual address of that metho
d |
| 202 * - This determines the method
range for the |
| 203 * iJVM_EVENT_TYPE_ENTER/LEAVE_M
ETHOD_ADDR |
| 204 * events |
| 205 */ |
| 206 unsigned int method_size; /* Size in memory - Must be exac
t */ |
| 207 unsigned int line_number_size; /* Line Table size in number of
entries |
| 208 * - Zero if none |
| 209 */ |
| 210 pLineNumberInfo line_number_table; /* Pointer to the begining of th
e line numbers |
| 211 * info array |
| 212 */ |
| 213 unsigned int class_id; /* unique class ID */ |
| 214 char* class_file_name; /* class file name */ |
| 215 char* source_file_name; /* source file name */ |
| 216 void* user_data; /* bits supplied by the user for
saving in |
| 217 * the JIT file |
| 218 */ |
| 219 unsigned int user_data_size; /* the size of the user data buf
fer */ |
| 220 iJDEnvironmentType env; /* NOTE: no need to fill this fi
eld, |
| 221 * it's filled by VTune |
| 222 */ |
| 223 } *piJIT_Method_Load, iJIT_Method_Load; |
| 224 |
| 225 /* API Functions */ |
| 226 #ifdef __cplusplus |
| 227 extern "C" { |
| 228 #endif |
| 229 |
| 230 #ifndef CDECL |
| 231 # if defined WIN32 || defined _WIN32 |
| 232 # define CDECL __cdecl |
| 233 # else /* defined WIN32 || defined _WIN32 */ |
| 234 # if defined _M_X64 || defined _M_AMD64 || defined __x86_64__ |
| 235 # define CDECL /* not actual on x86_64 platform */ |
| 236 # else /* _M_X64 || _M_AMD64 || __x86_64__ */ |
| 237 # define CDECL __attribute__ ((cdecl)) |
| 238 # endif /* _M_X64 || _M_AMD64 || __x86_64__ */ |
| 239 # endif /* defined WIN32 || defined _WIN32 */ |
| 240 #endif /* CDECL */ |
| 241 |
| 242 #define JITAPI CDECL |
| 243 |
| 244 /* called when the settings are changed with new settings */ |
| 245 typedef void (*iJIT_ModeChangedEx)(void *UserData, iJIT_ModeFlags Flags); |
| 246 |
| 247 int JITAPI iJIT_NotifyEvent(iJIT_JVM_EVENT event_type, void *EventSpecificData); |
| 248 |
| 249 /* The new mode call back routine */ |
| 250 void JITAPI iJIT_RegisterCallbackEx(void *userdata, iJIT_ModeChangedEx NewModeCa
llBackFuncEx); |
| 251 |
| 252 iJIT_IsProfilingActiveFlags JITAPI iJIT_IsProfilingActive(void); |
| 253 |
| 254 void JITAPI FinalizeThread(void); |
| 255 |
| 256 void JITAPI FinalizeProcess(void); |
| 257 |
| 258 unsigned int JITAPI iJIT_GetNewMethodID(void); |
| 259 |
| 260 #ifdef __cplusplus |
| 261 } |
| 262 #endif |
| 263 |
| 264 #endif /* __JITPROFILING_H__ */ |
OLD | NEW |