-
Notifications
You must be signed in to change notification settings - Fork 115
Description
In tiered compilation, the interpreter monitors the frequency of jumps to specific code addresses. Once a pre-set threshold is reached, it initiates JIT compilation. Concurrently, the emulator can continue operating with the interpreter, while JIT compilation is processed in a background thread, seamlessly switching to the JIT-compiled code once it is ready.
This emulator utilizes a JIT compiler for executing all RISC-V instructions. When execution begins, each emulator thread is equipped to compile new code. This implementation allows JIT compilation to occur in a background thread while the interpreter continues its execution until compilation is complete. If the emulator encounters a function that hasn't been compiled yet, it acquires a lock on the JIT code backend and attempts to compile the entire function into the JIT backend before resuming execution. Importantly, this lock only restricts other threads from adding new code to the JIT backend during compilation, without impeding their ability to use the JIT backend. Essentially, this means that one thread compiling new code has a minimal impact on other threads, resulting in a lock that imposes little overhead.