Path: blob/master/test/hotspot/jtreg/compiler/escapeAnalysis/TestMissingAntiDependency.java
41149 views
/*1* Copyright (c) 2020, Red Hat, Inc. 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 825229226* @summary 8240795 may cause anti-dependency to be missed27* @requires vm.gc.Parallel28*29* @run main/othervm -XX:-BackgroundCompilation -XX:+UseParallelGC TestMissingAntiDependency30*31*/3233public class TestMissingAntiDependency {34public static void main(String[] args) {35int[] src = new int[10];36for (int i = 0; i < 20_000; i++) {37test(src, true, true, 10);38test(src, true, false, 10);39test(src, false, false, 10);40}41src[9] = 42;42final int v = test(src, true, true, 1);43if (v != 42) {44throw new RuntimeException("Incorrect return value " + v);45}46}4748private static int test(int[] src, boolean flag1, boolean flag2, int stop) {49int v = 0;50int j = 1;51for (; j < 10; j++) {52for (int i = 0; i < 2; i++) {5354}55}56int[] dst = new int[10];57for (int i = 0; i < stop; i ++) {58if (flag1) {59System.arraycopy(src, 0, dst, 0, j);60v = dst[9];61if (flag2) {62src[9] = 0x42;63}64}65}66return v;67}68}697071