test/compiler/8004867/TestIntAtomicOrdered.java

Mon, 28 Jul 2014 15:06:38 -0700

author
fzhinkin
date
Mon, 28 Jul 2014 15:06:38 -0700
changeset 6997
dbb05f6d93c4
parent 0
f90c822e73f8
permissions
-rw-r--r--

8051344: JVM crashed in Compile::start() during method parsing w/ UseRTMDeopt turned on
Summary: call rtm_deopt() only if there were no compilation bailouts before.
Reviewed-by: kvn

     1 /*
     2  * Copyright (c) 2013, 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  *
    23  */
    25 /**
    26  * @test
    27  * @bug 8004867
    28  * @summary VM crashing with assert "share/vm/opto/node.hpp:357 - assert(i < _max) failed: oob"
    29  *
    30  * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:-OptimizeFill TestIntAtomicOrdered
    31  * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:+OptimizeFill TestIntAtomicOrdered
    32  */
    34 import java.util.concurrent.atomic.AtomicIntegerArray;
    36 public class TestIntAtomicOrdered {
    37   private static final int ARRLEN = 97;
    38   private static final int ITERS  = 11000;
    39   private static final int OFFSET = 3;
    40   private static final int SCALE = 2;
    41   private static final int ALIGN_OFF = 8;
    42   private static final int UNALIGN_OFF = 5;
    44   public static void main(String args[]) {
    45     System.out.println("Testing Integer array atomic ordered operations");
    46     int errn = test(false);
    47     if (errn > 0) {
    48       System.err.println("FAILED: " + errn + " errors");
    49       System.exit(97);
    50     }
    51     System.out.println("PASSED");
    52   }
    54   static int test(boolean test_only) {
    55     AtomicIntegerArray a1 = new AtomicIntegerArray(ARRLEN);
    56     AtomicIntegerArray a2 = new AtomicIntegerArray(ARRLEN);
    57     // Initialize
    58     for (int i=0; i<ARRLEN; i++) {
    59       a1.lazySet(i, -1);
    60       a2.lazySet(i, -1);
    61     }
    62     System.out.println("Warmup");
    63     for (int i=0; i<ITERS; i++) {
    64       test_ci(a1);
    65       test_vi(a2, 123, -1);
    66       test_cp(a1, a2);
    67       test_2ci(a1, a2);
    68       test_2vi(a1, a2, 123, 103);
    69       test_ci_neg(a1, 123);
    70       test_vi_neg(a2, 123, 103);
    71       test_cp_neg(a1, a2);
    72       test_2ci_neg(a1, a2);
    73       test_2vi_neg(a1, a2, 123, 103);
    74       test_ci_oppos(a1, 123);
    75       test_vi_oppos(a2, 123, 103);
    76       test_cp_oppos(a1, a2);
    77       test_2ci_oppos(a1, a2);
    78       test_2vi_oppos(a1, a2, 123, 103);
    79       test_ci_off(a1, 123);
    80       test_vi_off(a2, 123, 103);
    81       test_cp_off(a1, a2);
    82       test_2ci_off(a1, a2);
    83       test_2vi_off(a1, a2, 123, 103);
    84       test_ci_inv(a1, OFFSET, 123);
    85       test_vi_inv(a2, 123, OFFSET, 103);
    86       test_cp_inv(a1, a2, OFFSET);
    87       test_2ci_inv(a1, a2, OFFSET);
    88       test_2vi_inv(a1, a2, 123, 103, OFFSET);
    89       test_ci_scl(a1, 123);
    90       test_vi_scl(a2, 123, 103);
    91       test_cp_scl(a1, a2);
    92       test_2ci_scl(a1, a2);
    93       test_2vi_scl(a1, a2, 123, 103);
    94       test_cp_alndst(a1, a2);
    95       test_cp_alnsrc(a1, a2);
    96       test_2ci_aln(a1, a2);
    97       test_2vi_aln(a1, a2, 123, 103);
    98       test_cp_unalndst(a1, a2);
    99       test_cp_unalnsrc(a1, a2);
   100       test_2ci_unaln(a1, a2);
   101       test_2vi_unaln(a1, a2, 123, 103);
   102     }
   103     // Initialize
   104     for (int i=0; i<ARRLEN; i++) {
   105       a1.lazySet(i, -1);
   106       a2.lazySet(i, -1);
   107     }
   108     // Test and verify results
   109     System.out.println("Verification");
   110     int errn = 0;
   111     {
   112       test_ci(a1);
   113       for (int i=0; i<ARRLEN; i++) {
   114         errn += verify("test_ci: a1", i, a1.get(i), -123);
   115       }
   116       test_vi(a2, 123, -1);
   117       for (int i=0; i<ARRLEN; i++) {
   118         errn += verify("test_vi: a2", i, a2.get(i), 123);
   119       }
   120       test_cp(a1, a2);
   121       for (int i=0; i<ARRLEN; i++) {
   122         errn += verify("test_cp: a1", i, a1.get(i), 123);
   123       }
   124       test_2ci(a1, a2);
   125       for (int i=0; i<ARRLEN; i++) {
   126         errn += verify("test_2ci: a1", i, a1.get(i), -123);
   127         errn += verify("test_2ci: a2", i, a2.get(i), -103);
   128       }
   129       test_2vi(a1, a2, 123, 103);
   130       for (int i=0; i<ARRLEN; i++) {
   131         errn += verify("test_2vi: a1", i, a1.get(i), 123);
   132         errn += verify("test_2vi: a2", i, a2.get(i), 103);
   133       }
   134       // Reset for negative stride
   135       for (int i=0; i<ARRLEN; i++) {
   136         a1.lazySet(i, -1);
   137         a2.lazySet(i, -1);
   138       }
   139       test_ci_neg(a1, -1);
   140       for (int i=0; i<ARRLEN; i++) {
   141         errn += verify("test_ci_neg: a1", i, a1.get(i), -123);
   142       }
   143       test_vi_neg(a2, 123, -1);
   144       for (int i=0; i<ARRLEN; i++) {
   145         errn += verify("test_vi_neg: a2", i, a2.get(i), 123);
   146       }
   147       test_cp_neg(a1, a2);
   148       for (int i=0; i<ARRLEN; i++) {
   149         errn += verify("test_cp_neg: a1", i, a1.get(i), 123);
   150       }
   151       test_2ci_neg(a1, a2);
   152       for (int i=0; i<ARRLEN; i++) {
   153         errn += verify("test_2ci_neg: a1", i, a1.get(i), -123);
   154         errn += verify("test_2ci_neg: a2", i, a2.get(i), -103);
   155       }
   156       test_2vi_neg(a1, a2, 123, 103);
   157       for (int i=0; i<ARRLEN; i++) {
   158         errn += verify("test_2vi_neg: a1", i, a1.get(i), 123);
   159         errn += verify("test_2vi_neg: a2", i, a2.get(i), 103);
   160       }
   161       // Reset for opposite stride
   162       for (int i=0; i<ARRLEN; i++) {
   163         a1.lazySet(i, -1);
   164         a2.lazySet(i, -1);
   165       }
   166       test_ci_oppos(a1, -1);
   167       for (int i=0; i<ARRLEN; i++) {
   168         errn += verify("test_ci_oppos: a1", i, a1.get(i), -123);
   169       }
   170       test_vi_oppos(a2, 123, -1);
   171       for (int i=0; i<ARRLEN; i++) {
   172         errn += verify("test_vi_oppos: a2", i, a2.get(i), 123);
   173       }
   174       test_cp_oppos(a1, a2);
   175       for (int i=0; i<ARRLEN; i++) {
   176         errn += verify("test_cp_oppos: a1", i, a1.get(i), 123);
   177       }
   178       test_2ci_oppos(a1, a2);
   179       for (int i=0; i<ARRLEN; i++) {
   180         errn += verify("test_2ci_oppos: a1", i, a1.get(i), -123);
   181         errn += verify("test_2ci_oppos: a2", i, a2.get(i), -103);
   182       }
   183       test_2vi_oppos(a1, a2, 123, 103);
   184       for (int i=0; i<ARRLEN; i++) {
   185         errn += verify("test_2vi_oppos: a1", i, a1.get(i), 123);
   186         errn += verify("test_2vi_oppos: a2", i, a2.get(i), 103);
   187       }
   188       // Reset for indexing with offset
   189       for (int i=0; i<ARRLEN; i++) {
   190         a1.lazySet(i, -1);
   191         a2.lazySet(i, -1);
   192       }
   193       test_ci_off(a1, -1);
   194       for (int i=OFFSET; i<ARRLEN; i++) {
   195         errn += verify("test_ci_off: a1", i, a1.get(i), -123);
   196       }
   197       test_vi_off(a2, 123, -1);
   198       for (int i=OFFSET; i<ARRLEN; i++) {
   199         errn += verify("test_vi_off: a2", i, a2.get(i), 123);
   200       }
   201       test_cp_off(a1, a2);
   202       for (int i=OFFSET; i<ARRLEN; i++) {
   203         errn += verify("test_cp_off: a1", i, a1.get(i), 123);
   204       }
   205       test_2ci_off(a1, a2);
   206       for (int i=OFFSET; i<ARRLEN; i++) {
   207         errn += verify("test_2ci_off: a1", i, a1.get(i), -123);
   208         errn += verify("test_2ci_off: a2", i, a2.get(i), -103);
   209       }
   210       test_2vi_off(a1, a2, 123, 103);
   211       for (int i=OFFSET; i<ARRLEN; i++) {
   212         errn += verify("test_2vi_off: a1", i, a1.get(i), 123);
   213         errn += verify("test_2vi_off: a2", i, a2.get(i), 103);
   214       }
   215       for (int i=0; i<OFFSET; i++) {
   216         errn += verify("test_2vi_off: a1", i, a1.get(i), -1);
   217         errn += verify("test_2vi_off: a2", i, a2.get(i), -1);
   218       }
   219       // Reset for indexing with invariant offset
   220       for (int i=0; i<ARRLEN; i++) {
   221         a1.lazySet(i, -1);
   222         a2.lazySet(i, -1);
   223       }
   224       test_ci_inv(a1, OFFSET, -1);
   225       for (int i=OFFSET; i<ARRLEN; i++) {
   226         errn += verify("test_ci_inv: a1", i, a1.get(i), -123);
   227       }
   228       test_vi_inv(a2, 123, OFFSET, -1);
   229       for (int i=OFFSET; i<ARRLEN; i++) {
   230         errn += verify("test_vi_inv: a2", i, a2.get(i), 123);
   231       }
   232       test_cp_inv(a1, a2, OFFSET);
   233       for (int i=OFFSET; i<ARRLEN; i++) {
   234         errn += verify("test_cp_inv: a1", i, a1.get(i), 123);
   235       }
   236       test_2ci_inv(a1, a2, OFFSET);
   237       for (int i=OFFSET; i<ARRLEN; i++) {
   238         errn += verify("test_2ci_inv: a1", i, a1.get(i), -123);
   239         errn += verify("test_2ci_inv: a2", i, a2.get(i), -103);
   240       }
   241       test_2vi_inv(a1, a2, 123, 103, OFFSET);
   242       for (int i=OFFSET; i<ARRLEN; i++) {
   243         errn += verify("test_2vi_inv: a1", i, a1.get(i), 123);
   244         errn += verify("test_2vi_inv: a2", i, a2.get(i), 103);
   245       }
   246       for (int i=0; i<OFFSET; i++) {
   247         errn += verify("test_2vi_inv: a1", i, a1.get(i), -1);
   248         errn += verify("test_2vi_inv: a2", i, a2.get(i), -1);
   249       }
   250       // Reset for indexing with scale
   251       for (int i=0; i<ARRLEN; i++) {
   252         a1.lazySet(i, -1);
   253         a2.lazySet(i, -1);
   254       }
   255       test_ci_scl(a1, -1);
   256       for (int i=0; i<ARRLEN; i++) {
   257         int val = (i%SCALE != 0) ? -1 : -123;
   258         errn += verify("test_ci_scl: a1", i, a1.get(i), val);
   259       }
   260       test_vi_scl(a2, 123, -1);
   261       for (int i=0; i<ARRLEN; i++) {
   262         int val = (i%SCALE != 0) ? -1 : 123;
   263         errn += verify("test_vi_scl: a2", i, a2.get(i), val);
   264       }
   265       test_cp_scl(a1, a2);
   266       for (int i=0; i<ARRLEN; i++) {
   267         int val = (i%SCALE != 0) ? -1 : 123;
   268         errn += verify("test_cp_scl: a1", i, a1.get(i), val);
   269       }
   270       test_2ci_scl(a1, a2);
   271       for (int i=0; i<ARRLEN; i++) {
   272         if (i%SCALE != 0) {
   273           errn += verify("test_2ci_scl: a1", i, a1.get(i), -1);
   274         } else if (i*SCALE < ARRLEN) {
   275           errn += verify("test_2ci_scl: a1", i*SCALE, a1.get(i*SCALE), -123);
   276         }
   277         if (i%SCALE != 0) {
   278           errn += verify("test_2ci_scl: a2", i, a2.get(i), -1);
   279         } else if (i*SCALE < ARRLEN) {
   280           errn += verify("test_2ci_scl: a2", i*SCALE, a2.get(i*SCALE), -103);
   281         }
   282       }
   283       test_2vi_scl(a1, a2, 123, 103);
   284       for (int i=0; i<ARRLEN; i++) {
   285         if (i%SCALE != 0) {
   286           errn += verify("test_2vi_scl: a1", i, a1.get(i), -1);
   287         } else if (i*SCALE < ARRLEN) {
   288           errn += verify("test_2vi_scl: a1", i*SCALE, a1.get(i*SCALE), 123);
   289         }
   290         if (i%SCALE != 0) {
   291           errn += verify("test_2vi_scl: a2", i, a2.get(i), -1);
   292         } else if (i*SCALE < ARRLEN) {
   293           errn += verify("test_2vi_scl: a2", i*SCALE, a2.get(i*SCALE), 103);
   294         }
   295       }
   296       // Reset for 2 arrays with relative aligned offset
   297       for (int i=0; i<ARRLEN; i++) {
   298         a1.lazySet(i, -1);
   299         a2.lazySet(i, -1);
   300       }
   301       test_vi(a2, 123, -1);
   302       test_cp_alndst(a1, a2);
   303       for (int i=0; i<ALIGN_OFF; i++) {
   304         errn += verify("test_cp_alndst: a1", i, a1.get(i), -1);
   305       }
   306       for (int i=ALIGN_OFF; i<ARRLEN; i++) {
   307         errn += verify("test_cp_alndst: a1", i, a1.get(i), 123);
   308       }
   309       for (int i=0; i<ALIGN_OFF; i++) {
   310         a1.lazySet(i, 123);
   311       }
   312       test_vi(a2, -123, 123);
   313       test_cp_alnsrc(a1, a2);
   314       for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
   315         errn += verify("test_cp_alnsrc: a1", i, a1.get(i), -123);
   316       }
   317       for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
   318         errn += verify("test_cp_alnsrc: a1", i, a1.get(i), 123);
   319       }
   320       for (int i=0; i<ARRLEN; i++) {
   321         a1.lazySet(i, -1);
   322         a2.lazySet(i, -1);
   323       }
   324       test_2ci_aln(a1, a2);
   325       for (int i=0; i<ALIGN_OFF; i++) {
   326         errn += verify("test_2ci_aln: a1", i, a1.get(i), -1);
   327       }
   328       for (int i=ALIGN_OFF; i<ARRLEN; i++) {
   329         errn += verify("test_2ci_aln: a1", i, a1.get(i), -123);
   330       }
   331       for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
   332         errn += verify("test_2ci_aln: a2", i, a2.get(i), -103);
   333       }
   334       for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
   335         errn += verify("test_2ci_aln: a2", i, a2.get(i), -1);
   336       }
   337       for (int i=0; i<ARRLEN; i++) {
   338         a1.lazySet(i, -1);
   339         a2.lazySet(i, -1);
   340       }
   341       test_2vi_aln(a1, a2, 123, 103);
   342       for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
   343         errn += verify("test_2vi_aln: a1", i, a1.get(i), 123);
   344       }
   345       for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
   346         errn += verify("test_2vi_aln: a1", i, a1.get(i), -1);
   347       }
   348       for (int i=0; i<ALIGN_OFF; i++) {
   349         errn += verify("test_2vi_aln: a2", i, a2.get(i), -1);
   350       }
   351       for (int i=ALIGN_OFF; i<ARRLEN; i++) {
   352         errn += verify("test_2vi_aln: a2", i, a2.get(i), 103);
   353       }
   355       // Reset for 2 arrays with relative unaligned offset
   356       for (int i=0; i<ARRLEN; i++) {
   357         a1.lazySet(i, -1);
   358         a2.lazySet(i, -1);
   359       }
   360       test_vi(a2, 123, -1);
   361       test_cp_unalndst(a1, a2);
   362       for (int i=0; i<UNALIGN_OFF; i++) {
   363         errn += verify("test_cp_unalndst: a1", i, a1.get(i), -1);
   364       }
   365       for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
   366         errn += verify("test_cp_unalndst: a1", i, a1.get(i), 123);
   367       }
   368       test_vi(a2, -123, 123);
   369       test_cp_unalnsrc(a1, a2);
   370       for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
   371         errn += verify("test_cp_unalnsrc: a1", i, a1.get(i), -123);
   372       }
   373       for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
   374         errn += verify("test_cp_unalnsrc: a1", i, a1.get(i), 123);
   375       }
   376       for (int i=0; i<ARRLEN; i++) {
   377         a1.lazySet(i, -1);
   378         a2.lazySet(i, -1);
   379       }
   380       test_2ci_unaln(a1, a2);
   381       for (int i=0; i<UNALIGN_OFF; i++) {
   382         errn += verify("test_2ci_unaln: a1", i, a1.get(i), -1);
   383       }
   384       for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
   385         errn += verify("test_2ci_unaln: a1", i, a1.get(i), -123);
   386       }
   387       for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
   388         errn += verify("test_2ci_unaln: a2", i, a2.get(i), -103);
   389       }
   390       for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
   391         errn += verify("test_2ci_unaln: a2", i, a2.get(i), -1);
   392       }
   393       for (int i=0; i<ARRLEN; i++) {
   394         a1.lazySet(i, -1);
   395         a2.lazySet(i, -1);
   396       }
   397       test_2vi_unaln(a1, a2, 123, 103);
   398       for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
   399         errn += verify("test_2vi_unaln: a1", i, a1.get(i), 123);
   400       }
   401       for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
   402         errn += verify("test_2vi_unaln: a1", i, a1.get(i), -1);
   403       }
   404       for (int i=0; i<UNALIGN_OFF; i++) {
   405         errn += verify("test_2vi_unaln: a2", i, a2.get(i), -1);
   406       }
   407       for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
   408         errn += verify("test_2vi_unaln: a2", i, a2.get(i), 103);
   409       }
   411       // Reset for aligned overlap initialization
   412       for (int i=0; i<ALIGN_OFF; i++) {
   413         a1.lazySet(i, i);
   414       }
   415       for (int i=ALIGN_OFF; i<ARRLEN; i++) {
   416         a1.lazySet(i, -1);
   417       }
   418       test_cp_alndst(a1, a1);
   419       for (int i=0; i<ARRLEN; i++) {
   420         int v = i%ALIGN_OFF;
   421         errn += verify("test_cp_alndst_overlap: a1", i, a1.get(i), v);
   422       }
   423       for (int i=0; i<ALIGN_OFF; i++) {
   424         a1.lazySet((i+ALIGN_OFF), -1);
   425       }
   426       test_cp_alnsrc(a1, a1);
   427       for (int i=0; i<ALIGN_OFF; i++) {
   428         errn += verify("test_cp_alnsrc_overlap: a1", i, a1.get(i), -1);
   429       }
   430       for (int i=ALIGN_OFF; i<ARRLEN; i++) {
   431         int v = i%ALIGN_OFF;
   432         errn += verify("test_cp_alnsrc_overlap: a1", i, a1.get(i), v);
   433       }
   434       for (int i=0; i<ARRLEN; i++) {
   435         a1.lazySet(i, -1);
   436       }
   437       test_2ci_aln(a1, a1);
   438       for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
   439         errn += verify("test_2ci_aln_overlap: a1", i, a1.get(i), -103);
   440       }
   441       for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
   442         errn += verify("test_2ci_aln_overlap: a1", i, a1.get(i), -123);
   443       }
   444       for (int i=0; i<ARRLEN; i++) {
   445         a1.lazySet(i, -1);
   446       }
   447       test_2vi_aln(a1, a1, 123, 103);
   448       for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
   449         errn += verify("test_2vi_aln_overlap: a1", i, a1.get(i), 123);
   450       }
   451       for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
   452         errn += verify("test_2vi_aln_overlap: a1", i, a1.get(i), 103);
   453       }
   455       // Reset for unaligned overlap initialization
   456       for (int i=0; i<UNALIGN_OFF; i++) {
   457         a1.lazySet(i, i);
   458       }
   459       for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
   460         a1.lazySet(i, -1);
   461       }
   462       test_cp_unalndst(a1, a1);
   463       for (int i=0; i<ARRLEN; i++) {
   464         int v = i%UNALIGN_OFF;
   465         errn += verify("test_cp_unalndst_overlap: a1", i, a1.get(i), v);
   466       }
   467       for (int i=0; i<UNALIGN_OFF; i++) {
   468         a1.lazySet((i+UNALIGN_OFF), -1);
   469       }
   470       test_cp_unalnsrc(a1, a1);
   471       for (int i=0; i<UNALIGN_OFF; i++) {
   472         errn += verify("test_cp_unalnsrc_overlap: a1", i, a1.get(i), -1);
   473       }
   474       for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
   475         int v = i%UNALIGN_OFF;
   476         errn += verify("test_cp_unalnsrc_overlap: a1", i, a1.get(i), v);
   477       }
   478       for (int i=0; i<ARRLEN; i++) {
   479         a1.lazySet(i, -1);
   480       }
   481       test_2ci_unaln(a1, a1);
   482       for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
   483         errn += verify("test_2ci_unaln_overlap: a1", i, a1.get(i), -103);
   484       }
   485       for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
   486         errn += verify("test_2ci_unaln_overlap: a1", i, a1.get(i), -123);
   487       }
   488       for (int i=0; i<ARRLEN; i++) {
   489         a1.lazySet(i, -1);
   490       }
   491       test_2vi_unaln(a1, a1, 123, 103);
   492       for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
   493         errn += verify("test_2vi_unaln_overlap: a1", i, a1.get(i), 123);
   494       }
   495       for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
   496         errn += verify("test_2vi_unaln_overlap: a1", i, a1.get(i), 103);
   497       }
   499     }
   501     if (errn > 0 || test_only)
   502       return errn;
   504     // Initialize
   505     for (int i=0; i<ARRLEN; i++) {
   506       a1.lazySet(i, -1);
   507       a2.lazySet(i, -1);
   508     }
   509     System.out.println("Time");
   510     long start, end;
   511     start = System.currentTimeMillis();
   512     for (int i=0; i<ITERS; i++) {
   513       test_ci(a1);
   514     }
   515     end = System.currentTimeMillis();
   516     System.out.println("test_ci: " + (end - start));
   517     start = System.currentTimeMillis();
   518     for (int i=0; i<ITERS; i++) {
   519       test_vi(a2, 123, -1);
   520     }
   521     end = System.currentTimeMillis();
   522     System.out.println("test_vi: " + (end - start));
   523     start = System.currentTimeMillis();
   524     for (int i=0; i<ITERS; i++) {
   525       test_cp(a1, a2);
   526     }
   527     end = System.currentTimeMillis();
   528     System.out.println("test_cp: " + (end - start));
   529     start = System.currentTimeMillis();
   530     for (int i=0; i<ITERS; i++) {
   531       test_2ci(a1, a2);
   532     }
   533     end = System.currentTimeMillis();
   534     System.out.println("test_2ci: " + (end - start));
   535     start = System.currentTimeMillis();
   536     for (int i=0; i<ITERS; i++) {
   537       test_2vi(a1, a2, 123, 103);
   538     }
   539     end = System.currentTimeMillis();
   540     System.out.println("test_2vi: " + (end - start));
   542     start = System.currentTimeMillis();
   543     for (int i=0; i<ITERS; i++) {
   544       test_ci_neg(a1, 123);
   545     }
   546     end = System.currentTimeMillis();
   547     System.out.println("test_ci_neg: " + (end - start));
   548     start = System.currentTimeMillis();
   549     for (int i=0; i<ITERS; i++) {
   550       test_vi_neg(a2, 123, 103);
   551     }
   552     end = System.currentTimeMillis();
   553     System.out.println("test_vi_neg: " + (end - start));
   554     start = System.currentTimeMillis();
   555     for (int i=0; i<ITERS; i++) {
   556       test_cp_neg(a1, a2);
   557     }
   558     end = System.currentTimeMillis();
   559     System.out.println("test_cp_neg: " + (end - start));
   560     start = System.currentTimeMillis();
   561     for (int i=0; i<ITERS; i++) {
   562       test_2ci_neg(a1, a2);
   563     }
   564     end = System.currentTimeMillis();
   565     System.out.println("test_2ci_neg: " + (end - start));
   566     start = System.currentTimeMillis();
   567     for (int i=0; i<ITERS; i++) {
   568       test_2vi_neg(a1, a2, 123, 103);
   569     }
   570     end = System.currentTimeMillis();
   571     System.out.println("test_2vi_neg: " + (end - start));
   573     start = System.currentTimeMillis();
   574     for (int i=0; i<ITERS; i++) {
   575       test_ci_oppos(a1, 123);
   576     }
   577     end = System.currentTimeMillis();
   578     System.out.println("test_ci_oppos: " + (end - start));
   579     start = System.currentTimeMillis();
   580     for (int i=0; i<ITERS; i++) {
   581       test_vi_oppos(a2, 123, 103);
   582     }
   583     end = System.currentTimeMillis();
   584     System.out.println("test_vi_oppos: " + (end - start));
   585     start = System.currentTimeMillis();
   586     for (int i=0; i<ITERS; i++) {
   587       test_cp_oppos(a1, a2);
   588     }
   589     end = System.currentTimeMillis();
   590     System.out.println("test_cp_oppos: " + (end - start));
   591     start = System.currentTimeMillis();
   592     for (int i=0; i<ITERS; i++) {
   593       test_2ci_oppos(a1, a2);
   594     }
   595     end = System.currentTimeMillis();
   596     System.out.println("test_2ci_oppos: " + (end - start));
   597     start = System.currentTimeMillis();
   598     for (int i=0; i<ITERS; i++) {
   599       test_2vi_oppos(a1, a2, 123, 103);
   600     }
   601     end = System.currentTimeMillis();
   602     System.out.println("test_2vi_oppos: " + (end - start));
   604     start = System.currentTimeMillis();
   605     for (int i=0; i<ITERS; i++) {
   606       test_ci_off(a1, 123);
   607     }
   608     end = System.currentTimeMillis();
   609     System.out.println("test_ci_off: " + (end - start));
   610     start = System.currentTimeMillis();
   611     for (int i=0; i<ITERS; i++) {
   612       test_vi_off(a2, 123, 103);
   613     }
   614     end = System.currentTimeMillis();
   615     System.out.println("test_vi_off: " + (end - start));
   616     start = System.currentTimeMillis();
   617     for (int i=0; i<ITERS; i++) {
   618       test_cp_off(a1, a2);
   619     }
   620     end = System.currentTimeMillis();
   621     System.out.println("test_cp_off: " + (end - start));
   622     start = System.currentTimeMillis();
   623     for (int i=0; i<ITERS; i++) {
   624       test_2ci_off(a1, a2);
   625     }
   626     end = System.currentTimeMillis();
   627     System.out.println("test_2ci_off: " + (end - start));
   628     start = System.currentTimeMillis();
   629     for (int i=0; i<ITERS; i++) {
   630       test_2vi_off(a1, a2, 123, 103);
   631     }
   632     end = System.currentTimeMillis();
   633     System.out.println("test_2vi_off: " + (end - start));
   635     start = System.currentTimeMillis();
   636     for (int i=0; i<ITERS; i++) {
   637       test_ci_inv(a1, OFFSET, 123);
   638     }
   639     end = System.currentTimeMillis();
   640     System.out.println("test_ci_inv: " + (end - start));
   641     start = System.currentTimeMillis();
   642     for (int i=0; i<ITERS; i++) {
   643       test_vi_inv(a2, 123, OFFSET, 103);
   644     }
   645     end = System.currentTimeMillis();
   646     System.out.println("test_vi_inv: " + (end - start));
   647     start = System.currentTimeMillis();
   648     for (int i=0; i<ITERS; i++) {
   649       test_cp_inv(a1, a2, OFFSET);
   650     }
   651     end = System.currentTimeMillis();
   652     System.out.println("test_cp_inv: " + (end - start));
   653     start = System.currentTimeMillis();
   654     for (int i=0; i<ITERS; i++) {
   655       test_2ci_inv(a1, a2, OFFSET);
   656     }
   657     end = System.currentTimeMillis();
   658     System.out.println("test_2ci_inv: " + (end - start));
   659     start = System.currentTimeMillis();
   660     for (int i=0; i<ITERS; i++) {
   661       test_2vi_inv(a1, a2, 123, 103, OFFSET);
   662     }
   663     end = System.currentTimeMillis();
   664     System.out.println("test_2vi_inv: " + (end - start));
   666     start = System.currentTimeMillis();
   667     for (int i=0; i<ITERS; i++) {
   668       test_ci_scl(a1, 123);
   669     }
   670     end = System.currentTimeMillis();
   671     System.out.println("test_ci_scl: " + (end - start));
   672     start = System.currentTimeMillis();
   673     for (int i=0; i<ITERS; i++) {
   674       test_vi_scl(a2, 123, 103);
   675     }
   676     end = System.currentTimeMillis();
   677     System.out.println("test_vi_scl: " + (end - start));
   678     start = System.currentTimeMillis();
   679     for (int i=0; i<ITERS; i++) {
   680       test_cp_scl(a1, a2);
   681     }
   682     end = System.currentTimeMillis();
   683     System.out.println("test_cp_scl: " + (end - start));
   684     start = System.currentTimeMillis();
   685     for (int i=0; i<ITERS; i++) {
   686       test_2ci_scl(a1, a2);
   687     }
   688     end = System.currentTimeMillis();
   689     System.out.println("test_2ci_scl: " + (end - start));
   690     start = System.currentTimeMillis();
   691     for (int i=0; i<ITERS; i++) {
   692       test_2vi_scl(a1, a2, 123, 103);
   693     }
   694     end = System.currentTimeMillis();
   695     System.out.println("test_2vi_scl: " + (end - start));
   697     start = System.currentTimeMillis();
   698     for (int i=0; i<ITERS; i++) {
   699       test_cp_alndst(a1, a2);
   700     }
   701     end = System.currentTimeMillis();
   702     System.out.println("test_cp_alndst: " + (end - start));
   703     start = System.currentTimeMillis();
   704     for (int i=0; i<ITERS; i++) {
   705       test_cp_alnsrc(a1, a2);
   706     }
   707     end = System.currentTimeMillis();
   708     System.out.println("test_cp_alnsrc: " + (end - start));
   709     start = System.currentTimeMillis();
   710     for (int i=0; i<ITERS; i++) {
   711       test_2ci_aln(a1, a2);
   712     }
   713     end = System.currentTimeMillis();
   714     System.out.println("test_2ci_aln: " + (end - start));
   715     start = System.currentTimeMillis();
   716     for (int i=0; i<ITERS; i++) {
   717       test_2vi_aln(a1, a2, 123, 103);
   718     }
   719     end = System.currentTimeMillis();
   720     System.out.println("test_2vi_aln: " + (end - start));
   722     start = System.currentTimeMillis();
   723     for (int i=0; i<ITERS; i++) {
   724       test_cp_unalndst(a1, a2);
   725     }
   726     end = System.currentTimeMillis();
   727     System.out.println("test_cp_unalndst: " + (end - start));
   728     start = System.currentTimeMillis();
   729     for (int i=0; i<ITERS; i++) {
   730       test_cp_unalnsrc(a1, a2);
   731     }
   732     end = System.currentTimeMillis();
   733     System.out.println("test_cp_unalnsrc: " + (end - start));
   734     start = System.currentTimeMillis();
   735     for (int i=0; i<ITERS; i++) {
   736       test_2ci_unaln(a1, a2);
   737     }
   738     end = System.currentTimeMillis();
   739     System.out.println("test_2ci_unaln: " + (end - start));
   740     start = System.currentTimeMillis();
   741     for (int i=0; i<ITERS; i++) {
   742       test_2vi_unaln(a1, a2, 123, 103);
   743     }
   744     end = System.currentTimeMillis();
   745     System.out.println("test_2vi_unaln: " + (end - start));
   747     return errn;
   748   }
   750   static void test_ci(AtomicIntegerArray a) {
   751     for (int i = 0; i < ARRLEN; i+=1) {
   752       a.lazySet(i, -123);
   753     }
   754   }
   755   static void test_vi(AtomicIntegerArray a, int b, int old) {
   756     for (int i = 0; i < ARRLEN; i+=1) {
   757       a.lazySet(i, b);
   758     }
   759   }
   760   static void test_cp(AtomicIntegerArray a, AtomicIntegerArray b) {
   761     for (int i = 0; i < ARRLEN; i+=1) {
   762       a.lazySet(i, b.get(i));
   763     }
   764   }
   765   static void test_2ci(AtomicIntegerArray a, AtomicIntegerArray b) {
   766     for (int i = 0; i < ARRLEN; i+=1) {
   767       a.lazySet(i, -123);
   768       b.lazySet(i, -103);
   769     }
   770   }
   771   static void test_2vi(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
   772     for (int i = 0; i < ARRLEN; i+=1) {
   773       a.lazySet(i, c);
   774       b.lazySet(i, d);
   775     }
   776   }
   777   static void test_ci_neg(AtomicIntegerArray a, int old) {
   778     for (int i = ARRLEN-1; i >= 0; i-=1) {
   779       a.lazySet(i,-123);
   780     }
   781   }
   782   static void test_vi_neg(AtomicIntegerArray a, int b, int old) {
   783     for (int i = ARRLEN-1; i >= 0; i-=1) {
   784       a.lazySet(i, b);
   785     }
   786   }
   787   static void test_cp_neg(AtomicIntegerArray a, AtomicIntegerArray b) {
   788     for (int i = ARRLEN-1; i >= 0; i-=1) {
   789       a.lazySet(i, b.get(i));
   790     }
   791   }
   792   static void test_2ci_neg(AtomicIntegerArray a, AtomicIntegerArray b) {
   793     for (int i = ARRLEN-1; i >= 0; i-=1) {
   794       a.lazySet(i, -123);
   795       b.lazySet(i, -103);
   796     }
   797   }
   798   static void test_2vi_neg(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
   799     for (int i = ARRLEN-1; i >= 0; i-=1) {
   800       a.lazySet(i, c);
   801       b.lazySet(i, d);
   802     }
   803   }
   804   static void test_ci_oppos(AtomicIntegerArray a, int old) {
   805     int limit = ARRLEN-1;
   806     for (int i = 0; i < ARRLEN; i+=1) {
   807       a.lazySet((limit-i), -123);
   808     }
   809   }
   810   static void test_vi_oppos(AtomicIntegerArray a, int b, int old) {
   811     int limit = ARRLEN-1;
   812     for (int i = limit; i >= 0; i-=1) {
   813       a.lazySet((limit-i), b);
   814     }
   815   }
   816   static void test_cp_oppos(AtomicIntegerArray a, AtomicIntegerArray b) {
   817     int limit = ARRLEN-1;
   818     for (int i = 0; i < ARRLEN; i+=1) {
   819       a.lazySet(i, b.get(limit-i));
   820     }
   821   }
   822   static void test_2ci_oppos(AtomicIntegerArray a, AtomicIntegerArray b) {
   823     int limit = ARRLEN-1;
   824     for (int i = 0; i < ARRLEN; i+=1) {
   825       a.lazySet((limit-i), -123);
   826       b.lazySet(i, -103);
   827     }
   828   }
   829   static void test_2vi_oppos(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
   830     int limit = ARRLEN-1;
   831     for (int i = limit; i >= 0; i-=1) {
   832       a.lazySet(i, c);
   833       b.lazySet((limit-i), d);
   834     }
   835   }
   836   static void test_ci_off(AtomicIntegerArray a, int old) {
   837     for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
   838       a.lazySet((i+OFFSET), -123);
   839     }
   840   }
   841   static void test_vi_off(AtomicIntegerArray a, int b, int old) {
   842     for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
   843       a.lazySet((i+OFFSET), b);
   844     }
   845   }
   846   static void test_cp_off(AtomicIntegerArray a, AtomicIntegerArray b) {
   847     for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
   848       a.lazySet((i+OFFSET), b.get(i+OFFSET));
   849     }
   850   }
   851   static void test_2ci_off(AtomicIntegerArray a, AtomicIntegerArray b) {
   852     for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
   853       a.lazySet((i+OFFSET), -123);
   854       b.lazySet((i+OFFSET), -103);
   855     }
   856   }
   857   static void test_2vi_off(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
   858     for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
   859       a.lazySet((i+OFFSET), c);
   860       b.lazySet((i+OFFSET), d);
   861     }
   862   }
   863   static void test_ci_inv(AtomicIntegerArray a, int k, int old) {
   864     for (int i = 0; i < ARRLEN-k; i+=1) {
   865       a.lazySet((i+k),-123);
   866     }
   867   }
   868   static void test_vi_inv(AtomicIntegerArray a, int b, int k, int old) {
   869     for (int i = 0; i < ARRLEN-k; i+=1) {
   870       a.lazySet((i+k), b);
   871     }
   872   }
   873   static void test_cp_inv(AtomicIntegerArray a, AtomicIntegerArray b, int k) {
   874     for (int i = 0; i < ARRLEN-k; i+=1) {
   875       a.lazySet((i+k), b.get(i+k));
   876     }
   877   }
   878   static void test_2ci_inv(AtomicIntegerArray a, AtomicIntegerArray b, int k) {
   879     for (int i = 0; i < ARRLEN-k; i+=1) {
   880       a.lazySet((i+k), -123);
   881       b.lazySet((i+k), -103);
   882     }
   883   }
   884   static void test_2vi_inv(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d, int k) {
   885     for (int i = 0; i < ARRLEN-k; i+=1) {
   886       a.lazySet((i+k), c);
   887       b.lazySet((i+k), d);
   888     }
   889   }
   890   static void test_ci_scl(AtomicIntegerArray a, int old) {
   891     for (int i = 0; i*SCALE < ARRLEN; i+=1) {
   892       a.lazySet((i*SCALE), -123);
   893     }
   894   }
   895   static void test_vi_scl(AtomicIntegerArray a, int b, int old) {
   896     for (int i = 0; i*SCALE < ARRLEN; i+=1) {
   897       a.lazySet((i*SCALE), b);
   898     }
   899   }
   900   static void test_cp_scl(AtomicIntegerArray a, AtomicIntegerArray b) {
   901     for (int i = 0; i*SCALE < ARRLEN; i+=1) {
   902       a.lazySet((i*SCALE), b.get(i*SCALE));
   903     }
   904   }
   905   static void test_2ci_scl(AtomicIntegerArray a, AtomicIntegerArray b) {
   906     for (int i = 0; i*SCALE < ARRLEN; i+=1) {
   907       a.lazySet((i*SCALE), -123);
   908       b.lazySet((i*SCALE), -103);
   909     }
   910   }
   911   static void test_2vi_scl(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
   912     for (int i = 0; i*SCALE < ARRLEN; i+=1) {
   913       a.lazySet((i*SCALE), c);
   914       b.lazySet((i*SCALE), d);
   915     }
   916   }
   917   static void test_cp_alndst(AtomicIntegerArray a, AtomicIntegerArray b) {
   918     for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
   919       a.lazySet((i+ALIGN_OFF), b.get(i));
   920     }
   921   }
   922   static void test_cp_alnsrc(AtomicIntegerArray a, AtomicIntegerArray b) {
   923     for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
   924       a.lazySet(i, b.get(i+ALIGN_OFF));
   925     }
   926   }
   927   static void test_2ci_aln(AtomicIntegerArray a, AtomicIntegerArray b) {
   928     for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
   929       a.lazySet((i+ALIGN_OFF), -123);
   930       b.lazySet(i, -103);
   931     }
   932   }
   933   static void test_2vi_aln(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
   934     for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
   935       a.lazySet(i, c);
   936       b.lazySet((i+ALIGN_OFF), d);
   937     }
   938   }
   939   static void test_cp_unalndst(AtomicIntegerArray a, AtomicIntegerArray b) {
   940     for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
   941       a.lazySet((i+UNALIGN_OFF), b.get(i));
   942     }
   943   }
   944   static void test_cp_unalnsrc(AtomicIntegerArray a, AtomicIntegerArray b) {
   945     for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
   946       a.lazySet(i, b.get(i+UNALIGN_OFF));
   947     }
   948   }
   949   static void test_2ci_unaln(AtomicIntegerArray a, AtomicIntegerArray b) {
   950     for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
   951       a.lazySet((i+UNALIGN_OFF), -123);
   952       b.lazySet(i, -103);
   953     }
   954   }
   955   static void test_2vi_unaln(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
   956     for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
   957       a.lazySet(i, c);
   958       b.lazySet((i+UNALIGN_OFF), d);
   959     }
   960   }
   962   static int verify(String text, int i, int elem, int val) {
   963     if (elem != val) {
   964       System.err.println(text + "[" + i + "] = " + elem + " != " + val);
   965       return 1;
   966     }
   967     return 0;
   968   }
   969 }

mercurial