Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Show HN: A Wasm to Go Translator (github.com/ncruces)
7 points by ncruces 21 days ago | hide | past | favorite | 1 comment
I've spent the past couple of weeks building a Wasm-to-Go translator.

It supports a subset of Wasm useful enough to translate SQLite into 600k LoC (~20 MiB) of Go code. It already passes all of my Go SQLite driver's tests across the 20 platforms I support.

Performance compared to https://wazero.io/ is a bit of a mixed bag: code that frequently crosses the Go-Wasm boundary improves, but code that spends most of its time in "Wasm land" doesn't.

There's probably room for improvement (I'd love to hear your ideas), but this is also a testament to how good the wazero AOT compiler actually is.

You can get a feel for the generated code by looking into https://github.com/ncruces/wasm2go/tree/main/testdata

I should eventually spend some time ensuring the translator passes the spectest, though I suspect that'll be far less fun than building the translator itself was.



I should add that using unsafe.Pointer I'm able to get a significant boost on little endian platforms, with no loss of safety (pointers are still bounds checked).

With this change, my ported driver would beat wazero on most benchmarks. I do need two 20 MiB blobs of slow to compile, unreadable, Go code in my repo, though.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: