mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 04:48:14 +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
|
@ -17,6 +17,14 @@ CyclicModule::CyclicModule(Realm& realm, StringView filename, bool has_top_level
|
|||
{
|
||||
}
|
||||
|
||||
void CyclicModule::visit_edges(Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_cycle_root);
|
||||
for (auto* module : m_async_parent_modules)
|
||||
visitor.visit(module);
|
||||
}
|
||||
|
||||
// 16.2.1.5.1 Link ( ), https://tc39.es/ecma262/#sec-moduledeclarationlinking
|
||||
ThrowCompletionOr<void> CyclicModule::link(VM& vm)
|
||||
{
|
||||
|
@ -106,7 +114,7 @@ ThrowCompletionOr<u32> CyclicModule::inner_module_linking(VM& vm, Vector<Module*
|
|||
ModuleRequest required { required_string };
|
||||
|
||||
// a. Let requiredModule be ? HostResolveImportedModule(module, required).
|
||||
auto required_module = TRY(vm.host_resolve_imported_module(this->make_weak_ptr(), required));
|
||||
auto required_module = TRY(vm.host_resolve_imported_module(NonnullGCPtr<Module>(*this), required));
|
||||
|
||||
// b. Set index to ? InnerModuleLinking(requiredModule, stack, index).
|
||||
index = TRY(required_module->inner_module_linking(vm, stack, index));
|
||||
|
@ -305,7 +313,7 @@ ThrowCompletionOr<u32> CyclicModule::inner_module_evaluation(VM& vm, Vector<Modu
|
|||
for (auto& required : m_requested_modules) {
|
||||
|
||||
// a. Let requiredModule be ! HostResolveImportedModule(module, required).
|
||||
auto* required_module = MUST(vm.host_resolve_imported_module(this->make_weak_ptr(), required)).ptr();
|
||||
auto* required_module = MUST(vm.host_resolve_imported_module(NonnullGCPtr<Module>(*this), required)).ptr();
|
||||
// b. NOTE: Link must be completed successfully prior to invoking this method, so every requested module is guaranteed to resolve successfully.
|
||||
|
||||
// c. Set index to ? InnerModuleEvaluation(requiredModule, stack, index).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue