Contents Prev Next


Appendix A: An Optimization


The following set of pseudo-instructions suffixed by _quick are variants of Java virtual machine instructions. They are used to improve the speed of interpreting bytecodes. They are not part of the virtual machine specification or instruction set, and are invisible outside of an Java virtual machine implementation. However, inside a virtual machine implementation they have proven to be an effective optimization.

A compiler from Java source code to the Java virtual machine instruction set emits only non-_quick instructions. If the _quick pseudo-instructions are used, each instance of a non-_quick instruction with a _quick variant is overwritten on execution by its _quick variant. Subsequent execution of that instruction instance will be of the _quick variant.

In all cases, if an instruction has an alternative version with the suffix _quick, the instruction references the constant pool. If the _quick optimization is used, each non-_quick instruction with a _quick variant performs the following:

This is identical to the action of the instruction without the _quick optimization, except for the additional step in which the instruction overwrites itself with its _quick variant.

The _quick variant of an instruction assumes 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.

Note: some of the invoke methods only support a single-byte offset into the method table of the object; for objects with 256 or more methods some invocations cannot be "quicked" with only these bytecodes. We also need to define or change existing getfield and putfield bytecodes to support more than a byte of offset.

This Appendix doesn't give the opcode values of the pseudo-instructions, since they are invisible and subject to change.


Contents Prev Next