LibJS + js: Rethrow exception on the vm after bytecode interpreter run
When the bytecode interpreter was converted to ThrowCompletionOr<Value> it then also cleared the vm.exception() making it seem like no exception was thrown. Also removed the TRY_OR_DISCARD as that would skip the error handling parts.
This commit is contained in:
parent
3666d2132b
commit
22e679d844
Notes:
sideshowbarker
2024-07-18 01:03:23 +09:00
Author: https://github.com/davidot Commit: https://github.com/SerenityOS/serenity/commit/22e679d8444 Pull-request: https://github.com/SerenityOS/serenity/pull/10945 Reviewed-by: https://github.com/linusg ✅
2 changed files with 9 additions and 2 deletions
|
@ -769,7 +769,11 @@ Completion ECMAScriptFunctionObject::ordinary_call_evaluate_body()
|
|||
return throw_completion(exception->value());
|
||||
|
||||
VERIFY(result_and_frame.frame != nullptr);
|
||||
auto result = TRY(result_and_frame.value);
|
||||
if (result_and_frame.value.is_error()) {
|
||||
vm.throw_exception(bytecode_interpreter->global_object(), result_and_frame.value.release_error().value());
|
||||
return throw_completion(vm.exception()->value());
|
||||
}
|
||||
auto result = result_and_frame.value.release_value();
|
||||
|
||||
// NOTE: Running the bytecode should eventually return a completion.
|
||||
// Until it does, we assume "return" and include the undefined fallback from the call site.
|
||||
|
|
|
@ -837,7 +837,10 @@ static bool parse_and_run(JS::Interpreter& interpreter, StringView source, Strin
|
|||
|
||||
if (s_run_bytecode) {
|
||||
JS::Bytecode::Interpreter bytecode_interpreter(interpreter.global_object(), interpreter.realm());
|
||||
TRY_OR_DISCARD(bytecode_interpreter.run(executable));
|
||||
auto result = bytecode_interpreter.run(executable);
|
||||
// Since all the error handling code uses vm.exception() we just rethrow any exception we got here.
|
||||
if (result.is_error())
|
||||
vm->throw_exception(interpreter.global_object(), result.throw_completion().value());
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue