StringBuilder buffer allocation support in compiler

John Rose john.r.rose at oracle.com
Thu Jun 5 21:16:11 UTC 2014


On Jun 5, 2014, at 12:27 PM, Laszlo Hornyak <laszlo.hornyak at gmail.com> wrote:

>     public static String sayHello(String name, int age) {
>         return "Hello " + name + ", this is your " + age + "th birthday";
>     }

Try this example (suitably wrapped) with -XX:-OptimizeStringConcat and  -XX:+OptimizeStringConcat.

You should see a substantial difference.  I saw 3x.

Pre-optimizing bytecode shapes (in javac) is usually a bad idea.  Bytecodes are best thought of as a portable representation of programmer intention, not a vehicle for optimization.

— John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20140605/f2f0e2b0/attachment.html>


More information about the compiler-dev mailing list