[PATCH] D64537: [WebAssembly] Implement thread-local storage (local-exec model)

Guanzhong Chen via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 15 15:45:26 PDT 2019


quantum added a comment.

In D64537#1586577 <https://reviews.llvm.org/D64537#1586577>, @dschuff wrote:

> Another high-level question (based just on reading the CL description): The TLS-size intrinsic is per-function, does that mean that the tls-init function is called for every function? are there just multiple TLS sections per object file?


The TLS-size intrinsic returns the total size of TLS for the module it's called from. The initialization function initializes the TLS for the entire module.

In D64537#1586556 <https://reviews.llvm.org/D64537#1586556>, @dschuff wrote:

> The `offset` field of a segment can be a constant expression <https://webassembly.github.io/spec/core/valid/instructions.html#constant-expressions> which can be a `global.get` of an imported global. So we could have an imported global `__tls_base` which is different for each thread, and have an active segment with that as its segment offset?


I didn't know that it could have been a constant expression. I don't think this would have worked very well on the main thread though, since we need to run `malloc` before we can compute `__tls_base`. I think this requires the global to be mutable, if only because we need to be able to initialize it on the main thread.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64537/new/

https://reviews.llvm.org/D64537





More information about the cfe-commits mailing list