1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/test/compiler/6814842/Test6814842.java Wed May 13 00:45:22 2009 -0700 1.3 @@ -0,0 +1,104 @@ 1.4 +/* 1.5 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.24 + * have any questions. 1.25 + */ 1.26 + 1.27 +/** 1.28 + * @test 1.29 + * @bug 6814842 1.30 + * @summary Load shortening optimizations 1.31 + * 1.32 + * @run main/othervm -Xcomp -XX:CompileOnly=Test6814842.loadS2B,Test6814842.loadS2Bmask255,Test6814842.loadUS2B,Test6814842.loadUS2Bmask255,Test6814842.loadI2B,Test6814842.loadI2Bmask255,Test6814842.loadI2S,Test6814842.loadI2Smask255,Test6814842.loadI2Smask65535,Test6814842.loadI2US,Test6814842.loadI2USmask255,Test6814842.loadI2USmask65535 Test6814842 1.33 + */ 1.34 + 1.35 +public class Test6814842 { 1.36 + static final short[] sa = new short[] { (short) 0xF1F2 }; 1.37 + static final char[] ca = new char[] { (char) 0xF3F4 }; 1.38 + static final int[] ia = new int[] { 0xF1F2F3F4 }; 1.39 + 1.40 + public static void main(String[] args) 1.41 + { 1.42 + byte s2b = loadS2B(sa); 1.43 + if (s2b != (byte) 0xF2) 1.44 + throw new InternalError("loadS2B failed: " + s2b + " != " + (byte) 0xF2); 1.45 + 1.46 + byte s2bmask255 = loadS2Bmask255(sa); 1.47 + if (s2bmask255 != (byte) 0xF2) 1.48 + throw new InternalError("loadS2Bmask255 failed: " + s2bmask255 + " != " + (byte) 0xF2); 1.49 + 1.50 + byte us2b = loadUS2B(ca); 1.51 + if (us2b != (byte) 0xF4) 1.52 + throw new InternalError("loadUS2B failed: " + us2b + " != " + (byte) 0xF4); 1.53 + 1.54 + byte us2bmask255 = loadUS2Bmask255(ca); 1.55 + if (us2bmask255 != (byte) 0xF4) 1.56 + throw new InternalError("loadUS2Bmask255 failed: " + us2bmask255 + " != " + (byte) 0xF4); 1.57 + 1.58 + byte i2b = loadI2B(ia); 1.59 + if (i2b != (byte) 0xF4) 1.60 + throw new InternalError("loadI2B failed: " + i2b + " != " + (byte) 0xF4); 1.61 + 1.62 + byte i2bmask255 = loadI2Bmask255(ia); 1.63 + if (i2bmask255 != (byte) 0xF4) 1.64 + throw new InternalError("loadI2Bmask255 failed: " + i2bmask255 + " != " + (byte) 0xF4); 1.65 + 1.66 + short i2s = loadI2S(ia); 1.67 + if (i2s != (short) 0xF3F4) 1.68 + throw new InternalError("loadI2S failed: " + i2s + " != " + (short) 0xF3F4); 1.69 + 1.70 + short i2smask255 = loadI2Smask255(ia); 1.71 + if (i2smask255 != (short) 0xF4) 1.72 + throw new InternalError("loadI2Smask255 failed: " + i2smask255 + " != " + (short) 0xF4); 1.73 + 1.74 + short i2smask65535 = loadI2Smask65535(ia); 1.75 + if (i2smask65535 != (short) 0xF3F4) 1.76 + throw new InternalError("loadI2Smask65535 failed: " + i2smask65535 + " != " + (short) 0xF3F4); 1.77 + 1.78 + char i2us = loadI2US(ia); 1.79 + if (i2us != (char) 0xF3F4) 1.80 + throw new InternalError("loadI2US failed: " + (int) i2us + " != " + (char) 0xF3F4); 1.81 + 1.82 + char i2usmask255 = loadI2USmask255(ia); 1.83 + if (i2usmask255 != (char) 0xF4) 1.84 + throw new InternalError("loadI2USmask255 failed: " + (int) i2usmask255 + " != " + (char) 0xF4); 1.85 + 1.86 + char i2usmask65535 = loadI2USmask65535(ia); 1.87 + if (i2usmask65535 != (char) 0xF3F4) 1.88 + throw new InternalError("loadI2USmask65535 failed: " + (int) i2usmask65535 + " != " + (char) 0xF3F4); 1.89 + } 1.90 + 1.91 + static byte loadS2B (short[] sa) { return (byte) (sa[0] ); } 1.92 + static byte loadS2Bmask255 (short[] sa) { return (byte) (sa[0] & 0xFF ); } 1.93 + 1.94 + static byte loadUS2B (char[] ca) { return (byte) (ca[0] ); } 1.95 + static byte loadUS2Bmask255 (char[] ca) { return (byte) (ca[0] & 0xFF ); } 1.96 + 1.97 + static byte loadI2B (int[] ia) { return (byte) (ia[0] ); } 1.98 + static byte loadI2Bmask255 (int[] ia) { return (byte) (ia[0] & 0xFF ); } 1.99 + 1.100 + static short loadI2S (int[] ia) { return (short) (ia[0] ); } 1.101 + static short loadI2Smask255 (int[] ia) { return (short) (ia[0] & 0xFF ); } 1.102 + static short loadI2Smask65535 (int[] ia) { return (short) (ia[0] & 0xFFFF); } 1.103 + 1.104 + static char loadI2US (int[] ia) { return (char) (ia[0] ); } 1.105 + static char loadI2USmask255 (int[] ia) { return (char) (ia[0] & 0xFF ); } 1.106 + static char loadI2USmask65535(int[] ia) { return (char) (ia[0] & 0xFFFF); } 1.107 +}