< prev index next >

test/compiler/c2/cr8004867/TestIntUnsafeVolatile.java

Print this page


   1 /*
   2  * Copyright (c) 2013, 2015, 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  *


  33  *    compiler.c2.cr8004867.TestIntUnsafeVolatile
  34  * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation
  35  *    -XX:+OptimizeFill
  36  *    compiler.c2.cr8004867.TestIntUnsafeVolatile
  37  */
  38 
  39 package compiler.c2.cr8004867;
  40 
  41 import jdk.internal.misc.Unsafe;
  42 
  43 import java.lang.reflect.Field;
  44 
  45 public class TestIntUnsafeVolatile {
  46   private static final int ARRLEN = 97;
  47   private static final int ITERS  = 11000;
  48   private static final int OFFSET = 3;
  49   private static final int SCALE = 2;
  50   private static final int ALIGN_OFF = 8;
  51   private static final int UNALIGN_OFF = 5;
  52 
  53   private static final Unsafe unsafe;
  54   private static final int BASE;
  55   static {
  56     try {
  57       Class c = TestIntUnsafeVolatile.class.getClassLoader().loadClass("jdk.internal.misc.Unsafe");
  58       Field f = c.getDeclaredField("theUnsafe");
  59       f.setAccessible(true);
  60       unsafe = (Unsafe)f.get(c);
  61       BASE = unsafe.arrayBaseOffset(int[].class);
  62     } catch (Exception e) {
  63       InternalError err = new InternalError();
  64       err.initCause(e);
  65       throw err;
  66     }
  67   }
  68 
  69   public static void main(String args[]) {
  70     System.out.println("Testing Integer array unsafe volatile operations");
  71     int errn = test(false);
  72     if (errn > 0) {
  73       System.err.println("FAILED: " + errn + " errors");
  74       System.exit(97);
  75     }
  76     System.out.println("PASSED");
  77   }
  78 
  79   static int test(boolean test_only) {
  80     int[] a1 = new int[ARRLEN];


   1 /*
   2  * Copyright (c) 2013, 2016, 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  *


  33  *    compiler.c2.cr8004867.TestIntUnsafeVolatile
  34  * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation
  35  *    -XX:+OptimizeFill
  36  *    compiler.c2.cr8004867.TestIntUnsafeVolatile
  37  */
  38 
  39 package compiler.c2.cr8004867;
  40 
  41 import jdk.internal.misc.Unsafe;
  42 
  43 import java.lang.reflect.Field;
  44 
  45 public class TestIntUnsafeVolatile {
  46   private static final int ARRLEN = 97;
  47   private static final int ITERS  = 11000;
  48   private static final int OFFSET = 3;
  49   private static final int SCALE = 2;
  50   private static final int ALIGN_OFF = 8;
  51   private static final int UNALIGN_OFF = 5;
  52 
  53   private static final Unsafe unsafe = Unsafe.getUnsafe();
  54   private static final int BASE;
  55   static {
  56     try {




  57       BASE = unsafe.arrayBaseOffset(int[].class);
  58     } catch (Exception e) {
  59       InternalError err = new InternalError();
  60       err.initCause(e);
  61       throw err;
  62     }
  63   }
  64 
  65   public static void main(String args[]) {
  66     System.out.println("Testing Integer array unsafe volatile operations");
  67     int errn = test(false);
  68     if (errn > 0) {
  69       System.err.println("FAILED: " + errn + " errors");
  70       System.exit(97);
  71     }
  72     System.out.println("PASSED");
  73   }
  74 
  75   static int test(boolean test_only) {
  76     int[] a1 = new int[ARRLEN];


< prev index next >