Truffle Node replacement problem caused by recursion
Thomas Wuerthinger
thomas.wuerthinger at oracle.com
Mon Oct 21 07:10:51 PDT 2013
Thanks both Wei and Stefan for describing the issue. We are currently experimenting with various possible of fixes (this is why you can see change sets being pushed and backed out again ;)). Andreas is going to post a description of the solution once we are confident that we have solved the problem. - thomas
On Oct 19, 2013, at 6:53 PM, Stefan Marr <java at stefan-marr.de> wrote:
> Hi Wei:
>
> On 19 Oct 2013, at 01:44, Wei Zhang <ndrzmansn at gmail.com> wrote:
>
>> Hi guys,
>>
>> I came across a problem with Truffle node replacement when I was
>> trying to apply Python level inlining to binarytrees.py (one of the
>> shootout benchmarks). I thought it is worth sharing it with all of you
>> that are using Truffle.
>>
>> Basically, recursion might cause inconsistencies in a Truffle AST.
>> That is a node's parent's children don't include itself.
>
> I had similar issues. A simple fibonacci function is a good example.
> The plus operation got specialized in a recursive call, and the unspecialized plus node was still on the Java call stack and tried to specialize itself after completing execution of its arguments.
>
> My solution first was based on remembering in the node that it got specialized.
> See [1] and [2] for the code in my nodes.
>
> However, after I switched to using the Truffle DSL, that problem went away. Don't know exactly why.
>
> And even more mysterious is a commit that was done by Andreas recently and later reverted: [3] "Truffle: fix node rewrite issue that can occur when a currently executing node is replaced in a recursive call."
> Not sure why it got reverted later on, but since I am not experiencing the issue anymore, I hope it is solved somehow by the Truffle DSL implementation.
>
> Best regards
> Stefan
>
> [1] https://github.com/smarr/TruffleSOM/blob/bf97e05836c0c9c9647b41e6da305c007ac94236/src/som/interpreter/nodes/MessageNode.java#L141
> [2] https://github.com/smarr/TruffleSOM/blob/bf97e05836c0c9c9647b41e6da305c007ac94236/src/som/interpreter/nodes/MessageNode.java#L257
>
> [3] http://hg.openjdk.java.net/graal/graal/rev/be0a33a631fa
>
> --
> Stefan Marr
> Software Languages Lab
> Vrije Universiteit Brussel
> Pleinlaan 2 / B-1050 Brussels / Belgium
> http://soft.vub.ac.be/~smarr
> Phone: +32 2 629 2974
> Fax: +32 2 629 3525
>
More information about the graal-dev
mailing list