diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2021-06-09 06:49:58 +0430 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-09 09:07:29 +0200 |
commit | 01e8f0889acf9fc0c84402793ecf96859c737f9a (patch) | |
tree | d3451229cdfd0117929b2216ca91a011a34e2d9e /Userland/Libraries/LibJS/Bytecode/Label.h | |
parent | d7a25cdb82ff5326236934dd6e99e1a1b2bef3fe (diff) | |
download | serenity-01e8f0889acf9fc0c84402793ecf96859c737f9a.zip |
LibJS: Generate bytecode in basic blocks instead of one big block
This limits the size of each block (currently set to 1K), and gets us
closer to a canonical, more easily analysable bytecode format.
As a result of this, "Labels" are now simply entries to basic blocks.
Since there is no more 'conditional' jump (as all jumps are always
taken), JumpIf{True,False} are unified to JumpConditional, and
JumpIfNullish is renamed to JumpNullish.
Also fixes #7914 as a result of reimplementing the loop logic.
Diffstat (limited to 'Userland/Libraries/LibJS/Bytecode/Label.h')
-rw-r--r-- | Userland/Libraries/LibJS/Bytecode/Label.h | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/Userland/Libraries/LibJS/Bytecode/Label.h b/Userland/Libraries/LibJS/Bytecode/Label.h index 56eec29dd0..8174463f6e 100644 --- a/Userland/Libraries/LibJS/Bytecode/Label.h +++ b/Userland/Libraries/LibJS/Bytecode/Label.h @@ -7,20 +7,21 @@ #pragma once #include <AK/Format.h> +#include <LibJS/Bytecode/BasicBlock.h> namespace JS::Bytecode { class Label { public: - explicit Label(size_t address) - : m_address(address) + explicit Label(BasicBlock const& block) + : m_block(block) { } - size_t address() const { return m_address; } + auto& block() const { return m_block; } private: - size_t m_address { 0 }; + BasicBlock const& m_block; }; } @@ -29,6 +30,6 @@ template<> struct AK::Formatter<JS::Bytecode::Label> : AK::Formatter<FormatString> { void format(FormatBuilder& builder, JS::Bytecode::Label const& value) { - return AK::Formatter<FormatString>::format(builder, "@{:x}", value.address()); + return AK::Formatter<FormatString>::format(builder, "@{}", value.block().name()); } }; |