C2 performs escape analysis and, for a non-escaping object, may apply scalar replacement. What exactly does scalar replacement do, and how does it differ from simply allocating the object on the stack?
Point makePoint(int x, int y) { return null; }
int dist2(int x, int y) {
Point p = new Point(x, y); // does not escape dist2
return p.x * p.x + p.y * p.y;
}