MCPcopy Create free account
hub / github.com/nodejs/node / instantiateWasm

Function instantiateWasm

deps/v8/test/inspector/debugger/wasm-gc-anyref.js:66–177  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

64}
65
66async function instantiateWasm() {
67 var builder = new WasmModuleBuilder();
68 builder.startRecGroup();
69 let struct_type = builder.addStruct([makeField(kWasmI32, false)]);
70 let array_type = builder.addArray(kWasmI32);
71 let imported_ref_table =
72 builder.addImportedTable('import', 'any_table', 4, 4, kWasmAnyRef);
73 let imported_func_table =
74 builder.addImportedTable('import', 'func_table', 3, 3, kWasmFuncRef);
75 let ref_table = builder.addTable(kWasmAnyRef, 4)
76 .exportAs('exported_ref_table');
77 let func_table = builder.addTable(kWasmFuncRef, 3)
78 .exportAs('exported_func_table');
79 let i31ref_table = builder.addTable(kWasmI31Ref, 3)
80 .exportAs('exported_i31_table');
81
82 let func = builder.addFunction('my_func', kSig_v_v).addBody([kExprNop]);
83 // Make the function "declared".
84 builder.addGlobal(kWasmFuncRef, false, false, [kExprRefFunc, func.index]);
85
86 builder.addFunction('fill_tables', kSig_v_v)
87 .addBody([
88 ...wasmI32Const(0), ...wasmI32Const(123),
89 kGCPrefix, kExprStructNew, struct_type, kExprTableSet, ref_table.index,
90 ...wasmI32Const(1), ...wasmI32Const(20), ...wasmI32Const(21),
91 kGCPrefix, kExprArrayNewFixed, array_type, 2,
92 kExprTableSet, ref_table.index,
93 ...wasmI32Const(2), ...wasmI32Const(30),
94 kGCPrefix, kExprRefI31, kExprTableSet, ref_table.index,
95
96 // Fill imported any table.
97 ...wasmI32Const(1),
98 ...wasmI32Const(123), kGCPrefix, kExprStructNew, struct_type,
99 kExprTableSet, imported_ref_table,
100
101 ...wasmI32Const(1),
102 ...wasmI32Const(321), kGCPrefix, kExprRefI31,
103 kExprTableSet, imported_ref_table,
104
105 // Fill imported func table.
106 ...wasmI32Const(1),
107 kExprRefFunc, func.index,
108 kExprTableSet, imported_func_table,
109
110 // Fill func table.
111 ...wasmI32Const(1),
112 kExprRefFunc, func.index,
113 kExprTableSet, func_table.index,
114
115 // Fill i31 table.
116 ...wasmI32Const(0),
117 ...wasmI32Const(123456), kGCPrefix, kExprRefI31,
118 kExprTableSet, i31ref_table.index,
119
120 ...wasmI32Const(1),
121 ...wasmI32Const(-123), kGCPrefix, kExprRefI31,
122 kExprTableSet, i31ref_table.index,
123 ]).exportFunc();

Callers 1

wasm-gc-anyref.jsFile · 0.70

Calls 15

startRecGroupMethod · 0.95
addStructMethod · 0.95
addArrayMethod · 0.95
addImportedTableMethod · 0.95
addTableMethod · 0.95
addFunctionMethod · 0.95
addGlobalMethod · 0.95
endRecGroupMethod · 0.95
toArrayMethod · 0.95
makeFieldFunction · 0.50
wasmI32ConstFunction · 0.50
exportAsMethod · 0.45

Tested by

no test coverage detected