|
Array Bounds Optimization
Java guarantees Array bounds check of all array subscripts. By performing these checks at compile time, where possible, significant gains in performance can be obtained. Example:In the code fragement below, the bound optimization for a[0], a[1] can be performed at compile time. { int a[], notused; a = new int[100]; notused = a[0]; notused = a[1]; ... } Below is the code fragment after Array Bounds Optimization, and some other more traditional optimizations. { // Once Array Bounds Optimization is performed, all other // statements can be optimized away. } Notes:Array Bounds Optimization can easily performed as a special case of constant propagation. More advanced versions of Array Bounds Optimization will need range analysis. Array Bounds Optimization is one of the most important optimizations which has to be performed by any Java optimizer. Sometimes, the compiler may even have to rearrange control structures to enable Array Bounds optimizations. © 1990-2012 Nullstone Corporation. All Rights Reserved. |