mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-13 04:38:24 +00:00
SectionMemoryManager shouldn't be a JITMemoryManager. Previously, the
EngineBuilder interface required a JITMemoryManager even if it was being used to construct an MCJIT. But the MCJIT actually wants a RTDyldMemoryManager. Consequently, the SectionMemoryManager, which is meant for MCJIT, derived from the JITMemoryManager and then stubbed out a bunch of JITMemoryManager methods that weren't relevant to the MCJIT. This patch fixes the situation: it teaches the EngineBuilder that RTDyldMemoryManager is a supertype of JITMemoryManager, and that it's appropriate to pass a RTDyldMemoryManager instead of a JITMemoryManager if we're using the MCJIT. This allows us to remove the stub methods from SectionMemoryManager, and make SectionMemoryManager a direct subtype of RTDyldMemoryManager. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181820 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -34,6 +34,7 @@ namespace llvm {
|
||||
|
||||
struct GenericValue;
|
||||
class Constant;
|
||||
class DataLayout;
|
||||
class ExecutionEngine;
|
||||
class Function;
|
||||
class GlobalVariable;
|
||||
@ -44,7 +45,7 @@ class MachineCodeInfo;
|
||||
class Module;
|
||||
class MutexGuard;
|
||||
class ObjectCache;
|
||||
class DataLayout;
|
||||
class RTDyldMemoryManager;
|
||||
class Triple;
|
||||
class Type;
|
||||
|
||||
@ -142,7 +143,7 @@ protected:
|
||||
static ExecutionEngine *(*MCJITCtor)(
|
||||
Module *M,
|
||||
std::string *ErrorStr,
|
||||
JITMemoryManager *JMM,
|
||||
RTDyldMemoryManager *MCJMM,
|
||||
bool GVsWithCode,
|
||||
TargetMachine *TM);
|
||||
static ExecutionEngine *(*InterpCtor)(Module *M, std::string *ErrorStr);
|
||||
@ -496,6 +497,7 @@ private:
|
||||
EngineKind::Kind WhichEngine;
|
||||
std::string *ErrorStr;
|
||||
CodeGenOpt::Level OptLevel;
|
||||
RTDyldMemoryManager *MCJMM;
|
||||
JITMemoryManager *JMM;
|
||||
bool AllocateGVsWithCode;
|
||||
TargetOptions Options;
|
||||
@ -511,6 +513,7 @@ private:
|
||||
WhichEngine = EngineKind::Either;
|
||||
ErrorStr = NULL;
|
||||
OptLevel = CodeGenOpt::Default;
|
||||
MCJMM = NULL;
|
||||
JMM = NULL;
|
||||
Options = TargetOptions();
|
||||
AllocateGVsWithCode = false;
|
||||
@ -532,12 +535,29 @@ public:
|
||||
WhichEngine = w;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// setMCJITMemoryManager - Sets the MCJIT memory manager to use. This allows
|
||||
/// clients to customize their memory allocation policies for the MCJIT. This
|
||||
/// is only appropriate for the MCJIT; setting this and configuring the builder
|
||||
/// to create anything other than MCJIT will cause a runtime error. If create()
|
||||
/// is called and is successful, the created engine takes ownership of the
|
||||
/// memory manager. This option defaults to NULL. Using this option nullifies
|
||||
/// the setJITMemoryManager() option.
|
||||
EngineBuilder &setMCJITMemoryManager(RTDyldMemoryManager *mcjmm) {
|
||||
MCJMM = mcjmm;
|
||||
JMM = NULL;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// setJITMemoryManager - Sets the memory manager to use. This allows
|
||||
/// clients to customize their memory allocation policies. If create() is
|
||||
/// called and is successful, the created engine takes ownership of the
|
||||
/// memory manager. This option defaults to NULL.
|
||||
/// setJITMemoryManager - Sets the JIT memory manager to use. This allows
|
||||
/// clients to customize their memory allocation policies. This is only
|
||||
/// appropriate for either JIT or MCJIT; setting this and configuring the
|
||||
/// builder to create an interpreter will cause a runtime error. If create()
|
||||
/// is called and is successful, the created engine takes ownership of the
|
||||
/// memory manager. This option defaults to NULL. This option overrides
|
||||
/// setMCJITMemoryManager() as well.
|
||||
EngineBuilder &setJITMemoryManager(JITMemoryManager *jmm) {
|
||||
MCJMM = NULL;
|
||||
JMM = jmm;
|
||||
return *this;
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
#define LLVM_EXECUTIONENGINE_SECTIONMEMORYMANAGER_H
|
||||
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ExecutionEngine/JITMemoryManager.h"
|
||||
#include "llvm/ExecutionEngine/RuntimeDyld.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/Memory.h"
|
||||
|
||||
@ -35,7 +35,7 @@ namespace llvm {
|
||||
/// in the JITed object. Permissions can be applied either by calling
|
||||
/// MCJIT::finalizeObject or by calling SectionMemoryManager::applyPermissions
|
||||
/// directly. Clients of MCJIT should call MCJIT::finalizeObject.
|
||||
class SectionMemoryManager : public JITMemoryManager {
|
||||
class SectionMemoryManager : public RTDyldMemoryManager {
|
||||
SectionMemoryManager(const SectionMemoryManager&) LLVM_DELETED_FUNCTION;
|
||||
void operator=(const SectionMemoryManager&) LLVM_DELETED_FUNCTION;
|
||||
|
||||
@ -108,54 +108,6 @@ private:
|
||||
MemoryGroup CodeMem;
|
||||
MemoryGroup RWDataMem;
|
||||
MemoryGroup RODataMem;
|
||||
|
||||
public:
|
||||
///
|
||||
/// Functions below are not used by MCJIT or RuntimeDyld, but must be
|
||||
/// implemented because they are declared as pure virtuals in the base class.
|
||||
///
|
||||
|
||||
virtual void setMemoryWritable() {
|
||||
llvm_unreachable("Unexpected call!");
|
||||
}
|
||||
virtual void setMemoryExecutable() {
|
||||
llvm_unreachable("Unexpected call!");
|
||||
}
|
||||
virtual void setPoisonMemory(bool poison) {
|
||||
llvm_unreachable("Unexpected call!");
|
||||
}
|
||||
virtual void AllocateGOT() {
|
||||
llvm_unreachable("Unexpected call!");
|
||||
}
|
||||
virtual uint8_t *getGOTBase() const {
|
||||
llvm_unreachable("Unexpected call!");
|
||||
return 0;
|
||||
}
|
||||
virtual uint8_t *startFunctionBody(const Function *F,
|
||||
uintptr_t &ActualSize){
|
||||
llvm_unreachable("Unexpected call!");
|
||||
return 0;
|
||||
}
|
||||
virtual uint8_t *allocateStub(const GlobalValue *F, unsigned StubSize,
|
||||
unsigned Alignment) {
|
||||
llvm_unreachable("Unexpected call!");
|
||||
return 0;
|
||||
}
|
||||
virtual void endFunctionBody(const Function *F, uint8_t *FunctionStart,
|
||||
uint8_t *FunctionEnd) {
|
||||
llvm_unreachable("Unexpected call!");
|
||||
}
|
||||
virtual uint8_t *allocateSpace(intptr_t Size, unsigned Alignment) {
|
||||
llvm_unreachable("Unexpected call!");
|
||||
return 0;
|
||||
}
|
||||
virtual uint8_t *allocateGlobal(uintptr_t Size, unsigned Alignment) {
|
||||
llvm_unreachable("Unexpected call!");
|
||||
return 0;
|
||||
}
|
||||
virtual void deallocateFunctionBody(void *Body) {
|
||||
llvm_unreachable("Unexpected call!");
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user