Dynamic recompilation
This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these messages)
|
| Program execution |
|---|
| General concepts |
| Types of code |
| Compilation strategies |
| Notable runtimes |
|
| Notable compilers & toolchains |
|
In computer science, dynamic recompilation is a feature of some emulators and virtual machines, where the system may recompile some part of a program 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 efficient code by exploiting information that is not available to a traditional static compiler.
Uses
[edit]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 an adaptive optimization strategy to execute a portable program representation such as Java or .NET Common Language Runtime bytecodes. Full-speed debuggers also utilize dynamic recompilation to reduce the space overhead incurred in most deoptimization techniques, and other features such as dynamic thread migration.
Tasks
[edit]The main tasks a dynamic recompiler has to perform are:
- Reading in machine code from the source platform
- Emitting machine code for the target platform
A dynamic recompiler may also perform some auxiliary tasks:
- Managing a cache of recompiled code
- Updating of elapsed cycle counts on platforms with cycle count registers
- Management of interrupt checking
- Providing an interface to virtualized support hardware, for example a GPU
- Optimizing higher-level code structures to run efficiently on the target hardware (see below)
Applications
[edit]- Many Java virtual machines feature dynamic recompilation.
- Apple's Rosetta for macOS on x86 allows PowerPC code to be run on the x86 architecture. Similarly, Apple's Rosetta 2 for macOS on Apple silicon permits many applications compiled for x86-64-based processors to be translated for execution on Apple silicon.
- Later versions of the Mac 68K emulator used in classic Mac OS allow running 680x0 code on the PowerPC hardware.
- The HP Dynamo project, an example of a transparent binary dynamic optimizer.[1]
- DynamoRIO, an open-source successor to Dynamo that works with the ARM, x86-64 and IA-64 (Itanium) instruction sets.[2][3]
- The Vx32 virtual machine employs dynamic recompilation to create OS-independent x86 architecture sandboxes for safe application plugins.
- The backwards compatibility functionality of the Xbox 360 (i.e. running games written for the original Xbox) is widely assumed to use dynamic recompilation.
- Many emulators for video game consoles, such as PCSX2,[4] PPSSPP.[5], and melonDS[6] use JIT dynamic recompilation.
See also
[edit]References
[edit]- ↑ "HP Labs' technical report on Dynamo". Archived from the original on 2008-07-07. Retrieved 2006-01-22.
- ↑ "DynamoRIO Dynamic Instrumentation Tool Platform". Archived from the original on 2019-09-05. Retrieved 2016-04-12.
- ↑ "DynamoRIO". GitHub. 2021-10-15.
- ↑ "PCSX2". Retrieved 2026-11-17.
{{cite web}}: CS1 maint: url-status (link) - ↑ "PPSSPP - PPSSPP - PSP emulator for Android, Windows, Linux, iOS, MacOSX". ppsspp.org. Retrieved 2021-11-17.
- ↑ "melonDS". Retrieved 2026-11-17.
{{cite web}}: CS1 maint: url-status (link)
External links
[edit]- Dynamic recompiler tutorial. Archive at the Wayback Machine (archived 11 June 2021).
- Blog posts about writing a MIPS to PPC dynamic recompiler.