quantum added a comment.

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

> I had a reply that got eaten here, so I'm going to keep trolling you on your 
> CL since we don't have a design doc for this.
>  The `offset` field of a data segment initializer can be a `global.get` on an 
> imported global.  
> (https://webassembly.github.io/spec/core/valid/instructions.html#constant-expressions).
>  Since each thread is separately instantiated with separate JS, we could have 
> a global import like `__tls_base` which has a different value in each thread. 
> Then we wouldn't need to manually call the init code anywhere. Would there be 
> other advantages or disadvantages for that?


I already answered this one:

In D64537#1586614 <https://reviews.llvm.org/D64537#1586614>, @quantum wrote:

> 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.


The problem I found with the import approach is that the main thread cannot use 
`global.get` of an imported global to get the location of TLS, mainly because 
it needs to be `malloc`'d. To use `malloc`, the main thread needs to be 
initialized. This will result in a circular dependency.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D64537



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to