Debian Codegraph @

js/src/jit-test/tests/wasm/builtin-modules/uses-memory.js

raw
1 // |jit-test| --setpref=wasm_moz_intgemm=true; skip-if: true
2
3 const wat = `(module
4 ;; This builtin requires a memory, but no memory is declared, so we should
5 ;; fail to validate the module.
6 (import "wasm_gemm" "int8_prepare_b" (func $f (param i32 f32 f32 i32 i32 i32)))
7 ;; For good measure, we also attempt to call the function. This shouldn't
8 ;; even validate because the module should be rejected before the code
9 ;; section, but it gives us a fuller picture of validation.
10 (func (export "g")
11 (call $f (i32.const 0) (f32.const 0) (f32.const 0) (i32.const 64) (i32.const 64) (i32.const 0))
12 )
13 )`;
14
15 // new WebAssembly.Module
16 {
17 const g = newGlobal({ newCompartment: true, systemPrincipal: true });
18 assertErrorMessage(() => g.eval(`
19 const mod = new WebAssembly.Module(wasmTextToBinary(\`${wat}\`), { mozIntGemm: true });
20 `), g.WebAssembly.CompileError, /builtin function that requires a memory/);
21 }
22
23 // WebAssembly.instantiate
24 {
25 const g = newGlobal({ newCompartment: true, systemPrincipal: true });
26 assertErrorMessage(() => g.eval(`
27 let caught;
28 WebAssembly.instantiate(wasmTextToBinary(\`${wat}\`), {}, { mozIntGemm: true })
29 .then(() => {}, e => { caught = e; });
30 drainJobQueue();
31 if (caught) {
32 throw caught;
33 }
34 `), g.WebAssembly.CompileError, /builtin function that requires a memory/);
35 }
36
37 // WebAssembly.validate
38 {
39 const g = newGlobal({ newCompartment: true, systemPrincipal: true });
40 assertEq(g.eval(`
41 WebAssembly.validate(wasmTextToBinary(\`${wat}\`), { mozIntGemm: true });
42 `), false);
43 }