Debian Codegraph @

js/src/jit-test/tests/wasm/regress/bug1777604/test.js

raw
1 // |jit-test| skip-if: !wasmStreamingEnabled()
2
3 const { Instance, compile, compileStreaming } = WebAssembly;
4
5 for (let i = 0; i < 200; i++) {
6 // Possibly free code from a previous iteration, increasing probability
7 // new code will be allocated in a location previous code was.
8 gc(undefined, "shrinking");
9
10 function compileAndRun(x, g) {
11 var cache = streamCacheEntry(wasmTextToBinary(x));
12
13 compileStreaming(cache).then(function (m) {
14 g(new Instance(m, undefined));
15 return compileStreaming(cache);
16 }).then(function (m) {
17 g(new Instance(m, undefined));
18 });
19
20 // Serialize the promise execution at this point
21 drainJobQueue();
22 }
23
24 // Compile two different modules to increase probability that a module is
25 // is compiled to a page that a different module resided in previously.
26 compileAndRun('(module \
27 (func $test (param i64) (result f64) local.get 0 f64.convert_i64_u )\
28 (func (export "run") (result i32) i64.const 1 call $test f64.const 1 f64.eq )\
29 )', function (i) {});
30 compileAndRun('(module \
31 (func (export "run") (result i64) (i64.const 1))\
32 )', function (i) {
33 i.exports.run();
34 });
35 }