()
| 13 | // reused from the cache. |
| 14 | let sentinel = 0; |
| 15 | function buildModuleBytes() { |
| 16 | ++sentinel; |
| 17 | InspectorTest.log(`Building wasm module with sentinel ${sentinel}.`); |
| 18 | // Add fibonacci function, calling back and forth between JS and Wasm to also |
| 19 | // check for the occurrence of the wrappers. |
| 20 | var builder = new WasmModuleBuilder(); |
| 21 | const imp_index = builder.addImport('q', 'f', kSig_i_i); |
| 22 | builder.addFunction('fib', kSig_i_i) |
| 23 | .addBody([ |
| 24 | ...wasmI32Const(sentinel), kExprDrop, |
| 25 | kExprLocalGet, 0, |
| 26 | kExprLocalGet, 0, |
| 27 | kExprI32Const, 2, |
| 28 | kExprI32LeS, // i < 2 ? |
| 29 | kExprBrIf, 0, // --> return i |
| 30 | kExprI32Const, 1, kExprI32Sub, // i - 1 |
| 31 | kExprCallFunction, imp_index, // imp(i - 1) |
| 32 | kExprLocalGet, 0, kExprI32Const, 2, kExprI32Sub, // i - 2 |
| 33 | kExprCallFunction, imp_index, // imp(i - 2) |
| 34 | kExprI32Add |
| 35 | ]) |
| 36 | .exportFunc(); |
| 37 | return builder.toArray(); |
| 38 | } |
| 39 | |
| 40 | function instantiate(bytes) { |
| 41 | let buffer = new ArrayBuffer(bytes.length); |
no test coverage detected