Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(24)

Issue 71042: Patch to allow the JITMemoryManager to allocate more blocks of memory. (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
14 years, 10 months ago by Reid Kleckner
Modified:
14 years, 9 months ago
CC:
unladen-swallow_googlegroups.com
Base URL:
http://llvm.org/svn/llvm-project/llvm/trunk/
Visibility:
Public.

Description

This fixes the FIXMEs for stubs, globals, and code. For stubs and global data, the memory manager uses the simple BumpAllocator class, which keeps a vector of memory slabs and a pair of pointers that it bumps along to make allocations. For especially large allocations, it allocates a separate slab. This is done so that in the worst case it wastes at most an amount of space equal to the threshold at the end of the block, or a page at the end of the separate slab. For code, the memory manager adds the ability to request more memory by allocating more code slabs and adding them to the free list. If memory gets fragmented, this could become a problem, since each allocation loops over the entire free list. When the JITEmitter runs out of memory, it now frees the memory it has been working with so far, asks for twice as much memory, and tries again until it succeeds.

Patch Set 1 #

Total comments: 18

Patch Set 2 : Addressed comments, but the code is still buggy. #

Patch Set 3 : Added unittests to exercise the code. #

Patch Set 4 : Patch to clear out old relocations when reemitting code. #

Total comments: 34

Patch Set 5 : Addressed Jeffrey's comments. Fixed up CheckInvariants. #

Total comments: 45

Patch Set 6 : Fixed style issues. #

Patch Set 7 : Updated to use a bump allocator for both global data and function stubs #

Total comments: 41

Patch Set 8 : Addressed review comments. #

Total comments: 6

Patch Set 9 : ... #

Patch Set 10 : Modified LLI to make nightly tests pass with the new memory manager. #

Patch Set 11 : Merged bump allocators. #

Patch Set 12 : ... #

Total comments: 8

Patch Set 13 : Templatized BumpPtrAllocator. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+940 lines, -254 lines) Patch
M include/llvm/ExecutionEngine/JITMemoryManager.h View 1 2 3 4 5 6 7 8 9 10 11 4 chunks +60 lines, -9 lines 0 comments Download
M include/llvm/Support/Allocator.h View 11 12 3 chunks +201 lines, -12 lines 0 comments Download
M include/llvm/System/Memory.h View 8 9 10 11 3 chunks +6 lines, -3 lines 0 comments Download
M lib/ExecutionEngine/JIT/JITEmitter.cpp View 1 2 3 4 5 6 7 8 9 10 11 8 chunks +42 lines, -9 lines 0 comments Download
M lib/ExecutionEngine/JIT/JITMemoryManager.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 11 chunks +271 lines, -95 lines 0 comments Download
M lib/Support/Allocator.cpp View 11 12 1 chunk +8 lines, -119 lines 0 comments Download
M lib/System/Unix/Memory.inc View 8 9 10 11 2 chunks +4 lines, -3 lines 0 comments Download
M lib/System/Win32/Memory.inc View 8 9 10 11 2 chunks +4 lines, -3 lines 0 comments Download
M tools/lli/lli.cpp View 10 11 1 chunk +7 lines, -1 line 0 comments Download
A unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp View 3 4 5 6 7 8 9 10 1 chunk +276 lines, -0 lines 0 comments Download
A unittests/Support/AllocatorTest.cpp View 1 chunk +61 lines, -0 lines 0 comments Download

Messages

Total messages: 17
Reid Kleckner
14 years, 10 months ago (2009-06-11 00:36:51 UTC) #1
Jeffrey Yasskin
http://codereview.appspot.com/71042/diff/1/3 File lib/ExecutionEngine/JIT/JITEmitter.cpp (right): http://codereview.appspot.com/71042/diff/1/3#newcode1061 Line 1061: DOUT << "JIT: Ran out of space for ...
14 years, 10 months ago (2009-06-11 04:56:44 UTC) #2
Reid Kleckner
I also added some unittests to exercise this code, which pass. I think it all ...
14 years, 10 months ago (2009-06-12 22:28:15 UTC) #3
Reid Kleckner
14 years, 10 months ago (2009-06-15 19:55:37 UTC) #4
Jeffrey Yasskin
http://codereview.appspot.com/71042/diff/5013/5019 File lib/ExecutionEngine/JIT/JITEmitter.cpp (right): http://codereview.appspot.com/71042/diff/5013/5019#newcode1070 Line 1070: MemMgr->endFunctionBody(F.getFunction(), BufferBegin, CurBufferPtr); I'm not particularly happy having ...
14 years, 10 months ago (2009-06-16 18:04:03 UTC) #5
Reid Kleckner
Thanks Jeffrey, there was a lot to improve. http://codereview.appspot.com/71042/diff/5013/5019 File lib/ExecutionEngine/JIT/JITEmitter.cpp (right): http://codereview.appspot.com/71042/diff/5013/5019#newcode1070 Line 1070: ...
14 years, 10 months ago (2009-06-16 23:31:57 UTC) #6
Jeffrey Yasskin
Mostly LGTM. Nick, could you take a look from an LLVM perspective? http://codereview.appspot.com/71042/diff/5023/5024 File include/llvm/ExecutionEngine/JITMemoryManager.h ...
14 years, 10 months ago (2009-06-17 01:59:53 UTC) #7
nlewycky
http://codereview.appspot.com/71042/diff/5023/5024 File include/llvm/ExecutionEngine/JITMemoryManager.h (right): http://codereview.appspot.com/71042/diff/5023/5024#newcode140 Line 140: virtual std::string CheckInvariants() { Why on earth does ...
14 years, 10 months ago (2009-06-17 04:53:57 UTC) #8
Reid Kleckner
http://codereview.appspot.com/71042/diff/5023/5024 File include/llvm/ExecutionEngine/JITMemoryManager.h (right): http://codereview.appspot.com/71042/diff/5023/5024#newcode138 Line 138: /// CheckInvariants - For testing only. Return true ...
14 years, 10 months ago (2009-06-17 20:29:57 UTC) #9
Reid Kleckner
I updated this patch to deal with globals and other things. Could you guys take ...
14 years, 9 months ago (2009-07-09 22:11:38 UTC) #10
Jeffrey Yasskin
http://codereview.appspot.com/71042/diff/8001/9002 File include/llvm/CodeGen/JITCodeEmitter.h (right): http://codereview.appspot.com/71042/diff/8001/9002#newcode260 Line 260: Result = 0; // NULL ptr here! If ...
14 years, 9 months ago (2009-07-10 17:52:59 UTC) #11
Reid Kleckner
I'll get started running the nightly tests on this. http://codereview.appspot.com/71042/diff/8001/9002 File include/llvm/CodeGen/JITCodeEmitter.h (right): http://codereview.appspot.com/71042/diff/8001/9002#newcode260 Line ...
14 years, 9 months ago (2009-07-13 22:18:00 UTC) #12
Jeffrey Yasskin
LGTM. If llvm-commits hasn't gotten back to you by the end of tomorrow, go ahead ...
14 years, 9 months ago (2009-07-13 22:33:00 UTC) #13
Reid Kleckner
http://codereview.appspot.com/71042/diff/9010/9017 File lib/ExecutionEngine/JIT/JITMemoryManager.cpp (right): http://codereview.appspot.com/71042/diff/9010/9017#newcode295 Line 295: /// AlignPtr - Align Ptr to Alignment bytes, ...
14 years, 9 months ago (2009-07-13 22:47:23 UTC) #14
Reid Kleckner
Please take a look at my attempt to merge the bump allocators.
14 years, 9 months ago (2009-07-20 17:17:34 UTC) #15
Jeffrey Yasskin
Looks decent http://codereview.appspot.com/71042/diff/12011/12014 File include/llvm/Support/Allocator.h (left): http://codereview.appspot.com/71042/diff/12011/12014#oldcode52 Line 52: void *TheMemory; You may get pushback ...
14 years, 9 months ago (2009-07-20 18:12:59 UTC) #16
Reid Kleckner
14 years, 9 months ago (2009-07-20 18:37:29 UTC) #17
Thanks for the review!

http://codereview.appspot.com/71042/diff/12011/12014
File include/llvm/Support/Allocator.h (right):

http://codereview.appspot.com/71042/diff/12011/12014#newcode62
Line 62: virtual sys::MemoryBlock Allocate(size_t Size, size_t Alignment);
On 2009/07/20 18:12:59, Jeffrey Yasskin wrote:
> This should just forward to the MallocAllocator, I think.

Done.

http://codereview.appspot.com/71042/diff/12011/12014#newcode83
Line 83: /// malloc or mmap.
On 2009/07/20 18:12:59, Jeffrey Yasskin wrote:
> It's not going to be malloc or mmap themselves; it's a wrapper around them.

Done.

http://codereview.appspot.com/71042/diff/12011/12021
File lib/Support/Allocator.cpp (right):

http://codereview.appspot.com/71042/diff/12011/12021#newcode134
Line 134: Base = BumpPtrAllocator::AlignPtr((char*)Base, Alignment);
On 2009/07/20 18:12:59, Jeffrey Yasskin wrote:
> If this case runs and adjusts the pointer, MallocSlabAllocator::Free() can
> crash, since you're only allowed to pass the exact result of malloc() to
free().

Ach, true!  In any case, now that I forward to malloc allocator, this code is
gone.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b