Comparison of Application Virtual Machines - Comparison of Virtual Machines

Comparison of Virtual Machines

The table here summarizes elements for which the virtual machine designs intended to be efficient, not the list of capabilities present in any implementation.

Virtual machine Machine model Memory management Code security Interpreter JIT Precompilation Shared libraries Common Language Object Model Dynamic typing
CLR stack automatic or manual Yes No Yes Yes Yes Yes Yes
Dis (Inferno) register automatic Yes Yes Yes Yes Yes No No
DotGNU Portable.NET stack automatic or manual No No Yes Yes Yes Yes No
JVM stack automatic Yes Yes Yes Yes Yes Yes Yes
JikesRVM stack automatic No No Yes No ? No No
LLVM register manual No Yes Yes Yes Yes Yes No
Mono stack automatic or manual Yes Yes Yes Yes Yes Yes Yes
Parrot register automatic No Yes No Yes Yes Yes Yes
Dalvik register automatic Yes Yes Yes ? ? No No
libJIT stack manual No No Yes No No ? No
Squeak stack automatic No Yes Yes source to bytecode Yes No Yes

Virtual machine instructions process data in local variables using a main model of computation, typically that of a stack machine, register machine, or random access machine often called the memory machine. Use of these three techniques is motivated by different tradeoffs in virtual machines vs physical machines, such as ease of interpretation, compilation, and verifiability for security.

Memory management in these portable virtual machines is addressed at a higher level of abstraction than in physical machines. Some virtual machines, such as the popular JVM, are involved with addresses in such a way as to require safe automatic memory management by allowing the virtual machine to trace pointer references, and disallow machine instructions from manually constructing pointers to memory. Other virtual machines, such as LLVM, are more like traditional physical machines, allowing direct use and manipulation of pointers. CIL offers a hybrid in between, offering both controlled use of memory (like the JVM, which allows safe automatic memory management), while also offering an 'unsafe' mode that allows direct manipulation of pointers in ways that can violate type boundaries and permission.

Code security generally refers to the ability of the portable virtual machine to run code while only offering it a prescribed set of capabilities. For example, the virtual machine might only allow the code access to a certain set of functions or data. The same controls over pointers which make automatic memory management possible and allow the virtual machine to ensure typesafe data access are used to assure that a code fragment is only allowed to certain elements of memory and cannot sidestep the virtual machine itself. Other security mechanisms are then layered on top as code verifiers, stack verifiers, and other techniques.

An interpreter allows programs made of virtual instructions to be loaded and immediately run without a potentially costly compilation into native machine instructions. Any virtual machine which can be run can be interpreted, so the column designation here refers to whether the design includes provisions for efficient interpretation (for common usage).

Just-in-time compilation or JIT, refers to a method of compiling to native instructions at the latest possible time, usually immediately before or during the running of the program. The challenge of JIT is more one of implementation than of virtual machine design, however, modern designs have begun to make considerations to help efficiency. The simplest JIT techniques simply perform compilation to a code-fragment similar to an offline compiler. However, more complicated techniques are often employed, which specialize compiled code-fragments to parameters that are known only at runtime (see Adaptive optimization).

Precompiling refers to the more classical technique of using an offline compiler to generate a set of native instructions which do not change during the runtime of the program. Because aggressive compilation and optimization can take time, a precompiled program may launch faster than one which relies on JIT alone for execution. JVM implementations have mitigated this startup cost by using interpretation initially to speed launch times, until native code-fragments can be generated through JIT.

Shared libraries are a facility to reuse segments of native code across multiple running programs. In modern operating systems, this generally means using virtual memory to share the memory pages containing a shared library across different processes which are protected from each other via memory protection. It is interesting that aggressive JIT techniques such as adaptive optimization often produce code-fragments unsuitable for sharing across processes or successive runs of the program, requiring a tradeoff be made between the efficiencies of precompiled and shared code and the advantages of adaptively specialized code. For example, several design provisions of CIL are present to allow for efficient shared libraries, possibly at the cost of more specialized JIT code. The JVM implementation on Mac OS X uses a Java Shared Archive (apple docs) to provide some of the benefits of shared libraries.

Read more about this topic:  Comparison Of Application Virtual Machines

Famous quotes containing the words comparison of, comparison, virtual and/or machines:

    We teach boys to be such men as we are. We do not teach them to aspire to be all they can. We do not give them a training as if we believed in their noble nature. We scarce educate their bodies. We do not train the eye and the hand. We exercise their understandings to the apprehension and comparison of some facts, to a skill in numbers, in words; we aim to make accountants, attorneys, engineers; but not to make able, earnest, great- hearted men.
    Ralph Waldo Emerson (1803–1882)

    When we reflect on our past sentiments and affections, our thought is a faithful mirror, and copies its objects truly; but the colours which it employs are faint and dull, in comparison of those in which our original perceptions were clothed.
    David Hume (1711–1776)

    Neither dead nor alive, the hostage is suspended by an incalculable outcome. It is not his destiny that awaits for him, nor his own death, but anonymous chance, which can only seem to him something absolutely arbitrary.... He is in a state of radical emergency, of virtual extermination.
    Jean Baudrillard (b. 1929)

    If men do not keep on speaking terms with children, they cease to be men, and become merely machines for eating and for earning money.
    John Updike (b. 1932)