Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8362394

C2: Repeated stacked string concatenation fails with "Hit MemLimit" and other resourcing errors

XMLWordPrintable

      C2: String concatenation optimization fails with "Hit MemLimit". If we disable this limit, it hits another error: "assert(req < Compile::current()->max_node_limit() - NodeLimitFudgeFactor) failed: Input limit exceeded"

      In product, the test seems to hang.

      Code pattern:
      [...]
              s = new StringBuilder().append(s).append(s).toString();
              s = new StringBuilder().append(s).append(s).toString();
              s = new StringBuilder().append(s).append(s).toString();
              s = new StringBuilder().append(s).append(s).toString();
      [..]

      ===

      In TestStackedConcatsMany.java, a string of large size 2^24 is built. But even if half of those concats are removed resulting in a more reasonably sized 2^12 string, there's a later crash:

      78 assert(C->live_nodes() <= C->max_node_limit(), "Live Node limit exceeded limit");

      #0 src/hotspot/share/opto/node.cpp:78 in Node::verify_construction
      [...]
      # 7 src/hotspot/share/opto/stringopts.cpp:1558 in PhaseStringOpts::copy_string
      # 8 src/hotspot/share/opto/stringopts.cpp:1612 in PhaseStringOpts::replace_string_concat

      Less than 1000 live nodes before the call to replace_string_concat turns into 80000+ after.

      ===

      Maybe the optimization needs to be bounded somehow.

            dskantz Daniel Skantz
            dskantz Daniel Skantz
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: