Replies: 4 comments 19 replies
-
With @syg's scheme here (#4 (reply in thread)) we'd already need to thread the JS context through each function as an argument, so also making this the mechanism by which TIDs are propagated might be viable. @lukewagner and I also discussed a |
Beta Was this translation helpful? Give feedback.
-
One perhaps important consideration for this is that the linear-memory shadow-stack pointer, currently stored in a Mostly I wanted to say that while |
Beta Was this translation helpful? Give feedback.
-
Aren't all globals already thread-local unless explicitly marked as "shared" using the new "shared" attribute described in https://github.com/abrown/thread-spawn/blob/main/proposals/thread-spawn/Overview.md#shared-attributes? I assume I'm missing something here. |
Beta Was this translation helpful? Give feedback.
-
maybe the minimum approach is to have a convention to reserve a few parameters for all shared functions. a C compiler, or whatever entity which generates shared functions, can insert these "thread context" parameters automatically. how do you think? |
Beta Was this translation helpful? Give feedback.
-
In the TLS section, the overview claims that we can use a toolchain-generated TID to determine the TLS region in linear memory — this has a chicken and egg problem. If the toolchain generates a TID (or even if one is passed in to the thread start function), we either (a) need to thread that value through to all its uses as an extra function parameter or (b) need to find some thread-local place to put the value to use it later (e.g., a TID-indexed region in memory). The problem with (a) is that it is onerous for toolchains; please comment if you do not think so. But (b) is impossible: when we need to access TLS later to retrieve the TID, we don't have the TID available to find it. Thanks to @alexcrichton for pointing out this problem!
What to do? As we discussed this, several solutions came to mind:
thread.id
instruction (or import, depending on this discussionthread-local
attribute one could add to aglobal
(e.g.,(thread-local global $g (mut i32) (...))
or(global $g (thread-local mut i32) (...))
)(thread_local $g i32 (...))
)The result of this discussion should help us fix the TLS section as well as indicate in the TID section how one can access the TID values during execution.
Beta Was this translation helpful? Give feedback.
All reactions