[External] : Re: API to create a new Allocate node?

Vladimir Kozlov vladimir.kozlov at oracle.com
Fri Apr 29 22:06:58 UTC 2022


In such case you may not need Allocation node. You can try a simple new ideal node "ScalarObjectNode" which track 
allocation and its fields if there is guarantee that no safepoints in between. Something like SafePointScalarObjectNode 
but without referencing debug info (JVM state).

But I think you also need to consider more complex case: if there is Safepoint or Call between merge point and 
allocation reference after it:

if (...) {
    p0 = new Point();
} else {
    p1 = new Point();
}
foo(); // Allocation does not escape but it is refernced in debug info in JVMS of this call.
p = phi(p0, p1);
return p.x;

I am not sure we currently would handle such case when scalarizing allocations in macro.cpp.

Thanks,
Vladimir K

On 4/29/22 1:44 PM, Cesar Soares Lucas wrote:
> Thank you for taking the time to write a detailed explanation, John. That helps a lot!
> 
> One thing that perhaps I left implicit in my original comment: this new allocation shouldn't be part of the final code emitted by C2. The allocation will be used just to remove the phi node merging other objects and therefore EA+SR should be able to remove all allocations involved. Please, take a look at the example below.
> 
> C2 can't remove the allocations in the code below because of the Phi merging the objects:
> 
> if (...)
>     p0 = new Point();
> else
>     p1 = new Point();
> p = phi(p0, p1);
> return p.x;
> 
> What I'm proposing is to replace the Phi *temporarily* with an allocation like shown below. C2 should be able to scalar replace all three objects in the example.
> 
> if (...)
>     p0 = new Point(0);
> else
>     p1 = new Point(1);
> p = new Point(phi(p0.x, p1.x));
> return p.x;
> 
> In the final code we shouldn't have any allocation (and so no need to pick up a JVMS?!):
> 
> if (...)
>     x0 = 0;
> else
>     x1 = 1;
> px = phi(x0, x1);
> return px;
> 
> 
> Best regards,
> Cesar


More information about the hotspot-compiler-dev mailing list