[9] RFR(S): 8136469: OptimizeStringConcat fails on pre-sized StringBuilder shapes
Tobias Hartmann
tobias.hartmann at oracle.com
Fri Sep 18 09:57:00 UTC 2015
Hi,
please review the following patch.
https://bugs.openjdk.java.net/browse/JDK-8136469
http://cr.openjdk.java.net/~thartmann/8136469/webrev.00/
Problem:
When creating a pre-sized StringBuilder, C2's string concatenation optimization sometimes fails to optimize the chain (see [1]). 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 [2] contains an IfNode with a ConI (1) as input instead of the expected BoolNode and StringConcat::validate_control_flow() silently bails out.
Solution:
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().
Testing:
- New test (TestPresizedStringBuilder)
- JPRT
Thanks,
Tobias
[1] https://bugs.openjdk.java.net/secure/attachment/53220/TestPresizedStringBuilder.java
[2] https://bugs.openjdk.java.net/secure/attachment/53218/graph.png
More information about the hotspot-compiler-dev
mailing list