[15] RFR(S): 8235332: TestInstanceCloneAsLoadsStores.java fails with -XX:+StressGCM

Christian Hagedorn christian.hagedorn at oracle.com
Tue Jan 14 14:29:31 UTC 2020


Hi

Please review the following patch
http://cr.openjdk.java.net/~chagedorn/8235332/webrev.00/
https://bugs.openjdk.java.net/browse/JDK-8235332

An ArrayCopyNode for a clone is not inlined for more than 8 
(=ArrayCopyLoadStoreMaxElem) fields. Therefore, the test cases uses 9 
fields. There is a GC barrier for 109 ArrayCopy [1] when disabling 
ReduceInitialCardMarks which is not taken into account in the pattern 
matching check for a clone at [2] in ConnectionGraph::find_inst_mem() 
during escape analysis. As a result, 161 MemBarStoreStore is skipped and 
the search continues at 160 MergeMem and the result is set to 97 Proj at 
[3]. Escape Analysis will then optimize 171 LoadI to directly use the 
memory output of the uninitialized allocation instead of the output of 
the ArrayCopyNode because it thinks the memory is the same [4]. This 
bug, however, is only observed when enabling the StressGCM flag which 
emits the field loading code before the array copy code which results in 
reads from uninitialized memory.

The existing pattern matching code to find an ArrayCopyNode over the 
MergeMemNode is replaced by a pattern matching over the MemBarNode 
taking GC barriers into account.

Thank you!

Best regards,
Christian


[1] 
https://bugs.openjdk.java.net/secure/attachment/86398/array_copy_with_gc_barrier.png
[2] 
http://hg.openjdk.java.net/jdk/jdk/file/f7edb9ca045c/src/hotspot/share/opto/escape.cpp#l2749
[3] 
http://hg.openjdk.java.net/jdk/jdk/file/f7edb9ca045c/src/hotspot/share/opto/escape.cpp#l2765
[4] 
https://bugs.openjdk.java.net/secure/attachment/86397/field_load_wrong_memory.png


More information about the hotspot-compiler-dev mailing list