mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 11:42:57 +01:00
[Orc] Turn OrcX86_64::IndirectStubsInfo into a template helper class:
GenericIndirectStubsInfo. This will allow architecture support classes for other architectures to re-use this code. llvm-svn: 259549
This commit is contained in:
parent
d19bf6a28b
commit
481f4ed9e9
@ -67,42 +67,21 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/// @brief X86_64 support.
|
||||
///
|
||||
/// X86_64 supports lazy JITing.
|
||||
class OrcX86_64 {
|
||||
/// @brief Provide information about stub blocks generated by the
|
||||
/// makeIndirectStubsBlock function.
|
||||
template <unsigned StubSizeVal>
|
||||
class GenericIndirectStubsInfo {
|
||||
public:
|
||||
static const unsigned PointerSize = 8;
|
||||
static const unsigned TrampolineSize = 8;
|
||||
static const unsigned ResolverCodeSize = 0x78;
|
||||
const static unsigned StubSize = StubSizeVal;
|
||||
|
||||
typedef TargetAddress (*JITReentryFn)(void *CallbackMgr, void *TrampolineId);
|
||||
|
||||
/// @brief Write the resolver code into the given memory. The user is be
|
||||
/// responsible for allocating the memory and setting permissions.
|
||||
static void writeResolverCode(uint8_t *ResolveMem, JITReentryFn Reentry,
|
||||
void *CallbackMgr);
|
||||
|
||||
/// @brief Write the requsted number of trampolines into the given memory,
|
||||
/// which must be big enough to hold 1 pointer, plus NumTrampolines
|
||||
/// trampolines.
|
||||
static void writeTrampolines(uint8_t *TrampolineMem, void *ResolverAddr,
|
||||
unsigned NumTrampolines);
|
||||
|
||||
/// @brief Provide information about stub blocks generated by the
|
||||
/// makeIndirectStubsBlock function.
|
||||
class IndirectStubsInfo {
|
||||
friend class OrcX86_64;
|
||||
|
||||
public:
|
||||
const static unsigned StubSize = 8;
|
||||
|
||||
IndirectStubsInfo() : NumStubs(0) {}
|
||||
IndirectStubsInfo(IndirectStubsInfo &&Other)
|
||||
GenericIndirectStubsInfo() : NumStubs(0) {}
|
||||
GenericIndirectStubsInfo(unsigned NumStubs, sys::OwningMemoryBlock StubsMem)
|
||||
: NumStubs(NumStubs), StubsMem(std::move(StubsMem)) {}
|
||||
GenericIndirectStubsInfo(GenericIndirectStubsInfo &&Other)
|
||||
: NumStubs(Other.NumStubs), StubsMem(std::move(Other.StubsMem)) {
|
||||
Other.NumStubs = 0;
|
||||
}
|
||||
IndirectStubsInfo &operator=(IndirectStubsInfo &&Other) {
|
||||
GenericIndirectStubsInfo &operator=(GenericIndirectStubsInfo &&Other) {
|
||||
NumStubs = Other.NumStubs;
|
||||
Other.NumStubs = 0;
|
||||
StubsMem = std::move(Other.StubsMem);
|
||||
@ -126,10 +105,34 @@ public:
|
||||
return reinterpret_cast<void **>(PtrsBase) + Idx;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
unsigned NumStubs;
|
||||
sys::OwningMemoryBlock StubsMem;
|
||||
};
|
||||
};
|
||||
|
||||
/// @brief X86_64 support.
|
||||
///
|
||||
/// X86_64 supports lazy JITing.
|
||||
class OrcX86_64 {
|
||||
public:
|
||||
static const unsigned PointerSize = 8;
|
||||
static const unsigned TrampolineSize = 8;
|
||||
static const unsigned ResolverCodeSize = 0x78;
|
||||
|
||||
typedef GenericIndirectStubsInfo<8> IndirectStubsInfo;
|
||||
|
||||
typedef TargetAddress (*JITReentryFn)(void *CallbackMgr, void *TrampolineId);
|
||||
|
||||
/// @brief Write the resolver code into the given memory. The user is be
|
||||
/// responsible for allocating the memory and setting permissions.
|
||||
static void writeResolverCode(uint8_t *ResolveMem, JITReentryFn Reentry,
|
||||
void *CallbackMgr);
|
||||
|
||||
/// @brief Write the requsted number of trampolines into the given memory,
|
||||
/// which must be big enough to hold 1 pointer, plus NumTrampolines
|
||||
/// trampolines.
|
||||
static void writeTrampolines(uint8_t *TrampolineMem, void *ResolverAddr,
|
||||
unsigned NumTrampolines);
|
||||
|
||||
/// @brief Emit at least MinStubs worth of indirect call stubs, rounded out to
|
||||
/// the nearest page size.
|
||||
|
@ -161,8 +161,7 @@ std::error_code OrcX86_64::emitIndirectStubsBlock(IndirectStubsInfo &StubsInfo,
|
||||
for (unsigned I = 0; I < NumStubs; ++I)
|
||||
Ptr[I] = InitialPtrVal;
|
||||
|
||||
StubsInfo.NumStubs = NumStubs;
|
||||
StubsInfo.StubsMem = std::move(StubsMem);
|
||||
StubsInfo = IndirectStubsInfo(NumStubs, std::move(StubsMem));
|
||||
|
||||
return std::error_code();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user