2009-06-25 02:04:04 +00:00
|
|
|
//===- JITEventListener.h - Exposes events from JIT compilation -*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines the JITEventListener interface, which lets users get
|
|
|
|
// callbacks when significant events happen during the JIT compilation process.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2013-01-10 00:45:19 +00:00
|
|
|
#ifndef LLVM_EXECUTIONENGINE_JITEVENTLISTENER_H
|
|
|
|
#define LLVM_EXECUTIONENGINE_JITEVENTLISTENER_H
|
2009-06-25 02:04:04 +00:00
|
|
|
|
2012-12-13 15:03:38 +00:00
|
|
|
#include "llvm/Config/llvm-config.h"
|
2010-11-29 18:16:10 +00:00
|
|
|
#include "llvm/Support/DataTypes.h"
|
2009-07-16 21:07:26 +00:00
|
|
|
#include "llvm/Support/DebugLoc.h"
|
|
|
|
#include <vector>
|
2009-06-25 02:04:04 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
class Function;
|
2009-07-16 21:07:26 +00:00
|
|
|
class MachineFunction;
|
2012-03-13 08:33:15 +00:00
|
|
|
class OProfileWrapper;
|
|
|
|
class IntelJITEventsWrapper;
|
2012-11-06 18:51:59 +00:00
|
|
|
class ObjectImage;
|
2009-06-25 02:04:04 +00:00
|
|
|
|
2010-11-13 02:48:41 +00:00
|
|
|
/// JITEvent_EmittedFunctionDetails - Helper struct for containing information
|
|
|
|
/// about a generated machine code function.
|
2009-06-25 02:04:04 +00:00
|
|
|
struct JITEvent_EmittedFunctionDetails {
|
2009-07-16 21:07:26 +00:00
|
|
|
struct LineStart {
|
2010-11-13 02:48:41 +00:00
|
|
|
/// The address at which the current line changes.
|
2009-07-16 21:07:26 +00:00
|
|
|
uintptr_t Address;
|
2010-11-13 02:48:41 +00:00
|
|
|
|
|
|
|
/// The new location information. These can be translated to DebugLocTuples
|
|
|
|
/// using MF->getDebugLocTuple().
|
2009-07-16 21:07:26 +00:00
|
|
|
DebugLoc Loc;
|
|
|
|
};
|
2010-11-13 02:48:41 +00:00
|
|
|
|
|
|
|
/// The machine function the struct contains information for.
|
|
|
|
const MachineFunction *MF;
|
|
|
|
|
|
|
|
/// The list of line boundary information, sorted by address.
|
2009-07-16 21:07:26 +00:00
|
|
|
std::vector<LineStart> LineStarts;
|
2009-06-25 02:04:04 +00:00
|
|
|
};
|
|
|
|
|
2010-11-13 02:48:41 +00:00
|
|
|
/// JITEventListener - Abstract interface for use by the JIT to notify clients
|
|
|
|
/// about significant events during compilation. For example, to notify
|
|
|
|
/// profilers and debuggers that need to know where functions have been emitted.
|
2009-06-25 02:04:04 +00:00
|
|
|
///
|
2010-11-13 02:48:41 +00:00
|
|
|
/// The default implementation of each method does nothing.
|
2009-06-25 02:04:04 +00:00
|
|
|
class JITEventListener {
|
2010-11-13 02:48:41 +00:00
|
|
|
public:
|
|
|
|
typedef JITEvent_EmittedFunctionDetails EmittedFunctionDetails;
|
|
|
|
|
2009-06-25 02:04:04 +00:00
|
|
|
public:
|
|
|
|
JITEventListener() {}
|
2010-11-13 02:48:41 +00:00
|
|
|
virtual ~JITEventListener();
|
2009-06-25 02:04:04 +00:00
|
|
|
|
|
|
|
/// NotifyFunctionEmitted - Called after a function has been successfully
|
|
|
|
/// emitted to memory. The function still has its MachineFunction attached,
|
|
|
|
/// if you should happen to need that.
|
2011-11-04 18:11:56 +00:00
|
|
|
virtual void NotifyFunctionEmitted(const Function &,
|
|
|
|
void *, size_t,
|
|
|
|
const EmittedFunctionDetails &) {}
|
2009-06-25 02:04:04 +00:00
|
|
|
|
2010-11-13 02:48:41 +00:00
|
|
|
/// NotifyFreeingMachineCode - Called from freeMachineCodeForFunction(), after
|
|
|
|
/// the global mapping is removed, but before the machine code is returned to
|
|
|
|
/// the allocator.
|
|
|
|
///
|
|
|
|
/// OldPtr is the address of the machine code and will be the same as the Code
|
|
|
|
/// parameter to a previous NotifyFunctionEmitted call. The Function passed
|
|
|
|
/// to NotifyFunctionEmitted may have been destroyed by the time of the
|
|
|
|
/// matching NotifyFreeingMachineCode call.
|
2011-11-04 18:11:56 +00:00
|
|
|
virtual void NotifyFreeingMachineCode(void *) {}
|
2009-06-25 02:04:04 +00:00
|
|
|
|
2012-11-06 18:51:59 +00:00
|
|
|
/// NotifyObjectEmitted - Called after an object has been successfully
|
|
|
|
/// emitted to memory. NotifyFunctionEmitted will not be called for
|
|
|
|
/// individual functions in the object.
|
|
|
|
///
|
|
|
|
/// ELF-specific information
|
|
|
|
/// The ObjectImage contains the generated object image
|
|
|
|
/// with section headers updated to reflect the address at which sections
|
|
|
|
/// were loaded and with relocations performed in-place on debug sections.
|
|
|
|
virtual void NotifyObjectEmitted(const ObjectImage &Obj) {}
|
|
|
|
|
|
|
|
/// NotifyFreeingObject - Called just before the memory associated with
|
|
|
|
/// a previously emitted object is released.
|
|
|
|
virtual void NotifyFreeingObject(const ObjectImage &Obj) {}
|
|
|
|
|
2012-03-13 08:33:15 +00:00
|
|
|
#if LLVM_USE_INTEL_JITEVENTS
|
|
|
|
// Construct an IntelJITEventListener
|
|
|
|
static JITEventListener *createIntelJITEventListener();
|
|
|
|
|
|
|
|
// Construct an IntelJITEventListener with a test Intel JIT API implementation
|
|
|
|
static JITEventListener *createIntelJITEventListener(
|
|
|
|
IntelJITEventsWrapper* AlternativeImpl);
|
|
|
|
#else
|
|
|
|
static JITEventListener *createIntelJITEventListener() { return 0; }
|
|
|
|
|
|
|
|
static JITEventListener *createIntelJITEventListener(
|
|
|
|
IntelJITEventsWrapper* AlternativeImpl) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif // USE_INTEL_JITEVENTS
|
|
|
|
|
|
|
|
#if LLVM_USE_OPROFILE
|
|
|
|
// Construct an OProfileJITEventListener
|
|
|
|
static JITEventListener *createOProfileJITEventListener();
|
|
|
|
|
|
|
|
// Construct an OProfileJITEventListener with a test opagent implementation
|
|
|
|
static JITEventListener *createOProfileJITEventListener(
|
|
|
|
OProfileWrapper* AlternativeImpl);
|
|
|
|
#else
|
|
|
|
|
|
|
|
static JITEventListener *createOProfileJITEventListener() { return 0; }
|
|
|
|
|
|
|
|
static JITEventListener *createOProfileJITEventListener(
|
|
|
|
OProfileWrapper* AlternativeImpl) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif // USE_OPROFILE
|
|
|
|
|
|
|
|
};
|
2009-06-25 02:04:04 +00:00
|
|
|
|
|
|
|
} // end namespace llvm.
|
|
|
|
|
2013-01-10 00:45:19 +00:00
|
|
|
#endif // defined LLVM_EXECUTIONENGINE_JITEVENTLISTENER_H
|