mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 13:49:16 +00:00
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:
parent
8263a9863f
commit
7dd7e5b438
Notes:
github-actions[bot]
2025-04-25 14:45:40 +00:00
Author: https://github.com/shannonbooth
Commit: 7dd7e5b438
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4453
3 changed files with 8 additions and 7 deletions
|
@ -37,12 +37,12 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
NonnullRefPtr<VM> VM::create(OwnPtr<Agent> agent)
|
||||
NonnullRefPtr<VM> VM::create()
|
||||
{
|
||||
ErrorMessages error_messages {};
|
||||
error_messages[to_underlying(ErrorMessage::OutOfMemory)] = ErrorType::OutOfMemory.message();
|
||||
|
||||
auto vm = adopt_ref(*new VM(move(agent), move(error_messages)));
|
||||
auto vm = adopt_ref(*new VM(move(error_messages)));
|
||||
|
||||
WellKnownSymbols well_known_symbols {
|
||||
#define __JS_ENUMERATE(SymbolName, snake_name) \
|
||||
|
@ -63,12 +63,11 @@ static constexpr auto make_single_ascii_character_strings(IndexSequence<code_poi
|
|||
|
||||
static constexpr auto single_ascii_character_strings = make_single_ascii_character_strings(MakeIndexSequence<128>());
|
||||
|
||||
VM::VM(OwnPtr<Agent> agent, ErrorMessages error_messages)
|
||||
VM::VM(ErrorMessages error_messages)
|
||||
: m_heap(this, [this](HashMap<GC::Cell*, GC::HeapRoot>& roots) {
|
||||
gather_roots(roots);
|
||||
})
|
||||
, m_error_messages(move(error_messages))
|
||||
, m_agent(move(agent))
|
||||
{
|
||||
m_bytecode_interpreter = make<Bytecode::Interpreter>(*this);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue