brintos

brintos / llvm-project-archived public Read only

0
0
Text · 7.0 KiB · ba627b4 Raw
259 lines · c
1/*===-- jitprofiling.h - JIT Profiling API-------------------------*- C -*-===*2 *3 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4 * See https://llvm.org/LICENSE.txt for license information.5 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6 *7 *===----------------------------------------------------------------------===*8 *9 * This file provides Intel(R) Performance Analyzer JIT (Just-In-Time)10 * Profiling API declaration.11 *12 * NOTE: This file comes in a style different from the rest of LLVM13 * source base since  this is a piece of code shared from Intel(R)14 * products.  Please do not reformat / re-style this code to make15 * subsequent merges and contributions from the original source base eaiser.16 *17 *===----------------------------------------------------------------------===*/18#ifndef __JITPROFILING_H__19#define __JITPROFILING_H__20 21/*22 * Various constants used by functions23 */24 25/* event notification */26typedef enum iJIT_jvm_event27{28 29    /* shutdown  */30 31    /*32     * Program exiting EventSpecificData NA33     */34    iJVM_EVENT_TYPE_SHUTDOWN = 2,35 36    /* JIT profiling  */37 38    /*39     * issued after method code jitted into memory but before code is executed40     * EventSpecificData is an iJIT_Method_Load41     */42    iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED=13,43 44    /* issued before unload. Method code will no longer be executed, but code45     * and info are still in memory. The VTune profiler may capture method46     * code only at this point EventSpecificData is iJIT_Method_Id47     */48    iJVM_EVENT_TYPE_METHOD_UNLOAD_START,49 50    /* Method Profiling */51 52    /* method name, Id and stack is supplied53     * issued when a method is about to be entered EventSpecificData is54     * iJIT_Method_NIDS55     */56    iJVM_EVENT_TYPE_ENTER_NIDS = 19,57 58    /* method name, Id and stack is supplied59     * issued when a method is about to be left EventSpecificData is60     * iJIT_Method_NIDS61     */62    iJVM_EVENT_TYPE_LEAVE_NIDS63} iJIT_JVM_EVENT;64 65typedef enum _iJIT_ModeFlags66{67    /* No need to Notify VTune, since VTune is not running */68    iJIT_NO_NOTIFICATIONS          = 0x0000,69 70    /* when turned on the jit must call71     * iJIT_NotifyEvent72     * (73     *     iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED,74     * )75     * for all the method already jitted76     */77    iJIT_BE_NOTIFY_ON_LOAD         = 0x0001,78 79    /* when turned on the jit must call80     * iJIT_NotifyEvent81     * (82     *     iJVM_EVENT_TYPE_METHOD_UNLOAD_FINISHED,83     *  ) for all the method that are unloaded84     */85    iJIT_BE_NOTIFY_ON_UNLOAD       = 0x0002,86 87    /* when turned on the jit must instrument all88     * the currently jited code with calls on89     * method entries90     */91    iJIT_BE_NOTIFY_ON_METHOD_ENTRY = 0x0004,92 93    /* when turned on the jit must instrument all94     * the currently jited code with calls95     * on method exit96     */97    iJIT_BE_NOTIFY_ON_METHOD_EXIT  = 0x000898 99} iJIT_ModeFlags;100 101 102 /* Flags used by iJIT_IsProfilingActive() */103typedef enum _iJIT_IsProfilingActiveFlags104{105    /* No profiler is running. Currently not used */106    iJIT_NOTHING_RUNNING           = 0x0000,107 108    /* Sampling is running. This is the default value109     * returned by iJIT_IsProfilingActive()110     */111    iJIT_SAMPLING_ON               = 0x0001,112 113      /* Call Graph is running */114    iJIT_CALLGRAPH_ON              = 0x0002115 116} iJIT_IsProfilingActiveFlags;117 118/* Enumerator for the environment of methods*/119typedef enum _iJDEnvironmentType120{121    iJDE_JittingAPI = 2122} iJDEnvironmentType;123 124/**********************************125 * Data structures for the events *126 **********************************/127 128/* structure for the events:129 * iJVM_EVENT_TYPE_METHOD_UNLOAD_START130 */131 132typedef struct _iJIT_Method_Id133{134   /* Id of the method (same as the one passed in135   * the iJIT_Method_Load struct136   */137    unsigned int       method_id;138 139} *piJIT_Method_Id, iJIT_Method_Id;140 141 142/* structure for the events:143 * iJVM_EVENT_TYPE_ENTER_NIDS,144 * iJVM_EVENT_TYPE_LEAVE_NIDS,145 * iJVM_EVENT_TYPE_EXCEPTION_OCCURRED_NIDS146 */147 148typedef struct _iJIT_Method_NIDS149{150    /* unique method ID */151    unsigned int       method_id;152 153    /* NOTE: no need to fill this field, it's filled by VTune */154    unsigned int       stack_id;155 156    /* method name (just the method, without the class) */157    char*              method_name;158} *piJIT_Method_NIDS, iJIT_Method_NIDS;159 160/* structures for the events:161 * iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED162 */163 164typedef struct _LineNumberInfo165{166  /* x86 Offset from the beginning of the method*/167  unsigned int Offset;168 169  /* source line number from the beginning of the source file */170    unsigned int        LineNumber;171 172} *pLineNumberInfo, LineNumberInfo;173 174typedef struct _iJIT_Method_Load175{176    /* unique method ID - can be any unique value, (except 0 - 999) */177    unsigned int        method_id;178 179    /* method name (can be with or without the class and signature, in any case180     * the class name will be added to it)181     */182    char*               method_name;183 184    /* virtual address of that method - This determines the method range for the185     * iJVM_EVENT_TYPE_ENTER/LEAVE_METHOD_ADDR events186     */187    void*               method_load_address;188 189    /* Size in memory - Must be exact */190    unsigned int        method_size;191 192    /* Line Table size in number of entries - Zero if none */193    unsigned int line_number_size;194 195    /* Pointer to the beginning of the line numbers info array */196    pLineNumberInfo     line_number_table;197 198    /* unique class ID */199    unsigned int        class_id;200 201    /* class file name */202    char*               class_file_name;203 204    /* source file name */205    char*               source_file_name;206 207    /* bits supplied by the user for saving in the JIT file */208    void*               user_data;209 210    /* the size of the user data buffer */211    unsigned int        user_data_size;212 213    /* NOTE: no need to fill this field, it's filled by VTune */214    iJDEnvironmentType  env;215 216} *piJIT_Method_Load, iJIT_Method_Load;217 218/* API Functions */219#ifdef __cplusplus220extern "C" {221#endif222 223#ifndef CDECL224#  if defined WIN32 || defined _WIN32225#    define CDECL __cdecl226#  else /* defined WIN32 || defined _WIN32 */227#    if defined _M_X64 || defined _M_AMD64 || defined __x86_64__228#      define CDECL /* not actual on x86_64 platform */229#    else  /* _M_X64 || _M_AMD64 || __x86_64__ */230#      define CDECL __attribute__ ((cdecl))231#    endif /* _M_X64 || _M_AMD64 || __x86_64__ */232#  endif /* defined WIN32 || defined _WIN32 */233#endif /* CDECL */234 235#define JITAPI CDECL236 237/* called when the settings are changed with new settings */238typedef void (*iJIT_ModeChangedEx)(void *UserData, iJIT_ModeFlags Flags);239 240int JITAPI iJIT_NotifyEvent(iJIT_JVM_EVENT event_type, void *EventSpecificData);241 242/* The new mode call back routine */243void JITAPI iJIT_RegisterCallbackEx(void *userdata,244                                    iJIT_ModeChangedEx NewModeCallBackFuncEx);245 246iJIT_IsProfilingActiveFlags JITAPI iJIT_IsProfilingActive(void);247 248void JITAPI FinalizeThread(void);249 250void JITAPI FinalizeProcess(void);251 252unsigned int JITAPI iJIT_GetNewMethodID(void);253 254#ifdef __cplusplus255}256#endif257 258#endif /* __JITPROFILING_H__ */259