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

LibJS: Replace the custom unwind mechanism with completions :^)

This includes:

- Parsing proper LabelledStatements with try_parse_labelled_statement()
- Removing LabelableStatement
- Implementing the LoopEvaluation semantics via loop_evaluation() in
  each IterationStatement subclass; and IterationStatement evaluation
  via {For,ForIn,ForOf,ForAwaitOf,While,DoWhile}Statement::execute()
- Updating ReturnStatement, BreakStatement and ContinueStatement to
  return the appropriate completion types
- Basically reimplementing TryStatement and SwitchStatement according to
  the spec, using completions
- Honoring result completion types in AsyncBlockStart and
  OrdinaryCallEvaluateBody
- Removing any uses of the VM unwind mechanism - most importantly,
  VM::throw_exception() now exclusively sets an exception and no longer
  triggers any unwinding mechanism.
  However, we already did a good job updating all of LibWeb and userland
  applications to not use it, and the few remaining uses elsewhere don't
  rely on unwinding AFAICT.
This commit is contained in:
Linus Groh 2022-01-05 19:11:16 +01:00
parent eed764e1dd
commit 9d0d3affd4
16 changed files with 512 additions and 279 deletions

View file

@ -468,7 +468,6 @@ ThrowCompletionOr<void> VM::initialize_instance_elements(Object& object, ECMAScr
void VM::throw_exception(Exception& exception)
{
set_exception(exception);
unwind(ScopeType::Try);
}
// 9.4.4 ResolveThisBinding ( ), https://tc39.es/ecma262/#sec-resolvethisbinding
@ -547,7 +546,6 @@ void VM::run_queued_promise_jobs()
// exceptions when running Promise jobs. See the commit where these two lines were initially
// added for a much more detailed explanation.
clear_exception();
stop_unwind();
if (pushed_execution_context)
pop_execution_context();