summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/lib/ExecutionEngine/MCJIT/MCJITMemoryManager.h
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm/lib/ExecutionEngine/MCJIT/MCJITMemoryManager.h')
-rw-r--r--contrib/llvm/lib/ExecutionEngine/MCJIT/MCJITMemoryManager.h47
1 files changed, 16 insertions, 31 deletions
diff --git a/contrib/llvm/lib/ExecutionEngine/MCJIT/MCJITMemoryManager.h b/contrib/llvm/lib/ExecutionEngine/MCJIT/MCJITMemoryManager.h
index 40bc031..a68949a 100644
--- a/contrib/llvm/lib/ExecutionEngine/MCJIT/MCJITMemoryManager.h
+++ b/contrib/llvm/lib/ExecutionEngine/MCJIT/MCJITMemoryManager.h
@@ -21,45 +21,30 @@ namespace llvm {
// and the RuntimeDyld interface that maps objects, by name, onto their
// matching LLVM IR counterparts in the module(s) being compiled.
class MCJITMemoryManager : public RTDyldMemoryManager {
+ virtual void anchor();
JITMemoryManager *JMM;
// FIXME: Multiple modules.
Module *M;
public:
- MCJITMemoryManager(JITMemoryManager *jmm, Module *m) : JMM(jmm), M(m) {}
+ MCJITMemoryManager(JITMemoryManager *jmm, Module *m) :
+ JMM(jmm?jmm:JITMemoryManager::CreateDefaultMemManager()), M(m) {}
+ // We own the JMM, so make sure to delete it.
+ ~MCJITMemoryManager() { delete JMM; }
+
+ uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment,
+ unsigned SectionID) {
+ return JMM->allocateSpace(Size, Alignment);
+ }
- // Allocate ActualSize bytes, or more, for the named function. Return
- // a pointer to the allocated memory and update Size to reflect how much
- // memory was acutally allocated.
- uint8_t *startFunctionBody(const char *Name, uintptr_t &Size) {
- // FIXME: This should really reference the MCAsmInfo to get the global
- // prefix.
- if (Name[0] == '_') ++Name;
- Function *F = M->getFunction(Name);
- // Some ObjC names have a prefixed \01 in the IR. If we failed to find
- // the symbol and it's of the ObjC conventions (starts with "-"), try
- // prepending a \01 and see if we can find it that way.
- if (!F && Name[0] == '-')
- F = M->getFunction((Twine("\1") + Name).str());
- assert(F && "No matching function in JIT IR Module!");
- return JMM->startFunctionBody(F, Size);
+ uint8_t *allocateCodeSection(uintptr_t Size, unsigned Alignment,
+ unsigned SectionID) {
+ return JMM->allocateSpace(Size, Alignment);
}
- // Mark the end of the function, including how much of the allocated
- // memory was actually used.
- void endFunctionBody(const char *Name, uint8_t *FunctionStart,
- uint8_t *FunctionEnd) {
- // FIXME: This should really reference the MCAsmInfo to get the global
- // prefix.
- if (Name[0] == '_') ++Name;
- Function *F = M->getFunction(Name);
- // Some ObjC names have a prefixed \01 in the IR. If we failed to find
- // the symbol and it's of the ObjC conventions (starts with "-"), try
- // prepending a \01 and see if we can find it that way.
- if (!F && Name[0] == '-')
- F = M->getFunction((Twine("\1") + Name).str());
- assert(F && "No matching function in JIT IR Module!");
- JMM->endFunctionBody(F, FunctionStart, FunctionEnd);
+ virtual void *getPointerToNamedFunction(const std::string &Name,
+ bool AbortOnFailure = true) {
+ return JMM->getPointerToNamedFunction(Name, AbortOnFailure);
}
};
OpenPOWER on IntegriCloud