3 ms·
There are two compilers involved, Source to Wasm and Wasm to native (usually JIT). The second could easily optimize tail calls but it is required not to do so
by afiori 4y ago
There are two compilers involved, Source to Wasm and Wasm to native (usually JIT).
The second could easily optimize tail calls but it is required not to do so to increase reliability (all implementations need to agree which calls are tail calls that should be optimized and the simplest way to agree is to never do it) as otherwise a Wasm modules could work fine on an implementation and be unusable in another.
The first compiler cannot, the only possibility is to use whole-program transformations that significantly degrade performances.