LibJS: Make run_executable() return simple ThrowCompletionOr<Value>

We don't need to return two values; running an executable only ever
produces a throw completion, or a normal completion, i.e a Value.

This necessitated a few minor changes, such as adding a way to check
if a JS::Cell is a GeneratorResult.
This commit is contained in:
Andreas Kling 2025-10-30 10:27:47 +01:00 committed by Andreas Kling
parent 2f7797f854
commit 5706831328
Notes: github-actions[bot] 2025-10-31 07:57:15 +00:00
10 changed files with 37 additions and 51 deletions

View file

@ -823,7 +823,7 @@ void async_block_start(VM& vm, T const& async_body, PromiseCapability const& pro
if (maybe_executable.is_error())
result = maybe_executable.release_error();
else
result = vm.bytecode_interpreter().run_executable(vm.running_execution_context(), *maybe_executable.value(), {}).value;
result = vm.bytecode_interpreter().run_executable(vm.running_execution_context(), *maybe_executable.value(), {});
}
// c. Else,
else {
@ -886,13 +886,7 @@ template void async_function_start(VM&, PromiseCapability const&, GC::Function<C
// 15.8.4 Runtime Semantics: EvaluateAsyncFunctionBody, https://tc39.es/ecma262/#sec-runtime-semantics-evaluatefunctionbody
ThrowCompletionOr<Value> ECMAScriptFunctionObject::ordinary_call_evaluate_body(VM& vm, ExecutionContext& context)
{
auto result_and_frame = vm.bytecode_interpreter().run_executable(context, *bytecode_executable(), {});
if (result_and_frame.value.is_error()) [[unlikely]] {
return result_and_frame.value.release_error();
}
auto result = result_and_frame.value.release_value();
auto result = TRY(vm.bytecode_interpreter().run_executable(context, *bytecode_executable(), {}));
// NOTE: Running the bytecode should eventually return a completion.
// Until it does, we assume "return" and include the undefined fallback from the call site.