Java Reference
In-Depth Information
1. Compilation occurs asynchronously for methods that are placed on the compila-
tion queue.
2. The queue is not strictly ordered; hot methods are compiled before other methods
in the queue. This is another reason why compilation IDs can appear out of order
in the compilation log.
One of the most important optimizations the compiler makes is to inline methods. Code that
follows good object-oriented design often contains a number of attributes that are accessed
via getters (and perhaps setters):
public class
class Point
Point {
private int
int x , y ;
public void
void getX () { return
return x ; }
public void
void setX ( int
int i ) { x = i ; }
The overhead for invoking a method call like this is quite high, especially relative to the
amount of code in the method. In fact, in the early days of Java, performance tips often ar-
gued against this sort of encapsulation precisely because of the performance impact of all
those method calls. Fortunately, JVMs now routinely perform code inlining for these kinds of
methods. Hence, you can write this code:
Point p = getPoint ();
p . setX ( p . getX () * 2 );
and the compiled code will essentially execute this:
Point p = getPoint ();
p . x = p . x * 2 ;
Search WWH ::

Custom Search