> Under which circumstances would the Nim runtime not run at the root of the > call stack?
Normally when you compile your program with all the default options the GC can potentially kick in on any allocation. When compiling to asm.js/wasm through emscripten or clang you have to take special care to not let the GC happen "whenever", but only to let it happen when there are **no objects referred only from the stack** , because such objects will be mistakenly collected. Stack bottom is kinda guaranteed to be such a place that satisfies this requirement. Most obvious stack bottoms are nim functions which are called immediately from JS. As an example here's [some nimx code which runs the GC once per frame](https://github.com/yglukhov/nimx/blob/master/nimx/private/windows/emscripten_window.nim#L405-L421). > Does the EMSCRIPTEN_KEEPALIVE play a role in this? No. Totally irrelevant. > What about taking the no-emscripten path... The issue is the same with emscripten asm.js/wasm, and with pure clang wasm. Hopefully that makes it clear :)
