rust/src/libstd/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
..
io std: Move size/align functions to std::mem. #2240 2013-10-17 17:31:35 -07:00
uv auto merge of #9721 : klutzy/rust/uv-net-read-fix, r=alexcrichton 2013-10-16 19:21:25 -07:00
args.rs option: rewrite the API to use composition 2013-10-09 09:17:29 -04:00
borrowck.rs De-pub some private runtime components 2013-10-11 06:49:18 -07:00
comm.rs option: rewrite the API to use composition 2013-10-09 09:17:29 -04:00
context.rs auto merge of #9834 : alexcrichton/rust/morestack, r=brson 2013-10-19 09:46:18 -07:00
crate_map.rs Use __morestack to detect stack overflow 2013-10-19 09:43:31 -07:00
env.rs Use __morestack to detect stack overflow 2013-10-19 09:43:31 -07:00
global_heap.rs std: Move size/align functions to std::mem. #2240 2013-10-17 17:31:35 -07:00
kill.rs option: rewrite the API to use composition 2013-10-09 09:17:29 -04:00
local_heap.rs De-pub some private runtime components 2013-10-11 06:49:18 -07:00
local_ptr.rs De-pub some private runtime components 2013-10-11 06:49:18 -07:00
local.rs librustc: Fix merge fallout 2013-08-27 19:09:27 -07:00
logging.rs Migrate users of io::fd_t to io::native::file::fd_t 2013-10-10 03:38:51 -07:00
macros.rs De-pub some private runtime components 2013-10-11 06:49:18 -07:00
message_queue.rs Rename UnsafeAtomicRcBox to UnsafeArc. Fixes #7674. 2013-08-27 20:12:39 +10:00
mod.rs std::rt: Fix the set up of the main thread so that it doesn't try to steal work 2013-10-14 16:08:18 -07:00
rc.rs remove unnecessary transmutes 2013-09-17 11:54:37 -04:00
rtio.rs Implement process bindings to libuv 2013-09-18 13:52:18 -07:00
sched.rs auto merge of #9834 : alexcrichton/rust/morestack, r=brson 2013-10-19 09:46:18 -07:00
select.rs librustc: Ensure that type parameters are in the right positions in paths. 2013-08-27 18:47:57 -07:00
sleeper_list.rs Rename UnsafeAtomicRcBox to UnsafeArc. Fixes #7674. 2013-08-27 20:12:39 +10:00
stack.rs switch Drop to &mut self 2013-09-16 22:19:23 -04:00
task.rs auto merge of #9834 : alexcrichton/rust/morestack, r=brson 2013-10-19 09:46:18 -07:00
test.rs std: Move size/align functions to std::mem. #2240 2013-10-17 17:31:35 -07:00
thread_local_storage.rs Use __morestack to detect stack overflow 2013-10-19 09:43:31 -07:00
thread.rs Use __morestack to detect stack overflow 2013-10-19 09:43:31 -07:00
tube.rs librustc: Ensure that type parameters are in the right positions in paths. 2013-08-27 18:47:57 -07:00
util.rs De-pub some private runtime components 2013-10-11 06:49:18 -07:00
work_queue.rs Change concurrency primitives to standard naming conventions 2013-07-27 22:06:29 -07:00