[lworld] RFR: 8253113: [lworld] [lw3] C1 should avoid copying element of flattened arrays when reading a sub-element
Frederic Parain
fparain at openjdk.java.net
Mon Sep 14 14:01:50 UTC 2020
Please review these changes optimizing access to flattened arrays in C1.
The optimization avoids unnecessary copies of intermediate values when the code accesses a sub-element of a flattened
array.
For instance, with the following code:
inline class Point { int x = 0, y = 0; }
void foo() {
Point[] array = new Point[10];
int i = array[1].x;
}
C1 used to create a new instance of Point, copy the content from the array, then reads the x field from this new
instance. With the optimization, C1 directly accesses the x field from the flattened array, and makes no heap
allocation.
A simple benchmark on the "int i = array[1].x;" line gives these results:
baseline:
Benchmark Mode Samples Score Score error Units
o.s.MyBenchmark.testArrayReads avgt 200 4.250 0.011 ns/op
optimized:
Benchmark Mode Samples Score Score error Units
o.s.MyBenchmark.testArrayReads avgt 200 2.228 0.004 ns/op
Thank you,
Fred
-------------
Commit messages:
- Remove debug message in unit test
- Renaming and cleanup
- Fix flattened sub-element access, add unit tests
- Fix white space
- Extend CFG format with information related to sub-element accesses
- Remove debugging code
- First implementation
Changes: https://git.openjdk.java.net/valhalla/pull/187/files
Webrev: https://webrevs.openjdk.java.net/?repo=valhalla&pr=187&range=00
Issue: https://bugs.openjdk.java.net/browse/JDK-8253113
Stats: 361 lines in 7 files changed: 316 ins; 2 del; 43 mod
Patch: https://git.openjdk.java.net/valhalla/pull/187.diff
Fetch: git fetch https://git.openjdk.java.net/valhalla pull/187/head:pull/187
PR: https://git.openjdk.java.net/valhalla/pull/187
More information about the valhalla-dev
mailing list