Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/compiler/6431242/Test.java
32285 views
/*1* Copyright (c) 2006, 2013, 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*22*/2324/*25* @test26* @bug 643124227* @run main Test28*/2930public class Test{3132int _len = 8;33int[] _arr_i = new int[_len];34long[] _arr_l = new long[_len];3536int[] _arr_i_cp = new int [_len];37long[] _arr_l_cp = new long [_len];3839int _k = 0x12345678;40int _j = 0;41int _ir = 0x78563412;42int _ir1 = 0x78563413;43int _ir2 = 0x79563412;4445long _m = 0x123456789abcdef0L;46long _l = 0L;47long _lr = 0xf0debc9a78563412L;48long _lr1 = 0xf0debc9a78563413L;49long _lr2 = 0xf1debc9a78563412L;5051void init() {52for (int i=0; i<_arr_i.length; i++) {53_arr_i[i] = _k;54_arr_l[i] = _m;55}56}5758public int test_int_reversed(int i) {59return Integer.reverseBytes(i);60}6162public long test_long_reversed(long i) {63return Long.reverseBytes(i);64}6566public void test_copy_ints(int[] dst, int[] src) {67for(int i=0; i<src.length; i++) {68dst[i] = Integer.reverseBytes(src[i]);69}70}7172public void test_copy_ints_reversed(int[] dst, int[] src) {73for (int i=0; i<src.length; i++) {74dst[i] = 1 + Integer.reverseBytes(src[i]);75}76}7778public void test_copy_ints_store_reversed(int[] dst, int[] src) {79for(int i=0; i<src.length; i++) {80dst[i] = Integer.reverseBytes(1 + src[i]);81}82}8384public void test_copy_longs(long[] dst, long[] src) {85for(int i=0; i<src.length; i++) {86dst[i] = Long.reverseBytes(src[i]);87}88}8990public void test_copy_longs_reversed(long[] dst, long[] src) {91for (int i=0; i<src.length; i++) {92dst[i] = 1 + Long.reverseBytes(src[i]);93}94}9596public void test_copy_longs_store_reversed(long[] dst, long[] src) {97for(int i=0; i<src.length; i++) {98dst[i] = Long.reverseBytes(1 + src[i]);99}100}101102public void test() throws Exception {103int up_limit=90000;104105106//test single107108for (int loop=0; loop<up_limit; loop++) {109_j = test_int_reversed(_k);110if (_j != _ir ) {111throw new Exception("Interger.reverseBytes failed " + _j + " iter " + loop);112}113_l = test_long_reversed(_m);114if (_l != _lr ) {115throw new Exception("Long.reverseBytes failed " + _l + " iter " + loop);116}117}118119// test scalar load/store120for (int loop=0; loop<up_limit; loop++) {121122test_copy_ints(_arr_i_cp, _arr_i);123for (int j=0; j< _arr_i.length; j++) {124if (_arr_i_cp[j] != _ir) {125throw new Exception("Interger.reverseBytes failed test_copy_ints iter " + loop);126}127}128129test_copy_ints_reversed(_arr_i_cp, _arr_i);130for (int j=0; j< _arr_i.length; j++) {131if (_arr_i_cp[j] != _ir1) {132throw new Exception("Interger.reverseBytes failed test_copy_ints_reversed iter " + loop);133}134}135test_copy_ints_store_reversed(_arr_i_cp, _arr_i);136for (int j=0; j< _arr_i.length; j++) {137if (_arr_i_cp[j] != _ir2) {138throw new Exception("Interger.reverseBytes failed test_copy_ints_store_reversed iter " + loop);139}140}141142test_copy_longs(_arr_l_cp, _arr_l);143for (int j=0; j< _arr_i.length; j++) {144if (_arr_l_cp[j] != _lr) {145throw new Exception("Long.reverseBytes failed test_copy_longs iter " + loop);146}147}148test_copy_longs_reversed(_arr_l_cp, _arr_l);149for (int j=0; j< _arr_i.length; j++) {150if (_arr_l_cp[j] != _lr1) {151throw new Exception("Long.reverseBytes failed test_copy_longs_reversed iter " + loop);152}153}154test_copy_longs_store_reversed(_arr_l_cp, _arr_l);155for (int j=0; j< _arr_i.length; j++) {156if (_arr_l_cp[j] != _lr2) {157throw new Exception("Long.reverseBytes failed test_copy_longs_store_reversed iter " + loop);158}159}160161}162}163164public static void main(String args[]) {165try {166Test t = new Test();167t.init();168t.test();169System.out.println("Passed");170}catch (Exception e) {171e.printStackTrace();172System.out.println("Failed");173}174}175}176177178