HOME

TheInfoList



OR:

In
computer science Computer science is the study of computation, automation, and information. Computer science spans theoretical disciplines (such as algorithms, theory of computation, information theory, and automation) to Applied science, practical discipli ...
, dynamic recompilation is a feature of some emulators and virtual machines, where the system may recompile some part of a
program Program, programme, programmer, or programming may refer to: Business and management * Program management, the process of managing several related projects * Time management * Program, a part of planning Arts and entertainment Audio * Programm ...
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 In computing, a compiler is a computer program that translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primarily used for programs tha ...
.


Uses

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 Adaptive optimization is a technique in computer science that performs dynamic recompilation of portions of a program based on the current execution profile. With a simple implementation, an adaptive optimizer may simply make a trade-off between ...
strategy to execute a portable program representation such as
Java Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's mo ...
or .NET Common Language Runtime bytecodes. Full-speed debuggers also utilize dynamic recompilation to reduce the space overhead incurred in most
deoptimization Adaptive optimization is a technique in computer science that performs dynamic recompilation of portions of a program based on the current execution profile. With a simple implementation, an adaptive optimizer may simply make a trade-off between ...
techniques, and other features such as dynamic thread migration.


Tasks

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

* Many Java virtual machines feature dynamic recompilation. * Apple's
Rosetta Rosetta or Rashid (; ar, رشيد ' ; french: Rosette  ; cop, ϯⲣⲁϣⲓⲧ ''ti-Rashit'', Ancient Greek: Βολβιτίνη ''Bolbitinē'') is a port city of the Nile Delta, east of Alexandria, in Egypt's Beheira governorate. The R ...
for
Mac OS X macOS (; previously OS X and originally Mac OS X) is a Unix operating system developed and marketed by Apple Inc. since 2001. It is the primary operating system for Apple's Mac computers. Within the market of desktop and lap ...
on x86, allows PowerPC code to be run on the x86 architecture. * Later versions of the Mac 68K emulator used in classic Mac OS to run
680x0 The Motorola 68000 series (also known as 680x0, m68000, m68k, or 68k) is a family of 32-bit complex instruction set computer (CISC) microprocessors. During the 1980s and early 1990s, they were popular in personal computers and workstations an ...
code on the PowerPC hardware. * Psyco, a
specializing compiler In computer science, run-time algorithm specialization is a methodology for creating efficient algorithms for costly computation tasks of certain kinds. The methodology originates in the field of automated theorem proving and, more specifically, in ...
for Python. * The HP
Dynamo project In computing, just-in-time (JIT) compilation (also dynamic translation or run-time compilations) is a way of executing computer code that involves compilation during execution of a program (at run time) rather than before execution. This may c ...
, an example of a transparent binary dynamic optimizer. * DynamoRIO, an open-source successor to Dynamo that works with the ARM, x86-64 and IA-64 (Itanium) instruction sets. * The Vx32 virtual machine employs dynamic recompilation to create OS-independent x86 architecture sandboxes for safe application plugins. * Microsoft Virtual PC for Mac, used to run x86 code on PowerPC. * FreeKEYB, an international DOS keyboard and console driver with many usability enhancements utilized self-modifying code and dynamic 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. * The backwards compatibility functionality of the Xbox 360 (i.e. running games written for the original Xbox) is widely assumed to use dynamic recompilation. * Apple's
Rosetta 2 Rosetta is a dynamic binary translator developed by Apple Inc. for macOS, an application compatibility layer between different instruction set architectures. It enables a transition to newer hardware, by automatically translating software. The ...
for Apple silicon, permits many applications compiled for x86-64-based processors to be translated for execution on Apple silicon.


Emulators

* PCSX2, a Sony PlayStation 2 emulator, has a recompiler called "microVU", the successor of "SuperVU". * GCemu, a Nintendo GameCube emulator. * GEM, a Nintendo Game Boy emulator for MSX uses an optimizing dynamic recompiler. * DeSmuME, a Nintendo DS emulator, has a dynarec option. * Soywiz's Psp, a Sony PlayStation Portable emulator, has a dynarec option. * Mupen64Plus, a multi-platform Nintendo 64 emulator. * Yabause, a multi-platform Saturn emulator. *
PPSSPP (an acronym for "PlayStation Portable Simulator Suitable for Playing Portably") is a free and open-source PSP emulator for Windows, macOS, Linux, iOS, Android, Nintendo WiiU, Nintendo Switch, BlackBerry 10, MeeGo, Pandora, Xbox Series X, X ...
, a multi-platform PlayStation Portable emulator, uses a
JIT Jit (also known as jiti, jit-jive and the Harare beat) is a style of popular Zimbabwean dance music. It features a swift rhythm played on drums and accompanied by a guitar. Jit evolved out many diverse influences, including domestic chimurenga, ...
dynamic recompiler by default.


See also

*
Binary recompiler A binary recompiler is a compiler that takes executable binary files as input, analyzes their structure, applies transformations and optimizations, and outputs new optimized executable binaries. The foundation to the concepts of binary recompilat ...
*
Binary translation In computing, binary translation is a form of binary recompilation where sequences of instructions are translated from a ''source'' instruction set to the ''target'' instruction set. In some cases such as instruction set simulation, the target ...
*
Comparison of platform virtualization software Platform virtualization software, specifically emulators and hypervisors, are software packages that emulate the whole physical computer machine, often providing multiple virtual machines on one physical platform. The table below compares basic ...
* Just-in-time compilation * Instrumentation (computer programming)


References

{{Reflist


External links


Dynamic recompiler tutorial

Blog posts about writing a MIPS to PPC dynamic recompiler
Virtualization Compiler construction Emulation software