mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:17:44 +00:00
LibJS/Bytecode: Add peephole optimization pass and fuse compare+jump
This patch adds a new "Peephole" pass for performing small, local optimizations to bytecode. We also introduce the first such optimization, fusing a sequence of some comparison instruction FooCompare followed by a JumpIf into a new set of JumpFooCompare instructions. This gives a ~50% speed-up on the following microbenchmark: for (let i = 0; i < 10_000_000; ++i) { } But more traditional benchmarks see a pretty sizable speed-up as well, for example 15% on Kraken/ai-astar.js and 16% on Kraken/audio-dft.js :^)
This commit is contained in:
parent
acd29e064c
commit
4438ec481c
8 changed files with 214 additions and 24 deletions
|
@ -82,15 +82,15 @@ public:
|
|||
op->set_source_record({ start_offset, end_offset });
|
||||
}
|
||||
|
||||
private:
|
||||
explicit BasicBlock(String name);
|
||||
|
||||
void terminate(size_t slot_offset)
|
||||
{
|
||||
m_terminated = true;
|
||||
m_terminator_offset = slot_offset;
|
||||
}
|
||||
|
||||
private:
|
||||
explicit BasicBlock(String name);
|
||||
|
||||
Vector<u8> m_buffer;
|
||||
BasicBlock const* m_handler { nullptr };
|
||||
BasicBlock const* m_finalizer { nullptr };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue