mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 05:09:12 +00:00
LibJS/Bytecode: Do basic compare-and-jump peephole optimization
We now fuse sequences like [LessThan, JumpIf] to JumpLessThan. This is only allowed for temporaries (i.e VM registers) with no other references to them.
This commit is contained in:
parent
9bcb0feb4d
commit
7654da3851
Notes:
sideshowbarker
2024-07-18 00:41:35 +09:00
Author: https://github.com/awesomekling
Commit: 7654da3851
Pull-request: https://github.com/SerenityOS/serenity/pull/24276
Reviewed-by: https://github.com/Hendiadyoin1
Reviewed-by: https://github.com/shannonbooth
8 changed files with 166 additions and 28 deletions
|
@ -36,6 +36,12 @@ public:
|
|||
u8 const* data() const { return m_buffer.data(); }
|
||||
size_t size() const { return m_buffer.size(); }
|
||||
|
||||
void rewind()
|
||||
{
|
||||
m_buffer.resize_and_keep_capacity(m_last_instruction_start_offset);
|
||||
m_terminated = false;
|
||||
}
|
||||
|
||||
void grow(size_t additional_size);
|
||||
|
||||
void terminate(Badge<Generator>) { m_terminated = true; }
|
||||
|
@ -55,6 +61,9 @@ public:
|
|||
auto const& this_() const { return m_this; }
|
||||
void set_this(ScopedOperand operand) { m_this = operand; }
|
||||
|
||||
[[nodiscard]] size_t last_instruction_start_offset() const { return m_last_instruction_start_offset; }
|
||||
void set_last_instruction_start_offset(size_t offset) { m_last_instruction_start_offset = offset; }
|
||||
|
||||
private:
|
||||
explicit BasicBlock(u32 index, String name);
|
||||
|
||||
|
@ -68,6 +77,8 @@ private:
|
|||
HashMap<size_t, SourceRecord> m_source_map;
|
||||
|
||||
Optional<ScopedOperand> m_this;
|
||||
|
||||
size_t m_last_instruction_start_offset { 0 };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue