Tail Calls

D.Sturm D.Sturm42 at gmail.com
Sun Mar 16 15:24:16 UTC 2014


There is a TailCallNode in hotspot.nodes and the HotSpotLIRGenerator has
an emitTailcall function, that's why I asked. So is the reason for this
just to make

int foo() {
     // code.
     return bar();
}

a bit more efficient by avoiding the need for the second return op and
letting bar jump back to foo's caller directly?

-- Daniel

On 16 March 2014 16:14, Gilles Duboscq <duboscq at ssw.jku.at> wrote:

> Hello,
>
> I suppose you mean that you expect Graal to transform that code snippet
> into a loop?
> There is currently no tail recursion optimization in Graal.
>
> -Gilles
> On 16 Mar 2014 14:21, "D.Sturm" <D.Sturm42 at gmail.com> wrote:
>
>> I was trying to write a testcase for the aarch64 backend for tail
>> recursion, but I can't seem to get Graal to generate the code for it. I
>> tried it with the following, but that just causes a normal static call:
>>
>>         public static int tailCallTest(int n, int total) {
>>                 if (n == 0) return total;
>>                 return tailCallTest(n - 1, total + 1);
>>         }
>>
>> any ideas?
>>
>> -- Daniel
>>
>


More information about the graal-dev mailing list