From af8e766c26d36c34c3b84c975d3dea96dcf22197 Mon Sep 17 00:00:00 2001 From: Sven Sauleau Date: Mon, 11 Nov 2024 14:28:48 +0100 Subject: [PATCH] add missing saturating truncation instructions --- packages/helper-wasm-bytecode/src/index.js | 11 + .../test/fixtures/conversions/actual.wasm | Bin 0 -> 977 bytes .../test/fixtures/conversions/expected | 487 ++++++++++++++++++ 3 files changed, 498 insertions(+) create mode 100644 packages/wasm-parser/test/fixtures/conversions/actual.wasm create mode 100644 packages/wasm-parser/test/fixtures/conversions/expected diff --git a/packages/helper-wasm-bytecode/src/index.js b/packages/helper-wasm-bytecode/src/index.js index 76536f6ec..6d91ee69a 100644 --- a/packages/helper-wasm-bytecode/src/index.js +++ b/packages/helper-wasm-bytecode/src/index.js @@ -348,6 +348,17 @@ const symbolsByByte = { 0xfc_10: createSymbol("table.size", 1), 0xfc_11: createSymbol("table.fill", 1), + // https://webassembly.github.io/spec/core/binary/instructions.html#numeric-instructions + // saturating truncation instructions + 0xfc_00: createSymbol("i32.trunc_sat_f32_s"), + 0xfc_01: createSymbol("i32.trunc_sat_f32_u"), + 0xfc_02: createSymbol("i32.trunc_sat_f64_s"), + 0xfc_03: createSymbol("i32.trunc_sat_f64_u"), + 0xfc_04: createSymbol("i64.trunc_sat_f32_s"), + 0xfc_05: createSymbol("i64.trunc_sat_f32_u"), + 0xfc_06: createSymbol("i64.trunc_sat_f64_s"), + 0xfc_07: createSymbol("i64.trunc_sat_f64_u"), + // Atomic Memory Instructions 0xfe00: createSymbol("memory.atomic.notify", 1), 0xfe01: createSymbol("memory.atomic.wait32", 1), diff --git a/packages/wasm-parser/test/fixtures/conversions/actual.wasm b/packages/wasm-parser/test/fixtures/conversions/actual.wasm new file mode 100644 index 0000000000000000000000000000000000000000..dd697c3baae315ab4361abfbbef7850548a5d50a GIT binary patch literal 977 zcmZvaM{>eI5Jh_=B!aL3%Q=D%z`~~3`7A(zsA54Vp|QOnoWZAX&N&~!7xKb0e{jL5 zSm^cWO?PY55>>iQMnr5cS!P2vD6;_@mRVn-r&hxCW45x%UK2Nt2jLzgtv7C}& zi=H!6ET>s_e7YOFwgXR2lh$VCiEEw`;ulzVrSQE*EAae|@8LCQ z!