mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-25 14:05:15 +00:00
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.
35 lines
675 B
C++
35 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());
|
|
}
|
|
};
|