Path: blob/master/test/hotspot/jtreg/compiler/c2/IVTest.java
41152 views
/*1* Copyright (c) 1997, 2008, 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 666362126* @summary JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.27*28* @run main compiler.c2.IVTest29*/3031package compiler.c2;3233public class IVTest {34static int paddedSize;3536static void padV15(byte[] padded) {37int psSize = padded.length;38int k = 0;39while (psSize-- > 0) {40padded[k++] = (byte)0xff;41}42}4344static void padV15_2(int paddedSize) {45byte[] padded = new byte[paddedSize];46int psSize = padded.length;47int k = 0;48while (psSize-- > 0) {49padded[k++] = (byte)0xff;50}51}5253static void padV15_3() {54byte[] padded = new byte[paddedSize];55int psSize = padded.length;56int k = 0;57while (psSize-- > 0) {58padded[k++] = (byte)0xff;59}60}6162static void padV15_4() {63byte[] padded = new byte[paddedSize];64int psSize = padded.length;65for (int k = 0;psSize > 0; psSize--) {66int i = padded.length - psSize;67padded[i] = (byte)0xff;68}69}7071static void padV15_5() {72byte[] padded = new byte[paddedSize];73int psSize = padded.length;74int k = psSize - 1;75for (int i = 0; i < psSize; i++) {76padded[k--] = (byte)0xff;77}78}7980public static void main(String argv[]) {81int bounds = 1024;82int lim = 500000;83long start = System.currentTimeMillis();84for (int j = 0; j < lim; j++) {85paddedSize = j % bounds;86padV15(new byte[paddedSize]);87}88long end = System.currentTimeMillis();89System.out.println(end - start);90start = System.currentTimeMillis();91for (int j = 0; j < lim; j++) {92paddedSize = j % bounds;93padV15_2(paddedSize);94}95end = System.currentTimeMillis();96System.out.println(end - start);97start = System.currentTimeMillis();98for (int j = 0; j < lim; j++) {99paddedSize = j % bounds;100padV15_3();101}102end = System.currentTimeMillis();103System.out.println(end - start);104start = System.currentTimeMillis();105for (int j = 0; j < lim; j++) {106paddedSize = j % bounds;107padV15_4();108}109end = System.currentTimeMillis();110System.out.println(end - start);111start = System.currentTimeMillis();112for (int j = 0; j < lim; j++) {113paddedSize = j % bounds;114padV15_5();115}116end = System.currentTimeMillis();117System.out.println(end - start);118}119}120121122