Skip to content
Browse files

Use ANode bumpallocator for types.

Tidy invoketable/set allocation.
  • Loading branch information...
1 parent b2b29c1 commit 4e9c38a2378fdd06f7d8473909209e75c79a6276 agemogolk committed Dec 5, 2012
Showing with 20 additions and 10 deletions.
  1. +5 −0 compiler/clay.hpp
  2. +2 −9 compiler/invoketables.cpp
  3. +13 −1 compiler/invoketables.hpp
View
5 compiler/clay.hpp
@@ -2703,6 +2703,10 @@ struct Type : public Object {
typeInfoInitialized(false)
{}
+ void *operator new(size_t num_bytes) {
+ return ANodeAllocator->Allocate(num_bytes, llvm::AlignOf<Type>::Alignment);
+ }
+ virtual void dealloc() { ANodeAllocator->Deallocate(this); }
llvm::DIType getDebugInfo() { return llvm::DIType(debugInfo); }
};
@@ -2886,6 +2890,7 @@ struct Pattern : public Object {
PatternKind kind;
Pattern(PatternKind kind)
: Object(PATTERN), kind(kind) {}
+
};
struct PatternCell : public Pattern {
View
11 compiler/invoketables.cpp
@@ -10,11 +10,6 @@
namespace clay {
-static llvm::SpecificBumpPtrAllocator<InvokeEntry> *invokeEntryAllocator
- = new llvm::SpecificBumpPtrAllocator<InvokeEntry>();
-static llvm::SpecificBumpPtrAllocator<InvokeSet> *invokeSetAllocator
- = new llvm::SpecificBumpPtrAllocator<InvokeSet>();
-
static llvm::ArrayRef<OverloadPtr> callableOverloads(ObjectPtr x);
@@ -163,8 +158,7 @@ InvokeSet* lookupInvokeSet(ObjectPtr callable,
}
OverloadPtr interface = callableInterface(callable);
llvm::ArrayRef<OverloadPtr> overloads = callableOverloads(callable);
- InvokeSet* invokeSet = invokeSetAllocator->Allocate();
- new ((void*)invokeSet) InvokeSet(callable, argsKey, interface, overloads);
+ InvokeSet* invokeSet = new InvokeSet(callable, argsKey, interface, overloads);
invokeSet->shouldLog = shouldLogCallable(callable);
bucket.push_back(invokeSet);
@@ -321,8 +315,7 @@ static InvokeEntry* newInvokeEntry(InvokeSet* parent,
MatchSuccessPtr match,
MatchSuccessPtr interfaceMatch)
{
- InvokeEntry* entry = invokeEntryAllocator->Allocate();
- new ((void*)entry) InvokeEntry(parent, match->callable, match->argsKey);
+ InvokeEntry* entry = new InvokeEntry(parent, match->callable, match->argsKey);
entry->origCode = match->code;
entry->code = clone(match->code);
entry->env = match->env;
View
14 compiler/invoketables.hpp
@@ -9,7 +9,12 @@ namespace clay {
struct InvokeSet;
+struct InvokeEntry;
+static llvm::SpecificBumpPtrAllocator<InvokeEntry> *invokeEntryAllocator
+ = new llvm::SpecificBumpPtrAllocator<InvokeEntry>();
+static llvm::SpecificBumpPtrAllocator<InvokeSet> *invokeSetAllocator
+ = new llvm::SpecificBumpPtrAllocator<InvokeSet>();
struct InvokeEntry {
InvokeSet *parent;
@@ -61,7 +66,10 @@ struct InvokeEntry {
for (size_t i = 0; i < CC_Count; ++i)
llvmCWrappers[i] = NULL;
}
-
+ void *operator new(size_t num_bytes) {
+ return invokeEntryAllocator->Allocate();
+ }
+ virtual void dealloc() { ANodeAllocator->Deallocate(this); }
llvm::DISubprogram getDebugInfo() { return llvm::DISubprogram(debugInfo); }
};
@@ -92,6 +100,10 @@ struct InvokeSet {
{
overloads.insert(overloads.end(), patternOverloads.begin(), patternOverloads.end());
}
+ void *operator new(size_t num_bytes) {
+ return invokeSetAllocator->Allocate();
+ }
+ virtual void dealloc() { ANodeAllocator->Deallocate(this); }
};
typedef vector< pair<OverloadPtr, MatchResultPtr> > MatchFailureVector;

0 comments on commit 4e9c38a

Please sign in to comment.
Something went wrong with that request. Please try again.