Stack sizes and stack allocation

Vitaly Davidovich vitalyd at gmail.com
Thu Aug 13 16:53:22 UTC 2015


Scalar replacement basically takes the components of an object (i.e. its
fields), places them into registers, and eliminates the "host" object
itself.  Canonical example is eliminating ArrayList$Itr.  Your own types
are eligible for this, it's not restricted to JDK.

If you want to know more about the algorithm, I suggest you take a look at
the sources (
http://hg.openjdk.java.net/jdk9/hs-comp/hotspot/file/1aef080fd28d/src/share/vm/opto/escape.[h|c]pp)
and/or ask the compiler guys (hotspot-compiler mailing list).

On Thu, Aug 13, 2015 at 12:23 PM, Kees Jan Koster <kjkoster at gmail.com>
wrote:

> Dear Vitaly,
>
> > It will throw stackoverflow error.
>
> Right, that’s good. So by reducing the stack size we are not inadvertently
> reducing the ability for the VM to optimise.
>
> > Keep in mind that escape analysis (currently) only does scalar
> replacement and not true stack allocation, so the stack usage of it is
> additional registers and spill slots, no different than calling a method
> with more arguments.
>
> What does ‘scalar’ mean in this context? Only atomic types? Only JVM
> wrapper types such as java.lang.Integer? java.lang.Strings?
>
> How about my own types? If they have one field? Many fields?
>
> I guess my question is: what makes a class eligible to have its instances
> stack-allocated by escape analysis?
>
> --
> Kees Jan
>
> http://java-monitor.com/
> kjkoster at kjkoster.org
> +31651838192
>
> Human beings make life so interesting. Do you know that in a universe so
> full of wonders,
> they have managed to invent boredom. Quite astonishing... -- Terry
> Pratchett
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/hotspot-gc-use/attachments/20150813/dd4da930/attachment-0001.html>


More information about the hotspot-gc-use mailing list