Page MenuHomePhabricator

[WebAssembly] Create a __stack_limit variable
Needs ReviewPublic

Authored by sunfish on Wed, Nov 20, 3:08 PM.

Details

Reviewers
sbc100
Summary

Create a stack_limit variable, similar to stack_pointer, to mark
the end of the stack. This will support stack overflow checks.

Diff Detail

Event Timeline

sunfish created this revision.Wed, Nov 20, 3:08 PM

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?

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?

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?