31a209ca42
This commit re-introduces the functionality of __morestack in a way that it was not originally anticipated. Rust does not currently have segmented stacks, rather just large stack segments. We do not detect when these stack segments are overrun currently, but this commit leverages __morestack in order to check this. This commit purges a lot of the old __morestack and stack limit C++ functionality, migrating the necessary chunks to rust. The stack limit is now entirely maintained in rust, and the "main logic bits" of __morestack are now also implemented in rust as well. I put my best effort into validating that this currently builds and runs successfully on osx and linux 32/64 bit, but I was unable to get this working on windows. We never did have unwinding through __morestack frames, and although I tried poking at it for a bit, I was unable to understand why we don't get unwinding right now. A focus of this commit is to implement as much of the logic in rust as possible. This involved some liberal usage of `no_split_stack` in various locations, along with some use of the `asm!` macro (scary). I modified a bit of C++ to stop calling `record_sp_limit` because this is no longer defined in C++, rather in rust. Another consequence of this commit is that `thread_local_storage::{get, set}` must both be flagged with `#[rust_stack]`. I've briefly looked at the implementations on osx/linux/windows to ensure that they're pretty small stacks, and I'm pretty sure that they're definitely less than 20K stacks, so we probably don't have a lot to worry about. Other things worthy of note: * The default stack size is now 4MB instead of 2MB. This is so that when we request 2MB to call a C function you don't immediately overflow because you have consumed any stack at all. * `asm!` is actually pretty cool, maybe we could actually define context switching with it? * I wanted to add links to the internet about all this jazz of storing information in TLS, but I was only able to find a link for the windows implementation. Otherwise my suggestion is just "disassemble on that arch and see what happens" * I put my best effort forward on arm/mips to tweak __morestack correctly, we have no ability to test this so an extra set of eyes would be useful on these spots. * This is all really tricky stuff, so I tried to put as many comments as I thought were necessary, but if anything is still unclear (or I completely forgot to take something into account), I'm willing to write more! |
||
---|---|---|
.. | ||
clean.mk | ||
ctags.mk | ||
dist.mk | ||
docs.mk | ||
host.mk | ||
install.mk | ||
llvm.mk | ||
perf.mk | ||
platform.mk | ||
pp.mk | ||
rt.mk | ||
rustllvm.mk | ||
snap.mk | ||
stage0.mk | ||
target.mk | ||
tests.mk | ||
tools.mk |