--- old/src/share/vm/opto/stringopts.cpp Thu Jul 5 12:02:29 2012 +++ new/src/share/vm/opto/stringopts.cpp Thu Jul 5 12:02:28 2012 @@ -534,7 +534,22 @@ CallStaticJavaNode* csj = arg->in(0)->as_CallStaticJava(); if (csj->method() != NULL && csj->method()->intrinsic_id() == vmIntrinsics::_Integer_toString) { - sc->add_control(csj); + if (arg->outcnt() == 1) { + // _control is the list of StringBuilder calls nodes which + // will be eliminated by this String concatenation optimization. + // Integer::toString() call is not part of StringBuilder calls + // chain. It's node could be eliminated only if it's result + // is used only by this chain. + // An other limitation: it should be used only once because + // it is unknown that it is used only by this SB calls chain + // until all chain's nodes are collected. + // + // Note, it is fine to not eliminate Integer::toString() call + // node. It will be inlined later and it's code will fold if + // it's result is not used. + assert(arg->unique_out() == cnode, "sanity"); + sc->add_control(csj); + } sc->push_int(csj->in(TypeFunc::Parms)); continue; }