test/compiler/6663621/IVTest.java

Thu, 20 Mar 2008 10:43:42 -0700

author
never
date
Thu, 20 Mar 2008 10:43:42 -0700
changeset 507
f705f25597eb
child 612
2a8ec427fbe1
permissions
-rw-r--r--

6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
Summary: alignment expression with secondary induction variables is sometimes wrong
Reviewed-by: kvn, rasbold

     1 /*
     2  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
     3  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
     4  *
     5  *
     6  *
     7  *
     8  *
     9  *
    10  *
    11  *
    12  *
    13  *
    14  *
    15  *
    16  *
    17  *
    18  *
    19  *
    20  *
    21  *
    22  */
    24 /**
    25  * @test
    26  * @bug 6663621
    27  * @summary JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
    28  */
    30 public class IVTest {
    31     static int paddedSize;
    33     static void padV15(byte[] padded) {
    34         int psSize = padded.length;
    35         int k = 0;
    36         while (psSize-- > 0) {
    37             padded[k++] = (byte)0xff;
    38         }
    39     }
    41     static void padV15_2(int paddedSize) {
    42         byte[] padded = new byte[paddedSize];
    43         int psSize = padded.length;
    44         int k = 0;
    45         while (psSize-- > 0) {
    46             padded[k++] = (byte)0xff;
    47         }
    48     }
    50     static void padV15_3() {
    51         byte[] padded = new byte[paddedSize];
    52         int psSize = padded.length;
    53         int k = 0;
    54         while (psSize-- > 0) {
    55             padded[k++] = (byte)0xff;
    56         }
    57     }
    59     static void padV15_4() {
    60         byte[] padded = new byte[paddedSize];
    61         int psSize = padded.length;
    62         for (int k = 0;psSize > 0; psSize--) {
    63             int i = padded.length - psSize;
    64             padded[i] = (byte)0xff;
    65         }
    66     }
    68     static void padV15_5() {
    69         byte[] padded = new byte[paddedSize];
    70         int psSize = padded.length;
    71         int k = psSize - 1;
    72         for (int i = 0; i < psSize; i++) {
    73             padded[k--] = (byte)0xff;
    74         }
    75     }
    77     public static void main(String argv[]) {
    78         int bounds = 1024;
    79         int lim = 500000;
    80         long start = System.currentTimeMillis();
    81         for (int j = 0; j < lim; j++) {
    82             paddedSize = j % bounds;
    83             padV15(new byte[paddedSize]);
    84         }
    85         long end = System.currentTimeMillis();
    86         System.out.println(end - start);
    87         start = System.currentTimeMillis();
    88         for (int j = 0; j < lim; j++) {
    89             paddedSize = j % bounds;
    90             padV15_2(paddedSize);
    91         }
    92         end = System.currentTimeMillis();
    93         System.out.println(end - start);
    94         start = System.currentTimeMillis();
    95         for (int j = 0; j < lim; j++) {
    96             paddedSize = j % bounds;
    97             padV15_3();
    98         }
    99         end = System.currentTimeMillis();
   100         System.out.println(end - start);
   101         start = System.currentTimeMillis();
   102         for (int j = 0; j < lim; j++) {
   103             paddedSize = j % bounds;
   104             padV15_4();
   105         }
   106         end = System.currentTimeMillis();
   107         System.out.println(end - start);
   108         start = System.currentTimeMillis();
   109         for (int j = 0; j < lim; j++) {
   110             paddedSize = j % bounds;
   111             padV15_5();
   112         }
   113         end = System.currentTimeMillis();
   114         System.out.println(end - start);
   115     }
   116 }

mercurial