[External] : Re: RFC - Improving C2 Escape Analysis

Vladimir Kozlov vladimir.kozlov at oracle.com
Sat Oct 30 00:27:34 UTC 2021


On 10/29/21 4:50 PM, Cesar Soares Lucas wrote:
> Hi Vladimir and Tobias,
> 
>  >> Sure, here are four examples of EA and/or scalarization failing due to
>  >> complicated control/data flow:
>  >> https://cr.openjdk.java.net/~thartmann/EA_examples
> 
>  >> There are 2 test files with small methods for different EA cases I used to
>  >> see how EA works:
>  >>
>  >> test/hotspot/jtreg/compiler/escapeAnalysis/Test6726999.java
>  >> test/hotspot/jtreg/compiler/escapeAnalysis/Test6689060.java
> 
> Thank you for the examples, Tobias/Vladimir. This is being very helpful.
> 
>  >> Yes, finding solution for allocation merges (or NULL) is a pain. I spent
>  >> some time investigating possible solutions for it but "no cigar". May be we
>  >> do indead need control flow analysis to resolve this.
> 
> By "need control flow analysis" you mean the flow-sensitive EA algorithm? My

Yes.

To clarify. I investigated solutions in current flow-insensitive EA.

> first idea to handle these control/data-merge issues was to implement in C2 the
> same algorithm used by GRAAL - i.e., the algorithm described in Stadler et. al
> PEA paper. Do you think this is reasonable?

Yes, I think it would be good to have a prototype if you are comfortable to work with C2 code already.
I proposed small RFEs just for warmup ;)

> 
>  >> I am currently looking on iterative EA. Do more EA rounds if we can
>  >> eliminate more connected allocations. It was proposed by Vladimir Ivanov and
>  >> I have working prototype.
> 
> Cool! I'm curious, when do you plan to submit a Pull Request for this?

I am investigating regressions in some benchmarks.

> 
>  >> There is also suggestion from Amazon Java group about "C2 Partial Escape
>  >> Analysis" which needs more discussion:
>  >> https://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/2021-May/047486.html
> 
> I'd love to hear from them about their experience with these issues and if they
> have any plans to work on this moving forward! I'll ping them on the thread
> that you linked above.

Yes, I would like them to participate too (CCing to Paul). They sent proposal almost 6 months ago and we did not hear 
any additional information after Vladimir Ivanov replied.

Regards,
Vladimir K

> 
> 
> Regards,
> Cesar
> ------------------------------------------------------------------------------------------------------------------------
> *From:* Vladimir Kozlov <vladimir.kozlov at oracle.com>
> *Sent:* October 27, 2021 10:26 AM
> *To:* Tobias Hartmann <tobias.hartmann at oracle.com>; Cesar Soares Lucas <Divino.Cesar at microsoft.com>; Ron Pressler 
> <ron.pressler at oracle.com>
> *Cc:* John Rose <john.r.rose at oracle.com>; Mark Reinhold <mark.reinhold at oracle.com>; hotspot-dev at openjdk.java.net 
> <hotspot-dev at openjdk.java.net>; Brian Stafford <Brian.Stafford at microsoft.com>; Martijn Verburg 
> <Martijn.Verburg at microsoft.com>
> *Subject:* Re: [External] : Re: RFC - Improving C2 Escape Analysis
> First. Thank you, Cesar, for collecting data about C2 EA shortcomings.
> 
> I agree with cases Tobias pointed as possible starting points to improve EA.
> 
> Yes, finding solution for allocation merges (or NULL) is a pain. I spent some time investigating possible solutions for
> it but "no cigar". May be we do indead need control flow analysis to resolve this.
> 
> I looked through JBS and found few issues which are not required to write new EA:
> 
> https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugs.openjdk.java.net%2Fbrowse%2FJDK-7149991&data=04%7C01%7CDivino.Cesar%40microsoft.com%7C63920cb1798f48c3487508d9996efd44%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637709524262611242%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=QrR7%2BGxXon4ToV6x3PhtQzZGl5tF7f1RUDbEi2AMTqA%3D&reserved=0 
> <https://urldefense.com/v3/__https://nam06.safelinks.protection.outlook.com/?url=https*3A*2F*2Fbugs.openjdk.java.net*2Fbrowse*2FJDK-7149991&data=04*7C01*7CDivino.Cesar*40microsoft.com*7C63920cb1798f48c3487508d9996efd44*7C72f988bf86f141af91ab2d7cd011db47*7C1*7C0*7C637709524262611242*7CUnknown*7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0*3D*7C1000&sdata=QrR7*2BGxXon4ToV6x3PhtQzZGl5tF7f1RUDbEi2AMTqA*3D&reserved=0__;JSUlJSUlJSUlJSUlJSUlJSUlJQ!!ACWV5N9M2RV99hQ!Y9n_pFC3a0ZG4KrWKJhrn9mlogJtuWmPqPlYgyNTBHWD2o2yhpaz9QpDsRbFhx0nlxftOg$>
> https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugs.openjdk.java.net%2Fbrowse%2FJDK-8059378&data=04%7C01%7CDivino.Cesar%40microsoft.com%7C63920cb1798f48c3487508d9996efd44%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637709524262611242%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=rsMHgOyTDYF%2B%2Ba38jGeown5TcZfIEDucAWI5QuAaTd4%3D&reserved=0 
> <https://urldefense.com/v3/__https://nam06.safelinks.protection.outlook.com/?url=https*3A*2F*2Fbugs.openjdk.java.net*2Fbrowse*2FJDK-8059378&data=04*7C01*7CDivino.Cesar*40microsoft.com*7C63920cb1798f48c3487508d9996efd44*7C72f988bf86f141af91ab2d7cd011db47*7C1*7C0*7C637709524262611242*7CUnknown*7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0*3D*7C1000&sdata=rsMHgOyTDYF*2B*2Ba38jGeown5TcZfIEDucAWI5QuAaTd4*3D&reserved=0__;JSUlJSUlJSUlJSUlJSUlJSUlJSU!!ACWV5N9M2RV99hQ!Y9n_pFC3a0ZG4KrWKJhrn9mlogJtuWmPqPlYgyNTBHWD2o2yhpaz9QpDsRbFhx3fmFwUkA$>
> https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugs.openjdk.java.net%2Fbrowse%2FJDK-8073358&data=04%7C01%7CDivino.Cesar%40microsoft.com%7C63920cb1798f48c3487508d9996efd44%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637709524262611242%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=CypHNEd5B5EymTYMnF6jf30LspY6sBqXoz1sypE2tSg%3D&reserved=0 
> <https://urldefense.com/v3/__https://nam06.safelinks.protection.outlook.com/?url=https*3A*2F*2Fbugs.openjdk.java.net*2Fbrowse*2FJDK-8073358&data=04*7C01*7CDivino.Cesar*40microsoft.com*7C63920cb1798f48c3487508d9996efd44*7C72f988bf86f141af91ab2d7cd011db47*7C1*7C0*7C637709524262611242*7CUnknown*7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0*3D*7C1000&sdata=CypHNEd5B5EymTYMnF6jf30LspY6sBqXoz1sypE2tSg*3D&reserved=0__;JSUlJSUlJSUlJSUlJSUlJSUl!!ACWV5N9M2RV99hQ!Y9n_pFC3a0ZG4KrWKJhrn9mlogJtuWmPqPlYgyNTBHWD2o2yhpaz9QpDsRbFhx2VVMtprg$>
> https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugs.openjdk.java.net%2Fbrowse%2FJDK-8155769&data=04%7C01%7CDivino.Cesar%40microsoft.com%7C63920cb1798f48c3487508d9996efd44%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637709524262611242%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=BE170%2BZrn2c2%2FDLcijZsol25q2zY5X5idHXXwjCn7ug%3D&reserved=0 
> <https://urldefense.com/v3/__https://nam06.safelinks.protection.outlook.com/?url=https*3A*2F*2Fbugs.openjdk.java.net*2Fbrowse*2FJDK-8155769&data=04*7C01*7CDivino.Cesar*40microsoft.com*7C63920cb1798f48c3487508d9996efd44*7C72f988bf86f141af91ab2d7cd011db47*7C1*7C0*7C637709524262611242*7CUnknown*7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0*3D*7C1000&sdata=BE170*2BZrn2c2*2FDLcijZsol25q2zY5X5idHXXwjCn7ug*3D&reserved=0__;JSUlJSUlJSUlJSUlJSUlJSUlJSU!!ACWV5N9M2RV99hQ!Y9n_pFC3a0ZG4KrWKJhrn9mlogJtuWmPqPlYgyNTBHWD2o2yhpaz9QpDsRbFhx3hRRGkQg$>
> 
> Tobias also has fix prototype for next bug which was not fixed yet:
> https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugs.openjdk.java.net%2Fbrowse%2FJDK-8236493&data=04%7C01%7CDivino.Cesar%40microsoft.com%7C63920cb1798f48c3487508d9996efd44%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637709524262611242%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=fqaQ7zhAHGdsnUcw7wjA6c4XX96Aaa3acTIzc6%2FJXmY%3D&reserved=0 
> <https://urldefense.com/v3/__https://nam06.safelinks.protection.outlook.com/?url=https*3A*2F*2Fbugs.openjdk.java.net*2Fbrowse*2FJDK-8236493&data=04*7C01*7CDivino.Cesar*40microsoft.com*7C63920cb1798f48c3487508d9996efd44*7C72f988bf86f141af91ab2d7cd011db47*7C1*7C0*7C637709524262611242*7CUnknown*7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0*3D*7C1000&sdata=fqaQ7zhAHGdsnUcw7wjA6c4XX96Aaa3acTIzc6*2FJXmY*3D&reserved=0__;JSUlJSUlJSUlJSUlJSUlJSUlJQ!!ACWV5N9M2RV99hQ!Y9n_pFC3a0ZG4KrWKJhrn9mlogJtuWmPqPlYgyNTBHWD2o2yhpaz9QpDsRbFhx2urgFigw$>
> 
> Ther are 2 test files with small methods for different EA cases I used to see how EA works:
> 
> test/hotspot/jtreg/compiler/escapeAnalysis/Test6726999.java
> test/hotspot/jtreg/compiler/escapeAnalysis/Test6689060.java
> 
> You can start looking on above RFE/bug or run these tests and see why scalarization failed for some cases. Except for
> known merge issue:
> 
> https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugs.openjdk.java.net%2Fbrowse%2FJDK-6853701&data=04%7C01%7CDivino.Cesar%40microsoft.com%7C63920cb1798f48c3487508d9996efd44%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637709524262621193%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=F%2Bz1CFuCK6ZgXi5%2FWOcOgBWuXKeap0oZJh4873QKRgk%3D&reserved=0 
> <https://urldefense.com/v3/__https://nam06.safelinks.protection.outlook.com/?url=https*3A*2F*2Fbugs.openjdk.java.net*2Fbrowse*2FJDK-6853701&data=04*7C01*7CDivino.Cesar*40microsoft.com*7C63920cb1798f48c3487508d9996efd44*7C72f988bf86f141af91ab2d7cd011db47*7C1*7C0*7C637709524262621193*7CUnknown*7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0*3D*7C1000&sdata=F*2Bz1CFuCK6ZgXi5*2FWOcOgBWuXKeap0oZJh4873QKRgk*3D&reserved=0__;JSUlJSUlJSUlJSUlJSUlJSUlJSU!!ACWV5N9M2RV99hQ!Y9n_pFC3a0ZG4KrWKJhrn9mlogJtuWmPqPlYgyNTBHWD2o2yhpaz9QpDsRbFhx1olloG2Q$>
> 
> I am currently looking on iterative EA. Do more EA rounds if we can eliminate more connected allocations. It was
> proposed by Vladimir Ivanov and I have working prototype.
> 
> There is also suggestin from Amazon Java group about "C2 Partial Escape Analysis" which needs more discsussion:
> https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.openjdk.java.net%2Fpipermail%2Fhotspot-compiler-dev%2F2021-May%2F047486.html&data=04%7C01%7CDivino.Cesar%40microsoft.com%7C63920cb1798f48c3487508d9996efd44%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637709524262621193%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=QFszHSDnPkYLBkjqzNkmU92P6VlBFSok1mOku5sNudw%3D&reserved=0 
> <https://urldefense.com/v3/__https://nam06.safelinks.protection.outlook.com/?url=https*3A*2F*2Fmail.openjdk.java.net*2Fpipermail*2Fhotspot-compiler-dev*2F2021-May*2F047486.html&data=04*7C01*7CDivino.Cesar*40microsoft.com*7C63920cb1798f48c3487508d9996efd44*7C72f988bf86f141af91ab2d7cd011db47*7C1*7C0*7C637709524262621193*7CUnknown*7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0*3D*7C1000&sdata=QFszHSDnPkYLBkjqzNkmU92P6VlBFSok1mOku5sNudw*3D&reserved=0__;JSUlJSUlJSUlJSUlJSUlJSUlJSU!!ACWV5N9M2RV99hQ!Y9n_pFC3a0ZG4KrWKJhrn9mlogJtuWmPqPlYgyNTBHWD2o2yhpaz9QpDsRbFhx2tIPFENw$>
> 
> Thanks,
> Vladimir K
> 
> On 10/27/21 3:04 AM, Tobias Hartmann wrote:
>> Hi Cesar,
>> 
>> On 27.10.21 08:20, Cesar Soares Lucas wrote:
>>> Right. I was suspecting this to be the most critical issue indeed. However, I
>>> didn't know there was a case where "... the object does not escape on any paths
>>> but control flow is too complicated for EA to prove that." Is this an issue
>>> tracked in JBS or perhaps you can show me an example where this happens?
>> 
>> Sure, here are four examples of EA and/or scalarization failing due to complicated control/data
>> flow: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcr.openjdk.java.net%2F~thartmann%2FEA_examples&data=04%7C01%7CDivino.Cesar%40microsoft.com%7C63920cb1798f48c3487508d9996efd44%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637709524262621193%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=YbaF4T0zt9dle23nulvUWWLktuTvaWFWENQHD7Q13CE%3D&reserved=0 
> <https://urldefense.com/v3/__https://nam06.safelinks.protection.outlook.com/?url=https*3A*2F*2Fcr.openjdk.java.net*2F*thartmann*2FEA_examples&data=04*7C01*7CDivino.Cesar*40microsoft.com*7C63920cb1798f48c3487508d9996efd44*7C72f988bf86f141af91ab2d7cd011db47*7C1*7C0*7C637709524262621193*7CUnknown*7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0*3D*7C1000&sdata=YbaF4T0zt9dle23nulvUWWLktuTvaWFWENQHD7Q13CE*3D&reserved=0__;JSUlJX4lJSUlJSUlJSUlJSUlJQ!!ACWV5N9M2RV99hQ!Y9n_pFC3a0ZG4KrWKJhrn9mlogJtuWmPqPlYgyNTBHWD2o2yhpaz9QpDsRbFhx03YEOG3w$>
>> 
>> All examples would completely fold with inline types (Valhalla).
>> 
>> I'm not sure if these issues are tracked by JBS issues but there's most likely an overlap with some
>> of the issues you already described.
>> 
>> Best regards,
>> Tobias
>> 


More information about the hotspot-dev mailing list