Contents Prev Next Up

# Appendix A - An Optimization

The following set of pseudo-instructions suffixed by _quick are variants of Java virtual machine instructions. They are used by the WebRunner/Java project to improve the execution of compiled code on our bytecode interpreter. 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 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:

- Resolves the specified item in the constant pool

- Signals an error if the item in the constant pool could not be resolved for some reason

- Turns itself into the _quick version of the instruction. The instructions putstatic, getstatic, putfield, and getfield each have two _quick versions.

- Performs its intended operation

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.

Pushing Constants onto the Stack (_quick variants)
Managing Arrays (_quick variants)
Manipulating Object Fields (_quick variants)
Method Invocation (_quick variants)
Miscellaneous Object Operations (_quick variants)
Constant Pool Resolution

Contents Prev Next Up

Generated with CERN WebMaker