-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
threads: implement init of TLS and stack pointer #342
Conversation
lol.. I'll have a look tomorrow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
#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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a merge conflict (with #339). Would you mind rebasing this?
libc-bottom-half/crt/crt1-command.c
Outdated
static void dummy_0() | ||
{ | ||
} | ||
weak_alias(dummy_0, __wasi_init_tp); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.