Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
0fdf24b
actually test rustc-guide with toolstate
mark-i-m Jul 17, 2019
97b4156
don't fail builds for rustc-guide
mark-i-m Jul 17, 2019
8070bb8
Regressions ok for miri too
mark-i-m Jul 18, 2019
b2d05db
add a few comments for the toolstate stuff
RalfJung Jul 18, 2019
8b87162
Update src/ci/docker/x86_64-gnu-tools/checktools.sh
mark-i-m Jul 18, 2019
17c4084
Update src/ci/docker/x86_64-gnu-tools/checkregression.py
mark-i-m Jul 18, 2019
8940a27
embedded-book failures don't block beta
mark-i-m Jul 18, 2019
1aa1079
Update src/ci/docker/x86_64-gnu-tools/checkregression.py
mark-i-m Jul 18, 2019
9c48ed4
more comments for toolstate scripts
RalfJung Jul 23, 2019
92d432a
more callback docs
RalfJung Jul 23, 2019
82d1841
more comments
RalfJung Jul 23, 2019
11a3b74
add back check for update prs
mark-i-m Jul 23, 2019
c7a599e
bump crossbeam-epoch dependency
RalfJung Jul 25, 2019
a120caf
rustc: Update wasm32 support for LLVM 9
alexcrichton Jul 19, 2019
dc50a63
std: Use native `#[thread_local]` TLS on wasm
alexcrichton Jul 19, 2019
f7c75cc
Add 'ast::PatKind::Rest'.
Centril Jul 6, 2019
ff77ef2
Introduce 'ast::Pat::is_rest(&self) -> bool'.
Centril Jul 9, 2019
633c997
Adjust 'ast::PatKind::{TupleStruct,Tuple,Slice}'.
Centril Jul 9, 2019
12250a2
Adjust feature gating of subslice patterns accordingly.
Centril Jul 9, 2019
b02941f
Adjust pretty printing accordingly.
Centril Jul 9, 2019
8ba5f49
Adjust and document 'Pat::to_ty' accordingly.
Centril Jul 9, 2019
d5df1e0
Adjust lowering of Tuple/TupleStruct patterns.
Centril Jul 9, 2019
694b3c3
Adjust lowering of Slice patterns.
Centril Jul 9, 2019
0a40ef2
Cleanup parse_seq_* methods + record trailing separators.
Centril Jul 9, 2019
7aeb4b7
Add more parse_*_seq methods for code reuse.
Centril Jul 9, 2019
7e1b671
Cleanup using the new parse_*_seq methods.
Centril Jul 9, 2019
62b29a1
Adjust parsing of Slice, Tuple, TupleStruct patterns.
Centril Jul 9, 2019
974413f
Recover on '..X' / '..=X' / '...X' range patterns.
Centril Jul 9, 2019
2f55354
Recover on 'X..' / 'X..=' / 'X...' range patterns.
Centril Jul 9, 2019
2411134
Update tests wrt. recovery of range patterns.
Centril Jul 9, 2019
f6c8234
And also --bless those recovery tests.
Centril Jul 9, 2019
891a736
Test parsing and recovery of all sorts of range patterns.
Centril Jul 9, 2019
75da43d
Use new 'p @ ..' syntax in tests.
Centril Jul 7, 2019
91c8b53
--bless tests due to new subslice syntax.
Centril Jul 7, 2019
e725ea2
Intersection patterns 'p1 @ p2' are not supported.
Centril Jul 8, 2019
06e5ae5
Account for better recovery in two cases.
Centril Jul 9, 2019
e3cdadd
(pat, ..,) is now syntactically legal.
Centril Jul 8, 2019
7c0b1da
Win some lose some; Unfortunately we lost recovery in one case.
Centril Jul 8, 2019
cec8649
Update unstable book wrt. subslice patterns.
Centril Jul 10, 2019
984f9db
Adjust documentation in HAIR.
Centril Jul 10, 2019
1060513
Get out of bootstrapping pickle.
Centril Jul 10, 2019
acc6a6d
--bless tests after rebase.
Centril Jul 10, 2019
59b5dae
Update error_codes.rs with new subslice syntax.
Centril Jul 10, 2019
397a027
Use AstP more in lowering.
Centril Jul 11, 2019
becdba8
Address comments in lowering + parsing.
Centril Jul 24, 2019
5f4dd1d
Address comments re. off-topic errors.
Centril Jul 24, 2019
18ccd6a
Add exceptions for ExprKind::Err/TyKind::Error.
Centril Jul 24, 2019
8774207
And --bless tests accordingly for those exceptions.
Centril Jul 24, 2019
d33696f
borrowck-describe-lvalue: --bless --compare-mode=nll.
Centril Jul 28, 2019
ef2d8c9
Rollup merge of #62550 - Centril:rest-patterns, r=petrochenkov
Centril Jul 28, 2019
56c83c3
Rollup merge of #62759 - mark-i-m:rustc-guide-toolstate-check, r=kennytm
Centril Jul 28, 2019
e5e4c41
Rollup merge of #62809 - alexcrichton:wasm-llvm-9, r=nikic
Centril Jul 28, 2019
11d0be7
Rollup merge of #62974 - RalfJung:crossbeam, r=alexcrichton
Centril Jul 28, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
std: Use native #[thread_local] TLS on wasm
This commit moves `thread_local!` on WebAssembly targets to using the
`#[thread_local]` attribute in LLVM. This was recently implemented
upstream and is [in the process of being documented][dox]. This change
only takes affect if modules are compiled with `+atomics` which is
currently unstable and a pretty esoteric method of compiling wasm
artifacts.

This "new power" of the wasm toolchain means that the old
`wasm-bindgen-threads` feature of the standard library can be removed
since it should now be possible to create a fully functioning threaded
wasm module without intrusively dealing with libstd symbols or
intrinsics. Yay!

[dox]: WebAssembly/tool-conventions#116
  • Loading branch information
alexcrichton committed Jul 25, 2019
commit dc50a633f3260a3aeb79a4ca9800587be7f732e7
7 changes: 7 additions & 0 deletions src/librustc_codegen_ssa/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,9 @@ impl<'a> WasmLd<'a> {
// linker will synthesize this function, and so we need to make sure
// that our usage of `--export` below won't accidentally cause this
// function to get deleted.
//
// * `--export=*tls*` - when `#[thread_local]` symbols are used these
// symbols are how the TLS segments are initialized and configured.
let atomics = sess.opts.cg.target_feature.contains("+atomics") ||
sess.target.target.options.features.contains("+atomics");
if atomics {
Expand All @@ -912,6 +915,10 @@ impl<'a> WasmLd<'a> {
cmd.arg("--import-memory");
cmd.arg("--passive-segments");
cmd.arg("--export=__wasm_init_memory");
cmd.arg("--export=__wasm_init_tls");
cmd.arg("--export=__tls_size");
cmd.arg("--export=__tls_align");
cmd.arg("--export=__tls_base");
}
WasmLd { cmd, sess, info }
}
Expand Down
8 changes: 8 additions & 0 deletions src/librustc_target/spec/wasm32_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ pub fn options() -> TargetOptions {
// non-relative calls and such later on).
relocation_model: "static".to_string(),

// When the atomics feature is activated then these two keys matter,
// otherwise they're basically ignored by the standard library. In this
// mode, however, the `#[thread_local]` attribute works (i.e.
// `has_elf_tls`) and we need to get it to work by specifying
// `local-exec` as that's all that's implemented in LLVM today for wasm.
has_elf_tls: true,
tls_model: "local-exec".to_string(),

.. Default::default()
}
}
5 changes: 0 additions & 5 deletions src/libstd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@ panic_immediate_abort = ["core/panic_immediate_abort"]
# requires rebuilding the standard library to use it.
wasm_syscall = []

# An off-by-default features to enable libstd to assume that wasm-bindgen is in
# the environment for hooking up some thread-related information like the
# current thread id and accessing/getting the current thread's TCB
wasm-bindgen-threads = []

# Enable std_detect default features for stdarch/crates/std_detect:
# https://github.com/rust-lang/stdarch/blob/master/crates/std_detect/Cargo.toml
std_detect_file_io = []
Expand Down
2 changes: 2 additions & 0 deletions src/libstd/sys/wasi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ pub mod stdio;
pub mod thread;
#[path = "../wasm/thread_local.rs"]
pub mod thread_local;
#[path = "../wasm/fast_thread_local.rs"]
pub mod fast_thread_local;
pub mod time;
pub mod ext;

Expand Down
9 changes: 9 additions & 0 deletions src/libstd/sys/wasm/fast_thread_local.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#![unstable(feature = "thread_local_internals", issue = "0")]

pub unsafe fn register_dtor(_t: *mut u8, _dtor: unsafe extern fn(*mut u8)) {
// FIXME: right now there is no concept of "thread exit", but this is likely
// going to show up at some point in the form of an exported symbol that the
// wasm runtime is oging to be expected to call. For now we basically just
// ignore the arguments, but if such a function starts to exist it will
// likely look like the OSX implementation in `unix/fast_thread_local.rs`
}
5 changes: 2 additions & 3 deletions src/libstd/sys/wasm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ pub mod stack_overflow;
pub mod thread;
pub mod time;
pub mod stdio;
pub mod thread_local;
pub mod fast_thread_local;

pub use crate::sys_common::os_str_bytes as os_str;

Expand All @@ -48,13 +50,10 @@ cfg_if::cfg_if! {
pub mod mutex;
#[path = "rwlock_atomics.rs"]
pub mod rwlock;
#[path = "thread_local_atomics.rs"]
pub mod thread_local;
} else {
pub mod condvar;
pub mod mutex;
pub mod rwlock;
pub mod thread_local;
}
}

Expand Down
76 changes: 34 additions & 42 deletions src/libstd/sys/wasm/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,48 +59,40 @@ pub mod guard {
pub unsafe fn init() -> Option<Guard> { None }
}

cfg_if::cfg_if! {
if #[cfg(all(target_feature = "atomics", feature = "wasm-bindgen-threads"))] {
#[link(wasm_import_module = "__wbindgen_thread_xform__")]
extern {
fn __wbindgen_current_id() -> u32;
fn __wbindgen_tcb_get() -> u32;
fn __wbindgen_tcb_set(ptr: u32);
// This is only used by atomics primitives when the `atomics` feature is
// enabled. In that mode we currently just use our own thread-local to store our
// current thread's ID, and then we lazily initialize it to something allocated
// from a global counter.
#[cfg(target_feature = "atomics")]
pub fn my_id() -> u32 {
use crate::sync::atomic::{AtomicU32, Ordering::SeqCst};

static NEXT_ID: AtomicU32 = AtomicU32::new(0);

#[thread_local]
static mut MY_ID: u32 = 0;

unsafe {
// If our thread ID isn't set yet then we need to allocate one. Do so
// with with a simple "atomically add to a global counter" strategy.
// This strategy doesn't handled what happens when the counter
// overflows, however, so just abort everything once the counter
// overflows and eventually we could have some sort of recycling scheme
// (or maybe this is all totally irrelevant by that point!). In any case
// though we're using a CAS loop instead of a `fetch_add` to ensure that
// the global counter never overflows.
if MY_ID == 0 {
let mut cur = NEXT_ID.load(SeqCst);
MY_ID = loop {
let next = cur.checked_add(1).unwrap_or_else(|| {
crate::arch::wasm32::unreachable()
});
match NEXT_ID.compare_exchange(cur, next, SeqCst, SeqCst) {
Ok(_) => break next,
Err(i) => cur = i,
}
};
}
pub fn my_id() -> u32 {
unsafe { __wbindgen_current_id() }
}

// These are currently only ever used in `thread_local_atomics.rs`, if
// you'd like to use them be sure to update that and make sure everyone
// agrees what's what.
pub fn tcb_get() -> *mut u8 {
use crate::mem;
assert_eq!(mem::size_of::<*mut u8>(), mem::size_of::<u32>());
unsafe { __wbindgen_tcb_get() as *mut u8 }
}

pub fn tcb_set(ptr: *mut u8) {
unsafe { __wbindgen_tcb_set(ptr as u32); }
}

// FIXME: still need something for hooking exiting a thread to free
// data...

} else if #[cfg(target_feature = "atomics")] {
pub fn my_id() -> u32 {
panic!("thread ids not implemented on wasm with atomics yet")
}

pub fn tcb_get() -> *mut u8 {
panic!("thread local data not implemented on wasm with atomics yet")
}

pub fn tcb_set(_ptr: *mut u8) {
panic!("thread local data not implemented on wasm with atomics yet")
}
} else {
// stubbed out because no functions actually access these intrinsics
// unless atomics are enabled
MY_ID
}
}
32 changes: 9 additions & 23 deletions src/libstd/sys/wasm/thread_local.rs
Original file line number Diff line number Diff line change
@@ -1,40 +1,26 @@
use crate::boxed::Box;
use crate::ptr;

pub type Key = usize;

struct Allocated {
value: *mut u8,
dtor: Option<unsafe extern fn(*mut u8)>,
}

#[inline]
pub unsafe fn create(dtor: Option<unsafe extern fn(*mut u8)>) -> Key {
Box::into_raw(Box::new(Allocated {
value: ptr::null_mut(),
dtor,
})) as usize
pub unsafe fn create(_dtor: Option<unsafe extern fn(*mut u8)>) -> Key {
panic!("should not be used on the wasm target");
}

#[inline]
pub unsafe fn set(key: Key, value: *mut u8) {
(*(key as *mut Allocated)).value = value;
pub unsafe fn set(_key: Key, _value: *mut u8) {
panic!("should not be used on the wasm target");
}

#[inline]
pub unsafe fn get(key: Key) -> *mut u8 {
(*(key as *mut Allocated)).value
pub unsafe fn get(_key: Key) -> *mut u8 {
panic!("should not be used on the wasm target");
}

#[inline]
pub unsafe fn destroy(key: Key) {
let key = Box::from_raw(key as *mut Allocated);
if let Some(f) = key.dtor {
f(key.value);
}
pub unsafe fn destroy(_key: Key) {
panic!("should not be used on the wasm target");
}

#[inline]
pub fn requires_synchronized_create() -> bool {
false
panic!("should not be used on the wasm target");
}
61 changes: 0 additions & 61 deletions src/libstd/sys/wasm/thread_local_atomics.rs

This file was deleted.

2 changes: 1 addition & 1 deletion src/llvm-project
Submodule llvm-project updated 1288 files