Skip to content

Commit ec22d0c

Browse files
Implementation for threads in spec tests
1 parent 4ccffa1 commit ec22d0c

File tree

10 files changed

+753
-43
lines changed

10 files changed

+753
-43
lines changed

debug_sb.wast

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
2+
(module $Mem
3+
(memory (export "shared") 1 1 shared)
4+
)
5+
(register "mem")
6+
7+
(thread $T1 (shared (module $Mem))
8+
(register "mem" $Mem)
9+
(module
10+
(memory (import "mem" "shared") 1 1 shared)
11+
(func (export "run")
12+
(local i32)
13+
(i32.atomic.store (i32.const 0) (i32.const 1))
14+
(i32.atomic.load (i32.const 4))
15+
(local.set 0)
16+
(i32.store (i32.const 24) (local.get 0))
17+
)
18+
)
19+
(invoke "run")
20+
)
21+
22+
(thread $T2 (shared (module $Mem))
23+
(register "mem" $Mem)
24+
(module
25+
(memory (import "mem" "shared") 1 1 shared)
26+
(func (export "run")
27+
(local i32)
28+
(i32.atomic.store (i32.const 4) (i32.const 1))
29+
(i32.atomic.load (i32.const 0))
30+
(local.set 0)
31+
(i32.store (i32.const 32) (local.get 0))
32+
)
33+
)
34+
(invoke "run")
35+
)
36+
37+
(wait $T1)
38+
(wait $T2)
39+
40+
(module $Check
41+
(memory (import "mem" "shared") 1 1 shared)
42+
(func (export "check") (result i32 i32)
43+
(i32.load (i32.const 32)) ;; Load L_1 first so it fails at index 0
44+
(i32.load (i32.const 24))
45+
)
46+
)
47+
48+
(assert_return (invoke $Check "check") (i32.const 999) (i32.const 999))

patch.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
with open("src/wasm-interpreter.h") as f:
3+
content = f.read()
4+
5+
# Add debug prints to doAtomicLoad and doAtomicStore
6+
load_hook = """ Literal doAtomicLoad(Address addr,
7+
Index bytes,
8+
Type type,
9+
Name memoryName,
10+
Address memorySize,
11+
MemoryOrder order) {
12+
std::cerr << "doAtomicLoad addr=" << addr << " memoryName=" << memoryName << " instance=" << this << "\\n";"""
13+
14+
content = content.replace(""" Literal doAtomicLoad(Address addr,
15+
Index bytes,
16+
Type type,
17+
Name memoryName,
18+
Address memorySize,
19+
MemoryOrder order) {""", load_hook)
20+
21+
store_hook = """ void doAtomicStore(Address addr,
22+
Index bytes,
23+
Literal toStore,
24+
Name memoryName,
25+
Address memorySize) {
26+
std::cerr << "doAtomicStore addr=" << addr << " val=" << toStore << " memoryName=" << memoryName << " instance=" << this << "\\n";"""
27+
28+
content = content.replace(""" void doAtomicStore(Address addr,
29+
Index bytes,
30+
Literal toStore,
31+
Name memoryName,
32+
Address memorySize) {""", store_hook)
33+
34+
with open("src/wasm-interpreter.h", "w") as f:
35+
f.write(content)

scripts/test/shared.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ def get_tests(test_dir, extensions=[], recursive=False):
400400
'threads/thread.wast',
401401

402402
# Requires better support for multi-threaded tests
403-
'threads/wait_notify.wast',
403+
# 'threads/wait_notify.wast',
404404

405405
# Non-natural alignment is invalid for atomic operations
406406
'threads/atomic.wast',

0 commit comments

Comments
 (0)