Skip to content

interp: support atomic operations in global initializers - #5993

Draft
davecheney wants to merge 1 commit into
tinygo-org:devfrom
davecheney:interp-atomicrmw
Draft

davecheney wants to merge 1 commit into
tinygo-org:devfrom
davecheney:interp-atomicrmw

Conversation

@davecheney

@davecheney davecheney commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Package-level initializers can now use sync/atomic operations while TinyGo evaluates global variables. The interpreter supports LLVM atomicrmw and cmpxchg for interpreter-owned memory, covering Add, And, Or, Swap, and CompareAndSwap without matching function names.

No competing execution contexts exist during initialization, so these operations can be evaluated as loads and stores. Volatile operations and external memory remain runtime operations.

Tests add interpreter coverage for atomicrmw and cmpxchg, plus global-initializer coverage for sync/atomic.

@davecheney davecheney added this to the 0.45 milestone Oct 22, 2026
@davecheney
davecheney force-pushed the interp-atomicrmw branch 3 times, most recently from 3ac4cfb to 7d47e03 Compare October 26, 2026 02:03
@davecheney davecheney changed the title Interp atomicrmw interp: support atomic operations in global initializers Oct 30, 2026
Package-level initializers can now use sync/atomic operations while TinyGo evaluates global variables. The interpreter handles atomicrmw and cmpxchg instructions in memory it owns, covering Add, And, Or, Swap, and CompareAndSwap without matching function names.

This is safe during initialization because no other execution contexts exist yet. Volatile operations and external memory remain runtime operations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant