mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-05 07:39:16 +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
|
@ -397,9 +397,17 @@ JS::ThrowCompletionOr<NonnullOwnPtr<Wasm::ModuleInstance>> instantiate_module(JS
|
|||
return vm.throw_completion<LinkError>(MUST(builder.to_string()));
|
||||
}
|
||||
|
||||
// https://webassembly.github.io/spec/js-api/index.html#instantiate-the-core-of-a-webassembly-module
|
||||
auto instance_result = cache.abstract_machine().instantiate(module, link_result.release_value());
|
||||
if (instance_result.is_error()) {
|
||||
return vm.throw_completion<LinkError>(instance_result.error().error);
|
||||
auto instantiation_error = instance_result.release_error();
|
||||
switch (instantiation_error.source) {
|
||||
case Wasm::InstantiationErrorSource::Linking:
|
||||
return vm.throw_completion<LinkError>(instantiation_error.error);
|
||||
case Wasm::InstantiationErrorSource::StartFunction:
|
||||
return vm.throw_completion<RuntimeError>(instantiation_error.error);
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
return instance_result.release_value();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue