From ae90475ad576b4e477062acf9667eb108f691387 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Tue, 16 Jan 2024 22:05:58 +0100 Subject: [PATCH] fix: patch parser to support narrow-width integer sign byte opcode --- lib/wasm-parser.mjs | 14 ++++++++++---- package.json | 7 ++++++- ...emblyjs__helper-wasm-bytecode@1.11.6.patch | 19 +++++++++++++++++++ pnpm-lock.yaml | 12 +++++++++--- 4 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 patches/@webassemblyjs__helper-wasm-bytecode@1.11.6.patch diff --git a/lib/wasm-parser.mjs b/lib/wasm-parser.mjs index 6c40759..445c8da 100644 --- a/lib/wasm-parser.mjs +++ b/lib/wasm-parser.mjs @@ -3054,9 +3054,9 @@ var require_signatures = __commonJS({ } }); -// node_modules/.pnpm/@webassemblyjs+helper-wasm-bytecode@1.11.6/node_modules/@webassemblyjs/helper-wasm-bytecode/lib/section.js +// node_modules/.pnpm/@webassemblyjs+helper-wasm-bytecode@1.11.6_patch_hash=2yqg2jtg6wn6u6w2h6qfarflum/node_modules/@webassemblyjs/helper-wasm-bytecode/lib/section.js var require_section = __commonJS({ - "node_modules/.pnpm/@webassemblyjs+helper-wasm-bytecode@1.11.6/node_modules/@webassemblyjs/helper-wasm-bytecode/lib/section.js"(exports) { + "node_modules/.pnpm/@webassemblyjs+helper-wasm-bytecode@1.11.6_patch_hash=2yqg2jtg6wn6u6w2h6qfarflum/node_modules/@webassemblyjs/helper-wasm-bytecode/lib/section.js"(exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true @@ -3088,9 +3088,9 @@ var require_section = __commonJS({ } }); -// node_modules/.pnpm/@webassemblyjs+helper-wasm-bytecode@1.11.6/node_modules/@webassemblyjs/helper-wasm-bytecode/lib/index.js +// node_modules/.pnpm/@webassemblyjs+helper-wasm-bytecode@1.11.6_patch_hash=2yqg2jtg6wn6u6w2h6qfarflum/node_modules/@webassemblyjs/helper-wasm-bytecode/lib/index.js var require_lib6 = __commonJS({ - "node_modules/.pnpm/@webassemblyjs+helper-wasm-bytecode@1.11.6/node_modules/@webassemblyjs/helper-wasm-bytecode/lib/index.js"(exports) { + "node_modules/.pnpm/@webassemblyjs+helper-wasm-bytecode@1.11.6_patch_hash=2yqg2jtg6wn6u6w2h6qfarflum/node_modules/@webassemblyjs/helper-wasm-bytecode/lib/index.js"(exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true @@ -3381,6 +3381,12 @@ var require_lib6 = __commonJS({ 189: createSymbolObject("reinterpret/f64", "i64"), 190: createSymbolObject("reinterpret/i32", "f32"), 191: createSymbolObject("reinterpret/i64", "f64"), + // https://github.com/xtuc/webassemblyjs/pull/1147 + 192: createSymbolObject("extend8_s", "i32"), + 193: createSymbolObject("extend16_s", "i32"), + 194: createSymbolObject("extend8_s", "i64"), + 195: createSymbolObject("extend16_s", "i64"), + 196: createSymbolObject("extend32_s", "i64"), // Atomic Memory Instructions 65024: createSymbol("memory.atomic.notify", 1), 65025: createSymbol("memory.atomic.wait32", 1), diff --git a/package.json b/package.json index a65b796..24bef75 100644 --- a/package.json +++ b/package.json @@ -73,5 +73,10 @@ "vite": "^5.0.11", "vitest": "^1.2.0" }, - "packageManager": "pnpm@8.14.1" + "packageManager": "pnpm@8.14.1", + "pnpm": { + "patchedDependencies": { + "@webassemblyjs/helper-wasm-bytecode@1.11.6": "patches/@webassemblyjs__helper-wasm-bytecode@1.11.6.patch" + } + } } diff --git a/patches/@webassemblyjs__helper-wasm-bytecode@1.11.6.patch b/patches/@webassemblyjs__helper-wasm-bytecode@1.11.6.patch new file mode 100644 index 0000000..f2b90a1 --- /dev/null +++ b/patches/@webassemblyjs__helper-wasm-bytecode@1.11.6.patch @@ -0,0 +1,19 @@ +diff --git a/lib/index.js b/lib/index.js +index cd647d2d169fe793dc3100a148c0beef19c286fc..76d80a75a4be8218ad3af3097dff3d05921793d4 100644 +--- a/lib/index.js ++++ b/lib/index.js +@@ -311,6 +311,14 @@ var symbolsByByte = { + 0xbd: createSymbolObject("reinterpret/f64", "i64"), + 0xbe: createSymbolObject("reinterpret/i32", "f32"), + 0xbf: createSymbolObject("reinterpret/i64", "f64"), ++ ++ // https://github.com/xtuc/webassemblyjs/pull/1147 ++ 0xc0: createSymbolObject("extend8_s", "i32"), ++ 0xc1: createSymbolObject("extend16_s", "i32"), ++ 0xc2: createSymbolObject("extend8_s", "i64"), ++ 0xc3: createSymbolObject("extend16_s", "i64"), ++ 0xc4: createSymbolObject("extend32_s", "i64"), ++ + // Atomic Memory Instructions + 0xfe00: createSymbol("memory.atomic.notify", 1), + 0xfe01: createSymbol("memory.atomic.wait32", 1), diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 12f9d1d..af00b4a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,6 +4,11 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false +patchedDependencies: + '@webassemblyjs/helper-wasm-bytecode@1.11.6': + hash: 2yqg2jtg6wn6u6w2h6qfarflum + path: patches/@webassemblyjs__helper-wasm-bytecode@1.11.6.patch + dependencies: magic-string: specifier: ^0.30.5 @@ -1151,7 +1156,7 @@ packages: resolution: {integrity: sha512-IN1xI7PwOvLPgjcf180gC1bqn3q/QaOCwYUahIOhbYUu8KA/3tw2RT/T0Gidi1l7Hhj5D/INhJxiICObqpMu4Q==} dependencies: '@webassemblyjs/helper-numbers': 1.11.6 - '@webassemblyjs/helper-wasm-bytecode': 1.11.6 + '@webassemblyjs/helper-wasm-bytecode': 1.11.6(patch_hash=2yqg2jtg6wn6u6w2h6qfarflum) dev: true /@webassemblyjs/floating-point-hex-parser@1.11.6: @@ -1170,9 +1175,10 @@ packages: '@xtuc/long': 4.2.2 dev: true - /@webassemblyjs/helper-wasm-bytecode@1.11.6: + /@webassemblyjs/helper-wasm-bytecode@1.11.6(patch_hash=2yqg2jtg6wn6u6w2h6qfarflum): resolution: {integrity: sha512-sFFHKwcmBprO9e7Icf0+gddyWYDViL8bpPjJJl0WHxCdETktXdmtWLGVzoHbqUcY4Be1LkNfwTmXOJUFZYSJdA==} dev: true + patched: true /@webassemblyjs/ieee754@1.11.6: resolution: {integrity: sha512-LM4p2csPNvbij6U1f19v6WR56QZ8JcHg3QIJTlSwzFcmx6WSORicYj6I63f9yU1kEUtrpG+kjkiIAkevHpDXrg==} @@ -1195,7 +1201,7 @@ packages: dependencies: '@webassemblyjs/ast': 1.11.6 '@webassemblyjs/helper-api-error': 1.11.6 - '@webassemblyjs/helper-wasm-bytecode': 1.11.6 + '@webassemblyjs/helper-wasm-bytecode': 1.11.6(patch_hash=2yqg2jtg6wn6u6w2h6qfarflum) '@webassemblyjs/ieee754': 1.11.6 '@webassemblyjs/leb128': 1.11.6 '@webassemblyjs/utf8': 1.11.6