mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 13:45:06 +00:00
LibJS: Make Script and Module GC-allocated
This ensures that code currently in any active or saved execution stack always stays alive.
This commit is contained in:
parent
cb15132146
commit
00c8f07192
18 changed files with 145 additions and 89 deletions
|
@ -12,11 +12,21 @@
|
|||
namespace JS {
|
||||
|
||||
Module::Module(Realm& realm, String filename)
|
||||
: m_realm(make_handle(&realm))
|
||||
: m_realm(realm)
|
||||
, m_filename(move(filename))
|
||||
{
|
||||
}
|
||||
|
||||
Module::~Module() = default;
|
||||
|
||||
void Module::visit_edges(Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_realm);
|
||||
visitor.visit(m_environment);
|
||||
visitor.visit(m_namespace);
|
||||
}
|
||||
|
||||
// 16.2.1.5.1.1 InnerModuleLinking ( module, stack, index ), https://tc39.es/ecma262/#sec-InnerModuleLinking
|
||||
ThrowCompletionOr<u32> Module::inner_module_linking(VM& vm, Vector<Module*>&, u32 index)
|
||||
{
|
||||
|
@ -54,7 +64,7 @@ ThrowCompletionOr<Object*> Module::get_module_namespace(VM& vm)
|
|||
// FIXME: How do we check this without breaking encapsulation?
|
||||
|
||||
// 2. Let namespace be module.[[Namespace]].
|
||||
auto* namespace_ = m_namespace.is_null() ? nullptr : m_namespace.cell();
|
||||
auto* namespace_ = m_namespace.ptr();
|
||||
|
||||
// 3. If namespace is empty, then
|
||||
if (!namespace_) {
|
||||
|
@ -76,7 +86,7 @@ ThrowCompletionOr<Object*> Module::get_module_namespace(VM& vm)
|
|||
|
||||
// d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames).
|
||||
namespace_ = module_namespace_create(vm, unambiguous_names);
|
||||
VERIFY(!m_namespace.is_null());
|
||||
VERIFY(m_namespace);
|
||||
// Note: This set the local variable 'namespace' and not the member variable which is done by ModuleNamespaceCreate
|
||||
}
|
||||
|
||||
|
@ -90,7 +100,7 @@ Object* Module::module_namespace_create(VM& vm, Vector<FlyString> unambiguous_na
|
|||
auto& realm = this->realm();
|
||||
|
||||
// 1. Assert: module.[[Namespace]] is empty.
|
||||
VERIFY(m_namespace.is_null());
|
||||
VERIFY(!m_namespace);
|
||||
|
||||
// 2. Let internalSlotsList be the internal slots listed in Table 34.
|
||||
// 3. Let M be MakeBasicObject(internalSlotsList).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue