Node specialization for a statically typed language?

Stefan Marr java at stefan-marr.de
Wed Jul 27 12:40:57 UTC 2016


Hi Gerard:

> On 27 Jul 2016, at 14:28, Gerard Krol <gerard at gerardkrol.nl> wrote:
> 
> With Cover[1] I'm implementing C/C++, which is statically typed. Currently
> I'm using a single Add node, like SimpleLanguage does, with specializations
> for long and double. Performance is fine, but I'm wondering if this is the
> optimal way.

Using separate typed add nodes would be beneficial for interpreter speed (i.e. running without Graal).
So, it can be preferable.


> Can't I just emit AddLong and AddDouble nodes? I think it would make the
> code a lot clearer, and save me from debugging code that picks the wrong
> specialization. If the parameters to the node are not correct during parse
> time I can just add a cast node in between.

I guess the details depend on your languages, but yes, separate nodes can work nicely.

Note however, that you might still want to do some specialization based on the Add semantics of your language.
Add comes in some languages with very specific overflow semantics that can be expensive to handle. So, there it is useful to speculate that adds don’t actually overflow.

Best regards
Stefan

-- 
Stefan Marr
Johannes Kepler Universität Linz
http://stefan-marr.de/research/





More information about the graal-dev mailing list