diff options
author | Jim Grosbach <grosbach@apple.com> | 2012-09-05 16:50:34 +0000 |
---|---|---|
committer | Jim Grosbach <grosbach@apple.com> | 2012-09-05 16:50:34 +0000 |
commit | 706f03a35db7029b2dbd2925552eb0d0472dcbb4 (patch) | |
tree | bc8714e6adb6b8c664c4e48dbf8a04f7133d4632 /tools/lli/RecordingMemoryManager.h | |
parent | 998d3cca2937393d91b04d4d6105d9e67dd3b1b6 (diff) |
MCJIT: Add faux remote target execution to lli for the MCJIT.
Simulate a remote target address space by allocating a seperate chunk of
memory for the target and re-mapping section addresses to that prior to
execution. Later we'll want to have a truly remote process, but for now
this gets us closer to being able to test the remote target
functionality outside LLDB.
rdar://12157052
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163216 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/lli/RecordingMemoryManager.h')
-rw-r--r-- | tools/lli/RecordingMemoryManager.h | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/tools/lli/RecordingMemoryManager.h b/tools/lli/RecordingMemoryManager.h new file mode 100644 index 0000000000..1590235a79 --- /dev/null +++ b/tools/lli/RecordingMemoryManager.h @@ -0,0 +1,78 @@ +//===- RecordingMemoryManager.h - LLI MCJIT recording memory manager ------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This memory manager allocates local storage and keeps a record of each +// allocation. Iterators are provided for all data and code allocations. +// +//===----------------------------------------------------------------------===// + +#ifndef RECORDINGMEMORYMANAGER_H +#define RECORDINGMEMORYMANAGER_H + +#include "llvm/ADT/SmallVector.h" +#include "llvm/ExecutionEngine/JITMemoryManager.h" +#include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/Memory.h" +#include <utility> + +namespace llvm { + +class RecordingMemoryManager : public JITMemoryManager { +public: + typedef std::pair<sys::MemoryBlock, unsigned> Allocation; + +private: + SmallVector<Allocation, 16> AllocatedDataMem; + SmallVector<Allocation, 16> AllocatedCodeMem; + +public: + RecordingMemoryManager() {} + virtual ~RecordingMemoryManager() {} + + typedef SmallVectorImpl<Allocation>::const_iterator const_data_iterator; + typedef SmallVectorImpl<Allocation>::const_iterator const_code_iterator; + + const_data_iterator data_begin() const { return AllocatedDataMem.begin(); } + const_data_iterator data_end() const { return AllocatedDataMem.end(); } + const_code_iterator code_begin() const { return AllocatedCodeMem.begin(); } + const_code_iterator code_end() const { return AllocatedCodeMem.end(); } + + uint8_t *allocateCodeSection(uintptr_t Size, unsigned Alignment, + unsigned SectionID); + + uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment, + unsigned SectionID); + + void *getPointerToNamedFunction(const std::string &Name, + bool AbortOnFailure = true); + // The following obsolete JITMemoryManager calls are stubbed out for + // this model. + void setMemoryWritable(); + void setMemoryExecutable(); + void setPoisonMemory(bool poison); + void AllocateGOT(); + uint8_t *getGOTBase() const; + uint8_t *startFunctionBody(const Function *F, uintptr_t &ActualSize); + uint8_t *allocateStub(const GlobalValue* F, unsigned StubSize, + unsigned Alignment); + void endFunctionBody(const Function *F, uint8_t *FunctionStart, + uint8_t *FunctionEnd); + uint8_t *allocateSpace(intptr_t Size, unsigned Alignment); + uint8_t *allocateGlobal(uintptr_t Size, unsigned Alignment); + void deallocateFunctionBody(void *Body); + uint8_t* startExceptionTable(const Function* F, uintptr_t &ActualSize); + void endExceptionTable(const Function *F, uint8_t *TableStart, + uint8_t *TableEnd, uint8_t* FrameRegister); + void deallocateExceptionTable(void *ET); + +}; + +} // end namespace llvm + +#endif |