lightning
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Lightning] Are tail calls possible in GNU lightning?


From: Paulo César Pereira de Andrade
Subject: Re: [Lightning] Are tail calls possible in GNU lightning?
Date: Thu, 15 Jan 2015 15:12:30 -0200

2015-01-10 12:11 GMT-02:00 Marc Nieper-Wißkirchen <address@hidden>:

  Hi,

>>   Your specific example would be better done using
>> jit_frame and jit_tramp. These calls are not in a
>> released lightning version, but were added for
>> GNU Smalltalk. Examples:
>>
>> http://git.savannah.gnu.org/cgit/lightning.git/tree/check/tramp.tst
>> http://git.savannah.gnu.org/cgit/lightning.git/tree/check/ctramp.c
>>
>> Basically, "jit_frame(int size)" creates a stack frame
>> saving all callee save registers, and allocates at
>> least "size" bytes, that have as a good value, 8*
>> maximum number of arguments used in a C call.
>>
>> After that, trampolines, but work as tail call in the
>> way you need it,  created with "jit_tramp(int size)"
>> are like a normal function body, just that while it
>> needs calling jit_prolog and jit_epilog, it does not
>> generate any code, so, it is very "light" and allow
>> jumping from code generated by one jit_context_t
>> to another.
>
>
> That's exactly what I need! Thanks for pointing out your new work. In fact,
> the generated code is very light.

  Good to know it did work :)

  I did not yet finish a proper interface for tail call, because
I am still trying to decide if implement an efficient but very
restrict one, or a somewhat inefficient one. At first, I added
an interface to change arguments to the current jit function:

http://git.savannah.gnu.org/cgit/lightning.git/commit/?id=27d9b68a3fad0fbb1956a11f35ce51852480135c

  The new check/put.tst test case is using a trampoline,
but should later use some tail call interface. A predicate
should also be added, to know if an argument is in a
register or not (lightning does not spill/reload values
in register arguments by default), so, one could want
to jit_allocai and manually ensure those are kept
safe, in the function prolog.

>> I suggest you test it. Lightning 2.0.6 should be
>> released shortly, and will have the feature described
>> above.
>
>
> I checked out the git version and it worked instantly. I am also looking
> forward for the next proper release.
>
> Thanks again for your great piece of software!
>
> Best,
>
> Marc

Thanks,
Paulo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]