mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 14:58:46 +00:00
LibJS: Make PromiseCapability GC-allocated
A struct with three raw pointers to other GC'd types is a pretty big liability, let's just turn this into a Cell itself. This comes with the additional benefit of being able to capture it in a lambda effortlessly, without having to create handles for individual members.
This commit is contained in:
parent
0585029c30
commit
fc9d587e39
Notes:
sideshowbarker
2024-07-17 20:22:04 +09:00
Author: https://github.com/linusg
Commit: fc9d587e39
Pull-request: https://github.com/SerenityOS/serenity/pull/15438
Reviewed-by: https://github.com/davidot ✅
29 changed files with 243 additions and 217 deletions
|
@ -646,9 +646,9 @@ ThrowCompletionOr<ResolvedBinding> SourceTextModule::resolve_export(VM& vm, FlyS
|
|||
}
|
||||
|
||||
// 16.2.1.6.5 ExecuteModule ( [ capability ] ), https://tc39.es/ecma262/#sec-source-text-module-record-execute-module
|
||||
ThrowCompletionOr<void> SourceTextModule::execute_module(VM& vm, Optional<PromiseCapability> capability)
|
||||
ThrowCompletionOr<void> SourceTextModule::execute_module(VM& vm, GCPtr<PromiseCapability> capability)
|
||||
{
|
||||
dbgln_if(JS_MODULE_DEBUG, "[JS MODULE] SourceTextModule::execute_module({}, capability has value: {})", filename(), capability.has_value());
|
||||
dbgln_if(JS_MODULE_DEBUG, "[JS MODULE] SourceTextModule::execute_module({}, PromiseCapability @ {})", filename(), capability.ptr());
|
||||
|
||||
// 1. Let moduleContext be a new ECMAScript code execution context.
|
||||
ExecutionContext module_context { vm.heap() };
|
||||
|
@ -679,7 +679,7 @@ ThrowCompletionOr<void> SourceTextModule::execute_module(VM& vm, Optional<Promis
|
|||
// 9. If module.[[HasTLA]] is false, then
|
||||
if (!m_has_top_level_await) {
|
||||
// a. Assert: capability is not present.
|
||||
VERIFY(!capability.has_value());
|
||||
VERIFY(capability == nullptr);
|
||||
// b. Push moduleContext onto the execution context stack; moduleContext is now the running execution context.
|
||||
TRY(vm.push_execution_context(module_context, {}));
|
||||
|
||||
|
@ -701,10 +701,10 @@ ThrowCompletionOr<void> SourceTextModule::execute_module(VM& vm, Optional<Promis
|
|||
// 10. Else,
|
||||
else {
|
||||
// a. Assert: capability is a PromiseCapability Record.
|
||||
VERIFY(capability.has_value());
|
||||
VERIFY(capability != nullptr);
|
||||
|
||||
// b. Perform AsyncBlockStart(capability, module.[[ECMAScriptCode]], moduleContext).
|
||||
async_block_start(vm, m_ecmascript_code, capability.value(), module_context);
|
||||
async_block_start(vm, m_ecmascript_code, *capability, module_context);
|
||||
}
|
||||
|
||||
// 11. Return unused.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue