Path: blob/master/test/hotspot/jtreg/compiler/escapeAnalysis/TestEABadMergeMem.java
41152 views
/*1* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 813403126* @summary Bad rewiring of memory edges when we split unique types during EA27*28* @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement29* -XX:CompileCommand=dontinline,compiler.escapeAnalysis.TestEABadMergeMem::m_notinlined30* compiler.escapeAnalysis.TestEABadMergeMem31*/3233package compiler.escapeAnalysis;3435public class TestEABadMergeMem {3637static class Box {38int i;39}4041static void m_notinlined() {42}4344static float dummy1;45static float dummy2;4647static int test(Box a, Box c, int i, int j, int k, boolean flag1, boolean flag2) {48Box b = new Box(); // non escaping49a.i = i;50b.i = j;51c.i = k;5253m_notinlined();5455boolean flag3 = false;56if (flag1) {57for (int ii = 0; ii < 100; ii++) {58if (flag2) {59dummy1 = (float)ii;60} else {61dummy2 = (float)ii;62}63}64flag3 = true;65}66// Memory Phi here with projection of not inlined call as one edge, MergeMem as other6768if (flag3) { // will split through Phi during loopopts69int res = c.i + b.i;70m_notinlined(); // prevents split through phi during igvn71return res;72} else {73return 44 + 43;74}75}7677static public void main(String[] args) {78for (int i = 0; i < 20000; i++) {79// m(2);80Box a = new Box();81Box c = new Box();82int res = test(a, c, 42, 43, 44, (i%2) == 0, (i%3) == 0);83if (res != 44 + 43) {84throw new RuntimeException("Bad result " + res);85}86}87}8889}909192