mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 12:38:12 +00:00
LibJS: Add a basic pass manager and add some basic passes
This commit adds a bunch of passes, the most interesting of which is a pass that merges blocks together, and a pass that places blocks that flow into each other next to each other, and a very simply pass that removes duplicate basic blocks. Note that this does not remove the jump at the end of each block in that pass to avoid scope creep in the passes.
This commit is contained in:
parent
e81fd7106b
commit
1414c7b049
17 changed files with 751 additions and 30 deletions
|
@ -165,4 +165,38 @@ void Interpreter::continue_pending_unwind(Label const& resume_label)
|
|||
jump(resume_label);
|
||||
}
|
||||
}
|
||||
|
||||
AK::Array<OwnPtr<PassManager>, static_cast<UnderlyingType<Interpreter::OptimizationLevel>>(Interpreter::OptimizationLevel::__Count)> Interpreter::s_optimization_pipelines {};
|
||||
|
||||
Bytecode::PassManager& Interpreter::optimization_pipeline(Interpreter::OptimizationLevel level)
|
||||
{
|
||||
auto underlying_level = to_underlying(level);
|
||||
VERIFY(underlying_level <= to_underlying(Interpreter::OptimizationLevel::__Count));
|
||||
auto& entry = s_optimization_pipelines[underlying_level];
|
||||
|
||||
if (entry)
|
||||
return *entry;
|
||||
|
||||
auto pm = make<PassManager>();
|
||||
if (level == OptimizationLevel::Default) {
|
||||
pm->add<Passes::GenerateCFG>();
|
||||
pm->add<Passes::UnifySameBlocks>();
|
||||
pm->add<Passes::GenerateCFG>();
|
||||
pm->add<Passes::MergeBlocks>();
|
||||
pm->add<Passes::GenerateCFG>();
|
||||
pm->add<Passes::UnifySameBlocks>();
|
||||
pm->add<Passes::GenerateCFG>();
|
||||
pm->add<Passes::MergeBlocks>();
|
||||
pm->add<Passes::GenerateCFG>();
|
||||
pm->add<Passes::PlaceBlocks>();
|
||||
} else {
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
auto& passes = *pm;
|
||||
entry = move(pm);
|
||||
|
||||
return passes;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue