jitprofiling.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. /*===-- jitprofiling.h - JIT Profiling API-------------------------*- C -*-===*
  2. *
  3. * The LLVM Compiler Infrastructure
  4. *
  5. * This file is distributed under the University of Illinois Open Source
  6. * License. See LICENSE.TXT for details.
  7. *
  8. *===----------------------------------------------------------------------===*
  9. *
  10. * This file provides Intel(R) Performance Analyzer JIT (Just-In-Time)
  11. * Profiling API declaration.
  12. *
  13. * NOTE: This file comes in a style different from the rest of LLVM
  14. * source base since this is a piece of code shared from Intel(R)
  15. * products. Please do not reformat / re-style this code to make
  16. * subsequent merges and contributions from the original source base eaiser.
  17. *
  18. *===----------------------------------------------------------------------===*/
  19. #ifndef __JITPROFILING_H__
  20. #define __JITPROFILING_H__
  21. /*
  22. * Various constants used by functions
  23. */
  24. /* event notification */
  25. typedef enum iJIT_jvm_event
  26. {
  27. /* shutdown */
  28. /*
  29. * Program exiting EventSpecificData NA
  30. */
  31. iJVM_EVENT_TYPE_SHUTDOWN = 2,
  32. /* JIT profiling */
  33. /*
  34. * issued after method code jitted into memory but before code is executed
  35. * EventSpecificData is an iJIT_Method_Load
  36. */
  37. iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED=13,
  38. /* issued before unload. Method code will no longer be executed, but code
  39. * and info are still in memory. The VTune profiler may capture method
  40. * code only at this point EventSpecificData is iJIT_Method_Id
  41. */
  42. iJVM_EVENT_TYPE_METHOD_UNLOAD_START,
  43. /* Method Profiling */
  44. /* method name, Id and stack is supplied
  45. * issued when a method is about to be entered EventSpecificData is
  46. * iJIT_Method_NIDS
  47. */
  48. iJVM_EVENT_TYPE_ENTER_NIDS = 19,
  49. /* method name, Id and stack is supplied
  50. * issued when a method is about to be left EventSpecificData is
  51. * iJIT_Method_NIDS
  52. */
  53. iJVM_EVENT_TYPE_LEAVE_NIDS
  54. } iJIT_JVM_EVENT;
  55. typedef enum _iJIT_ModeFlags
  56. {
  57. /* No need to Notify VTune, since VTune is not running */
  58. iJIT_NO_NOTIFICATIONS = 0x0000,
  59. /* when turned on the jit must call
  60. * iJIT_NotifyEvent
  61. * (
  62. * iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED,
  63. * )
  64. * for all the method already jitted
  65. */
  66. iJIT_BE_NOTIFY_ON_LOAD = 0x0001,
  67. /* when turned on the jit must call
  68. * iJIT_NotifyEvent
  69. * (
  70. * iJVM_EVENT_TYPE_METHOD_UNLOAD_FINISHED,
  71. * ) for all the method that are unloaded
  72. */
  73. iJIT_BE_NOTIFY_ON_UNLOAD = 0x0002,
  74. /* when turned on the jit must instrument all
  75. * the currently jited code with calls on
  76. * method entries
  77. */
  78. iJIT_BE_NOTIFY_ON_METHOD_ENTRY = 0x0004,
  79. /* when turned on the jit must instrument all
  80. * the currently jited code with calls
  81. * on method exit
  82. */
  83. iJIT_BE_NOTIFY_ON_METHOD_EXIT = 0x0008
  84. } iJIT_ModeFlags;
  85. /* Flags used by iJIT_IsProfilingActive() */
  86. typedef enum _iJIT_IsProfilingActiveFlags
  87. {
  88. /* No profiler is running. Currently not used */
  89. iJIT_NOTHING_RUNNING = 0x0000,
  90. /* Sampling is running. This is the default value
  91. * returned by iJIT_IsProfilingActive()
  92. */
  93. iJIT_SAMPLING_ON = 0x0001,
  94. /* Call Graph is running */
  95. iJIT_CALLGRAPH_ON = 0x0002
  96. } iJIT_IsProfilingActiveFlags;
  97. /* Enumerator for the environment of methods*/
  98. typedef enum _iJDEnvironmentType
  99. {
  100. iJDE_JittingAPI = 2
  101. } iJDEnvironmentType;
  102. /**********************************
  103. * Data structures for the events *
  104. **********************************/
  105. /* structure for the events:
  106. * iJVM_EVENT_TYPE_METHOD_UNLOAD_START
  107. */
  108. typedef struct _iJIT_Method_Id
  109. {
  110. /* Id of the method (same as the one passed in
  111. * the iJIT_Method_Load struct
  112. */
  113. unsigned int method_id;
  114. } *piJIT_Method_Id, iJIT_Method_Id;
  115. /* structure for the events:
  116. * iJVM_EVENT_TYPE_ENTER_NIDS,
  117. * iJVM_EVENT_TYPE_LEAVE_NIDS,
  118. * iJVM_EVENT_TYPE_EXCEPTION_OCCURRED_NIDS
  119. */
  120. typedef struct _iJIT_Method_NIDS
  121. {
  122. /* unique method ID */
  123. unsigned int method_id;
  124. /* NOTE: no need to fill this field, it's filled by VTune */
  125. unsigned int stack_id;
  126. /* method name (just the method, without the class) */
  127. char* method_name;
  128. } *piJIT_Method_NIDS, iJIT_Method_NIDS;
  129. /* structures for the events:
  130. * iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED
  131. */
  132. typedef struct _LineNumberInfo
  133. {
  134. /* x86 Offset from the beginning of the method*/
  135. unsigned int Offset;
  136. /* source line number from the beginning of the source file */
  137. unsigned int LineNumber;
  138. } *pLineNumberInfo, LineNumberInfo;
  139. typedef struct _iJIT_Method_Load
  140. {
  141. /* unique method ID - can be any unique value, (except 0 - 999) */
  142. unsigned int method_id;
  143. /* method name (can be with or without the class and signature, in any case
  144. * the class name will be added to it)
  145. */
  146. char* method_name;
  147. /* virtual address of that method - This determines the method range for the
  148. * iJVM_EVENT_TYPE_ENTER/LEAVE_METHOD_ADDR events
  149. */
  150. void* method_load_address;
  151. /* Size in memory - Must be exact */
  152. unsigned int method_size;
  153. /* Line Table size in number of entries - Zero if none */
  154. unsigned int line_number_size;
  155. /* Pointer to the beginning of the line numbers info array */
  156. pLineNumberInfo line_number_table;
  157. /* unique class ID */
  158. unsigned int class_id;
  159. /* class file name */
  160. char* class_file_name;
  161. /* source file name */
  162. char* source_file_name;
  163. /* bits supplied by the user for saving in the JIT file */
  164. void* user_data;
  165. /* the size of the user data buffer */
  166. unsigned int user_data_size;
  167. /* NOTE: no need to fill this field, it's filled by VTune */
  168. iJDEnvironmentType env;
  169. } *piJIT_Method_Load, iJIT_Method_Load;
  170. /* API Functions */
  171. #ifdef __cplusplus
  172. extern "C" {
  173. #endif
  174. #ifndef CDECL
  175. # if defined WIN32 || defined _WIN32
  176. # define CDECL __cdecl
  177. # else /* defined WIN32 || defined _WIN32 */
  178. # if defined _M_X64 || defined _M_AMD64 || defined __x86_64__
  179. # define CDECL /* not actual on x86_64 platform */
  180. # else /* _M_X64 || _M_AMD64 || __x86_64__ */
  181. # define CDECL __attribute__ ((cdecl))
  182. # endif /* _M_X64 || _M_AMD64 || __x86_64__ */
  183. # endif /* defined WIN32 || defined _WIN32 */
  184. #endif /* CDECL */
  185. // HLSL Change: changed calling convention to __stdcall
  186. #define JITAPI __stdcall
  187. /* called when the settings are changed with new settings */
  188. typedef void (*iJIT_ModeChangedEx)(void *UserData, iJIT_ModeFlags Flags);
  189. int JITAPI iJIT_NotifyEvent(iJIT_JVM_EVENT event_type, void *EventSpecificData);
  190. /* The new mode call back routine */
  191. void JITAPI iJIT_RegisterCallbackEx(void *userdata,
  192. iJIT_ModeChangedEx NewModeCallBackFuncEx);
  193. iJIT_IsProfilingActiveFlags JITAPI iJIT_IsProfilingActive(void);
  194. void JITAPI FinalizeThread(void);
  195. void JITAPI FinalizeProcess(void);
  196. unsigned int JITAPI iJIT_GetNewMethodID(void);
  197. #ifdef __cplusplus
  198. }
  199. #endif
  200. #endif /* __JITPROFILING_H__ */