|
1 /* |
|
2 * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. |
|
8 * |
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
|
13 * accompanied this code). |
|
14 * |
|
15 * You should have received a copy of the GNU General Public License version |
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 * |
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 * or visit www.oracle.com if you need additional information or have any |
|
21 * questions. |
|
22 */ |
|
23 |
|
24 /** |
|
25 * @test |
|
26 * @bug 6663621 |
|
27 * @summary JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests. |
|
28 * |
|
29 * @run main compiler.c2.IVTest |
|
30 */ |
|
31 |
|
32 package compiler.c2; |
|
33 |
|
34 public class IVTest { |
|
35 static int paddedSize; |
|
36 |
|
37 static void padV15(byte[] padded) { |
|
38 int psSize = padded.length; |
|
39 int k = 0; |
|
40 while (psSize-- > 0) { |
|
41 padded[k++] = (byte)0xff; |
|
42 } |
|
43 } |
|
44 |
|
45 static void padV15_2(int paddedSize) { |
|
46 byte[] padded = new byte[paddedSize]; |
|
47 int psSize = padded.length; |
|
48 int k = 0; |
|
49 while (psSize-- > 0) { |
|
50 padded[k++] = (byte)0xff; |
|
51 } |
|
52 } |
|
53 |
|
54 static void padV15_3() { |
|
55 byte[] padded = new byte[paddedSize]; |
|
56 int psSize = padded.length; |
|
57 int k = 0; |
|
58 while (psSize-- > 0) { |
|
59 padded[k++] = (byte)0xff; |
|
60 } |
|
61 } |
|
62 |
|
63 static void padV15_4() { |
|
64 byte[] padded = new byte[paddedSize]; |
|
65 int psSize = padded.length; |
|
66 for (int k = 0;psSize > 0; psSize--) { |
|
67 int i = padded.length - psSize; |
|
68 padded[i] = (byte)0xff; |
|
69 } |
|
70 } |
|
71 |
|
72 static void padV15_5() { |
|
73 byte[] padded = new byte[paddedSize]; |
|
74 int psSize = padded.length; |
|
75 int k = psSize - 1; |
|
76 for (int i = 0; i < psSize; i++) { |
|
77 padded[k--] = (byte)0xff; |
|
78 } |
|
79 } |
|
80 |
|
81 public static void main(String argv[]) { |
|
82 int bounds = 1024; |
|
83 int lim = 500000; |
|
84 long start = System.currentTimeMillis(); |
|
85 for (int j = 0; j < lim; j++) { |
|
86 paddedSize = j % bounds; |
|
87 padV15(new byte[paddedSize]); |
|
88 } |
|
89 long end = System.currentTimeMillis(); |
|
90 System.out.println(end - start); |
|
91 start = System.currentTimeMillis(); |
|
92 for (int j = 0; j < lim; j++) { |
|
93 paddedSize = j % bounds; |
|
94 padV15_2(paddedSize); |
|
95 } |
|
96 end = System.currentTimeMillis(); |
|
97 System.out.println(end - start); |
|
98 start = System.currentTimeMillis(); |
|
99 for (int j = 0; j < lim; j++) { |
|
100 paddedSize = j % bounds; |
|
101 padV15_3(); |
|
102 } |
|
103 end = System.currentTimeMillis(); |
|
104 System.out.println(end - start); |
|
105 start = System.currentTimeMillis(); |
|
106 for (int j = 0; j < lim; j++) { |
|
107 paddedSize = j % bounds; |
|
108 padV15_4(); |
|
109 } |
|
110 end = System.currentTimeMillis(); |
|
111 System.out.println(end - start); |
|
112 start = System.currentTimeMillis(); |
|
113 for (int j = 0; j < lim; j++) { |
|
114 paddedSize = j % bounds; |
|
115 padV15_5(); |
|
116 } |
|
117 end = System.currentTimeMillis(); |
|
118 System.out.println(end - start); |
|
119 } |
|
120 } |