pub const WASM_MAX_STACK: u32 = _ /* 262_144u32 */;Expand description
The largest ValidateOptions::max_stack on WebAssembly, and its default there
(DEFAULT_MAX_STACK): 256 KiB.
The native stack of a JavaScript engine can run out before the module’s stack in
linear memory reaches ValidateOptions::max_stack (see WASM_MAX_DEPTH).
Measured with the npm package, the largest max_stack, in KiB, with which a
recursion still ends with Error::Limit (LimitExceeded::Stack) rather than with
the engine’s stack overflow, for the stylesheets of the built-in rule sets and of
Peppol BIS Billing 3.0.22 on a document 8192 levels deep / a named template calling
itself (not as a tail call) / a template rule applying itself / a function calling
itself:
| Engine | Official | Named template | Template rule | Function |
|---|---|---|---|---|
| Chrome 154, Web Worker | 320 | 342 | 348 | 543 |
| Chrome 154, main thread | 522 | 512 | 545 | 863 |
| Firefox 153, Web Worker | 630 | 674 | 689 | 1021 |
| Firefox 153, main thread | 1021 | 1021 | 1021 | 1021 |
| Node.js 22 | 640 | 679 | 685 | 1021 |
(1021 KiB is the module’s own stack, 1 MiB, running out.) 256 KiB keeps a margin of a fifth below the smallest, a Chrome Web Worker.