[lworld] RFR: 8255046: [lworld] JIT should make use of array layout encoding in markWord

Tobias Hartmann thartmann at openjdk.java.net
Thu Nov 12 13:41:23 UTC 2020


This patch re-implements the flat array check in C1 and C2 by using the mark word bits instead of the layout helper from the array Klass (see [JDK-8247299](https://bugs.openjdk.java.net/browse/JDK-8247299)). Unfortunately, this turned out to be far from trivial to implement in C2.

I've introduced a new FlatArrayCheck macro node to wrap the logic of the new check and to make it easier for the loop unswitching optimization to detect and hoist the check. One major problem is that we can't use immutable memory anymore because we are loading the mark word which is mutable (`AliasType::_is_rewritable` is `true`). Although the bits we are interested in are in fact immutable (we check for `markWord::unlocked_value`), we need to use raw memory to not break anti dependency analysis. As a result, flat array checks are not hoisted out of loops anymore and loop unswitching fails. `PhaseIdealLoop::move_flat_array_check_out_of_loop` will attempt to still move flat array checks out of loops by walking up the memory edge to before the loop and re-wiring the check accordingly.

This patch also fixes an existing issue in Escape Analysis that was only triggered now that we are able to fold the flat array check in more cases due to the `::Ideal`/`::Value `transformations.

@kuksenko, could you please evaluate performance of this change? Disabling the `UseArrayMarkWordCheck` flag allows to switch back to the old check using the layout helper.

Thanks,
Tobias

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

Commit messages:
 - Removed trailing whitespace
 - 8255046: [lworld] JIT should make use of array layout encoding in markWord

Changes: https://git.openjdk.java.net/valhalla/pull/256/files
 Webrev: https://webrevs.openjdk.java.net/?repo=valhalla&pr=256&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8255046
  Stats: 665 lines in 19 files changed: 570 ins; 42 del; 53 mod
  Patch: https://git.openjdk.java.net/valhalla/pull/256.diff
  Fetch: git fetch https://git.openjdk.java.net/valhalla pull/256/head:pull/256

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


More information about the valhalla-dev mailing list