LibJS+LibWeb: Defer initialization of the Agent after VM constructor

This helps unwind a niggly depedency where the VM owns and constructs
the Heap and the Agent. But the agent wants to have customized
construction that depends on the heap. Solve this by defering
the initialization of the Agent to after we have constructed the
VM and the heap.
This commit is contained in:
Shannon Booth 2025-04-24 15:58:00 +12:00 committed by Andreas Kling
commit 7dd7e5b438
Notes: github-actions[bot] 2025-04-25 14:45:40 +00:00
3 changed files with 8 additions and 7 deletions

View file

@ -76,7 +76,8 @@ void initialize_main_thread_vm(HTML::EventLoop::Type type)
{
VERIFY(!s_main_thread_vm);
s_main_thread_vm = JS::VM::create(make<HTML::SimilarOriginWindowAgent>());
s_main_thread_vm = JS::VM::create();
s_main_thread_vm->set_agent(make<HTML::SimilarOriginWindowAgent>());
auto& agent = as<HTML::Agent>(*s_main_thread_vm->agent());
agent.event_loop = s_main_thread_vm->heap().allocate<HTML::EventLoop>(type);