Stack sizes and stack allocation

Kees Jan Koster kjkoster at gmail.com
Sat Aug 15 20:45:19 UTC 2015


Dear Vitaly and Jenny,

Thank you so much for taking the time to answer my questions and give me pointers on where to go next. Much appreciated.

Kees Jan


> On 13 Aug 2015, at 18:53, Vitaly Davidovich <vitalyd at gmail.com> wrote:
> 
> 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
> 
> 


--
Kees Jan

http://java-monitor.com/
kjkoster at kjkoster.org
+31651838192

Change is good. Granted, it is good in retrospect, but change is good.



More information about the hotspot-gc-use mailing list