mirror of
https://github.com/xenia-project/xenia.git
synced 2025-12-06 07:12:03 +01:00
Adding a shared scratch arena for compiler passes.
This commit is contained in:
parent
e6f3716d87
commit
6bd214af0b
|
|
@ -20,6 +20,8 @@ using namespace alloy::runtime;
|
||||||
|
|
||||||
Compiler::Compiler(Runtime* runtime) :
|
Compiler::Compiler(Runtime* runtime) :
|
||||||
runtime_(runtime) {
|
runtime_(runtime) {
|
||||||
|
scratch_arena_ = new Arena();
|
||||||
|
|
||||||
alloy::tracing::WriteEvent(EventType::Init({
|
alloy::tracing::WriteEvent(EventType::Init({
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
@ -32,6 +34,8 @@ Compiler::~Compiler() {
|
||||||
delete pass;
|
delete pass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete scratch_arena_;
|
||||||
|
|
||||||
alloy::tracing::WriteEvent(EventType::Deinit({
|
alloy::tracing::WriteEvent(EventType::Deinit({
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
@ -49,6 +53,7 @@ int Compiler::Compile(HIRBuilder* builder) {
|
||||||
// stop changing things, etc.
|
// stop changing things, etc.
|
||||||
for (auto it = passes_.begin(); it != passes_.end(); ++it) {
|
for (auto it = passes_.begin(); it != passes_.end(); ++it) {
|
||||||
CompilerPass* pass = *it;
|
CompilerPass* pass = *it;
|
||||||
|
scratch_arena_->Reset();
|
||||||
if (pass->Run(builder)) {
|
if (pass->Run(builder)) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ public:
|
||||||
~Compiler();
|
~Compiler();
|
||||||
|
|
||||||
runtime::Runtime* runtime() const { return runtime_; }
|
runtime::Runtime* runtime() const { return runtime_; }
|
||||||
|
Arena* scratch_arena() const { return scratch_arena_; }
|
||||||
|
|
||||||
void AddPass(CompilerPass* pass);
|
void AddPass(CompilerPass* pass);
|
||||||
|
|
||||||
|
|
@ -37,6 +38,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
runtime::Runtime* runtime_;
|
runtime::Runtime* runtime_;
|
||||||
|
Arena* scratch_arena_;
|
||||||
|
|
||||||
typedef std::vector<CompilerPass*> PassList;
|
typedef std::vector<CompilerPass*> PassList;
|
||||||
PassList passes_;
|
PassList passes_;
|
||||||
|
|
|
||||||
|
|
@ -27,3 +27,7 @@ int CompilerPass::Initialize(Compiler* compiler) {
|
||||||
compiler_ = compiler;
|
compiler_ = compiler;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Arena* CompilerPass::scratch_arena() const {
|
||||||
|
return compiler_->scratch_arena();
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,9 @@ public:
|
||||||
|
|
||||||
virtual int Run(hir::HIRBuilder* builder) = 0;
|
virtual int Run(hir::HIRBuilder* builder) = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Arena* scratch_arena() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
runtime::Runtime* runtime_;
|
runtime::Runtime* runtime_;
|
||||||
Compiler* compiler_;
|
Compiler* compiler_;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue