translator. It takes a Wasm module and converts it to a Go package. I plan to use it for my SQLite driver. I'm translating a Wasm build of SQLite into ~
. I've tested it across 20 GOOS/GOARCH combinations.
I have found that GC produces suboptimal code in some situations.
Wasm is a little endian platform, so a memory load is something like (offset is a constant literal):
int32(binary.LittleEndian.Uint32(m.Memory[int64(ptr)+offset:]))
I've noticed that, on little endian platforms, this works much faster:
*(*int32)(unsafe.Pointer((*[4]byte)(m.Memory[int64(ptr)+offset:])))
I think because the first version has 2 bounds checks, and the later just one? This is unfortunate, as I have to generate 2 versions of the code (for little and big endian).
Am I missing any trick to get the compiler to generate better code?
Thanks!