Mon, 27 Jun 2016 08:10:51 +0200
8160122: Backport of JDK-8159244 used wrong version of the JDK 9 fix
Summary: Correct backport of 8159244.
Reviewed-by: kvn
src/share/vm/opto/stringopts.cpp | file | annotate | diff | comparison | revisions | |
test/compiler/stringopts/TestStringObjectInitialization.java | file | annotate | diff | comparison | revisions |
1.1 --- a/src/share/vm/opto/stringopts.cpp Sat Jun 25 20:03:17 2016 +0100 1.2 +++ b/src/share/vm/opto/stringopts.cpp Mon Jun 27 08:10:51 2016 +0200 1.3 @@ -1641,16 +1641,11 @@ 1.4 } 1.5 kit.store_String_value(kit.control(), result, char_array); 1.6 1.7 - // Do not let stores that initialize this object be reordered with 1.8 - // a subsequent store that would make this object accessible by 1.9 - // other threads. 1.10 - // Record what AllocateNode this StoreStore protects so that 1.11 - // escape analysis can go from the MemBarStoreStoreNode to the 1.12 - // AllocateNode and eliminate the MemBarStoreStoreNode if possible 1.13 - // based on the escape status of the AllocateNode. 1.14 - AllocateNode* alloc = AllocateNode::Ideal_allocation(result, _gvn); 1.15 - assert(alloc != NULL, "should be newly allocated"); 1.16 - kit.insert_mem_bar(Op_MemBarStoreStore, alloc->proj_out(AllocateNode::RawAddress)); 1.17 + // The value field is final. Emit a barrier here to ensure that the effect 1.18 + // of the initialization is committed to memory before any code publishes 1.19 + // a reference to the newly constructed object (see Parse::do_exits()). 1.20 + assert(AllocateNode::Ideal_allocation(result, _gvn) != NULL, "should be newly allocated"); 1.21 + kit.insert_mem_bar(Op_MemBarRelease, result); 1.22 } else { 1.23 result = C->top(); 1.24 }
2.1 --- a/test/compiler/stringopts/TestStringObjectInitialization.java Sat Jun 25 20:03:17 2016 +0100 2.2 +++ b/test/compiler/stringopts/TestStringObjectInitialization.java Mon Jun 27 08:10:51 2016 +0200 2.3 @@ -27,6 +27,7 @@ 2.4 /* 2.5 * @test 2.6 * @bug 8159244 2.7 + * @requires vm.gc == "Parallel" | vm.gc == "null" 2.8 * @summary Verifies that no partially initialized String object escapes from 2.9 * C2's String concat optimization in a highly concurrent setting. 2.10 * This test triggers the bug in about 1 out of 10 runs.