1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:58:12 +00:00

LibJS: Generate unwind chains for break in Bytecode

This uses a newly added instruction `ScheduleJump`
This instruction tells the finally proceeding it, that instead of
jumping to it's next block it should jump to the designated block.
This commit is contained in:
Hendiadyoin1 2022-11-25 16:15:34 +01:00 committed by Linus Groh
parent 495ba53e46
commit f5376cb282
9 changed files with 123 additions and 19 deletions

View file

@ -790,6 +790,12 @@ void Call::replace_references_impl(Register from, Register to)
m_this_value = to;
}
ThrowCompletionOr<void> ScheduleJump::execute_impl(Bytecode::Interpreter& interpreter) const
{
interpreter.schedule_jump(m_target);
return {};
}
ThrowCompletionOr<void> LeaveEnvironment::execute_impl(Bytecode::Interpreter& interpreter) const
{
if (m_mode == EnvironmentMode::Lexical)
@ -1265,6 +1271,11 @@ DeprecatedString EnterUnwindContext::to_deprecated_string_impl(Bytecode::Executa
return DeprecatedString::formatted("EnterUnwindContext handler:{} finalizer:{} entry:{}", handler_string, finalizer_string, m_entry_point);
}
DeprecatedString ScheduleJump::to_deprecated_string_impl(Bytecode::Executable const&) const
{
return DeprecatedString::formatted("ScheduleJump {}", m_target);
}
DeprecatedString LeaveEnvironment::to_deprecated_string_impl(Bytecode::Executable const&) const
{
auto mode_string = m_mode == EnvironmentMode::Lexical