mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:08:11 +00:00
LibJS+Everywhere: Remove VM::exception() and most related functions
This commit removes all exception related code: Remove VM::exception(), VM::throw_exception() etc. Any leftover throw_exception calls are moved to throw_completion. The one method left is clear_exception() which is now a no-op. Most of these calls are just to clear whatever exception might have been thrown when handling a Completion. So to have a cleaner commit this will be removed in a next commit. It also removes the actual Exception and TemporaryClearException classes since these are no longer used. In any spot where the exception was actually used an attempt was made to preserve that behavior. However since it is no longer tracked by the VM we cannot access exceptions which were thrown in previous calls. There are two such cases which might have different behavior: - In Web::DOM::Document::interpreter() the on_call_stack_emptied hook used to print any uncaught exception but this is now no longer possible as the VM does not store uncaught exceptions. - In js the code used to be interruptable by throwing an exception on the VM. This is no longer possible but was already somewhat fragile before as you could happen to throw an exception just before a VERIFY.
This commit is contained in:
parent
4ef1e8f226
commit
9264f9d24e
35 changed files with 145 additions and 349 deletions
|
@ -44,7 +44,6 @@ Interpreter::~Interpreter()
|
|||
ThrowCompletionOr<Value> Interpreter::run(Script& script_record)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
VERIFY(!vm.exception());
|
||||
|
||||
VM::InterpreterExecutionScope scope(*this);
|
||||
|
||||
|
@ -136,24 +135,15 @@ ThrowCompletionOr<Value> Interpreter::run(SourceTextModule& module)
|
|||
// To avoid work we use link_and_eval_module however that can already be
|
||||
// dangerous if the vm loaded other modules.
|
||||
auto& vm = this->vm();
|
||||
VERIFY(!vm.exception());
|
||||
|
||||
VM::InterpreterExecutionScope scope(*this);
|
||||
|
||||
auto evaluated_or_error = vm.link_and_eval_module({}, module);
|
||||
// This error does not set vm.exception so we set that here for the stuff that needs it
|
||||
if (evaluated_or_error.is_throw_completion()) {
|
||||
auto* error = vm.heap().allocate<Exception>(global_object(), *(evaluated_or_error.throw_completion().value()));
|
||||
vm.set_exception(*error);
|
||||
return evaluated_or_error.throw_completion();
|
||||
}
|
||||
VERIFY(!vm.exception());
|
||||
TRY(vm.link_and_eval_module({}, module));
|
||||
|
||||
vm.run_queued_promise_jobs();
|
||||
|
||||
vm.run_queued_finalization_registry_cleanup_jobs();
|
||||
|
||||
VERIFY(!vm.exception());
|
||||
return js_undefined();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue