Create a stack_limit variable, similar to stack_pointer, to mark
the end of the stack. This will support stack overflow checks.
Details
- Reviewers
sbc100
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Does this need to be wasm global? Or can it just be regular data symbol like globalBase? i.e. do we want fast access to it without a load?
lld/wasm/Writer.cpp | ||
---|---|---|
221 | Maybe avoid the extra local and just do this 4 lines above. You can also remove the now redundant log("mem: stack base = " + Twine(memoryPtr)); line? |
I made it a global because I was thinking about multiple threads, where each thread has its own stack. But that's true, we could do a data symbol in the single-threaded case. I'll look into that.
I think if you want it to be visible as a C symbol, with an address etc, then it would need to be data symbol. It can be TLS for multi-threading I guess?
Sorry, I have somehow forgotten about this change when I created https://reviews.llvm.org/D135910.
I'm not sure if something like this also needed? Unlike the two variables I created this global is thread local which means it could be more useful in mutli-thread environments. In emscripten we currently inject a (TLS) wasm global to aid with stack checking: https://github.com/emscripten-core/emscripten/blob/af961ad5c4c278ec510f0b7f7d522a95ee5a90f8/system/lib/compiler-rt/stack_limits.S#L21-L24.. but I suppose having the linker so it could also make sense.
Do you think this change is still useful and/or better than https://reviews.llvm.org/D135910?
Maybe avoid the extra local and just do this 4 lines above. You can also remove the now redundant log("mem: stack base = " + Twine(memoryPtr)); line?