Skip to content

Commit

Permalink
[Test] Fix the atomic tests in threads proposal.
Browse files Browse the repository at this point in the history
Please refer to this issue:
WebAssembly/threads#195

Signed-off-by: YiYing He <yiying@secondstate.io>
  • Loading branch information
q82419 committed Nov 18, 2022
1 parent 30064c7 commit 4034d2b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

* `core/select/select.wast` line 325: `invalid result arity` -> `type mismatch`
* This error message is for the WAT format, WASM format cannot detect this error by the bytecode.
* `threads/atomic/atomic.wast`: divergence behavior
* Please check [this issue](https://github.com/WebAssembly/threads/issues/195).
* Modified the `wast` file for fitting the `compare_exchange_strong` behavior in C++.

## Branches And Tags

Expand Down Expand Up @@ -43,3 +46,4 @@
* `wasm-ref-types`: The test suite for the bulk-memory-operations and reference-types proposals.
* `wasm-1.1`: The test suite for the WASM 1.1.
* `wasm-1.0`: The test suite for the WASM 1.0.

10 changes: 5 additions & 5 deletions threads/atomic/atomic.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,31 +167,31 @@
{"type": "assert_return", "line": 323, "action": {"type": "invoke", "field": "i64.atomic.load", "args": [{"type": "i32", "value": "0"}]}, "expected": [{"type": "i64", "value": "1229782938247303441"}]},
{"type": "action", "line": 325, "action": {"type": "invoke", "field": "init", "args": [{"type": "i64", "value": "1229782938247303441"}]}, "expected": []},
{"type": "assert_return", "line": 326, "action": {"type": "invoke", "field": "i32.atomic.rmw8.cmpxchg_u", "args": [{"type": "i32", "value": "0"}, {"type": "i32", "value": "286331153"}, {"type": "i32", "value": "3452816845"}]}, "expected": [{"type": "i32", "value": "17"}]},
{"type": "assert_return", "line": 327, "action": {"type": "invoke", "field": "i64.atomic.load", "args": [{"type": "i32", "value": "0"}]}, "expected": [{"type": "i64", "value": "1229782938247303441"}]},
{"type": "assert_return", "line": 327, "action": {"type": "invoke", "field": "i64.atomic.load", "args": [{"type": "i32", "value": "0"}]}, "expected": [{"type": "i64", "value": "1229782938247303629"}]},
{"type": "action", "line": 329, "action": {"type": "invoke", "field": "init", "args": [{"type": "i64", "value": "1229782938247303441"}]}, "expected": []},
{"type": "assert_return", "line": 330, "action": {"type": "invoke", "field": "i32.atomic.rmw16.cmpxchg_u", "args": [{"type": "i32", "value": "0"}, {"type": "i32", "value": "0"}, {"type": "i32", "value": "3405695742"}]}, "expected": [{"type": "i32", "value": "4369"}]},
{"type": "assert_return", "line": 331, "action": {"type": "invoke", "field": "i64.atomic.load", "args": [{"type": "i32", "value": "0"}]}, "expected": [{"type": "i64", "value": "1229782938247303441"}]},
{"type": "action", "line": 333, "action": {"type": "invoke", "field": "init", "args": [{"type": "i64", "value": "1229782938247303441"}]}, "expected": []},
{"type": "assert_return", "line": 334, "action": {"type": "invoke", "field": "i32.atomic.rmw16.cmpxchg_u", "args": [{"type": "i32", "value": "0"}, {"type": "i32", "value": "286331153"}, {"type": "i32", "value": "3405695742"}]}, "expected": [{"type": "i32", "value": "4369"}]},
{"type": "assert_return", "line": 335, "action": {"type": "invoke", "field": "i64.atomic.load", "args": [{"type": "i32", "value": "0"}]}, "expected": [{"type": "i64", "value": "1229782938247303441"}]},
{"type": "assert_return", "line": 335, "action": {"type": "invoke", "field": "i64.atomic.load", "args": [{"type": "i32", "value": "0"}]}, "expected": [{"type": "i64", "value": "1229782938247351038"}]},
{"type": "action", "line": 337, "action": {"type": "invoke", "field": "init", "args": [{"type": "i64", "value": "1229782938247303441"}]}, "expected": []},
{"type": "assert_return", "line": 338, "action": {"type": "invoke", "field": "i64.atomic.rmw8.cmpxchg_u", "args": [{"type": "i32", "value": "0"}, {"type": "i64", "value": "0"}, {"type": "i64", "value": "4774451407313060418"}]}, "expected": [{"type": "i64", "value": "17"}]},
{"type": "assert_return", "line": 339, "action": {"type": "invoke", "field": "i64.atomic.load", "args": [{"type": "i32", "value": "0"}]}, "expected": [{"type": "i64", "value": "1229782938247303441"}]},
{"type": "action", "line": 341, "action": {"type": "invoke", "field": "init", "args": [{"type": "i64", "value": "1229782938247303441"}]}, "expected": []},
{"type": "assert_return", "line": 342, "action": {"type": "invoke", "field": "i64.atomic.rmw8.cmpxchg_u", "args": [{"type": "i32", "value": "0"}, {"type": "i64", "value": "1229782938247303441"}, {"type": "i64", "value": "4774451407313060418"}]}, "expected": [{"type": "i64", "value": "17"}]},
{"type": "assert_return", "line": 343, "action": {"type": "invoke", "field": "i64.atomic.load", "args": [{"type": "i32", "value": "0"}]}, "expected": [{"type": "i64", "value": "1229782938247303441"}]},
{"type": "assert_return", "line": 343, "action": {"type": "invoke", "field": "i64.atomic.load", "args": [{"type": "i32", "value": "0"}]}, "expected": [{"type": "i64", "value": "1229782938247303490"}]},
{"type": "action", "line": 345, "action": {"type": "invoke", "field": "init", "args": [{"type": "i64", "value": "1229782938247303441"}]}, "expected": []},
{"type": "assert_return", "line": 346, "action": {"type": "invoke", "field": "i64.atomic.rmw16.cmpxchg_u", "args": [{"type": "i32", "value": "0"}, {"type": "i64", "value": "0"}, {"type": "i64", "value": "13758425323549998831"}]}, "expected": [{"type": "i64", "value": "4369"}]},
{"type": "assert_return", "line": 347, "action": {"type": "invoke", "field": "i64.atomic.load", "args": [{"type": "i32", "value": "0"}]}, "expected": [{"type": "i64", "value": "1229782938247303441"}]},
{"type": "action", "line": 349, "action": {"type": "invoke", "field": "init", "args": [{"type": "i64", "value": "1229782938247303441"}]}, "expected": []},
{"type": "assert_return", "line": 350, "action": {"type": "invoke", "field": "i64.atomic.rmw16.cmpxchg_u", "args": [{"type": "i32", "value": "0"}, {"type": "i64", "value": "1229782938247303441"}, {"type": "i64", "value": "13758425323549998831"}]}, "expected": [{"type": "i64", "value": "4369"}]},
{"type": "assert_return", "line": 351, "action": {"type": "invoke", "field": "i64.atomic.load", "args": [{"type": "i32", "value": "0"}]}, "expected": [{"type": "i64", "value": "1229782938247303441"}]},
{"type": "assert_return", "line": 351, "action": {"type": "invoke", "field": "i64.atomic.load", "args": [{"type": "i32", "value": "0"}]}, "expected": [{"type": "i64", "value": "1229782938247347951"}]},
{"type": "action", "line": 353, "action": {"type": "invoke", "field": "init", "args": [{"type": "i64", "value": "1229782938247303441"}]}, "expected": []},
{"type": "assert_return", "line": 354, "action": {"type": "invoke", "field": "i64.atomic.rmw32.cmpxchg_u", "args": [{"type": "i32", "value": "0"}, {"type": "i64", "value": "0"}, {"type": "i64", "value": "14608453322185352933"}]}, "expected": [{"type": "i64", "value": "286331153"}]},
{"type": "assert_return", "line": 355, "action": {"type": "invoke", "field": "i64.atomic.load", "args": [{"type": "i32", "value": "0"}]}, "expected": [{"type": "i64", "value": "1229782938247303441"}]},
{"type": "action", "line": 357, "action": {"type": "invoke", "field": "init", "args": [{"type": "i64", "value": "1229782938247303441"}]}, "expected": []},
{"type": "assert_return", "line": 358, "action": {"type": "invoke", "field": "i64.atomic.rmw32.cmpxchg_u", "args": [{"type": "i32", "value": "0"}, {"type": "i64", "value": "1229782938247303441"}, {"type": "i64", "value": "14608453322185352933"}]}, "expected": [{"type": "i64", "value": "286331153"}]},
{"type": "assert_return", "line": 359, "action": {"type": "invoke", "field": "i64.atomic.load", "args": [{"type": "i32", "value": "0"}]}, "expected": [{"type": "i64", "value": "1229782938247303441"}]},
{"type": "assert_return", "line": 359, "action": {"type": "invoke", "field": "i64.atomic.load", "args": [{"type": "i32", "value": "0"}]}, "expected": [{"type": "i64", "value": "1229782941362267877"}]},
{"type": "action", "line": 363, "action": {"type": "invoke", "field": "init", "args": [{"type": "i64", "value": "1229782938247303441"}]}, "expected": []},
{"type": "assert_return", "line": 364, "action": {"type": "invoke", "field": "i32.atomic.rmw.cmpxchg", "args": [{"type": "i32", "value": "0"}, {"type": "i32", "value": "286331153"}, {"type": "i32", "value": "305419896"}]}, "expected": [{"type": "i32", "value": "286331153"}]},
{"type": "assert_return", "line": 365, "action": {"type": "invoke", "field": "i64.atomic.load", "args": [{"type": "i32", "value": "0"}]}, "expected": [{"type": "i64", "value": "1229782938266392184"}]},
Expand Down
10 changes: 5 additions & 5 deletions threads/atomic/atomic.wast
Original file line number Diff line number Diff line change
Expand Up @@ -324,39 +324,39 @@

(invoke "init" (i64.const 0x1111111111111111))
(assert_return (invoke "i32.atomic.rmw8.cmpxchg_u" (i32.const 0) (i32.const 0x11111111) (i32.const 0xcdcdcdcd)) (i32.const 0x11))
(assert_return (invoke "i64.atomic.load" (i32.const 0)) (i64.const 0x1111111111111111))
(assert_return (invoke "i64.atomic.load" (i32.const 0)) (i64.const 0x11111111111111cd))

(invoke "init" (i64.const 0x1111111111111111))
(assert_return (invoke "i32.atomic.rmw16.cmpxchg_u" (i32.const 0) (i32.const 0) (i32.const 0xcafecafe)) (i32.const 0x1111))
(assert_return (invoke "i64.atomic.load" (i32.const 0)) (i64.const 0x1111111111111111))

(invoke "init" (i64.const 0x1111111111111111))
(assert_return (invoke "i32.atomic.rmw16.cmpxchg_u" (i32.const 0) (i32.const 0x11111111) (i32.const 0xcafecafe)) (i32.const 0x1111))
(assert_return (invoke "i64.atomic.load" (i32.const 0)) (i64.const 0x1111111111111111))
(assert_return (invoke "i64.atomic.load" (i32.const 0)) (i64.const 0x111111111111cafe))

(invoke "init" (i64.const 0x1111111111111111))
(assert_return (invoke "i64.atomic.rmw8.cmpxchg_u" (i32.const 0) (i64.const 0) (i64.const 0x4242424242424242)) (i64.const 0x11))
(assert_return (invoke "i64.atomic.load" (i32.const 0)) (i64.const 0x1111111111111111))

(invoke "init" (i64.const 0x1111111111111111))
(assert_return (invoke "i64.atomic.rmw8.cmpxchg_u" (i32.const 0) (i64.const 0x1111111111111111) (i64.const 0x4242424242424242)) (i64.const 0x11))
(assert_return (invoke "i64.atomic.load" (i32.const 0)) (i64.const 0x1111111111111111))
(assert_return (invoke "i64.atomic.load" (i32.const 0)) (i64.const 0x1111111111111142))

(invoke "init" (i64.const 0x1111111111111111))
(assert_return (invoke "i64.atomic.rmw16.cmpxchg_u" (i32.const 0) (i64.const 0) (i64.const 0xbeefbeefbeefbeef)) (i64.const 0x1111))
(assert_return (invoke "i64.atomic.load" (i32.const 0)) (i64.const 0x1111111111111111))

(invoke "init" (i64.const 0x1111111111111111))
(assert_return (invoke "i64.atomic.rmw16.cmpxchg_u" (i32.const 0) (i64.const 0x1111111111111111) (i64.const 0xbeefbeefbeefbeef)) (i64.const 0x1111))
(assert_return (invoke "i64.atomic.load" (i32.const 0)) (i64.const 0x1111111111111111))
(assert_return (invoke "i64.atomic.load" (i32.const 0)) (i64.const 0x111111111111beef))

(invoke "init" (i64.const 0x1111111111111111))
(assert_return (invoke "i64.atomic.rmw32.cmpxchg_u" (i32.const 0) (i64.const 0) (i64.const 0xcabba6e5cabba6e5)) (i64.const 0x11111111))
(assert_return (invoke "i64.atomic.load" (i32.const 0)) (i64.const 0x1111111111111111))

(invoke "init" (i64.const 0x1111111111111111))
(assert_return (invoke "i64.atomic.rmw32.cmpxchg_u" (i32.const 0) (i64.const 0x1111111111111111) (i64.const 0xcabba6e5cabba6e5)) (i64.const 0x11111111))
(assert_return (invoke "i64.atomic.load" (i32.const 0)) (i64.const 0x1111111111111111))
(assert_return (invoke "i64.atomic.load" (i32.const 0)) (i64.const 0x11111111cabba6e5))

;; *.atomic.rmw*.cmpxchg (compare true)

Expand Down

0 comments on commit 4034d2b

Please sign in to comment.