On constructors and compiler blackholes

Aleksey Shipilev shade at redhat.com
Wed Apr 13 17:18:55 UTC 2022


On 4/13/22 16:00, Aleksey Shipilev wrote:
> On 4/11/22 11:28, Andrew Haley wrote:
>> The significant difference is that if we use compiler blackholes, C2 omits all of
>> the fences that would usually be necessary. I guess that C2 detects that the
>> newly-constructed AtomicLong is non-escaping.
> 
> Reproduced.
> 
> I think EA needs some knowledge about Blackhole arguments after all. This hack seems to resolve this
> particular trouble.

Now being worked on here:
   https://bugs.openjdk.java.net/browse/JDK-8284848

It is not exactly the bug, because blackholes are declared to guard from DCE, not from other weird 
optimizations. It just happens that plain Java blackholes were implemented to deter advanced EA 
optimizations, and current compiler blackholes are weaker in that sense.

The fix for JDK-8284848 is supposed to get back to that status quo. I still need to think if that is 
indeed the best way forward. Opinions welcome!

-- 
Thanks,
-Aleksey



More information about the jmh-dev mailing list