| From the link about GraalVM: > Something that Graal can do that C2 cannot, and a key advantage of GraalVM, is partial escape analysis. Instead of determining a binary value of whether an object escapes the compilation unit or not, this can determine on which branches an object escapes it, and move allocation of the object to only those branches where it escapes. And from https://docs.oracle.com/en/java/javase/11/vm/java-hotspot-vi... > The Java HotSpot Server Compiler implements the flow-insensitive escape analysis algorithm described in: > ... > After escape analysis, the server compiler eliminates the scalar replaceable object allocations and the associated locks from generated code. The server compiler also eliminates locks for objects that do not globally escape. It does not replace a heap allocation with a stack allocation for objects that do not globally escape. ---- So, some JVMs implement, others only do a limited subset of the optimizations available with escape analysis. I would not say that the answer of "is it used in practice" is "no." |
Theoretically it could do hat, but that's just the classic "sufficient smart compiler" strawman [1]
[1] https://wiki.c2.com/?SufficientlySmartCompiler
[2] https://stackoverflow.com/questions/29665748/memory-allocati...