RFR(S): 8136469: OptimizeStringConcat fails on pre-sized StringBuilder shapes
tobias.hartmann at oracle.com
Fri Sep 18 09:57:00 UTC 2015
please review the following patch.
When creating a pre-sized StringBuilder, C2's string concatenation optimization sometimes fails to optimize the chain (see ). The problem is that the initial size of the StringBuilder depends on a static final boolean that is initialized to true at runtime. Therefore the string concatenation control flow chain  contains an IfNode with a ConI (1) as input instead of the expected BoolNode and StringConcat::validate_control_flow() silently bails out.
I changed the implementation to skip dead tests as they would be removed by IGVN later anyway. I added an assert to make sure we don't bail out silently if the input of the IfNode is not a bool. I also had to change validate_mem_flow() to handle dead ifs. Further, the assert in line 825 is unnecessary because we execute the same check in as_If().
- New test (TestPresizedStringBuilder)
More information about the hotspot-compiler-dev