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

Cesar Soares Lucas Divino.Cesar at microsoft.com
Thu Apr 28 22:17:47 UTC 2022


> Yes, we use GraphKit in post Parse phases. StringOpts are called in inline_incrementally() after Parse.

Cool. Thanks!

> You can try to do this during parsing if there is Phi which *directly* points to allocations (CheckCastPP)
> only at merge point. I assume you are looking only on simple cases where there are such Phis.

My idea is to do this transformation only if the allocation doesn’t escape therefore, I can’t do it during parsing.

> I am not sure how it will help since you still need to generate Load
> nodes to initialize its fields and split them through Phi.

I’m still working on the idea so perhaps I overlooked something.
Splitting the loads (especially if they don’t have a control input) it’s not too hard AFAIU.
I’ll create some examples of what I’m thinking and share on the list.


Thanks,
Cesar

From: Vladimir Kozlov <vladimir.kozlov at oracle.com>
Date: Thursday, April 28, 2022 at 2:56 PM
To: Cesar Soares Lucas <Divino.Cesar at microsoft.com>, hotspot-compiler-dev at openjdk.java.net <hotspot-compiler-dev at openjdk.java.net>
Subject: Re: [External] : Re: API to create a new Allocate node?
On 4/28/22 2:29 PM, Cesar Soares Lucas wrote:
> Thanks, Vladimir.
>
>> Do you have correct jvm state at the point of insertion (to deoptimize correctly if needed)?
>
> I think I do. Is that the only requirement for getting GraphKit to work properly outside parsing? Generally speaking is it fair game to use GraphKit outside the parsing phase?

Yes, we use GraphKit in post Parse phases. StringOpts are called in inline_incrementally() after Parse.

>
>> Did you look on examples in `PhaseStringOpts::replace_string_concat`?:
>
> Yeah, I looked at a few examples and I'm able to instantiate it. However, I got some SEGFAULT when new_instance tries to create new nodes.
>
>> I suggest to clone original Allocate node (if you have it) and adjust its edges (input and outputs) if needed.
>
> I'll try that. Thanks! However, the biggest challenge seems to be which node is the correct node to connect the edges to/from!
>
> FYI, basically what I'm trying to do is to insert an object allocation at the place where we have an object allocation merge. Then later I'll initialize the fields of the newly allocated objects using phi functions for each individual field. etc.

You can try to do this during parsing if there is Phi which *directly* points to allocations (CheckCastPP) only at merge
point. I assume you are looking only on simple cases where there are such Phis.

I am not sure how it will help since you still need to generate Load nodes to initialize its fields and split them
through Phi.

Vladimir K

>
>
> Thanks!
> Cesar
>
> ________________________________________
> From: Vladimir Kozlov <vladimir.kozlov at oracle.com>
> Sent: April 28, 2022 1:55 PM
> To: Cesar Soares Lucas; hotspot-compiler-dev at openjdk.java.net
> Subject: Re: API to create a new Allocate node?
>
> We don't have specialized code which insert Alloacte node into random place.
> Do you have correct jvm state at the point of insertion (to deoptimize correctly if needed)?
>
> Did you look on examples in `PhaseStringOpts::replace_string_concat`?:
>
> https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Furldefense.com%2Fv3%2F__https%3A%2F%2Fnam06.safelinks.protection.outlook.com%2F%3Furl%3Dhttps*3A*2F*2Fgithub.com*2Fopenjdk*2Fjdk*2Fblob*2Fmaster*2Fsrc*2Fhotspot*2Fshare*2Fopto*2Fstringopts.cpp*23L1746%26amp%3Bdata%3D05*7C01*7CDivino.Cesar*40microsoft.com*7C296007dba4ba437642a808da29598056*7C72f988bf86f141af91ab2d7cd011db47*7C1*7C0*7C637867761639761388*7CUnknown*7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0*3D*7C3000*7C*7C*7C%26amp%3Bsdata%3DBYLXbO*2Fpkb*2BA2zR9Rh*2FG7VjHq3Q5J1k5WggE8B27Zj4*3D%26amp%3Breserved%3D0__%3BJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSU!!ACWV5N9M2RV99hQ!MpvnBSQ1q7Mba90ZAGqiGWTXi-OiwLjc5vi2C1D_tB0vWFaXbvB0rLik_Ko0Ei0di9ReMZw8CMgdcRCOh98ko6fQWigZHMg%24&data=05%7C01%7CDivino.Cesar%40microsoft.com%7C42d0700a9d1d4618dc1a08da2961f355%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637867797924479537%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=qCa060J%2BUloFlOr590rMHYT6Vy9z3ljjrLoWxMUmKcc%3D&reserved=0
> There is call to `new_instance()` at line 2032. But it works only by replacing existing call node `kit.replace_call()`.
>
> I suggest to clone original Allocate node (if you have it) and adjust its edges (input and outputs) if needed.
>
> Thanks,
> Vladimir K
>
> On 4/28/22 1:24 PM, Cesar Soares Lucas wrote:
>> Hi there!
>>
>> I have a quick question. I'm trying to implement an optimization idea in C2 and it requires me to insert Allocate nodes in some places in the IR graph. I'm wondering if there is already a method that I can use that creates the node and adds the necessary edges to surrounding nodes. I tried to use GraphKit::new_instance but after some failed attempts I got the impression that that class is not guaranteed to work outside the parsing phase.
>>
>>
>> Any advice would be appreciated.
>> Cesar


More information about the hotspot-compiler-dev mailing list