Adding a shared scratch arena for compiler passes.

This commit is contained in:
Ben Vanik
2014-02-08 22:01:51 -08:00
parent e6f3716d87
commit 6bd214af0b
4 changed files with 14 additions and 0 deletions

View File

@@ -20,6 +20,8 @@ using namespace alloy::runtime;
Compiler::Compiler(Runtime* runtime) :
runtime_(runtime) {
scratch_arena_ = new Arena();
alloy::tracing::WriteEvent(EventType::Init({
}));
}
@@ -32,6 +34,8 @@ Compiler::~Compiler() {
delete pass;
}
delete scratch_arena_;
alloy::tracing::WriteEvent(EventType::Deinit({
}));
}
@@ -49,6 +53,7 @@ int Compiler::Compile(HIRBuilder* builder) {
// stop changing things, etc.
for (auto it = passes_.begin(); it != passes_.end(); ++it) {
CompilerPass* pass = *it;
scratch_arena_->Reset();
if (pass->Run(builder)) {
return 1;
}