public inbox for jit@gcc.gnu.org
 help / color / mirror / Atom feed
* GCCJIT and proper tail calls
@ 2016-01-01  0:00 Marc Nieper-Wißkirchen
  2016-01-01  0:00 ` David Malcolm
  0 siblings, 1 reply; 6+ messages in thread
From: Marc Nieper-Wißkirchen @ 2016-01-01  0:00 UTC (permalink / raw)
  To: jit

Last year there was a discussion on the gccjit mailing list whether it 
is possible to guarantee the elimination of proper tail calls.

Compiling Scheme code with gccjit was given as an example because the 
language demands proper tail call elimination (for example, loops are 
usually implemented by recursive function calls).

The point I would like to make that proper tail call elimination on 
gccjit's side remains crucial even if Scheme didn't ask for proper tail 
call elimination: Scheme allows programs to get hold of the current 
continuation of the program. One way to implement this is to globally 
rewrite the program into continuation-passing style. In other words, 
every call (outside of calling library functions) would become a proper 
tail call. If gccjit chose not to eliminate the calls in favour of 
jumps, the stack usage of the transformed program would be proportional 
to its running time.

LLVM has the `musttail' marker 
http://llvm.org/docs/LangRef.html#call-instruction 
<http://llvm.org/docs/LangRef.html#call-instruction> to guarantee proper 
tail call elimination independent of any optimization pass (or to signal 
an error in case the requirements for the elimination are not met).

Such a thing should be possible for gccjit as well (so that the 
aforementioned program in continuation-passing style would still work 
even without an optimization pass eliminating non-marked proper tail calls).

--

Marc

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-05-13 13:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-01  0:00 GCCJIT and proper tail calls Marc Nieper-Wißkirchen
2016-01-01  0:00 ` David Malcolm
2016-01-01  0:00   ` Basile Starynkevitch
2016-01-01  0:00     ` Marc Nieper-Wißkirchen
2016-01-01  0:00       ` David Malcolm
2016-01-01  0:00         ` Basile Starynkevitch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).