IntelJITEventsWrapper.h [plain text]
#ifndef INTEL_JIT_EVENTS_WRAPPER_H
#define INTEL_JIT_EVENTS_WRAPPER_H
#include "jitprofiling.h"
namespace llvm {
class IntelJITEventsWrapper {
typedef int (*NotifyEventPtr)(iJIT_JVM_EVENT, void*);
typedef void (*RegisterCallbackExPtr)(void *, iJIT_ModeChangedEx );
typedef iJIT_IsProfilingActiveFlags (*IsProfilingActivePtr)(void);
typedef void (*FinalizeThreadPtr)(void);
typedef void (*FinalizeProcessPtr)(void);
typedef unsigned int (*GetNewMethodIDPtr)(void);
NotifyEventPtr NotifyEventFunc;
RegisterCallbackExPtr RegisterCallbackExFunc;
IsProfilingActivePtr IsProfilingActiveFunc;
GetNewMethodIDPtr GetNewMethodIDFunc;
public:
bool isAmplifierRunning() {
return iJIT_IsProfilingActive() == iJIT_SAMPLING_ON;
}
IntelJITEventsWrapper()
: NotifyEventFunc(::iJIT_NotifyEvent),
RegisterCallbackExFunc(::iJIT_RegisterCallbackEx),
IsProfilingActiveFunc(::iJIT_IsProfilingActive),
GetNewMethodIDFunc(::iJIT_GetNewMethodID) {
}
IntelJITEventsWrapper(NotifyEventPtr NotifyEventImpl,
RegisterCallbackExPtr RegisterCallbackExImpl,
IsProfilingActivePtr IsProfilingActiveImpl,
FinalizeThreadPtr FinalizeThreadImpl,
FinalizeProcessPtr FinalizeProcessImpl,
GetNewMethodIDPtr GetNewMethodIDImpl)
: NotifyEventFunc(NotifyEventImpl),
RegisterCallbackExFunc(RegisterCallbackExImpl),
IsProfilingActiveFunc(IsProfilingActiveImpl),
GetNewMethodIDFunc(GetNewMethodIDImpl) {
}
int iJIT_NotifyEvent(iJIT_JVM_EVENT EventType, void *EventSpecificData) {
if (!NotifyEventFunc)
return -1;
return NotifyEventFunc(EventType, EventSpecificData);
}
void iJIT_RegisterCallbackEx(void *UserData,
iJIT_ModeChangedEx NewModeCallBackFuncEx) {
if (RegisterCallbackExFunc)
RegisterCallbackExFunc(UserData, NewModeCallBackFuncEx);
}
iJIT_IsProfilingActiveFlags iJIT_IsProfilingActive(void) {
if (!IsProfilingActiveFunc)
return iJIT_NOTHING_RUNNING;
return IsProfilingActiveFunc();
}
unsigned int iJIT_GetNewMethodID(void) {
if (!GetNewMethodIDFunc)
return -1;
return GetNewMethodIDFunc();
}
};
}
#endif //INTEL_JIT_EVENTS_WRAPPER_H