Truffle CallNode API
Christian Humer
christian.humer at gmail.com
Sun Mar 9 21:28:31 UTC 2014
Hi Stefan,
On Sun, Mar 9, 2014 at 8:42 PM, Stefan Marr <java at stefan-marr.de> wrote:
> For instance, the lookup of globals goes from uninitialized to cached,
> because it simply looks up the association object (key, global value). So,
> is the 'cached' class a specialized or generic one? Does the distinction
> have an influence on your heuristic?
>
I am not yet sure how to do the exact distinction of kinds. Often it is
hard to categorize. If you are not sure, you can leave them as specialized
for now. That will do no harm (while generic or polymorphic could).
A generic version of a node is a node which encodes the full operation in
the node. It is kind of the worst case specialization. A generic version is
considered expensive. However if the generic version is the only
specialization that is available I would mark that node as specialized for
now otherwise the enclosing method will always get split.
I would consider a cache chain as polymorphic as soon as there are two or
more entries. If there are less than two entries it could be considered
specialized.
I solved this for simple language using this pattern:
@Override
public Kind getKind() {
return nextNode.getKind() == Kind.UNINITIALIZED ?
Kind.SPECIALIZED : Kind.POLYMORPHIC;
}
For a cache chain with n entries the heuristic will get the information
that n - 1 nodes are polymorphic. If the cache chain gets to big it should
rewrite the chain with a node that is marked as generic/megamorphic.
The heuristic counts the number of polymorphic and generic marked nodes. It
uses this information to determine if it should split or not (beside some
other criteria). However I am not yet sure how the heuristic will look like
in the end. Maybe it will just always split if there is a polymorphic
and/or generic node contained in the method. So the exact number of
polymorphic and/or generic nodes may not be required in the end. It is even
possible that we will drop this idea of counting polymorphic/generic nodes
for the split heuristic completely ;).
- Christian Humer
More information about the graal-dev
mailing list