RFR: 8262739: String inflation C2 intrinsic prevents insertion of anti-dependencies

Tobias Hartmann thartmann at openjdk.java.net
Tue Mar 16 11:18:24 UTC 2021


The string inflation intrinsic `StrInflatedCopyNode` which converts the String internal byte[] to char[] has `bottom_type` `Type::MEMORY`:
https://github.com/openjdk/jdk/blob/f71e8a61988cc9f095a4f034636baf04c3f48f77/src/hotspot/share/opto/intrinsicnode.hpp#L143-L145

Memory users (i.e. loads) should therefore be checked for nearby anti-dependent stores:
https://github.com/openjdk/jdk/blob/f71e8a61988cc9f095a4f034636baf04c3f48f77/src/hotspot/share/opto/node.cpp#L1482-L1486

However, since `InstructForm::captures_bottom_type` returns `false` for `StrInflatedCopyNode`, after matching, the corresponding `MachNode` version will have `bottom_type` `Type::BOTTOM` and no anti-dependency analysis will be performed for its users. Scheduling then incorrectly orders loads from the char array with anti-dependent stores to the same array, leading to incorrect results.

`StrCompressedCopyNode` does not need this because it has `TypeInt::INT` as  `bottom_type` (the memory output is handled via a `SCMemProjNode`):
https://github.com/openjdk/jdk/blob/f71e8a61988cc9f095a4f034636baf04c3f48f77/src/hotspot/share/opto/intrinsicnode.hpp#L131-L133

Thanks,
Tobias

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

Commit messages:
 - 8262739: String inflation C2 intrinsic prevents insertion of anti-dependencies

Changes: https://git.openjdk.java.net/jdk/pull/3025/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=3025&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8262739
  Stats: 65 lines in 2 files changed: 65 ins; 0 del; 0 mod
  Patch: https://git.openjdk.java.net/jdk/pull/3025.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/3025/head:pull/3025

PR: https://git.openjdk.java.net/jdk/pull/3025


More information about the hotspot-compiler-dev mailing list