LibWeb: Support wasm module instantiation using a global address

Fixes 1 WPT subtest in `wasm/core/simd`.
This commit is contained in:
Jelle Raaijmakers 2025-07-25 15:08:31 +02:00 committed by Ali Mohammad Pur
commit 76ee1ce04c
Notes: github-actions[bot] 2025-07-25 13:36:40 +00:00
4 changed files with 42 additions and 2 deletions

View file

@ -342,8 +342,11 @@ JS::ThrowCompletionOr<NonnullOwnPtr<Wasm::ModuleInstance>> instantiate_module(JS
// 3.5.1.7. Set the surrounding agent's associated store to store.
address = cache.abstract_machine().store().allocate({ type.type(), false }, cast_value);
}
// FIXME: 3.5.2. Otherwise, if v implements Global,
// FIXME: 3.5.2.1. Let globaladdr be v.[[Global]].
// 3.5.2. Otherwise, if v implements Global,
else if (import_.is_object() && is<Global>(import_.as_object())) {
// 3.5.2.1. Let globaladdr be v.[[Global]].
address = as<Global>(import_.as_object()).address();
}
// 3.5.3. Otherwise,
else {
// 3.5.3.1. Throw a LinkError exception.

View file

@ -0,0 +1,9 @@
Harness status: OK
Found 4 tests
4 Pass
Pass #1 Reinitialize the default imports
Pass #2 Reinitialize the default imports
Pass #3 Test that WebAssembly instantiation succeeds
Pass #4 Test that WebAssembly instantiation succeeds

View file

@ -0,0 +1,12 @@
(function simd_linking_wast_js() {
// simd_linking.wast:1
let $1 = instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x06\xab\x80\x80\x80\x00\x02\x7b\x00\xfd\x0c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0b\x7b\x01\xfd\x0c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0b\x07\x94\x80\x80\x80\x00\x02\x06\x67\x2d\x76\x31\x32\x38\x03\x00\x07\x6d\x67\x2d\x76\x31\x32\x38\x03\x01");
// simd_linking.wast:5
register("Mv128", $1)
// simd_linking.wast:7
let $2 = instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x02\x92\x80\x80\x80\x00\x01\x05\x4d\x76\x31\x32\x38\x07\x6d\x67\x2d\x76\x31\x32\x38\x03\x7b\x01");
reinitializeRegistry();
})();

View file

@ -0,0 +1,16 @@
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>WebAssembly Web Platform Test</title>
</head>
<body>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../js/harness/async_index.js"></script>
<div id=log></div>
<script src="../js/simd/simd_linking.wast.js"></script>
</body>
</html>