Skip to content

Commit 67c2b3f

Browse files
committed
Give names to some locals and params in wat
Also add some comments
1 parent 62781d3 commit 67c2b3f

7 files changed

+35
-6
lines changed

test/testsuite/wasi_threads_exit_main_block.wat

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
;; When the main thread calls proc_exit, it should terminate
22
;; a thread blocking in `memory.atomic.wait32` opecode.
3+
;;
4+
;; linear memory usage:
5+
;; 0: notify/wait
36

47
(module
58
(memory (export "memory") (import "foo" "bar") 1 1 shared)

test/testsuite/wasi_threads_exit_main_busy.wat

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
;; When the main thread calls proc_exit, it should terminate
22
;; a busy-looping thread.
3+
;;
4+
;; linear memory usage:
5+
;; 0: wait
36

47
(module
58
(memory (export "memory") (import "foo" "bar") 1 1 shared)

test/testsuite/wasi_threads_exit_main_wasi.wat

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
;; When the main thread calls proc_exit, it should terminate
22
;; a thread blocking in a WASI call. (poll_oneoff)
3+
;;
4+
;; linear memory usage:
5+
;; 0: wait
6+
;; 100: poll_oneoff subscription
7+
;; 200: poll_oneoff event
8+
;; 300: poll_oneoff return value
39

410
(module
511
(memory (export "memory") (import "foo" "bar") 1 1 shared)

test/testsuite/wasi_threads_exit_nonmain_block.wat

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
;; When a non-main thread calls proc_exit, it should terminate
22
;; the main thread blocking in `memory.atomic.wait32` opecode.
3+
;;
4+
;; linear memory usage:
5+
;; 0: wait
36

47
(module
58
(memory (export "memory") (import "foo" "bar") 1 1 shared)

test/testsuite/wasi_threads_exit_nonmain_busy.wat

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
;; When a non-main thread calls proc_exit, it should terminate
22
;; the main thread which is busy-looping.
3+
;;
4+
;; linear memory usage:
5+
;; 0: wait
36

47
(module
58
(memory (export "memory") (import "foo" "bar") 1 1 shared)

test/testsuite/wasi_threads_exit_nonmain_wasi.wat

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
;; When a non-main thread calls proc_exit, it should terminate
22
;; the main thread which is blocking in a WASI call. (poll_oneoff)
3+
;;
4+
;; linear memory usage:
5+
;; 0: wait
6+
;; 100: poll_oneoff subscription
7+
;; 200: poll_oneoff event
8+
;; 300: poll_oneoff return value
39

410
(module
511
(memory (export "memory") (import "foo" "bar") 1 1 shared)

test/testsuite/wasi_threads_spawn.wat

+11-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
;; Create a thread with thread-spawn and perform a few sanity checks.
22

3+
;; linear memory usage:
4+
;; 0: notify/wait
5+
;; 4: tid
6+
;; 8: user_arg
7+
38
(module
49
(memory (export "memory") (import "foo" "bar") 1 1 shared)
510
(func $thread_spawn (import "wasi" "thread_spawn") (param i32) (result i32))
611
(func $proc_exit (import "wasi_snapshot_preview1" "proc_exit") (param i32))
7-
(func (export "wasi_thread_start") (param i32 i32)
12+
(func (export "wasi_thread_start") (param $tid i32) (param $user_arg i32)
813
;; store tid
914
i32.const 4
10-
local.get 0
15+
local.get $tid
1116
i32.store
1217
;; store user pointer
1318
i32.const 8
14-
local.get 1
19+
local.get $user_arg
1520
i32.store
1621
;; notify the main
1722
i32.const 0
@@ -23,12 +28,12 @@
2328
drop
2429
;; returning from wasi_thread_start terminates only this thread
2530
)
26-
(func (export "_start") (local i32)
31+
(func (export "_start") (local $tid i32)
2732
;; spawn a thread
2833
i32.const 12345 ;; user pointer
2934
call $thread_spawn
3035
;; check error
31-
local.tee 0 ;; save the tid to check later
36+
local.tee $tid ;; save the tid to check later
3237
i32.const 0
3338
i32.le_s
3439
if
@@ -46,7 +51,7 @@
4651
unreachable
4752
end
4853
;; check the tid
49-
local.get 0
54+
local.get $tid
5055
i32.const 4
5156
i32.load
5257
i32.ne

0 commit comments

Comments
 (0)