Abstract:
Dynamic class loading is an integral part of the Java programming language, offering a number advantages such as lazy class loading and dynamic installation of software components. Unfortunately, these advantages often come at the cost of decreased performance because certain optimizations become more difficult to perform when an optimizing compiler cannot assume that it has seen the whole program.
This paper introduces thin guards, a simple but effective technique that uses lightweight runtime tests to identify regions of code within which speculative optimizations can be performed. One application of thin guards is described in detail, demonstrating how they can be used to perform speculative inlining in the presence of dynamic class loading. Our experimental evaluation shows that when used in combination with other traditional compiler optimizations, thin guards can eliminate most of the penalty dynamic class loading. Performance improvements of up to 27% are observed, eliminating up to 92% of the penalty imposed by dynamic class loading.