Is saving the stack pointer around method handle calls still needed?

Remi Forax forax at univ-mlv.fr
Fri Apr 4 07:20:43 UTC 2014


On 04/04/2014 06:48 AM, John Rose wrote:
> On Apr 3, 2014, at 5:38 PM, Krystal Mok <rednaxelafx at gmail.com 
> <mailto:rednaxelafx at gmail.com>> wrote:
>
>> It'd be interesting to see tail calls coming :-)
>
> Doug Lea reminded Brian, David, and me today of one big reason tail 
> calls are important:  Certain threaded frameworks cannot delegate from 
> one actor to another without it.  The failure mode is stack overflow, 
> very occasionally.  This is the root cause of a recent bug in our 
> fork-join framework code, which schedules from task to task by 
> (sometimes) delegating from the old task to the new one.

More generally, if you have a code that separate a slow path from a fast 
path, the slow path requires a tailcall.

Moreover, in plain Java, there are two use cases where tail calls are 
badly needed,
- Java EE/Spring like frameworks, the code that manage annotations grows 
on the stack because there is no tailcall,
   hence the huge stack traces that everybody see.
- bridges generated by javac to fill the gap between Java the language 
world and Java VM world,
   (generics and inner classes), half of them should call their delegate 
method/constructor with a tail call.

>
> — John

Rémi



More information about the hotspot-compiler-dev mailing list