Skip to content

Instantly share code, notes, and snippets.

@binji
Last active January 13, 2021 12:11
Show Gist options
  • Save binji/0d498bbe16173e7fad18cfb39897e2b0 to your computer and use it in GitHub Desktop.
Save binji/0d498bbe16173e7fad18cfb39897e2b0 to your computer and use it in GitHub Desktop.
Thread/Atomics WebAssembly opcode space

Proposed

Name Opcodes Size
is_lock_free 0xff00 1
wake 0xff01 1
i32.wait 0xff02 1
i64.wait 0xff03 1
available 0xff04..0xff0f 12
*.atomic.rmw*.* 0xff10..0xff1b 12
*.atomic.rmw*.cmpxchg* 0xff1c..0xff27 12
*.atomic.load* 0xff28..0xff35 14
*.atomic.store* 0xff36..0xff3e 9
available 0xff3f..0xffff 193

As a cute feature, the opcodes for atomic load/store match the opcodes for load/store.

Factoring out RMW ops

Name Opcodes Size
is_lock_free 0xff00 1
wake 0xff01 1
i32.wait 0xff02 1
i64.wait 0xff03 1
available 0xff04..0xff0f 12
*.atomic.rmw*.add 0xff10..0xff1b 12
*.atomic.rmw*.cmpxchg* 0xff1c..0xff27 12
*.atomic.load* 0xff28..0xff35 14
*.atomic.store* 0xff36..0xff3e 9
*.atomic.rmw*.sub 0xff3f..0xff4a 12
*.atomic.rmw*.and 0xff4b..0xff56 12
*.atomic.rmw*.or 0xff57..0xff62 12
*.atomic.rmw*.xor 0xff63..0xff6e 12
*.atomic.rmw*.xchg 0xff6f..0xff7a 12
available 0xff7b..0xffff 133
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment