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

String concat with many fields will cause c2 compilation failure

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • tbd
    • 25
    • hotspot

      Recently we find the problem from a real application. I write a demo test to reproduce it.

      Java app may use lombok to auto generate toString method and the generated code simply concat all fields. So my test define a class with 50 fields and annotated by "@Data" from lombok. When C2 try to compile the method, it will failed with "COMPILE SKIPPED: unsupported calling sequence (retry at different tier)" .

      My test output is like:
      9549 1808 b java.lang.String$$StringConcat/0x00007f7537000400::concat (716 bytes) COMPILE SKIPPED: unsupported calling sequence (retry at different tier)
      10147 1916 b java.lang.invoke.LambdaForm$DMH/0x00007f7537001000::invokeSpecial (114 bytes) COMPILE SKIPPED: unsupported calling sequence (retry at different tier)
      10934 2019 b java.lang.invoke.LambdaForm$DMH/0x00007f7537001400::invokeSpecial (116 bytes) COMPILE SKIPPED: unsupported calling sequence (retry at different tier)
      10961 2026 b java.lang.invoke.LambdaForm$BMH/0x00007f7537001800::reinvoke (117 bytes) COMPILE SKIPPED: unsupported calling sequence (retry at different tier)
      11182 2070 b java.lang.invoke.LambdaForm$MH/0x00007f7537001c00::invoke (125 bytes) COMPILE SKIPPED: unsupported calling sequence (retry at different tier)
      11306 2098 b java.lang.invoke.LambdaForm$MH/0x00007f7537002000::linkToTargetMethod (105 bytes) COMPILE SKIPPED: unsupported calling sequence (retry at different tier)


      C2 can support 90+ parameters for x86. Why does it fail with 50 parameter? After some investigation, I find new sealed class based string concat implementation will generate some helper functions like coder, length, They also need 50+ parameters as well. So for the concat method, it has 50 incoming parameters and 50 out parameters and break the limit.

      We can increase C2's register mark to handle more parameters. But generated toString can easily break the limit. I think we may change string concat factory to generate methods in chunk style, not handle all parameters in one method. I'm not sure if it is doable.

            Unassigned Unassigned
            kwei Kuai Wei
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: