1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-11 18:20:43 +09:00

LibJS: Make JS::Script keep the VM alive

Script has a Handle member (m_realm), and for handles to remain valid,
the VM must stay alive.
This commit is contained in:
Andreas Kling 2021-09-14 20:30:04 +02:00
parent d553fd7f4f
commit f08a46bd9e
Notes: sideshowbarker 2024-07-18 03:58:08 +09:00
2 changed files with 5 additions and 1 deletions

View file

@ -30,7 +30,8 @@ NonnullRefPtr<Script> Script::parse(StringView source_text, Realm& realm, String
}
Script::Script(Realm& realm, NonnullRefPtr<Program> parse_node)
: m_realm(make_handle(&realm))
: m_vm(realm.vm())
, m_realm(make_handle(&realm))
, m_parse_node(move(parse_node))
{
}

View file

@ -26,6 +26,9 @@ public:
private:
Script(Realm&, NonnullRefPtr<Program>);
// Handles are not safe unless we keep the VM alive.
NonnullRefPtr<VM> m_vm;
Handle<Realm> m_realm; // [[Realm]]
NonnullRefPtr<Program> m_parse_node; // [[ECMAScriptCode]]
};