diff options
author | Nicolas Geoffray <nicolas.geoffray@lip6.fr> | 2008-04-16 20:46:05 +0000 |
---|---|---|
committer | Nicolas Geoffray <nicolas.geoffray@lip6.fr> | 2008-04-16 20:46:05 +0000 |
commit | 51cc3c13eac78da242f0518fc42580e48dd5304f (patch) | |
tree | 8cabb5d8c03920e8df85546c5c76465ae2dc131e /lib/ExecutionEngine/JIT | |
parent | e20bbc81012e636cb59bbbe3a114895a2f7fa0da (diff) | |
download | external_llvm-51cc3c13eac78da242f0518fc42580e48dd5304f.zip external_llvm-51cc3c13eac78da242f0518fc42580e48dd5304f.tar.gz external_llvm-51cc3c13eac78da242f0518fc42580e48dd5304f.tar.bz2 |
Correlate stubs with functions in JIT: when emitting a stub, the JIT tells the memory manager which function
the stub will resolve.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49814 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine/JIT')
-rw-r--r-- | lib/ExecutionEngine/JIT/JITEmitter.cpp | 18 | ||||
-rw-r--r-- | lib/ExecutionEngine/JIT/JITMemoryManager.cpp | 7 |
2 files changed, 15 insertions, 10 deletions
diff --git a/lib/ExecutionEngine/JIT/JITEmitter.cpp b/lib/ExecutionEngine/JIT/JITEmitter.cpp index 64d3cd7..1a0bb26 100644 --- a/lib/ExecutionEngine/JIT/JITEmitter.cpp +++ b/lib/ExecutionEngine/JIT/JITEmitter.cpp @@ -175,7 +175,7 @@ void *JITResolver::getFunctionStub(Function *F) { // Otherwise, codegen a new stub. For now, the stub will call the lazy // resolver function. - Stub = TheJIT->getJITInfo().emitFunctionStub(Actual, + Stub = TheJIT->getJITInfo().emitFunctionStub(F, Actual, *TheJIT->getCodeEmitter()); if (Actual != (void*)(intptr_t)LazyResolverFn) { @@ -204,7 +204,7 @@ void *JITResolver::getGlobalValueLazyPtr(GlobalValue *GV, void *GVAddress) { if (LazyPtr) return LazyPtr; // Otherwise, codegen a new lazy pointer. - LazyPtr = TheJIT->getJITInfo().emitGlobalValueLazyPtr(GVAddress, + LazyPtr = TheJIT->getJITInfo().emitGlobalValueLazyPtr(GV, GVAddress, *TheJIT->getCodeEmitter()); DOUT << "JIT: Stub emitted at [" << LazyPtr << "] for GV '" @@ -220,7 +220,7 @@ void *JITResolver::getExternalFunctionStub(void *FnAddr) { void *&Stub = ExternalFnToStubMap[FnAddr]; if (Stub) return Stub; - Stub = TheJIT->getJITInfo().emitFunctionStub(FnAddr, + Stub = TheJIT->getJITInfo().emitFunctionStub(0, FnAddr, *TheJIT->getCodeEmitter()); DOUT << "JIT: Stub emitted at [" << Stub @@ -503,8 +503,9 @@ namespace { void initJumpTableInfo(MachineJumpTableInfo *MJTI); void emitJumpTableInfo(MachineJumpTableInfo *MJTI); - virtual void startFunctionStub(unsigned StubSize, unsigned Alignment = 1); - virtual void* finishFunctionStub(const Function *F); + virtual void startFunctionStub(const GlobalValue* F, unsigned StubSize, + unsigned Alignment = 1); + virtual void* finishFunctionStub(const GlobalValue *F); virtual void addRelocation(const MachineRelocation &MR) { Relocations.push_back(MR); @@ -822,16 +823,17 @@ void JITEmitter::emitJumpTableInfo(MachineJumpTableInfo *MJTI) { } } -void JITEmitter::startFunctionStub(unsigned StubSize, unsigned Alignment) { +void JITEmitter::startFunctionStub(const GlobalValue* F, unsigned StubSize, + unsigned Alignment) { SavedBufferBegin = BufferBegin; SavedBufferEnd = BufferEnd; SavedCurBufferPtr = CurBufferPtr; - BufferBegin = CurBufferPtr = MemMgr->allocateStub(StubSize, Alignment); + BufferBegin = CurBufferPtr = MemMgr->allocateStub(F, StubSize, Alignment); BufferEnd = BufferBegin+StubSize+1; } -void *JITEmitter::finishFunctionStub(const Function *F) { +void *JITEmitter::finishFunctionStub(const GlobalValue* F) { NumBytes += getCurrentPCOffset(); std::swap(SavedBufferBegin, BufferBegin); BufferEnd = SavedBufferEnd; diff --git a/lib/ExecutionEngine/JIT/JITMemoryManager.cpp b/lib/ExecutionEngine/JIT/JITMemoryManager.cpp index 5908e43..b07af2e 100644 --- a/lib/ExecutionEngine/JIT/JITMemoryManager.cpp +++ b/lib/ExecutionEngine/JIT/JITMemoryManager.cpp @@ -11,6 +11,7 @@ // //===----------------------------------------------------------------------===// +#include "llvm/GlobalValue.h" #include "llvm/ExecutionEngine/JITMemoryManager.h" #include "llvm/Support/Compiler.h" #include "llvm/System/Memory.h" @@ -265,7 +266,8 @@ namespace { void AllocateGOT(); - unsigned char *allocateStub(unsigned StubSize, unsigned Alignment); + unsigned char *allocateStub(const GlobalValue* F, unsigned StubSize, + unsigned Alignment); /// startFunctionBody - When a function starts, allocate a block of free /// executable memory, returning a pointer to it and its actual size. @@ -438,7 +440,8 @@ DefaultJITMemoryManager::~DefaultJITMemoryManager() { Blocks.clear(); } -unsigned char *DefaultJITMemoryManager::allocateStub(unsigned StubSize, +unsigned char *DefaultJITMemoryManager::allocateStub(const GlobalValue* F, + unsigned StubSize, unsigned Alignment) { CurStubPtr -= StubSize; CurStubPtr = (unsigned char*)(((intptr_t)CurStubPtr) & |