Path: blob/master/test/hotspot/jtreg/compiler/escapeAnalysis/TestIdealAllocShape.java
41152 views
/*1* Copyright (c) 2020, 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 824289526* @summary full loop unroll before EA creates phis between allocs projs and init27* @run main/othervm -Xbatch -XX:CompileCommand=dontinline,*DataA.m1 compiler.escapeAnalysis.TestIdealAllocShape28*/2930package compiler.escapeAnalysis;3132public class TestIdealAllocShape {33static volatile DataA f1;3435static class DataA {36DataA f1;37DataA(DataA p1) {38this.f1 = p1;39}40public void m1() {}41}4243public static DataA test1() {44DataA l1 = new DataA(null);45for (int i=0; i<2; i++) {46try {47return new DataA(l1); // l1 is a GlobalEscape. // control break.48} catch (Exception e) {49}50}51return null;52}5354public static DataA test2() {55DataA l1 = new DataA(null);56for (int i=0; i<2; i++) {57try {58f1 = new DataA(l1); // l1 is a GlobalEscape.59break; // control break.60} catch (Exception e) {61}62}63synchronized(l1) { // elided sync64l1.m1();65}66return null;67}6869public static void main(String argv[]) {7071for (int i=0; i<20000; i++) {72TestIdealAllocShape.test1();73}7475for (int i=0; i<20000; i++) {76TestIdealAllocShape.test2();77}78}79}808182