2 ms·
JVM does a lot of escape analysis to turn heap allocated memory into stack local variables. It doesn't matter if it's local since it's a VM, it's doing it at r
by jmalicki 2mo ago
JVM does a lot of escape analysis to turn heap allocated memory into stack local variables.
It doesn't matter if it's local since it's a VM, it's doing it at runtime and can change an entire call stack of non local code for an optimization.
- pjmlp 2mo agoSome fact correcting, first of all while most people refer to "The JVM", most likely impling OpenJDK, Java is a standard and there are many implementations. Which exactly in this subject varies a lot between implementations, on how well escape analysis is done, if there is a JIT cache between JVM executions, or AOT compilation. Additionally Valhalla is finally getting added to the language with a new EA made available last week, thus value classes will add yet another way to have stack values.
- jmalicki 2mo agoWe were talking about examples of compiler optimizations that save memory, so I gave one. Value classes are not a compiler optimization, and I wasn't talking about the standard, I was talking about an implementation.