mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 10:08:10 +00:00
LibJS: Remove FinishUnwind instruction
This is essentially a LeaveUnwind+Jump, so lets just do that, that will make it easier to optimize it, or see unwind state transitions
This commit is contained in:
parent
fc332be2e5
commit
133faa0acc
5 changed files with 2 additions and 46 deletions
|
@ -1987,7 +1987,8 @@ Bytecode::CodeGenerationErrorOr<void> TryStatement::generate_bytecode(Bytecode::
|
|||
generator.emit<Bytecode::Op::Jump>(finalizer_target);
|
||||
} else {
|
||||
auto& block = generator.make_block();
|
||||
generator.emit<Bytecode::Op::FinishUnwind>(Bytecode::Label { block });
|
||||
generator.emit<Bytecode::Op::LeaveUnwindContext>();
|
||||
generator.emit<Bytecode::Op::Jump>(Bytecode::Label { block });
|
||||
next_block = █
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
O(EnterUnwindContext) \
|
||||
O(EnterObjectEnvironment) \
|
||||
O(Exp) \
|
||||
O(FinishUnwind) \
|
||||
O(GetById) \
|
||||
O(GetByValue) \
|
||||
O(GetIterator) \
|
||||
|
|
|
@ -744,19 +744,6 @@ void EnterUnwindContext::replace_references_impl(BasicBlock const& from, BasicBl
|
|||
m_finalizer_target = Label { to };
|
||||
}
|
||||
|
||||
ThrowCompletionOr<void> FinishUnwind::execute_impl(Bytecode::Interpreter& interpreter) const
|
||||
{
|
||||
interpreter.leave_unwind_context();
|
||||
interpreter.jump(m_next_target);
|
||||
return {};
|
||||
}
|
||||
|
||||
void FinishUnwind::replace_references_impl(BasicBlock const& from, BasicBlock const& to)
|
||||
{
|
||||
if (&m_next_target.block() == &from)
|
||||
m_next_target = Label { to };
|
||||
}
|
||||
|
||||
void CopyObjectExcludingProperties::replace_references_impl(Register from, Register to)
|
||||
{
|
||||
if (m_from_object == from)
|
||||
|
@ -1229,11 +1216,6 @@ DeprecatedString EnterUnwindContext::to_deprecated_string_impl(Bytecode::Executa
|
|||
return DeprecatedString::formatted("EnterUnwindContext handler:{} finalizer:{} entry:{}", handler_string, finalizer_string, m_entry_point);
|
||||
}
|
||||
|
||||
DeprecatedString FinishUnwind::to_deprecated_string_impl(Bytecode::Executable const&) const
|
||||
{
|
||||
return DeprecatedString::formatted("FinishUnwind next:{}", m_next_target);
|
||||
}
|
||||
|
||||
DeprecatedString LeaveEnvironment::to_deprecated_string_impl(Bytecode::Executable const&) const
|
||||
{
|
||||
auto mode_string = m_mode == EnvironmentMode::Lexical
|
||||
|
|
|
@ -876,27 +876,6 @@ public:
|
|||
void replace_references_impl(Register, Register) { }
|
||||
};
|
||||
|
||||
class FinishUnwind final : public Instruction {
|
||||
public:
|
||||
constexpr static bool IsTerminator = true;
|
||||
|
||||
FinishUnwind(Label next)
|
||||
: Instruction(Type::FinishUnwind)
|
||||
, m_next_target(move(next))
|
||||
{
|
||||
}
|
||||
|
||||
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
||||
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
|
||||
void replace_references_impl(BasicBlock const&, BasicBlock const&);
|
||||
void replace_references_impl(Register, Register) { }
|
||||
|
||||
Label next_target() const { return m_next_target; }
|
||||
|
||||
private:
|
||||
Label m_next_target;
|
||||
};
|
||||
|
||||
class ContinuePendingUnwind final : public Instruction {
|
||||
public:
|
||||
constexpr static bool IsTerminator = true;
|
||||
|
|
|
@ -90,11 +90,6 @@ void GenerateCFG::perform(PassPipelineExecutable& executable)
|
|||
enter_label(&resume_target, current_block);
|
||||
continue;
|
||||
}
|
||||
case FinishUnwind: {
|
||||
auto const& next_target = static_cast<Op::FinishUnwind const&>(instruction).next_target();
|
||||
enter_label(&next_target, current_block);
|
||||
continue;
|
||||
}
|
||||
default:
|
||||
// Otherwise, pop the current block off, it doesn't jump anywhere.
|
||||
iterators.take_last();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue