RFR: 8271600: C2: CheckCastPP which should closely follow Allocate is sunk of a loop
Vladimir Ivanov
vlivanov at openjdk.java.net
Mon Aug 23 08:40:29 UTC 2021
On Fri, 20 Aug 2021 12:02:25 GMT, Vladimir Ivanov <vlivanov at openjdk.org> wrote:
> `PhaseIdealLoop::try_sink_out_of_loop()` tries to move nodes outside a loop. It doesn't work well for cast nodes which accompany `Allocate` nodes: the cast reifies the effect instance initialization and turns a raw pointer into an oop. Once the cast node doesn't immediately follow the corresponding `Initialize`, it creates a window where the raw pointer is observed. And it can become so wide that the raw pointer crosses a safepoint and has to be recorded in the oop map (that's the case when the reported assertion failure happens).
>
> Proposed fix is to keep such cast nodes intact. Moreover, I propose to disable the optimization for all flavors of cast nodes.
> Cast nodes usually accompany runtime checks and I don't see much benefit in moving the cast node away while leaving the runtime check inside the loop.
>
> Testing: hs-tier1 - hs-tier6
Thanks for the review, Christian.
I took a look at JDK-8272562. Your analysis looks reasonable, but I'm still curious whether the problem is specific to cast nodes. My understanding is the general problem stems from the fact that a computation may be sunk into an effectively dead path. When C2 can't prove that the branch is dead, the dying computation on that path corrupts the graph. Do we need to introduce a more robust solution to guarantee the corruption never happens?
-------------
PR: https://git.openjdk.java.net/jdk/pull/5199
More information about the hotspot-compiler-dev
mailing list