about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-10-13 14:28:48 +0000
committerbors <bors@rust-lang.org>2018-10-13 14:28:48 +0000
commitf51752774bbbe48d2aabe53c86e9e91ed3a73a5d (patch)
tree2186eef6fcb94391c98c6c36efed30682fbba8fb /src/liballoc
parent24faa975895b548a2868491b1268076cc599151d (diff)
parentcbe9f33b8bb94b262f91bc8c6f61a7f6518164b4 (diff)
downloadrust-f51752774bbbe48d2aabe53c86e9e91ed3a73a5d.tar.gz
rust-f51752774bbbe48d2aabe53c86e9e91ed3a73a5d.zip
Auto merge of #54951 - alexcrichton:more-wasm-threads, r=sfackler
std: Implement TLS for wasm32-unknown-unknown

This adds an implementation of thread local storage for the
`wasm32-unknown-unknown` target when the `atomics` feature is
implemented. This, however, comes with a notable caveat of that it
requires a new feature of the standard library, `wasm-bindgen-threads`,
to be enabled.

Thread local storage for wasm (when `atomics` are enabled and there's
actually more than one thread) is powered by the assumption that an
external entity can fill in some information for us. It's not currently
clear who will fill in this information nor whose responsibility it
should be long-term. In the meantime there's a strategy being gamed out
in the `wasm-bindgen` project specifically, and the hope is that we can
continue to test and iterate on the standard library without committing
to a particular strategy yet.

As to the details of `wasm-bindgen`'s strategy, LLVM doesn't currently
have the ability to emit custom `global` values (thread locals in a
`WebAssembly.Module`) so we leverage the `wasm-bindgen` CLI tool to do
it for us. To that end we have a few intrinsics, assuming two global values:

* `__wbindgen_current_id` - gets the current thread id as a 32-bit
  integer. It's `wasm-bindgen`'s responsibility to initialize this
  per-thread and then inform libstd of the id. Currently `wasm-bindgen`
  performs this initialization as part of the `start` function.
* `__wbindgen_tcb_{get,set}` - in addition to a thread id it's assumed
  that there's a global available for simply storing a pointer's worth
  of information (a thread control block, which currently only contains
  thread local storage). This would ideally be a native `global`
  injected by LLVM, but we don't have a great way to support that right
  now.

To reiterate, this is all intended to be unstable and purely intended
for testing out Rust on the web with threads. The story is very likely
to change in the future and we want to make sure that we're able to do
that!
Diffstat (limited to 'src/liballoc')
0 files changed, 0 insertions, 0 deletions