LibWeb: Make EventLoop, TaskQueue, and Task GC-allocated

...and use HeapFunction instead of SafeFunction for task steps.

Since there is only one EventLoop per process, it lives as a global
handle in the VM custom data.

This makes it much easier to reason about lifetimes of tasks, task
steps, and random stuff captured by them.
This commit is contained in:
Andreas Kling 2024-04-04 12:06:50 +02:00
commit 2ef37c0b06
Notes: sideshowbarker 2024-07-17 02:14:39 +09:00
20 changed files with 167 additions and 124 deletions

View file

@ -42,6 +42,7 @@ void EnvironmentSettingsObject::initialize(JS::Realm& realm)
void EnvironmentSettingsObject::visit_edges(Cell::Visitor& visitor)
{
Base::visit_edges(visitor);
visitor.visit(m_responsible_event_loop);
visitor.visit(target_browsing_context);
visitor.visit(m_module_map);
visitor.ignore(m_outstanding_rejected_promises_weak_set);
@ -84,8 +85,8 @@ EventLoop& EnvironmentSettingsObject::responsible_event_loop()
auto& vm = global_object().vm();
auto& event_loop = verify_cast<Bindings::WebEngineCustomData>(vm.custom_data())->event_loop;
m_responsible_event_loop = &event_loop;
return event_loop;
m_responsible_event_loop = event_loop;
return *event_loop;
}
// https://html.spec.whatwg.org/multipage/webappapis.html#check-if-we-can-run-script