[lworld] RFR: 8261037: [lworld] Assert during C2 compilation due to inconsistent JVMState at safepoint

Tobias Hartmann thartmann at openjdk.java.net
Fri Feb 5 08:38:02 UTC 2021


We assert when scalarizing an inline type in a safepoint because `debug_end()` (-> `_endoff`) of the attached `JVMState` is larger than `SafePointNode::_max`. I don't think JVMStates should be shared between safepoint nodes and I intend to fix this in mainline with [JDK-8261158](https://bugs.openjdk.java.net/browse/JDK-8261158).

Gory details:
In `PhaseIdealLoop::is_counted_loop`, we `// Check for immediately preceding SafePoint and remove` by cloning _SafePointNode1_ to _SafePointNode2_ without cloning the attached _JVMState_. Loop unswitching then clones the loop and therefore also clones _SafePointNode2_ to _SafePointNode3_, again without cloning the _JVMState_. All three safepoint nodes now share the same _JVMState_. An inline type is scalarized in _SafePointNode2_, increasing _JVMState_`::_endoff` to account for the fields. Once another inline type is scalarized in _SafePointNode3_,  _JVMState_`::_endoff ` is out of bounds of _SafePointNode3_`::_max`.

This fix refactors the code (which also serves as workaround because we now access `debug_end()` only after we updated it to the correct value for the current safepoint) and adds a regression test.

Best regards,
Tobias

-------------

Commit messages:
 - 8261037: [lworld] Assert during C2 compilation due to inconsistent JVMState at safepoint

Changes: https://git.openjdk.java.net/valhalla/pull/322/files
 Webrev: https://webrevs.openjdk.java.net/?repo=valhalla&pr=322&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8261037
  Stats: 35 lines in 3 files changed: 30 ins; 3 del; 2 mod
  Patch: https://git.openjdk.java.net/valhalla/pull/322.diff
  Fetch: git fetch https://git.openjdk.java.net/valhalla pull/322/head:pull/322

PR: https://git.openjdk.java.net/valhalla/pull/322


More information about the valhalla-dev mailing list