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

Function buildModuleBytes

deps/v8/test/inspector/cpu-profiler/console-profile-wasm.js:15–38  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13// reused from the cache.
14let sentinel = 0;
15function 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
40function instantiate(bytes) {
41 let buffer = new ArrayBuffer(bytes.length);

Callers 2

compileWasmFunction · 0.70

Calls 7

addImportMethod · 0.95
addFunctionMethod · 0.95
toArrayMethod · 0.95
wasmI32ConstFunction · 0.50
logMethod · 0.45
exportFuncMethod · 0.45
addBodyMethod · 0.45

Tested by

no test coverage detected