LibJS: Merge CallFrame into ExecutionContext

Before this change both ExecutionContext and CallFrame were created
before executing function/module/script with a couple exceptions:
- executable created for default function argument evaluation has to
  run in function's execution context.
- `execute_ast_node()` where executable compiled for ASTNode has to be
  executed in running execution context.

This change moves all members previously owned by CallFrame into
ExecutionContext, and makes two exceptions where an executable that does
not have a corresponding execution context saves and restores registers
before running.

Now, all execution state lives in a single entity, which makes it a bit
easier to reason about and opens opportunities for optimizations, such
as moving registers and local variables into a single array.
This commit is contained in:
Aliaksandr Kalenik
2024-05-01 19:33:49 +02:00
committed by Andreas Kling
parent 46b8a3afb7
commit 865e651a7d
15 changed files with 121 additions and 187 deletions

View File

@@ -717,12 +717,12 @@ ThrowCompletionOr<void> SourceTextModule::execute_module(VM& vm, GCPtr<PromiseCa
else {
auto executable = maybe_executable.release_value();
auto value_and_frame = vm.bytecode_interpreter().run_and_return_frame(*executable, nullptr);
if (value_and_frame.value.is_error()) {
result = value_and_frame.value.release_error();
auto result_and_return_register = vm.bytecode_interpreter().run_executable(*executable, nullptr);
if (result_and_return_register.value.is_error()) {
result = result_and_return_register.value.release_error();
} else {
// Resulting value is in the accumulator.
result = value_and_frame.frame->registers()[0].value_or(js_undefined());
result = result_and_return_register.return_register_value.value_or(js_undefined());
}
}