< prev index next >

test/compiler/c2/Test5057225.java

Print this page
rev 11557 : 8132919: use package in compiler tests
Reviewed-by: duke


  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 
  24 /**
  25  * @test
  26  * @bug 5057225
  27  * @summary Remove useless I2L conversions
  28  * @modules java.base/jdk.internal.misc
  29  * @library /testlibrary
  30  * @run main/othervm -Xcomp -XX:CompileOnly=Test5057225.doload Test5057225



  31  */
  32 

  33 import jdk.test.lib.Utils;
  34 
  35 public class Test5057225 {
  36     static byte[]  ba = new byte[]  { -1 };
  37     static short[] sa = new short[] { -1 };
  38     static int[]   ia = new int[]   { -1 };
  39 
  40     static final long[] BYTE_MASKS = {
  41          0x0FL,
  42          0x7FL,  // 7-bit
  43          0xFFL,
  44     };
  45 
  46     static final long[] SHORT_MASKS = {
  47         0x000FL,
  48         0x007FL,  // 7-bit
  49         0x00FFL,
  50         0x0FFFL,
  51         0x3FFFL,  // 14-bit
  52         0x7FFFL,  // 15-bit
  53         0xFFFFL,
  54     };
  55 
  56     static final long[] INT_MASKS = {
  57         0x0000000FL,
  58         0x0000007FL,  // 7-bit
  59         0x000000FFL,
  60         0x00000FFFL,
  61         0x00003FFFL,  // 14-bit
  62         0x00007FFFL,  // 15-bit
  63         0x0000FFFFL,
  64         0x00FFFFFFL,
  65         0x7FFFFFFFL,  // 31-bit
  66         0xFFFFFFFFL,
  67     };
  68 
  69     public static void main(String[] args) throws Exception {
  70         for (int i = 0; i < BYTE_MASKS.length; i++) {
  71             System.setProperty("value", "" + BYTE_MASKS[i]);
  72             loadAndRunClass("Test5057225$loadUB2L");
  73         }
  74 
  75         for (int i = 0; i < SHORT_MASKS.length; i++) {
  76             System.setProperty("value", "" + SHORT_MASKS[i]);
  77             loadAndRunClass("Test5057225$loadUS2L");
  78         }
  79 
  80         for (int i = 0; i < INT_MASKS.length; i++) {
  81             System.setProperty("value", "" + INT_MASKS[i]);
  82             loadAndRunClass("Test5057225$loadUI2L");
  83         }
  84     }
  85 
  86     static void check(long result, long expected) {
  87         if (result != expected)
  88             throw new InternalError(result + " != " + expected);
  89     }
  90 
  91     static void loadAndRunClass(String classname) throws Exception {
  92         Class cl = Class.forName(classname);
  93         ClassLoader apploader = cl.getClassLoader();
  94         ClassLoader loader
  95                 = Utils.getTestClassPathURLClassLoader(apploader.getParent());
  96         Class c = loader.loadClass(classname);
  97         Runnable r = (Runnable) c.newInstance();
  98         r.run();
  99     }
 100 
 101     public static class loadUB2L implements Runnable {
 102         static final long MASK;




  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 
  24 /**
  25  * @test
  26  * @bug 5057225
  27  * @summary Remove useless I2L conversions
  28  * @modules java.base/jdk.internal.misc
  29  * @library /testlibrary
  30  *
  31  * @run main/othervm -Xcomp
  32  *      -XX:CompileCommand=compileonly,compiler.c2.Test5057225::doload
  33  *      compiler.c2.Test5057225
  34  */
  35 
  36 package compiler.c2;
  37 import jdk.test.lib.Utils;
  38 
  39 public class Test5057225 {
  40     static byte[]  ba = new byte[]  { -1 };
  41     static short[] sa = new short[] { -1 };
  42     static int[]   ia = new int[]   { -1 };
  43 
  44     static final long[] BYTE_MASKS = {
  45          0x0FL,
  46          0x7FL,  // 7-bit
  47          0xFFL,
  48     };
  49 
  50     static final long[] SHORT_MASKS = {
  51         0x000FL,
  52         0x007FL,  // 7-bit
  53         0x00FFL,
  54         0x0FFFL,
  55         0x3FFFL,  // 14-bit
  56         0x7FFFL,  // 15-bit
  57         0xFFFFL,
  58     };
  59 
  60     static final long[] INT_MASKS = {
  61         0x0000000FL,
  62         0x0000007FL,  // 7-bit
  63         0x000000FFL,
  64         0x00000FFFL,
  65         0x00003FFFL,  // 14-bit
  66         0x00007FFFL,  // 15-bit
  67         0x0000FFFFL,
  68         0x00FFFFFFL,
  69         0x7FFFFFFFL,  // 31-bit
  70         0xFFFFFFFFL,
  71     };
  72 
  73     public static void main(String[] args) throws Exception {
  74         for (int i = 0; i < BYTE_MASKS.length; i++) {
  75             System.setProperty("value", "" + BYTE_MASKS[i]);
  76             loadAndRunClass(Test5057225.class.getName() + "$loadUB2L");
  77         }
  78 
  79         for (int i = 0; i < SHORT_MASKS.length; i++) {
  80             System.setProperty("value", "" + SHORT_MASKS[i]);
  81             loadAndRunClass(Test5057225.class.getName() + "$loadUS2L");
  82         }
  83 
  84         for (int i = 0; i < INT_MASKS.length; i++) {
  85             System.setProperty("value", "" + INT_MASKS[i]);
  86             loadAndRunClass(Test5057225.class.getName() + "$loadUI2L");
  87         }
  88     }
  89 
  90     static void check(long result, long expected) {
  91         if (result != expected)
  92             throw new InternalError(result + " != " + expected);
  93     }
  94 
  95     static void loadAndRunClass(String classname) throws Exception {
  96         Class cl = Class.forName(classname);
  97         ClassLoader apploader = cl.getClassLoader();
  98         ClassLoader loader
  99                 = Utils.getTestClassPathURLClassLoader(apploader.getParent());
 100         Class c = loader.loadClass(classname);
 101         Runnable r = (Runnable) c.newInstance();
 102         r.run();
 103     }
 104 
 105     public static class loadUB2L implements Runnable {
 106         static final long MASK;


< prev index next >