Large valid WASM functions exceed the JavaScript translator call-argument limit

Chiusa
#1,796 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@MathurAditya724 ci sta già lavorando.

Dal 20/10/2026.

  • #1575 di @MathurAditya724 — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
node.js, typescript, wasm
Ambito
backend, compilers

Direzione di ricerca

Read packages/compiler/src/wasm/translate.test.ts and the linked pull request #1575, which contains the standalone regression and proposed fix. Run pnpm exec vitest run packages/compiler/src/wasm/translate.test.ts in the prepared scriptc checkout. Done means the valid module translates with all 100,000 additions and the return instruction, and the regression passes.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

We are experimenting with compiling the complete Sentry CLI with scriptc, retaining its SQLite and debug-file processing dependencies, before comparing it with the existing Node SEA build. Large dependency WASM modules exposed a size limit in the JavaScript-hosted WASM translator.

Observed behavior

A valid WASM function with enough generated instructions fails during translation with:

RangeError: Maximum call stack size exceeded

The translator appends the function body with out.push(...this.lines.lines). Every generated line becomes a separate JavaScript call argument, so sufficiently large functions exceed the host engine's argument limit. This is a host call limit, rather than recursive WASM execution or invalid WASM input.

Reproduction and expected behavior

The standalone regression in #1575 constructs a valid module exporting sum, with one i32 local and 100,000 repeated additions of one. Node instantiates the module and returns 100000; the unpatched translator at 18400d0 throws while appending its generated body. Validation used Node 24.22.0 on Darwin arm64.

Translation should finish, retaining all 100,000 additions and the return instruction. The regression can be run from a prepared scriptc checkout containing the test:

pnpm exec vitest run packages/compiler/src/wasm/translate.test.ts
Proposed fix and scope

#1575 appends the generated lines in order with a loop. It removes the argument-count limit without changing translation semantics or the emitted IR. The issue concerns the JavaScript-hosted translator/API; it does not establish that the native compiler has the same host argument limit.

The regression fails before the fix and passes after it. Local validation also passed all 48 WASM tests and a 32-workload comparison with byte-identical IR, LLVM, and release executables. This fix removes one compilation blocker; the complete Sentry CLI still has other compatibility blockers, so no full CLI performance improvement is claimed.

Lingua principale
TypeScript
Stelle
6.4k
Fork
204
Merge medio
7h 45m
PR unite (30g)
845

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di vercel-labs/scriptc

Tutte le issue di vercel-labs/scriptc

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.