+TraceTruffleCompilation: More detailed infos on optimization

Andreas Woess andreas.woess at jku.at
Tue Sep 30 14:30:03 UTC 2014

Hi Gero,

On 2014-09-30 13:06, Gero Leinemann wrote:
> Hi Christian,
>>> a) the function which got called and
>> CallTarget#toString() delegates to RootNode#toString() which is
>> controlled by the guest language.  So feel free to implement your own
>> overwritten version of RootNode#toString() in R that fits your need
>> to identify the guest language function.
> yes. I wanted to stress the point that a function is most easily
> identified by the name of the variable it's assigned to, which is a
> property of the call site and not the function/CallTarget itself.
> Instead of modifying "RootNode.toString" or implement
> "getDebugProperties()", it'd be useful to be able to pass information
> from the call site, too.
I'd argue a function is best identified by its source location and it's
useful to capture the name at function assignment as an identifier (at
parse time), which is not a property of the call site. If I understand
you correctly, then for this piece of code:
name = function() { bla }; other = name; other();
you would identify "other" as the function name rather than "name"?
>>> b) from where it got called,
>> Do you mean the call site that made the CallTarget hot? We could just
>> go up the guest language stack trace once to see where it got hot.
>> How did you implement that, and can you give me an example output
>> with your modifications?
> The call site that triggered the "compile()", yes. Because R needs to
> know how each function was called (at least for error messages, maybe
> even for introspection), we store the SourceSection of the call site
> (say, "f(x, y)") in the frame.
> I extract it in "OptimizedCallTarget.interpreterCall", pass it down to
> "OptimizedCallTargetLog.logOptimizingDone" and add it as output
> property so a line looks like this:
>> [truffle] opt done         function(item, depth) {\n    if (depth ==
>> 0L)\n      <opt>  |ASTSize 324 (5/0) |Time  3212(2115+1097)ms
>> |*CallSrc tree(left_item, next_depth)* |CallNodes I     0/D     2
>> |GraalNodes  4201/ 4193 |CodeSize        19749 |Source
>> /home/gero/oracle-dev/r/r_benchmarks/r.benchmarks/bin/r/benchmarks/shootout/shootout-binarytrees.r:8
> Maybe it's possible to "simply" forward the SourceSection information
> present in the OptimizedDirectCallNode to the
> "OptimizedCallTarget.compile" (and so on), but I don't know how to do
> this without changing the "CallTarget.call(args)" signature, which is
> not desired I guess. 
If you need access to caller frames or call nodes in R you could just
use TruffleRuntime#iterateFrames (or getCallerFrame). For that, you
don't need the SourceSection in the frame. But it sounds like you're
mixing two problems here: getting the call node from within R (error
messages) vs. for compilation logging. I'm not convinced it is useful to
refer to the call site that triggered the compile(). There can be any
number of call sites per call target and which one triggers may depend
on compilation policy. What is it good for?

- andreas

More information about the graal-dev mailing list