[llvm-commits] Changes to BumpPtrAllocator so it can be used for JITed function stubs and globals
Chris Lattner
clattner at apple.com
Tue Jul 21 21:20:38 PDT 2009
On Jul 21, 2009, at 2:09 PM, Reid Kleckner wrote:
> I made some changes in response to djg's comments on IRC.
> BumpPtrAllocatorBase now takes a template parameter for the slab
> allocator, and BumpPtrAllocator just fills in the default malloc
> allocator. PTAL.
Hi Reid,
Some general comments:
+++ include/llvm/Support/Allocator.h (working copy)
@@ -15,6 +15,9 @@
#define LLVM_SUPPORT_ALLOCATOR_H
#include "llvm/Support/AlignOf.h"
+#include "llvm/Support/DataTypes.h"
+#include "llvm/Support/raw_ostream.h"
+#include <cassert>
#include <cstdlib>
Allocator.h shouldn't depend on raw_ostream.
A general comment about your patch: previously, the implementation
details of the bump pointer allocator were nicely hidden in
Allocator.cpp and the Allocator.h file was small and straight-
forward. Now, tons of guts are exposed. :(
"Slab allocation" is relatively expensive anyway, so I don't see a
problem with going through a virtual method to do it. How about
adding a very simple class like this:
class SlabAllocator {
public:
virtual MemSlab *Allocate(size_t Size) = 0;
virtual void Deallocate(MemSlab *Slab) = 0;
};
and give BumpPtrAllocator a "SlabAllocator*" that it allocates
through? This would allow the implementation of MallocSlabAllocator
to be hidden completely in the .cpp file and allow the guts of
BumpPtrAllocator to be in the .cpp file (and not be a template). What
do you think?
-Chris
More information about the llvm-commits
mailing list