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.