about summary refs log tree commit diff
path: root/src/libstd/rt
AgeCommit message (Collapse)AuthorLines
2014-01-22auto merge of #11682 : thestinger/rust/vector, r=brsonbors-2/+2
This is just an initial implementation and does not yet fully replace `~[T]`. A generic initialization syntax for containers is missing, and the slice functionality needs to be reworked to make auto-slicing unnecessary. Traits for supporting indexing properly are also required. This also needs to be fixed to make ring buffers as easy to use as vectors. The tests and documentation for `~[T]` can be ported over to this type when it is removed. I don't really expect DST to happen for vectors as having both `~[T]` and `Vec<T>` is overcomplicated and changing the slice representation to 3 words is not at all appealing. Unlike with traits, it's possible (and easy) to implement `RcSlice<T>` and `GcSlice<T>` without compiler help.
2014-01-22add new vector representation as a libraryDaniel Micay-1/+1
2014-01-22libc: switch `free` to the proper signatureDaniel Micay-2/+2
This does not attempt to fully propagate the mutability everywhere, but gives new code a hint to avoid the same issues.
2014-01-22Implement native timersAlex Crichton-0/+7
Native timers are a much hairier thing to deal with than green timers due to the interface that we would like to expose (both a blocking sleep() and a channel-based interface). I ended up implementing timers in three different ways for the various platforms that we supports. In all three of the implementations, there is a worker thread which does send()s on channels for timers. This worker thread is initialized once and then communicated to in a platform-specific manner, but there's always a shared channel available for sending messages to the worker thread. * Windows - I decided to use windows kernel timer objects via CreateWaitableTimer and SetWaitableTimer in order to provide sleeping capabilities. The worker thread blocks via WaitForMultipleObjects where one of the objects is an event that is used to wake up the helper thread (which then drains the incoming message channel for requests). * Linux/(Android?) - These have the ideal interface for implementing timers, timerfd_create. Each timer corresponds to a timerfd, and the helper thread uses epoll to wait for all active timers and then send() for the next one that wakes up. The tricky part in this implementation is updating a timerfd, but see the implementation for the fun details * OSX/FreeBSD - These obviously don't have the windows APIs, and sadly don't have the timerfd api available to them, so I have thrown together a solution which uses select() plus a timeout in order to ad-hoc-ly implement a timer solution for threads. The implementation is backed by a sorted array of timers which need to fire. As I said, this is an ad-hoc solution which is certainly not accurate timing-wise. I have done this implementation due to the lack of other primitives to provide an implementation, and I've done it the best that I could, but I'm sure that there's room for improvement. I'm pretty happy with how these implementations turned out. In theory we could drop the timerfd implementation and have linux use the select() + timeout implementation, but it's so inaccurate that I would much rather continue to use timerfd rather than my ad-hoc select() implementation. The only change that I would make to the API in general is to have a generic sleep() method on an IoFactory which doesn't require allocating a Timer object. For everything but windows it's super-cheap to request a blocking sleep for a set amount of time, and it's probably worth it to provide a sleep() which doesn't do something like allocate a file descriptor on linux.
2014-01-22Implement std::rt::at_exitAlex Crichton-0/+87
This routine is currently only used to clean up the timer helper thread in the libnative implementation, but there are possibly other uses for this. The documentation is clear that the procedures are *not* run with any task context and hence have very little available to them. I also opted to disallow at_exit inside of at_exit and just abort the process at that point.
2014-01-22Replace C types with Rust types in libstd, closes #7313Florian Hahn-45/+40
2014-01-22auto merge of #11711 : alexcrichton/rust/issue-11683, r=brsonbors-4/+58
There's lots of fun rationale in the comments of the diff. Closes #11683
2014-01-21Purge borrowck from libstdAlex Crichton-231/+0
This hasn't been in use since `@mut` was removed
2014-01-21Flag all TLS functions as inline(never)Alex Crichton-4/+58
There's lots of fun rationale in the comments of the diff. Closes #11683
2014-01-19auto merge of #11635 : thestinger/rust/zero-size-alloc, r=alexcrichtonbors-12/+25
The `malloc` family of functions may return a null pointer for a zero-size allocation, which should not be interpreted as an out-of-memory error. If the implementation does not return a null pointer, then handling this will result in memory savings for zero-size types. This also switches some code to `malloc_raw` in order to maintain a centralized point for handling out-of-memory in `rt::global_heap`. Closes #11634
2014-01-18Rename iterators for consistencyPalmer Cox-4/+4
Rename existing iterators to get rid of the Iterator suffix and to give them names that better describe the things being iterated over.
2014-01-17handle zero-size allocations correctlyDaniel Micay-12/+25
The `malloc` family of functions may return a null pointer for a zero-size allocation, which should not be interpreted as an out-of-memory error. If the implementation does not return a null pointer, then handling this will result in memory savings for zero-size types. This also switches some code to `malloc_raw` in order to maintain a centralized point for handling out-of-memory in `rt::global_heap`. Closes #11634
2014-01-17auto merge of #11585 : nikomatsakis/rust/issue-3511-rvalue-lifetimes, r=pcwaltonbors-9/+9
Major changes: - Define temporary scopes in a syntax-based way that basically defaults to the innermost statement or conditional block, except for in a `let` initializer, where we default to the innermost block. Rules are documented in the code, but not in the manual (yet). See new test run-pass/cleanup-value-scopes.rs for examples. - Refactors Datum to better define cleanup roles. - Refactor cleanup scopes to not be tied to basic blocks, permitting us to have a very large number of scopes (one per AST node). - Introduce nascent documentation in trans/doc.rs covering datums and cleanup in a more comprehensive way. r? @pcwalton
2014-01-16Fix some docs in std::rt::taskDerek Chiang-7/+6
2014-01-15Issue #3511 - Rationalize temporary lifetimes.Niko Matsakis-9/+9
Major changes: - Define temporary scopes in a syntax-based way that basically defaults to the innermost statement or conditional block, except for in a `let` initializer, where we default to the innermost block. Rules are documented in the code, but not in the manual (yet). See new test run-pass/cleanup-value-scopes.rs for examples. - Refactors Datum to better define cleanup roles. - Refactor cleanup scopes to not be tied to basic blocks, permitting us to have a very large number of scopes (one per AST node). - Introduce nascent documentation in trans/doc.rs covering datums and cleanup in a more comprehensive way.
2014-01-15auto merge of #11550 : alexcrichton/rust/noinline, r=thestingerbors-0/+2
The failure functions are generic, meaning they're candidates for getting inlined across crates. This has been happening, leading to monstrosities like that found in #11549. I have verified that the codegen is *much* better now that we're not inlining the failure path (the slow path).
2014-01-15libstd: Added more #[inline] annotations and replaced uses of `libc::abort` ↵Eduard Burtescu-6/+18
with the intrinsic.
2014-01-14Flag failure functions as inline(never)Alex Crichton-0/+2
The failure functions are generic, meaning they're candidates for getting inlined across crates. This has been happening, leading to monstrosities like that found in #11549. I have verified that the codegen is *much* better now that we're not inlining the failure path (the slow path).
2014-01-09auto merge of #11360 : huonw/rust/stack_bounds, r=alexcrichtonbors-2/+3
We just approximate with a 2MB stack for native::start.
2014-01-07Fixup the rest of the tests in the compilerAlex Crichton-2/+1
2014-01-07stdtest: Fix all leaked trait importsAlex Crichton-10/+4
2014-01-07Fix remaining cases of leaking importsAlex Crichton-0/+2
2014-01-07std: Fill in all missing importsAlex Crichton-7/+20
Fallout from the previous commits
2014-01-07auto merge of #11353 : alexcrichton/rust/improve-logging, r=brsonbors-88/+102
This will allow capturing of common things like logging messages, stdout prints (using stdio println), and failure messages (printed to stderr). Any new prints added to libstd should be funneled through these task handles to allow capture as well. Additionally, this commit redirects logging back through a `Logger` trait so the log level can be usefully consumed by an arbitrary logger. This commit also introduces methods to set the task-local stdout handles: * std::io::stdio::set_stdout * std::io::stdio::set_stderr * std::io::logging::set_logger These methods all return the previous logger just in case it needs to be used for inspection. I plan on using this infrastructure for extra::test soon, but we don't quite have the primitives that I'd like to use for it, so it doesn't migrate extra::test at this time. Closes #6369
2014-01-07auto merge of #11348 : alexcrichton/rust/snapshots, r=brsonbors-3/+0
2014-01-07auto merge of #11329 : fhahn/rust/unused-cast-lint2, r=alexcrichtonbors-1/+1
Updates as mentioned in #11135
2014-01-07std::rt: require known stack bounds for all tasks.Huon Wilson-2/+3
We just approximate with a 1 or 2 MB stack for native::start.
2014-01-06Support arbitrary stdout/stderr/logger handlesAlex Crichton-88/+102
This will allow capturing of common things like logging messages, stdout prints (using stdio println), and failure messages (printed to stderr). Any new prints added to libstd should be funneled through these task handles to allow capture as well. Additionally, this commit redirects logging back through a `Logger` trait so the log level can be usefully consumed by an arbitrary logger. This commit also introduces methods to set the task-local stdout handles: * std::io::stdio::set_stdout * std::io::stdio::set_stderr * std::io::logging::set_logger These methods all return the previous logger just in case it needs to be used for inspection. I plan on using this infrastructure for extra::test soon, but we don't quite have the primitives that I'd like to use for it, so it doesn't migrate extra::test at this time. Closes #6369
2014-01-06Remove some unnecessary type castsFlorian Hahn-1/+1
Conflicts: src/librustc/middle/lint.rs
2014-01-06Register new snapshotsAlex Crichton-3/+0
2014-01-06auto merge of #11333 : cmr/rust/triage2, r=alexcrichtonbors-1/+0
2014-01-05Fix some warningsCorey Richardson-1/+0
2014-01-06Revert "std: adjust requested stack size for thread-local storage."Huon Wilson-19/+1
This reverts commit f1b5f59287106fc511d29c425255bd343608065c. Using a private function of a library is a bad idea: several people (on Linux) were meeting with linking errors because of it (different/older versions of glibc).
2014-01-04Condition EH ABI on target_arch, not target_os.Vadim Chugunov-6/+12
More precise unwinder private data size specification.
2014-01-04auto merge of #11188 : brson/rust/noderef, r=brsonbors-2/+6
This removes the feature where newtype structs can be dereferenced like pointers, and likewise where certain enums can be dereferenced (which I imagine nobody realized still existed). This ad-hoc behavior is to be replaced by a more general overloadable dereference trait in the future. I've been nursing this patch for two months and think it's about rebased up to master. @nikomatsakis this makes a bunch of your type checking code noticeably uglier.
2014-01-04Don't allow newtype structs to be dereferenced. #6246Brian Anderson-2/+6
2014-01-04auto merge of #11284 : huonw/rust/issue-6233, r=alexcrichtonbors-1/+19
If there is a lot of data in thread-local storage some implementations of pthreads (e.g. glibc) fail if you don't request a stack large enough -- by adjusting for the minimum size we guarantee that our stacks are always large enough. Issue #6233.
2014-01-04auto merge of #11301 : vadimcn/rust/fix-android, r=brsonbors-46/+113
This fixes stack unwinding on targets using ARM EHABI. closes #11147
2014-01-04auto merge of #11306 : alexcrichton/rust/native-bounds, r=pcwaltonbors-0/+8
This allows inspection of the current task's bounds regardless of what the underlying task is. Closes #11293
2014-01-04auto merge of #11283 : brson/rust/doublefailure, r=alexcrichtonbors-1/+7
Previously this was an `rtabort!`, indicating a runtime bug. Promote this to a more intentional abort and print a (slightly) more informative error message. Can't test this sense our test suite can't handle an abort exit. I consider this to close #910, and that we should open another issue about implementing less conservative semantics here.
2014-01-04Add a stack_bounds function to the Runtime traitAlex Crichton-0/+8
This allows inspection of the current task's bounds regardless of what the underlying task is. Closes #11293
2014-01-03Fix ARM unwinding.Vadim Chugunov-46/+113
2014-01-04std: adjust requested stack size for thread-local storage.Huon Wilson-1/+19
If there is a lot of data in thread-local storage some implementations of pthreads (e.g. glibc) fail if you don't request a stack large enough -- by adjusting for the minimum size we guarantee that our stacks are always large enough. Issue #6233.
2014-01-03libstd: De-`@mut` the `heap_cycles` testPatrick Walton-4/+8
2014-01-02Abort on double-failure. #910Brian Anderson-1/+7
Previously this was an rtabort!, indicating a runtime bug. Promote this to a more intentional abort and print a (slightly) more informative error message. Can't test this sense our test suite can't handle an abort exit.
2014-01-01auto merge of #11212 : alexcrichton/rust/local-task-count, r=brsonbors-37/+59
For libgreen, bookeeping should not be global but rather on a per-pool basis. Inside libnative, it's known that there must be a global counter with a mutex/cvar. The benefit of taking this strategy is to remove this functionality from libstd to allow fine-grained control of it through libnative/libgreen. Notably, helper threads in libnative can manually decrement the global count so they don't count towards the global count of threads. Also, the shutdown process of *all* sched pools is now dependent on the number of tasks in the pool being 0 rather than this only being a hardcoded solution for the initial sched pool in libgreen. This involved adding a Local::try_take() method on the Local trait in order for the channel wakeup to work inside of libgreen. The channel send was happening from a SchedTask when there is no Task available in TLS, and now this is possible to work (remote wakeups are always possible, just a little slower).
2014-01-01Move task count bookeeping out of libstdAlex Crichton-37/+59
For libgreen, bookeeping should not be global but rather on a per-pool basis. Inside libnative, it's known that there must be a global counter with a mutex/cvar. The benefit of taking this strategy is to remove this functionality from libstd to allow fine-grained control of it through libnative/libgreen. Notably, helper threads in libnative can manually decrement the global count so they don't count towards the global count of threads. Also, the shutdown process of *all* sched pools is now dependent on the number of tasks in the pool being 0 rather than this only being a hardcoded solution for the initial sched pool in libgreen. This involved adding a Local::try_take() method on the Local trait in order for the channel wakeup to work inside of libgreen. The channel send was happening from a SchedTask when there is no Task available in TLS, and now this is possible to work (remote wakeups are always possible, just a little slower).
2013-12-31auto merge of #11187 : alexcrichton/rust/once, r=brsonbors-12/+2
Rationale can be found in the first commit, but this is basically the same thing as `pthread_once`
2013-12-31Convert relevant static mutexes to OnceAlex Crichton-12/+2
2013-12-31auto merge of #11236 : huonw/rust/sort-rust-log-help, r=sanxiynbors-2/+9
Fixes #8949.