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

Vladimir Kozlov vladimir.kozlov at oracle.com
Thu Apr 28 21:56:22 UTC 2022


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://urldefense.com/v3/__https://nam06.safelinks.protection.outlook.com/?url=https*3A*2F*2Fgithub.com*2Fopenjdk*2Fjdk*2Fblob*2Fmaster*2Fsrc*2Fhotspot*2Fshare*2Fopto*2Fstringopts.cpp*23L1746&data=05*7C01*7CDivino.Cesar*40microsoft.com*7C296007dba4ba437642a808da29598056*7C72f988bf86f141af91ab2d7cd011db47*7C1*7C0*7C637867761639761388*7CUnknown*7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0*3D*7C3000*7C*7C*7C&sdata=BYLXbO*2Fpkb*2BA2zR9Rh*2FG7VjHq3Q5J1k5WggE8B27Zj4*3D&reserved=0__;JSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSU!!ACWV5N9M2RV99hQ!MpvnBSQ1q7Mba90ZAGqiGWTXi-OiwLjc5vi2C1D_tB0vWFaXbvB0rLik_Ko0Ei0di9ReMZw8CMgdcRCOh98ko6fQWigZHMg$
> 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