Truffle: share frame descriptor among cloned call targets

Stefan Marr java at stefan-marr.de
Wed Dec 3 14:48:28 UTC 2014


Hi:

Kind of related to this old thread:

I am having issues with current handling of splitting in Truffle/Graal and my handling of lexical scopes, spitting, and ensuring that the right frame descriptors are used for different copies of ASTs.

In TruffleSOM, when a method is split, all type-specific specialization information are also split, which includes frame descriptors. For blocks/lambdas embedded into a split method this means they are also copied and will use the frame descriptors of the correct copy of the outer scopes. Until recently, this all worked pretty well, and enabled completely independent specialization of frame types for all copies of a method.

However, with the change of the splitting API, I can’t guarantee the consistency of my ASTs anymore.
The main issue is that the recursive NodeUtil.cloneNode is used, without giving my any ability to fix up the ASTs after the cloning.

Before, I was able to do the cloning completely myself, and afterwards send a NodeVisitor over the tree to fix up all relevant nodes. With the current API design, that is not possible anymore. And for some reason, which I don’t entirely understand yet, cloning the root node in copy() myself, while NodeUtil.cloneNode is doing its thing, can lead to inconsistencies.

So, would it be possible to expose a hook or something, in which I can fix up my ASTs after you cloned it?
I remember there was also some discussion about this API change already, but I didn’t find it.

Best regards
Stefan



> On 29 Oct 2014, at 17:13, Andreas Woess <andreas.woess at jku.at> wrote:
> 
> Short answer: because it could break code in a few cases.
> 
> A shallowCopy() isn't really that useful anyway, since it also shares existing FrameSlot instances and thus also the FrameSlotKinds. You can still do a full copy by overriding the copy() method. We don't do this because it requires any nodes referencing FrameSlots to be updated which is hard to do reliably in the framework.
> I've recently experimented with making this unnecessary, but I can't say yet whether this is going to happen.
> 
> - andreas
> 
> On 28/10/14 08:51, Stefan Marr wrote:
>> Hi Andreas:
>> 
>> Could you elaborate a little on this change?
>> 
>>> On 28 Oct 2014, at 03:00, doug.simon at oracle.com wrote:
>>> 
>>> Changeset: be1316e633b5
>>> Author:    Andreas Woess <andreas.woess at jku.at>
>>> Date:      2014-10-27 14:33 +0100
>>> URL:       http://hg.openjdk.java.net/graal/graal/rev/be1316e633b5
>>> 
>>> Truffle: share frame descriptor among cloned call targets
>>> 
>>> ! graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/RootNode.java
>> I thought the idea was that the cloned AST trees can specialize themselves completely independently. Also with regard to the types in the frames. So, in TruffleSOM I am also making sure to clone the frame slots properly and clone all lexically embedded methods to have a proper match of descriptors and slot objects.
>> 
>> Is all this not necessary anymore?
>> 
>> Best regards
>> Stefan
>> 
> 

-- 
Stefan Marr
INRIA Lille - Nord Europe
http://stefan-marr.de/research/





More information about the graal-dev mailing list