Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/compiler/6636138/Test2.java
32285 views
/*1* Copyright (c) 2009, 2013, 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 663613826* @summary SuperWord::co_locate_pack(Node_List* p) generates memory graph that leads to memory order violation.27*28* @run main/othervm -Xbatch -XX:CompileOnly=Test2.shift Test229*/3031public class Test2 {3233public static void init(int src[]) {34// Initialize the array35for (int i = 0; i < src.length; i++)36src[i] = i;37}3839public static void shift(int src[]) {40//left-shift the array41for (int i = src.length-1; i > 0; i--){42int tmp = src[i];43src[i] = src[i-1];44src[i-1] = tmp;45}46}4748public static void verify(int src[]) {49for (int i = 0; i < src.length; i++){50int value = (i-1 + src.length)%src.length; // correct value after shifting51if (src[i] != value) {52System.out.println("Error: src["+i+"] should be "+ value + " instead of " + src[i]);53System.exit(97);54}55}56}5758public static void test() {59int[] src = new int[10];60init(src);61shift(src);62verify(src);63}6465public static void main(String[] args) {66for (int i=0; i< 2000; i++)67test();68}69}707172