a risc-v 64 interpreter and JIT-to-amd64 for Go

70 views
Skip to first unread message

Jason E. Aten

unread,
May 29, 2026, 3:26:25 AM (4 days ago) May 29
to golang-nuts
Inspired by the C++ sandbox 


I wrote

https://github.com/glycerine/riscv-emu-golang 

which is a RISC-V cpu emulator in pure Go. 

With it you can run RV64 ELF binaries (or just snippets of RV64 assembly) fully inside your Go host program.

It includes a JIT compiler to translate RISC-V to amd64 at 
runtime for a nice 8x speedup. With that JIT-ing we are only
about 6x slower than native C compiled to amd64. 
Not bad for a fun side project.

Enjoy,
Jason


  JIT COMPARISON (rv8 vs abjit) — 2026-05-29 04:16  [macos]
  cpu: Intel(R) Core(TM) i7-1068NG7 CPU @ 2.30GHz

  Strategy                                     MIPS
  ──────────
────────────────────────────────────────
  Go JIT — rv8 Fixed Static Mapping (native): 3367 MIPS
  Go JIT — abjit (native):                    3396 MIPS
  Go interpreter (no JIT):                     432 MIPS
  libriscv — JIT (TCC):                       3517 MIPS
  libriscv — interpreter (no JIT):             846 MIPS
  libriscv — full binary translation - N/A, claims 50% native
  native x86-64 (-O3 -march=native):         16833 MIPS (150ms)
  wazero wasm aot-and-run                     8555 MIPS (but linux is near native)

Specific ISA: RV64IMAFDC with Zicsr, Zifencei, Zicond, and bitmanip extensions Zba/Zbb/Zbc/Zbs. As a single hart, atomics are processed but ignored as no-ops.
Reply all
Reply to author
Forward
0 new messages