1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:38:11 +00:00

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.
This commit is contained in:
Ali Mohammad Pur 2021-06-09 06:49:58 +04:30 committed by Andreas Kling
parent d7a25cdb82
commit 01e8f0889a
16 changed files with 392 additions and 174 deletions

View file

@ -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());
}
};