test/compiler/6431242/Test.java

Fri, 02 Dec 2011 15:11:40 -0800

author
jcoomes
date
Fri, 02 Dec 2011 15:11:40 -0800
changeset 3301
aed8bf036ce2
parent 2384
0a8e0d4345b3
child 4684
7369298bec7e
permissions
-rw-r--r--

Added tag hs23-b07 for changeset 6de8c9ba5907

     1 /*
     2  * Copyright (c) 2006, 2010, 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  */
    25 /*
    26  * @test
    27  * @bug 6431242
    28  * @run main/othervm -server -XX:+PrintCompilation Test
    29  */
    31 public class Test{
    33   int    _len      = 8;
    34   int[]  _arr_i    = new int[_len];
    35   long[] _arr_l    = new long[_len];
    37   int[]  _arr_i_cp = new int [_len];
    38   long[] _arr_l_cp = new long [_len];
    40   int _k     = 0x12345678;
    41   int _j     = 0;
    42   int _ir    = 0x78563412;
    43   int _ir1   = 0x78563413;
    44   int _ir2   = 0x79563412;
    46   long _m    = 0x123456789abcdef0L;
    47   long _l    = 0L;
    48   long _lr   = 0xf0debc9a78563412L;
    49   long _lr1  = 0xf0debc9a78563413L;
    50   long _lr2  = 0xf1debc9a78563412L;
    52   void init() {
    53     for (int i=0; i<_arr_i.length; i++) {
    54       _arr_i[i] = _k;
    55       _arr_l[i] = _m;
    56     }
    57   }
    59   public int test_int_reversed(int i) {
    60     return Integer.reverseBytes(i);
    61   }
    63   public long test_long_reversed(long i) {
    64     return Long.reverseBytes(i);
    65   }
    67   public void test_copy_ints(int[] dst, int[] src) {
    68     for(int i=0; i<src.length; i++) {
    69       dst[i] = Integer.reverseBytes(src[i]);
    70     }
    71   }
    73   public void test_copy_ints_reversed(int[] dst, int[] src) {
    74     for (int i=0; i<src.length; i++) {
    75       dst[i] = 1 + Integer.reverseBytes(src[i]);
    76     }
    77   }
    79   public void test_copy_ints_store_reversed(int[] dst, int[] src) {
    80     for(int i=0; i<src.length; i++) {
    81       dst[i] = Integer.reverseBytes(1 + src[i]);
    82     }
    83   }
    85   public void test_copy_longs(long[] dst, long[] src) {
    86     for(int i=0; i<src.length; i++) {
    87       dst[i] = Long.reverseBytes(src[i]);
    88     }
    89   }
    91   public void test_copy_longs_reversed(long[] dst, long[] src) {
    92     for (int i=0; i<src.length; i++) {
    93       dst[i] = 1 + Long.reverseBytes(src[i]);
    94     }
    95   }
    97   public void test_copy_longs_store_reversed(long[] dst, long[] src) {
    98     for(int i=0; i<src.length; i++) {
    99       dst[i] = Long.reverseBytes(1 + src[i]);
   100     }
   101   }
   103   public void test() throws Exception {
   104     int up_limit=90000;
   107     //test single
   109     for (int loop=0; loop<up_limit; loop++) {
   110       _j = test_int_reversed(_k);
   111       if (_j != _ir ) {
   112         throw new Exception("Interger.reverseBytes failed " + _j + " iter " + loop);
   113       }
   114       _l = test_long_reversed(_m);
   115       if (_l != _lr ) {
   116         throw new Exception("Long.reverseBytes failed " + _l + " iter " + loop);
   117       }
   118     }
   120     // test scalar load/store
   121     for (int loop=0; loop<up_limit; loop++) {
   123       test_copy_ints(_arr_i_cp, _arr_i);
   124       for (int j=0; j< _arr_i.length; j++) {
   125         if (_arr_i_cp[j] != _ir) {
   126           throw new Exception("Interger.reverseBytes failed test_copy_ints iter " + loop);
   127         }
   128       }
   130       test_copy_ints_reversed(_arr_i_cp, _arr_i);
   131       for (int j=0; j< _arr_i.length; j++) {
   132         if (_arr_i_cp[j] != _ir1) {
   133           throw new Exception("Interger.reverseBytes failed test_copy_ints_reversed iter " + loop);
   134         }
   135       }
   136       test_copy_ints_store_reversed(_arr_i_cp, _arr_i);
   137       for (int j=0; j< _arr_i.length; j++) {
   138         if (_arr_i_cp[j] != _ir2) {
   139           throw new Exception("Interger.reverseBytes failed test_copy_ints_store_reversed iter " + loop);
   140         }
   141       }
   143       test_copy_longs(_arr_l_cp, _arr_l);
   144       for (int j=0; j< _arr_i.length; j++) {
   145         if (_arr_l_cp[j] != _lr) {
   146           throw new Exception("Long.reverseBytes failed test_copy_longs iter " + loop);
   147         }
   148       }
   149       test_copy_longs_reversed(_arr_l_cp, _arr_l);
   150       for (int j=0; j< _arr_i.length; j++) {
   151         if (_arr_l_cp[j] != _lr1) {
   152           throw new Exception("Long.reverseBytes failed test_copy_longs_reversed iter " + loop);
   153         }
   154       }
   155       test_copy_longs_store_reversed(_arr_l_cp, _arr_l);
   156       for (int j=0; j< _arr_i.length; j++) {
   157         if (_arr_l_cp[j] != _lr2) {
   158           throw new Exception("Long.reverseBytes failed test_copy_longs_store_reversed iter " + loop);
   159         }
   160       }
   162     }
   163   }
   165   public static void main(String args[]) {
   166     try {
   167       Test t = new Test();
   168       t.init();
   169       t.test();
   170       System.out.println("Passed");
   171     }catch (Exception e) {
   172       e.printStackTrace();
   173       System.out.println("Failed");
   174     }
   175   }
   176 }

mercurial