LibJS: Remove unused C++ bytecode block classes
The Rust bytecode generator now owns basic block construction. The old C++ BasicBlock class no longer has any users. Label no longer needs to translate from BasicBlock. Remove the now-empty Label.cpp from the build as well.
This commit is contained in:
parent
0af548b27d
commit
ef8ac6ea7d
8 changed files with 5 additions and 141 deletions
|
|
@ -1,32 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Andreas Kling <andreas@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <LibJS/Bytecode/BasicBlock.h>
|
||||
#include <LibJS/Bytecode/Op.h>
|
||||
|
||||
namespace JS::Bytecode {
|
||||
|
||||
NonnullOwnPtr<BasicBlock> BasicBlock::create(u32 index, String name)
|
||||
{
|
||||
return adopt_own(*new BasicBlock(index, move(name)));
|
||||
}
|
||||
|
||||
BasicBlock::BasicBlock(u32 index, String name)
|
||||
: m_index(index)
|
||||
, m_name(move(name))
|
||||
{
|
||||
}
|
||||
|
||||
BasicBlock::~BasicBlock() = default;
|
||||
|
||||
void BasicBlock::grow(size_t additional_size)
|
||||
{
|
||||
m_buffer.grow_capacity(m_buffer.size() + additional_size);
|
||||
m_buffer.resize(m_buffer.size() + additional_size);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,74 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Andreas Kling <andreas@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Badge.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibJS/Bytecode/Executable.h>
|
||||
#include <LibJS/Forward.h>
|
||||
|
||||
namespace JS::Bytecode {
|
||||
|
||||
class BasicBlock {
|
||||
AK_MAKE_NONCOPYABLE(BasicBlock);
|
||||
|
||||
public:
|
||||
static NonnullOwnPtr<BasicBlock> create(u32 index, String name);
|
||||
~BasicBlock();
|
||||
|
||||
u32 index() const { return m_index; }
|
||||
|
||||
ReadonlyBytes instruction_stream() const LIFETIME_BOUND { return m_buffer.span(); }
|
||||
u8* data() { return m_buffer.data(); }
|
||||
u8 const* data() const { return m_buffer.data(); }
|
||||
size_t size() const { return m_buffer.size(); }
|
||||
|
||||
void rewind()
|
||||
{
|
||||
m_buffer.resize_and_keep_capacity(m_last_instruction_start_offset);
|
||||
m_terminated = false;
|
||||
}
|
||||
|
||||
void grow(size_t additional_size);
|
||||
|
||||
void terminate(Badge<Generator>) { m_terminated = true; }
|
||||
bool is_terminated() const { return m_terminated; }
|
||||
|
||||
String const& name() const { return m_name; }
|
||||
|
||||
void set_handler(BasicBlock const& handler) { m_handler = &handler; }
|
||||
|
||||
BasicBlock const* handler() const { return m_handler; }
|
||||
|
||||
auto const& source_map() const { return m_source_map; }
|
||||
void add_source_map_entry(u32 bytecode_offset, Position source_start)
|
||||
{
|
||||
m_source_map.append({ bytecode_offset, source_start.line, source_start.column });
|
||||
}
|
||||
|
||||
[[nodiscard]] bool has_resolved_this() const { return m_has_resolved_this; }
|
||||
void set_has_resolved_this() { m_has_resolved_this = true; }
|
||||
|
||||
[[nodiscard]] size_t last_instruction_start_offset() const { return m_last_instruction_start_offset; }
|
||||
void set_last_instruction_start_offset(size_t offset) { m_last_instruction_start_offset = offset; }
|
||||
|
||||
private:
|
||||
explicit BasicBlock(u32 index, String name);
|
||||
|
||||
u32 m_index { 0 };
|
||||
Vector<u8> m_buffer;
|
||||
BasicBlock const* m_handler { nullptr };
|
||||
String m_name;
|
||||
bool m_terminated { false };
|
||||
bool m_has_resolved_this { false };
|
||||
|
||||
Vector<SourceMapEntry> m_source_map;
|
||||
|
||||
size_t m_last_instruction_start_offset { 0 };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
@ -11,7 +11,6 @@
|
|||
#include <AK/StdLibExtras.h>
|
||||
#include <LibGC/Heap.h>
|
||||
#include <LibGC/HeapBlock.h>
|
||||
#include <LibJS/Bytecode/BasicBlock.h>
|
||||
#include <LibJS/Bytecode/Executable.h>
|
||||
#include <LibJS/Bytecode/FormatOperand.h>
|
||||
#include <LibJS/Bytecode/Instruction.h>
|
||||
|
|
|
|||
|
|
@ -1,17 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Andreas Kling <andreas@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/Bytecode/BasicBlock.h>
|
||||
#include <LibJS/Bytecode/Label.h>
|
||||
|
||||
namespace JS::Bytecode {
|
||||
|
||||
Label::Label(Bytecode::BasicBlock const& basic_block)
|
||||
: m_address_or_basic_block_index(basic_block.index())
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -10,27 +10,19 @@
|
|||
|
||||
namespace JS::Bytecode {
|
||||
|
||||
class BasicBlock;
|
||||
|
||||
class Label {
|
||||
public:
|
||||
explicit Label(BasicBlock const&);
|
||||
|
||||
explicit Label(u32 basic_block_index)
|
||||
: m_address_or_basic_block_index(basic_block_index)
|
||||
explicit Label(u32 address)
|
||||
: m_address(address)
|
||||
{
|
||||
}
|
||||
|
||||
// Used while compiling.
|
||||
size_t basic_block_index() const { return m_address_or_basic_block_index; }
|
||||
size_t address() const { return m_address; }
|
||||
|
||||
// Used after compiling.
|
||||
size_t address() const { return m_address_or_basic_block_index; }
|
||||
|
||||
void set_address(size_t address) { m_address_or_basic_block_index = address; }
|
||||
void set_address(size_t address) { m_address = address; }
|
||||
|
||||
private:
|
||||
u32 m_address_or_basic_block_index { 0 };
|
||||
u32 m_address { 0 };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,12 +2,10 @@ include(libjs_generators)
|
|||
|
||||
set(SOURCES
|
||||
Bytecode/AsmInterpreter/AsmSlowPaths.cpp
|
||||
Bytecode/BasicBlock.cpp
|
||||
Bytecode/Executable.cpp
|
||||
Bytecode/IdentifierTable.cpp
|
||||
Bytecode/Instruction.cpp
|
||||
Bytecode/Interpreter.cpp
|
||||
Bytecode/Label.cpp
|
||||
Bytecode/PropertyNameIterator.cpp
|
||||
Bytecode/PropertyKeyTable.cpp
|
||||
Bytecode/RegexTable.cpp
|
||||
|
|
|
|||
|
|
@ -315,7 +315,6 @@ using NativeFunctionPointer = ThrowCompletionOr<Value> (*)(VM&);
|
|||
|
||||
namespace Bytecode {
|
||||
|
||||
class BasicBlock;
|
||||
enum class Builtin : u8;
|
||||
class Executable;
|
||||
class Generator;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@
|
|||
|
||||
#include <AK/Checked.h>
|
||||
#include <AK/Span.h>
|
||||
#include <LibJS/Bytecode/BasicBlock.h>
|
||||
#include <LibJS/Export.h>
|
||||
#include <LibJS/Forward.h>
|
||||
#include <LibJS/Module.h>
|
||||
|
|
|
|||
Loading…
Reference in a new issue