Tail Calls

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


My fault for not being clearer.

Thanks for the answer, I guess I'll just throw a not implemented exception
for now and worry about testing the code when I run into an actual use case.

--Daniel
On 16 Mar 2014 16:31, "Gilles Duboscq" <duboscq at ssw.jku.at> wrote:

> Yes sorry, I should have read the email subject rather than concentrating
> on the example.
>
> There is also no tail calls optimization.
>
> This node was used for manually constructed graphs. I'm not even sure it
> is still used anywhere.
>
> -Gilles
> On 16 Mar 2014 16:24, "D.Sturm" <D.Sturm42 at gmail.com> wrote:
>
>> 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