(add_memory, import_sig)
| 11 | // This builder can be used to generate a module with memory + load/store |
| 12 | // functions and/or an additional imported function. |
| 13 | function generateBuilder(add_memory, import_sig) { |
| 14 | let builder = new WasmModuleBuilder(); |
| 15 | if (import_sig) { |
| 16 | // Add the import if we expect a module builder with imported functions. |
| 17 | let idx = builder.addImport('import_module', 'other_module_fn', import_sig); |
| 18 | // The imported function should always have index 0. With this assertion we |
| 19 | // verify that we can use other_fn_idx to refer to this function. |
| 20 | assertEquals(idx, other_fn_idx) |
| 21 | } |
| 22 | if (add_memory) { |
| 23 | // Add the memory if we expect a module builder with memory and load/store. |
| 24 | builder.addMemory(initialMemoryPages, maximumMemoryPages); |
| 25 | builder.addFunction('load', kSig_i_i) |
| 26 | .addBody([kExprLocalGet, 0, kExprI32LoadMem, 0, 0]) |
| 27 | .exportFunc(); |
| 28 | builder.addFunction('store', kSig_i_ii) |
| 29 | .addBody([ |
| 30 | kExprLocalGet, 0, kExprLocalGet, 1, kExprI32StoreMem, 0, 0, |
| 31 | kExprLocalGet, 1 |
| 32 | ]) |
| 33 | .exportFunc(); |
| 34 | } |
| 35 | return builder; |
| 36 | } |
| 37 | |
| 38 | function assertMemoryIndependence(load_a, store_a, load_b, store_b) { |
| 39 |
no test coverage detected
searching dependent graphs…