LibJS: Eliminate GeneratorResult GC cell allocation on yield/await

Store yield_continuation and yield_is_await directly in
ExecutionContext instead of allocating a GeneratorResult GC cell.
This removes a heap allocation per yield/await and fixes a latent
bug where continuation addresses stored as doubles could lose
precision.
This commit is contained in:
Johan Dahlin 2026-03-16 00:02:11 +01:00 committed by Andreas Kling
parent 9a34fb59aa
commit 1179e40d3f
Notes: github-actions[bot] 2026-03-20 20:58:50 +00:00
14 changed files with 90 additions and 176 deletions

View file

@ -80,9 +80,9 @@ ThrowCompletionOr<Value> NativeJavaScriptBackedFunction::call()
auto& realm = *vm.current_realm();
if (kind == FunctionKind::AsyncGenerator)
return AsyncGenerator::create(realm, result, GC::Ref { *this }, vm.running_execution_context().copy());
return AsyncGenerator::create(realm, GC::Ref { *this }, vm.running_execution_context().copy());
auto generator_object = GeneratorObject::create(realm, result, GC::Ref { *this }, vm.running_execution_context().copy());
auto generator_object = GeneratorObject::create(realm, GC::Ref { *this }, vm.running_execution_context().copy());
// NOTE: Async functions are entirely transformed to generator functions, and wrapped in a custom driver that returns a promise.
if (kind == FunctionKind::Async)