Path: blob/master/test/hotspot/jtreg/compiler/arraycopy/TestArrayCopyBadReexec.java
41149 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 807386626* @summary Fix for 8064703 may also cause stores between the allocation and arraycopy to be rexecuted after a deoptimization27*28* @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement29* compiler.arraycopy.TestArrayCopyBadReexec30*/3132package compiler.arraycopy;3334public class TestArrayCopyBadReexec {3536static int val;3738static int[] m1(int[] src, int l) {39if (src == null) {40return null;41}42int[] dest = new int[10];43val++;44try {45System.arraycopy(src, 0, dest, 0, l);46} catch (IndexOutOfBoundsException npe) {47}48return dest;49}5051static public void main(String[] args) {52int[] src = new int[10];53int[] res = null;54boolean success = true;5556for (int i = 0; i < 20000; i++) {57m1(src, 10);58}5960int val_before = val;6162m1(src, -1);6364if (val - val_before != 1) {65System.out.println("Bad increment: " + (val - val_before));66throw new RuntimeException("Test failed");67}68}69}707172