Tail Call Optimization

Christian Humer christian.humer at gmail.com
Wed Jan 14 00:31:22 UTC 2015


Hi Christian,

You should not pass nodes around like values (like you do with the
DirectCallNode). Instead let the TailCallException carry a CallTarget.

As Stefan pointed out, in the catch block of the TailCallException you are
going to need another inline cache similar to the one in
SLDirectDispatchNode. To try it out quickly you can also use an
IndirectCallNode instead, but don't expect perfect performance from this.

- Christian Humer



On Wed Jan 14 2015 at 00:18:13 Cristian Esquivias <
cristian.esquivias at gmail.com> wrote:

> Hi Stefan,
>
> Thanks for taking a look. So I would create a linked list of dispatch nodes
> like in Simple Language?
>
> http://hg.openjdk.java.net/graal/graal/file/3a59e1411192/gra
> al/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/call/
> SLDirectDispatchNode.java
>
> Since the function object and the call target don't change, how should I
> test for equality between one dispatch node and another? That is, how do I
> know to use one dispatch node versus another?
>
> Thanks again,
> Cristian
>
> On Tue, Jan 13, 2015 at 3:06 PM, Stefan Marr <java at stefan-marr.de> wrote:
>
> > Hi Cristian:
> >
> > > On 13 Jan 2015, at 23:25, Cristian Esquivias <
> > cristian.esquivias at gmail.com> wrote:
> > >
> > > I'm trying to add tail call optimization to my test language and have a
> > > functional version (no stackoverflows).
> > >
> > >
> > https://github.com/cesquivias/mumbler/commit/3b61f7ccdad7429
> d2feac6068b0f57edce6a4151
> >
> > Looking at the diff/code, I think the issue is the call node that you
> pass
> > back in the exception.
> > At the point where you handle the exception, you’ll probably need to make
> > that node a constant as part of the AST, by using a dispatch node
> chain/an
> > inline cache.
> >
> > Best regards
> > Stefan
> >
> >
> > --
> > Stefan Marr
> > INRIA Lille - Nord Europe
> > http://stefan-marr.de/research/
> >
> >
> >
> >
>


More information about the graal-dev mailing list