[aarch64-port-dev ] RFR(s): AArch64: 8149080: Recoginize disjoint array copy in stub code
hui.shi at linaro.org
Mon Feb 8 11:55:34 UTC 2016
> You're confusing me. String concatenation is a disjoint array copy.
> Therefore it always copies forwards, does it not?
Yes, it would be better JIT can recognize this at compile time. Previous
performance data is collected on Java8 (so copy is performed in short array
copy, while in JDK9 it is byte array copy). I check both JDK8 and JDK9,
both invoke Stub::jshort_arraycopy and Stub::jbyte_arraycopy. One reason
might be JIT time determination is not important as there is run time check
for disjoint array copy.
> > 1. Forward array copy can prefetch dest address needed in next string
> > append.
> So can backwards array copy, surely.
Could you please give more details about how backward array copy can also
utilize hardware prefetcher in multiple string append case?
> > 2. Backward array copy might cause much more unaligned memory access in
> > string append/concatenation.
> Okay, I see. That is fixable: we can make sure that there are no
> more misaligned accesses in either direction.
> > Perform forward array copy when possible will not make things worse and
> > benefit common cases like string append/concatenation. This is the
> > logic when generate conjoint array copy, this patch complete this logic
> > recognize all disjoint array copy. Does this make sense?
> Yes, but it's a kludge. I'd much rather fix backwards copies so that
> they were just as fast. If that's not possible then your patch may be
> acceptable, but I think we should first try to fix backwards copies.
> We should be able to fix this the *right way*, by using prefetch
> instructions and making sure copies are aligned where possible. When
> I did my testing misaligned fetches were quite fast, and it didn't
> seem worth the effort to fix it.
I agree inserting prefetch in backward copy and make backward array copy
more faster. For mis-aligned issue in backward array copy, we might copy in
1,2,4,8 order to make it align.
> But I'm really mystified by why String concatenation doesn't always
> use forward copies anyway.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the hotspot-compiler-dev