< prev index next >

test/compiler/profiling/UnsafeAccess.java

Print this page
rev 12711 : 8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
Reviewed-by: psandoz, dholmes, thartmann
Contributed-by: ron.pressler@oracle.com, claes.redestad@oracle.com


  47         return null;
  48     }
  49 
  50     static Object helperUnsafeAccess(Object o, boolean isObjArray) {
  51         if (isObjArray) {
  52             U.putObject(o, off, new Object());
  53         }
  54         return o;
  55     }
  56 
  57     static Object testUnsafeLoadStore(Object o, boolean isObjArray) {
  58         if (o != null && cls.isInstance(o)) { // speculates "o" type to int[]
  59             return helperUnsafeLoadStore(o, isObjArray);
  60         }
  61         return null;
  62     }
  63 
  64     static Object helperUnsafeLoadStore(Object o, boolean isObjArray) {
  65         if (isObjArray) {
  66             Object o1 = U.getObject(o, off);
  67             U.compareAndSwapObject(o, off, o1, new Object());
  68         }
  69         return o;
  70     }
  71 
  72     public static void main(String[] args) {
  73         Object[] objArray = new Object[10];
  74         int[]    intArray = new    int[10];
  75 
  76         for (int i = 0; i < 20_000; i++) {
  77             helperUnsafeAccess(objArray, true);
  78         }
  79         for (int i = 0; i < 20_000; i++) {
  80             testUnsafeAccess(intArray, false);
  81         }
  82 
  83         for (int i = 0; i < 20_000; i++) {
  84             helperUnsafeLoadStore(objArray, true);
  85         }
  86         for (int i = 0; i < 20_000; i++) {
  87             testUnsafeLoadStore(intArray, false);


  47         return null;
  48     }
  49 
  50     static Object helperUnsafeAccess(Object o, boolean isObjArray) {
  51         if (isObjArray) {
  52             U.putObject(o, off, new Object());
  53         }
  54         return o;
  55     }
  56 
  57     static Object testUnsafeLoadStore(Object o, boolean isObjArray) {
  58         if (o != null && cls.isInstance(o)) { // speculates "o" type to int[]
  59             return helperUnsafeLoadStore(o, isObjArray);
  60         }
  61         return null;
  62     }
  63 
  64     static Object helperUnsafeLoadStore(Object o, boolean isObjArray) {
  65         if (isObjArray) {
  66             Object o1 = U.getObject(o, off);
  67             U.compareAndSetObject(o, off, o1, new Object());
  68         }
  69         return o;
  70     }
  71 
  72     public static void main(String[] args) {
  73         Object[] objArray = new Object[10];
  74         int[]    intArray = new    int[10];
  75 
  76         for (int i = 0; i < 20_000; i++) {
  77             helperUnsafeAccess(objArray, true);
  78         }
  79         for (int i = 0; i < 20_000; i++) {
  80             testUnsafeAccess(intArray, false);
  81         }
  82 
  83         for (int i = 0; i < 20_000; i++) {
  84             helperUnsafeLoadStore(objArray, true);
  85         }
  86         for (int i = 0; i < 20_000; i++) {
  87             testUnsafeLoadStore(intArray, false);
< prev index next >