forked from bytecodealliance/wasm-tools
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add wast parsing support for threads proposal
Add support for the new `(thread ...)` and `(wait ...)` constructs added in the upstream threads proposal.
- Loading branch information
1 parent
a1d01ab
commit b318766
Showing
42 changed files
with
1,088 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
(module $Mem | ||
(memory (export "shared") 1 1 shared) | ||
) | ||
|
||
(thread $T1 (shared (module $Mem)) | ||
(register "mem" $Mem) | ||
(module | ||
(memory (import "mem" "shared") 1 10 shared) | ||
(func (export "run") | ||
(local i32) | ||
(i32.load (i32.const 4)) | ||
(local.set 0) | ||
(i32.store (i32.const 0) (i32.const 1)) | ||
|
||
;; store results for checking | ||
(i32.store (i32.const 24) (local.get 0)) | ||
) | ||
) | ||
(invoke "run") | ||
) | ||
|
||
(thread $T2 (shared (module $Mem)) | ||
(register "mem" $Mem) | ||
(module | ||
(memory (import "mem" "shared") 1 1 shared) | ||
(func (export "run") | ||
(local i32) | ||
(i32.load (i32.const 0)) | ||
(local.set 0) | ||
(i32.store (i32.const 4) (i32.const 1)) | ||
|
||
;; store results for checking | ||
(i32.store (i32.const 32) (local.get 0)) | ||
) | ||
) | ||
|
||
(invoke "run") | ||
) | ||
|
||
(wait $T1) | ||
(wait $T2) | ||
|
||
(module $Check | ||
(memory (import "mem" "shared") 1 1 shared) | ||
|
||
(func (export "check") (result i32) | ||
(local i32 i32) | ||
(i32.load (i32.const 24)) | ||
(local.set 0) | ||
(i32.load (i32.const 32)) | ||
(local.set 1) | ||
|
||
;; allowed results: (L_0 = 0 || L_0 = 1) && (L_1 = 0 || L_1 = 1) | ||
|
||
(i32.or (i32.eq (local.get 0) (i32.const 1)) (i32.eq (local.get 0) (i32.const 0))) | ||
(i32.or (i32.eq (local.get 1) (i32.const 1)) (i32.eq (local.get 0) (i32.const 0))) | ||
(i32.and) | ||
(return) | ||
) | ||
) | ||
|
||
(assert_return (invoke $Check "check") (i32.const 1)) |
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,64 @@ | ||
(module $Mem | ||
(memory (export "shared") 1 1 shared) | ||
) | ||
|
||
(thread $T1 (shared (module $Mem)) | ||
(register "mem" $Mem) | ||
(module | ||
(memory (import "mem" "shared") 1 10 shared) | ||
(func (export "run") | ||
(local i32) | ||
(i32.atomic.load (i32.const 4)) | ||
(local.set 0) | ||
(i32.atomic.store (i32.const 0) (i32.const 1)) | ||
|
||
;; store results for checking | ||
(i32.store (i32.const 24) (local.get 0)) | ||
) | ||
) | ||
(invoke "run") | ||
) | ||
|
||
(thread $T2 (shared (module $Mem)) | ||
(register "mem" $Mem) | ||
(module | ||
(memory (import "mem" "shared") 1 1 shared) | ||
(func (export "run") | ||
(local i32) | ||
(i32.atomic.load (i32.const 0)) | ||
(local.set 0) | ||
(i32.atomic.store (i32.const 4) (i32.const 1)) | ||
|
||
;; store results for checking | ||
(i32.store (i32.const 32) (local.get 0)) | ||
) | ||
) | ||
|
||
(invoke "run") | ||
) | ||
|
||
(wait $T1) | ||
(wait $T2) | ||
|
||
(module $Check | ||
(memory (import "mem" "shared") 1 1 shared) | ||
|
||
(func (export "check") (result i32) | ||
(local i32 i32) | ||
(i32.load (i32.const 24)) | ||
(local.set 0) | ||
(i32.load (i32.const 32)) | ||
(local.set 1) | ||
|
||
;; allowed results: (L_0 = 0 && L_1 = 0) || (L_0 = 0 && L_1 = 1) || (L_0 = 1 && L_1 = 0) | ||
|
||
(i32.and (i32.eq (local.get 0) (i32.const 0)) (i32.eq (local.get 1) (i32.const 0))) | ||
(i32.and (i32.eq (local.get 0) (i32.const 0)) (i32.eq (local.get 1) (i32.const 1))) | ||
(i32.and (i32.eq (local.get 0) (i32.const 1)) (i32.eq (local.get 1) (i32.const 0))) | ||
(i32.or) | ||
(i32.or) | ||
(return) | ||
) | ||
) | ||
|
||
(assert_return (invoke $Check "check") (i32.const 1)) |
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,59 @@ | ||
(module $Mem | ||
(memory (export "shared") 1 1 shared) | ||
) | ||
|
||
(thread $T1 (shared (module $Mem)) | ||
(register "mem" $Mem) | ||
(module | ||
(memory (import "mem" "shared") 1 10 shared) | ||
(func (export "run") | ||
(i32.store (i32.const 0) (i32.const 42)) | ||
(i32.store (i32.const 4) (i32.const 1)) | ||
) | ||
) | ||
(invoke "run") | ||
) | ||
|
||
(thread $T2 (shared (module $Mem)) | ||
(register "mem" $Mem) | ||
(module | ||
(memory (import "mem" "shared") 1 1 shared) | ||
(func (export "run") | ||
(local i32 i32) | ||
(i32.load (i32.const 4)) | ||
(local.set 0) | ||
(i32.load (i32.const 0)) | ||
(local.set 1) | ||
|
||
;; store results for checking | ||
(i32.store (i32.const 24) (local.get 0)) | ||
(i32.store (i32.const 32) (local.get 1)) | ||
) | ||
) | ||
|
||
(invoke "run") | ||
) | ||
|
||
(wait $T1) | ||
(wait $T2) | ||
|
||
(module $Check | ||
(memory (import "mem" "shared") 1 1 shared) | ||
|
||
(func (export "check") (result i32) | ||
(local i32 i32) | ||
(i32.load (i32.const 24)) | ||
(local.set 0) | ||
(i32.load (i32.const 32)) | ||
(local.set 1) | ||
|
||
;; allowed results: (L_0 = 0 || L_0 = 1) && (L_1 = 0 || L_1 = 42) | ||
|
||
(i32.or (i32.eq (local.get 0) (i32.const 1)) (i32.eq (local.get 0) (i32.const 0))) | ||
(i32.or (i32.eq (local.get 1) (i32.const 42)) (i32.eq (local.get 0) (i32.const 0))) | ||
(i32.and) | ||
(return) | ||
) | ||
) | ||
|
||
(assert_return (invoke $Check "check") (i32.const 1)) |
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,61 @@ | ||
(module $Mem | ||
(memory (export "shared") 1 1 shared) | ||
) | ||
|
||
(thread $T1 (shared (module $Mem)) | ||
(register "mem" $Mem) | ||
(module | ||
(memory (import "mem" "shared") 1 10 shared) | ||
(func (export "run") | ||
(i32.atomic.store (i32.const 0) (i32.const 42)) | ||
(i32.atomic.store (i32.const 4) (i32.const 1)) | ||
) | ||
) | ||
(invoke "run") | ||
) | ||
|
||
(thread $T2 (shared (module $Mem)) | ||
(register "mem" $Mem) | ||
(module | ||
(memory (import "mem" "shared") 1 1 shared) | ||
(func (export "run") | ||
(local i32 i32) | ||
(i32.atomic.load (i32.const 4)) | ||
(local.set 0) | ||
(i32.atomic.load (i32.const 0)) | ||
(local.set 1) | ||
|
||
;; store results for checking | ||
(i32.store (i32.const 24) (local.get 0)) | ||
(i32.store (i32.const 32) (local.get 1)) | ||
) | ||
) | ||
|
||
(invoke "run") | ||
) | ||
|
||
(wait $T1) | ||
(wait $T2) | ||
|
||
(module $Check | ||
(memory (import "mem" "shared") 1 1 shared) | ||
|
||
(func (export "check") (result i32) | ||
(local i32 i32) | ||
(i32.load (i32.const 24)) | ||
(local.set 0) | ||
(i32.load (i32.const 32)) | ||
(local.set 1) | ||
|
||
;; allowed results: (L_0 = 1 && L_1 = 42) || (L_0 = 0 && L_1 = 0) || (L_0 = 0 && L_1 = 42) | ||
|
||
(i32.and (i32.eq (local.get 0) (i32.const 1)) (i32.eq (local.get 1) (i32.const 42))) | ||
(i32.and (i32.eq (local.get 0) (i32.const 0)) (i32.eq (local.get 1) (i32.const 0))) | ||
(i32.and (i32.eq (local.get 0) (i32.const 0)) (i32.eq (local.get 1) (i32.const 42))) | ||
(i32.or) | ||
(i32.or) | ||
(return) | ||
) | ||
) | ||
|
||
(assert_return (invoke $Check "check") (i32.const 1)) |
Oops, something went wrong.