-
Notifications
You must be signed in to change notification settings - Fork 646
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix examples so they correctly set the stack pointer on thread startup
For pthreads this is configured in wasi-libc, but since we don't use pthreads here, we have to do it explicitly. The wasi_thread_start code is implemented in wasm to make sure there's no stack operations before the stack pointer is set to a correct value.
- Loading branch information
Showing
4 changed files
with
70 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
.globaltype __stack_pointer, i32 | ||
.functype __wasi_thread_start_C (i32, i32) -> () | ||
|
||
.globl wasi_thread_start | ||
|
||
wasi_thread_start: | ||
.functype wasi_thread_start (i32, i32) -> () | ||
|
||
# Set up the minimum C environment. | ||
# Note: offsetof(start_arg, stack) == 0 | ||
local.get 1 # start_arg | ||
i32.load 0 # stack | ||
global.set __stack_pointer | ||
|
||
# Make the C function do the rest of work. | ||
local.get 0 # tid | ||
local.get 1 # start_arg | ||
call __wasi_thread_start_C | ||
|
||
end_function |