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

Function addLoadSetTestFunction

deps/v8/test/mjsunit/wasm/wasm-interpreter.js:861–901  ·  view source on GitHub ↗
(builder, name, copyFromReg)

Source from the content-addressed store, hash-verified

859 const new_value = 42;
860
861 let addLoadSetTestFunction = function (builder, name, copyFromReg) {
862 builder.addFunction(name, kSig_v_v)
863 .addLocals(kWasmI32, 1)
864 .addBody([
865 // Create a shared slot.
866 ...wasmI32Const(old_value),
867 kExprLocalSet, 0,
868 kExprLocalGet, 0,
869
870 // Write a new value to memory
871 ...wasmI32Const(memory_offset),
872 ...wasmI32Const(new_value),
873 kExprI32StoreMem, 0, 0,
874
875 // Super-instruction: Load+Set.
876 ...wasmI32Const(memory_offset)]
877 .concat(copyFromReg ? [
878 ...wasmI32Const(0),
879 kExprI32Add
880 ] : [])
881 .concat([
882 kExprI32LoadMem, 0, 0,
883 kExprLocalSet, 0,
884
885 // Verify that the set slot contains the new value and that the shared
886 // slot contains the old value.
887 ...wasmI32Const(old_value),
888 kExprI32Ne,
889 kExprIf, kWasmVoid,
890 kExprUnreachable,
891 kExprEnd,
892
893 kExprLocalGet, 0,
894 ...wasmI32Const(new_value),
895 kExprI32Ne,
896 kExprIf, kWasmVoid,
897 kExprUnreachable,
898 kExprEnd
899 ]))
900 .exportAs(name);
901 }
902
903 var builder = new WasmModuleBuilder();
904 builder.addMemory(1, 1, false);

Callers 1

Calls 6

concatMethod · 0.80
wasmI32ConstFunction · 0.70
exportAsMethod · 0.45
addBodyMethod · 0.45
addLocalsMethod · 0.45
addFunctionMethod · 0.45

Tested by

no test coverage detected