ladybird/Userland/Libraries/LibJS/Bytecode/Label.h
Ali Mohammad Pur 01e8f0889a 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.
2021-06-09 09:07:29 +02:00

36 lines
675 B
C++

/*
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Format.h>
#include <LibJS/Bytecode/BasicBlock.h>
namespace JS::Bytecode {
class Label {
public:
explicit Label(BasicBlock const& block)
: m_block(block)
{
}
auto& block() const { return m_block; }
private:
BasicBlock const& m_block;
};
}
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, "@{}", value.block().name());
}
};