Incomputer science,dynamic recompilation is a feature of someemulators andvirtual machines, where the system mayrecompile some part of aprogram during execution. By compiling during execution, the system can tailor the generated code to reflect the program's run-time environment, and potentially produce more efficientcode by exploiting information that is not available to a traditional staticcompiler.
Most dynamic recompilers are used to convert machine code between architectures at runtime. This is a task often needed in the emulation of legacy gaming platforms. In other cases, a system may employ dynamic recompilation as part of anadaptive optimization strategy to execute a portable program representation such asJava or .NETCommon Language Runtime bytecodes. Full-speed debuggers also utilize dynamic recompilation to reduce the space overhead incurred in mostdeoptimization techniques, and other features such as dynamicthread migration.
FreeKEYB, an international DOS keyboard and console driver with many usability enhancements utilizedself-modifying code anddynamic dead code elimination to minimize its in-memory image based on its user configuration (selected features, languages, layouts) and actual runtime environment (OS variant and version, loaded drivers, underlying hardware), automatically resolving dependencies, dynamically relocating and recombining code sections on byte-level granularity and optimizing opstrings based on semantic information provided in the source code, relocation information generated by special tools during assembly and profile information obtained at load time.[4]
The backwards compatibility functionality of theXbox 360 (i.e. running games written for the originalXbox) is widely assumed to use dynamic recompilation.
Apple'sRosetta 2 for Apple silicon, permits many applications compiled forx86-64-based processors to be translated for execution on Apple silicon.
PCem, an emulator for old pc platforms which can be used on Windows and Linux. It uses the recompiler to translate legacy cpu calls to modern cpu instructions and to gain some speed in emulation overall.
86Box, a fork of PCem with the goal of a more accurate emulation. It is using the recompiler for the same purpose.