RFR: 8357105: C2: compilation fails with "assert(false) failed: empty program detected during loop optimization"

SendaoYan syan at openjdk.org
Fri May 23 02:44:51 UTC 2025


On Thu, 22 May 2025 15:19:08 GMT, Daniel Skantz <dskantz at openjdk.org> wrote:

> This pull request contains a fix for JDK-8357105.
> 
> The problem is performing stacked string concatenation optimization between a pair of StringBuilder.append().toString()-links SB1 and SB2, where the parameter of an append call in SB2 has a complex dependency on the result of SB1, which in turn is replaced by top() during stringopts -- similar to JDK-8271341, which had a diamond if-structure using the result of SB1, while in this case the use is an unstable If. In the attached regression test, a live part of the graph gets optimized away during later phases and ultimately the whole graph vanishes.
> 
> The proposed solution is to simply exclude this specific case. This bug has existed for a long time and stacked concats is a niche optimization.
> 
> Testing:
> Tier1-4.
> 
> Extra testing:
> Ran Tier1-4 with an instrumented build and observed that we do not disable stacked concatenation in any previously known case after the fix.

Changes requested by syan (Committer).

test/hotspot/jtreg/compiler/stringopts/TestStackedConcatsAppendUncommonTrap.java line 38:

> 36: 
> 37:     public static void main (String... args) {
> 38:         for (int i = 0; i < 1_000_000; i ++) {

How about `i ++` replaced as `i++`. The whitespace seems do not need.

test/hotspot/jtreg/compiler/stringopts/TestStackedConcatsAppendUncommonTrap.java line 39:

> 37:     public static void main (String... args) {
> 38:         for (int i = 0; i < 1_000_000; i ++) {
> 39:             f(" ");

Should we use the function return value, to avoid the compiler do the dead code elimination optimization

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

PR Review: https://git.openjdk.org/jdk/pull/25395#pullrequestreview-2863000077
PR Review Comment: https://git.openjdk.org/jdk/pull/25395#discussion_r2103686850
PR Review Comment: https://git.openjdk.org/jdk/pull/25395#discussion_r2103690822


More information about the hotspot-compiler-dev mailing list