Tue, 19 Aug 2014 07:36:11 +0200
8048879: "unexpected yanked node" opto/postaloc.cpp:139
Summary: MemBarAcquireNode prevents deletion of dead LoadNNode. Added condition to 'has_special_unique_user' to trigger deletion.
Reviewed-by: kvn, iveresov
src/share/vm/opto/node.cpp | file | annotate | diff | comparison | revisions | |
test/compiler/membars/TestMemBarAcquire.java | file | annotate | diff | comparison | revisions |
1.1 --- a/src/share/vm/opto/node.cpp Fri Sep 05 15:10:41 2014 -0700 1.2 +++ b/src/share/vm/opto/node.cpp Tue Aug 19 07:36:11 2014 +0200 1.3 @@ -1093,6 +1093,9 @@ 1.4 if( this->is_Store() ) { 1.5 // Condition for back-to-back stores folding. 1.6 return n->Opcode() == op && n->in(MemNode::Memory) == this; 1.7 + } else if (this->is_Load()) { 1.8 + // Condition for removing an unused LoadNode from the MemBarAcquire precedence input 1.9 + return n->Opcode() == Op_MemBarAcquire; 1.10 } else if( op == Op_AddL ) { 1.11 // Condition for convL2I(addL(x,y)) ==> addI(convL2I(x),convL2I(y)) 1.12 return n->Opcode() == Op_ConvL2I && n->in(1) == this;
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/test/compiler/membars/TestMemBarAcquire.java Tue Aug 19 07:36:11 2014 +0200 2.3 @@ -0,0 +1,53 @@ 2.4 +/* 2.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.7 + * 2.8 + * This code is free software; you can redistribute it and/or modify it 2.9 + * under the terms of the GNU General Public License version 2 only, as 2.10 + * published by the Free Software Foundation. 2.11 + * 2.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 2.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 2.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 2.15 + * version 2 for more details (a copy is included in the LICENSE file that 2.16 + * accompanied this code). 2.17 + * 2.18 + * You should have received a copy of the GNU General Public License version 2.19 + * 2 along with this work; if not, write to the Free Software Foundation, 2.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2.21 + * 2.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2.23 + * or visit www.oracle.com if you need additional information or have any 2.24 + * questions. 2.25 + */ 2.26 + 2.27 +/* 2.28 + * @test TestMemBarAcquire 2.29 + * @bug 8048879 2.30 + * @summary "Tests optimization of MemBarAcquireNodes" 2.31 + * @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation TestMemBarAcquire 2.32 + */ 2.33 +public class TestMemBarAcquire { 2.34 + private volatile static Object defaultObj = new Object(); 2.35 + private Object obj; 2.36 + 2.37 + public TestMemBarAcquire(Object param) { 2.38 + // Volatile load. MemBarAcquireNode is added after the 2.39 + // load to prevent following loads from floating up past. 2.40 + // StoreNode is added to store result of load in 'obj'. 2.41 + this.obj = defaultObj; 2.42 + // Overrides 'obj' and therefore makes previous StoreNode 2.43 + // and the corresponding LoadNode useless. However, the 2.44 + // LoadNode is still connected to the MemBarAcquireNode 2.45 + // that should now release the reference. 2.46 + this.obj = param; 2.47 + } 2.48 + 2.49 + public static void main(String[] args) throws Exception { 2.50 + // Make sure TestMemBarAcquire::<init> is compiled 2.51 + for (int i = 0; i < 100000; ++i) { 2.52 + TestMemBarAcquire p = new TestMemBarAcquire(new Object()); 2.53 + } 2.54 + } 2.55 +} 2.56 +