Orb
Orb copied to clipboard
Allow specifying alignment to loads and stores
trafficstars
e.g.
(i32.load align=1 (i32.const 0))
(i32.load align=4 (i32.const 0))
(i32.store align=4 (i32.const 0) (i32.const 1))
(i64.store align=8 (i32.const 0) (i64.const 1))
(f32.store align=4 (i32.const 0) (f32.const 1.0))
The default alignment when loading i32.load is 4, should we change this for I32.UnsafePointer?
I32.UnsafePointer.alignment() # 1
I32.UnsafeAlignedPointer.alignment() # 4
some_address: I32.UnsafePointer
Memory.load(I32, some_address) # (i32.load (i32.const 0))
some_address2: I32.UnsafeAlignedPointer
Memory.load(I32, some_address) # (i32.load align=4 (i32.const 0))
- https://rsms.me/wasm-intro#addressing-memory
- https://github.com/WebAssembly/testsuite/blob/main/align.wast
Aligns could be defined when defining a SilverOrb Arena, and so you know for example that loads/store to your particular arena is 32-bit aligned.
Some progress has been made on this. I just need to decide whether I32.UnsafePointer should be aligned by default or not. If it should be aligned perhaps it should be renamed to I32.UnsafeAlignedPointer to reflect this. I think it partly depends on which pointer types should be built-in.