mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:27:35 +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
|
@ -456,7 +456,6 @@ Completion SuperCall::execute(Interpreter& interpreter, GlobalObject& global_obj
|
|||
|
||||
// 3. Let func be ! GetSuperConstructor().
|
||||
auto* func = get_super_constructor(interpreter.vm());
|
||||
VERIFY(!vm.exception());
|
||||
|
||||
// 4. Let argList be ? ArgumentListEvaluation of Arguments.
|
||||
MarkedValueList arg_list(vm.heap());
|
||||
|
@ -3686,7 +3685,6 @@ Completion TryStatement::execute(Interpreter& interpreter, GlobalObject& global_
|
|||
// TryStatement : try Block Catch
|
||||
// TryStatement : try Block Catch Finally
|
||||
if (m_handler) {
|
||||
vm.clear_exception();
|
||||
// 2. If B.[[Type]] is throw, let C be CatchClauseEvaluation of Catch with argument B.[[Value]].
|
||||
if (block_result.type() == Completion::Type::Throw)
|
||||
result = catch_clause_evaluation(*block_result.value());
|
||||
|
@ -3702,12 +3700,6 @@ Completion TryStatement::execute(Interpreter& interpreter, GlobalObject& global_
|
|||
// TryStatement : try Block Finally
|
||||
// TryStatement : try Block Catch Finally
|
||||
if (m_finalizer) {
|
||||
// NOTE: Temporary until VM::exception() is removed
|
||||
// Keep, if any, and then clear the current exception so we can
|
||||
// execute() the finalizer without an exception in our way.
|
||||
auto* previous_exception = vm.exception();
|
||||
vm.clear_exception();
|
||||
|
||||
// 4. Let F be the result of evaluating Finally.
|
||||
auto finalizer_result = m_finalizer->execute(interpreter, global_object);
|
||||
|
||||
|
@ -3715,12 +3707,6 @@ Completion TryStatement::execute(Interpreter& interpreter, GlobalObject& global_
|
|||
if (finalizer_result.type() == Completion::Type::Normal)
|
||||
finalizer_result = move(result);
|
||||
|
||||
// NOTE: Temporary until VM::exception() is removed
|
||||
// If we previously had an exception and we're carrying over
|
||||
// the catch block completion, restore it.
|
||||
if (finalizer_result.type() == Completion::Type::Normal && previous_exception)
|
||||
vm.set_exception(*previous_exception);
|
||||
|
||||
// 6. Return Completion(UpdateEmpty(F, undefined)).
|
||||
return finalizer_result.update_empty(js_undefined());
|
||||
}
|
||||
|
@ -3748,8 +3734,6 @@ Completion ThrowStatement::execute(Interpreter& interpreter, GlobalObject& globa
|
|||
auto value = TRY(m_argument->execute(interpreter, global_object)).release_value();
|
||||
|
||||
// 3. Return ThrowCompletion(exprValue).
|
||||
// TODO: Remove this once we get rid of VM::exception()
|
||||
interpreter.vm().throw_exception(global_object, value);
|
||||
return throw_completion(value);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue