Truffle Node replacement problem caused by recursion

Wei Zhang ndrzmansn at gmail.com
Sun Nov 3 11:25:49 PST 2013


Hi Andreas,

The fix worked for me. Now I don't have to do anything special when rewriting.
Thanks and take care!

/Wei

---------------------------------------------------------------------------
Message: 3
Date: Tue, 29 Oct 2013 18:32:42 +0100
From: Andreas Woess <andreas.woess at jku.at>
Subject: Re: Truffle Node replacement problem caused by recursion
To: graal-dev at openjdk.java.net
Message-ID: <526FF13A.90401 at jku.at>
Content-Type: text/plain; charset=UTF-8

Hi Wei, Stefan, et al,

I've pushed a fix about a week ago that solves this problem including an
assertion that should trigger if you do anything wrong. Please update
and let me know whether everything works as expected now.

- andreas
--------------------------
Wei Zhang
Personal: NdrZmansN at Gmail.com



On Mon, Oct 21, 2013 at 7:10 AM, Thomas Wuerthinger
<thomas.wuerthinger at oracle.com> wrote:
> 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