Commit Graph

2255 Commits

Author SHA1 Message Date
Ralf Jung
ba670d6970 make sure macos function has 'macos' in its name 2020-04-30 19:38:17 +02:00
bors
351d46d3fb Auto merge of #1284 - vakaras:add-threads-cr2, r=RalfJung
Implement basic support for concurrency (Linux/macos only)

Changes  (most new code is in `src/threads.rs` and `src/shims/foreign_items/posix.rs`):

1. Move the stack from `Machine` to a newly created `Thread` struct.
2. Add a `ThreadSet` struct that manages the threads.
3. Change `canonical_alloc_id` to create a unique allocation id for each thread local and thread (the responsible struct is `ThreadLocalStorage`)
4. Change the code to execute the thread local destructors immediately when a thread terminates.
5. Add the most basic round-robin scheduler.

This pull request depends on [these changes to the compiler](https://github.com/rust-lang/rust/pull/70598).
2020-04-30 16:21:43 +00:00
Vytautas Astrauskas
48da0cf489 Fix prctl SET_NAME and GET_NAME behaviour. 2020-04-30 08:35:59 -07:00
Ralf Jung
e9212d14ac more helpful error on workspaces 2020-04-30 10:19:34 +02:00
Vytautas Astrauskas
603ec0b3d8 Fix a regression in Windows dtors. 2020-04-29 15:20:26 -07:00
Vytautas Astrauskas
0e052ab897 Use Entry API in set_dtors_running. 2020-04-29 15:12:09 -07:00
Vytautas Astrauskas
46b03174d0 Improve code readability and comments. 2020-04-29 13:16:22 -07:00
Ralf Jung
a5445e0230 rustup for more LocalDefId changes 2020-04-28 10:30:21 +02:00
Vytautas Astrauskas
3b5854191c Fix MacOS and Windows builds. 2020-04-27 15:21:01 -07:00
Vytautas Astrauskas
1355574beb Delete remaining tls entries after all destructors completed. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
df2ca53b69 Make From implementations non-failing. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
c56ef31780 Improve comments. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
f204b67b0f Merge dtors_running and last_dtor_key fields. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
356aecce7f Add a FIXME. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
207c6e7fa7 Improve comments and code clarity. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
9ba3ef2a44 Change representation and conversion of ThreadId and BlockSetId. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
174adad2b3 Use DLL_THREAD_DETACH when calling windows TLS destructor. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
d9e18ada39 Make sure to remove thread local data only if we have destructor. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
911ff7eade Improve style and comments. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
c4574dde8d Many small changes to clean up code. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
6842eb2b84 Rename global tls dtor to thread dtor. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
64164b10e8 Improve comments. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
bc9d007e3e Improve Debug formatting of the thread name. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
04abf066f1 Move copying of the thread name to the client side. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
feb188360e Unify TLS dtors; move stepping outside. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
d45e985669 Clarify FIXME. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
8a7dbde372 Check prctl argument types and fix the test. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
e7c2694b8b Make the main thread detached. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
69eaaadc28 Fix merge error. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
452e36efb3 Print the thread name in Debug. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
3bb1657448 Small style fix. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
9a01c3fa3e Clarify comments about TLS destructor handling in Windows, add a test for TLS destructors. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
e4dc3567f8 Track if a thread was already joined. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
17f7bc86ae Fix how a pthread_create function argument is constructed. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
94cbe88e80 Many small changes to thread management. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
75e6549c11 Improve prctl, add a test. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
eab38dfe00 Change the warning message. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
69df2e19de Move prctl to Linux specific shims. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
d6c03926ab Rename MacOS set global dtor function. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
421be273cc Add concurrency tests. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
46fd333daa Implement thread::yield_now. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
134533d066 Add a comment explaining global destructors on MacOS. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
d062f63519 Fix support for MacOS. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
44e9305599 Rename threads to thread to match the Rust standard library. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
a585dc8289 Add a missing newline. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
688cacbdd7 Cleanup the implementation of adjust_global_const. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
1d0eb93ebd Fix typo in a comment. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
94118d4d9a Make an assert message consistent with other asserts. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
552080a5b7 Fix imports. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
4609c3c520 Rename eval_maybe_thread_local_static_const to adjust_global_const. 2020-04-27 14:26:36 -07:00