Path: blob/master/test/hotspot/jtreg/compiler/codegen/Test6431242.java
41149 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*/2223/*24* @test25* @bug 643124226*27* @run main compiler.codegen.Test643124228*/2930package compiler.codegen;3132public class Test6431242 {3334int _len = 8;35int[] _arr_i = new int[_len];36long[] _arr_l = new long[_len];3738int[] _arr_i_cp = new int[_len];39long[] _arr_l_cp = new long[_len];4041int _k = 0x12345678;42int _j = 0;43int _ir = 0x78563412;44int _ir1 = 0x78563413;45int _ir2 = 0x79563412;4647long _m = 0x123456789abcdef0L;48long _l = 0L;49long _lr = 0xf0debc9a78563412L;50long _lr1 = 0xf0debc9a78563413L;51long _lr2 = 0xf1debc9a78563412L;5253void init() {54for (int i = 0; i < _arr_i.length; i++) {55_arr_i[i] = _k;56_arr_l[i] = _m;57}58}5960public int test_int_reversed(int i) {61return Integer.reverseBytes(i);62}6364public long test_long_reversed(long i) {65return Long.reverseBytes(i);66}6768public void test_copy_ints(int[] dst, int[] src) {69for (int i = 0; i < src.length; i++) {70dst[i] = Integer.reverseBytes(src[i]);71}72}7374public void test_copy_ints_reversed(int[] dst, int[] src) {75for (int i = 0; i < src.length; i++) {76dst[i] = 1 + Integer.reverseBytes(src[i]);77}78}7980public void test_copy_ints_store_reversed(int[] dst, int[] src) {81for (int i = 0; i < src.length; i++) {82dst[i] = Integer.reverseBytes(1 + src[i]);83}84}8586public void test_copy_longs(long[] dst, long[] src) {87for (int i = 0; i < src.length; i++) {88dst[i] = Long.reverseBytes(src[i]);89}90}9192public void test_copy_longs_reversed(long[] dst, long[] src) {93for (int i = 0; i < src.length; i++) {94dst[i] = 1 + Long.reverseBytes(src[i]);95}96}9798public void test_copy_longs_store_reversed(long[] dst, long[] src) {99for (int i = 0; i < src.length; i++) {100dst[i] = Long.reverseBytes(1 + src[i]);101}102}103104public void test() throws Exception {105int up_limit = 90000;106107108//test single109110for (int loop = 0; loop < up_limit; loop++) {111_j = test_int_reversed(_k);112if (_j != _ir) {113throw new Exception("Interger.reverseBytes failed " + _j + " iter " + loop);114}115_l = test_long_reversed(_m);116if (_l != _lr) {117throw new Exception("Long.reverseBytes failed " + _l + " iter " + loop);118}119}120121// test scalar load/store122for (int loop = 0; loop < up_limit; loop++) {123124test_copy_ints(_arr_i_cp, _arr_i);125for (int j = 0; j < _arr_i.length; j++) {126if (_arr_i_cp[j] != _ir) {127throw new Exception("Interger.reverseBytes failed test_copy_ints iter " + loop);128}129}130131test_copy_ints_reversed(_arr_i_cp, _arr_i);132for (int j = 0; j < _arr_i.length; j++) {133if (_arr_i_cp[j] != _ir1) {134throw new Exception("Interger.reverseBytes failed test_copy_ints_reversed iter " + loop);135}136}137test_copy_ints_store_reversed(_arr_i_cp, _arr_i);138for (int j = 0; j < _arr_i.length; j++) {139if (_arr_i_cp[j] != _ir2) {140throw new Exception("Interger.reverseBytes failed test_copy_ints_store_reversed iter " + loop);141}142}143144test_copy_longs(_arr_l_cp, _arr_l);145for (int j = 0; j < _arr_i.length; j++) {146if (_arr_l_cp[j] != _lr) {147throw new Exception("Long.reverseBytes failed test_copy_longs iter " + loop);148}149}150test_copy_longs_reversed(_arr_l_cp, _arr_l);151for (int j = 0; j < _arr_i.length; j++) {152if (_arr_l_cp[j] != _lr1) {153throw new Exception("Long.reverseBytes failed test_copy_longs_reversed iter " + loop);154}155}156test_copy_longs_store_reversed(_arr_l_cp, _arr_l);157for (int j = 0; j < _arr_i.length; j++) {158if (_arr_l_cp[j] != _lr2) {159throw new Exception("Long.reverseBytes failed test_copy_longs_store_reversed iter " + loop);160}161}162163}164}165166public static void main(String args[]) {167try {168Test6431242 t = new Test6431242();169t.init();170t.test();171System.out.println("Passed");172} catch (Exception e) {173e.printStackTrace();174System.out.println("Failed");175}176}177}178179180