(f)
| 7 | d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js"); |
| 8 | |
| 9 | function run(f) { |
| 10 | // wrap the creation in a closure so that the only thing returned is |
| 11 | // the module (i.e. the underlying array buffer of wasm wire bytes dies). |
| 12 | var module = (() => { |
| 13 | var builder = new WasmModuleBuilder(); |
| 14 | builder.addImport("mod", "the_name_of_my_import", kSig_i_i); |
| 15 | builder.addFunction("main", kSig_i_i) |
| 16 | .addBody([ |
| 17 | kExprLocalGet, 0, |
| 18 | kExprCallFunction, 0]) |
| 19 | .exportAs("main"); |
| 20 | print("module"); |
| 21 | return new WebAssembly.Module(builder.toBuffer()); |
| 22 | })(); |
| 23 | |
| 24 | gc(); |
| 25 | for (var i = 0; i < 10; i++) { |
| 26 | print(" instance " + i); |
| 27 | var instance = new WebAssembly.Instance(module, {"mod": {the_name_of_my_import: f}}); |
| 28 | var g = instance.exports.main; |
| 29 | assertEquals("function", typeof g); |
| 30 | for (var j = 0; j < 10; j++) { |
| 31 | assertEquals(f(j), g(j)); |
| 32 | } |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | (function test() { |
| 37 | for (var i = 0; i < 3; i++) { |
no test coverage detected