EE/JIT: unique_ptr-ify

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216361 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dylan Noblesmith
2014-08-25 00:58:15 +00:00
parent 0acfd7f0a4
commit 444aa2d525

View File

@@ -324,7 +324,7 @@ namespace {
// When emitting code into a memory block, this is the block. // When emitting code into a memory block, this is the block.
MemoryRangeHeader *CurBlock; MemoryRangeHeader *CurBlock;
uint8_t *GOTBase; // Target Specific reserved memory std::unique_ptr<uint8_t[]> GOTBase; // Target Specific reserved memory
public: public:
DefaultJITMemoryManager(); DefaultJITMemoryManager();
~DefaultJITMemoryManager(); ~DefaultJITMemoryManager();
@@ -525,7 +525,7 @@ namespace {
} }
uint8_t *getGOTBase() const override { uint8_t *getGOTBase() const override {
return GOTBase; return GOTBase.get();
} }
void deallocateBlock(void *Block) { void deallocateBlock(void *Block) {
@@ -638,21 +638,17 @@ DefaultJITMemoryManager::DefaultJITMemoryManager()
// Start out with the freelist pointing to Mem0. // Start out with the freelist pointing to Mem0.
FreeMemoryList = Mem0; FreeMemoryList = Mem0;
GOTBase = nullptr;
} }
void DefaultJITMemoryManager::AllocateGOT() { void DefaultJITMemoryManager::AllocateGOT() {
assert(!GOTBase && "Cannot allocate the got multiple times"); assert(!GOTBase && "Cannot allocate the got multiple times");
GOTBase = new uint8_t[sizeof(void*) * 8192]; GOTBase = make_unique<uint8_t[]>(sizeof(void*) * 8192);
HasGOT = true; HasGOT = true;
} }
DefaultJITMemoryManager::~DefaultJITMemoryManager() { DefaultJITMemoryManager::~DefaultJITMemoryManager() {
for (unsigned i = 0, e = CodeSlabs.size(); i != e; ++i) for (unsigned i = 0, e = CodeSlabs.size(); i != e; ++i)
sys::Memory::ReleaseRWX(CodeSlabs[i]); sys::Memory::ReleaseRWX(CodeSlabs[i]);
delete[] GOTBase;
} }
sys::MemoryBlock DefaultJITMemoryManager::allocateNewSlab(size_t size) { sys::MemoryBlock DefaultJITMemoryManager::allocateNewSlab(size_t size) {