Re: Graal - first step

Remi Forax forax at
Wed Apr 4 04:33:07 PDT 2012

The decision to profile or not should not be a global decision.

Let's take an example, delayed de-visualization.
Language like scalable or java8 allows to write high order functions that by example loop over a collection of items and call a block of code for each element.
From a VM point of view the call to the block of code is megamorphic. One way to devirtualize it is to let the interpreter to profile the code so we will have enough information to find which concrete high order function is called thus be able to inline it but instead of generating only a vtable call for the block call one can also add a code that will profile the type again.
Because the code was inclined, the block call is not megamorphic anymore and a second generation will be able to fully online the high order function call at callsite.
So deciding to insert profiling information should not be done globally.


Sent from my Phone

----- Reply message -----
From: "Thomas Wuerthinger" <thomas.wuerthinger at>
To: "Rémi Forax" <forax at>
Cc: <graal-dev at>
Subject: Graal - first step
Date: Wed, Apr 4, 2012 11:23

On 04.04.2012 00:16, Rémi Forax wrote:
>>> Another related problem is that there is currently no node that does 
>>> profiling so
>>> I can't generate a graph of nodes with profile information that I 
>>> will be able to extract
>>> using Graal interface with Hotspot.
>> It is possible to generate a node that will lower itself to a 
>> store/load to an object that is pointing to the profiling data. The 
>> Graal snippet mechanism would allow to specify the lowering in Java 
>> code (like we do with arraycopy intrinsification, see 
>> ArrayCopySnippets class). What kind of general-purpose interface 
>> would you suggest for weaving profiling code into the Graal IR?
> I think some nodes like IfNode, SwitchNode, InstanceOfNode etc. should 
> have a boolean
> asking for generating the record code, in order to record branch taken,
> type profile and exception seen.
> By example for IfNode, a boolean profileBranchTakenProbability will ask
> the code generator to generate the record code for each branch of the if.
> and as you said, a new phase should be introduced that will add new 
> Nodes (using snippet)
> to generate the record code where it should be generated.
We could add a phase that automatically inserts such code on every 
control split. What is the format / Java data structure in which you 
would like to have it recorded?

- thomas

More information about the graal-dev mailing list