JDK-6892658 : C2 should optimize some stringbuilder patterns
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: hs17,hs22.5,6,7
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic,solaris_9,windows_xp
  • CPU: generic,x86,sparc
  • Submitted: 2009-10-16
  • Updated: 2018-12-05
  • Resolved: 2010-01-15
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7 Other
6u18Fixed 7Fixed hs16Fixed
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
There are many common patterns of string concatenation using StringBuilder that could be transformed into much more efficient patterns.  StringBuilder has some assumptions that it might be used in a persistent way that result in many extra copies and intermediate values being produced.  Transforming these patterns into an optimal set of string operations can greatly speed up these operations.

Doing this within in the context of hotspot has some extra complexity because of deoptimization.  It always has to be possible to recover a valid execution state where you can resume in the interpeter.  This we can handled by introducing a transactional style of code generation where an early JVMState capture the starting point and any uncommon traps lead back to that execution point.  Any code like allocations also reuses that point to describe the current state.

EVALUATION http://hg.openjdk.java.net/jdk7/hotspot-comp/hotspot/rev/7c57aead6d3e

EVALUATION http://hg.openjdk.java.net/hsx/hsx16/master/rev/1a1b644fe617

EVALUATION http://hg.openjdk.java.net/hsx/hsx16/baseline/rev/1a1b644fe617