MCPcopy Index your code
hub / github.com/nodejs/node / generateBuilder

Function generateBuilder

deps/v8/test/mjsunit/wasm/memory-external-call.js:13–36  ·  view source on GitHub ↗
(add_memory, import_sig)

Source from the content-addressed store, hash-verified

11// This builder can be used to generate a module with memory + load/store
12// functions and/or an additional imported function.
13function 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
38function assertMemoryIndependence(load_a, store_a, load_b, store_b) {
39

Callers 1

Calls 6

addImportMethod · 0.95
addMemoryMethod · 0.95
addFunctionMethod · 0.95
assertEqualsFunction · 0.50
exportFuncMethod · 0.45
addBodyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…