-
Enhancement
-
Resolution: Unresolved
-
P3
-
9, 10
There are many cases where C2 eliminates the array pre-zeroing followed by arraycopy into the array. However, there are cases where this surprisingly does not work.
For example, see this benchmark:
http://cr.openjdk.java.net/~shade/8146828/ArrayZeroingBench.java
http://cr.openjdk.java.net/~shade/8146828/benchmarks.jar
The most puzzling example is this:
@Benchmark
public Foo[] arraycopy_srcLength() {
Object[] src = this.src;
Foo[] dst = new Foo[size];
System.arraycopy(src, 0, dst, 0, src.length);
return dst;
}
@Benchmark
public Foo[] arraycopy_dstLength() {
Object[] src = this.src;
Foo[] dst = new Foo[size];
System.arraycopy(src, 0, dst, 0, dst.length);
return dst;
}
In srcLength case we successfully eliminate the pre-zeroing on destination array, while in dstLength we don't!
See "rep stos" in dstLength case, and no zeroing in srcLength case:
http://cr.openjdk.java.net/~shade/8146828/jdk9b99.perfasm
http://cr.openjdk.java.net/~shade/8146828/jdk9b99-size10.perfasm
For example, see this benchmark:
http://cr.openjdk.java.net/~shade/8146828/ArrayZeroingBench.java
http://cr.openjdk.java.net/~shade/8146828/benchmarks.jar
The most puzzling example is this:
@Benchmark
public Foo[] arraycopy_srcLength() {
Object[] src = this.src;
Foo[] dst = new Foo[size];
System.arraycopy(src, 0, dst, 0, src.length);
return dst;
}
@Benchmark
public Foo[] arraycopy_dstLength() {
Object[] src = this.src;
Foo[] dst = new Foo[size];
System.arraycopy(src, 0, dst, 0, dst.length);
return dst;
}
In srcLength case we successfully eliminate the pre-zeroing on destination array, while in dstLength we don't!
See "rep stos" in dstLength case, and no zeroing in srcLength case:
http://cr.openjdk.java.net/~shade/8146828/jdk9b99.perfasm
http://cr.openjdk.java.net/~shade/8146828/jdk9b99-size10.perfasm
- relates to
-
JDK-8253577 C2 should eliminate zeroing when filling tightly coupled array
- Open