-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Move pthread TLS state native code using wasm globals #12839
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
.globaltype thread_id, i32 | ||
thread_id: | ||
|
||
.globaltype is_main_thread, i32 | ||
is_main_thread: | ||
|
||
.globaltype is_runtime_thread, i32 | ||
is_runtime_thread: | ||
|
||
.globl pthread_self | ||
pthread_self: | ||
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wait, so any function that is defined in And any functions defined in C/C++ files do not get a That is actually pretty backwards: in native compilers all assembly code is unprefixed, and all C/C++ code is prefixed with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The The actual compiler, llvm, does not emit the From the linker's POV there is no way to way to the difference between a C symbol and an assembler symbols. They are all just "native" sybmols and we mangle all of them when we import them into JS. One day we should completely remove the mangling... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I created an issue to remove this mangling completely one day: #12844 |
||
.functype pthread_self () -> (i32) | ||
global.get thread_id | ||
end_function | ||
|
||
.globl _emscripten_thread_init | ||
_emscripten_thread_init: | ||
.functype _emscripten_thread_init (i32, i32, i32) -> () | ||
local.get 0 | ||
global.set thread_id | ||
local.get 1 | ||
global.set is_main_thread | ||
local.get 2 | ||
global.set is_runtime_thread | ||
end_function | ||
|
||
# Semantically the same as testing "!ENVIRONMENT_IS_PTHREAD" in JS | ||
.globl emscripten_is_main_runtime_thread | ||
emscripten_is_main_runtime_thread: | ||
.functype emscripten_is_main_runtime_thread () -> (i32) | ||
global.get is_runtime_thread | ||
end_function | ||
|
||
# Semantically the same as testing "!ENVIRONMENT_IS_WORKER" in JS | ||
.globl emscripten_is_main_browser_thread | ||
emscripten_is_main_browser_thread: | ||
.functype emscripten_is_main_browser_thread () -> (i32) | ||
global.get is_main_thread | ||
end_function |
Uh oh!
There was an error while loading. Please reload this page.