jitprofiling.h 32 KB

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