mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:27:45 +00:00
LibJS: Use LoadRequestedModules in the ad-hoc module loading path
This ensures that modules go through the expected state transitions, fixing hundreds of test262 tests.
This commit is contained in:
parent
d7005be768
commit
26c21fba8e
2 changed files with 3 additions and 29 deletions
|
@ -746,36 +746,10 @@ ThrowCompletionOr<void> VM::link_and_eval_module(Badge<Bytecode::Interpreter>, S
|
||||||
return link_and_eval_module(module);
|
return link_and_eval_module(module);
|
||||||
}
|
}
|
||||||
|
|
||||||
ThrowCompletionOr<void> VM::link_and_eval_module(Module& module)
|
ThrowCompletionOr<void> VM::link_and_eval_module(CyclicModule& module)
|
||||||
{
|
{
|
||||||
auto filename = module.filename();
|
auto filename = module.filename();
|
||||||
|
module.load_requested_modules(nullptr);
|
||||||
auto module_or_end = m_loaded_modules.find_if([&](StoredModule const& stored_module) {
|
|
||||||
return stored_module.module.ptr() == &module;
|
|
||||||
});
|
|
||||||
|
|
||||||
StoredModule* stored_module;
|
|
||||||
|
|
||||||
if (module_or_end.is_end()) {
|
|
||||||
dbgln_if(JS_MODULE_DEBUG, "[JS MODULE] Warning introducing module via link_and_eval_module {}", module.filename());
|
|
||||||
if (m_loaded_modules.size() > 0)
|
|
||||||
dbgln("Warning: Using multiple modules as entry point can lead to unexpected results");
|
|
||||||
|
|
||||||
m_loaded_modules.empend(
|
|
||||||
ImportedModuleReferrer { NonnullGCPtr { verify_cast<CyclicModule>(module) } },
|
|
||||||
module.filename(),
|
|
||||||
DeprecatedString {}, // Null type
|
|
||||||
module,
|
|
||||||
true);
|
|
||||||
stored_module = &m_loaded_modules.last();
|
|
||||||
} else {
|
|
||||||
stored_module = module_or_end.operator->();
|
|
||||||
if (stored_module->has_once_started_linking) {
|
|
||||||
dbgln_if(JS_MODULE_DEBUG, "[JS MODULE] Module already has started linking once {}", module.filename());
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
stored_module->has_once_started_linking = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
dbgln_if(JS_MODULE_DEBUG, "[JS MODULE] Linking module {}", filename);
|
dbgln_if(JS_MODULE_DEBUG, "[JS MODULE] Linking module {}", filename);
|
||||||
auto linked_or_error = module.link(*this);
|
auto linked_or_error = module.link(*this);
|
||||||
|
|
|
@ -268,7 +268,7 @@ private:
|
||||||
ThrowCompletionOr<void> iterator_binding_initialization(BindingPattern const& binding, IteratorRecord& iterator_record, Environment* environment);
|
ThrowCompletionOr<void> iterator_binding_initialization(BindingPattern const& binding, IteratorRecord& iterator_record, Environment* environment);
|
||||||
|
|
||||||
void load_imported_module(ImportedModuleReferrer, ModuleRequest const&, GCPtr<GraphLoadingState::HostDefined>, ImportedModulePayload);
|
void load_imported_module(ImportedModuleReferrer, ModuleRequest const&, GCPtr<GraphLoadingState::HostDefined>, ImportedModulePayload);
|
||||||
ThrowCompletionOr<void> link_and_eval_module(Module& module);
|
ThrowCompletionOr<void> link_and_eval_module(CyclicModule&);
|
||||||
|
|
||||||
void set_well_known_symbols(WellKnownSymbols well_known_symbols) { m_well_known_symbols = move(well_known_symbols); }
|
void set_well_known_symbols(WellKnownSymbols well_known_symbols) { m_well_known_symbols = move(well_known_symbols); }
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue