jitprofiling.h 30 KB

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