rust/src/rt
bors 31a209ca42 auto merge of #9834 : alexcrichton/rust/morestack, r=brson
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!
2013-10-19 09:46:18 -07:00
..
arch Use __morestack to detect stack overflow 2013-10-19 09:43:31 -07:00
msvc Add some C99 and C++ compatibility headers for MSVC 2011-03-21 10:24:00 -07:00
sundown Expand tidy to prevent binaries from being checked 2013-09-30 10:15:47 -07:00
sync Use __morestack to detect stack overflow 2013-10-19 09:43:31 -07:00
util rt: Remove indexed_list 2013-08-23 14:46:23 -07:00
vg rt: Make valgrind Win64-compatible 2013-08-26 22:15:45 +09:00
boxed_region.cpp rt: Remove rust_env 2013-08-16 13:24:24 -07:00
boxed_region.h rt: Don't make memory_region depend on rust_env 2013-04-21 17:42:45 -07:00
memory_region.cpp rt: Remove sync.h 2013-08-23 18:38:59 -07:00
memory_region.h rt: Memory regions are never synchronized now 2013-08-23 18:38:59 -07:00
miniz.cpp Fix MZ_FORCEINLINE define to work with GCC 4.7.1. 2012-08-29 01:18:00 -07:00
rust_android_dummy.cpp rt: add android dummy functions for mman related 2013-06-26 10:25:12 +09:00
rust_android_dummy.h auto merge of #6234 : yichoi/rust/glob-dummy-pull, r=thestinger 2013-05-04 22:09:36 -07:00
rust_builtin.cpp Use __morestack to detect stack overflow 2013-10-19 09:43:31 -07:00
rust_globals.h rt: Remove unused parts of rust_globals.h 2013-08-16 13:24:24 -07:00
rust_test_helpers.cpp Use __morestack to detect stack overflow 2013-10-19 09:43:31 -07:00
rust_type.h add type name to the tydesc 2013-09-03 04:44:47 -04:00
rust_upcall.cpp rt: Support SEH/SJLJ personality routine 2013-08-26 22:15:45 +09:00
rust_util.h Remove a little bit of unused C++ 2013-09-26 18:40:13 -07:00
rust_uv.cpp Implement process bindings to libuv 2013-09-18 13:52:18 -07:00
rustrt.def.in Use __morestack to detect stack overflow 2013-10-19 09:43:31 -07:00