Mon, 31 Aug 2015 17:20:08 +0200
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
Summary: Bad rewiring of memory edges when we split unique types during EA
Reviewed-by: kvn
src/share/vm/opto/escape.cpp | file | annotate | diff | comparison | revisions | |
test/compiler/escapeAnalysis/TestEABadMergeMem.java | file | annotate | diff | comparison | revisions |
1.1 --- a/src/share/vm/opto/escape.cpp Thu Oct 08 09:38:24 2015 +0200 1.2 +++ b/src/share/vm/opto/escape.cpp Mon Aug 31 17:20:08 2015 +0200 1.3 @@ -3183,7 +3183,7 @@ 1.4 // Note 2: MergeMem may already contains instance memory slices added 1.5 // during find_inst_mem() call when memory nodes were processed above. 1.6 igvn->hash_delete(nmm); 1.7 - uint nslices = nmm->req(); 1.8 + uint nslices = MIN2(nmm->req(), new_index_start); 1.9 for (uint i = Compile::AliasIdxRaw+1; i < nslices; i++) { 1.10 Node* mem = nmm->in(i); 1.11 Node* cur = NULL;
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/test/compiler/escapeAnalysis/TestEABadMergeMem.java Mon Aug 31 17:20:08 2015 +0200 2.3 @@ -0,0 +1,86 @@ 2.4 +/* 2.5 + * Copyright (c) 2015, 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 2.29 + * @bug 8134031 2.30 + * @summary Bad rewiring of memory edges when we split unique types during EA 2.31 + * @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement -XX:CompileCommand=dontinline,TestEABadMergeMem::m_notinlined TestEABadMergeMem 2.32 + * 2.33 + */ 2.34 + 2.35 +public class TestEABadMergeMem { 2.36 + 2.37 + static class Box { 2.38 + int i; 2.39 + } 2.40 + 2.41 + static void m_notinlined() { 2.42 + } 2.43 + 2.44 + static float dummy1; 2.45 + static float dummy2; 2.46 + 2.47 + static int test(Box a, Box c, int i, int j, int k, boolean flag1, boolean flag2) { 2.48 + Box b = new Box(); // non escaping 2.49 + a.i = i; 2.50 + b.i = j; 2.51 + c.i = k; 2.52 + 2.53 + m_notinlined(); 2.54 + 2.55 + boolean flag3 = false; 2.56 + if (flag1) { 2.57 + for (int ii = 0; ii < 100; ii++) { 2.58 + if (flag2) { 2.59 + dummy1 = (float)ii; 2.60 + } else { 2.61 + dummy2 = (float)ii; 2.62 + } 2.63 + } 2.64 + flag3 = true; 2.65 + } 2.66 + // Memory Phi here with projection of not inlined call as one edge, MergeMem as other 2.67 + 2.68 + if (flag3) { // will split through Phi during loopopts 2.69 + int res = c.i + b.i; 2.70 + m_notinlined(); // prevents split through phi during igvn 2.71 + return res; 2.72 + } else { 2.73 + return 44 + 43; 2.74 + } 2.75 + } 2.76 + 2.77 + static public void main(String[] args) { 2.78 + for (int i = 0; i < 20000; i++) { 2.79 + // m(2); 2.80 + Box a = new Box(); 2.81 + Box c = new Box(); 2.82 + int res = test(a, c, 42, 43, 44, (i%2) == 0, (i%3) == 0); 2.83 + if (res != 44 + 43) { 2.84 + throw new RuntimeException("Bad result " + res); 2.85 + } 2.86 + } 2.87 + } 2.88 + 2.89 +}