Fri, 23 Aug 2013 18:04:35 -0700
8023472: C2 optimization breaks with G1
Summary: set control edge for previous value load in G1 pre-barrier
Reviewed-by: twisti
src/share/vm/opto/graphKit.cpp | file | annotate | diff | comparison | revisions | |
test/compiler/gcbarriers/G1CrashTest.java | file | annotate | diff | comparison | revisions |
1.1 --- a/src/share/vm/opto/graphKit.cpp Fri Aug 23 11:41:37 2013 -0700 1.2 +++ b/src/share/vm/opto/graphKit.cpp Fri Aug 23 18:04:35 2013 -0700 1.3 @@ -3595,7 +3595,7 @@ 1.4 if (do_load) { 1.5 // load original value 1.6 // alias_idx correct?? 1.7 - pre_val = __ load(no_ctrl, adr, val_type, bt, alias_idx); 1.8 + pre_val = __ load(__ ctrl(), adr, val_type, bt, alias_idx); 1.9 } 1.10 1.11 // if (pre_val != NULL)
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/test/compiler/gcbarriers/G1CrashTest.java Fri Aug 23 18:04:35 2013 -0700 2.3 @@ -0,0 +1,84 @@ 2.4 +/* 2.5 + * Copyright (c) 2013, 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 +/** 2.29 + * @test 2.30 + * @bug 8023472 2.31 + * @summary C2 optimization breaks with G1 2.32 + * 2.33 + * @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -Dcount=100000 G1CrashTest 2.34 + * 2.35 + * @author pbiswal@palantir.com 2.36 + */ 2.37 + 2.38 +public class G1CrashTest { 2.39 + static Object[] set = new Object[11]; 2.40 + 2.41 + public static void main(String[] args) throws InterruptedException { 2.42 + for (int j = 0; j < Integer.getInteger("count"); j++) { 2.43 + Object key = new Object(); 2.44 + insertKey(key); 2.45 + if (j > set.length / 2) { 2.46 + Object[] oldKeys = set; 2.47 + set = new Object[2 * set.length - 1]; 2.48 + for (Object o : oldKeys) { 2.49 + if (o != null) 2.50 + insertKey(o); 2.51 + } 2.52 + } 2.53 + } 2.54 + } 2.55 + 2.56 + static void insertKey(Object key) { 2.57 + int hash = key.hashCode() & 0x7fffffff; 2.58 + int index = hash % set.length; 2.59 + Object cur = set[index]; 2.60 + if (cur == null) 2.61 + set[index] = key; 2.62 + else 2.63 + insertKeyRehash(key, index, hash, cur); 2.64 + } 2.65 + 2.66 + static void insertKeyRehash(Object key, int index, int hash, Object cur) { 2.67 + int loopIndex = index; 2.68 + int firstRemoved = -1; 2.69 + do { 2.70 + if (cur == "dead") 2.71 + firstRemoved = 1; 2.72 + index--; 2.73 + if (index < 0) 2.74 + index += set.length; 2.75 + cur = set[index]; 2.76 + if (cur == null) { 2.77 + if (firstRemoved != -1) 2.78 + set[firstRemoved] = "dead"; 2.79 + else 2.80 + set[index] = key; 2.81 + return; 2.82 + } 2.83 + } while (index != loopIndex); 2.84 + if (firstRemoved != -1) 2.85 + set[firstRemoved] = null; 2.86 + } 2.87 +}