String concatenation tweaks

Aleksey Shipilev aleksey.shipilev at oracle.com
Thu May 14 22:06:39 UTC 2015


(finally found a slot to try this)

On 17.04.2015 20:11, Louis Wasserman wrote:
> I would be thrilled to see that level of magic, though that's probably
> beyond my personal abilities to implement or contribute as a patch.

It actually does not seem that scary. javac changes seem minimal,
because they basically mirror [1] what is already done for current
String concat and lambda desugaring.

JDK side of changes is not too scary as well [2], and it readily lends
itself to different implementation strategies, including precomputing
the argument lengths. I realized too late it does not check for argument
nullity properly, but this is a proof-of-concept patch anyway.

The real upside is that you can spell out the optimized implementation
in more familiar ASM, rather than in javac AST/IR. Since the indy
bootstrap runs once during the linkage, and we know a lot about the
callsite, we can even specialize for the cases Louis described
originally (i.e. two Strings).

I have also collected the notes here [3], and it seems precomputing the
lengths indeed supplements OptoStringConcat nicely (i.e. catches up when
OptoStringConcat fails). Although the benchmarking was very, very light.

Opinions, suggestions, pitchforks are welcome. We would probably need to
submit JEP at some point... volunteers?

Thanks,
-Aleksey.

[1]
http://cr.openjdk.java.net/~shade/scratch/string-concat-indy/patch-langtools-1.patch
[2]
http://cr.openjdk.java.net/~shade/scratch/string-concat-indy/patch-jdk-1.patch
[3] http://cr.openjdk.java.net/~shade/scratch/string-concat-indy/notes.txt

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20150515/8f72ec11/signature.asc>


More information about the compiler-dev mailing list