|Contents | Prev | Next | Index||The JavaTM Virtual Machine Specification|
This chapter describes an optimization implemented in Sun's version of the Java Virtual Machine. In this optimization, compiled Java Virtual Machine code is modified at run time for better performance.
The optimization takes the form of a set of pseudo-instructions. These are variants of normal Java Virtual Machine instructions that take advantage of information learned at run time to do less work than the original instructions. The pseudo-instructions are distinguishable by the suffix _quick in their mnemonics.
It is important to understand that these pseudo-instructions are not part of the Java Virtual Machine specification or instruction set. They are invisible outside of a Java Virtual Machine implementation. However, inside a Java Virtual Machine implementation they have proven to be an effective optimization.
The technique documented in this chapter is covered by U.S. Patent 5,367,685.
For instructions that are rewritten, each instance of the instruction is replaced on its first execution by a _quick pseudo-instruction. Subsequent execution of that instruction instance is always the _quick variant. Most instructions with _quick variants have just a single alternative version, although some have several.
In all cases, the instructions with _quick variants reference the constant pool, a fairly costly operation. The _quick pseudo-instructions save time by exploiting the fact that, while the first time an instruction referencing the constant pool must dynamically resolve the constant pool entry, subsequent invocations of that same instruction must reference the same object and need not resolve the entry again. The rewriting process is as follows:
The _quick variant of an instruction can assume that the item in the constant pool has already been resolved and that this resolution did not generate any errors. It simply performs the intended operation on the resolved item. A significant amount of time is thus saved on all subsequent invocations of the pseudo-instruction.
classfiles. They are normally an invisible implementation detail, so that decisions such as opcode choices are left up to the implementor.
However, there are exceptions to this rule. Certain tools such as debuggers and just-in-time (JIT) code generators may need to know details about the _quick pseudo-instructions so that they can operate on code that has already been executed. An implementation of the Java Virtual Machine may use techniques similar to but different from Sun's _quick pseudo-instructions, or may use different opcode numbers from Sun's implementation. Tools assuming the details of Sun's _quick pseudo-instructions may not work with these differing implementations.
APIs are being developed for debuggers and JIT code generators. These APIs may provide ways of hiding details of internal pseudo-instructions so that tools that are independent of internal implementation details can be written. However, as of this writing these APIs have not yet been established, so in the meantime we document opcode values together with other details of Sun's _quick instructions. Tools can assume that implementations of the Java Virtual Machine that derive from Sun's, or that are written to be compatible with Sun's implementation, will follow the specification given below.
email@example.com for more information about the status of debugger and JIT code generator APIs.
Contents | Prev | Next | Index
Java Virtual Machine Specification
Copyright © 1996, 1997 Sun Microsystems, Inc. All rights reserved
Please send any comments or corrections to firstname.lastname@example.org