diff options
author | Reid Kleckner <reid@kleckner.net> | 2009-07-23 01:40:54 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2009-07-23 01:40:54 +0000 |
commit | 4bf370698a456bcc96d26184785eb4f5fab396f2 (patch) | |
tree | 30f156c6f9fbe2faa7faf0dbbf047dd053dd1d23 /lib/ExecutionEngine/JIT/JITEmitter.cpp | |
parent | 54e650f2c7bfcaec159ae41b2d79ce4a9a45edf8 (diff) |
Reverting r76825 and r76828, since they caused clang runtime errors and some build failure involving memset.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76838 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine/JIT/JITEmitter.cpp')
-rw-r--r-- | lib/ExecutionEngine/JIT/JITEmitter.cpp | 51 |
1 files changed, 9 insertions, 42 deletions
diff --git a/lib/ExecutionEngine/JIT/JITEmitter.cpp b/lib/ExecutionEngine/JIT/JITEmitter.cpp index 246a0ce76f..ce52273b00 100644 --- a/lib/ExecutionEngine/JIT/JITEmitter.cpp +++ b/lib/ExecutionEngine/JIT/JITEmitter.cpp @@ -51,7 +51,6 @@ using namespace llvm; STATISTIC(NumBytes, "Number of bytes of machine code compiled"); STATISTIC(NumRelos, "Number of relocations applied"); -STATISTIC(NumRetries, "Number of retries with more memory"); static JIT *TheJIT = 0; @@ -426,12 +425,6 @@ namespace { // save BufferBegin/BufferEnd/CurBufferPtr here. uint8_t *SavedBufferBegin, *SavedBufferEnd, *SavedCurBufferPtr; - // When reattempting to JIT a function after running out of space, we store - // the estimated size of the function we're trying to JIT here, so we can - // ask the memory manager for at least this much space. When we - // successfully emit the function, we reset this back to zero. - uintptr_t SizeEstimate; - /// Relocations - These are the relocations that the function needs, as /// emitted. std::vector<MachineRelocation> Relocations; @@ -503,8 +496,7 @@ namespace { DebugLocTuple PrevDLT; public: - JITEmitter(JIT &jit, JITMemoryManager *JMM) - : SizeEstimate(0), Resolver(jit), CurFn(0) { + JITEmitter(JIT &jit, JITMemoryManager *JMM) : Resolver(jit), CurFn(0) { MemMgr = JMM ? JMM : JITMemoryManager::CreateDefaultMemManager(); if (jit.getJITInfo().needsGOT()) { MemMgr->AllocateGOT(); @@ -569,14 +561,9 @@ namespace { return MBBLocations[MBB->getNumber()]; } - /// retryWithMoreMemory - Log a retry and deallocate all memory for the - /// given function. Increase the minimum allocation size so that we get - /// more memory next time. - void retryWithMoreMemory(MachineFunction &F); - /// deallocateMemForFunction - Deallocate all memory for the specified /// function body. - void deallocateMemForFunction(const Function *F); + void deallocateMemForFunction(Function *F); /// AddStubToCurrentFunction - Mark the current function being JIT'd as /// using the stub at the specified address. Allows @@ -938,9 +925,6 @@ void JITEmitter::startFunction(MachineFunction &F) { // previously allocated. ActualSize += GetSizeOfGlobalsInBytes(F); DOUT << "JIT: ActualSize after globals " << ActualSize << "\n"; - } else if (SizeEstimate > 0) { - // SizeEstimate will be non-zero on reallocation attempts. - ActualSize = SizeEstimate; } BufferBegin = CurBufferPtr = MemMgr->startFunctionBody(F.getFunction(), @@ -965,15 +949,12 @@ void JITEmitter::startFunction(MachineFunction &F) { bool JITEmitter::finishFunction(MachineFunction &F) { if (CurBufferPtr == BufferEnd) { - // We must call endFunctionBody before retrying, because - // deallocateMemForFunction requires it. - MemMgr->endFunctionBody(F.getFunction(), BufferBegin, CurBufferPtr); - retryWithMoreMemory(F); - return true; + // FIXME: Allocate more space, then try again. + llvm_report_error("JIT: Ran out of space for generated machine code!"); } - + emitJumpTableInfo(F.getJumpTableInfo()); - + // FnStart is the start of the text, not the start of the constant pool and // other per-function data. uint8_t *FnStart = @@ -1064,12 +1045,8 @@ bool JITEmitter::finishFunction(MachineFunction &F) { MemMgr->endFunctionBody(F.getFunction(), BufferBegin, CurBufferPtr); if (CurBufferPtr == BufferEnd) { - retryWithMoreMemory(F); - return true; - } else { - // Now that we've succeeded in emitting the function, reset the - // SizeEstimate back down to zero. - SizeEstimate = 0; + // FIXME: Allocate more space, then try again. + llvm_report_error("JIT: Ran out of space for generated machine code!"); } BufferBegin = CurBufferPtr = 0; @@ -1154,19 +1131,9 @@ bool JITEmitter::finishFunction(MachineFunction &F) { return false; } -void JITEmitter::retryWithMoreMemory(MachineFunction &F) { - DOUT << "JIT: Ran out of space for native code. Reattempting.\n"; - Relocations.clear(); // Clear the old relocations or we'll reapply them. - ConstPoolAddresses.clear(); - ++NumRetries; - deallocateMemForFunction(F.getFunction()); - // Try again with at least twice as much free space. - SizeEstimate = (uintptr_t)(2 * (BufferEnd - BufferBegin)); -} - /// deallocateMemForFunction - Deallocate all memory for the specified /// function body. Also drop any references the function has to stubs. -void JITEmitter::deallocateMemForFunction(const Function *F) { +void JITEmitter::deallocateMemForFunction(Function *F) { MemMgr->deallocateMemForFunction(F); // If the function did not reference any stubs, return. |