1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 12:28:12 +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:
Linus Groh 2022-10-02 12:11:30 +01:00
parent 0585029c30
commit fc9d587e39
29 changed files with 243 additions and 217 deletions

View file

@ -3361,10 +3361,10 @@ Completion ImportCall::execute(Interpreter& interpreter) const
if (!options_value.is_object()) {
auto* error = TypeError::create(realm, String::formatted(ErrorType::NotAnObject.message(), "ImportOptions"));
// i. Perform ! Call(promiseCapability.[[Reject]], undefined, « a newly created TypeError object »).
MUST(call(vm, *promise_capability.reject, js_undefined(), error));
MUST(call(vm, *promise_capability->reject(), js_undefined(), error));
// ii. Return promiseCapability.[[Promise]].
return Value { promise_capability.promise };
return Value { promise_capability->promise() };
}
// b. Let assertionsObj be Get(options, "assert").
@ -3377,10 +3377,10 @@ Completion ImportCall::execute(Interpreter& interpreter) const
if (!assertion_object.is_object()) {
auto* error = TypeError::create(realm, String::formatted(ErrorType::NotAnObject.message(), "ImportOptionsAssertions"));
// 1. Perform ! Call(promiseCapability.[[Reject]], undefined, « a newly created TypeError object »).
MUST(call(vm, *promise_capability.reject, js_undefined(), error));
MUST(call(vm, *promise_capability->reject(), js_undefined(), error));
// 2. Return promiseCapability.[[Promise]].
return Value { promise_capability.promise };
return Value { promise_capability->promise() };
}
// ii. Let keys be EnumerableOwnPropertyNames(assertionsObj, key).
@ -3402,10 +3402,10 @@ Completion ImportCall::execute(Interpreter& interpreter) const
if (!value.is_string()) {
auto* error = TypeError::create(realm, String::formatted(ErrorType::NotAString.message(), "Import Assertion option value"));
// a. Perform ! Call(promiseCapability.[[Reject]], undefined, « a newly created TypeError object »).
MUST(call(vm, *promise_capability.reject, js_undefined(), error));
MUST(call(vm, *promise_capability->reject(), js_undefined(), error));
// b. Return promiseCapability.[[Promise]].
return Value { promise_capability.promise };
return Value { promise_capability->promise() };
}
// 4. If supportedAssertions contains key, then
@ -3426,7 +3426,7 @@ Completion ImportCall::execute(Interpreter& interpreter) const
interpreter.vm().host_import_module_dynamically(referencing_script_or_module, move(request), promise_capability);
// 13. Return promiseCapability.[[Promise]].
return Value { promise_capability.promise };
return Value { promise_capability->promise() };
}
// 13.2.3.1 Runtime Semantics: Evaluation, https://tc39.es/ecma262/#sec-literals-runtime-semantics-evaluation