Next: Performance
Up: Optimizations for x86
Previous: Calling Convention
Floating-Point Modes
Switching the floating-point precision mode on x86 inserts an
additional instruction into the code and also causes stalls in the
processor pipeline. For Java methods using 32-bit and 64-bit
floating-point operations, switching precision is inevitable. However,
our experiments have shown that while running the benchmarks, only one
method in the Java class libraries and one method in the benchmark
programs (mpegaudio) use two precision modes within a single
method. Even in these cases the less frequent precision is used at
most two times. To take advantage of this fact, we choose a
default precision mode for each method and set the precision mode to
the default at the beginning of each method that uses floating-point
operations. Thus, default precision operations require no additional
instructions, while the precision mode needs to be set and reset
around the occasional non-default precision operation. Our calling
convention considers the precision mode to be a preserved value, so it
must be reset at the end of the method.
Because non-default precision operations are rare, this strategy
significantly decreases the number of switches required and thus
increases performance. Precisely analyzing the control-flow and
optimizing the number of switches in a given method would help, but
may be too expensive for just-in-time compilation.
Next: Performance
Up: Optimizations for x86
Previous: Calling Convention