mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 21:17:42 +00:00
LibJS: Return early from Interpreter on unhandled exception
If we don't have a local unwind context to handle the exception, we can just return right away. This allows us to remove one check from the inner loop.
This commit is contained in:
parent
c9eff35b96
commit
39cfb64269
1 changed files with 3 additions and 5 deletions
|
@ -173,14 +173,15 @@ void Interpreter::run_bytecode()
|
||||||
|
|
||||||
while (!pc.at_end()) {
|
while (!pc.at_end()) {
|
||||||
auto& instruction = *pc;
|
auto& instruction = *pc;
|
||||||
|
|
||||||
auto ran_or_error = instruction.execute(*this);
|
auto ran_or_error = instruction.execute(*this);
|
||||||
if (ran_or_error.is_error()) [[unlikely]] {
|
if (ran_or_error.is_error()) [[unlikely]] {
|
||||||
reg(Register::exception()) = *ran_or_error.throw_completion().value();
|
reg(Register::exception()) = *ran_or_error.throw_completion().value();
|
||||||
if (unwind_contexts().is_empty())
|
if (unwind_contexts().is_empty())
|
||||||
break;
|
return;
|
||||||
auto& unwind_context = unwind_contexts().last();
|
auto& unwind_context = unwind_contexts().last();
|
||||||
if (unwind_context.executable != m_current_executable)
|
if (unwind_context.executable != m_current_executable)
|
||||||
break;
|
return;
|
||||||
if (unwind_context.handler && !unwind_context.handler_called) {
|
if (unwind_context.handler && !unwind_context.handler_called) {
|
||||||
vm().running_execution_context().lexical_environment = unwind_context.lexical_environment;
|
vm().running_execution_context().lexical_environment = unwind_context.lexical_environment;
|
||||||
m_current_block = unwind_context.handler;
|
m_current_block = unwind_context.handler;
|
||||||
|
@ -234,9 +235,6 @@ void Interpreter::run_bytecode()
|
||||||
if (pc.at_end())
|
if (pc.at_end())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (!reg(Register::exception()).is_empty())
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (will_return)
|
if (will_return)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue