[llvm-commits] [unladen-swallow] Re: Patch to allow the JITMemoryManager to allocate more blocks of memory

Reid Kleckner rnk at mit.edu
Mon Jul 13 16:57:41 PDT 2009


On Tue, Jun 23, 2009 at 11:11 PM, Chris Lattner<clattner at apple.com> wrote:
> Have you run through the llvm testsuite with the initial threshold cranked
> way down?  This would cause the test suite to check out whether the
> reallocation stuff is working.  If that works, it looks good to me.

So, getting back to this patch, I went ahead and did all the FIXMEs in
JITMemoryManager.cpp.  This means that it will not run out of memory
for function stubs, global data, or code until the OS gives up.

I've added some unit tests which now pass, and the SPASS test passes
with lli.  I had to modify lli to not allocate globals with code,
though, but I think that should eventually become the default.  I'm
running the rest of the nightly tests right now.

I've attached the patch and here's the Rietveld link if you prefer:
http://codereview.appspot.com/71042/show

Here's a description of how the patch works:

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 space in the buffer it got on its
first try, it now frees the memory it has been working with so far,
asks for twice as much memory, and tries again until it succeeds.

Please review!

Thanks,
Reid
-------------- next part --------------
A non-text attachment was scrubbed...
Name: JITMemoryManager.diff
Type: text/x-diff
Size: 44914 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20090713/4a1e31be/attachment.diff>


More information about the llvm-commits mailing list