< prev index next >

test/compiler/c2/cr8004867/TestIntUnsafeCAS.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


 756       test_2ci_unaln(a1, a2);
 757     }
 758     end = System.currentTimeMillis();
 759     System.out.println("test_2ci_unaln: " + (end - start));
 760     start = System.currentTimeMillis();
 761     for (int i=0; i<ITERS; i++) {
 762       test_2vi_unaln(a1, a2, 123, 103);
 763     }
 764     end = System.currentTimeMillis();
 765     System.out.println("test_2vi_unaln: " + (end - start));
 766 
 767     return errn;
 768   }
 769 
 770   private final static long byte_offset(int i) {
 771     return ((long)i << 2) + BASE;
 772   }
 773 
 774   static void test_ci(int[] a) {
 775     for (int i = 0; i < ARRLEN; i+=1) {
 776       unsafe.compareAndSwapInt(a, byte_offset(i), -1, -123);
 777     }
 778   }
 779   static void test_vi(int[] a, int b, int old) {
 780     for (int i = 0; i < ARRLEN; i+=1) {
 781       unsafe.compareAndSwapInt(a, byte_offset(i), old, b);
 782     }
 783   }
 784   static void test_cp(int[] a, int[] b) {
 785     for (int i = 0; i < ARRLEN; i+=1) {
 786       unsafe.compareAndSwapInt(a, byte_offset(i), -123, b[i]);
 787     }
 788   }
 789   static void test_2ci(int[] a, int[] b) {
 790     for (int i = 0; i < ARRLEN; i+=1) {
 791       unsafe.compareAndSwapInt(a, byte_offset(i), 123, -123);
 792       unsafe.compareAndSwapInt(b, byte_offset(i), 123, -103);
 793     }
 794   }
 795   static void test_2vi(int[] a, int[] b, int c, int d) {
 796     for (int i = 0; i < ARRLEN; i+=1) {
 797       unsafe.compareAndSwapInt(a, byte_offset(i), -123, c);
 798       unsafe.compareAndSwapInt(b, byte_offset(i), -103, d);
 799     }
 800   }
 801   static void test_ci_neg(int[] a, int old) {
 802     for (int i = ARRLEN-1; i >= 0; i-=1) {
 803       unsafe.compareAndSwapInt(a, byte_offset(i), old, -123);
 804     }
 805   }
 806   static void test_vi_neg(int[] a, int b, int old) {
 807     for (int i = ARRLEN-1; i >= 0; i-=1) {
 808       unsafe.compareAndSwapInt(a, byte_offset(i), old, b);
 809     }
 810   }
 811   static void test_cp_neg(int[] a, int[] b) {
 812     for (int i = ARRLEN-1; i >= 0; i-=1) {
 813       unsafe.compareAndSwapInt(a, byte_offset(i), -123, b[i]);
 814     }
 815   }
 816   static void test_2ci_neg(int[] a, int[] b) {
 817     for (int i = ARRLEN-1; i >= 0; i-=1) {
 818       unsafe.compareAndSwapInt(a, byte_offset(i), 123, -123);
 819       unsafe.compareAndSwapInt(b, byte_offset(i), 123, -103);
 820     }
 821   }
 822   static void test_2vi_neg(int[] a, int[] b, int c, int d) {
 823     for (int i = ARRLEN-1; i >= 0; i-=1) {
 824       unsafe.compareAndSwapInt(a, byte_offset(i), -123, c);
 825       unsafe.compareAndSwapInt(b, byte_offset(i), -103, d);
 826     }
 827   }
 828   static void test_ci_oppos(int[] a, int old) {
 829     int limit = ARRLEN-1;
 830     for (int i = 0; i < ARRLEN; i+=1) {
 831       unsafe.compareAndSwapInt(a, byte_offset(limit-i), old, -123);
 832     }
 833   }
 834   static void test_vi_oppos(int[] a, int b, int old) {
 835     int limit = ARRLEN-1;
 836     for (int i = limit; i >= 0; i-=1) {
 837       unsafe.compareAndSwapInt(a, byte_offset(limit-i), old, b);
 838     }
 839   }
 840   static void test_cp_oppos(int[] a, int[] b) {
 841     int limit = ARRLEN-1;
 842     for (int i = 0; i < ARRLEN; i+=1) {
 843       unsafe.compareAndSwapInt(a, byte_offset(i), -123, b[limit-i]);
 844     }
 845   }
 846   static void test_2ci_oppos(int[] a, int[] b) {
 847     int limit = ARRLEN-1;
 848     for (int i = 0; i < ARRLEN; i+=1) {
 849       unsafe.compareAndSwapInt(a, byte_offset(limit-i), 123, -123);
 850       unsafe.compareAndSwapInt(b, byte_offset(i), 123, -103);
 851     }
 852   }
 853   static void test_2vi_oppos(int[] a, int[] b, int c, int d) {
 854     int limit = ARRLEN-1;
 855     for (int i = limit; i >= 0; i-=1) {
 856       unsafe.compareAndSwapInt(a, byte_offset(i), -123, c);
 857       unsafe.compareAndSwapInt(b, byte_offset(limit-i), -103, d);
 858     }
 859   }
 860   static void test_ci_off(int[] a, int old) {
 861     for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
 862       unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), old, -123);
 863     }
 864   }
 865   static void test_vi_off(int[] a, int b, int old) {
 866     for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
 867       unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), old, b);
 868     }
 869   }
 870   static void test_cp_off(int[] a, int[] b) {
 871     for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
 872       unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), -123, b[i+OFFSET]);
 873     }
 874   }
 875   static void test_2ci_off(int[] a, int[] b) {
 876     for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
 877       unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), 123, -123);
 878       unsafe.compareAndSwapInt(b, byte_offset(i+OFFSET), 123, -103);
 879     }
 880   }
 881   static void test_2vi_off(int[] a, int[] b, int c, int d) {
 882     for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
 883       unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), -123, c);
 884       unsafe.compareAndSwapInt(b, byte_offset(i+OFFSET), -103, d);
 885     }
 886   }
 887   static void test_ci_inv(int[] a, int k, int old) {
 888     for (int i = 0; i < ARRLEN-k; i+=1) {
 889       unsafe.compareAndSwapInt(a, byte_offset(i+k), old, -123);
 890     }
 891   }
 892   static void test_vi_inv(int[] a, int b, int k, int old) {
 893     for (int i = 0; i < ARRLEN-k; i+=1) {
 894       unsafe.compareAndSwapInt(a, byte_offset(i+k), old, b);
 895     }
 896   }
 897   static void test_cp_inv(int[] a, int[] b, int k) {
 898     for (int i = 0; i < ARRLEN-k; i+=1) {
 899       unsafe.compareAndSwapInt(a, byte_offset(i+k), -123, b[i+k]);
 900     }
 901   }
 902   static void test_2ci_inv(int[] a, int[] b, int k) {
 903     for (int i = 0; i < ARRLEN-k; i+=1) {
 904       unsafe.compareAndSwapInt(a, byte_offset(i+k), 123, -123);
 905       unsafe.compareAndSwapInt(b, byte_offset(i+k), 123, -103);
 906     }
 907   }
 908   static void test_2vi_inv(int[] a, int[] b, int c, int d, int k) {
 909     for (int i = 0; i < ARRLEN-k; i+=1) {
 910       unsafe.compareAndSwapInt(a, byte_offset(i+k), -123, c);
 911       unsafe.compareAndSwapInt(b, byte_offset(i+k), -103, d);
 912     }
 913   }
 914   static void test_ci_scl(int[] a, int old) {
 915     for (int i = 0; i*SCALE < ARRLEN; i+=1) {
 916       unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), old, -123);
 917     }
 918   }
 919   static void test_vi_scl(int[] a, int b, int old) {
 920     for (int i = 0; i*SCALE < ARRLEN; i+=1) {
 921       unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), old, b);
 922     }
 923   }
 924   static void test_cp_scl(int[] a, int[] b) {
 925     for (int i = 0; i*SCALE < ARRLEN; i+=1) {
 926       unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), -123, b[i*SCALE]);
 927     }
 928   }
 929   static void test_2ci_scl(int[] a, int[] b) {
 930     for (int i = 0; i*SCALE < ARRLEN; i+=1) {
 931       unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), 123, -123);
 932       unsafe.compareAndSwapInt(b, byte_offset(i*SCALE), 123, -103);
 933     }
 934   }
 935   static void test_2vi_scl(int[] a, int[] b, int c, int d) {
 936     for (int i = 0; i*SCALE < ARRLEN; i+=1) {
 937       unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), -123, c);
 938       unsafe.compareAndSwapInt(b, byte_offset(i*SCALE), -103, d);
 939     }
 940   }
 941   static void test_cp_alndst(int[] a, int[] b) {
 942     for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
 943       unsafe.compareAndSwapInt(a, byte_offset(i+ALIGN_OFF), -1, b[i]);
 944     }
 945   }
 946   static void test_cp_alnsrc(int[] a, int[] b) {
 947     for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
 948       int old = unsafe.getIntVolatile(a, byte_offset(i));
 949       unsafe.compareAndSwapInt(a, byte_offset(i), old, b[i+ALIGN_OFF]);
 950     }
 951   }
 952   static void test_2ci_aln(int[] a, int[] b) {
 953     for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
 954       unsafe.compareAndSwapInt(a, byte_offset(i+ALIGN_OFF), -1, -123);
 955       int old = unsafe.getIntVolatile(b, byte_offset(i));
 956       unsafe.compareAndSwapInt(b, byte_offset(i), old, -103);
 957     }
 958   }
 959   static void test_2vi_aln(int[] a, int[] b, int c, int d) {
 960     for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
 961       int old = unsafe.getIntVolatile(a, byte_offset(i));
 962       unsafe.compareAndSwapInt(a, byte_offset(i), old, c);
 963       old = unsafe.getIntVolatile(b, byte_offset(i+ALIGN_OFF));
 964       unsafe.compareAndSwapInt(b, byte_offset(i+ALIGN_OFF), old, d);
 965     }
 966   }
 967   static void test_cp_unalndst(int[] a, int[] b) {
 968     for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
 969       unsafe.compareAndSwapInt(a, byte_offset(i+UNALIGN_OFF), -1, b[i]);
 970     }
 971   }
 972   static void test_cp_unalnsrc(int[] a, int[] b) {
 973     for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
 974       int old = unsafe.getIntVolatile(a, byte_offset(i));
 975       unsafe.compareAndSwapInt(a, byte_offset(i), old, b[i+UNALIGN_OFF]);
 976     }
 977   }
 978   static void test_2ci_unaln(int[] a, int[] b) {
 979     for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
 980       unsafe.compareAndSwapInt(a, byte_offset(i+UNALIGN_OFF), -1, -123);
 981       int old = unsafe.getIntVolatile(b, byte_offset(i));
 982       unsafe.compareAndSwapInt(b, byte_offset(i), old, -103);
 983     }
 984   }
 985   static void test_2vi_unaln(int[] a, int[] b, int c, int d) {
 986     for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
 987       int old = unsafe.getIntVolatile(a, byte_offset(i));
 988       unsafe.compareAndSwapInt(a, byte_offset(i), old, c);
 989       old = unsafe.getIntVolatile(b, byte_offset(i+UNALIGN_OFF));
 990       unsafe.compareAndSwapInt(b, byte_offset(i+UNALIGN_OFF), old, d);
 991     }
 992   }
 993 
 994   static int verify(String text, int i, int elem, int val) {
 995     if (elem != val) {
 996       System.err.println(text + "[" + i + "] = " + elem + " != " + val);
 997       return 1;
 998     }
 999     return 0;
1000   }
1001 }


 756       test_2ci_unaln(a1, a2);
 757     }
 758     end = System.currentTimeMillis();
 759     System.out.println("test_2ci_unaln: " + (end - start));
 760     start = System.currentTimeMillis();
 761     for (int i=0; i<ITERS; i++) {
 762       test_2vi_unaln(a1, a2, 123, 103);
 763     }
 764     end = System.currentTimeMillis();
 765     System.out.println("test_2vi_unaln: " + (end - start));
 766 
 767     return errn;
 768   }
 769 
 770   private final static long byte_offset(int i) {
 771     return ((long)i << 2) + BASE;
 772   }
 773 
 774   static void test_ci(int[] a) {
 775     for (int i = 0; i < ARRLEN; i+=1) {
 776       unsafe.compareAndSetInt(a, byte_offset(i), -1, -123);
 777     }
 778   }
 779   static void test_vi(int[] a, int b, int old) {
 780     for (int i = 0; i < ARRLEN; i+=1) {
 781       unsafe.compareAndSetInt(a, byte_offset(i), old, b);
 782     }
 783   }
 784   static void test_cp(int[] a, int[] b) {
 785     for (int i = 0; i < ARRLEN; i+=1) {
 786       unsafe.compareAndSetInt(a, byte_offset(i), -123, b[i]);
 787     }
 788   }
 789   static void test_2ci(int[] a, int[] b) {
 790     for (int i = 0; i < ARRLEN; i+=1) {
 791       unsafe.compareAndSetInt(a, byte_offset(i), 123, -123);
 792       unsafe.compareAndSetInt(b, byte_offset(i), 123, -103);
 793     }
 794   }
 795   static void test_2vi(int[] a, int[] b, int c, int d) {
 796     for (int i = 0; i < ARRLEN; i+=1) {
 797       unsafe.compareAndSetInt(a, byte_offset(i), -123, c);
 798       unsafe.compareAndSetInt(b, byte_offset(i), -103, d);
 799     }
 800   }
 801   static void test_ci_neg(int[] a, int old) {
 802     for (int i = ARRLEN-1; i >= 0; i-=1) {
 803       unsafe.compareAndSetInt(a, byte_offset(i), old, -123);
 804     }
 805   }
 806   static void test_vi_neg(int[] a, int b, int old) {
 807     for (int i = ARRLEN-1; i >= 0; i-=1) {
 808       unsafe.compareAndSetInt(a, byte_offset(i), old, b);
 809     }
 810   }
 811   static void test_cp_neg(int[] a, int[] b) {
 812     for (int i = ARRLEN-1; i >= 0; i-=1) {
 813       unsafe.compareAndSetInt(a, byte_offset(i), -123, b[i]);
 814     }
 815   }
 816   static void test_2ci_neg(int[] a, int[] b) {
 817     for (int i = ARRLEN-1; i >= 0; i-=1) {
 818       unsafe.compareAndSetInt(a, byte_offset(i), 123, -123);
 819       unsafe.compareAndSetInt(b, byte_offset(i), 123, -103);
 820     }
 821   }
 822   static void test_2vi_neg(int[] a, int[] b, int c, int d) {
 823     for (int i = ARRLEN-1; i >= 0; i-=1) {
 824       unsafe.compareAndSetInt(a, byte_offset(i), -123, c);
 825       unsafe.compareAndSetInt(b, byte_offset(i), -103, d);
 826     }
 827   }
 828   static void test_ci_oppos(int[] a, int old) {
 829     int limit = ARRLEN-1;
 830     for (int i = 0; i < ARRLEN; i+=1) {
 831       unsafe.compareAndSetInt(a, byte_offset(limit-i), old, -123);
 832     }
 833   }
 834   static void test_vi_oppos(int[] a, int b, int old) {
 835     int limit = ARRLEN-1;
 836     for (int i = limit; i >= 0; i-=1) {
 837       unsafe.compareAndSetInt(a, byte_offset(limit-i), old, b);
 838     }
 839   }
 840   static void test_cp_oppos(int[] a, int[] b) {
 841     int limit = ARRLEN-1;
 842     for (int i = 0; i < ARRLEN; i+=1) {
 843       unsafe.compareAndSetInt(a, byte_offset(i), -123, b[limit-i]);
 844     }
 845   }
 846   static void test_2ci_oppos(int[] a, int[] b) {
 847     int limit = ARRLEN-1;
 848     for (int i = 0; i < ARRLEN; i+=1) {
 849       unsafe.compareAndSetInt(a, byte_offset(limit-i), 123, -123);
 850       unsafe.compareAndSetInt(b, byte_offset(i), 123, -103);
 851     }
 852   }
 853   static void test_2vi_oppos(int[] a, int[] b, int c, int d) {
 854     int limit = ARRLEN-1;
 855     for (int i = limit; i >= 0; i-=1) {
 856       unsafe.compareAndSetInt(a, byte_offset(i), -123, c);
 857       unsafe.compareAndSetInt(b, byte_offset(limit-i), -103, d);
 858     }
 859   }
 860   static void test_ci_off(int[] a, int old) {
 861     for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
 862       unsafe.compareAndSetInt(a, byte_offset(i+OFFSET), old, -123);
 863     }
 864   }
 865   static void test_vi_off(int[] a, int b, int old) {
 866     for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
 867       unsafe.compareAndSetInt(a, byte_offset(i+OFFSET), old, b);
 868     }
 869   }
 870   static void test_cp_off(int[] a, int[] b) {
 871     for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
 872       unsafe.compareAndSetInt(a, byte_offset(i+OFFSET), -123, b[i+OFFSET]);
 873     }
 874   }
 875   static void test_2ci_off(int[] a, int[] b) {
 876     for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
 877       unsafe.compareAndSetInt(a, byte_offset(i+OFFSET), 123, -123);
 878       unsafe.compareAndSetInt(b, byte_offset(i+OFFSET), 123, -103);
 879     }
 880   }
 881   static void test_2vi_off(int[] a, int[] b, int c, int d) {
 882     for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
 883       unsafe.compareAndSetInt(a, byte_offset(i+OFFSET), -123, c);
 884       unsafe.compareAndSetInt(b, byte_offset(i+OFFSET), -103, d);
 885     }
 886   }
 887   static void test_ci_inv(int[] a, int k, int old) {
 888     for (int i = 0; i < ARRLEN-k; i+=1) {
 889       unsafe.compareAndSetInt(a, byte_offset(i+k), old, -123);
 890     }
 891   }
 892   static void test_vi_inv(int[] a, int b, int k, int old) {
 893     for (int i = 0; i < ARRLEN-k; i+=1) {
 894       unsafe.compareAndSetInt(a, byte_offset(i+k), old, b);
 895     }
 896   }
 897   static void test_cp_inv(int[] a, int[] b, int k) {
 898     for (int i = 0; i < ARRLEN-k; i+=1) {
 899       unsafe.compareAndSetInt(a, byte_offset(i+k), -123, b[i+k]);
 900     }
 901   }
 902   static void test_2ci_inv(int[] a, int[] b, int k) {
 903     for (int i = 0; i < ARRLEN-k; i+=1) {
 904       unsafe.compareAndSetInt(a, byte_offset(i+k), 123, -123);
 905       unsafe.compareAndSetInt(b, byte_offset(i+k), 123, -103);
 906     }
 907   }
 908   static void test_2vi_inv(int[] a, int[] b, int c, int d, int k) {
 909     for (int i = 0; i < ARRLEN-k; i+=1) {
 910       unsafe.compareAndSetInt(a, byte_offset(i+k), -123, c);
 911       unsafe.compareAndSetInt(b, byte_offset(i+k), -103, d);
 912     }
 913   }
 914   static void test_ci_scl(int[] a, int old) {
 915     for (int i = 0; i*SCALE < ARRLEN; i+=1) {
 916       unsafe.compareAndSetInt(a, byte_offset(i*SCALE), old, -123);
 917     }
 918   }
 919   static void test_vi_scl(int[] a, int b, int old) {
 920     for (int i = 0; i*SCALE < ARRLEN; i+=1) {
 921       unsafe.compareAndSetInt(a, byte_offset(i*SCALE), old, b);
 922     }
 923   }
 924   static void test_cp_scl(int[] a, int[] b) {
 925     for (int i = 0; i*SCALE < ARRLEN; i+=1) {
 926       unsafe.compareAndSetInt(a, byte_offset(i*SCALE), -123, b[i*SCALE]);
 927     }
 928   }
 929   static void test_2ci_scl(int[] a, int[] b) {
 930     for (int i = 0; i*SCALE < ARRLEN; i+=1) {
 931       unsafe.compareAndSetInt(a, byte_offset(i*SCALE), 123, -123);
 932       unsafe.compareAndSetInt(b, byte_offset(i*SCALE), 123, -103);
 933     }
 934   }
 935   static void test_2vi_scl(int[] a, int[] b, int c, int d) {
 936     for (int i = 0; i*SCALE < ARRLEN; i+=1) {
 937       unsafe.compareAndSetInt(a, byte_offset(i*SCALE), -123, c);
 938       unsafe.compareAndSetInt(b, byte_offset(i*SCALE), -103, d);
 939     }
 940   }
 941   static void test_cp_alndst(int[] a, int[] b) {
 942     for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
 943       unsafe.compareAndSetInt(a, byte_offset(i+ALIGN_OFF), -1, b[i]);
 944     }
 945   }
 946   static void test_cp_alnsrc(int[] a, int[] b) {
 947     for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
 948       int old = unsafe.getIntVolatile(a, byte_offset(i));
 949       unsafe.compareAndSetInt(a, byte_offset(i), old, b[i+ALIGN_OFF]);
 950     }
 951   }
 952   static void test_2ci_aln(int[] a, int[] b) {
 953     for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
 954       unsafe.compareAndSetInt(a, byte_offset(i+ALIGN_OFF), -1, -123);
 955       int old = unsafe.getIntVolatile(b, byte_offset(i));
 956       unsafe.compareAndSetInt(b, byte_offset(i), old, -103);
 957     }
 958   }
 959   static void test_2vi_aln(int[] a, int[] b, int c, int d) {
 960     for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
 961       int old = unsafe.getIntVolatile(a, byte_offset(i));
 962       unsafe.compareAndSetInt(a, byte_offset(i), old, c);
 963       old = unsafe.getIntVolatile(b, byte_offset(i+ALIGN_OFF));
 964       unsafe.compareAndSetInt(b, byte_offset(i+ALIGN_OFF), old, d);
 965     }
 966   }
 967   static void test_cp_unalndst(int[] a, int[] b) {
 968     for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
 969       unsafe.compareAndSetInt(a, byte_offset(i+UNALIGN_OFF), -1, b[i]);
 970     }
 971   }
 972   static void test_cp_unalnsrc(int[] a, int[] b) {
 973     for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
 974       int old = unsafe.getIntVolatile(a, byte_offset(i));
 975       unsafe.compareAndSetInt(a, byte_offset(i), old, b[i+UNALIGN_OFF]);
 976     }
 977   }
 978   static void test_2ci_unaln(int[] a, int[] b) {
 979     for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
 980       unsafe.compareAndSetInt(a, byte_offset(i+UNALIGN_OFF), -1, -123);
 981       int old = unsafe.getIntVolatile(b, byte_offset(i));
 982       unsafe.compareAndSetInt(b, byte_offset(i), old, -103);
 983     }
 984   }
 985   static void test_2vi_unaln(int[] a, int[] b, int c, int d) {
 986     for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
 987       int old = unsafe.getIntVolatile(a, byte_offset(i));
 988       unsafe.compareAndSetInt(a, byte_offset(i), old, c);
 989       old = unsafe.getIntVolatile(b, byte_offset(i+UNALIGN_OFF));
 990       unsafe.compareAndSetInt(b, byte_offset(i+UNALIGN_OFF), old, d);
 991     }
 992   }
 993 
 994   static int verify(String text, int i, int elem, int val) {
 995     if (elem != val) {
 996       System.err.println(text + "[" + i + "] = " + elem + " != " + val);
 997       return 1;
 998     }
 999     return 0;
1000   }
1001 }
< prev index next >