mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
LibJS: Stop worrying about Instruction destructors
By adding static_asserts to prove that all of our generated instruction classes are trivially destructible, we can confidently remove the destructor walk in BasicBlock and save ourselves some unnecessary work.
This commit is contained in:
parent
370b81f1b7
commit
f37063e2a1
Notes:
github-actions[bot]
2025-11-21 08:47:34 +00:00
Author: https://github.com/awesomekling
Commit: f37063e2a1
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6888
4 changed files with 2 additions and 27 deletions
|
|
@ -21,15 +21,7 @@ BasicBlock::BasicBlock(u32 index, String name)
|
|||
{
|
||||
}
|
||||
|
||||
BasicBlock::~BasicBlock()
|
||||
{
|
||||
Bytecode::InstructionStreamIterator it(instruction_stream());
|
||||
while (!it.at_end()) {
|
||||
auto& to_destroy = (*it);
|
||||
++it;
|
||||
Instruction::destroy(const_cast<Instruction&>(to_destroy));
|
||||
}
|
||||
}
|
||||
BasicBlock::~BasicBlock() = default;
|
||||
|
||||
void BasicBlock::grow(size_t additional_size)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,22 +10,6 @@
|
|||
|
||||
namespace JS::Bytecode {
|
||||
|
||||
void Instruction::destroy(Instruction& instruction)
|
||||
{
|
||||
#define __BYTECODE_OP(op) \
|
||||
case Type::op: \
|
||||
static_cast<Op::op&>(instruction).~op(); \
|
||||
return;
|
||||
|
||||
switch (instruction.type()) {
|
||||
ENUMERATE_BYTECODE_OPS(__BYTECODE_OP)
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
#undef __BYTECODE_OP
|
||||
}
|
||||
|
||||
void Instruction::visit_labels(Function<void(JS::Bytecode::Label&)> visitor)
|
||||
{
|
||||
#define __BYTECODE_OP(op) \
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
#include <AK/Forward.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/Span.h>
|
||||
#include <LibJS/Bytecode/Executable.h>
|
||||
#include <LibJS/Bytecode/OpCodes.h>
|
||||
#include <LibJS/Forward.h>
|
||||
|
|
@ -85,7 +84,6 @@ public:
|
|||
ByteString to_byte_string(Bytecode::Executable const&) const;
|
||||
void visit_labels(Function<void(Label&)> visitor);
|
||||
void visit_operands(Function<void(Operand&)> visitor);
|
||||
static void destroy(Instruction&);
|
||||
|
||||
Strict strict() const { return m_strict; }
|
||||
void set_strict(Strict strict) { m_strict = strict; }
|
||||
|
|
|
|||
|
|
@ -322,6 +322,7 @@ def generate_class(op: OpDef) -> str:
|
|||
lines.append(f" {f.type} {f.name};")
|
||||
|
||||
lines.append("};")
|
||||
lines.append(f"static_assert(IsTriviallyDestructible<{op.name}>);")
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue