Path: blob/main/contrib/llvm-project/llvm/lib/ExecutionEngine/IntelJITProfiling/jitprofiling.h
35271 views
/*===-- jitprofiling.h - JIT Profiling API-------------------------*- C -*-===*1*2* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3* See https://llvm.org/LICENSE.txt for license information.4* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5*6*===----------------------------------------------------------------------===*7*8* This file provides Intel(R) Performance Analyzer JIT (Just-In-Time)9* Profiling API declaration.10*11* NOTE: This file comes in a style different from the rest of LLVM12* source base since this is a piece of code shared from Intel(R)13* products. Please do not reformat / re-style this code to make14* subsequent merges and contributions from the original source base eaiser.15*16*===----------------------------------------------------------------------===*/17#ifndef __JITPROFILING_H__18#define __JITPROFILING_H__1920/*21* Various constants used by functions22*/2324/* event notification */25typedef enum iJIT_jvm_event26{2728/* shutdown */2930/*31* Program exiting EventSpecificData NA32*/33iJVM_EVENT_TYPE_SHUTDOWN = 2,3435/* JIT profiling */3637/*38* issued after method code jitted into memory but before code is executed39* EventSpecificData is an iJIT_Method_Load40*/41iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED=13,4243/* issued before unload. Method code will no longer be executed, but code44* and info are still in memory. The VTune profiler may capture method45* code only at this point EventSpecificData is iJIT_Method_Id46*/47iJVM_EVENT_TYPE_METHOD_UNLOAD_START,4849/* Method Profiling */5051/* method name, Id and stack is supplied52* issued when a method is about to be entered EventSpecificData is53* iJIT_Method_NIDS54*/55iJVM_EVENT_TYPE_ENTER_NIDS = 19,5657/* method name, Id and stack is supplied58* issued when a method is about to be left EventSpecificData is59* iJIT_Method_NIDS60*/61iJVM_EVENT_TYPE_LEAVE_NIDS62} iJIT_JVM_EVENT;6364typedef enum _iJIT_ModeFlags65{66/* No need to Notify VTune, since VTune is not running */67iJIT_NO_NOTIFICATIONS = 0x0000,6869/* when turned on the jit must call70* iJIT_NotifyEvent71* (72* iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED,73* )74* for all the method already jitted75*/76iJIT_BE_NOTIFY_ON_LOAD = 0x0001,7778/* when turned on the jit must call79* iJIT_NotifyEvent80* (81* iJVM_EVENT_TYPE_METHOD_UNLOAD_FINISHED,82* ) for all the method that are unloaded83*/84iJIT_BE_NOTIFY_ON_UNLOAD = 0x0002,8586/* when turned on the jit must instrument all87* the currently jited code with calls on88* method entries89*/90iJIT_BE_NOTIFY_ON_METHOD_ENTRY = 0x0004,9192/* when turned on the jit must instrument all93* the currently jited code with calls94* on method exit95*/96iJIT_BE_NOTIFY_ON_METHOD_EXIT = 0x00089798} iJIT_ModeFlags;99100101/* Flags used by iJIT_IsProfilingActive() */102typedef enum _iJIT_IsProfilingActiveFlags103{104/* No profiler is running. Currently not used */105iJIT_NOTHING_RUNNING = 0x0000,106107/* Sampling is running. This is the default value108* returned by iJIT_IsProfilingActive()109*/110iJIT_SAMPLING_ON = 0x0001,111112/* Call Graph is running */113iJIT_CALLGRAPH_ON = 0x0002114115} iJIT_IsProfilingActiveFlags;116117/* Enumerator for the environment of methods*/118typedef enum _iJDEnvironmentType119{120iJDE_JittingAPI = 2121} iJDEnvironmentType;122123/**********************************124* Data structures for the events *125**********************************/126127/* structure for the events:128* iJVM_EVENT_TYPE_METHOD_UNLOAD_START129*/130131typedef struct _iJIT_Method_Id132{133/* Id of the method (same as the one passed in134* the iJIT_Method_Load struct135*/136unsigned int method_id;137138} *piJIT_Method_Id, iJIT_Method_Id;139140141/* structure for the events:142* iJVM_EVENT_TYPE_ENTER_NIDS,143* iJVM_EVENT_TYPE_LEAVE_NIDS,144* iJVM_EVENT_TYPE_EXCEPTION_OCCURRED_NIDS145*/146147typedef struct _iJIT_Method_NIDS148{149/* unique method ID */150unsigned int method_id;151152/* NOTE: no need to fill this field, it's filled by VTune */153unsigned int stack_id;154155/* method name (just the method, without the class) */156char* method_name;157} *piJIT_Method_NIDS, iJIT_Method_NIDS;158159/* structures for the events:160* iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED161*/162163typedef struct _LineNumberInfo164{165/* x86 Offset from the beginning of the method*/166unsigned int Offset;167168/* source line number from the beginning of the source file */169unsigned int LineNumber;170171} *pLineNumberInfo, LineNumberInfo;172173typedef struct _iJIT_Method_Load174{175/* unique method ID - can be any unique value, (except 0 - 999) */176unsigned int method_id;177178/* method name (can be with or without the class and signature, in any case179* the class name will be added to it)180*/181char* method_name;182183/* virtual address of that method - This determines the method range for the184* iJVM_EVENT_TYPE_ENTER/LEAVE_METHOD_ADDR events185*/186void* method_load_address;187188/* Size in memory - Must be exact */189unsigned int method_size;190191/* Line Table size in number of entries - Zero if none */192unsigned int line_number_size;193194/* Pointer to the beginning of the line numbers info array */195pLineNumberInfo line_number_table;196197/* unique class ID */198unsigned int class_id;199200/* class file name */201char* class_file_name;202203/* source file name */204char* source_file_name;205206/* bits supplied by the user for saving in the JIT file */207void* user_data;208209/* the size of the user data buffer */210unsigned int user_data_size;211212/* NOTE: no need to fill this field, it's filled by VTune */213iJDEnvironmentType env;214215} *piJIT_Method_Load, iJIT_Method_Load;216217/* API Functions */218#ifdef __cplusplus219extern "C" {220#endif221222#ifndef CDECL223# if defined WIN32 || defined _WIN32224# define CDECL __cdecl225# else /* defined WIN32 || defined _WIN32 */226# if defined _M_X64 || defined _M_AMD64 || defined __x86_64__227# define CDECL /* not actual on x86_64 platform */228# else /* _M_X64 || _M_AMD64 || __x86_64__ */229# define CDECL __attribute__ ((cdecl))230# endif /* _M_X64 || _M_AMD64 || __x86_64__ */231# endif /* defined WIN32 || defined _WIN32 */232#endif /* CDECL */233234#define JITAPI CDECL235236/* called when the settings are changed with new settings */237typedef void (*iJIT_ModeChangedEx)(void *UserData, iJIT_ModeFlags Flags);238239int JITAPI iJIT_NotifyEvent(iJIT_JVM_EVENT event_type, void *EventSpecificData);240241/* The new mode call back routine */242void JITAPI iJIT_RegisterCallbackEx(void *userdata,243iJIT_ModeChangedEx NewModeCallBackFuncEx);244245iJIT_IsProfilingActiveFlags JITAPI iJIT_IsProfilingActive(void);246247void JITAPI FinalizeThread(void);248249void JITAPI FinalizeProcess(void);250251unsigned int JITAPI iJIT_GetNewMethodID(void);252253#ifdef __cplusplus254}255#endif256257#endif /* __JITPROFILING_H__ */258259260