diff options
author | Hendiadyoin1 <leon.a@serenityos.org> | 2022-11-26 14:42:36 +0100 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2022-12-03 17:07:30 +0330 |
commit | 192897c26964f0abff113d17d128c0353f9acf2c (patch) | |
tree | fc659a2be7c4f28e1b011833ea8ebcae5dc33ffd /Userland/Libraries/LibJS | |
parent | 8c4717fc6e2df02804942c75f6aa2efbe93c1ecc (diff) | |
download | serenity-192897c26964f0abff113d17d128c0353f9acf2c.zip |
LibJS: Remeber which instruction terminated a block
Diffstat (limited to 'Userland/Libraries/LibJS')
-rw-r--r-- | Userland/Libraries/LibJS/Bytecode/BasicBlock.h | 7 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Bytecode/Generator.h | 4 |
2 files changed, 6 insertions, 5 deletions
diff --git a/Userland/Libraries/LibJS/Bytecode/BasicBlock.h b/Userland/Libraries/LibJS/Bytecode/BasicBlock.h index b5f7c83eae..04541cd108 100644 --- a/Userland/Libraries/LibJS/Bytecode/BasicBlock.h +++ b/Userland/Libraries/LibJS/Bytecode/BasicBlock.h @@ -36,8 +36,9 @@ public: bool can_grow(size_t additional_size) const { return m_buffer_size + additional_size <= m_buffer_capacity; } void grow(size_t additional_size); - void terminate(Badge<Generator>) { m_is_terminated = true; } - bool is_terminated() const { return m_is_terminated; } + void terminate(Badge<Generator>, Instruction const* terminator) { m_terminator = terminator; } + bool is_terminated() const { return m_terminator != nullptr; } + Instruction const* terminator() const { return m_terminator; } String const& name() const { return m_name; } @@ -45,9 +46,9 @@ private: BasicBlock(String name, size_t size); u8* m_buffer { nullptr }; + Instruction const* m_terminator { nullptr }; size_t m_buffer_capacity { 0 }; size_t m_buffer_size { 0 }; - bool m_is_terminated { false }; String m_name; }; diff --git a/Userland/Libraries/LibJS/Bytecode/Generator.h b/Userland/Libraries/LibJS/Bytecode/Generator.h index 85ee15a3b4..7ba96a7e47 100644 --- a/Userland/Libraries/LibJS/Bytecode/Generator.h +++ b/Userland/Libraries/LibJS/Bytecode/Generator.h @@ -57,7 +57,7 @@ public: grow(sizeof(OpType)); new (slot) OpType(forward<Args>(args)...); if constexpr (OpType::IsTerminator) - m_current_basic_block->terminate({}); + m_current_basic_block->terminate({}, static_cast<Instruction const*>(slot)); return *static_cast<OpType*>(slot); } @@ -76,7 +76,7 @@ public: grow(size_to_allocate); new (slot) OpType(forward<Args>(args)...); if constexpr (OpType::IsTerminator) - m_current_basic_block->terminate({}); + m_current_basic_block->terminate({}, static_cast<Instruction const*>(slot)); return *static_cast<OpType*>(slot); } |