threads: implement init of TLS and stack pointer#342
Conversation
|
lol.. I'll have a look tomorrow |
| #else | ||
| new_tls_base = __copy_tls(tsd - tls_size); | ||
| tls_offset = new_tls_base - tls_base; | ||
| new = (void*)((uintptr_t)self + tls_offset); |
There was a problem hiding this comment.
Nice trick to get the new __wasilibc_pthread_self pointer.
|
I like this implementation more, because of how it uses a trick to fill in the new The only thing missing is With some I also added more pthread funcs in this patch. |
|
updated the above comment with new patch links |
|
@12101111 please remove the last commit. That should go into a separate PR. |
|
@12101111 btw, I have a working wasmtime branch to try out threading. You have to compile your C source with Then you can run it with: |
|
Ok, in my testing I needed haraldh@be2151b for the stack to be properly aligned. |
|
@sunfishcode Could we get a review on this? |
sunfishcode
left a comment
There was a problem hiding this comment.
There's a merge conflict (with #339). Would you mind rebasing this?
| static void dummy_0() | ||
| { | ||
| } | ||
| weak_alias(dummy_0, __wasi_init_tp); |
There was a problem hiding this comment.
Instead of using a weak symbol, could you put this under #if defined(_REENTRANT) so that it isn't included in non-threaded builds?
Signed-off-by: Harald Hoyer <harald@profian.com>
Signed-off-by: Harald Hoyer <harald@profian.com>
Can't use `exit()` because it is too high level. Have to unlock the thread list. Signed-off-by: Harald Hoyer <harald@profian.com>
Signed-off-by: Harald Hoyer <harald@profian.com>
Signed-off-by: Harald Hoyer <harald@profian.com>
24143de to
e38063f
Compare
|
Looks good, thanks! |
* threads: implement init of TLS and stack pointer * fix: rename wasi_snapshot_preview2_thread_spawn to wasi_thread_spawn Signed-off-by: Harald Hoyer <harald@profian.com> * fix: change signature of wasi_thread_start Signed-off-by: Harald Hoyer <harald@profian.com> * fix: pthread_exit for WASI Can't use `exit()` because it is too high level. Have to unlock the thread list. Signed-off-by: Harald Hoyer <harald@profian.com> * fix: initialize struct pthread for the main thread Signed-off-by: Harald Hoyer <harald@profian.com> * fix: store the aligned stack minus `struct start_args` Signed-off-by: Harald Hoyer <harald@profian.com> Signed-off-by: Harald Hoyer <harald@profian.com> Co-authored-by: Harald Hoyer <harald@profian.com>
No description provided.