Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions debug_sb.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

(module $Mem
(memory (export "shared") 1 1 shared)
)
(register "mem")

(thread $T1 (shared (module $Mem))
(register "mem" $Mem)
(module
(memory (import "mem" "shared") 1 1 shared)
(func (export "run")
(local i32)
(i32.atomic.store (i32.const 0) (i32.const 1))
(i32.atomic.load (i32.const 4))
(local.set 0)
(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.store (i32.const 4) (i32.const 1))
(i32.atomic.load (i32.const 0))
(local.set 0)
(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 i32)
(i32.load (i32.const 32)) ;; Load L_1 first so it fails at index 0
(i32.load (i32.const 24))
)
)

(assert_return (invoke $Check "check") (i32.const 999) (i32.const 999))
35 changes: 35 additions & 0 deletions patch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

with open("src/wasm-interpreter.h") as f:
content = f.read()

# Add debug prints to doAtomicLoad and doAtomicStore
load_hook = """ Literal doAtomicLoad(Address addr,
Index bytes,
Type type,
Name memoryName,
Address memorySize,
MemoryOrder order) {
std::cerr << "doAtomicLoad addr=" << addr << " memoryName=" << memoryName << " instance=" << this << "\\n";"""

content = content.replace(""" Literal doAtomicLoad(Address addr,
Index bytes,
Type type,
Name memoryName,
Address memorySize,
MemoryOrder order) {""", load_hook)

store_hook = """ void doAtomicStore(Address addr,
Index bytes,
Literal toStore,
Name memoryName,
Address memorySize) {
std::cerr << "doAtomicStore addr=" << addr << " val=" << toStore << " memoryName=" << memoryName << " instance=" << this << "\\n";"""

content = content.replace(""" void doAtomicStore(Address addr,
Index bytes,
Literal toStore,
Name memoryName,
Address memorySize) {""", store_hook)

with open("src/wasm-interpreter.h", "w") as f:
f.write(content)
2 changes: 1 addition & 1 deletion scripts/test/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def get_tests(test_dir, extensions=[], recursive=False):
'threads/thread.wast',

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

# Non-natural alignment is invalid for atomic operations
'threads/atomic.wast',
Expand Down
Loading
Loading