1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-25 19:15:06 +00:00

LibJS+LibWeb: Make CyclicModule & GraphLoadingState GC-allocated

This allows them to participate in the ownership graph and fixes a
lifetime issue in module loading found by ASAN.

Co-Authored-By: networkException <networkexception@serenityos.org>
This commit is contained in:
Andreas Kling 2023-11-17 12:14:18 +01:00
parent aa7501a66a
commit 0817d8bda6
6 changed files with 60 additions and 24 deletions

View file

@ -54,8 +54,17 @@ struct ScriptFetchOptions {
// https://html.spec.whatwg.org/multipage/webappapis.html#default-classic-script-fetch-options
ScriptFetchOptions default_classic_script_fetch_options();
struct FetchContext : JS::GraphLoadingState::HostDefined {
FetchContext(JS::GCPtr<JS::Value> parse_error, Fetch::Infrastructure::Request::Destination destination, JS::GCPtr<JS::Promise> perform_fetch, EnvironmentSettingsObject& fetch_client)
class FetchContext : public JS::GraphLoadingState::HostDefined {
JS_CELL(FetchContext, JS::GraphLoadingState::HostDefined);
public:
JS::Value parse_error; // [[ParseError]]
Fetch::Infrastructure::Request::Destination destination; // [[Destination]]
JS::GCPtr<JS::Promise> perform_fetch; // [[PerformFetch]]
EnvironmentSettingsObject& fetch_client; // [[FetchClient]]
private:
FetchContext(JS::Value parse_error, Fetch::Infrastructure::Request::Destination destination, JS::GCPtr<JS::Promise> perform_fetch, EnvironmentSettingsObject& fetch_client)
: parse_error(parse_error)
, destination(destination)
, perform_fetch(perform_fetch)
@ -63,10 +72,13 @@ struct FetchContext : JS::GraphLoadingState::HostDefined {
{
}
JS::GCPtr<JS::Value> parse_error; // [[ParseError]]
Fetch::Infrastructure::Request::Destination destination; // [[Destination]]
JS::GCPtr<JS::Promise> perform_fetch; // [[PerformFetch]]
EnvironmentSettingsObject& fetch_client; // [[FetchClient]]
void visit_edges(Visitor& visitor) override
{
Base::visit_edges(visitor);
visitor.visit(parse_error);
visitor.visit(perform_fetch);
visitor.visit(fetch_client);
}
};
DeprecatedString module_type_from_module_request(JS::ModuleRequest const&);