rvemu
is a fast Linux emulator, which can run statically linked RV64 programs.
Yeah, it's a toy, but a fairly complete and fast one, which is perfect for learning how a JIT emulator works.
- Faster than QEMU, can achieve native performance in some cases.
- (Almost*) architecture independent, we've tested it under x86_64.
- Tiny, and easy to understand.
- Targeting RV64IMFDC w/ Newlib (only a small subset of syscalls is implemented, adding more).
*Support for new architecture requires handling relocations in src/compile.c, but it's relatively easy. A few lines of code would do.
make -j
riscv64-unknown-elf-gcc hello.c
./rvemu a.out
rvemu
can only run under Linux, and clang
needs to be installed to run, as rvemu uses clang
to generate jit code.
$ ./rvemu bin/lua -v
Lua 4.0.1 Copyright (C) 1994-2000 TeCGraf, PUC-Rio
$ ./rvemu bin/lua test/hello.lua
hello world, from Lua!
Running Java (using PitifulVM)
$ javac tests/Hello.java
$ ./rvemu jvm tests/Hello.class
Hello, World!
-
rvemu
usesclang -O3
to generate highly optimized target code. -
rvemu
uses hardfloat technique to gain more performance, just like NEMU, this actually violates the RISC-V standard, but it produces correct results in most cases, and it's way faster than softfloat. -
rvemu
uses a linear-mapped MMU similar to blink, which is really fast.
All the tests is compiled with
riscv64-unknown-elf-gcc -O3
for RISC-V andclang-15
for x86 native, and run on Intel Xeon Platinum 8269CY.
- Test suite: nbench
- Unit: iterations/second
rvemu | ####################################################### | 1595.92
QEMU | ############################ | 821.9
Native | ############################################################ | 1735.89
rvemu | ### | 138.96
QEMU | # | 25.24
Native | ############################################################ | 2680.95
rvemu | ######################################################### | 741057761.48
QEMU | ############################### | 406495858.33
Native | ############################################################ | 783239543.75
rvemu | ################################## | 591.06
QEMU | ######### | 162.26
Native | ############################################################ | 1040.14
rvemu | ### | 6284.49
QEMU | ## | 5867.78
Native | ############################################################ | 147247.94
rvemu | ################################################## | 84.68
QEMU | ################### | 31.98
Native | ############################################################ | 102.54
rvemu | ############################################# | 11070.72
QEMU | ##################### | 5234.18
Native | ############################################################ | 14832.27
rvemu | ############################################################ | 5070.87
QEMU | ########################## | 2205.89
Native | ###################################################### | 4599.75
Inspired by