Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* |
michael@0 | 2 | This file is provided under a dual BSD/GPLv2 license. When using or |
michael@0 | 3 | redistributing this file, you may do so under either license. |
michael@0 | 4 | |
michael@0 | 5 | GPL LICENSE SUMMARY |
michael@0 | 6 | |
michael@0 | 7 | Copyright (c) 2005-2013 Intel Corporation. All rights reserved. |
michael@0 | 8 | |
michael@0 | 9 | This program is free software; you can redistribute it and/or modify |
michael@0 | 10 | it under the terms of version 2 of the GNU General Public License as |
michael@0 | 11 | published by the Free Software Foundation. |
michael@0 | 12 | |
michael@0 | 13 | This program is distributed in the hope that it will be useful, but |
michael@0 | 14 | WITHOUT ANY WARRANTY; without even the implied warranty of |
michael@0 | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
michael@0 | 16 | General Public License for more details. |
michael@0 | 17 | |
michael@0 | 18 | You should have received a copy of the GNU General Public License |
michael@0 | 19 | along with this program; if not, write to the Free Software |
michael@0 | 20 | Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. |
michael@0 | 21 | The full GNU General Public License is included in this distribution |
michael@0 | 22 | in the file called LICENSE.GPL. |
michael@0 | 23 | |
michael@0 | 24 | Contact Information: |
michael@0 | 25 | http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/ |
michael@0 | 26 | |
michael@0 | 27 | BSD LICENSE |
michael@0 | 28 | |
michael@0 | 29 | Copyright (c) 2005-2013 Intel Corporation. All rights reserved. |
michael@0 | 30 | All rights reserved. |
michael@0 | 31 | |
michael@0 | 32 | Redistribution and use in source and binary forms, with or without |
michael@0 | 33 | modification, are permitted provided that the following conditions |
michael@0 | 34 | are met: |
michael@0 | 35 | |
michael@0 | 36 | * Redistributions of source code must retain the above copyright |
michael@0 | 37 | notice, this list of conditions and the following disclaimer. |
michael@0 | 38 | * Redistributions in binary form must reproduce the above copyright |
michael@0 | 39 | notice, this list of conditions and the following disclaimer in |
michael@0 | 40 | the documentation and/or other materials provided with the |
michael@0 | 41 | distribution. |
michael@0 | 42 | * Neither the name of Intel Corporation nor the names of its |
michael@0 | 43 | contributors may be used to endorse or promote products derived |
michael@0 | 44 | from this software without specific prior written permission. |
michael@0 | 45 | |
michael@0 | 46 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
michael@0 | 47 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
michael@0 | 48 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
michael@0 | 49 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
michael@0 | 50 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
michael@0 | 51 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
michael@0 | 52 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
michael@0 | 53 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
michael@0 | 54 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
michael@0 | 55 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
michael@0 | 56 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
michael@0 | 57 | */ |
michael@0 | 58 | |
michael@0 | 59 | #ifndef __JITPROFILING_H__ |
michael@0 | 60 | #define __JITPROFILING_H__ |
michael@0 | 61 | |
michael@0 | 62 | /** |
michael@0 | 63 | * @brief JIT Profiling APIs |
michael@0 | 64 | * |
michael@0 | 65 | * The JIT Profiling API is used to report information about just-in-time |
michael@0 | 66 | * generated code that can be used by performance tools. The user inserts |
michael@0 | 67 | * calls in the code generator to report information before JIT-compiled |
michael@0 | 68 | * code goes to execution. This information is collected at runtime and used |
michael@0 | 69 | * by tools like Intel(R) VTune(TM) Amplifier to display performance metrics |
michael@0 | 70 | * associated with JIT-compiled code. |
michael@0 | 71 | * |
michael@0 | 72 | * These APIs can be used to\n |
michael@0 | 73 | * **Profile trace-based and method-based JIT-compiled |
michael@0 | 74 | * code**. Some examples of environments that you can profile with this APIs: |
michael@0 | 75 | * dynamic JIT compilation of JavaScript code traces, OpenCL JIT execution, |
michael@0 | 76 | * Java/.NET managed execution environments, and custom ISV JIT engines. |
michael@0 | 77 | * |
michael@0 | 78 | * @code |
michael@0 | 79 | * #include <jitprofiling.h> |
michael@0 | 80 | * |
michael@0 | 81 | * if (iJIT_IsProfilingActive != iJIT_SAMPLING_ON) { |
michael@0 | 82 | * return; |
michael@0 | 83 | * } |
michael@0 | 84 | * |
michael@0 | 85 | * iJIT_Method_Load jmethod = {0}; |
michael@0 | 86 | * jmethod.method_id = iJIT_GetNewMethodID(); |
michael@0 | 87 | * jmethod.method_name = "method_name"; |
michael@0 | 88 | * jmethod.class_file_name = "class_name"; |
michael@0 | 89 | * jmethod.source_file_name = "source_file_name"; |
michael@0 | 90 | * jmethod.method_load_address = code_addr; |
michael@0 | 91 | * jmethod.method_size = code_size; |
michael@0 | 92 | * |
michael@0 | 93 | * iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED, (void*)&jmethod); |
michael@0 | 94 | * iJIT_NotifyEvent(iJVM_EVENT_TYPE_SHUTDOWN, NULL); |
michael@0 | 95 | * @endcode |
michael@0 | 96 | * |
michael@0 | 97 | * * Expected behaviour: |
michael@0 | 98 | * * If any iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED event overwrites |
michael@0 | 99 | * already reported method, then such a method becomes invalid and its |
michael@0 | 100 | * memory region is treated as unloaded. VTune Amplifier displays the metrics |
michael@0 | 101 | * collected by the method until it is overwritten. |
michael@0 | 102 | * * If supplied line number information contains multiple source lines for |
michael@0 | 103 | * the same assembly instruction (code location), then VTune Amplifier picks up |
michael@0 | 104 | * the first line number. |
michael@0 | 105 | * * Dynamically generated code can be associated with a module name. |
michael@0 | 106 | * Use the iJIT_Method_Load_V2 structure.\n |
michael@0 | 107 | * Clarification of some cases:\n |
michael@0 | 108 | * * If you register a function with the same method ID multiple times |
michael@0 | 109 | * specifying different module names, then the VTune Amplifier picks up |
michael@0 | 110 | * the module name registered first. If you want to distinguish the same |
michael@0 | 111 | * function between different JIT engines, supply different method IDs for |
michael@0 | 112 | * each function. Other symbolic information (for example, source file) |
michael@0 | 113 | * can be identical. |
michael@0 | 114 | * |
michael@0 | 115 | * **Analyze split functions** (multiple joint or disjoint code regions |
michael@0 | 116 | * belonging to the same function) **including re-JIT** |
michael@0 | 117 | * with potential overlapping of code regions in time, which is common in |
michael@0 | 118 | * resource-limited environments. |
michael@0 | 119 | * @code |
michael@0 | 120 | * #include <jitprofiling.h> |
michael@0 | 121 | * |
michael@0 | 122 | * unsigned int method_id = iJIT_GetNewMethodID(); |
michael@0 | 123 | * |
michael@0 | 124 | * iJIT_Method_Load a = {0}; |
michael@0 | 125 | * a.method_id = method_id; |
michael@0 | 126 | * a.method_load_address = acode_addr; |
michael@0 | 127 | * a.method_size = acode_size; |
michael@0 | 128 | * |
michael@0 | 129 | * iJIT_Method_Load b = {0}; |
michael@0 | 130 | * b.method_id = method_id; |
michael@0 | 131 | * b.method_load_address = baddr_second; |
michael@0 | 132 | * b.method_size = bsize_second; |
michael@0 | 133 | * |
michael@0 | 134 | * iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED, (void*)&a); |
michael@0 | 135 | * iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED, (void*)&b); |
michael@0 | 136 | * @endcode |
michael@0 | 137 | * |
michael@0 | 138 | * * Expected behaviour: |
michael@0 | 139 | * * If a iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED event overwrites |
michael@0 | 140 | * already reported method, then such a method becomes invalid and |
michael@0 | 141 | * its memory region is treated as unloaded. |
michael@0 | 142 | * * All code regions reported with the same method ID are considered as |
michael@0 | 143 | * belonging to the same method. Symbolic information (method name, |
michael@0 | 144 | * source file name) will be taken from the first notification, all |
michael@0 | 145 | * subsequent notifications with the same method ID will be processed |
michael@0 | 146 | * only for line number table information. So, the VTune Amplifier will map |
michael@0 | 147 | * samples to a source line using the line number table from the current |
michael@0 | 148 | * notification while taking source file name from the very first one.\n |
michael@0 | 149 | * Clarification of some cases:\n |
michael@0 | 150 | * * If you register a second code region with a different source file |
michael@0 | 151 | * name and the same method ID, then this information will be saved and |
michael@0 | 152 | * will not be considered as an extension of the first code region, but |
michael@0 | 153 | * VTune Amplifier will use source file of the first code region and map |
michael@0 | 154 | * performance metrics incorrectly. |
michael@0 | 155 | * * If you register a second code region with the same source file as |
michael@0 | 156 | * for the first region and the same method ID, then source file will be |
michael@0 | 157 | * discarded but VTune Amplifier will map metrics to the source file correctly. |
michael@0 | 158 | * * If you register a second code region with a null source file and |
michael@0 | 159 | * the same method ID, then provided line number info will be associated |
michael@0 | 160 | * with the source file of the first code region. |
michael@0 | 161 | * |
michael@0 | 162 | * **Explore inline functions** including multi-level hierarchy of |
michael@0 | 163 | * nested inlines to see how performance metrics are distributed through them. |
michael@0 | 164 | * |
michael@0 | 165 | * @code |
michael@0 | 166 | * #include <jitprofiling.h> |
michael@0 | 167 | * |
michael@0 | 168 | * // method_id parent_id |
michael@0 | 169 | * // [-- c --] 3000 2000 |
michael@0 | 170 | * // [---- d -----] 2001 1000 |
michael@0 | 171 | * // [---- b ----] 2000 1000 |
michael@0 | 172 | * // [------------ a ----------------] 1000 n/a |
michael@0 | 173 | * |
michael@0 | 174 | * iJIT_Method_Load a = {0}; |
michael@0 | 175 | * a.method_id = 1000; |
michael@0 | 176 | * |
michael@0 | 177 | * iJIT_Method_Inline_Load b = {0}; |
michael@0 | 178 | * b.method_id = 2000; |
michael@0 | 179 | * b.parent_method_id = 1000; |
michael@0 | 180 | * |
michael@0 | 181 | * iJIT_Method_Inline_Load c = {0}; |
michael@0 | 182 | * c.method_id = 3000; |
michael@0 | 183 | * c.parent_method_id = 2000; |
michael@0 | 184 | * |
michael@0 | 185 | * iJIT_Method_Inline_Load d = {0}; |
michael@0 | 186 | * d.method_id = 2001; |
michael@0 | 187 | * d.parent_method_id = 1000; |
michael@0 | 188 | * |
michael@0 | 189 | * iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED, (void*)&a); |
michael@0 | 190 | * iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_INLINE_LOAD_FINISHED, (void*)&b); |
michael@0 | 191 | * iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_INLINE_LOAD_FINISHED, (void*)&c); |
michael@0 | 192 | * iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_INLINE_LOAD_FINISHED, (void*)&d); |
michael@0 | 193 | * @endcode |
michael@0 | 194 | * |
michael@0 | 195 | * * Requirements: |
michael@0 | 196 | * * Each inline (iJIT_Method_Inline_Load) method should be associated |
michael@0 | 197 | * with two method IDs: one for itself, one for its immediate parent. |
michael@0 | 198 | * * Address regions of inline methods of the same parent method cannot |
michael@0 | 199 | * overlap each other. |
michael@0 | 200 | * * Execution of the parent method must not be started until it and all |
michael@0 | 201 | * its inlines are reported. |
michael@0 | 202 | * * Expected behaviour: |
michael@0 | 203 | * * In case of nested inlines an order of |
michael@0 | 204 | * iJVM_EVENT_TYPE_METHOD_INLINE_LOAD_FINISHED events is not important. |
michael@0 | 205 | * * If any event overwrites either inline method or top parent method, |
michael@0 | 206 | * then the parent including inlines becomes invalid and its memory |
michael@0 | 207 | * region is treated as unloaded. |
michael@0 | 208 | * |
michael@0 | 209 | * **Life time of allocated data**\n |
michael@0 | 210 | * The client sends an event notification to the agent with event-specific |
michael@0 | 211 | * data, which is a structure. The pointers in the structure refers to memory |
michael@0 | 212 | * allocated by the client, which responsible for releasing it. The pointers are |
michael@0 | 213 | * used by the iJIT_NotifyEvent method to copy client's data in a trace file |
michael@0 | 214 | * and they are not used after the iJIT_NotifyEvent method returns. |
michael@0 | 215 | * |
michael@0 | 216 | */ |
michael@0 | 217 | |
michael@0 | 218 | /** |
michael@0 | 219 | * @defgroup jitapi JIT Profiling |
michael@0 | 220 | * @ingroup internal |
michael@0 | 221 | * @{ |
michael@0 | 222 | */ |
michael@0 | 223 | |
michael@0 | 224 | /** |
michael@0 | 225 | * @enum iJIT_jvm_event |
michael@0 | 226 | * @brief Enumerator for the types of notifications |
michael@0 | 227 | */ |
michael@0 | 228 | typedef enum iJIT_jvm_event |
michael@0 | 229 | { |
michael@0 | 230 | iJVM_EVENT_TYPE_SHUTDOWN = 2, /**< Send to shutdown the agent. |
michael@0 | 231 | * Use NULL for event data. */ |
michael@0 | 232 | |
michael@0 | 233 | iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED = 13, /**< Send when a dynamic code is |
michael@0 | 234 | * JIT compiled and loaded into |
michael@0 | 235 | * memory by the JIT engine but |
michael@0 | 236 | * before the code is executed. |
michael@0 | 237 | * Use iJIT_Method_Load as event |
michael@0 | 238 | * data. */ |
michael@0 | 239 | /** @cond exclude_from_documentation */ |
michael@0 | 240 | iJVM_EVENT_TYPE_METHOD_UNLOAD_START, /**< Send when a compiled dynamic |
michael@0 | 241 | * code is being unloaded from memory. |
michael@0 | 242 | * Use iJIT_Method_Load as event data.*/ |
michael@0 | 243 | /** @endcond */ |
michael@0 | 244 | |
michael@0 | 245 | //TODO: add a note that line info assumes from method load |
michael@0 | 246 | iJVM_EVENT_TYPE_METHOD_UPDATE, /**< Send to provide a new content for |
michael@0 | 247 | * an early reported dynamic code. |
michael@0 | 248 | * The previous content will be invalidate |
michael@0 | 249 | * starting from time of the notification. |
michael@0 | 250 | * Use iJIT_Method_Load as event data but |
michael@0 | 251 | * required fields are following: |
michael@0 | 252 | * - method_id identify the code to update. |
michael@0 | 253 | * - method_load_address specify start address |
michael@0 | 254 | * within identified code range |
michael@0 | 255 | * where update should be started. |
michael@0 | 256 | * - method_size specify length of updated code |
michael@0 | 257 | * range. */ |
michael@0 | 258 | |
michael@0 | 259 | iJVM_EVENT_TYPE_METHOD_INLINE_LOAD_FINISHED, /**< Send when an inline dynamic |
michael@0 | 260 | * code is JIT compiled and loaded |
michael@0 | 261 | * into memory by the JIT engine |
michael@0 | 262 | * but before the parent code region |
michael@0 | 263 | * is started executing. |
michael@0 | 264 | * Use iJIT_Method_Inline_Load as event data.*/ |
michael@0 | 265 | |
michael@0 | 266 | /** @cond exclude_from_documentation */ |
michael@0 | 267 | /* Legacy stuff. Do not use it. */ |
michael@0 | 268 | iJVM_EVENT_TYPE_ENTER_NIDS = 19, |
michael@0 | 269 | iJVM_EVENT_TYPE_LEAVE_NIDS, |
michael@0 | 270 | /** @endcond */ |
michael@0 | 271 | |
michael@0 | 272 | iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED_V2 /**< Send when a dynamic code is |
michael@0 | 273 | * JIT compiled and loaded into |
michael@0 | 274 | * memory by the JIT engine but |
michael@0 | 275 | * before the code is executed. |
michael@0 | 276 | * Use iJIT_Method_Load_V2 as event |
michael@0 | 277 | * data. */ |
michael@0 | 278 | } iJIT_JVM_EVENT; |
michael@0 | 279 | |
michael@0 | 280 | /** @cond exclude_from_documentation */ |
michael@0 | 281 | /* Legacy stuff. Do not use it. */ |
michael@0 | 282 | typedef enum _iJIT_ModeFlags |
michael@0 | 283 | { |
michael@0 | 284 | iJIT_NO_NOTIFICATIONS = 0x0000, |
michael@0 | 285 | iJIT_BE_NOTIFY_ON_LOAD = 0x0001, |
michael@0 | 286 | iJIT_BE_NOTIFY_ON_UNLOAD = 0x0002, |
michael@0 | 287 | iJIT_BE_NOTIFY_ON_METHOD_ENTRY = 0x0004, |
michael@0 | 288 | iJIT_BE_NOTIFY_ON_METHOD_EXIT = 0x0008 |
michael@0 | 289 | |
michael@0 | 290 | } iJIT_ModeFlags; |
michael@0 | 291 | /** @endcond */ |
michael@0 | 292 | |
michael@0 | 293 | /** |
michael@0 | 294 | * @enum _iJIT_IsProfilingActiveFlags |
michael@0 | 295 | * @brief Enumerator for the agent's mode |
michael@0 | 296 | */ |
michael@0 | 297 | typedef enum _iJIT_IsProfilingActiveFlags |
michael@0 | 298 | { |
michael@0 | 299 | iJIT_NOTHING_RUNNING = 0x0000, /**< The agent is not running. |
michael@0 | 300 | * iJIT_NotifyEvent calls will |
michael@0 | 301 | * not be processed. */ |
michael@0 | 302 | iJIT_SAMPLING_ON = 0x0001, /**< The agent is running and |
michael@0 | 303 | * ready to process notifications. */ |
michael@0 | 304 | |
michael@0 | 305 | /** @cond exclude_from_documentation */ |
michael@0 | 306 | /* Legacy. Call Graph is running */ |
michael@0 | 307 | iJIT_CALLGRAPH_ON = 0x0002 |
michael@0 | 308 | /** @endcond */ |
michael@0 | 309 | |
michael@0 | 310 | } iJIT_IsProfilingActiveFlags; |
michael@0 | 311 | |
michael@0 | 312 | /** @cond exclude_from_documentation */ |
michael@0 | 313 | /* Legacy stuff. Do not use it. */ |
michael@0 | 314 | typedef enum _iJDEnvironmentType |
michael@0 | 315 | { |
michael@0 | 316 | iJDE_JittingAPI = 2 |
michael@0 | 317 | |
michael@0 | 318 | } iJDEnvironmentType; |
michael@0 | 319 | |
michael@0 | 320 | typedef struct _iJIT_Method_Id |
michael@0 | 321 | { |
michael@0 | 322 | unsigned int method_id; |
michael@0 | 323 | |
michael@0 | 324 | } *piJIT_Method_Id, iJIT_Method_Id; |
michael@0 | 325 | |
michael@0 | 326 | typedef struct _iJIT_Method_NIDS |
michael@0 | 327 | { |
michael@0 | 328 | unsigned int method_id; /**< Unique method ID */ |
michael@0 | 329 | unsigned int stack_id; /**< NOTE: no need to fill this field, |
michael@0 | 330 | * it's filled by VTune Amplifier */ |
michael@0 | 331 | char* method_name; /**< Method name (just the method, without the class) */ |
michael@0 | 332 | |
michael@0 | 333 | } *piJIT_Method_NIDS, iJIT_Method_NIDS; |
michael@0 | 334 | /** @endcond */ |
michael@0 | 335 | |
michael@0 | 336 | typedef enum _iJIT_CodeType |
michael@0 | 337 | { |
michael@0 | 338 | iJIT_CT_UNKNOWN = 0, |
michael@0 | 339 | iJIT_CT_CODE, // executable code |
michael@0 | 340 | iJIT_CT_DATA, // this kind of “update” will be excluded from the function’s body. |
michael@0 | 341 | iJIT_CT_EOF |
michael@0 | 342 | } iJIT_CodeType; |
michael@0 | 343 | |
michael@0 | 344 | typedef struct _iJIT_Method_Update |
michael@0 | 345 | { |
michael@0 | 346 | unsigned int method_id; |
michael@0 | 347 | void* load_address; |
michael@0 | 348 | unsigned int size; |
michael@0 | 349 | iJIT_CodeType type; |
michael@0 | 350 | |
michael@0 | 351 | } *piJIT_Method_Update, iJIT_Method_Update; |
michael@0 | 352 | |
michael@0 | 353 | /** |
michael@0 | 354 | * @details Describes a single entry in the line number information of |
michael@0 | 355 | * a code region that gives information about how the reported code region |
michael@0 | 356 | * is mapped to source file. |
michael@0 | 357 | * Intel(R) VTune(TM) Amplifier uses line number information to attribute |
michael@0 | 358 | * the samples (virtual address) to a line number. \n |
michael@0 | 359 | * It is acceptable to report different code addresses for the same source line: |
michael@0 | 360 | * @code |
michael@0 | 361 | * Offset LineNumber |
michael@0 | 362 | * 1 2 |
michael@0 | 363 | * 12 4 |
michael@0 | 364 | * 15 2 |
michael@0 | 365 | * 18 1 |
michael@0 | 366 | * 21 30 |
michael@0 | 367 | * |
michael@0 | 368 | * VTune(TM) Amplifier XE contsructs the following table using the client data |
michael@0 | 369 | * |
michael@0 | 370 | * Code subrange Line number |
michael@0 | 371 | * 0-1 2 |
michael@0 | 372 | * 1-12 4 |
michael@0 | 373 | * 12-15 2 |
michael@0 | 374 | * 15-18 1 |
michael@0 | 375 | * 18-21 30 |
michael@0 | 376 | * @endcode |
michael@0 | 377 | */ |
michael@0 | 378 | typedef struct _LineNumberInfo |
michael@0 | 379 | { |
michael@0 | 380 | unsigned int Offset; /**< Offset from the begining of the code region. */ |
michael@0 | 381 | unsigned int LineNumber; /**< Matching source line number offset (from beginning of source file). */ |
michael@0 | 382 | |
michael@0 | 383 | } *pLineNumberInfo, LineNumberInfo; |
michael@0 | 384 | |
michael@0 | 385 | /** |
michael@0 | 386 | * Description of a JIT-compiled method |
michael@0 | 387 | */ |
michael@0 | 388 | typedef struct _iJIT_Method_Load |
michael@0 | 389 | { |
michael@0 | 390 | unsigned int method_id; /**< Unique method ID. |
michael@0 | 391 | * Method ID cannot be smaller than 999. |
michael@0 | 392 | * Either you use the API function |
michael@0 | 393 | * iJIT_GetNewMethodID to get a valid and unique |
michael@0 | 394 | * method ID, or you take care of ID uniqueness |
michael@0 | 395 | * and correct range by yourself.\n |
michael@0 | 396 | * You must use the same method ID for all code |
michael@0 | 397 | * regions of the same method, otherwise different |
michael@0 | 398 | * method IDs mean different methods. */ |
michael@0 | 399 | |
michael@0 | 400 | char* method_name; /** The name of the method. It can be optionally |
michael@0 | 401 | * prefixed with its class name and appended with |
michael@0 | 402 | * its complete signature. Can't be NULL. */ |
michael@0 | 403 | |
michael@0 | 404 | void* method_load_address; /** The start virtual address of the method code |
michael@0 | 405 | * region. If NULL that data provided with |
michael@0 | 406 | * event are not accepted. */ |
michael@0 | 407 | |
michael@0 | 408 | unsigned int method_size; /** The code size of the method in memory. |
michael@0 | 409 | * If 0, then data provided with the event are not |
michael@0 | 410 | * accepted. */ |
michael@0 | 411 | |
michael@0 | 412 | unsigned int line_number_size; /** The number of entries in the line number |
michael@0 | 413 | * table.0 if none. */ |
michael@0 | 414 | |
michael@0 | 415 | pLineNumberInfo line_number_table; /** Pointer to the line numbers info |
michael@0 | 416 | * array. Can be NULL if |
michael@0 | 417 | * line_number_size is 0. See |
michael@0 | 418 | * LineNumberInfo Structure for a |
michael@0 | 419 | * description of a single entry in |
michael@0 | 420 | * the line number info array */ |
michael@0 | 421 | |
michael@0 | 422 | unsigned int class_id; /** This field is obsolete. */ |
michael@0 | 423 | |
michael@0 | 424 | char* class_file_name; /** Class name. Can be NULL.*/ |
michael@0 | 425 | |
michael@0 | 426 | char* source_file_name; /** Source file name. Can be NULL.*/ |
michael@0 | 427 | |
michael@0 | 428 | void* user_data; /** This field is obsolete. */ |
michael@0 | 429 | |
michael@0 | 430 | unsigned int user_data_size; /** This field is obsolete. */ |
michael@0 | 431 | |
michael@0 | 432 | iJDEnvironmentType env; /** This field is obsolete. */ |
michael@0 | 433 | |
michael@0 | 434 | } *piJIT_Method_Load, iJIT_Method_Load; |
michael@0 | 435 | |
michael@0 | 436 | #pragma pack(push, 8) |
michael@0 | 437 | /** |
michael@0 | 438 | * Description of a JIT-compiled method |
michael@0 | 439 | * |
michael@0 | 440 | * When you use the iJIT_Method_Load_V2 structure to describe |
michael@0 | 441 | * the JIT compiled method, use iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED_V2 |
michael@0 | 442 | * as an event type to report it. |
michael@0 | 443 | */ |
michael@0 | 444 | typedef struct _iJIT_Method_Load_V2 |
michael@0 | 445 | { |
michael@0 | 446 | unsigned int method_id; /**< Unique method ID. |
michael@0 | 447 | * Method ID cannot be smaller than 999. |
michael@0 | 448 | * Either you use the API function |
michael@0 | 449 | * iJIT_GetNewMethodID to get a valid and unique |
michael@0 | 450 | * method ID, or you take care of ID uniqueness |
michael@0 | 451 | * and correct range by yourself.\n |
michael@0 | 452 | * You must use the same method ID for all code |
michael@0 | 453 | * regions of the same method, otherwise different |
michael@0 | 454 | * method IDs mean different methods. */ |
michael@0 | 455 | |
michael@0 | 456 | char* method_name; /** The name of the method. It can be optionally |
michael@0 | 457 | * prefixed with its class name and appended with |
michael@0 | 458 | * its complete signature. Can't be NULL. */ |
michael@0 | 459 | |
michael@0 | 460 | void* method_load_address; /** The start virtual address of the method code |
michael@0 | 461 | * region. If NULL that data provided with |
michael@0 | 462 | * event are not accepted. */ |
michael@0 | 463 | |
michael@0 | 464 | unsigned int method_size; /** The code size of the method in memory. |
michael@0 | 465 | * If 0, then data provided with the event are not |
michael@0 | 466 | * accepted. */ |
michael@0 | 467 | |
michael@0 | 468 | unsigned int line_number_size; /** The number of entries in the line number |
michael@0 | 469 | * table.0 if none. */ |
michael@0 | 470 | |
michael@0 | 471 | pLineNumberInfo line_number_table; /** Pointer to the line numbers info |
michael@0 | 472 | * array. Can be NULL if |
michael@0 | 473 | * line_number_size is 0. See |
michael@0 | 474 | * LineNumberInfo Structure for a |
michael@0 | 475 | * description of a single entry in |
michael@0 | 476 | * the line number info array */ |
michael@0 | 477 | |
michael@0 | 478 | char* class_file_name; /** Class name. Can be NULL.*/ |
michael@0 | 479 | |
michael@0 | 480 | char* source_file_name; /** Source file name. Can be NULL.*/ |
michael@0 | 481 | |
michael@0 | 482 | char* module_name; /** Module name. Can be NULL. |
michael@0 | 483 | The module name can be useful for distinguishing among |
michael@0 | 484 | different JIT engines. Intel VTune Amplifier will display |
michael@0 | 485 | reported methods split by specified modules */ |
michael@0 | 486 | |
michael@0 | 487 | } *piJIT_Method_Load_V2, iJIT_Method_Load_V2; |
michael@0 | 488 | #pragma pack(pop) |
michael@0 | 489 | |
michael@0 | 490 | /** |
michael@0 | 491 | * Description of an inline JIT-compiled method |
michael@0 | 492 | */ |
michael@0 | 493 | typedef struct _iJIT_Method_Inline_Load |
michael@0 | 494 | { |
michael@0 | 495 | unsigned int method_id; /**< Unique method ID. |
michael@0 | 496 | * Method ID cannot be smaller than 999. |
michael@0 | 497 | * Either you use the API function |
michael@0 | 498 | * iJIT_GetNewMethodID to get a valid and unique |
michael@0 | 499 | * method ID, or you take care of ID uniqueness |
michael@0 | 500 | * and correct range by yourself. */ |
michael@0 | 501 | |
michael@0 | 502 | unsigned int parent_method_id; /** Unique immediate parent's method ID. |
michael@0 | 503 | * Method ID may not be smaller than 999. |
michael@0 | 504 | * Either you use the API function |
michael@0 | 505 | * iJIT_GetNewMethodID to get a valid and unique |
michael@0 | 506 | * method ID, or you take care of ID uniqueness |
michael@0 | 507 | * and correct range by yourself. */ |
michael@0 | 508 | |
michael@0 | 509 | char* method_name; /** The name of the method. It can be optionally |
michael@0 | 510 | * prefixed with its class name and appended with |
michael@0 | 511 | * its complete signature. Can't be NULL. */ |
michael@0 | 512 | |
michael@0 | 513 | void* method_load_address; /** The virtual address on which the method |
michael@0 | 514 | * is inlined. If NULL, then data provided with |
michael@0 | 515 | * the event are not accepted. */ |
michael@0 | 516 | |
michael@0 | 517 | unsigned int method_size; /** The code size of the method in memory. |
michael@0 | 518 | * If 0 that data provided with event are not |
michael@0 | 519 | * accepted. */ |
michael@0 | 520 | |
michael@0 | 521 | unsigned int line_number_size; /** The number of entries in the line number |
michael@0 | 522 | * table. 0 if none. */ |
michael@0 | 523 | |
michael@0 | 524 | pLineNumberInfo line_number_table; /** Pointer to the line numbers info |
michael@0 | 525 | * array. Can be NULL if |
michael@0 | 526 | * line_number_size is 0. See |
michael@0 | 527 | * LineNumberInfo Structure for a |
michael@0 | 528 | * description of a single entry in |
michael@0 | 529 | * the line number info array */ |
michael@0 | 530 | |
michael@0 | 531 | char* class_file_name; /** Class name. Can be NULL.*/ |
michael@0 | 532 | |
michael@0 | 533 | char* source_file_name; /** Source file name. Can be NULL.*/ |
michael@0 | 534 | |
michael@0 | 535 | } *piJIT_Method_Inline_Load, iJIT_Method_Inline_Load; |
michael@0 | 536 | |
michael@0 | 537 | /** @cond exclude_from_documentation */ |
michael@0 | 538 | #ifdef __cplusplus |
michael@0 | 539 | extern "C" { |
michael@0 | 540 | #endif /* __cplusplus */ |
michael@0 | 541 | |
michael@0 | 542 | #ifndef CDECL |
michael@0 | 543 | # if defined WIN32 || defined _WIN32 |
michael@0 | 544 | # define CDECL __cdecl |
michael@0 | 545 | # else /* defined WIN32 || defined _WIN32 */ |
michael@0 | 546 | # if defined _M_X64 || defined _M_AMD64 || defined __x86_64__ |
michael@0 | 547 | # define CDECL /* not actual on x86_64 platform */ |
michael@0 | 548 | # else /* _M_X64 || _M_AMD64 || __x86_64__ */ |
michael@0 | 549 | # define CDECL __attribute__ ((cdecl)) |
michael@0 | 550 | # endif /* _M_X64 || _M_AMD64 || __x86_64__ */ |
michael@0 | 551 | # endif /* defined WIN32 || defined _WIN32 */ |
michael@0 | 552 | #endif /* CDECL */ |
michael@0 | 553 | |
michael@0 | 554 | #define JITAPI CDECL |
michael@0 | 555 | /** @endcond */ |
michael@0 | 556 | |
michael@0 | 557 | /** |
michael@0 | 558 | * @brief Generates a new unique method ID. |
michael@0 | 559 | * |
michael@0 | 560 | * You must use this API to obtain unique and valid method IDs for methods or |
michael@0 | 561 | * traces reported to the agent if you don't have you own mechanism to generate |
michael@0 | 562 | * unique method IDs. |
michael@0 | 563 | * |
michael@0 | 564 | * @return a new unique method ID. When out of unique method IDs, this API |
michael@0 | 565 | * returns 0, which is not an accepted value. |
michael@0 | 566 | */ |
michael@0 | 567 | unsigned int JITAPI iJIT_GetNewMethodID(void); |
michael@0 | 568 | |
michael@0 | 569 | /** |
michael@0 | 570 | * @brief Returns the current mode of the agent. |
michael@0 | 571 | * |
michael@0 | 572 | * @return iJIT_SAMPLING_ON, indicating that agent is running, or |
michael@0 | 573 | * iJIT_NOTHING_RUNNING if no agent is running. |
michael@0 | 574 | */ |
michael@0 | 575 | iJIT_IsProfilingActiveFlags JITAPI iJIT_IsProfilingActive(void); |
michael@0 | 576 | |
michael@0 | 577 | /** |
michael@0 | 578 | * @brief Reports infomation about JIT-compiled code to the agent. |
michael@0 | 579 | * |
michael@0 | 580 | * The reported information is used to attribute samples obtained from any |
michael@0 | 581 | * Intel(R) VTune(TM) Amplifier collector. This API needs to be called |
michael@0 | 582 | * after JIT compilation and before the first entry into the JIT compiled |
michael@0 | 583 | * code. |
michael@0 | 584 | * |
michael@0 | 585 | * @param[in] event_type - type of the data sent to the agent |
michael@0 | 586 | * @param[in] EventSpecificData - pointer to event-specific data |
michael@0 | 587 | * |
michael@0 | 588 | * @returns 1 on success, otherwise 0. |
michael@0 | 589 | */ |
michael@0 | 590 | int JITAPI iJIT_NotifyEvent(iJIT_JVM_EVENT event_type, void *EventSpecificData); |
michael@0 | 591 | |
michael@0 | 592 | /** @cond exclude_from_documentation */ |
michael@0 | 593 | /* |
michael@0 | 594 | * Do not use these legacy APIs, which are here for backward compatibility |
michael@0 | 595 | * with Intel(R) VTune(TM) Performance Analyzer. |
michael@0 | 596 | */ |
michael@0 | 597 | typedef void (*iJIT_ModeChangedEx)(void *UserData, iJIT_ModeFlags Flags); |
michael@0 | 598 | void JITAPI iJIT_RegisterCallbackEx(void *userdata, |
michael@0 | 599 | iJIT_ModeChangedEx NewModeCallBackFuncEx); |
michael@0 | 600 | void JITAPI FinalizeThread(void); |
michael@0 | 601 | void JITAPI FinalizeProcess(void); |
michael@0 | 602 | |
michael@0 | 603 | #ifdef __cplusplus |
michael@0 | 604 | } |
michael@0 | 605 | #endif /* __cplusplus */ |
michael@0 | 606 | /** @endcond */ |
michael@0 | 607 | |
michael@0 | 608 | /** @} jitapi group */ |
michael@0 | 609 | |
michael@0 | 610 | #endif /* __JITPROFILING_H__ */ |