mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-23 00:19:18 +00:00
LibWeb+LibWasm: Reject module instantiation with correct error type
The spec tells us to reject the promise with a RuntimeError instead of a LinkError whenever the module's start function fails during module instantiation. Fixes 1 WPT subtest in `wasm/core`.
This commit is contained in:
parent
35ca7f82b0
commit
58c3a391a3
Notes:
github-actions[bot]
2025-07-25 13:14:45 +00:00
Author: https://github.com/gmta
Commit: 58c3a391a3
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5601
Reviewed-by: https://github.com/alimpfard ✅
6 changed files with 128 additions and 4 deletions
|
@ -387,12 +387,11 @@ InstantiationResult AbstractMachine::instantiate(Module const& module, Vector<Ex
|
|||
if (module.start_section().function().has_value()) {
|
||||
auto& functions = main_module_instance.functions();
|
||||
auto index = module.start_section().function()->index();
|
||||
if (functions.size() <= index.value()) {
|
||||
if (functions.size() <= index.value())
|
||||
return InstantiationError { ByteString::formatted("Start section function referenced invalid index {} of max {} entries", index.value(), functions.size()) };
|
||||
}
|
||||
auto result = invoke(functions[index.value()], {});
|
||||
if (result.is_trap())
|
||||
return InstantiationError { "Start function trapped", move(result.trap()) };
|
||||
return InstantiationError { "Start function trapped", move(result.trap()), InstantiationErrorSource::StartFunction };
|
||||
}
|
||||
|
||||
return InstantiationResult { move(main_module_instance_pointer) };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue