How to dump AST nodes of a small program (larger program works)?

Christian Humer christian.humer at gmail.com
Wed Jul 27 21:00:09 UTC 2016


Hi Sidharth,

As you have guessed correctly, the HelloWorld.sl program is too simple 
to cause any compilations. That's why you don't see any ASTs and graphs 
dumped to IGV.

You can choose modify HelloWorld.sl and add a loop similar to SumCall.sl 
so the hello world function gets hot enough to be compiled and dumped to 
IGV.
Besides that forcing a dump of the AST to IGV before compilation is not 
as easy as it probably should be. I cannot offer a simpler solution than 
modifying the SL program atm.

If you just want to see the AST. There is an easy way to print the AST 
to the console:
For that, modify SimpleLanguage and use the NodeUtil#printCompactTree 
utility to print the AST at a desired point in time. Please keep in mind 
that the resulting AST looks very different depending on if you print it 
before or after the first execution, as the AST specializes. If you want 
to print the uninitialized tree you might want to use the dumping 
utility in SLNodeFactory#finishFunction. If you want to print the AST 
after each execution, consider modifying 
SLDispatchNode#doDirect/doIndirect.

Hope this helps,

Cheers,
Christian


On 27.07.2016 05:47:34, "Sidharth Kshatriya" <sid.kshatriya at gmail.com> 
wrote:

>Hi,
>
>I am playing around with simplelanguage. To that end, I have a jvmci
>compiler, graal-core, truffle, mx etc. all setup as explained on 
>github.
>
>Something like:
>
>./sl -disassemble -dump tests/SumCall.sl
>
>works properly and I can see the AST/Compilation passes in igv. 
>However,
>something like
>
>./sl -disassemble -dump tests/HelloWorld.sl
>
>does not show anything in igv. The program simply prints the result and
>exists.
>
>Is this because this program is being purely run in the AST 
>interpreter?
>Its a trivial program, I know, but I want to see the AST.
>
>I'm on Truffle API 0.15 / jvmci 0.19-dev.
>
>Thanks,
>
>Sidharth



More information about the graal-dev mailing list