Merge

Thu, 21 Feb 2013 06:29:43 -0800

author
vlivanov
date
Thu, 21 Feb 2013 06:29:43 -0800
changeset 4621
2e4b16122164
parent 4616
5741d3fc502d
parent 4620
ad736b4683b4
child 4632
ed96c6015470

Merge

     1.1 --- a/src/share/vm/opto/library_call.cpp	Thu Feb 21 13:13:22 2013 +0100
     1.2 +++ b/src/share/vm/opto/library_call.cpp	Thu Feb 21 06:29:43 2013 -0800
     1.3 @@ -1481,10 +1481,10 @@
     1.4    Node* arg = round_double_node(argument(0));
     1.5    Node* n;
     1.6    switch (id) {
     1.7 -  case vmIntrinsics::_dabs:   n = new (C) AbsDNode(    arg);  break;
     1.8 -  case vmIntrinsics::_dsqrt:  n = new (C) SqrtDNode(0, arg);  break;
     1.9 -  case vmIntrinsics::_dlog:   n = new (C) LogDNode(    arg);  break;
    1.10 -  case vmIntrinsics::_dlog10: n = new (C) Log10DNode(  arg);  break;
    1.11 +  case vmIntrinsics::_dabs:   n = new (C) AbsDNode(                arg);  break;
    1.12 +  case vmIntrinsics::_dsqrt:  n = new (C) SqrtDNode(C, control(),  arg);  break;
    1.13 +  case vmIntrinsics::_dlog:   n = new (C) LogDNode(C, control(),   arg);  break;
    1.14 +  case vmIntrinsics::_dlog10: n = new (C) Log10DNode(C, control(), arg);  break;
    1.15    default:  fatal_unexpected_iid(id);  break;
    1.16    }
    1.17    set_result(_gvn.transform(n));
    1.18 @@ -1499,9 +1499,9 @@
    1.19    Node* n = NULL;
    1.20  
    1.21    switch (id) {
    1.22 -  case vmIntrinsics::_dsin:  n = new (C) SinDNode(arg);  break;
    1.23 -  case vmIntrinsics::_dcos:  n = new (C) CosDNode(arg);  break;
    1.24 -  case vmIntrinsics::_dtan:  n = new (C) TanDNode(arg);  break;
    1.25 +  case vmIntrinsics::_dsin:  n = new (C) SinDNode(C, control(), arg);  break;
    1.26 +  case vmIntrinsics::_dcos:  n = new (C) CosDNode(C, control(), arg);  break;
    1.27 +  case vmIntrinsics::_dtan:  n = new (C) TanDNode(C, control(), arg);  break;
    1.28    default:  fatal_unexpected_iid(id);  break;
    1.29    }
    1.30    n = _gvn.transform(n);
     2.1 --- a/src/share/vm/opto/subnode.hpp	Thu Feb 21 13:13:22 2013 +0100
     2.2 +++ b/src/share/vm/opto/subnode.hpp	Thu Feb 21 06:29:43 2013 -0800
     2.3 @@ -399,7 +399,10 @@
     2.4  // Cosinus of a double
     2.5  class CosDNode : public Node {
     2.6  public:
     2.7 -  CosDNode( Node *in1  ) : Node(0, in1) {}
     2.8 +  CosDNode(Compile* C, Node *c, Node *in1) : Node(c, in1) {
     2.9 +    init_flags(Flag_is_expensive);
    2.10 +    C->add_expensive_node(this);
    2.11 +  }
    2.12    virtual int Opcode() const;
    2.13    const Type *bottom_type() const { return Type::DOUBLE; }
    2.14    virtual uint ideal_reg() const { return Op_RegD; }
    2.15 @@ -410,7 +413,10 @@
    2.16  // Sinus of a double
    2.17  class SinDNode : public Node {
    2.18  public:
    2.19 -  SinDNode( Node *in1  ) : Node(0, in1) {}
    2.20 +  SinDNode(Compile* C, Node *c, Node *in1) : Node(c, in1) {
    2.21 +    init_flags(Flag_is_expensive);
    2.22 +    C->add_expensive_node(this);
    2.23 +  }
    2.24    virtual int Opcode() const;
    2.25    const Type *bottom_type() const { return Type::DOUBLE; }
    2.26    virtual uint ideal_reg() const { return Op_RegD; }
    2.27 @@ -422,7 +428,10 @@
    2.28  // tangens of a double
    2.29  class TanDNode : public Node {
    2.30  public:
    2.31 -  TanDNode(Node *in1  ) : Node(0, in1) {}
    2.32 +  TanDNode(Compile* C, Node *c,Node *in1) : Node(c, in1) {
    2.33 +    init_flags(Flag_is_expensive);
    2.34 +    C->add_expensive_node(this);
    2.35 +  }
    2.36    virtual int Opcode() const;
    2.37    const Type *bottom_type() const { return Type::DOUBLE; }
    2.38    virtual uint ideal_reg() const { return Op_RegD; }
    2.39 @@ -445,7 +454,10 @@
    2.40  // square root a double
    2.41  class SqrtDNode : public Node {
    2.42  public:
    2.43 -  SqrtDNode(Node *c, Node *in1  ) : Node(c, in1) {}
    2.44 +  SqrtDNode(Compile* C, Node *c, Node *in1) : Node(c, in1) {
    2.45 +    init_flags(Flag_is_expensive);
    2.46 +    C->add_expensive_node(this);
    2.47 +  }
    2.48    virtual int Opcode() const;
    2.49    const Type *bottom_type() const { return Type::DOUBLE; }
    2.50    virtual uint ideal_reg() const { return Op_RegD; }
    2.51 @@ -470,7 +482,10 @@
    2.52  // Log_e of a double
    2.53  class LogDNode : public Node {
    2.54  public:
    2.55 -  LogDNode( Node *in1 ) : Node(0, in1) {}
    2.56 +  LogDNode(Compile* C, Node *c, Node *in1) : Node(c, in1) {
    2.57 +    init_flags(Flag_is_expensive);
    2.58 +    C->add_expensive_node(this);
    2.59 +  }
    2.60    virtual int Opcode() const;
    2.61    const Type *bottom_type() const { return Type::DOUBLE; }
    2.62    virtual uint ideal_reg() const { return Op_RegD; }
    2.63 @@ -481,7 +496,10 @@
    2.64  // Log_10 of a double
    2.65  class Log10DNode : public Node {
    2.66  public:
    2.67 -  Log10DNode( Node *in1 ) : Node(0, in1) {}
    2.68 +  Log10DNode(Compile* C, Node *c, Node *in1) : Node(c, in1) {
    2.69 +    init_flags(Flag_is_expensive);
    2.70 +    C->add_expensive_node(this);
    2.71 +  }
    2.72    virtual int Opcode() const;
    2.73    const Type *bottom_type() const { return Type::DOUBLE; }
    2.74    virtual uint ideal_reg() const { return Op_RegD; }
     3.1 --- a/src/share/vm/opto/superword.cpp	Thu Feb 21 13:13:22 2013 +0100
     3.2 +++ b/src/share/vm/opto/superword.cpp	Thu Feb 21 06:29:43 2013 -0800
     3.3 @@ -143,7 +143,8 @@
     3.4  
     3.5    // Ready the block
     3.6  
     3.7 -  construct_bb();
     3.8 +  if (!construct_bb())
     3.9 +    return; // Exit if no interesting nodes or complex graph.
    3.10  
    3.11    dependence_graph();
    3.12  
    3.13 @@ -615,6 +616,7 @@
    3.14      if (n == stop) break;
    3.15      preds.push(n);
    3.16      prev = n;
    3.17 +    assert(n->is_Mem(), err_msg_res("unexpected node %s", n->Name()));
    3.18      n = n->in(MemNode::Memory);
    3.19    }
    3.20  }
    3.21 @@ -1578,7 +1580,7 @@
    3.22  
    3.23  //------------------------------construct_bb---------------------------
    3.24  // Construct reverse postorder list of block members
    3.25 -void SuperWord::construct_bb() {
    3.26 +bool SuperWord::construct_bb() {
    3.27    Node* entry = bb();
    3.28  
    3.29    assert(_stk.length() == 0,            "stk is empty");
    3.30 @@ -1596,6 +1598,12 @@
    3.31      Node *n = lpt()->_body.at(i);
    3.32      set_bb_idx(n, i); // Create a temporary map
    3.33      if (in_bb(n)) {
    3.34 +      if (n->is_LoadStore() || n->is_MergeMem() ||
    3.35 +          (n->is_Proj() && !n->as_Proj()->is_CFG())) {
    3.36 +        // Bailout if the loop has LoadStore, MergeMem or data Proj
    3.37 +        // nodes. Superword optimization does not work with them.
    3.38 +        return false;
    3.39 +      }
    3.40        bb_ct++;
    3.41        if (!n->is_CFG()) {
    3.42          bool found = false;
    3.43 @@ -1620,6 +1628,10 @@
    3.44      if (in_bb(n) && (n->is_Phi() && n->bottom_type() == Type::MEMORY)) {
    3.45        Node* n_tail  = n->in(LoopNode::LoopBackControl);
    3.46        if (n_tail != n->in(LoopNode::EntryControl)) {
    3.47 +        if (!n_tail->is_Mem()) {
    3.48 +          assert(n_tail->is_Mem(), err_msg_res("unexpected node for memory slice: %s", n_tail->Name()));
    3.49 +          return false; // Bailout
    3.50 +        }
    3.51          _mem_slice_head.push(n);
    3.52          _mem_slice_tail.push(n_tail);
    3.53        }
    3.54 @@ -1695,6 +1707,7 @@
    3.55    }
    3.56  #endif
    3.57    assert(rpo_idx == -1 && bb_ct == _block.length(), "all block members found");
    3.58 +  return (_mem_slice_head.length() > 0) || (_data_entry.length() > 0);
    3.59  }
    3.60  
    3.61  //------------------------------initialize_bb---------------------------
     4.1 --- a/src/share/vm/opto/superword.hpp	Thu Feb 21 13:13:22 2013 +0100
     4.2 +++ b/src/share/vm/opto/superword.hpp	Thu Feb 21 06:29:43 2013 -0800
     4.3 @@ -380,7 +380,7 @@
     4.4    // Is use->in(u_idx) a vector use?
     4.5    bool is_vector_use(Node* use, int u_idx);
     4.6    // Construct reverse postorder list of block members
     4.7 -  void construct_bb();
     4.8 +  bool construct_bb();
     4.9    // Initialize per node info
    4.10    void initialize_bb();
    4.11    // Insert n into block after pos
     5.1 --- a/test/compiler/5091921/Test6850611.java	Thu Feb 21 13:13:22 2013 +0100
     5.2 +++ b/test/compiler/5091921/Test6850611.java	Thu Feb 21 06:29:43 2013 -0800
     5.3 @@ -1,5 +1,5 @@
     5.4  /*
     5.5 - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
     5.6 + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
     5.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5.8   *
     5.9   * This code is free software; you can redistribute it and/or modify it
    5.10 @@ -27,7 +27,7 @@
    5.11   * @bug 6850611
    5.12   * @summary int / long arithmetic seems to be broken in 1.6.0_14 HotSpot Server VM (Win XP)
    5.13   *
    5.14 - * @run main Test6850611
    5.15 + * @run main/timeout=480 Test6850611
    5.16   */
    5.17  
    5.18  public class Test6850611 {
     6.1 --- a/test/compiler/5091921/Test6890943.java	Thu Feb 21 13:13:22 2013 +0100
     6.2 +++ b/test/compiler/5091921/Test6890943.java	Thu Feb 21 06:29:43 2013 -0800
     6.3 @@ -1,5 +1,5 @@
     6.4  /*
     6.5 - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
     6.6 + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
     6.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     6.8   *
     6.9   * This code is free software; you can redistribute it and/or modify it
    6.10 @@ -27,7 +27,7 @@
    6.11   * @bug 6890943
    6.12   * @summary JVM mysteriously gives wrong result on 64-bit 1.6 VMs in hotspot mode.
    6.13   *
    6.14 - * @run shell Test6890943.sh
    6.15 + * @run shell/timeout=240 Test6890943.sh
    6.16   */
    6.17  import java.util.*;
    6.18  import java.io.*;
     7.1 --- a/test/compiler/5091921/Test6890943.sh	Thu Feb 21 13:13:22 2013 +0100
     7.2 +++ b/test/compiler/5091921/Test6890943.sh	Thu Feb 21 06:29:43 2013 -0800
     7.3 @@ -1,6 +1,6 @@
     7.4  #!/bin/sh
     7.5  # 
     7.6 -# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
     7.7 +# Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
     7.8  # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     7.9  # 
    7.10  # This code is free software; you can redistribute it and/or modify it
    7.11 @@ -52,7 +52,10 @@
    7.12  
    7.13  ${TESTJAVA}/bin/javac -d . Test6890943.java
    7.14  
    7.15 -${TESTJAVA}/bin/java -XX:-PrintVMOptions ${TESTVMOPTS} Test6890943 < input6890943.txt > test.out 2>&1
    7.16 +${TESTJAVA}/bin/java -XX:-PrintVMOptions -XX:+IgnoreUnrecognizedVMOptions ${TESTVMOPTS} Test6890943 < input6890943.txt > pretest.out 2>&1
    7.17 +
    7.18 +# This test sometimes tickles an unrelated performance warning that interferes with diff.
    7.19 +grep -v 'warning: Performance bug: SystemDictionary' pretest.out > test.out
    7.20  
    7.21  diff output6890943.txt test.out
    7.22  
     8.1 --- a/test/compiler/5091921/Test6905845.java	Thu Feb 21 13:13:22 2013 +0100
     8.2 +++ b/test/compiler/5091921/Test6905845.java	Thu Feb 21 06:29:43 2013 -0800
     8.3 @@ -1,5 +1,5 @@
     8.4  /*
     8.5 - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
     8.6 + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
     8.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     8.8   *
     8.9   * This code is free software; you can redistribute it and/or modify it
    8.10 @@ -27,7 +27,7 @@
    8.11   * @bug 6905845
    8.12   * @summary Server VM improperly optimizing away loop.
    8.13   *
    8.14 - * @run main Test6905845
    8.15 + * @run main/timeout=480 Test6905845
    8.16   */
    8.17  
    8.18  public class Test6905845 {
     9.1 --- a/test/compiler/5091921/Test6992759.java	Thu Feb 21 13:13:22 2013 +0100
     9.2 +++ b/test/compiler/5091921/Test6992759.java	Thu Feb 21 06:29:43 2013 -0800
     9.3 @@ -1,5 +1,5 @@
     9.4  /*
     9.5 - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
     9.6 + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
     9.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     9.8   *
     9.9   * This code is free software; you can redistribute it and/or modify it
    9.10 @@ -27,7 +27,7 @@
    9.11   * @bug 6992759
    9.12   * @summary Bad code generated for integer <= comparison, fails for Integer.MAX_VALUE
    9.13   *
    9.14 - * @run main Test6992759
    9.15 + * @run main/timeout=240 Test6992759
    9.16   */
    9.17  
    9.18  public class Test6992759 {
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/test/compiler/8004867/TestIntAtomicCAS.java	Thu Feb 21 06:29:43 2013 -0800
    10.3 @@ -0,0 +1,969 @@
    10.4 +/*
    10.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    10.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    10.7 + *
    10.8 + * This code is free software; you can redistribute it and/or modify it
    10.9 + * under the terms of the GNU General Public License version 2 only, as
   10.10 + * published by the Free Software Foundation.
   10.11 + *
   10.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   10.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   10.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   10.15 + * version 2 for more details (a copy is included in the LICENSE file that
   10.16 + * accompanied this code).
   10.17 + *
   10.18 + * You should have received a copy of the GNU General Public License version
   10.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   10.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   10.21 + *
   10.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   10.23 + * or visit www.oracle.com if you need additional information or have any
   10.24 + * questions.
   10.25 + *
   10.26 + */
   10.27 +
   10.28 +/**
   10.29 + * @test
   10.30 + * @bug 8004867
   10.31 + * @summary VM crashing with assert "share/vm/opto/node.hpp:357 - assert(i < _max) failed: oob"
   10.32 + *
   10.33 + * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:-OptimizeFill TestIntAtomicCAS
   10.34 + * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:+OptimizeFill TestIntAtomicCAS
   10.35 + */
   10.36 +
   10.37 +import java.util.concurrent.atomic.AtomicIntegerArray;
   10.38 +
   10.39 +public class TestIntAtomicCAS {
   10.40 +  private static final int ARRLEN = 97;
   10.41 +  private static final int ITERS  = 11000;
   10.42 +  private static final int OFFSET = 3;
   10.43 +  private static final int SCALE = 2;
   10.44 +  private static final int ALIGN_OFF = 8;
   10.45 +  private static final int UNALIGN_OFF = 5;
   10.46 +
   10.47 +  public static void main(String args[]) {
   10.48 +    System.out.println("Testing Integer array atomic CAS operations");
   10.49 +    int errn = test(false);
   10.50 +    if (errn > 0) {
   10.51 +      System.err.println("FAILED: " + errn + " errors");
   10.52 +      System.exit(97);
   10.53 +    }
   10.54 +    System.out.println("PASSED");
   10.55 +  }
   10.56 +
   10.57 +  static int test(boolean test_only) {
   10.58 +    AtomicIntegerArray a1 = new AtomicIntegerArray(ARRLEN);
   10.59 +    AtomicIntegerArray a2 = new AtomicIntegerArray(ARRLEN);
   10.60 +    // Initialize
   10.61 +    for (int i=0; i<ARRLEN; i++) {
   10.62 +      a1.set(i, -1);
   10.63 +      a2.set(i, -1);
   10.64 +    }
   10.65 +    System.out.println("Warmup");
   10.66 +    for (int i=0; i<ITERS; i++) {
   10.67 +      test_ci(a1);
   10.68 +      test_vi(a2, 123, -1);
   10.69 +      test_cp(a1, a2);
   10.70 +      test_2ci(a1, a2);
   10.71 +      test_2vi(a1, a2, 123, 103);
   10.72 +      test_ci_neg(a1, 123);
   10.73 +      test_vi_neg(a2, 123, 103);
   10.74 +      test_cp_neg(a1, a2);
   10.75 +      test_2ci_neg(a1, a2);
   10.76 +      test_2vi_neg(a1, a2, 123, 103);
   10.77 +      test_ci_oppos(a1, 123);
   10.78 +      test_vi_oppos(a2, 123, 103);
   10.79 +      test_cp_oppos(a1, a2);
   10.80 +      test_2ci_oppos(a1, a2);
   10.81 +      test_2vi_oppos(a1, a2, 123, 103);
   10.82 +      test_ci_off(a1, 123);
   10.83 +      test_vi_off(a2, 123, 103);
   10.84 +      test_cp_off(a1, a2);
   10.85 +      test_2ci_off(a1, a2);
   10.86 +      test_2vi_off(a1, a2, 123, 103);
   10.87 +      test_ci_inv(a1, OFFSET, 123);
   10.88 +      test_vi_inv(a2, 123, OFFSET, 103);
   10.89 +      test_cp_inv(a1, a2, OFFSET);
   10.90 +      test_2ci_inv(a1, a2, OFFSET);
   10.91 +      test_2vi_inv(a1, a2, 123, 103, OFFSET);
   10.92 +      test_ci_scl(a1, 123);
   10.93 +      test_vi_scl(a2, 123, 103);
   10.94 +      test_cp_scl(a1, a2);
   10.95 +      test_2ci_scl(a1, a2);
   10.96 +      test_2vi_scl(a1, a2, 123, 103);
   10.97 +      test_cp_alndst(a1, a2);
   10.98 +      test_cp_alnsrc(a1, a2);
   10.99 +      test_2ci_aln(a1, a2);
  10.100 +      test_2vi_aln(a1, a2, 123, 103);
  10.101 +      test_cp_unalndst(a1, a2);
  10.102 +      test_cp_unalnsrc(a1, a2);
  10.103 +      test_2ci_unaln(a1, a2);
  10.104 +      test_2vi_unaln(a1, a2, 123, 103);
  10.105 +    }
  10.106 +    // Initialize
  10.107 +    for (int i=0; i<ARRLEN; i++) {
  10.108 +      a1.set(i, -1);
  10.109 +      a2.set(i, -1);
  10.110 +    }
  10.111 +    // Test and verify results
  10.112 +    System.out.println("Verification");
  10.113 +    int errn = 0;
  10.114 +    {
  10.115 +      test_ci(a1);
  10.116 +      for (int i=0; i<ARRLEN; i++) {
  10.117 +        errn += verify("test_ci: a1", i, a1.get(i), -123);
  10.118 +      }
  10.119 +      test_vi(a2, 123, -1);
  10.120 +      for (int i=0; i<ARRLEN; i++) {
  10.121 +        errn += verify("test_vi: a2", i, a2.get(i), 123);
  10.122 +      }
  10.123 +      test_cp(a1, a2);
  10.124 +      for (int i=0; i<ARRLEN; i++) {
  10.125 +        errn += verify("test_cp: a1", i, a1.get(i), 123);
  10.126 +      }
  10.127 +      test_2ci(a1, a2);
  10.128 +      for (int i=0; i<ARRLEN; i++) {
  10.129 +        errn += verify("test_2ci: a1", i, a1.get(i), -123);
  10.130 +        errn += verify("test_2ci: a2", i, a2.get(i), -103);
  10.131 +      }
  10.132 +      test_2vi(a1, a2, 123, 103);
  10.133 +      for (int i=0; i<ARRLEN; i++) {
  10.134 +        errn += verify("test_2vi: a1", i, a1.get(i), 123);
  10.135 +        errn += verify("test_2vi: a2", i, a2.get(i), 103);
  10.136 +      }
  10.137 +      // Reset for negative stride
  10.138 +      for (int i=0; i<ARRLEN; i++) {
  10.139 +        a1.set(i, -1);
  10.140 +        a2.set(i, -1);
  10.141 +      }
  10.142 +      test_ci_neg(a1, -1);
  10.143 +      for (int i=0; i<ARRLEN; i++) {
  10.144 +        errn += verify("test_ci_neg: a1", i, a1.get(i), -123);
  10.145 +      }
  10.146 +      test_vi_neg(a2, 123, -1);
  10.147 +      for (int i=0; i<ARRLEN; i++) {
  10.148 +        errn += verify("test_vi_neg: a2", i, a2.get(i), 123);
  10.149 +      }
  10.150 +      test_cp_neg(a1, a2);
  10.151 +      for (int i=0; i<ARRLEN; i++) {
  10.152 +        errn += verify("test_cp_neg: a1", i, a1.get(i), 123);
  10.153 +      }
  10.154 +      test_2ci_neg(a1, a2);
  10.155 +      for (int i=0; i<ARRLEN; i++) {
  10.156 +        errn += verify("test_2ci_neg: a1", i, a1.get(i), -123);
  10.157 +        errn += verify("test_2ci_neg: a2", i, a2.get(i), -103);
  10.158 +      }
  10.159 +      test_2vi_neg(a1, a2, 123, 103);
  10.160 +      for (int i=0; i<ARRLEN; i++) {
  10.161 +        errn += verify("test_2vi_neg: a1", i, a1.get(i), 123);
  10.162 +        errn += verify("test_2vi_neg: a2", i, a2.get(i), 103);
  10.163 +      }
  10.164 +      // Reset for opposite stride
  10.165 +      for (int i=0; i<ARRLEN; i++) {
  10.166 +        a1.set(i, -1);
  10.167 +        a2.set(i, -1);
  10.168 +      }
  10.169 +      test_ci_oppos(a1, -1);
  10.170 +      for (int i=0; i<ARRLEN; i++) {
  10.171 +        errn += verify("test_ci_oppos: a1", i, a1.get(i), -123);
  10.172 +      }
  10.173 +      test_vi_oppos(a2, 123, -1);
  10.174 +      for (int i=0; i<ARRLEN; i++) {
  10.175 +        errn += verify("test_vi_oppos: a2", i, a2.get(i), 123);
  10.176 +      }
  10.177 +      test_cp_oppos(a1, a2);
  10.178 +      for (int i=0; i<ARRLEN; i++) {
  10.179 +        errn += verify("test_cp_oppos: a1", i, a1.get(i), 123);
  10.180 +      }
  10.181 +      test_2ci_oppos(a1, a2);
  10.182 +      for (int i=0; i<ARRLEN; i++) {
  10.183 +        errn += verify("test_2ci_oppos: a1", i, a1.get(i), -123);
  10.184 +        errn += verify("test_2ci_oppos: a2", i, a2.get(i), -103);
  10.185 +      }
  10.186 +      test_2vi_oppos(a1, a2, 123, 103);
  10.187 +      for (int i=0; i<ARRLEN; i++) {
  10.188 +        errn += verify("test_2vi_oppos: a1", i, a1.get(i), 123);
  10.189 +        errn += verify("test_2vi_oppos: a2", i, a2.get(i), 103);
  10.190 +      }
  10.191 +      // Reset for indexing with offset
  10.192 +      for (int i=0; i<ARRLEN; i++) {
  10.193 +        a1.set(i, -1);
  10.194 +        a2.set(i, -1);
  10.195 +      }
  10.196 +      test_ci_off(a1, -1);
  10.197 +      for (int i=OFFSET; i<ARRLEN; i++) {
  10.198 +        errn += verify("test_ci_off: a1", i, a1.get(i), -123);
  10.199 +      }
  10.200 +      test_vi_off(a2, 123, -1);
  10.201 +      for (int i=OFFSET; i<ARRLEN; i++) {
  10.202 +        errn += verify("test_vi_off: a2", i, a2.get(i), 123);
  10.203 +      }
  10.204 +      test_cp_off(a1, a2);
  10.205 +      for (int i=OFFSET; i<ARRLEN; i++) {
  10.206 +        errn += verify("test_cp_off: a1", i, a1.get(i), 123);
  10.207 +      }
  10.208 +      test_2ci_off(a1, a2);
  10.209 +      for (int i=OFFSET; i<ARRLEN; i++) {
  10.210 +        errn += verify("test_2ci_off: a1", i, a1.get(i), -123);
  10.211 +        errn += verify("test_2ci_off: a2", i, a2.get(i), -103);
  10.212 +      }
  10.213 +      test_2vi_off(a1, a2, 123, 103);
  10.214 +      for (int i=OFFSET; i<ARRLEN; i++) {
  10.215 +        errn += verify("test_2vi_off: a1", i, a1.get(i), 123);
  10.216 +        errn += verify("test_2vi_off: a2", i, a2.get(i), 103);
  10.217 +      }
  10.218 +      for (int i=0; i<OFFSET; i++) {
  10.219 +        errn += verify("test_2vi_off: a1", i, a1.get(i), -1);
  10.220 +        errn += verify("test_2vi_off: a2", i, a2.get(i), -1);
  10.221 +      }
  10.222 +      // Reset for indexing with invariant offset
  10.223 +      for (int i=0; i<ARRLEN; i++) {
  10.224 +        a1.set(i, -1);
  10.225 +        a2.set(i, -1);
  10.226 +      }
  10.227 +      test_ci_inv(a1, OFFSET, -1);
  10.228 +      for (int i=OFFSET; i<ARRLEN; i++) {
  10.229 +        errn += verify("test_ci_inv: a1", i, a1.get(i), -123);
  10.230 +      }
  10.231 +      test_vi_inv(a2, 123, OFFSET, -1);
  10.232 +      for (int i=OFFSET; i<ARRLEN; i++) {
  10.233 +        errn += verify("test_vi_inv: a2", i, a2.get(i), 123);
  10.234 +      }
  10.235 +      test_cp_inv(a1, a2, OFFSET);
  10.236 +      for (int i=OFFSET; i<ARRLEN; i++) {
  10.237 +        errn += verify("test_cp_inv: a1", i, a1.get(i), 123);
  10.238 +      }
  10.239 +      test_2ci_inv(a1, a2, OFFSET);
  10.240 +      for (int i=OFFSET; i<ARRLEN; i++) {
  10.241 +        errn += verify("test_2ci_inv: a1", i, a1.get(i), -123);
  10.242 +        errn += verify("test_2ci_inv: a2", i, a2.get(i), -103);
  10.243 +      }
  10.244 +      test_2vi_inv(a1, a2, 123, 103, OFFSET);
  10.245 +      for (int i=OFFSET; i<ARRLEN; i++) {
  10.246 +        errn += verify("test_2vi_inv: a1", i, a1.get(i), 123);
  10.247 +        errn += verify("test_2vi_inv: a2", i, a2.get(i), 103);
  10.248 +      }
  10.249 +      for (int i=0; i<OFFSET; i++) {
  10.250 +        errn += verify("test_2vi_inv: a1", i, a1.get(i), -1);
  10.251 +        errn += verify("test_2vi_inv: a2", i, a2.get(i), -1);
  10.252 +      }
  10.253 +      // Reset for indexing with scale
  10.254 +      for (int i=0; i<ARRLEN; i++) {
  10.255 +        a1.set(i, -1);
  10.256 +        a2.set(i, -1);
  10.257 +      }
  10.258 +      test_ci_scl(a1, -1);
  10.259 +      for (int i=0; i<ARRLEN; i++) {
  10.260 +        int val = (i%SCALE != 0) ? -1 : -123;
  10.261 +        errn += verify("test_ci_scl: a1", i, a1.get(i), val);
  10.262 +      }
  10.263 +      test_vi_scl(a2, 123, -1);
  10.264 +      for (int i=0; i<ARRLEN; i++) {
  10.265 +        int val = (i%SCALE != 0) ? -1 : 123;
  10.266 +        errn += verify("test_vi_scl: a2", i, a2.get(i), val);
  10.267 +      }
  10.268 +      test_cp_scl(a1, a2);
  10.269 +      for (int i=0; i<ARRLEN; i++) {
  10.270 +        int val = (i%SCALE != 0) ? -1 : 123;
  10.271 +        errn += verify("test_cp_scl: a1", i, a1.get(i), val);
  10.272 +      }
  10.273 +      test_2ci_scl(a1, a2);
  10.274 +      for (int i=0; i<ARRLEN; i++) {
  10.275 +        if (i%SCALE != 0) {
  10.276 +          errn += verify("test_2ci_scl: a1", i, a1.get(i), -1);
  10.277 +        } else if (i*SCALE < ARRLEN) {
  10.278 +          errn += verify("test_2ci_scl: a1", i*SCALE, a1.get(i*SCALE), -123);
  10.279 +        }
  10.280 +        if (i%SCALE != 0) {
  10.281 +          errn += verify("test_2ci_scl: a2", i, a2.get(i), -1);
  10.282 +        } else if (i*SCALE < ARRLEN) {
  10.283 +          errn += verify("test_2ci_scl: a2", i*SCALE, a2.get(i*SCALE), -103);
  10.284 +        }
  10.285 +      }
  10.286 +      test_2vi_scl(a1, a2, 123, 103);
  10.287 +      for (int i=0; i<ARRLEN; i++) {
  10.288 +        if (i%SCALE != 0) {
  10.289 +          errn += verify("test_2vi_scl: a1", i, a1.get(i), -1);
  10.290 +        } else if (i*SCALE < ARRLEN) {
  10.291 +          errn += verify("test_2vi_scl: a1", i*SCALE, a1.get(i*SCALE), 123);
  10.292 +        }
  10.293 +        if (i%SCALE != 0) {
  10.294 +          errn += verify("test_2vi_scl: a2", i, a2.get(i), -1);
  10.295 +        } else if (i*SCALE < ARRLEN) {
  10.296 +          errn += verify("test_2vi_scl: a2", i*SCALE, a2.get(i*SCALE), 103);
  10.297 +        }
  10.298 +      }
  10.299 +      // Reset for 2 arrays with relative aligned offset
  10.300 +      for (int i=0; i<ARRLEN; i++) {
  10.301 +        a1.set(i, -1);
  10.302 +        a2.set(i, -1);
  10.303 +      }
  10.304 +      test_vi(a2, 123, -1);
  10.305 +      test_cp_alndst(a1, a2);
  10.306 +      for (int i=0; i<ALIGN_OFF; i++) {
  10.307 +        errn += verify("test_cp_alndst: a1", i, a1.get(i), -1);
  10.308 +      }
  10.309 +      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
  10.310 +        errn += verify("test_cp_alndst: a1", i, a1.get(i), 123);
  10.311 +      }
  10.312 +      for (int i=0; i<ALIGN_OFF; i++) {
  10.313 +        a1.set(i, 123);
  10.314 +      }
  10.315 +      test_vi(a2, -123, 123);
  10.316 +      test_cp_alnsrc(a1, a2);
  10.317 +      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
  10.318 +        errn += verify("test_cp_alnsrc: a1", i, a1.get(i), -123);
  10.319 +      }
  10.320 +      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
  10.321 +        errn += verify("test_cp_alnsrc: a1", i, a1.get(i), 123);
  10.322 +      }
  10.323 +      for (int i=0; i<ARRLEN; i++) {
  10.324 +        a1.set(i, -1);
  10.325 +        a2.set(i, -1);
  10.326 +      }
  10.327 +      test_2ci_aln(a1, a2);
  10.328 +      for (int i=0; i<ALIGN_OFF; i++) {
  10.329 +        errn += verify("test_2ci_aln: a1", i, a1.get(i), -1);
  10.330 +      }
  10.331 +      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
  10.332 +        errn += verify("test_2ci_aln: a1", i, a1.get(i), -123);
  10.333 +      }
  10.334 +      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
  10.335 +        errn += verify("test_2ci_aln: a2", i, a2.get(i), -103);
  10.336 +      }
  10.337 +      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
  10.338 +        errn += verify("test_2ci_aln: a2", i, a2.get(i), -1);
  10.339 +      }
  10.340 +      for (int i=0; i<ARRLEN; i++) {
  10.341 +        a1.set(i, -1);
  10.342 +        a2.set(i, -1);
  10.343 +      }
  10.344 +      test_2vi_aln(a1, a2, 123, 103);
  10.345 +      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
  10.346 +        errn += verify("test_2vi_aln: a1", i, a1.get(i), 123);
  10.347 +      }
  10.348 +      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
  10.349 +        errn += verify("test_2vi_aln: a1", i, a1.get(i), -1);
  10.350 +      }
  10.351 +      for (int i=0; i<ALIGN_OFF; i++) {
  10.352 +        errn += verify("test_2vi_aln: a2", i, a2.get(i), -1);
  10.353 +      }
  10.354 +      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
  10.355 +        errn += verify("test_2vi_aln: a2", i, a2.get(i), 103);
  10.356 +      }
  10.357 +
  10.358 +      // Reset for 2 arrays with relative unaligned offset
  10.359 +      for (int i=0; i<ARRLEN; i++) {
  10.360 +        a1.set(i, -1);
  10.361 +        a2.set(i, -1);
  10.362 +      }
  10.363 +      test_vi(a2, 123, -1);
  10.364 +      test_cp_unalndst(a1, a2);
  10.365 +      for (int i=0; i<UNALIGN_OFF; i++) {
  10.366 +        errn += verify("test_cp_unalndst: a1", i, a1.get(i), -1);
  10.367 +      }
  10.368 +      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
  10.369 +        errn += verify("test_cp_unalndst: a1", i, a1.get(i), 123);
  10.370 +      }
  10.371 +      test_vi(a2, -123, 123);
  10.372 +      test_cp_unalnsrc(a1, a2);
  10.373 +      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
  10.374 +        errn += verify("test_cp_unalnsrc: a1", i, a1.get(i), -123);
  10.375 +      }
  10.376 +      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
  10.377 +        errn += verify("test_cp_unalnsrc: a1", i, a1.get(i), 123);
  10.378 +      }
  10.379 +      for (int i=0; i<ARRLEN; i++) {
  10.380 +        a1.set(i, -1);
  10.381 +        a2.set(i, -1);
  10.382 +      }
  10.383 +      test_2ci_unaln(a1, a2);
  10.384 +      for (int i=0; i<UNALIGN_OFF; i++) {
  10.385 +        errn += verify("test_2ci_unaln: a1", i, a1.get(i), -1);
  10.386 +      }
  10.387 +      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
  10.388 +        errn += verify("test_2ci_unaln: a1", i, a1.get(i), -123);
  10.389 +      }
  10.390 +      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
  10.391 +        errn += verify("test_2ci_unaln: a2", i, a2.get(i), -103);
  10.392 +      }
  10.393 +      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
  10.394 +        errn += verify("test_2ci_unaln: a2", i, a2.get(i), -1);
  10.395 +      }
  10.396 +      for (int i=0; i<ARRLEN; i++) {
  10.397 +        a1.set(i, -1);
  10.398 +        a2.set(i, -1);
  10.399 +      }
  10.400 +      test_2vi_unaln(a1, a2, 123, 103);
  10.401 +      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
  10.402 +        errn += verify("test_2vi_unaln: a1", i, a1.get(i), 123);
  10.403 +      }
  10.404 +      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
  10.405 +        errn += verify("test_2vi_unaln: a1", i, a1.get(i), -1);
  10.406 +      }
  10.407 +      for (int i=0; i<UNALIGN_OFF; i++) {
  10.408 +        errn += verify("test_2vi_unaln: a2", i, a2.get(i), -1);
  10.409 +      }
  10.410 +      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
  10.411 +        errn += verify("test_2vi_unaln: a2", i, a2.get(i), 103);
  10.412 +      }
  10.413 +
  10.414 +      // Reset for aligned overlap initialization
  10.415 +      for (int i=0; i<ALIGN_OFF; i++) {
  10.416 +        a1.set(i, i);
  10.417 +      }
  10.418 +      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
  10.419 +        a1.set(i, -1);
  10.420 +      }
  10.421 +      test_cp_alndst(a1, a1);
  10.422 +      for (int i=0; i<ARRLEN; i++) {
  10.423 +        int v = i%ALIGN_OFF;
  10.424 +        errn += verify("test_cp_alndst_overlap: a1", i, a1.get(i), v);
  10.425 +      }
  10.426 +      for (int i=0; i<ALIGN_OFF; i++) {
  10.427 +        a1.set((i+ALIGN_OFF), -1);
  10.428 +      }
  10.429 +      test_cp_alnsrc(a1, a1);
  10.430 +      for (int i=0; i<ALIGN_OFF; i++) {
  10.431 +        errn += verify("test_cp_alnsrc_overlap: a1", i, a1.get(i), -1);
  10.432 +      }
  10.433 +      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
  10.434 +        int v = i%ALIGN_OFF;
  10.435 +        errn += verify("test_cp_alnsrc_overlap: a1", i, a1.get(i), v);
  10.436 +      }
  10.437 +      for (int i=0; i<ARRLEN; i++) {
  10.438 +        a1.set(i, -1);
  10.439 +      }
  10.440 +      test_2ci_aln(a1, a1);
  10.441 +      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
  10.442 +        errn += verify("test_2ci_aln_overlap: a1", i, a1.get(i), -103);
  10.443 +      }
  10.444 +      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
  10.445 +        errn += verify("test_2ci_aln_overlap: a1", i, a1.get(i), -123);
  10.446 +      }
  10.447 +      for (int i=0; i<ARRLEN; i++) {
  10.448 +        a1.set(i, -1);
  10.449 +      }
  10.450 +      test_2vi_aln(a1, a1, 123, 103);
  10.451 +      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
  10.452 +        errn += verify("test_2vi_aln_overlap: a1", i, a1.get(i), 123);
  10.453 +      }
  10.454 +      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
  10.455 +        errn += verify("test_2vi_aln_overlap: a1", i, a1.get(i), 103);
  10.456 +      }
  10.457 +
  10.458 +      // Reset for unaligned overlap initialization
  10.459 +      for (int i=0; i<UNALIGN_OFF; i++) {
  10.460 +        a1.set(i, i);
  10.461 +      }
  10.462 +      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
  10.463 +        a1.set(i, -1);
  10.464 +      }
  10.465 +      test_cp_unalndst(a1, a1);
  10.466 +      for (int i=0; i<ARRLEN; i++) {
  10.467 +        int v = i%UNALIGN_OFF;
  10.468 +        errn += verify("test_cp_unalndst_overlap: a1", i, a1.get(i), v);
  10.469 +      }
  10.470 +      for (int i=0; i<UNALIGN_OFF; i++) {
  10.471 +        a1.set((i+UNALIGN_OFF), -1);
  10.472 +      }
  10.473 +      test_cp_unalnsrc(a1, a1);
  10.474 +      for (int i=0; i<UNALIGN_OFF; i++) {
  10.475 +        errn += verify("test_cp_unalnsrc_overlap: a1", i, a1.get(i), -1);
  10.476 +      }
  10.477 +      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
  10.478 +        int v = i%UNALIGN_OFF;
  10.479 +        errn += verify("test_cp_unalnsrc_overlap: a1", i, a1.get(i), v);
  10.480 +      }
  10.481 +      for (int i=0; i<ARRLEN; i++) {
  10.482 +        a1.set(i, -1);
  10.483 +      }
  10.484 +      test_2ci_unaln(a1, a1);
  10.485 +      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
  10.486 +        errn += verify("test_2ci_unaln_overlap: a1", i, a1.get(i), -103);
  10.487 +      }
  10.488 +      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
  10.489 +        errn += verify("test_2ci_unaln_overlap: a1", i, a1.get(i), -123);
  10.490 +      }
  10.491 +      for (int i=0; i<ARRLEN; i++) {
  10.492 +        a1.set(i, -1);
  10.493 +      }
  10.494 +      test_2vi_unaln(a1, a1, 123, 103);
  10.495 +      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
  10.496 +        errn += verify("test_2vi_unaln_overlap: a1", i, a1.get(i), 123);
  10.497 +      }
  10.498 +      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
  10.499 +        errn += verify("test_2vi_unaln_overlap: a1", i, a1.get(i), 103);
  10.500 +      }
  10.501 +
  10.502 +    }
  10.503 +
  10.504 +    if (errn > 0 || test_only)
  10.505 +      return errn;
  10.506 +
  10.507 +    // Initialize
  10.508 +    for (int i=0; i<ARRLEN; i++) {
  10.509 +      a1.set(i, -1);
  10.510 +      a2.set(i, -1);
  10.511 +    }
  10.512 +    System.out.println("Time");
  10.513 +    long start, end;
  10.514 +    start = System.currentTimeMillis();
  10.515 +    for (int i=0; i<ITERS; i++) {
  10.516 +      test_ci(a1);
  10.517 +    }
  10.518 +    end = System.currentTimeMillis();
  10.519 +    System.out.println("test_ci: " + (end - start));
  10.520 +    start = System.currentTimeMillis();
  10.521 +    for (int i=0; i<ITERS; i++) {
  10.522 +      test_vi(a2, 123, -1);
  10.523 +    }
  10.524 +    end = System.currentTimeMillis();
  10.525 +    System.out.println("test_vi: " + (end - start));
  10.526 +    start = System.currentTimeMillis();
  10.527 +    for (int i=0; i<ITERS; i++) {
  10.528 +      test_cp(a1, a2);
  10.529 +    }
  10.530 +    end = System.currentTimeMillis();
  10.531 +    System.out.println("test_cp: " + (end - start));
  10.532 +    start = System.currentTimeMillis();
  10.533 +    for (int i=0; i<ITERS; i++) {
  10.534 +      test_2ci(a1, a2);
  10.535 +    }
  10.536 +    end = System.currentTimeMillis();
  10.537 +    System.out.println("test_2ci: " + (end - start));
  10.538 +    start = System.currentTimeMillis();
  10.539 +    for (int i=0; i<ITERS; i++) {
  10.540 +      test_2vi(a1, a2, 123, 103);
  10.541 +    }
  10.542 +    end = System.currentTimeMillis();
  10.543 +    System.out.println("test_2vi: " + (end - start));
  10.544 +
  10.545 +    start = System.currentTimeMillis();
  10.546 +    for (int i=0; i<ITERS; i++) {
  10.547 +      test_ci_neg(a1, 123);
  10.548 +    }
  10.549 +    end = System.currentTimeMillis();
  10.550 +    System.out.println("test_ci_neg: " + (end - start));
  10.551 +    start = System.currentTimeMillis();
  10.552 +    for (int i=0; i<ITERS; i++) {
  10.553 +      test_vi_neg(a2, 123, 103);
  10.554 +    }
  10.555 +    end = System.currentTimeMillis();
  10.556 +    System.out.println("test_vi_neg: " + (end - start));
  10.557 +    start = System.currentTimeMillis();
  10.558 +    for (int i=0; i<ITERS; i++) {
  10.559 +      test_cp_neg(a1, a2);
  10.560 +    }
  10.561 +    end = System.currentTimeMillis();
  10.562 +    System.out.println("test_cp_neg: " + (end - start));
  10.563 +    start = System.currentTimeMillis();
  10.564 +    for (int i=0; i<ITERS; i++) {
  10.565 +      test_2ci_neg(a1, a2);
  10.566 +    }
  10.567 +    end = System.currentTimeMillis();
  10.568 +    System.out.println("test_2ci_neg: " + (end - start));
  10.569 +    start = System.currentTimeMillis();
  10.570 +    for (int i=0; i<ITERS; i++) {
  10.571 +      test_2vi_neg(a1, a2, 123, 103);
  10.572 +    }
  10.573 +    end = System.currentTimeMillis();
  10.574 +    System.out.println("test_2vi_neg: " + (end - start));
  10.575 +
  10.576 +    start = System.currentTimeMillis();
  10.577 +    for (int i=0; i<ITERS; i++) {
  10.578 +      test_ci_oppos(a1, 123);
  10.579 +    }
  10.580 +    end = System.currentTimeMillis();
  10.581 +    System.out.println("test_ci_oppos: " + (end - start));
  10.582 +    start = System.currentTimeMillis();
  10.583 +    for (int i=0; i<ITERS; i++) {
  10.584 +      test_vi_oppos(a2, 123, 103);
  10.585 +    }
  10.586 +    end = System.currentTimeMillis();
  10.587 +    System.out.println("test_vi_oppos: " + (end - start));
  10.588 +    start = System.currentTimeMillis();
  10.589 +    for (int i=0; i<ITERS; i++) {
  10.590 +      test_cp_oppos(a1, a2);
  10.591 +    }
  10.592 +    end = System.currentTimeMillis();
  10.593 +    System.out.println("test_cp_oppos: " + (end - start));
  10.594 +    start = System.currentTimeMillis();
  10.595 +    for (int i=0; i<ITERS; i++) {
  10.596 +      test_2ci_oppos(a1, a2);
  10.597 +    }
  10.598 +    end = System.currentTimeMillis();
  10.599 +    System.out.println("test_2ci_oppos: " + (end - start));
  10.600 +    start = System.currentTimeMillis();
  10.601 +    for (int i=0; i<ITERS; i++) {
  10.602 +      test_2vi_oppos(a1, a2, 123, 103);
  10.603 +    }
  10.604 +    end = System.currentTimeMillis();
  10.605 +    System.out.println("test_2vi_oppos: " + (end - start));
  10.606 +
  10.607 +    start = System.currentTimeMillis();
  10.608 +    for (int i=0; i<ITERS; i++) {
  10.609 +      test_ci_off(a1, 123);
  10.610 +    }
  10.611 +    end = System.currentTimeMillis();
  10.612 +    System.out.println("test_ci_off: " + (end - start));
  10.613 +    start = System.currentTimeMillis();
  10.614 +    for (int i=0; i<ITERS; i++) {
  10.615 +      test_vi_off(a2, 123, 103);
  10.616 +    }
  10.617 +    end = System.currentTimeMillis();
  10.618 +    System.out.println("test_vi_off: " + (end - start));
  10.619 +    start = System.currentTimeMillis();
  10.620 +    for (int i=0; i<ITERS; i++) {
  10.621 +      test_cp_off(a1, a2);
  10.622 +    }
  10.623 +    end = System.currentTimeMillis();
  10.624 +    System.out.println("test_cp_off: " + (end - start));
  10.625 +    start = System.currentTimeMillis();
  10.626 +    for (int i=0; i<ITERS; i++) {
  10.627 +      test_2ci_off(a1, a2);
  10.628 +    }
  10.629 +    end = System.currentTimeMillis();
  10.630 +    System.out.println("test_2ci_off: " + (end - start));
  10.631 +    start = System.currentTimeMillis();
  10.632 +    for (int i=0; i<ITERS; i++) {
  10.633 +      test_2vi_off(a1, a2, 123, 103);
  10.634 +    }
  10.635 +    end = System.currentTimeMillis();
  10.636 +    System.out.println("test_2vi_off: " + (end - start));
  10.637 +
  10.638 +    start = System.currentTimeMillis();
  10.639 +    for (int i=0; i<ITERS; i++) {
  10.640 +      test_ci_inv(a1, OFFSET, 123);
  10.641 +    }
  10.642 +    end = System.currentTimeMillis();
  10.643 +    System.out.println("test_ci_inv: " + (end - start));
  10.644 +    start = System.currentTimeMillis();
  10.645 +    for (int i=0; i<ITERS; i++) {
  10.646 +      test_vi_inv(a2, 123, OFFSET, 103);
  10.647 +    }
  10.648 +    end = System.currentTimeMillis();
  10.649 +    System.out.println("test_vi_inv: " + (end - start));
  10.650 +    start = System.currentTimeMillis();
  10.651 +    for (int i=0; i<ITERS; i++) {
  10.652 +      test_cp_inv(a1, a2, OFFSET);
  10.653 +    }
  10.654 +    end = System.currentTimeMillis();
  10.655 +    System.out.println("test_cp_inv: " + (end - start));
  10.656 +    start = System.currentTimeMillis();
  10.657 +    for (int i=0; i<ITERS; i++) {
  10.658 +      test_2ci_inv(a1, a2, OFFSET);
  10.659 +    }
  10.660 +    end = System.currentTimeMillis();
  10.661 +    System.out.println("test_2ci_inv: " + (end - start));
  10.662 +    start = System.currentTimeMillis();
  10.663 +    for (int i=0; i<ITERS; i++) {
  10.664 +      test_2vi_inv(a1, a2, 123, 103, OFFSET);
  10.665 +    }
  10.666 +    end = System.currentTimeMillis();
  10.667 +    System.out.println("test_2vi_inv: " + (end - start));
  10.668 +
  10.669 +    start = System.currentTimeMillis();
  10.670 +    for (int i=0; i<ITERS; i++) {
  10.671 +      test_ci_scl(a1, 123);
  10.672 +    }
  10.673 +    end = System.currentTimeMillis();
  10.674 +    System.out.println("test_ci_scl: " + (end - start));
  10.675 +    start = System.currentTimeMillis();
  10.676 +    for (int i=0; i<ITERS; i++) {
  10.677 +      test_vi_scl(a2, 123, 103);
  10.678 +    }
  10.679 +    end = System.currentTimeMillis();
  10.680 +    System.out.println("test_vi_scl: " + (end - start));
  10.681 +    start = System.currentTimeMillis();
  10.682 +    for (int i=0; i<ITERS; i++) {
  10.683 +      test_cp_scl(a1, a2);
  10.684 +    }
  10.685 +    end = System.currentTimeMillis();
  10.686 +    System.out.println("test_cp_scl: " + (end - start));
  10.687 +    start = System.currentTimeMillis();
  10.688 +    for (int i=0; i<ITERS; i++) {
  10.689 +      test_2ci_scl(a1, a2);
  10.690 +    }
  10.691 +    end = System.currentTimeMillis();
  10.692 +    System.out.println("test_2ci_scl: " + (end - start));
  10.693 +    start = System.currentTimeMillis();
  10.694 +    for (int i=0; i<ITERS; i++) {
  10.695 +      test_2vi_scl(a1, a2, 123, 103);
  10.696 +    }
  10.697 +    end = System.currentTimeMillis();
  10.698 +    System.out.println("test_2vi_scl: " + (end - start));
  10.699 +
  10.700 +    start = System.currentTimeMillis();
  10.701 +    for (int i=0; i<ITERS; i++) {
  10.702 +      test_cp_alndst(a1, a2);
  10.703 +    }
  10.704 +    end = System.currentTimeMillis();
  10.705 +    System.out.println("test_cp_alndst: " + (end - start));
  10.706 +    start = System.currentTimeMillis();
  10.707 +    for (int i=0; i<ITERS; i++) {
  10.708 +      test_cp_alnsrc(a1, a2);
  10.709 +    }
  10.710 +    end = System.currentTimeMillis();
  10.711 +    System.out.println("test_cp_alnsrc: " + (end - start));
  10.712 +    start = System.currentTimeMillis();
  10.713 +    for (int i=0; i<ITERS; i++) {
  10.714 +      test_2ci_aln(a1, a2);
  10.715 +    }
  10.716 +    end = System.currentTimeMillis();
  10.717 +    System.out.println("test_2ci_aln: " + (end - start));
  10.718 +    start = System.currentTimeMillis();
  10.719 +    for (int i=0; i<ITERS; i++) {
  10.720 +      test_2vi_aln(a1, a2, 123, 103);
  10.721 +    }
  10.722 +    end = System.currentTimeMillis();
  10.723 +    System.out.println("test_2vi_aln: " + (end - start));
  10.724 +
  10.725 +    start = System.currentTimeMillis();
  10.726 +    for (int i=0; i<ITERS; i++) {
  10.727 +      test_cp_unalndst(a1, a2);
  10.728 +    }
  10.729 +    end = System.currentTimeMillis();
  10.730 +    System.out.println("test_cp_unalndst: " + (end - start));
  10.731 +    start = System.currentTimeMillis();
  10.732 +    for (int i=0; i<ITERS; i++) {
  10.733 +      test_cp_unalnsrc(a1, a2);
  10.734 +    }
  10.735 +    end = System.currentTimeMillis();
  10.736 +    System.out.println("test_cp_unalnsrc: " + (end - start));
  10.737 +    start = System.currentTimeMillis();
  10.738 +    for (int i=0; i<ITERS; i++) {
  10.739 +      test_2ci_unaln(a1, a2);
  10.740 +    }
  10.741 +    end = System.currentTimeMillis();
  10.742 +    System.out.println("test_2ci_unaln: " + (end - start));
  10.743 +    start = System.currentTimeMillis();
  10.744 +    for (int i=0; i<ITERS; i++) {
  10.745 +      test_2vi_unaln(a1, a2, 123, 103);
  10.746 +    }
  10.747 +    end = System.currentTimeMillis();
  10.748 +    System.out.println("test_2vi_unaln: " + (end - start));
  10.749 +
  10.750 +    return errn;
  10.751 +  }
  10.752 +
  10.753 +  static void test_ci(AtomicIntegerArray a) {
  10.754 +    for (int i = 0; i < ARRLEN; i+=1) {
  10.755 +      a.compareAndSet(i, -1, -123);
  10.756 +    }
  10.757 +  }
  10.758 +  static void test_vi(AtomicIntegerArray a, int b, int old) {
  10.759 +    for (int i = 0; i < ARRLEN; i+=1) {
  10.760 +      a.compareAndSet(i, old, b);
  10.761 +    }
  10.762 +  }
  10.763 +  static void test_cp(AtomicIntegerArray a, AtomicIntegerArray b) {
  10.764 +    for (int i = 0; i < ARRLEN; i+=1) {
  10.765 +      a.compareAndSet(i, -123, b.get(i));
  10.766 +    }
  10.767 +  }
  10.768 +  static void test_2ci(AtomicIntegerArray a, AtomicIntegerArray b) {
  10.769 +    for (int i = 0; i < ARRLEN; i+=1) {
  10.770 +      a.compareAndSet(i, 123, -123);
  10.771 +      b.compareAndSet(i, 123, -103);
  10.772 +    }
  10.773 +  }
  10.774 +  static void test_2vi(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
  10.775 +    for (int i = 0; i < ARRLEN; i+=1) {
  10.776 +      a.compareAndSet(i, -123, c);
  10.777 +      b.compareAndSet(i, -103, d);
  10.778 +    }
  10.779 +  }
  10.780 +  static void test_ci_neg(AtomicIntegerArray a, int old) {
  10.781 +    for (int i = ARRLEN-1; i >= 0; i-=1) {
  10.782 +      a.compareAndSet(i, old, -123);
  10.783 +    }
  10.784 +  }
  10.785 +  static void test_vi_neg(AtomicIntegerArray a, int b, int old) {
  10.786 +    for (int i = ARRLEN-1; i >= 0; i-=1) {
  10.787 +      a.compareAndSet(i, old, b);
  10.788 +    }
  10.789 +  }
  10.790 +  static void test_cp_neg(AtomicIntegerArray a, AtomicIntegerArray b) {
  10.791 +    for (int i = ARRLEN-1; i >= 0; i-=1) {
  10.792 +      a.compareAndSet(i, -123, b.get(i));
  10.793 +    }
  10.794 +  }
  10.795 +  static void test_2ci_neg(AtomicIntegerArray a, AtomicIntegerArray b) {
  10.796 +    for (int i = ARRLEN-1; i >= 0; i-=1) {
  10.797 +      a.compareAndSet(i, 123, -123);
  10.798 +      b.compareAndSet(i, 123, -103);
  10.799 +    }
  10.800 +  }
  10.801 +  static void test_2vi_neg(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
  10.802 +    for (int i = ARRLEN-1; i >= 0; i-=1) {
  10.803 +      a.compareAndSet(i, -123, c);
  10.804 +      b.compareAndSet(i, -103, d);
  10.805 +    }
  10.806 +  }
  10.807 +  static void test_ci_oppos(AtomicIntegerArray a, int old) {
  10.808 +    int limit = ARRLEN-1;
  10.809 +    for (int i = 0; i < ARRLEN; i+=1) {
  10.810 +      a.compareAndSet((limit-i), old, -123);
  10.811 +    }
  10.812 +  }
  10.813 +  static void test_vi_oppos(AtomicIntegerArray a, int b, int old) {
  10.814 +    int limit = ARRLEN-1;
  10.815 +    for (int i = limit; i >= 0; i-=1) {
  10.816 +      a.compareAndSet((limit-i), old, b);
  10.817 +    }
  10.818 +  }
  10.819 +  static void test_cp_oppos(AtomicIntegerArray a, AtomicIntegerArray b) {
  10.820 +    int limit = ARRLEN-1;
  10.821 +    for (int i = 0; i < ARRLEN; i+=1) {
  10.822 +      a.compareAndSet(i, -123, b.get(limit-i));
  10.823 +    }
  10.824 +  }
  10.825 +  static void test_2ci_oppos(AtomicIntegerArray a, AtomicIntegerArray b) {
  10.826 +    int limit = ARRLEN-1;
  10.827 +    for (int i = 0; i < ARRLEN; i+=1) {
  10.828 +      a.compareAndSet((limit-i), 123, -123);
  10.829 +      b.compareAndSet(i, 123, -103);
  10.830 +    }
  10.831 +  }
  10.832 +  static void test_2vi_oppos(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
  10.833 +    int limit = ARRLEN-1;
  10.834 +    for (int i = limit; i >= 0; i-=1) {
  10.835 +      a.compareAndSet(i, -123, c);
  10.836 +      b.compareAndSet((limit-i), -103, d);
  10.837 +    }
  10.838 +  }
  10.839 +  static void test_ci_off(AtomicIntegerArray a, int old) {
  10.840 +    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
  10.841 +      a.compareAndSet((i+OFFSET), old, -123);
  10.842 +    }
  10.843 +  }
  10.844 +  static void test_vi_off(AtomicIntegerArray a, int b, int old) {
  10.845 +    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
  10.846 +      a.compareAndSet((i+OFFSET), old, b);
  10.847 +    }
  10.848 +  }
  10.849 +  static void test_cp_off(AtomicIntegerArray a, AtomicIntegerArray b) {
  10.850 +    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
  10.851 +      a.compareAndSet((i+OFFSET), -123, b.get(i+OFFSET));
  10.852 +    }
  10.853 +  }
  10.854 +  static void test_2ci_off(AtomicIntegerArray a, AtomicIntegerArray b) {
  10.855 +    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
  10.856 +      a.compareAndSet((i+OFFSET), 123, -123);
  10.857 +      b.compareAndSet((i+OFFSET), 123, -103);
  10.858 +    }
  10.859 +  }
  10.860 +  static void test_2vi_off(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
  10.861 +    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
  10.862 +      a.compareAndSet((i+OFFSET), -123, c);
  10.863 +      b.compareAndSet((i+OFFSET), -103, d);
  10.864 +    }
  10.865 +  }
  10.866 +  static void test_ci_inv(AtomicIntegerArray a, int k, int old) {
  10.867 +    for (int i = 0; i < ARRLEN-k; i+=1) {
  10.868 +      a.compareAndSet((i+k), old, -123);
  10.869 +    }
  10.870 +  }
  10.871 +  static void test_vi_inv(AtomicIntegerArray a, int b, int k, int old) {
  10.872 +    for (int i = 0; i < ARRLEN-k; i+=1) {
  10.873 +      a.compareAndSet((i+k), old, b);
  10.874 +    }
  10.875 +  }
  10.876 +  static void test_cp_inv(AtomicIntegerArray a, AtomicIntegerArray b, int k) {
  10.877 +    for (int i = 0; i < ARRLEN-k; i+=1) {
  10.878 +      a.compareAndSet((i+k), -123, b.get(i+k));
  10.879 +    }
  10.880 +  }
  10.881 +  static void test_2ci_inv(AtomicIntegerArray a, AtomicIntegerArray b, int k) {
  10.882 +    for (int i = 0; i < ARRLEN-k; i+=1) {
  10.883 +      a.compareAndSet((i+k), 123, -123);
  10.884 +      b.compareAndSet((i+k), 123, -103);
  10.885 +    }
  10.886 +  }
  10.887 +  static void test_2vi_inv(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d, int k) {
  10.888 +    for (int i = 0; i < ARRLEN-k; i+=1) {
  10.889 +      a.compareAndSet((i+k), -123, c);
  10.890 +      b.compareAndSet((i+k), -103, d);
  10.891 +    }
  10.892 +  }
  10.893 +  static void test_ci_scl(AtomicIntegerArray a, int old) {
  10.894 +    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
  10.895 +      a.compareAndSet((i*SCALE), old, -123);
  10.896 +    }
  10.897 +  }
  10.898 +  static void test_vi_scl(AtomicIntegerArray a, int b, int old) {
  10.899 +    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
  10.900 +      a.compareAndSet((i*SCALE), old, b);
  10.901 +    }
  10.902 +  }
  10.903 +  static void test_cp_scl(AtomicIntegerArray a, AtomicIntegerArray b) {
  10.904 +    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
  10.905 +      a.compareAndSet((i*SCALE), -123, b.get(i*SCALE));
  10.906 +    }
  10.907 +  }
  10.908 +  static void test_2ci_scl(AtomicIntegerArray a, AtomicIntegerArray b) {
  10.909 +    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
  10.910 +      a.compareAndSet((i*SCALE), 123, -123);
  10.911 +      b.compareAndSet((i*SCALE), 123, -103);
  10.912 +    }
  10.913 +  }
  10.914 +  static void test_2vi_scl(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
  10.915 +    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
  10.916 +      a.compareAndSet((i*SCALE), -123, c);
  10.917 +      b.compareAndSet((i*SCALE), -103, d);
  10.918 +    }
  10.919 +  }
  10.920 +  static void test_cp_alndst(AtomicIntegerArray a, AtomicIntegerArray b) {
  10.921 +    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
  10.922 +      a.compareAndSet((i+ALIGN_OFF), -1, b.get(i));
  10.923 +    }
  10.924 +  }
  10.925 +  static void test_cp_alnsrc(AtomicIntegerArray a, AtomicIntegerArray b) {
  10.926 +    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
  10.927 +      a.getAndSet(i, b.get(i+ALIGN_OFF));
  10.928 +    }
  10.929 +  }
  10.930 +  static void test_2ci_aln(AtomicIntegerArray a, AtomicIntegerArray b) {
  10.931 +    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
  10.932 +      a.compareAndSet((i+ALIGN_OFF), -1, -123);
  10.933 +      b.getAndSet(i, -103);
  10.934 +    }
  10.935 +  }
  10.936 +  static void test_2vi_aln(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
  10.937 +    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
  10.938 +      a.getAndSet(i, c);
  10.939 +      b.getAndSet((i+ALIGN_OFF), d);
  10.940 +    }
  10.941 +  }
  10.942 +  static void test_cp_unalndst(AtomicIntegerArray a, AtomicIntegerArray b) {
  10.943 +    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
  10.944 +      a.compareAndSet((i+UNALIGN_OFF), -1, b.get(i));
  10.945 +    }
  10.946 +  }
  10.947 +  static void test_cp_unalnsrc(AtomicIntegerArray a, AtomicIntegerArray b) {
  10.948 +    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
  10.949 +      a.getAndSet(i, b.get(i+UNALIGN_OFF));
  10.950 +    }
  10.951 +  }
  10.952 +  static void test_2ci_unaln(AtomicIntegerArray a, AtomicIntegerArray b) {
  10.953 +    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
  10.954 +      a.compareAndSet((i+UNALIGN_OFF), -1, -123);
  10.955 +      b.getAndSet(i, -103);
  10.956 +    }
  10.957 +  }
  10.958 +  static void test_2vi_unaln(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
  10.959 +    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
  10.960 +      a.getAndSet(i, c);
  10.961 +      b.getAndSet((i+UNALIGN_OFF), d);
  10.962 +    }
  10.963 +  }
  10.964 +
  10.965 +  static int verify(String text, int i, int elem, int val) {
  10.966 +    if (elem != val) {
  10.967 +      System.err.println(text + "[" + i + "] = " + elem + " != " + val);
  10.968 +      return 1;
  10.969 +    }
  10.970 +    return 0;
  10.971 +  }
  10.972 +}
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/test/compiler/8004867/TestIntAtomicOrdered.java	Thu Feb 21 06:29:43 2013 -0800
    11.3 @@ -0,0 +1,969 @@
    11.4 +/*
    11.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    11.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    11.7 + *
    11.8 + * This code is free software; you can redistribute it and/or modify it
    11.9 + * under the terms of the GNU General Public License version 2 only, as
   11.10 + * published by the Free Software Foundation.
   11.11 + *
   11.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   11.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   11.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   11.15 + * version 2 for more details (a copy is included in the LICENSE file that
   11.16 + * accompanied this code).
   11.17 + *
   11.18 + * You should have received a copy of the GNU General Public License version
   11.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   11.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   11.21 + *
   11.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   11.23 + * or visit www.oracle.com if you need additional information or have any
   11.24 + * questions.
   11.25 + *
   11.26 + */
   11.27 +
   11.28 +/**
   11.29 + * @test
   11.30 + * @bug 8004867
   11.31 + * @summary VM crashing with assert "share/vm/opto/node.hpp:357 - assert(i < _max) failed: oob"
   11.32 + *
   11.33 + * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:-OptimizeFill TestIntAtomicOrdered
   11.34 + * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:+OptimizeFill TestIntAtomicOrdered
   11.35 + */
   11.36 +
   11.37 +import java.util.concurrent.atomic.AtomicIntegerArray;
   11.38 +
   11.39 +public class TestIntAtomicOrdered {
   11.40 +  private static final int ARRLEN = 97;
   11.41 +  private static final int ITERS  = 11000;
   11.42 +  private static final int OFFSET = 3;
   11.43 +  private static final int SCALE = 2;
   11.44 +  private static final int ALIGN_OFF = 8;
   11.45 +  private static final int UNALIGN_OFF = 5;
   11.46 +
   11.47 +  public static void main(String args[]) {
   11.48 +    System.out.println("Testing Integer array atomic ordered operations");
   11.49 +    int errn = test(false);
   11.50 +    if (errn > 0) {
   11.51 +      System.err.println("FAILED: " + errn + " errors");
   11.52 +      System.exit(97);
   11.53 +    }
   11.54 +    System.out.println("PASSED");
   11.55 +  }
   11.56 +
   11.57 +  static int test(boolean test_only) {
   11.58 +    AtomicIntegerArray a1 = new AtomicIntegerArray(ARRLEN);
   11.59 +    AtomicIntegerArray a2 = new AtomicIntegerArray(ARRLEN);
   11.60 +    // Initialize
   11.61 +    for (int i=0; i<ARRLEN; i++) {
   11.62 +      a1.lazySet(i, -1);
   11.63 +      a2.lazySet(i, -1);
   11.64 +    }
   11.65 +    System.out.println("Warmup");
   11.66 +    for (int i=0; i<ITERS; i++) {
   11.67 +      test_ci(a1);
   11.68 +      test_vi(a2, 123, -1);
   11.69 +      test_cp(a1, a2);
   11.70 +      test_2ci(a1, a2);
   11.71 +      test_2vi(a1, a2, 123, 103);
   11.72 +      test_ci_neg(a1, 123);
   11.73 +      test_vi_neg(a2, 123, 103);
   11.74 +      test_cp_neg(a1, a2);
   11.75 +      test_2ci_neg(a1, a2);
   11.76 +      test_2vi_neg(a1, a2, 123, 103);
   11.77 +      test_ci_oppos(a1, 123);
   11.78 +      test_vi_oppos(a2, 123, 103);
   11.79 +      test_cp_oppos(a1, a2);
   11.80 +      test_2ci_oppos(a1, a2);
   11.81 +      test_2vi_oppos(a1, a2, 123, 103);
   11.82 +      test_ci_off(a1, 123);
   11.83 +      test_vi_off(a2, 123, 103);
   11.84 +      test_cp_off(a1, a2);
   11.85 +      test_2ci_off(a1, a2);
   11.86 +      test_2vi_off(a1, a2, 123, 103);
   11.87 +      test_ci_inv(a1, OFFSET, 123);
   11.88 +      test_vi_inv(a2, 123, OFFSET, 103);
   11.89 +      test_cp_inv(a1, a2, OFFSET);
   11.90 +      test_2ci_inv(a1, a2, OFFSET);
   11.91 +      test_2vi_inv(a1, a2, 123, 103, OFFSET);
   11.92 +      test_ci_scl(a1, 123);
   11.93 +      test_vi_scl(a2, 123, 103);
   11.94 +      test_cp_scl(a1, a2);
   11.95 +      test_2ci_scl(a1, a2);
   11.96 +      test_2vi_scl(a1, a2, 123, 103);
   11.97 +      test_cp_alndst(a1, a2);
   11.98 +      test_cp_alnsrc(a1, a2);
   11.99 +      test_2ci_aln(a1, a2);
  11.100 +      test_2vi_aln(a1, a2, 123, 103);
  11.101 +      test_cp_unalndst(a1, a2);
  11.102 +      test_cp_unalnsrc(a1, a2);
  11.103 +      test_2ci_unaln(a1, a2);
  11.104 +      test_2vi_unaln(a1, a2, 123, 103);
  11.105 +    }
  11.106 +    // Initialize
  11.107 +    for (int i=0; i<ARRLEN; i++) {
  11.108 +      a1.lazySet(i, -1);
  11.109 +      a2.lazySet(i, -1);
  11.110 +    }
  11.111 +    // Test and verify results
  11.112 +    System.out.println("Verification");
  11.113 +    int errn = 0;
  11.114 +    {
  11.115 +      test_ci(a1);
  11.116 +      for (int i=0; i<ARRLEN; i++) {
  11.117 +        errn += verify("test_ci: a1", i, a1.get(i), -123);
  11.118 +      }
  11.119 +      test_vi(a2, 123, -1);
  11.120 +      for (int i=0; i<ARRLEN; i++) {
  11.121 +        errn += verify("test_vi: a2", i, a2.get(i), 123);
  11.122 +      }
  11.123 +      test_cp(a1, a2);
  11.124 +      for (int i=0; i<ARRLEN; i++) {
  11.125 +        errn += verify("test_cp: a1", i, a1.get(i), 123);
  11.126 +      }
  11.127 +      test_2ci(a1, a2);
  11.128 +      for (int i=0; i<ARRLEN; i++) {
  11.129 +        errn += verify("test_2ci: a1", i, a1.get(i), -123);
  11.130 +        errn += verify("test_2ci: a2", i, a2.get(i), -103);
  11.131 +      }
  11.132 +      test_2vi(a1, a2, 123, 103);
  11.133 +      for (int i=0; i<ARRLEN; i++) {
  11.134 +        errn += verify("test_2vi: a1", i, a1.get(i), 123);
  11.135 +        errn += verify("test_2vi: a2", i, a2.get(i), 103);
  11.136 +      }
  11.137 +      // Reset for negative stride
  11.138 +      for (int i=0; i<ARRLEN; i++) {
  11.139 +        a1.lazySet(i, -1);
  11.140 +        a2.lazySet(i, -1);
  11.141 +      }
  11.142 +      test_ci_neg(a1, -1);
  11.143 +      for (int i=0; i<ARRLEN; i++) {
  11.144 +        errn += verify("test_ci_neg: a1", i, a1.get(i), -123);
  11.145 +      }
  11.146 +      test_vi_neg(a2, 123, -1);
  11.147 +      for (int i=0; i<ARRLEN; i++) {
  11.148 +        errn += verify("test_vi_neg: a2", i, a2.get(i), 123);
  11.149 +      }
  11.150 +      test_cp_neg(a1, a2);
  11.151 +      for (int i=0; i<ARRLEN; i++) {
  11.152 +        errn += verify("test_cp_neg: a1", i, a1.get(i), 123);
  11.153 +      }
  11.154 +      test_2ci_neg(a1, a2);
  11.155 +      for (int i=0; i<ARRLEN; i++) {
  11.156 +        errn += verify("test_2ci_neg: a1", i, a1.get(i), -123);
  11.157 +        errn += verify("test_2ci_neg: a2", i, a2.get(i), -103);
  11.158 +      }
  11.159 +      test_2vi_neg(a1, a2, 123, 103);
  11.160 +      for (int i=0; i<ARRLEN; i++) {
  11.161 +        errn += verify("test_2vi_neg: a1", i, a1.get(i), 123);
  11.162 +        errn += verify("test_2vi_neg: a2", i, a2.get(i), 103);
  11.163 +      }
  11.164 +      // Reset for opposite stride
  11.165 +      for (int i=0; i<ARRLEN; i++) {
  11.166 +        a1.lazySet(i, -1);
  11.167 +        a2.lazySet(i, -1);
  11.168 +      }
  11.169 +      test_ci_oppos(a1, -1);
  11.170 +      for (int i=0; i<ARRLEN; i++) {
  11.171 +        errn += verify("test_ci_oppos: a1", i, a1.get(i), -123);
  11.172 +      }
  11.173 +      test_vi_oppos(a2, 123, -1);
  11.174 +      for (int i=0; i<ARRLEN; i++) {
  11.175 +        errn += verify("test_vi_oppos: a2", i, a2.get(i), 123);
  11.176 +      }
  11.177 +      test_cp_oppos(a1, a2);
  11.178 +      for (int i=0; i<ARRLEN; i++) {
  11.179 +        errn += verify("test_cp_oppos: a1", i, a1.get(i), 123);
  11.180 +      }
  11.181 +      test_2ci_oppos(a1, a2);
  11.182 +      for (int i=0; i<ARRLEN; i++) {
  11.183 +        errn += verify("test_2ci_oppos: a1", i, a1.get(i), -123);
  11.184 +        errn += verify("test_2ci_oppos: a2", i, a2.get(i), -103);
  11.185 +      }
  11.186 +      test_2vi_oppos(a1, a2, 123, 103);
  11.187 +      for (int i=0; i<ARRLEN; i++) {
  11.188 +        errn += verify("test_2vi_oppos: a1", i, a1.get(i), 123);
  11.189 +        errn += verify("test_2vi_oppos: a2", i, a2.get(i), 103);
  11.190 +      }
  11.191 +      // Reset for indexing with offset
  11.192 +      for (int i=0; i<ARRLEN; i++) {
  11.193 +        a1.lazySet(i, -1);
  11.194 +        a2.lazySet(i, -1);
  11.195 +      }
  11.196 +      test_ci_off(a1, -1);
  11.197 +      for (int i=OFFSET; i<ARRLEN; i++) {
  11.198 +        errn += verify("test_ci_off: a1", i, a1.get(i), -123);
  11.199 +      }
  11.200 +      test_vi_off(a2, 123, -1);
  11.201 +      for (int i=OFFSET; i<ARRLEN; i++) {
  11.202 +        errn += verify("test_vi_off: a2", i, a2.get(i), 123);
  11.203 +      }
  11.204 +      test_cp_off(a1, a2);
  11.205 +      for (int i=OFFSET; i<ARRLEN; i++) {
  11.206 +        errn += verify("test_cp_off: a1", i, a1.get(i), 123);
  11.207 +      }
  11.208 +      test_2ci_off(a1, a2);
  11.209 +      for (int i=OFFSET; i<ARRLEN; i++) {
  11.210 +        errn += verify("test_2ci_off: a1", i, a1.get(i), -123);
  11.211 +        errn += verify("test_2ci_off: a2", i, a2.get(i), -103);
  11.212 +      }
  11.213 +      test_2vi_off(a1, a2, 123, 103);
  11.214 +      for (int i=OFFSET; i<ARRLEN; i++) {
  11.215 +        errn += verify("test_2vi_off: a1", i, a1.get(i), 123);
  11.216 +        errn += verify("test_2vi_off: a2", i, a2.get(i), 103);
  11.217 +      }
  11.218 +      for (int i=0; i<OFFSET; i++) {
  11.219 +        errn += verify("test_2vi_off: a1", i, a1.get(i), -1);
  11.220 +        errn += verify("test_2vi_off: a2", i, a2.get(i), -1);
  11.221 +      }
  11.222 +      // Reset for indexing with invariant offset
  11.223 +      for (int i=0; i<ARRLEN; i++) {
  11.224 +        a1.lazySet(i, -1);
  11.225 +        a2.lazySet(i, -1);
  11.226 +      }
  11.227 +      test_ci_inv(a1, OFFSET, -1);
  11.228 +      for (int i=OFFSET; i<ARRLEN; i++) {
  11.229 +        errn += verify("test_ci_inv: a1", i, a1.get(i), -123);
  11.230 +      }
  11.231 +      test_vi_inv(a2, 123, OFFSET, -1);
  11.232 +      for (int i=OFFSET; i<ARRLEN; i++) {
  11.233 +        errn += verify("test_vi_inv: a2", i, a2.get(i), 123);
  11.234 +      }
  11.235 +      test_cp_inv(a1, a2, OFFSET);
  11.236 +      for (int i=OFFSET; i<ARRLEN; i++) {
  11.237 +        errn += verify("test_cp_inv: a1", i, a1.get(i), 123);
  11.238 +      }
  11.239 +      test_2ci_inv(a1, a2, OFFSET);
  11.240 +      for (int i=OFFSET; i<ARRLEN; i++) {
  11.241 +        errn += verify("test_2ci_inv: a1", i, a1.get(i), -123);
  11.242 +        errn += verify("test_2ci_inv: a2", i, a2.get(i), -103);
  11.243 +      }
  11.244 +      test_2vi_inv(a1, a2, 123, 103, OFFSET);
  11.245 +      for (int i=OFFSET; i<ARRLEN; i++) {
  11.246 +        errn += verify("test_2vi_inv: a1", i, a1.get(i), 123);
  11.247 +        errn += verify("test_2vi_inv: a2", i, a2.get(i), 103);
  11.248 +      }
  11.249 +      for (int i=0; i<OFFSET; i++) {
  11.250 +        errn += verify("test_2vi_inv: a1", i, a1.get(i), -1);
  11.251 +        errn += verify("test_2vi_inv: a2", i, a2.get(i), -1);
  11.252 +      }
  11.253 +      // Reset for indexing with scale
  11.254 +      for (int i=0; i<ARRLEN; i++) {
  11.255 +        a1.lazySet(i, -1);
  11.256 +        a2.lazySet(i, -1);
  11.257 +      }
  11.258 +      test_ci_scl(a1, -1);
  11.259 +      for (int i=0; i<ARRLEN; i++) {
  11.260 +        int val = (i%SCALE != 0) ? -1 : -123;
  11.261 +        errn += verify("test_ci_scl: a1", i, a1.get(i), val);
  11.262 +      }
  11.263 +      test_vi_scl(a2, 123, -1);
  11.264 +      for (int i=0; i<ARRLEN; i++) {
  11.265 +        int val = (i%SCALE != 0) ? -1 : 123;
  11.266 +        errn += verify("test_vi_scl: a2", i, a2.get(i), val);
  11.267 +      }
  11.268 +      test_cp_scl(a1, a2);
  11.269 +      for (int i=0; i<ARRLEN; i++) {
  11.270 +        int val = (i%SCALE != 0) ? -1 : 123;
  11.271 +        errn += verify("test_cp_scl: a1", i, a1.get(i), val);
  11.272 +      }
  11.273 +      test_2ci_scl(a1, a2);
  11.274 +      for (int i=0; i<ARRLEN; i++) {
  11.275 +        if (i%SCALE != 0) {
  11.276 +          errn += verify("test_2ci_scl: a1", i, a1.get(i), -1);
  11.277 +        } else if (i*SCALE < ARRLEN) {
  11.278 +          errn += verify("test_2ci_scl: a1", i*SCALE, a1.get(i*SCALE), -123);
  11.279 +        }
  11.280 +        if (i%SCALE != 0) {
  11.281 +          errn += verify("test_2ci_scl: a2", i, a2.get(i), -1);
  11.282 +        } else if (i*SCALE < ARRLEN) {
  11.283 +          errn += verify("test_2ci_scl: a2", i*SCALE, a2.get(i*SCALE), -103);
  11.284 +        }
  11.285 +      }
  11.286 +      test_2vi_scl(a1, a2, 123, 103);
  11.287 +      for (int i=0; i<ARRLEN; i++) {
  11.288 +        if (i%SCALE != 0) {
  11.289 +          errn += verify("test_2vi_scl: a1", i, a1.get(i), -1);
  11.290 +        } else if (i*SCALE < ARRLEN) {
  11.291 +          errn += verify("test_2vi_scl: a1", i*SCALE, a1.get(i*SCALE), 123);
  11.292 +        }
  11.293 +        if (i%SCALE != 0) {
  11.294 +          errn += verify("test_2vi_scl: a2", i, a2.get(i), -1);
  11.295 +        } else if (i*SCALE < ARRLEN) {
  11.296 +          errn += verify("test_2vi_scl: a2", i*SCALE, a2.get(i*SCALE), 103);
  11.297 +        }
  11.298 +      }
  11.299 +      // Reset for 2 arrays with relative aligned offset
  11.300 +      for (int i=0; i<ARRLEN; i++) {
  11.301 +        a1.lazySet(i, -1);
  11.302 +        a2.lazySet(i, -1);
  11.303 +      }
  11.304 +      test_vi(a2, 123, -1);
  11.305 +      test_cp_alndst(a1, a2);
  11.306 +      for (int i=0; i<ALIGN_OFF; i++) {
  11.307 +        errn += verify("test_cp_alndst: a1", i, a1.get(i), -1);
  11.308 +      }
  11.309 +      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
  11.310 +        errn += verify("test_cp_alndst: a1", i, a1.get(i), 123);
  11.311 +      }
  11.312 +      for (int i=0; i<ALIGN_OFF; i++) {
  11.313 +        a1.lazySet(i, 123);
  11.314 +      }
  11.315 +      test_vi(a2, -123, 123);
  11.316 +      test_cp_alnsrc(a1, a2);
  11.317 +      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
  11.318 +        errn += verify("test_cp_alnsrc: a1", i, a1.get(i), -123);
  11.319 +      }
  11.320 +      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
  11.321 +        errn += verify("test_cp_alnsrc: a1", i, a1.get(i), 123);
  11.322 +      }
  11.323 +      for (int i=0; i<ARRLEN; i++) {
  11.324 +        a1.lazySet(i, -1);
  11.325 +        a2.lazySet(i, -1);
  11.326 +      }
  11.327 +      test_2ci_aln(a1, a2);
  11.328 +      for (int i=0; i<ALIGN_OFF; i++) {
  11.329 +        errn += verify("test_2ci_aln: a1", i, a1.get(i), -1);
  11.330 +      }
  11.331 +      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
  11.332 +        errn += verify("test_2ci_aln: a1", i, a1.get(i), -123);
  11.333 +      }
  11.334 +      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
  11.335 +        errn += verify("test_2ci_aln: a2", i, a2.get(i), -103);
  11.336 +      }
  11.337 +      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
  11.338 +        errn += verify("test_2ci_aln: a2", i, a2.get(i), -1);
  11.339 +      }
  11.340 +      for (int i=0; i<ARRLEN; i++) {
  11.341 +        a1.lazySet(i, -1);
  11.342 +        a2.lazySet(i, -1);
  11.343 +      }
  11.344 +      test_2vi_aln(a1, a2, 123, 103);
  11.345 +      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
  11.346 +        errn += verify("test_2vi_aln: a1", i, a1.get(i), 123);
  11.347 +      }
  11.348 +      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
  11.349 +        errn += verify("test_2vi_aln: a1", i, a1.get(i), -1);
  11.350 +      }
  11.351 +      for (int i=0; i<ALIGN_OFF; i++) {
  11.352 +        errn += verify("test_2vi_aln: a2", i, a2.get(i), -1);
  11.353 +      }
  11.354 +      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
  11.355 +        errn += verify("test_2vi_aln: a2", i, a2.get(i), 103);
  11.356 +      }
  11.357 +
  11.358 +      // Reset for 2 arrays with relative unaligned offset
  11.359 +      for (int i=0; i<ARRLEN; i++) {
  11.360 +        a1.lazySet(i, -1);
  11.361 +        a2.lazySet(i, -1);
  11.362 +      }
  11.363 +      test_vi(a2, 123, -1);
  11.364 +      test_cp_unalndst(a1, a2);
  11.365 +      for (int i=0; i<UNALIGN_OFF; i++) {
  11.366 +        errn += verify("test_cp_unalndst: a1", i, a1.get(i), -1);
  11.367 +      }
  11.368 +      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
  11.369 +        errn += verify("test_cp_unalndst: a1", i, a1.get(i), 123);
  11.370 +      }
  11.371 +      test_vi(a2, -123, 123);
  11.372 +      test_cp_unalnsrc(a1, a2);
  11.373 +      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
  11.374 +        errn += verify("test_cp_unalnsrc: a1", i, a1.get(i), -123);
  11.375 +      }
  11.376 +      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
  11.377 +        errn += verify("test_cp_unalnsrc: a1", i, a1.get(i), 123);
  11.378 +      }
  11.379 +      for (int i=0; i<ARRLEN; i++) {
  11.380 +        a1.lazySet(i, -1);
  11.381 +        a2.lazySet(i, -1);
  11.382 +      }
  11.383 +      test_2ci_unaln(a1, a2);
  11.384 +      for (int i=0; i<UNALIGN_OFF; i++) {
  11.385 +        errn += verify("test_2ci_unaln: a1", i, a1.get(i), -1);
  11.386 +      }
  11.387 +      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
  11.388 +        errn += verify("test_2ci_unaln: a1", i, a1.get(i), -123);
  11.389 +      }
  11.390 +      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
  11.391 +        errn += verify("test_2ci_unaln: a2", i, a2.get(i), -103);
  11.392 +      }
  11.393 +      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
  11.394 +        errn += verify("test_2ci_unaln: a2", i, a2.get(i), -1);
  11.395 +      }
  11.396 +      for (int i=0; i<ARRLEN; i++) {
  11.397 +        a1.lazySet(i, -1);
  11.398 +        a2.lazySet(i, -1);
  11.399 +      }
  11.400 +      test_2vi_unaln(a1, a2, 123, 103);
  11.401 +      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
  11.402 +        errn += verify("test_2vi_unaln: a1", i, a1.get(i), 123);
  11.403 +      }
  11.404 +      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
  11.405 +        errn += verify("test_2vi_unaln: a1", i, a1.get(i), -1);
  11.406 +      }
  11.407 +      for (int i=0; i<UNALIGN_OFF; i++) {
  11.408 +        errn += verify("test_2vi_unaln: a2", i, a2.get(i), -1);
  11.409 +      }
  11.410 +      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
  11.411 +        errn += verify("test_2vi_unaln: a2", i, a2.get(i), 103);
  11.412 +      }
  11.413 +
  11.414 +      // Reset for aligned overlap initialization
  11.415 +      for (int i=0; i<ALIGN_OFF; i++) {
  11.416 +        a1.lazySet(i, i);
  11.417 +      }
  11.418 +      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
  11.419 +        a1.lazySet(i, -1);
  11.420 +      }
  11.421 +      test_cp_alndst(a1, a1);
  11.422 +      for (int i=0; i<ARRLEN; i++) {
  11.423 +        int v = i%ALIGN_OFF;
  11.424 +        errn += verify("test_cp_alndst_overlap: a1", i, a1.get(i), v);
  11.425 +      }
  11.426 +      for (int i=0; i<ALIGN_OFF; i++) {
  11.427 +        a1.lazySet((i+ALIGN_OFF), -1);
  11.428 +      }
  11.429 +      test_cp_alnsrc(a1, a1);
  11.430 +      for (int i=0; i<ALIGN_OFF; i++) {
  11.431 +        errn += verify("test_cp_alnsrc_overlap: a1", i, a1.get(i), -1);
  11.432 +      }
  11.433 +      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
  11.434 +        int v = i%ALIGN_OFF;
  11.435 +        errn += verify("test_cp_alnsrc_overlap: a1", i, a1.get(i), v);
  11.436 +      }
  11.437 +      for (int i=0; i<ARRLEN; i++) {
  11.438 +        a1.lazySet(i, -1);
  11.439 +      }
  11.440 +      test_2ci_aln(a1, a1);
  11.441 +      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
  11.442 +        errn += verify("test_2ci_aln_overlap: a1", i, a1.get(i), -103);
  11.443 +      }
  11.444 +      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
  11.445 +        errn += verify("test_2ci_aln_overlap: a1", i, a1.get(i), -123);
  11.446 +      }
  11.447 +      for (int i=0; i<ARRLEN; i++) {
  11.448 +        a1.lazySet(i, -1);
  11.449 +      }
  11.450 +      test_2vi_aln(a1, a1, 123, 103);
  11.451 +      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
  11.452 +        errn += verify("test_2vi_aln_overlap: a1", i, a1.get(i), 123);
  11.453 +      }
  11.454 +      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
  11.455 +        errn += verify("test_2vi_aln_overlap: a1", i, a1.get(i), 103);
  11.456 +      }
  11.457 +
  11.458 +      // Reset for unaligned overlap initialization
  11.459 +      for (int i=0; i<UNALIGN_OFF; i++) {
  11.460 +        a1.lazySet(i, i);
  11.461 +      }
  11.462 +      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
  11.463 +        a1.lazySet(i, -1);
  11.464 +      }
  11.465 +      test_cp_unalndst(a1, a1);
  11.466 +      for (int i=0; i<ARRLEN; i++) {
  11.467 +        int v = i%UNALIGN_OFF;
  11.468 +        errn += verify("test_cp_unalndst_overlap: a1", i, a1.get(i), v);
  11.469 +      }
  11.470 +      for (int i=0; i<UNALIGN_OFF; i++) {
  11.471 +        a1.lazySet((i+UNALIGN_OFF), -1);
  11.472 +      }
  11.473 +      test_cp_unalnsrc(a1, a1);
  11.474 +      for (int i=0; i<UNALIGN_OFF; i++) {
  11.475 +        errn += verify("test_cp_unalnsrc_overlap: a1", i, a1.get(i), -1);
  11.476 +      }
  11.477 +      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
  11.478 +        int v = i%UNALIGN_OFF;
  11.479 +        errn += verify("test_cp_unalnsrc_overlap: a1", i, a1.get(i), v);
  11.480 +      }
  11.481 +      for (int i=0; i<ARRLEN; i++) {
  11.482 +        a1.lazySet(i, -1);
  11.483 +      }
  11.484 +      test_2ci_unaln(a1, a1);
  11.485 +      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
  11.486 +        errn += verify("test_2ci_unaln_overlap: a1", i, a1.get(i), -103);
  11.487 +      }
  11.488 +      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
  11.489 +        errn += verify("test_2ci_unaln_overlap: a1", i, a1.get(i), -123);
  11.490 +      }
  11.491 +      for (int i=0; i<ARRLEN; i++) {
  11.492 +        a1.lazySet(i, -1);
  11.493 +      }
  11.494 +      test_2vi_unaln(a1, a1, 123, 103);
  11.495 +      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
  11.496 +        errn += verify("test_2vi_unaln_overlap: a1", i, a1.get(i), 123);
  11.497 +      }
  11.498 +      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
  11.499 +        errn += verify("test_2vi_unaln_overlap: a1", i, a1.get(i), 103);
  11.500 +      }
  11.501 +
  11.502 +    }
  11.503 +
  11.504 +    if (errn > 0 || test_only)
  11.505 +      return errn;
  11.506 +
  11.507 +    // Initialize
  11.508 +    for (int i=0; i<ARRLEN; i++) {
  11.509 +      a1.lazySet(i, -1);
  11.510 +      a2.lazySet(i, -1);
  11.511 +    }
  11.512 +    System.out.println("Time");
  11.513 +    long start, end;
  11.514 +    start = System.currentTimeMillis();
  11.515 +    for (int i=0; i<ITERS; i++) {
  11.516 +      test_ci(a1);
  11.517 +    }
  11.518 +    end = System.currentTimeMillis();
  11.519 +    System.out.println("test_ci: " + (end - start));
  11.520 +    start = System.currentTimeMillis();
  11.521 +    for (int i=0; i<ITERS; i++) {
  11.522 +      test_vi(a2, 123, -1);
  11.523 +    }
  11.524 +    end = System.currentTimeMillis();
  11.525 +    System.out.println("test_vi: " + (end - start));
  11.526 +    start = System.currentTimeMillis();
  11.527 +    for (int i=0; i<ITERS; i++) {
  11.528 +      test_cp(a1, a2);
  11.529 +    }
  11.530 +    end = System.currentTimeMillis();
  11.531 +    System.out.println("test_cp: " + (end - start));
  11.532 +    start = System.currentTimeMillis();
  11.533 +    for (int i=0; i<ITERS; i++) {
  11.534 +      test_2ci(a1, a2);
  11.535 +    }
  11.536 +    end = System.currentTimeMillis();
  11.537 +    System.out.println("test_2ci: " + (end - start));
  11.538 +    start = System.currentTimeMillis();
  11.539 +    for (int i=0; i<ITERS; i++) {
  11.540 +      test_2vi(a1, a2, 123, 103);
  11.541 +    }
  11.542 +    end = System.currentTimeMillis();
  11.543 +    System.out.println("test_2vi: " + (end - start));
  11.544 +
  11.545 +    start = System.currentTimeMillis();
  11.546 +    for (int i=0; i<ITERS; i++) {
  11.547 +      test_ci_neg(a1, 123);
  11.548 +    }
  11.549 +    end = System.currentTimeMillis();
  11.550 +    System.out.println("test_ci_neg: " + (end - start));
  11.551 +    start = System.currentTimeMillis();
  11.552 +    for (int i=0; i<ITERS; i++) {
  11.553 +      test_vi_neg(a2, 123, 103);
  11.554 +    }
  11.555 +    end = System.currentTimeMillis();
  11.556 +    System.out.println("test_vi_neg: " + (end - start));
  11.557 +    start = System.currentTimeMillis();
  11.558 +    for (int i=0; i<ITERS; i++) {
  11.559 +      test_cp_neg(a1, a2);
  11.560 +    }
  11.561 +    end = System.currentTimeMillis();
  11.562 +    System.out.println("test_cp_neg: " + (end - start));
  11.563 +    start = System.currentTimeMillis();
  11.564 +    for (int i=0; i<ITERS; i++) {
  11.565 +      test_2ci_neg(a1, a2);
  11.566 +    }
  11.567 +    end = System.currentTimeMillis();
  11.568 +    System.out.println("test_2ci_neg: " + (end - start));
  11.569 +    start = System.currentTimeMillis();
  11.570 +    for (int i=0; i<ITERS; i++) {
  11.571 +      test_2vi_neg(a1, a2, 123, 103);
  11.572 +    }
  11.573 +    end = System.currentTimeMillis();
  11.574 +    System.out.println("test_2vi_neg: " + (end - start));
  11.575 +
  11.576 +    start = System.currentTimeMillis();
  11.577 +    for (int i=0; i<ITERS; i++) {
  11.578 +      test_ci_oppos(a1, 123);
  11.579 +    }
  11.580 +    end = System.currentTimeMillis();
  11.581 +    System.out.println("test_ci_oppos: " + (end - start));
  11.582 +    start = System.currentTimeMillis();
  11.583 +    for (int i=0; i<ITERS; i++) {
  11.584 +      test_vi_oppos(a2, 123, 103);
  11.585 +    }
  11.586 +    end = System.currentTimeMillis();
  11.587 +    System.out.println("test_vi_oppos: " + (end - start));
  11.588 +    start = System.currentTimeMillis();
  11.589 +    for (int i=0; i<ITERS; i++) {
  11.590 +      test_cp_oppos(a1, a2);
  11.591 +    }
  11.592 +    end = System.currentTimeMillis();
  11.593 +    System.out.println("test_cp_oppos: " + (end - start));
  11.594 +    start = System.currentTimeMillis();
  11.595 +    for (int i=0; i<ITERS; i++) {
  11.596 +      test_2ci_oppos(a1, a2);
  11.597 +    }
  11.598 +    end = System.currentTimeMillis();
  11.599 +    System.out.println("test_2ci_oppos: " + (end - start));
  11.600 +    start = System.currentTimeMillis();
  11.601 +    for (int i=0; i<ITERS; i++) {
  11.602 +      test_2vi_oppos(a1, a2, 123, 103);
  11.603 +    }
  11.604 +    end = System.currentTimeMillis();
  11.605 +    System.out.println("test_2vi_oppos: " + (end - start));
  11.606 +
  11.607 +    start = System.currentTimeMillis();
  11.608 +    for (int i=0; i<ITERS; i++) {
  11.609 +      test_ci_off(a1, 123);
  11.610 +    }
  11.611 +    end = System.currentTimeMillis();
  11.612 +    System.out.println("test_ci_off: " + (end - start));
  11.613 +    start = System.currentTimeMillis();
  11.614 +    for (int i=0; i<ITERS; i++) {
  11.615 +      test_vi_off(a2, 123, 103);
  11.616 +    }
  11.617 +    end = System.currentTimeMillis();
  11.618 +    System.out.println("test_vi_off: " + (end - start));
  11.619 +    start = System.currentTimeMillis();
  11.620 +    for (int i=0; i<ITERS; i++) {
  11.621 +      test_cp_off(a1, a2);
  11.622 +    }
  11.623 +    end = System.currentTimeMillis();
  11.624 +    System.out.println("test_cp_off: " + (end - start));
  11.625 +    start = System.currentTimeMillis();
  11.626 +    for (int i=0; i<ITERS; i++) {
  11.627 +      test_2ci_off(a1, a2);
  11.628 +    }
  11.629 +    end = System.currentTimeMillis();
  11.630 +    System.out.println("test_2ci_off: " + (end - start));
  11.631 +    start = System.currentTimeMillis();
  11.632 +    for (int i=0; i<ITERS; i++) {
  11.633 +      test_2vi_off(a1, a2, 123, 103);
  11.634 +    }
  11.635 +    end = System.currentTimeMillis();
  11.636 +    System.out.println("test_2vi_off: " + (end - start));
  11.637 +
  11.638 +    start = System.currentTimeMillis();
  11.639 +    for (int i=0; i<ITERS; i++) {
  11.640 +      test_ci_inv(a1, OFFSET, 123);
  11.641 +    }
  11.642 +    end = System.currentTimeMillis();
  11.643 +    System.out.println("test_ci_inv: " + (end - start));
  11.644 +    start = System.currentTimeMillis();
  11.645 +    for (int i=0; i<ITERS; i++) {
  11.646 +      test_vi_inv(a2, 123, OFFSET, 103);
  11.647 +    }
  11.648 +    end = System.currentTimeMillis();
  11.649 +    System.out.println("test_vi_inv: " + (end - start));
  11.650 +    start = System.currentTimeMillis();
  11.651 +    for (int i=0; i<ITERS; i++) {
  11.652 +      test_cp_inv(a1, a2, OFFSET);
  11.653 +    }
  11.654 +    end = System.currentTimeMillis();
  11.655 +    System.out.println("test_cp_inv: " + (end - start));
  11.656 +    start = System.currentTimeMillis();
  11.657 +    for (int i=0; i<ITERS; i++) {
  11.658 +      test_2ci_inv(a1, a2, OFFSET);
  11.659 +    }
  11.660 +    end = System.currentTimeMillis();
  11.661 +    System.out.println("test_2ci_inv: " + (end - start));
  11.662 +    start = System.currentTimeMillis();
  11.663 +    for (int i=0; i<ITERS; i++) {
  11.664 +      test_2vi_inv(a1, a2, 123, 103, OFFSET);
  11.665 +    }
  11.666 +    end = System.currentTimeMillis();
  11.667 +    System.out.println("test_2vi_inv: " + (end - start));
  11.668 +
  11.669 +    start = System.currentTimeMillis();
  11.670 +    for (int i=0; i<ITERS; i++) {
  11.671 +      test_ci_scl(a1, 123);
  11.672 +    }
  11.673 +    end = System.currentTimeMillis();
  11.674 +    System.out.println("test_ci_scl: " + (end - start));
  11.675 +    start = System.currentTimeMillis();
  11.676 +    for (int i=0; i<ITERS; i++) {
  11.677 +      test_vi_scl(a2, 123, 103);
  11.678 +    }
  11.679 +    end = System.currentTimeMillis();
  11.680 +    System.out.println("test_vi_scl: " + (end - start));
  11.681 +    start = System.currentTimeMillis();
  11.682 +    for (int i=0; i<ITERS; i++) {
  11.683 +      test_cp_scl(a1, a2);
  11.684 +    }
  11.685 +    end = System.currentTimeMillis();
  11.686 +    System.out.println("test_cp_scl: " + (end - start));
  11.687 +    start = System.currentTimeMillis();
  11.688 +    for (int i=0; i<ITERS; i++) {
  11.689 +      test_2ci_scl(a1, a2);
  11.690 +    }
  11.691 +    end = System.currentTimeMillis();
  11.692 +    System.out.println("test_2ci_scl: " + (end - start));
  11.693 +    start = System.currentTimeMillis();
  11.694 +    for (int i=0; i<ITERS; i++) {
  11.695 +      test_2vi_scl(a1, a2, 123, 103);
  11.696 +    }
  11.697 +    end = System.currentTimeMillis();
  11.698 +    System.out.println("test_2vi_scl: " + (end - start));
  11.699 +
  11.700 +    start = System.currentTimeMillis();
  11.701 +    for (int i=0; i<ITERS; i++) {
  11.702 +      test_cp_alndst(a1, a2);
  11.703 +    }
  11.704 +    end = System.currentTimeMillis();
  11.705 +    System.out.println("test_cp_alndst: " + (end - start));
  11.706 +    start = System.currentTimeMillis();
  11.707 +    for (int i=0; i<ITERS; i++) {
  11.708 +      test_cp_alnsrc(a1, a2);
  11.709 +    }
  11.710 +    end = System.currentTimeMillis();
  11.711 +    System.out.println("test_cp_alnsrc: " + (end - start));
  11.712 +    start = System.currentTimeMillis();
  11.713 +    for (int i=0; i<ITERS; i++) {
  11.714 +      test_2ci_aln(a1, a2);
  11.715 +    }
  11.716 +    end = System.currentTimeMillis();
  11.717 +    System.out.println("test_2ci_aln: " + (end - start));
  11.718 +    start = System.currentTimeMillis();
  11.719 +    for (int i=0; i<ITERS; i++) {
  11.720 +      test_2vi_aln(a1, a2, 123, 103);
  11.721 +    }
  11.722 +    end = System.currentTimeMillis();
  11.723 +    System.out.println("test_2vi_aln: " + (end - start));
  11.724 +
  11.725 +    start = System.currentTimeMillis();
  11.726 +    for (int i=0; i<ITERS; i++) {
  11.727 +      test_cp_unalndst(a1, a2);
  11.728 +    }
  11.729 +    end = System.currentTimeMillis();
  11.730 +    System.out.println("test_cp_unalndst: " + (end - start));
  11.731 +    start = System.currentTimeMillis();
  11.732 +    for (int i=0; i<ITERS; i++) {
  11.733 +      test_cp_unalnsrc(a1, a2);
  11.734 +    }
  11.735 +    end = System.currentTimeMillis();
  11.736 +    System.out.println("test_cp_unalnsrc: " + (end - start));
  11.737 +    start = System.currentTimeMillis();
  11.738 +    for (int i=0; i<ITERS; i++) {
  11.739 +      test_2ci_unaln(a1, a2);
  11.740 +    }
  11.741 +    end = System.currentTimeMillis();
  11.742 +    System.out.println("test_2ci_unaln: " + (end - start));
  11.743 +    start = System.currentTimeMillis();
  11.744 +    for (int i=0; i<ITERS; i++) {
  11.745 +      test_2vi_unaln(a1, a2, 123, 103);
  11.746 +    }
  11.747 +    end = System.currentTimeMillis();
  11.748 +    System.out.println("test_2vi_unaln: " + (end - start));
  11.749 +
  11.750 +    return errn;
  11.751 +  }
  11.752 +
  11.753 +  static void test_ci(AtomicIntegerArray a) {
  11.754 +    for (int i = 0; i < ARRLEN; i+=1) {
  11.755 +      a.lazySet(i, -123);
  11.756 +    }
  11.757 +  }
  11.758 +  static void test_vi(AtomicIntegerArray a, int b, int old) {
  11.759 +    for (int i = 0; i < ARRLEN; i+=1) {
  11.760 +      a.lazySet(i, b);
  11.761 +    }
  11.762 +  }
  11.763 +  static void test_cp(AtomicIntegerArray a, AtomicIntegerArray b) {
  11.764 +    for (int i = 0; i < ARRLEN; i+=1) {
  11.765 +      a.lazySet(i, b.get(i));
  11.766 +    }
  11.767 +  }
  11.768 +  static void test_2ci(AtomicIntegerArray a, AtomicIntegerArray b) {
  11.769 +    for (int i = 0; i < ARRLEN; i+=1) {
  11.770 +      a.lazySet(i, -123);
  11.771 +      b.lazySet(i, -103);
  11.772 +    }
  11.773 +  }
  11.774 +  static void test_2vi(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
  11.775 +    for (int i = 0; i < ARRLEN; i+=1) {
  11.776 +      a.lazySet(i, c);
  11.777 +      b.lazySet(i, d);
  11.778 +    }
  11.779 +  }
  11.780 +  static void test_ci_neg(AtomicIntegerArray a, int old) {
  11.781 +    for (int i = ARRLEN-1; i >= 0; i-=1) {
  11.782 +      a.lazySet(i,-123);
  11.783 +    }
  11.784 +  }
  11.785 +  static void test_vi_neg(AtomicIntegerArray a, int b, int old) {
  11.786 +    for (int i = ARRLEN-1; i >= 0; i-=1) {
  11.787 +      a.lazySet(i, b);
  11.788 +    }
  11.789 +  }
  11.790 +  static void test_cp_neg(AtomicIntegerArray a, AtomicIntegerArray b) {
  11.791 +    for (int i = ARRLEN-1; i >= 0; i-=1) {
  11.792 +      a.lazySet(i, b.get(i));
  11.793 +    }
  11.794 +  }
  11.795 +  static void test_2ci_neg(AtomicIntegerArray a, AtomicIntegerArray b) {
  11.796 +    for (int i = ARRLEN-1; i >= 0; i-=1) {
  11.797 +      a.lazySet(i, -123);
  11.798 +      b.lazySet(i, -103);
  11.799 +    }
  11.800 +  }
  11.801 +  static void test_2vi_neg(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
  11.802 +    for (int i = ARRLEN-1; i >= 0; i-=1) {
  11.803 +      a.lazySet(i, c);
  11.804 +      b.lazySet(i, d);
  11.805 +    }
  11.806 +  }
  11.807 +  static void test_ci_oppos(AtomicIntegerArray a, int old) {
  11.808 +    int limit = ARRLEN-1;
  11.809 +    for (int i = 0; i < ARRLEN; i+=1) {
  11.810 +      a.lazySet((limit-i), -123);
  11.811 +    }
  11.812 +  }
  11.813 +  static void test_vi_oppos(AtomicIntegerArray a, int b, int old) {
  11.814 +    int limit = ARRLEN-1;
  11.815 +    for (int i = limit; i >= 0; i-=1) {
  11.816 +      a.lazySet((limit-i), b);
  11.817 +    }
  11.818 +  }
  11.819 +  static void test_cp_oppos(AtomicIntegerArray a, AtomicIntegerArray b) {
  11.820 +    int limit = ARRLEN-1;
  11.821 +    for (int i = 0; i < ARRLEN; i+=1) {
  11.822 +      a.lazySet(i, b.get(limit-i));
  11.823 +    }
  11.824 +  }
  11.825 +  static void test_2ci_oppos(AtomicIntegerArray a, AtomicIntegerArray b) {
  11.826 +    int limit = ARRLEN-1;
  11.827 +    for (int i = 0; i < ARRLEN; i+=1) {
  11.828 +      a.lazySet((limit-i), -123);
  11.829 +      b.lazySet(i, -103);
  11.830 +    }
  11.831 +  }
  11.832 +  static void test_2vi_oppos(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
  11.833 +    int limit = ARRLEN-1;
  11.834 +    for (int i = limit; i >= 0; i-=1) {
  11.835 +      a.lazySet(i, c);
  11.836 +      b.lazySet((limit-i), d);
  11.837 +    }
  11.838 +  }
  11.839 +  static void test_ci_off(AtomicIntegerArray a, int old) {
  11.840 +    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
  11.841 +      a.lazySet((i+OFFSET), -123);
  11.842 +    }
  11.843 +  }
  11.844 +  static void test_vi_off(AtomicIntegerArray a, int b, int old) {
  11.845 +    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
  11.846 +      a.lazySet((i+OFFSET), b);
  11.847 +    }
  11.848 +  }
  11.849 +  static void test_cp_off(AtomicIntegerArray a, AtomicIntegerArray b) {
  11.850 +    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
  11.851 +      a.lazySet((i+OFFSET), b.get(i+OFFSET));
  11.852 +    }
  11.853 +  }
  11.854 +  static void test_2ci_off(AtomicIntegerArray a, AtomicIntegerArray b) {
  11.855 +    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
  11.856 +      a.lazySet((i+OFFSET), -123);
  11.857 +      b.lazySet((i+OFFSET), -103);
  11.858 +    }
  11.859 +  }
  11.860 +  static void test_2vi_off(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
  11.861 +    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
  11.862 +      a.lazySet((i+OFFSET), c);
  11.863 +      b.lazySet((i+OFFSET), d);
  11.864 +    }
  11.865 +  }
  11.866 +  static void test_ci_inv(AtomicIntegerArray a, int k, int old) {
  11.867 +    for (int i = 0; i < ARRLEN-k; i+=1) {
  11.868 +      a.lazySet((i+k),-123);
  11.869 +    }
  11.870 +  }
  11.871 +  static void test_vi_inv(AtomicIntegerArray a, int b, int k, int old) {
  11.872 +    for (int i = 0; i < ARRLEN-k; i+=1) {
  11.873 +      a.lazySet((i+k), b);
  11.874 +    }
  11.875 +  }
  11.876 +  static void test_cp_inv(AtomicIntegerArray a, AtomicIntegerArray b, int k) {
  11.877 +    for (int i = 0; i < ARRLEN-k; i+=1) {
  11.878 +      a.lazySet((i+k), b.get(i+k));
  11.879 +    }
  11.880 +  }
  11.881 +  static void test_2ci_inv(AtomicIntegerArray a, AtomicIntegerArray b, int k) {
  11.882 +    for (int i = 0; i < ARRLEN-k; i+=1) {
  11.883 +      a.lazySet((i+k), -123);
  11.884 +      b.lazySet((i+k), -103);
  11.885 +    }
  11.886 +  }
  11.887 +  static void test_2vi_inv(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d, int k) {
  11.888 +    for (int i = 0; i < ARRLEN-k; i+=1) {
  11.889 +      a.lazySet((i+k), c);
  11.890 +      b.lazySet((i+k), d);
  11.891 +    }
  11.892 +  }
  11.893 +  static void test_ci_scl(AtomicIntegerArray a, int old) {
  11.894 +    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
  11.895 +      a.lazySet((i*SCALE), -123);
  11.896 +    }
  11.897 +  }
  11.898 +  static void test_vi_scl(AtomicIntegerArray a, int b, int old) {
  11.899 +    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
  11.900 +      a.lazySet((i*SCALE), b);
  11.901 +    }
  11.902 +  }
  11.903 +  static void test_cp_scl(AtomicIntegerArray a, AtomicIntegerArray b) {
  11.904 +    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
  11.905 +      a.lazySet((i*SCALE), b.get(i*SCALE));
  11.906 +    }
  11.907 +  }
  11.908 +  static void test_2ci_scl(AtomicIntegerArray a, AtomicIntegerArray b) {
  11.909 +    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
  11.910 +      a.lazySet((i*SCALE), -123);
  11.911 +      b.lazySet((i*SCALE), -103);
  11.912 +    }
  11.913 +  }
  11.914 +  static void test_2vi_scl(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
  11.915 +    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
  11.916 +      a.lazySet((i*SCALE), c);
  11.917 +      b.lazySet((i*SCALE), d);
  11.918 +    }
  11.919 +  }
  11.920 +  static void test_cp_alndst(AtomicIntegerArray a, AtomicIntegerArray b) {
  11.921 +    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
  11.922 +      a.lazySet((i+ALIGN_OFF), b.get(i));
  11.923 +    }
  11.924 +  }
  11.925 +  static void test_cp_alnsrc(AtomicIntegerArray a, AtomicIntegerArray b) {
  11.926 +    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
  11.927 +      a.lazySet(i, b.get(i+ALIGN_OFF));
  11.928 +    }
  11.929 +  }
  11.930 +  static void test_2ci_aln(AtomicIntegerArray a, AtomicIntegerArray b) {
  11.931 +    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
  11.932 +      a.lazySet((i+ALIGN_OFF), -123);
  11.933 +      b.lazySet(i, -103);
  11.934 +    }
  11.935 +  }
  11.936 +  static void test_2vi_aln(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
  11.937 +    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
  11.938 +      a.lazySet(i, c);
  11.939 +      b.lazySet((i+ALIGN_OFF), d);
  11.940 +    }
  11.941 +  }
  11.942 +  static void test_cp_unalndst(AtomicIntegerArray a, AtomicIntegerArray b) {
  11.943 +    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
  11.944 +      a.lazySet((i+UNALIGN_OFF), b.get(i));
  11.945 +    }
  11.946 +  }
  11.947 +  static void test_cp_unalnsrc(AtomicIntegerArray a, AtomicIntegerArray b) {
  11.948 +    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
  11.949 +      a.lazySet(i, b.get(i+UNALIGN_OFF));
  11.950 +    }
  11.951 +  }
  11.952 +  static void test_2ci_unaln(AtomicIntegerArray a, AtomicIntegerArray b) {
  11.953 +    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
  11.954 +      a.lazySet((i+UNALIGN_OFF), -123);
  11.955 +      b.lazySet(i, -103);
  11.956 +    }
  11.957 +  }
  11.958 +  static void test_2vi_unaln(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
  11.959 +    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
  11.960 +      a.lazySet(i, c);
  11.961 +      b.lazySet((i+UNALIGN_OFF), d);
  11.962 +    }
  11.963 +  }
  11.964 +
  11.965 +  static int verify(String text, int i, int elem, int val) {
  11.966 +    if (elem != val) {
  11.967 +      System.err.println(text + "[" + i + "] = " + elem + " != " + val);
  11.968 +      return 1;
  11.969 +    }
  11.970 +    return 0;
  11.971 +  }
  11.972 +}
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/test/compiler/8004867/TestIntAtomicVolatile.java	Thu Feb 21 06:29:43 2013 -0800
    12.3 @@ -0,0 +1,969 @@
    12.4 +/*
    12.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    12.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    12.7 + *
    12.8 + * This code is free software; you can redistribute it and/or modify it
    12.9 + * under the terms of the GNU General Public License version 2 only, as
   12.10 + * published by the Free Software Foundation.
   12.11 + *
   12.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   12.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   12.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   12.15 + * version 2 for more details (a copy is included in the LICENSE file that
   12.16 + * accompanied this code).
   12.17 + *
   12.18 + * You should have received a copy of the GNU General Public License version
   12.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   12.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   12.21 + *
   12.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   12.23 + * or visit www.oracle.com if you need additional information or have any
   12.24 + * questions.
   12.25 + *
   12.26 + */
   12.27 +
   12.28 +/**
   12.29 + * @test
   12.30 + * @bug 8004867
   12.31 + * @summary VM crashing with assert "share/vm/opto/node.hpp:357 - assert(i < _max) failed: oob"
   12.32 + *
   12.33 + * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:-OptimizeFill TestIntAtomicVolatile
   12.34 + * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:+OptimizeFill TestIntAtomicVolatile
   12.35 + */
   12.36 +
   12.37 +import java.util.concurrent.atomic.AtomicIntegerArray;
   12.38 +
   12.39 +public class TestIntAtomicVolatile {
   12.40 +  private static final int ARRLEN = 97;
   12.41 +  private static final int ITERS  = 11000;
   12.42 +  private static final int OFFSET = 3;
   12.43 +  private static final int SCALE = 2;
   12.44 +  private static final int ALIGN_OFF = 8;
   12.45 +  private static final int UNALIGN_OFF = 5;
   12.46 +
   12.47 +  public static void main(String args[]) {
   12.48 +    System.out.println("Testing Integer array atomic volatile operations");
   12.49 +    int errn = test(false);
   12.50 +    if (errn > 0) {
   12.51 +      System.err.println("FAILED: " + errn + " errors");
   12.52 +      System.exit(97);
   12.53 +    }
   12.54 +    System.out.println("PASSED");
   12.55 +  }
   12.56 +
   12.57 +  static int test(boolean test_only) {
   12.58 +    AtomicIntegerArray a1 = new AtomicIntegerArray(ARRLEN);
   12.59 +    AtomicIntegerArray a2 = new AtomicIntegerArray(ARRLEN);
   12.60 +    // Initialize
   12.61 +    for (int i=0; i<ARRLEN; i++) {
   12.62 +      a1.set(i, -1);
   12.63 +      a2.set(i, -1);
   12.64 +    }
   12.65 +    System.out.println("Warmup");
   12.66 +    for (int i=0; i<ITERS; i++) {
   12.67 +      test_ci(a1);
   12.68 +      test_vi(a2, 123, -1);
   12.69 +      test_cp(a1, a2);
   12.70 +      test_2ci(a1, a2);
   12.71 +      test_2vi(a1, a2, 123, 103);
   12.72 +      test_ci_neg(a1, 123);
   12.73 +      test_vi_neg(a2, 123, 103);
   12.74 +      test_cp_neg(a1, a2);
   12.75 +      test_2ci_neg(a1, a2);
   12.76 +      test_2vi_neg(a1, a2, 123, 103);
   12.77 +      test_ci_oppos(a1, 123);
   12.78 +      test_vi_oppos(a2, 123, 103);
   12.79 +      test_cp_oppos(a1, a2);
   12.80 +      test_2ci_oppos(a1, a2);
   12.81 +      test_2vi_oppos(a1, a2, 123, 103);
   12.82 +      test_ci_off(a1, 123);
   12.83 +      test_vi_off(a2, 123, 103);
   12.84 +      test_cp_off(a1, a2);
   12.85 +      test_2ci_off(a1, a2);
   12.86 +      test_2vi_off(a1, a2, 123, 103);
   12.87 +      test_ci_inv(a1, OFFSET, 123);
   12.88 +      test_vi_inv(a2, 123, OFFSET, 103);
   12.89 +      test_cp_inv(a1, a2, OFFSET);
   12.90 +      test_2ci_inv(a1, a2, OFFSET);
   12.91 +      test_2vi_inv(a1, a2, 123, 103, OFFSET);
   12.92 +      test_ci_scl(a1, 123);
   12.93 +      test_vi_scl(a2, 123, 103);
   12.94 +      test_cp_scl(a1, a2);
   12.95 +      test_2ci_scl(a1, a2);
   12.96 +      test_2vi_scl(a1, a2, 123, 103);
   12.97 +      test_cp_alndst(a1, a2);
   12.98 +      test_cp_alnsrc(a1, a2);
   12.99 +      test_2ci_aln(a1, a2);
  12.100 +      test_2vi_aln(a1, a2, 123, 103);
  12.101 +      test_cp_unalndst(a1, a2);
  12.102 +      test_cp_unalnsrc(a1, a2);
  12.103 +      test_2ci_unaln(a1, a2);
  12.104 +      test_2vi_unaln(a1, a2, 123, 103);
  12.105 +    }
  12.106 +    // Initialize
  12.107 +    for (int i=0; i<ARRLEN; i++) {
  12.108 +      a1.set(i, -1);
  12.109 +      a2.set(i, -1);
  12.110 +    }
  12.111 +    // Test and verify results
  12.112 +    System.out.println("Verification");
  12.113 +    int errn = 0;
  12.114 +    {
  12.115 +      test_ci(a1);
  12.116 +      for (int i=0; i<ARRLEN; i++) {
  12.117 +        errn += verify("test_ci: a1", i, a1.get(i), -123);
  12.118 +      }
  12.119 +      test_vi(a2, 123, -1);
  12.120 +      for (int i=0; i<ARRLEN; i++) {
  12.121 +        errn += verify("test_vi: a2", i, a2.get(i), 123);
  12.122 +      }
  12.123 +      test_cp(a1, a2);
  12.124 +      for (int i=0; i<ARRLEN; i++) {
  12.125 +        errn += verify("test_cp: a1", i, a1.get(i), 123);
  12.126 +      }
  12.127 +      test_2ci(a1, a2);
  12.128 +      for (int i=0; i<ARRLEN; i++) {
  12.129 +        errn += verify("test_2ci: a1", i, a1.get(i), -123);
  12.130 +        errn += verify("test_2ci: a2", i, a2.get(i), -103);
  12.131 +      }
  12.132 +      test_2vi(a1, a2, 123, 103);
  12.133 +      for (int i=0; i<ARRLEN; i++) {
  12.134 +        errn += verify("test_2vi: a1", i, a1.get(i), 123);
  12.135 +        errn += verify("test_2vi: a2", i, a2.get(i), 103);
  12.136 +      }
  12.137 +      // Reset for negative stride
  12.138 +      for (int i=0; i<ARRLEN; i++) {
  12.139 +        a1.set(i, -1);
  12.140 +        a2.set(i, -1);
  12.141 +      }
  12.142 +      test_ci_neg(a1, -1);
  12.143 +      for (int i=0; i<ARRLEN; i++) {
  12.144 +        errn += verify("test_ci_neg: a1", i, a1.get(i), -123);
  12.145 +      }
  12.146 +      test_vi_neg(a2, 123, -1);
  12.147 +      for (int i=0; i<ARRLEN; i++) {
  12.148 +        errn += verify("test_vi_neg: a2", i, a2.get(i), 123);
  12.149 +      }
  12.150 +      test_cp_neg(a1, a2);
  12.151 +      for (int i=0; i<ARRLEN; i++) {
  12.152 +        errn += verify("test_cp_neg: a1", i, a1.get(i), 123);
  12.153 +      }
  12.154 +      test_2ci_neg(a1, a2);
  12.155 +      for (int i=0; i<ARRLEN; i++) {
  12.156 +        errn += verify("test_2ci_neg: a1", i, a1.get(i), -123);
  12.157 +        errn += verify("test_2ci_neg: a2", i, a2.get(i), -103);
  12.158 +      }
  12.159 +      test_2vi_neg(a1, a2, 123, 103);
  12.160 +      for (int i=0; i<ARRLEN; i++) {
  12.161 +        errn += verify("test_2vi_neg: a1", i, a1.get(i), 123);
  12.162 +        errn += verify("test_2vi_neg: a2", i, a2.get(i), 103);
  12.163 +      }
  12.164 +      // Reset for opposite stride
  12.165 +      for (int i=0; i<ARRLEN; i++) {
  12.166 +        a1.set(i, -1);
  12.167 +        a2.set(i, -1);
  12.168 +      }
  12.169 +      test_ci_oppos(a1, -1);
  12.170 +      for (int i=0; i<ARRLEN; i++) {
  12.171 +        errn += verify("test_ci_oppos: a1", i, a1.get(i), -123);
  12.172 +      }
  12.173 +      test_vi_oppos(a2, 123, -1);
  12.174 +      for (int i=0; i<ARRLEN; i++) {
  12.175 +        errn += verify("test_vi_oppos: a2", i, a2.get(i), 123);
  12.176 +      }
  12.177 +      test_cp_oppos(a1, a2);
  12.178 +      for (int i=0; i<ARRLEN; i++) {
  12.179 +        errn += verify("test_cp_oppos: a1", i, a1.get(i), 123);
  12.180 +      }
  12.181 +      test_2ci_oppos(a1, a2);
  12.182 +      for (int i=0; i<ARRLEN; i++) {
  12.183 +        errn += verify("test_2ci_oppos: a1", i, a1.get(i), -123);
  12.184 +        errn += verify("test_2ci_oppos: a2", i, a2.get(i), -103);
  12.185 +      }
  12.186 +      test_2vi_oppos(a1, a2, 123, 103);
  12.187 +      for (int i=0; i<ARRLEN; i++) {
  12.188 +        errn += verify("test_2vi_oppos: a1", i, a1.get(i), 123);
  12.189 +        errn += verify("test_2vi_oppos: a2", i, a2.get(i), 103);
  12.190 +      }
  12.191 +      // Reset for indexing with offset
  12.192 +      for (int i=0; i<ARRLEN; i++) {
  12.193 +        a1.set(i, -1);
  12.194 +        a2.set(i, -1);
  12.195 +      }
  12.196 +      test_ci_off(a1, -1);
  12.197 +      for (int i=OFFSET; i<ARRLEN; i++) {
  12.198 +        errn += verify("test_ci_off: a1", i, a1.get(i), -123);
  12.199 +      }
  12.200 +      test_vi_off(a2, 123, -1);
  12.201 +      for (int i=OFFSET; i<ARRLEN; i++) {
  12.202 +        errn += verify("test_vi_off: a2", i, a2.get(i), 123);
  12.203 +      }
  12.204 +      test_cp_off(a1, a2);
  12.205 +      for (int i=OFFSET; i<ARRLEN; i++) {
  12.206 +        errn += verify("test_cp_off: a1", i, a1.get(i), 123);
  12.207 +      }
  12.208 +      test_2ci_off(a1, a2);
  12.209 +      for (int i=OFFSET; i<ARRLEN; i++) {
  12.210 +        errn += verify("test_2ci_off: a1", i, a1.get(i), -123);
  12.211 +        errn += verify("test_2ci_off: a2", i, a2.get(i), -103);
  12.212 +      }
  12.213 +      test_2vi_off(a1, a2, 123, 103);
  12.214 +      for (int i=OFFSET; i<ARRLEN; i++) {
  12.215 +        errn += verify("test_2vi_off: a1", i, a1.get(i), 123);
  12.216 +        errn += verify("test_2vi_off: a2", i, a2.get(i), 103);
  12.217 +      }
  12.218 +      for (int i=0; i<OFFSET; i++) {
  12.219 +        errn += verify("test_2vi_off: a1", i, a1.get(i), -1);
  12.220 +        errn += verify("test_2vi_off: a2", i, a2.get(i), -1);
  12.221 +      }
  12.222 +      // Reset for indexing with invariant offset
  12.223 +      for (int i=0; i<ARRLEN; i++) {
  12.224 +        a1.set(i, -1);
  12.225 +        a2.set(i, -1);
  12.226 +      }
  12.227 +      test_ci_inv(a1, OFFSET, -1);
  12.228 +      for (int i=OFFSET; i<ARRLEN; i++) {
  12.229 +        errn += verify("test_ci_inv: a1", i, a1.get(i), -123);
  12.230 +      }
  12.231 +      test_vi_inv(a2, 123, OFFSET, -1);
  12.232 +      for (int i=OFFSET; i<ARRLEN; i++) {
  12.233 +        errn += verify("test_vi_inv: a2", i, a2.get(i), 123);
  12.234 +      }
  12.235 +      test_cp_inv(a1, a2, OFFSET);
  12.236 +      for (int i=OFFSET; i<ARRLEN; i++) {
  12.237 +        errn += verify("test_cp_inv: a1", i, a1.get(i), 123);
  12.238 +      }
  12.239 +      test_2ci_inv(a1, a2, OFFSET);
  12.240 +      for (int i=OFFSET; i<ARRLEN; i++) {
  12.241 +        errn += verify("test_2ci_inv: a1", i, a1.get(i), -123);
  12.242 +        errn += verify("test_2ci_inv: a2", i, a2.get(i), -103);
  12.243 +      }
  12.244 +      test_2vi_inv(a1, a2, 123, 103, OFFSET);
  12.245 +      for (int i=OFFSET; i<ARRLEN; i++) {
  12.246 +        errn += verify("test_2vi_inv: a1", i, a1.get(i), 123);
  12.247 +        errn += verify("test_2vi_inv: a2", i, a2.get(i), 103);
  12.248 +      }
  12.249 +      for (int i=0; i<OFFSET; i++) {
  12.250 +        errn += verify("test_2vi_inv: a1", i, a1.get(i), -1);
  12.251 +        errn += verify("test_2vi_inv: a2", i, a2.get(i), -1);
  12.252 +      }
  12.253 +      // Reset for indexing with scale
  12.254 +      for (int i=0; i<ARRLEN; i++) {
  12.255 +        a1.set(i, -1);
  12.256 +        a2.set(i, -1);
  12.257 +      }
  12.258 +      test_ci_scl(a1, -1);
  12.259 +      for (int i=0; i<ARRLEN; i++) {
  12.260 +        int val = (i%SCALE != 0) ? -1 : -123;
  12.261 +        errn += verify("test_ci_scl: a1", i, a1.get(i), val);
  12.262 +      }
  12.263 +      test_vi_scl(a2, 123, -1);
  12.264 +      for (int i=0; i<ARRLEN; i++) {
  12.265 +        int val = (i%SCALE != 0) ? -1 : 123;
  12.266 +        errn += verify("test_vi_scl: a2", i, a2.get(i), val);
  12.267 +      }
  12.268 +      test_cp_scl(a1, a2);
  12.269 +      for (int i=0; i<ARRLEN; i++) {
  12.270 +        int val = (i%SCALE != 0) ? -1 : 123;
  12.271 +        errn += verify("test_cp_scl: a1", i, a1.get(i), val);
  12.272 +      }
  12.273 +      test_2ci_scl(a1, a2);
  12.274 +      for (int i=0; i<ARRLEN; i++) {
  12.275 +        if (i%SCALE != 0) {
  12.276 +          errn += verify("test_2ci_scl: a1", i, a1.get(i), -1);
  12.277 +        } else if (i*SCALE < ARRLEN) {
  12.278 +          errn += verify("test_2ci_scl: a1", i*SCALE, a1.get(i*SCALE), -123);
  12.279 +        }
  12.280 +        if (i%SCALE != 0) {
  12.281 +          errn += verify("test_2ci_scl: a2", i, a2.get(i), -1);
  12.282 +        } else if (i*SCALE < ARRLEN) {
  12.283 +          errn += verify("test_2ci_scl: a2", i*SCALE, a2.get(i*SCALE), -103);
  12.284 +        }
  12.285 +      }
  12.286 +      test_2vi_scl(a1, a2, 123, 103);
  12.287 +      for (int i=0; i<ARRLEN; i++) {
  12.288 +        if (i%SCALE != 0) {
  12.289 +          errn += verify("test_2vi_scl: a1", i, a1.get(i), -1);
  12.290 +        } else if (i*SCALE < ARRLEN) {
  12.291 +          errn += verify("test_2vi_scl: a1", i*SCALE, a1.get(i*SCALE), 123);
  12.292 +        }
  12.293 +        if (i%SCALE != 0) {
  12.294 +          errn += verify("test_2vi_scl: a2", i, a2.get(i), -1);
  12.295 +        } else if (i*SCALE < ARRLEN) {
  12.296 +          errn += verify("test_2vi_scl: a2", i*SCALE, a2.get(i*SCALE), 103);
  12.297 +        }
  12.298 +      }
  12.299 +      // Reset for 2 arrays with relative aligned offset
  12.300 +      for (int i=0; i<ARRLEN; i++) {
  12.301 +        a1.set(i, -1);
  12.302 +        a2.set(i, -1);
  12.303 +      }
  12.304 +      test_vi(a2, 123, -1);
  12.305 +      test_cp_alndst(a1, a2);
  12.306 +      for (int i=0; i<ALIGN_OFF; i++) {
  12.307 +        errn += verify("test_cp_alndst: a1", i, a1.get(i), -1);
  12.308 +      }
  12.309 +      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
  12.310 +        errn += verify("test_cp_alndst: a1", i, a1.get(i), 123);
  12.311 +      }
  12.312 +      for (int i=0; i<ALIGN_OFF; i++) {
  12.313 +        a1.set(i, 123);
  12.314 +      }
  12.315 +      test_vi(a2, -123, 123);
  12.316 +      test_cp_alnsrc(a1, a2);
  12.317 +      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
  12.318 +        errn += verify("test_cp_alnsrc: a1", i, a1.get(i), -123);
  12.319 +      }
  12.320 +      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
  12.321 +        errn += verify("test_cp_alnsrc: a1", i, a1.get(i), 123);
  12.322 +      }
  12.323 +      for (int i=0; i<ARRLEN; i++) {
  12.324 +        a1.set(i, -1);
  12.325 +        a2.set(i, -1);
  12.326 +      }
  12.327 +      test_2ci_aln(a1, a2);
  12.328 +      for (int i=0; i<ALIGN_OFF; i++) {
  12.329 +        errn += verify("test_2ci_aln: a1", i, a1.get(i), -1);
  12.330 +      }
  12.331 +      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
  12.332 +        errn += verify("test_2ci_aln: a1", i, a1.get(i), -123);
  12.333 +      }
  12.334 +      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
  12.335 +        errn += verify("test_2ci_aln: a2", i, a2.get(i), -103);
  12.336 +      }
  12.337 +      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
  12.338 +        errn += verify("test_2ci_aln: a2", i, a2.get(i), -1);
  12.339 +      }
  12.340 +      for (int i=0; i<ARRLEN; i++) {
  12.341 +        a1.set(i, -1);
  12.342 +        a2.set(i, -1);
  12.343 +      }
  12.344 +      test_2vi_aln(a1, a2, 123, 103);
  12.345 +      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
  12.346 +        errn += verify("test_2vi_aln: a1", i, a1.get(i), 123);
  12.347 +      }
  12.348 +      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
  12.349 +        errn += verify("test_2vi_aln: a1", i, a1.get(i), -1);
  12.350 +      }
  12.351 +      for (int i=0; i<ALIGN_OFF; i++) {
  12.352 +        errn += verify("test_2vi_aln: a2", i, a2.get(i), -1);
  12.353 +      }
  12.354 +      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
  12.355 +        errn += verify("test_2vi_aln: a2", i, a2.get(i), 103);
  12.356 +      }
  12.357 +
  12.358 +      // Reset for 2 arrays with relative unaligned offset
  12.359 +      for (int i=0; i<ARRLEN; i++) {
  12.360 +        a1.set(i, -1);
  12.361 +        a2.set(i, -1);
  12.362 +      }
  12.363 +      test_vi(a2, 123, -1);
  12.364 +      test_cp_unalndst(a1, a2);
  12.365 +      for (int i=0; i<UNALIGN_OFF; i++) {
  12.366 +        errn += verify("test_cp_unalndst: a1", i, a1.get(i), -1);
  12.367 +      }
  12.368 +      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
  12.369 +        errn += verify("test_cp_unalndst: a1", i, a1.get(i), 123);
  12.370 +      }
  12.371 +      test_vi(a2, -123, 123);
  12.372 +      test_cp_unalnsrc(a1, a2);
  12.373 +      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
  12.374 +        errn += verify("test_cp_unalnsrc: a1", i, a1.get(i), -123);
  12.375 +      }
  12.376 +      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
  12.377 +        errn += verify("test_cp_unalnsrc: a1", i, a1.get(i), 123);
  12.378 +      }
  12.379 +      for (int i=0; i<ARRLEN; i++) {
  12.380 +        a1.set(i, -1);
  12.381 +        a2.set(i, -1);
  12.382 +      }
  12.383 +      test_2ci_unaln(a1, a2);
  12.384 +      for (int i=0; i<UNALIGN_OFF; i++) {
  12.385 +        errn += verify("test_2ci_unaln: a1", i, a1.get(i), -1);
  12.386 +      }
  12.387 +      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
  12.388 +        errn += verify("test_2ci_unaln: a1", i, a1.get(i), -123);
  12.389 +      }
  12.390 +      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
  12.391 +        errn += verify("test_2ci_unaln: a2", i, a2.get(i), -103);
  12.392 +      }
  12.393 +      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
  12.394 +        errn += verify("test_2ci_unaln: a2", i, a2.get(i), -1);
  12.395 +      }
  12.396 +      for (int i=0; i<ARRLEN; i++) {
  12.397 +        a1.set(i, -1);
  12.398 +        a2.set(i, -1);
  12.399 +      }
  12.400 +      test_2vi_unaln(a1, a2, 123, 103);
  12.401 +      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
  12.402 +        errn += verify("test_2vi_unaln: a1", i, a1.get(i), 123);
  12.403 +      }
  12.404 +      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
  12.405 +        errn += verify("test_2vi_unaln: a1", i, a1.get(i), -1);
  12.406 +      }
  12.407 +      for (int i=0; i<UNALIGN_OFF; i++) {
  12.408 +        errn += verify("test_2vi_unaln: a2", i, a2.get(i), -1);
  12.409 +      }
  12.410 +      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
  12.411 +        errn += verify("test_2vi_unaln: a2", i, a2.get(i), 103);
  12.412 +      }
  12.413 +
  12.414 +      // Reset for aligned overlap initialization
  12.415 +      for (int i=0; i<ALIGN_OFF; i++) {
  12.416 +        a1.set(i, i);
  12.417 +      }
  12.418 +      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
  12.419 +        a1.set(i, -1);
  12.420 +      }
  12.421 +      test_cp_alndst(a1, a1);
  12.422 +      for (int i=0; i<ARRLEN; i++) {
  12.423 +        int v = i%ALIGN_OFF;
  12.424 +        errn += verify("test_cp_alndst_overlap: a1", i, a1.get(i), v);
  12.425 +      }
  12.426 +      for (int i=0; i<ALIGN_OFF; i++) {
  12.427 +        a1.set((i+ALIGN_OFF), -1);
  12.428 +      }
  12.429 +      test_cp_alnsrc(a1, a1);
  12.430 +      for (int i=0; i<ALIGN_OFF; i++) {
  12.431 +        errn += verify("test_cp_alnsrc_overlap: a1", i, a1.get(i), -1);
  12.432 +      }
  12.433 +      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
  12.434 +        int v = i%ALIGN_OFF;
  12.435 +        errn += verify("test_cp_alnsrc_overlap: a1", i, a1.get(i), v);
  12.436 +      }
  12.437 +      for (int i=0; i<ARRLEN; i++) {
  12.438 +        a1.set(i, -1);
  12.439 +      }
  12.440 +      test_2ci_aln(a1, a1);
  12.441 +      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
  12.442 +        errn += verify("test_2ci_aln_overlap: a1", i, a1.get(i), -103);
  12.443 +      }
  12.444 +      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
  12.445 +        errn += verify("test_2ci_aln_overlap: a1", i, a1.get(i), -123);
  12.446 +      }
  12.447 +      for (int i=0; i<ARRLEN; i++) {
  12.448 +        a1.set(i, -1);
  12.449 +      }
  12.450 +      test_2vi_aln(a1, a1, 123, 103);
  12.451 +      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
  12.452 +        errn += verify("test_2vi_aln_overlap: a1", i, a1.get(i), 123);
  12.453 +      }
  12.454 +      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
  12.455 +        errn += verify("test_2vi_aln_overlap: a1", i, a1.get(i), 103);
  12.456 +      }
  12.457 +
  12.458 +      // Reset for unaligned overlap initialization
  12.459 +      for (int i=0; i<UNALIGN_OFF; i++) {
  12.460 +        a1.set(i, i);
  12.461 +      }
  12.462 +      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
  12.463 +        a1.set(i, -1);
  12.464 +      }
  12.465 +      test_cp_unalndst(a1, a1);
  12.466 +      for (int i=0; i<ARRLEN; i++) {
  12.467 +        int v = i%UNALIGN_OFF;
  12.468 +        errn += verify("test_cp_unalndst_overlap: a1", i, a1.get(i), v);
  12.469 +      }
  12.470 +      for (int i=0; i<UNALIGN_OFF; i++) {
  12.471 +        a1.set((i+UNALIGN_OFF), -1);
  12.472 +      }
  12.473 +      test_cp_unalnsrc(a1, a1);
  12.474 +      for (int i=0; i<UNALIGN_OFF; i++) {
  12.475 +        errn += verify("test_cp_unalnsrc_overlap: a1", i, a1.get(i), -1);
  12.476 +      }
  12.477 +      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
  12.478 +        int v = i%UNALIGN_OFF;
  12.479 +        errn += verify("test_cp_unalnsrc_overlap: a1", i, a1.get(i), v);
  12.480 +      }
  12.481 +      for (int i=0; i<ARRLEN; i++) {
  12.482 +        a1.set(i, -1);
  12.483 +      }
  12.484 +      test_2ci_unaln(a1, a1);
  12.485 +      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
  12.486 +        errn += verify("test_2ci_unaln_overlap: a1", i, a1.get(i), -103);
  12.487 +      }
  12.488 +      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
  12.489 +        errn += verify("test_2ci_unaln_overlap: a1", i, a1.get(i), -123);
  12.490 +      }
  12.491 +      for (int i=0; i<ARRLEN; i++) {
  12.492 +        a1.set(i, -1);
  12.493 +      }
  12.494 +      test_2vi_unaln(a1, a1, 123, 103);
  12.495 +      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
  12.496 +        errn += verify("test_2vi_unaln_overlap: a1", i, a1.get(i), 123);
  12.497 +      }
  12.498 +      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
  12.499 +        errn += verify("test_2vi_unaln_overlap: a1", i, a1.get(i), 103);
  12.500 +      }
  12.501 +
  12.502 +    }
  12.503 +
  12.504 +    if (errn > 0 || test_only)
  12.505 +      return errn;
  12.506 +
  12.507 +    // Initialize
  12.508 +    for (int i=0; i<ARRLEN; i++) {
  12.509 +      a1.set(i, -1);
  12.510 +      a2.set(i, -1);
  12.511 +    }
  12.512 +    System.out.println("Time");
  12.513 +    long start, end;
  12.514 +    start = System.currentTimeMillis();
  12.515 +    for (int i=0; i<ITERS; i++) {
  12.516 +      test_ci(a1);
  12.517 +    }
  12.518 +    end = System.currentTimeMillis();
  12.519 +    System.out.println("test_ci: " + (end - start));
  12.520 +    start = System.currentTimeMillis();
  12.521 +    for (int i=0; i<ITERS; i++) {
  12.522 +      test_vi(a2, 123, -1);
  12.523 +    }
  12.524 +    end = System.currentTimeMillis();
  12.525 +    System.out.println("test_vi: " + (end - start));
  12.526 +    start = System.currentTimeMillis();
  12.527 +    for (int i=0; i<ITERS; i++) {
  12.528 +      test_cp(a1, a2);
  12.529 +    }
  12.530 +    end = System.currentTimeMillis();
  12.531 +    System.out.println("test_cp: " + (end - start));
  12.532 +    start = System.currentTimeMillis();
  12.533 +    for (int i=0; i<ITERS; i++) {
  12.534 +      test_2ci(a1, a2);
  12.535 +    }
  12.536 +    end = System.currentTimeMillis();
  12.537 +    System.out.println("test_2ci: " + (end - start));
  12.538 +    start = System.currentTimeMillis();
  12.539 +    for (int i=0; i<ITERS; i++) {
  12.540 +      test_2vi(a1, a2, 123, 103);
  12.541 +    }
  12.542 +    end = System.currentTimeMillis();
  12.543 +    System.out.println("test_2vi: " + (end - start));
  12.544 +
  12.545 +    start = System.currentTimeMillis();
  12.546 +    for (int i=0; i<ITERS; i++) {
  12.547 +      test_ci_neg(a1, 123);
  12.548 +    }
  12.549 +    end = System.currentTimeMillis();
  12.550 +    System.out.println("test_ci_neg: " + (end - start));
  12.551 +    start = System.currentTimeMillis();
  12.552 +    for (int i=0; i<ITERS; i++) {
  12.553 +      test_vi_neg(a2, 123, 103);
  12.554 +    }
  12.555 +    end = System.currentTimeMillis();
  12.556 +    System.out.println("test_vi_neg: " + (end - start));
  12.557 +    start = System.currentTimeMillis();
  12.558 +    for (int i=0; i<ITERS; i++) {
  12.559 +      test_cp_neg(a1, a2);
  12.560 +    }
  12.561 +    end = System.currentTimeMillis();
  12.562 +    System.out.println("test_cp_neg: " + (end - start));
  12.563 +    start = System.currentTimeMillis();
  12.564 +    for (int i=0; i<ITERS; i++) {
  12.565 +      test_2ci_neg(a1, a2);
  12.566 +    }
  12.567 +    end = System.currentTimeMillis();
  12.568 +    System.out.println("test_2ci_neg: " + (end - start));
  12.569 +    start = System.currentTimeMillis();
  12.570 +    for (int i=0; i<ITERS; i++) {
  12.571 +      test_2vi_neg(a1, a2, 123, 103);
  12.572 +    }
  12.573 +    end = System.currentTimeMillis();
  12.574 +    System.out.println("test_2vi_neg: " + (end - start));
  12.575 +
  12.576 +    start = System.currentTimeMillis();
  12.577 +    for (int i=0; i<ITERS; i++) {
  12.578 +      test_ci_oppos(a1, 123);
  12.579 +    }
  12.580 +    end = System.currentTimeMillis();
  12.581 +    System.out.println("test_ci_oppos: " + (end - start));
  12.582 +    start = System.currentTimeMillis();
  12.583 +    for (int i=0; i<ITERS; i++) {
  12.584 +      test_vi_oppos(a2, 123, 103);
  12.585 +    }
  12.586 +    end = System.currentTimeMillis();
  12.587 +    System.out.println("test_vi_oppos: " + (end - start));
  12.588 +    start = System.currentTimeMillis();
  12.589 +    for (int i=0; i<ITERS; i++) {
  12.590 +      test_cp_oppos(a1, a2);
  12.591 +    }
  12.592 +    end = System.currentTimeMillis();
  12.593 +    System.out.println("test_cp_oppos: " + (end - start));
  12.594 +    start = System.currentTimeMillis();
  12.595 +    for (int i=0; i<ITERS; i++) {
  12.596 +      test_2ci_oppos(a1, a2);
  12.597 +    }
  12.598 +    end = System.currentTimeMillis();
  12.599 +    System.out.println("test_2ci_oppos: " + (end - start));
  12.600 +    start = System.currentTimeMillis();
  12.601 +    for (int i=0; i<ITERS; i++) {
  12.602 +      test_2vi_oppos(a1, a2, 123, 103);
  12.603 +    }
  12.604 +    end = System.currentTimeMillis();
  12.605 +    System.out.println("test_2vi_oppos: " + (end - start));
  12.606 +
  12.607 +    start = System.currentTimeMillis();
  12.608 +    for (int i=0; i<ITERS; i++) {
  12.609 +      test_ci_off(a1, 123);
  12.610 +    }
  12.611 +    end = System.currentTimeMillis();
  12.612 +    System.out.println("test_ci_off: " + (end - start));
  12.613 +    start = System.currentTimeMillis();
  12.614 +    for (int i=0; i<ITERS; i++) {
  12.615 +      test_vi_off(a2, 123, 103);
  12.616 +    }
  12.617 +    end = System.currentTimeMillis();
  12.618 +    System.out.println("test_vi_off: " + (end - start));
  12.619 +    start = System.currentTimeMillis();
  12.620 +    for (int i=0; i<ITERS; i++) {
  12.621 +      test_cp_off(a1, a2);
  12.622 +    }
  12.623 +    end = System.currentTimeMillis();
  12.624 +    System.out.println("test_cp_off: " + (end - start));
  12.625 +    start = System.currentTimeMillis();
  12.626 +    for (int i=0; i<ITERS; i++) {
  12.627 +      test_2ci_off(a1, a2);
  12.628 +    }
  12.629 +    end = System.currentTimeMillis();
  12.630 +    System.out.println("test_2ci_off: " + (end - start));
  12.631 +    start = System.currentTimeMillis();
  12.632 +    for (int i=0; i<ITERS; i++) {
  12.633 +      test_2vi_off(a1, a2, 123, 103);
  12.634 +    }
  12.635 +    end = System.currentTimeMillis();
  12.636 +    System.out.println("test_2vi_off: " + (end - start));
  12.637 +
  12.638 +    start = System.currentTimeMillis();
  12.639 +    for (int i=0; i<ITERS; i++) {
  12.640 +      test_ci_inv(a1, OFFSET, 123);
  12.641 +    }
  12.642 +    end = System.currentTimeMillis();
  12.643 +    System.out.println("test_ci_inv: " + (end - start));
  12.644 +    start = System.currentTimeMillis();
  12.645 +    for (int i=0; i<ITERS; i++) {
  12.646 +      test_vi_inv(a2, 123, OFFSET, 103);
  12.647 +    }
  12.648 +    end = System.currentTimeMillis();
  12.649 +    System.out.println("test_vi_inv: " + (end - start));
  12.650 +    start = System.currentTimeMillis();
  12.651 +    for (int i=0; i<ITERS; i++) {
  12.652 +      test_cp_inv(a1, a2, OFFSET);
  12.653 +    }
  12.654 +    end = System.currentTimeMillis();
  12.655 +    System.out.println("test_cp_inv: " + (end - start));
  12.656 +    start = System.currentTimeMillis();
  12.657 +    for (int i=0; i<ITERS; i++) {
  12.658 +      test_2ci_inv(a1, a2, OFFSET);
  12.659 +    }
  12.660 +    end = System.currentTimeMillis();
  12.661 +    System.out.println("test_2ci_inv: " + (end - start));
  12.662 +    start = System.currentTimeMillis();
  12.663 +    for (int i=0; i<ITERS; i++) {
  12.664 +      test_2vi_inv(a1, a2, 123, 103, OFFSET);
  12.665 +    }
  12.666 +    end = System.currentTimeMillis();
  12.667 +    System.out.println("test_2vi_inv: " + (end - start));
  12.668 +
  12.669 +    start = System.currentTimeMillis();
  12.670 +    for (int i=0; i<ITERS; i++) {
  12.671 +      test_ci_scl(a1, 123);
  12.672 +    }
  12.673 +    end = System.currentTimeMillis();
  12.674 +    System.out.println("test_ci_scl: " + (end - start));
  12.675 +    start = System.currentTimeMillis();
  12.676 +    for (int i=0; i<ITERS; i++) {
  12.677 +      test_vi_scl(a2, 123, 103);
  12.678 +    }
  12.679 +    end = System.currentTimeMillis();
  12.680 +    System.out.println("test_vi_scl: " + (end - start));
  12.681 +    start = System.currentTimeMillis();
  12.682 +    for (int i=0; i<ITERS; i++) {
  12.683 +      test_cp_scl(a1, a2);
  12.684 +    }
  12.685 +    end = System.currentTimeMillis();
  12.686 +    System.out.println("test_cp_scl: " + (end - start));
  12.687 +    start = System.currentTimeMillis();
  12.688 +    for (int i=0; i<ITERS; i++) {
  12.689 +      test_2ci_scl(a1, a2);
  12.690 +    }
  12.691 +    end = System.currentTimeMillis();
  12.692 +    System.out.println("test_2ci_scl: " + (end - start));
  12.693 +    start = System.currentTimeMillis();
  12.694 +    for (int i=0; i<ITERS; i++) {
  12.695 +      test_2vi_scl(a1, a2, 123, 103);
  12.696 +    }
  12.697 +    end = System.currentTimeMillis();
  12.698 +    System.out.println("test_2vi_scl: " + (end - start));
  12.699 +
  12.700 +    start = System.currentTimeMillis();
  12.701 +    for (int i=0; i<ITERS; i++) {
  12.702 +      test_cp_alndst(a1, a2);
  12.703 +    }
  12.704 +    end = System.currentTimeMillis();
  12.705 +    System.out.println("test_cp_alndst: " + (end - start));
  12.706 +    start = System.currentTimeMillis();
  12.707 +    for (int i=0; i<ITERS; i++) {
  12.708 +      test_cp_alnsrc(a1, a2);
  12.709 +    }
  12.710 +    end = System.currentTimeMillis();
  12.711 +    System.out.println("test_cp_alnsrc: " + (end - start));
  12.712 +    start = System.currentTimeMillis();
  12.713 +    for (int i=0; i<ITERS; i++) {
  12.714 +      test_2ci_aln(a1, a2);
  12.715 +    }
  12.716 +    end = System.currentTimeMillis();
  12.717 +    System.out.println("test_2ci_aln: " + (end - start));
  12.718 +    start = System.currentTimeMillis();
  12.719 +    for (int i=0; i<ITERS; i++) {
  12.720 +      test_2vi_aln(a1, a2, 123, 103);
  12.721 +    }
  12.722 +    end = System.currentTimeMillis();
  12.723 +    System.out.println("test_2vi_aln: " + (end - start));
  12.724 +
  12.725 +    start = System.currentTimeMillis();
  12.726 +    for (int i=0; i<ITERS; i++) {
  12.727 +      test_cp_unalndst(a1, a2);
  12.728 +    }
  12.729 +    end = System.currentTimeMillis();
  12.730 +    System.out.println("test_cp_unalndst: " + (end - start));
  12.731 +    start = System.currentTimeMillis();
  12.732 +    for (int i=0; i<ITERS; i++) {
  12.733 +      test_cp_unalnsrc(a1, a2);
  12.734 +    }
  12.735 +    end = System.currentTimeMillis();
  12.736 +    System.out.println("test_cp_unalnsrc: " + (end - start));
  12.737 +    start = System.currentTimeMillis();
  12.738 +    for (int i=0; i<ITERS; i++) {
  12.739 +      test_2ci_unaln(a1, a2);
  12.740 +    }
  12.741 +    end = System.currentTimeMillis();
  12.742 +    System.out.println("test_2ci_unaln: " + (end - start));
  12.743 +    start = System.currentTimeMillis();
  12.744 +    for (int i=0; i<ITERS; i++) {
  12.745 +      test_2vi_unaln(a1, a2, 123, 103);
  12.746 +    }
  12.747 +    end = System.currentTimeMillis();
  12.748 +    System.out.println("test_2vi_unaln: " + (end - start));
  12.749 +
  12.750 +    return errn;
  12.751 +  }
  12.752 +
  12.753 +  static void test_ci(AtomicIntegerArray a) {
  12.754 +    for (int i = 0; i < ARRLEN; i+=1) {
  12.755 +      a.set(i, -123);
  12.756 +    }
  12.757 +  }
  12.758 +  static void test_vi(AtomicIntegerArray a, int b, int old) {
  12.759 +    for (int i = 0; i < ARRLEN; i+=1) {
  12.760 +      a.set(i, b);
  12.761 +    }
  12.762 +  }
  12.763 +  static void test_cp(AtomicIntegerArray a, AtomicIntegerArray b) {
  12.764 +    for (int i = 0; i < ARRLEN; i+=1) {
  12.765 +      a.set(i, b.get(i));
  12.766 +    }
  12.767 +  }
  12.768 +  static void test_2ci(AtomicIntegerArray a, AtomicIntegerArray b) {
  12.769 +    for (int i = 0; i < ARRLEN; i+=1) {
  12.770 +      a.set(i, -123);
  12.771 +      b.set(i, -103);
  12.772 +    }
  12.773 +  }
  12.774 +  static void test_2vi(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
  12.775 +    for (int i = 0; i < ARRLEN; i+=1) {
  12.776 +      a.set(i, c);
  12.777 +      b.set(i, d);
  12.778 +    }
  12.779 +  }
  12.780 +  static void test_ci_neg(AtomicIntegerArray a, int old) {
  12.781 +    for (int i = ARRLEN-1; i >= 0; i-=1) {
  12.782 +      a.set(i,-123);
  12.783 +    }
  12.784 +  }
  12.785 +  static void test_vi_neg(AtomicIntegerArray a, int b, int old) {
  12.786 +    for (int i = ARRLEN-1; i >= 0; i-=1) {
  12.787 +      a.set(i, b);
  12.788 +    }
  12.789 +  }
  12.790 +  static void test_cp_neg(AtomicIntegerArray a, AtomicIntegerArray b) {
  12.791 +    for (int i = ARRLEN-1; i >= 0; i-=1) {
  12.792 +      a.set(i, b.get(i));
  12.793 +    }
  12.794 +  }
  12.795 +  static void test_2ci_neg(AtomicIntegerArray a, AtomicIntegerArray b) {
  12.796 +    for (int i = ARRLEN-1; i >= 0; i-=1) {
  12.797 +      a.set(i, -123);
  12.798 +      b.set(i, -103);
  12.799 +    }
  12.800 +  }
  12.801 +  static void test_2vi_neg(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
  12.802 +    for (int i = ARRLEN-1; i >= 0; i-=1) {
  12.803 +      a.set(i, c);
  12.804 +      b.set(i, d);
  12.805 +    }
  12.806 +  }
  12.807 +  static void test_ci_oppos(AtomicIntegerArray a, int old) {
  12.808 +    int limit = ARRLEN-1;
  12.809 +    for (int i = 0; i < ARRLEN; i+=1) {
  12.810 +      a.set((limit-i), -123);
  12.811 +    }
  12.812 +  }
  12.813 +  static void test_vi_oppos(AtomicIntegerArray a, int b, int old) {
  12.814 +    int limit = ARRLEN-1;
  12.815 +    for (int i = limit; i >= 0; i-=1) {
  12.816 +      a.set((limit-i), b);
  12.817 +    }
  12.818 +  }
  12.819 +  static void test_cp_oppos(AtomicIntegerArray a, AtomicIntegerArray b) {
  12.820 +    int limit = ARRLEN-1;
  12.821 +    for (int i = 0; i < ARRLEN; i+=1) {
  12.822 +      a.set(i, b.get(limit-i));
  12.823 +    }
  12.824 +  }
  12.825 +  static void test_2ci_oppos(AtomicIntegerArray a, AtomicIntegerArray b) {
  12.826 +    int limit = ARRLEN-1;
  12.827 +    for (int i = 0; i < ARRLEN; i+=1) {
  12.828 +      a.set((limit-i), -123);
  12.829 +      b.set(i, -103);
  12.830 +    }
  12.831 +  }
  12.832 +  static void test_2vi_oppos(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
  12.833 +    int limit = ARRLEN-1;
  12.834 +    for (int i = limit; i >= 0; i-=1) {
  12.835 +      a.set(i, c);
  12.836 +      b.set((limit-i), d);
  12.837 +    }
  12.838 +  }
  12.839 +  static void test_ci_off(AtomicIntegerArray a, int old) {
  12.840 +    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
  12.841 +      a.set((i+OFFSET), -123);
  12.842 +    }
  12.843 +  }
  12.844 +  static void test_vi_off(AtomicIntegerArray a, int b, int old) {
  12.845 +    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
  12.846 +      a.set((i+OFFSET), b);
  12.847 +    }
  12.848 +  }
  12.849 +  static void test_cp_off(AtomicIntegerArray a, AtomicIntegerArray b) {
  12.850 +    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
  12.851 +      a.set((i+OFFSET), b.get(i+OFFSET));
  12.852 +    }
  12.853 +  }
  12.854 +  static void test_2ci_off(AtomicIntegerArray a, AtomicIntegerArray b) {
  12.855 +    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
  12.856 +      a.set((i+OFFSET), -123);
  12.857 +      b.set((i+OFFSET), -103);
  12.858 +    }
  12.859 +  }
  12.860 +  static void test_2vi_off(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
  12.861 +    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
  12.862 +      a.set((i+OFFSET), c);
  12.863 +      b.set((i+OFFSET), d);
  12.864 +    }
  12.865 +  }
  12.866 +  static void test_ci_inv(AtomicIntegerArray a, int k, int old) {
  12.867 +    for (int i = 0; i < ARRLEN-k; i+=1) {
  12.868 +      a.set((i+k),-123);
  12.869 +    }
  12.870 +  }
  12.871 +  static void test_vi_inv(AtomicIntegerArray a, int b, int k, int old) {
  12.872 +    for (int i = 0; i < ARRLEN-k; i+=1) {
  12.873 +      a.set((i+k), b);
  12.874 +    }
  12.875 +  }
  12.876 +  static void test_cp_inv(AtomicIntegerArray a, AtomicIntegerArray b, int k) {
  12.877 +    for (int i = 0; i < ARRLEN-k; i+=1) {
  12.878 +      a.set((i+k), b.get(i+k));
  12.879 +    }
  12.880 +  }
  12.881 +  static void test_2ci_inv(AtomicIntegerArray a, AtomicIntegerArray b, int k) {
  12.882 +    for (int i = 0; i < ARRLEN-k; i+=1) {
  12.883 +      a.set((i+k), -123);
  12.884 +      b.set((i+k), -103);
  12.885 +    }
  12.886 +  }
  12.887 +  static void test_2vi_inv(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d, int k) {
  12.888 +    for (int i = 0; i < ARRLEN-k; i+=1) {
  12.889 +      a.set((i+k), c);
  12.890 +      b.set((i+k), d);
  12.891 +    }
  12.892 +  }
  12.893 +  static void test_ci_scl(AtomicIntegerArray a, int old) {
  12.894 +    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
  12.895 +      a.set((i*SCALE), -123);
  12.896 +    }
  12.897 +  }
  12.898 +  static void test_vi_scl(AtomicIntegerArray a, int b, int old) {
  12.899 +    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
  12.900 +      a.set((i*SCALE), b);
  12.901 +    }
  12.902 +  }
  12.903 +  static void test_cp_scl(AtomicIntegerArray a, AtomicIntegerArray b) {
  12.904 +    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
  12.905 +      a.set((i*SCALE), b.get(i*SCALE));
  12.906 +    }
  12.907 +  }
  12.908 +  static void test_2ci_scl(AtomicIntegerArray a, AtomicIntegerArray b) {
  12.909 +    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
  12.910 +      a.set((i*SCALE), -123);
  12.911 +      b.set((i*SCALE), -103);
  12.912 +    }
  12.913 +  }
  12.914 +  static void test_2vi_scl(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
  12.915 +    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
  12.916 +      a.set((i*SCALE), c);
  12.917 +      b.set((i*SCALE), d);
  12.918 +    }
  12.919 +  }
  12.920 +  static void test_cp_alndst(AtomicIntegerArray a, AtomicIntegerArray b) {
  12.921 +    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
  12.922 +      a.set((i+ALIGN_OFF), b.get(i));
  12.923 +    }
  12.924 +  }
  12.925 +  static void test_cp_alnsrc(AtomicIntegerArray a, AtomicIntegerArray b) {
  12.926 +    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
  12.927 +      a.set(i, b.get(i+ALIGN_OFF));
  12.928 +    }
  12.929 +  }
  12.930 +  static void test_2ci_aln(AtomicIntegerArray a, AtomicIntegerArray b) {
  12.931 +    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
  12.932 +      a.set((i+ALIGN_OFF), -123);
  12.933 +      b.set(i, -103);
  12.934 +    }
  12.935 +  }
  12.936 +  static void test_2vi_aln(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
  12.937 +    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
  12.938 +      a.set(i, c);
  12.939 +      b.set((i+ALIGN_OFF), d);
  12.940 +    }
  12.941 +  }
  12.942 +  static void test_cp_unalndst(AtomicIntegerArray a, AtomicIntegerArray b) {
  12.943 +    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
  12.944 +      a.set((i+UNALIGN_OFF), b.get(i));
  12.945 +    }
  12.946 +  }
  12.947 +  static void test_cp_unalnsrc(AtomicIntegerArray a, AtomicIntegerArray b) {
  12.948 +    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
  12.949 +      a.set(i, b.get(i+UNALIGN_OFF));
  12.950 +    }
  12.951 +  }
  12.952 +  static void test_2ci_unaln(AtomicIntegerArray a, AtomicIntegerArray b) {
  12.953 +    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
  12.954 +      a.set((i+UNALIGN_OFF), -123);
  12.955 +      b.set(i, -103);
  12.956 +    }
  12.957 +  }
  12.958 +  static void test_2vi_unaln(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
  12.959 +    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
  12.960 +      a.set(i, c);
  12.961 +      b.set((i+UNALIGN_OFF), d);
  12.962 +    }
  12.963 +  }
  12.964 +
  12.965 +  static int verify(String text, int i, int elem, int val) {
  12.966 +    if (elem != val) {
  12.967 +      System.err.println(text + "[" + i + "] = " + elem + " != " + val);
  12.968 +      return 1;
  12.969 +    }
  12.970 +    return 0;
  12.971 +  }
  12.972 +}
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/test/compiler/8004867/TestIntUnsafeCAS.java	Thu Feb 21 06:29:43 2013 -0800
    13.3 @@ -0,0 +1,998 @@
    13.4 +/*
    13.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    13.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    13.7 + *
    13.8 + * This code is free software; you can redistribute it and/or modify it
    13.9 + * under the terms of the GNU General Public License version 2 only, as
   13.10 + * published by the Free Software Foundation.
   13.11 + *
   13.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   13.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   13.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   13.15 + * version 2 for more details (a copy is included in the LICENSE file that
   13.16 + * accompanied this code).
   13.17 + *
   13.18 + * You should have received a copy of the GNU General Public License version
   13.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   13.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   13.21 + *
   13.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   13.23 + * or visit www.oracle.com if you need additional information or have any
   13.24 + * questions.
   13.25 + *
   13.26 + */
   13.27 +
   13.28 +/**
   13.29 + * @test
   13.30 + * @bug 8004867
   13.31 + * @summary VM crashing with assert "share/vm/opto/node.hpp:357 - assert(i < _max) failed: oob"
   13.32 + *
   13.33 + * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:-OptimizeFill TestIntUnsafeCAS
   13.34 + * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:+OptimizeFill TestIntUnsafeCAS
   13.35 + */
   13.36 +
   13.37 +import sun.misc.Unsafe;
   13.38 +import java.lang.reflect.*;
   13.39 +
   13.40 +public class TestIntUnsafeCAS {
   13.41 +  private static final int ARRLEN = 97;
   13.42 +  private static final int ITERS  = 11000;
   13.43 +  private static final int OFFSET = 3;
   13.44 +  private static final int SCALE = 2;
   13.45 +  private static final int ALIGN_OFF = 8;
   13.46 +  private static final int UNALIGN_OFF = 5;
   13.47 +
   13.48 +  private static final Unsafe unsafe;
   13.49 +  private static final int BASE;
   13.50 +  static {
   13.51 +    try {
   13.52 +      Class c = TestIntUnsafeCAS.class.getClassLoader().loadClass("sun.misc.Unsafe");
   13.53 +      Field f = c.getDeclaredField("theUnsafe");
   13.54 +      f.setAccessible(true);
   13.55 +      unsafe = (Unsafe)f.get(c);
   13.56 +      BASE = unsafe.arrayBaseOffset(int[].class);
   13.57 +    } catch (Exception e) {
   13.58 +      InternalError err = new InternalError();
   13.59 +      err.initCause(e);
   13.60 +      throw err;
   13.61 +    }
   13.62 +  }
   13.63 +
   13.64 +  public static void main(String args[]) {
   13.65 +    System.out.println("Testing Integer array unsafe CAS operations");
   13.66 +    int errn = test(false);
   13.67 +    if (errn > 0) {
   13.68 +      System.err.println("FAILED: " + errn + " errors");
   13.69 +      System.exit(97);
   13.70 +    }
   13.71 +    System.out.println("PASSED");
   13.72 +  }
   13.73 +
   13.74 +  static int test(boolean test_only) {
   13.75 +    int[] a1 = new int[ARRLEN];
   13.76 +    int[] a2 = new int[ARRLEN];
   13.77 +    // Initialize
   13.78 +    for (int i=0; i<ARRLEN; i++) {
   13.79 +      a1[i] = -1;
   13.80 +      a2[i] = -1;
   13.81 +    }
   13.82 +    System.out.println("Warmup");
   13.83 +    for (int i=0; i<ITERS; i++) {
   13.84 +      test_ci(a1);
   13.85 +      test_vi(a2, 123, -1);
   13.86 +      test_cp(a1, a2);
   13.87 +      test_2ci(a1, a2);
   13.88 +      test_2vi(a1, a2, 123, 103);
   13.89 +      test_ci_neg(a1, 123);
   13.90 +      test_vi_neg(a2, 123, 103);
   13.91 +      test_cp_neg(a1, a2);
   13.92 +      test_2ci_neg(a1, a2);
   13.93 +      test_2vi_neg(a1, a2, 123, 103);
   13.94 +      test_ci_oppos(a1, 123);
   13.95 +      test_vi_oppos(a2, 123, 103);
   13.96 +      test_cp_oppos(a1, a2);
   13.97 +      test_2ci_oppos(a1, a2);
   13.98 +      test_2vi_oppos(a1, a2, 123, 103);
   13.99 +      test_ci_off(a1, 123);
  13.100 +      test_vi_off(a2, 123, 103);
  13.101 +      test_cp_off(a1, a2);
  13.102 +      test_2ci_off(a1, a2);
  13.103 +      test_2vi_off(a1, a2, 123, 103);
  13.104 +      test_ci_inv(a1, OFFSET, 123);
  13.105 +      test_vi_inv(a2, 123, OFFSET, 103);
  13.106 +      test_cp_inv(a1, a2, OFFSET);
  13.107 +      test_2ci_inv(a1, a2, OFFSET);
  13.108 +      test_2vi_inv(a1, a2, 123, 103, OFFSET);
  13.109 +      test_ci_scl(a1, 123);
  13.110 +      test_vi_scl(a2, 123, 103);
  13.111 +      test_cp_scl(a1, a2);
  13.112 +      test_2ci_scl(a1, a2);
  13.113 +      test_2vi_scl(a1, a2, 123, 103);
  13.114 +      test_cp_alndst(a1, a2);
  13.115 +      test_cp_alnsrc(a1, a2);
  13.116 +      test_2ci_aln(a1, a2);
  13.117 +      test_2vi_aln(a1, a2, 123, 103);
  13.118 +      test_cp_unalndst(a1, a2);
  13.119 +      test_cp_unalnsrc(a1, a2);
  13.120 +      test_2ci_unaln(a1, a2);
  13.121 +      test_2vi_unaln(a1, a2, 123, 103);
  13.122 +    }
  13.123 +    // Initialize
  13.124 +    for (int i=0; i<ARRLEN; i++) {
  13.125 +      a1[i] = -1;
  13.126 +      a2[i] = -1;
  13.127 +    }
  13.128 +    // Test and verify results
  13.129 +    System.out.println("Verification");
  13.130 +    int errn = 0;
  13.131 +    {
  13.132 +      test_ci(a1);
  13.133 +      for (int i=0; i<ARRLEN; i++) {
  13.134 +        errn += verify("test_ci: a1", i, a1[i], -123);
  13.135 +      }
  13.136 +      test_vi(a2, 123, -1);
  13.137 +      for (int i=0; i<ARRLEN; i++) {
  13.138 +        errn += verify("test_vi: a2", i, a2[i], 123);
  13.139 +      }
  13.140 +      test_cp(a1, a2);
  13.141 +      for (int i=0; i<ARRLEN; i++) {
  13.142 +        errn += verify("test_cp: a1", i, a1[i], 123);
  13.143 +      }
  13.144 +      test_2ci(a1, a2);
  13.145 +      for (int i=0; i<ARRLEN; i++) {
  13.146 +        errn += verify("test_2ci: a1", i, a1[i], -123);
  13.147 +        errn += verify("test_2ci: a2", i, a2[i], -103);
  13.148 +      }
  13.149 +      test_2vi(a1, a2, 123, 103);
  13.150 +      for (int i=0; i<ARRLEN; i++) {
  13.151 +        errn += verify("test_2vi: a1", i, a1[i], 123);
  13.152 +        errn += verify("test_2vi: a2", i, a2[i], 103);
  13.153 +      }
  13.154 +      // Reset for negative stride
  13.155 +      for (int i=0; i<ARRLEN; i++) {
  13.156 +        a1[i] = -1;
  13.157 +        a2[i] = -1;
  13.158 +      }
  13.159 +      test_ci_neg(a1, -1);
  13.160 +      for (int i=0; i<ARRLEN; i++) {
  13.161 +        errn += verify("test_ci_neg: a1", i, a1[i], -123);
  13.162 +      }
  13.163 +      test_vi_neg(a2, 123, -1);
  13.164 +      for (int i=0; i<ARRLEN; i++) {
  13.165 +        errn += verify("test_vi_neg: a2", i, a2[i], 123);
  13.166 +      }
  13.167 +      test_cp_neg(a1, a2);
  13.168 +      for (int i=0; i<ARRLEN; i++) {
  13.169 +        errn += verify("test_cp_neg: a1", i, a1[i], 123);
  13.170 +      }
  13.171 +      test_2ci_neg(a1, a2);
  13.172 +      for (int i=0; i<ARRLEN; i++) {
  13.173 +        errn += verify("test_2ci_neg: a1", i, a1[i], -123);
  13.174 +        errn += verify("test_2ci_neg: a2", i, a2[i], -103);
  13.175 +      }
  13.176 +      test_2vi_neg(a1, a2, 123, 103);
  13.177 +      for (int i=0; i<ARRLEN; i++) {
  13.178 +        errn += verify("test_2vi_neg: a1", i, a1[i], 123);
  13.179 +        errn += verify("test_2vi_neg: a2", i, a2[i], 103);
  13.180 +      }
  13.181 +      // Reset for opposite stride
  13.182 +      for (int i=0; i<ARRLEN; i++) {
  13.183 +        a1[i] = -1;
  13.184 +        a2[i] = -1;
  13.185 +      }
  13.186 +      test_ci_oppos(a1, -1);
  13.187 +      for (int i=0; i<ARRLEN; i++) {
  13.188 +        errn += verify("test_ci_oppos: a1", i, a1[i], -123);
  13.189 +      }
  13.190 +      test_vi_oppos(a2, 123, -1);
  13.191 +      for (int i=0; i<ARRLEN; i++) {
  13.192 +        errn += verify("test_vi_oppos: a2", i, a2[i], 123);
  13.193 +      }
  13.194 +      test_cp_oppos(a1, a2);
  13.195 +      for (int i=0; i<ARRLEN; i++) {
  13.196 +        errn += verify("test_cp_oppos: a1", i, a1[i], 123);
  13.197 +      }
  13.198 +      test_2ci_oppos(a1, a2);
  13.199 +      for (int i=0; i<ARRLEN; i++) {
  13.200 +        errn += verify("test_2ci_oppos: a1", i, a1[i], -123);
  13.201 +        errn += verify("test_2ci_oppos: a2", i, a2[i], -103);
  13.202 +      }
  13.203 +      test_2vi_oppos(a1, a2, 123, 103);
  13.204 +      for (int i=0; i<ARRLEN; i++) {
  13.205 +        errn += verify("test_2vi_oppos: a1", i, a1[i], 123);
  13.206 +        errn += verify("test_2vi_oppos: a2", i, a2[i], 103);
  13.207 +      }
  13.208 +      // Reset for indexing with offset
  13.209 +      for (int i=0; i<ARRLEN; i++) {
  13.210 +        a1[i] = -1;
  13.211 +        a2[i] = -1;
  13.212 +      }
  13.213 +      test_ci_off(a1, -1);
  13.214 +      for (int i=OFFSET; i<ARRLEN; i++) {
  13.215 +        errn += verify("test_ci_off: a1", i, a1[i], -123);
  13.216 +      }
  13.217 +      test_vi_off(a2, 123, -1);
  13.218 +      for (int i=OFFSET; i<ARRLEN; i++) {
  13.219 +        errn += verify("test_vi_off: a2", i, a2[i], 123);
  13.220 +      }
  13.221 +      test_cp_off(a1, a2);
  13.222 +      for (int i=OFFSET; i<ARRLEN; i++) {
  13.223 +        errn += verify("test_cp_off: a1", i, a1[i], 123);
  13.224 +      }
  13.225 +      test_2ci_off(a1, a2);
  13.226 +      for (int i=OFFSET; i<ARRLEN; i++) {
  13.227 +        errn += verify("test_2ci_off: a1", i, a1[i], -123);
  13.228 +        errn += verify("test_2ci_off: a2", i, a2[i], -103);
  13.229 +      }
  13.230 +      test_2vi_off(a1, a2, 123, 103);
  13.231 +      for (int i=OFFSET; i<ARRLEN; i++) {
  13.232 +        errn += verify("test_2vi_off: a1", i, a1[i], 123);
  13.233 +        errn += verify("test_2vi_off: a2", i, a2[i], 103);
  13.234 +      }
  13.235 +      for (int i=0; i<OFFSET; i++) {
  13.236 +        errn += verify("test_2vi_off: a1", i, a1[i], -1);
  13.237 +        errn += verify("test_2vi_off: a2", i, a2[i], -1);
  13.238 +      }
  13.239 +      // Reset for indexing with invariant offset
  13.240 +      for (int i=0; i<ARRLEN; i++) {
  13.241 +        a1[i] = -1;
  13.242 +        a2[i] = -1;
  13.243 +      }
  13.244 +      test_ci_inv(a1, OFFSET, -1);
  13.245 +      for (int i=OFFSET; i<ARRLEN; i++) {
  13.246 +        errn += verify("test_ci_inv: a1", i, a1[i], -123);
  13.247 +      }
  13.248 +      test_vi_inv(a2, 123, OFFSET, -1);
  13.249 +      for (int i=OFFSET; i<ARRLEN; i++) {
  13.250 +        errn += verify("test_vi_inv: a2", i, a2[i], 123);
  13.251 +      }
  13.252 +      test_cp_inv(a1, a2, OFFSET);
  13.253 +      for (int i=OFFSET; i<ARRLEN; i++) {
  13.254 +        errn += verify("test_cp_inv: a1", i, a1[i], 123);
  13.255 +      }
  13.256 +      test_2ci_inv(a1, a2, OFFSET);
  13.257 +      for (int i=OFFSET; i<ARRLEN; i++) {
  13.258 +        errn += verify("test_2ci_inv: a1", i, a1[i], -123);
  13.259 +        errn += verify("test_2ci_inv: a2", i, a2[i], -103);
  13.260 +      }
  13.261 +      test_2vi_inv(a1, a2, 123, 103, OFFSET);
  13.262 +      for (int i=OFFSET; i<ARRLEN; i++) {
  13.263 +        errn += verify("test_2vi_inv: a1", i, a1[i], 123);
  13.264 +        errn += verify("test_2vi_inv: a2", i, a2[i], 103);
  13.265 +      }
  13.266 +      for (int i=0; i<OFFSET; i++) {
  13.267 +        errn += verify("test_2vi_inv: a1", i, a1[i], -1);
  13.268 +        errn += verify("test_2vi_inv: a2", i, a2[i], -1);
  13.269 +      }
  13.270 +      // Reset for indexing with scale
  13.271 +      for (int i=0; i<ARRLEN; i++) {
  13.272 +        a1[i] = -1;
  13.273 +        a2[i] = -1;
  13.274 +      }
  13.275 +      test_ci_scl(a1, -1);
  13.276 +      for (int i=0; i<ARRLEN; i++) {
  13.277 +        int val = (i%SCALE != 0) ? -1 : -123;
  13.278 +        errn += verify("test_ci_scl: a1", i, a1[i], val);
  13.279 +      }
  13.280 +      test_vi_scl(a2, 123, -1);
  13.281 +      for (int i=0; i<ARRLEN; i++) {
  13.282 +        int val = (i%SCALE != 0) ? -1 : 123;
  13.283 +        errn += verify("test_vi_scl: a2", i, a2[i], val);
  13.284 +      }
  13.285 +      test_cp_scl(a1, a2);
  13.286 +      for (int i=0; i<ARRLEN; i++) {
  13.287 +        int val = (i%SCALE != 0) ? -1 : 123;
  13.288 +        errn += verify("test_cp_scl: a1", i, a1[i], val);
  13.289 +      }
  13.290 +      test_2ci_scl(a1, a2);
  13.291 +      for (int i=0; i<ARRLEN; i++) {
  13.292 +        if (i%SCALE != 0) {
  13.293 +          errn += verify("test_2ci_scl: a1", i, a1[i], -1);
  13.294 +        } else if (i*SCALE < ARRLEN) {
  13.295 +          errn += verify("test_2ci_scl: a1", i*SCALE, a1[i*SCALE], -123);
  13.296 +        }
  13.297 +        if (i%SCALE != 0) {
  13.298 +          errn += verify("test_2ci_scl: a2", i, a2[i], -1);
  13.299 +        } else if (i*SCALE < ARRLEN) {
  13.300 +          errn += verify("test_2ci_scl: a2", i*SCALE, a2[i*SCALE], -103);
  13.301 +        }
  13.302 +      }
  13.303 +      test_2vi_scl(a1, a2, 123, 103);
  13.304 +      for (int i=0; i<ARRLEN; i++) {
  13.305 +        if (i%SCALE != 0) {
  13.306 +          errn += verify("test_2vi_scl: a1", i, a1[i], -1);
  13.307 +        } else if (i*SCALE < ARRLEN) {
  13.308 +          errn += verify("test_2vi_scl: a1", i*SCALE, a1[i*SCALE], 123);
  13.309 +        }
  13.310 +        if (i%SCALE != 0) {
  13.311 +          errn += verify("test_2vi_scl: a2", i, a2[i], -1);
  13.312 +        } else if (i*SCALE < ARRLEN) {
  13.313 +          errn += verify("test_2vi_scl: a2", i*SCALE, a2[i*SCALE], 103);
  13.314 +        }
  13.315 +      }
  13.316 +      // Reset for 2 arrays with relative aligned offset
  13.317 +      for (int i=0; i<ARRLEN; i++) {
  13.318 +        a1[i] = -1;
  13.319 +        a2[i] = -1;
  13.320 +      }
  13.321 +      test_vi(a2, 123, -1);
  13.322 +      test_cp_alndst(a1, a2);
  13.323 +      for (int i=0; i<ALIGN_OFF; i++) {
  13.324 +        errn += verify("test_cp_alndst: a1", i, a1[i], -1);
  13.325 +      }
  13.326 +      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
  13.327 +        errn += verify("test_cp_alndst: a1", i, a1[i], 123);
  13.328 +      }
  13.329 +      for (int i=0; i<ALIGN_OFF; i++) {
  13.330 +        a1[i] = 123;
  13.331 +      }
  13.332 +      test_vi(a2, -123, 123);
  13.333 +      test_cp_alnsrc(a1, a2);
  13.334 +      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
  13.335 +        errn += verify("test_cp_alnsrc: a1", i, a1[i], -123);
  13.336 +      }
  13.337 +      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
  13.338 +        errn += verify("test_cp_alnsrc: a1", i, a1[i], 123);
  13.339 +      }
  13.340 +      for (int i=0; i<ARRLEN; i++) {
  13.341 +        a1[i] = -1;
  13.342 +        a2[i] = -1;
  13.343 +      }
  13.344 +      test_2ci_aln(a1, a2);
  13.345 +      for (int i=0; i<ALIGN_OFF; i++) {
  13.346 +        errn += verify("test_2ci_aln: a1", i, a1[i], -1);
  13.347 +      }
  13.348 +      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
  13.349 +        errn += verify("test_2ci_aln: a1", i, a1[i], -123);
  13.350 +      }
  13.351 +      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
  13.352 +        errn += verify("test_2ci_aln: a2", i, a2[i], -103);
  13.353 +      }
  13.354 +      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
  13.355 +        errn += verify("test_2ci_aln: a2", i, a2[i], -1);
  13.356 +      }
  13.357 +      for (int i=0; i<ARRLEN; i++) {
  13.358 +        a1[i] = -1;
  13.359 +        a2[i] = -1;
  13.360 +      }
  13.361 +      test_2vi_aln(a1, a2, 123, 103);
  13.362 +      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
  13.363 +        errn += verify("test_2vi_aln: a1", i, a1[i], 123);
  13.364 +      }
  13.365 +      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
  13.366 +        errn += verify("test_2vi_aln: a1", i, a1[i], -1);
  13.367 +      }
  13.368 +      for (int i=0; i<ALIGN_OFF; i++) {
  13.369 +        errn += verify("test_2vi_aln: a2", i, a2[i], -1);
  13.370 +      }
  13.371 +      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
  13.372 +        errn += verify("test_2vi_aln: a2", i, a2[i], 103);
  13.373 +      }
  13.374 +
  13.375 +      // Reset for 2 arrays with relative unaligned offset
  13.376 +      for (int i=0; i<ARRLEN; i++) {
  13.377 +        a1[i] = -1;
  13.378 +        a2[i] = -1;
  13.379 +      }
  13.380 +      test_vi(a2, 123, -1);
  13.381 +      test_cp_unalndst(a1, a2);
  13.382 +      for (int i=0; i<UNALIGN_OFF; i++) {
  13.383 +        errn += verify("test_cp_unalndst: a1", i, a1[i], -1);
  13.384 +      }
  13.385 +      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
  13.386 +        errn += verify("test_cp_unalndst: a1", i, a1[i], 123);
  13.387 +      }
  13.388 +      test_vi(a2, -123, 123);
  13.389 +      test_cp_unalnsrc(a1, a2);
  13.390 +      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
  13.391 +        errn += verify("test_cp_unalnsrc: a1", i, a1[i], -123);
  13.392 +      }
  13.393 +      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
  13.394 +        errn += verify("test_cp_unalnsrc: a1", i, a1[i], 123);
  13.395 +      }
  13.396 +      for (int i=0; i<ARRLEN; i++) {
  13.397 +        a1[i] = -1;
  13.398 +        a2[i] = -1;
  13.399 +      }
  13.400 +      test_2ci_unaln(a1, a2);
  13.401 +      for (int i=0; i<UNALIGN_OFF; i++) {
  13.402 +        errn += verify("test_2ci_unaln: a1", i, a1[i], -1);
  13.403 +      }
  13.404 +      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
  13.405 +        errn += verify("test_2ci_unaln: a1", i, a1[i], -123);
  13.406 +      }
  13.407 +      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
  13.408 +        errn += verify("test_2ci_unaln: a2", i, a2[i], -103);
  13.409 +      }
  13.410 +      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
  13.411 +        errn += verify("test_2ci_unaln: a2", i, a2[i], -1);
  13.412 +      }
  13.413 +      for (int i=0; i<ARRLEN; i++) {
  13.414 +        a1[i] = -1;
  13.415 +        a2[i] = -1;
  13.416 +      }
  13.417 +      test_2vi_unaln(a1, a2, 123, 103);
  13.418 +      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
  13.419 +        errn += verify("test_2vi_unaln: a1", i, a1[i], 123);
  13.420 +      }
  13.421 +      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
  13.422 +        errn += verify("test_2vi_unaln: a1", i, a1[i], -1);
  13.423 +      }
  13.424 +      for (int i=0; i<UNALIGN_OFF; i++) {
  13.425 +        errn += verify("test_2vi_unaln: a2", i, a2[i], -1);
  13.426 +      }
  13.427 +      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
  13.428 +        errn += verify("test_2vi_unaln: a2", i, a2[i], 103);
  13.429 +      }
  13.430 +
  13.431 +      // Reset for aligned overlap initialization
  13.432 +      for (int i=0; i<ALIGN_OFF; i++) {
  13.433 +        a1[i] = i;
  13.434 +      }
  13.435 +      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
  13.436 +        a1[i] = -1;
  13.437 +      }
  13.438 +      test_cp_alndst(a1, a1);
  13.439 +      for (int i=0; i<ARRLEN; i++) {
  13.440 +        int v = i%ALIGN_OFF;
  13.441 +        errn += verify("test_cp_alndst_overlap: a1", i, a1[i], v);
  13.442 +      }
  13.443 +      for (int i=0; i<ALIGN_OFF; i++) {
  13.444 +        a1[i+ALIGN_OFF] = -1;
  13.445 +      }
  13.446 +      test_cp_alnsrc(a1, a1);
  13.447 +      for (int i=0; i<ALIGN_OFF; i++) {
  13.448 +        errn += verify("test_cp_alnsrc_overlap: a1", i, a1[i], -1);
  13.449 +      }
  13.450 +      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
  13.451 +        int v = i%ALIGN_OFF;
  13.452 +        errn += verify("test_cp_alnsrc_overlap: a1", i, a1[i], v);
  13.453 +      }
  13.454 +      for (int i=0; i<ARRLEN; i++) {
  13.455 +        a1[i] = -1;
  13.456 +      }
  13.457 +      test_2ci_aln(a1, a1);
  13.458 +      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
  13.459 +        errn += verify("test_2ci_aln_overlap: a1", i, a1[i], -103);
  13.460 +      }
  13.461 +      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
  13.462 +        errn += verify("test_2ci_aln_overlap: a1", i, a1[i], -123);
  13.463 +      }
  13.464 +      for (int i=0; i<ARRLEN; i++) {
  13.465 +        a1[i] = -1;
  13.466 +      }
  13.467 +      test_2vi_aln(a1, a1, 123, 103);
  13.468 +      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
  13.469 +        errn += verify("test_2vi_aln_overlap: a1", i, a1[i], 123);
  13.470 +      }
  13.471 +      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
  13.472 +        errn += verify("test_2vi_aln_overlap: a1", i, a1[i], 103);
  13.473 +      }
  13.474 +
  13.475 +      // Reset for unaligned overlap initialization
  13.476 +      for (int i=0; i<UNALIGN_OFF; i++) {
  13.477 +        a1[i] = i;
  13.478 +      }
  13.479 +      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
  13.480 +        a1[i] = -1;
  13.481 +      }
  13.482 +      test_cp_unalndst(a1, a1);
  13.483 +      for (int i=0; i<ARRLEN; i++) {
  13.484 +        int v = i%UNALIGN_OFF;
  13.485 +        errn += verify("test_cp_unalndst_overlap: a1", i, a1[i], v);
  13.486 +      }
  13.487 +      for (int i=0; i<UNALIGN_OFF; i++) {
  13.488 +        a1[i+UNALIGN_OFF] = -1;
  13.489 +      }
  13.490 +      test_cp_unalnsrc(a1, a1);
  13.491 +      for (int i=0; i<UNALIGN_OFF; i++) {
  13.492 +        errn += verify("test_cp_unalnsrc_overlap: a1", i, a1[i], -1);
  13.493 +      }
  13.494 +      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
  13.495 +        int v = i%UNALIGN_OFF;
  13.496 +        errn += verify("test_cp_unalnsrc_overlap: a1", i, a1[i], v);
  13.497 +      }
  13.498 +      for (int i=0; i<ARRLEN; i++) {
  13.499 +        a1[i] = -1;
  13.500 +      }
  13.501 +      test_2ci_unaln(a1, a1);
  13.502 +      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
  13.503 +        errn += verify("test_2ci_unaln_overlap: a1", i, a1[i], -103);
  13.504 +      }
  13.505 +      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
  13.506 +        errn += verify("test_2ci_unaln_overlap: a1", i, a1[i], -123);
  13.507 +      }
  13.508 +      for (int i=0; i<ARRLEN; i++) {
  13.509 +        a1[i] = -1;
  13.510 +      }
  13.511 +      test_2vi_unaln(a1, a1, 123, 103);
  13.512 +      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
  13.513 +        errn += verify("test_2vi_unaln_overlap: a1", i, a1[i], 123);
  13.514 +      }
  13.515 +      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
  13.516 +        errn += verify("test_2vi_unaln_overlap: a1", i, a1[i], 103);
  13.517 +      }
  13.518 +
  13.519 +    }
  13.520 +
  13.521 +    if (errn > 0 || test_only)
  13.522 +      return errn;
  13.523 +
  13.524 +    // Initialize
  13.525 +    for (int i=0; i<ARRLEN; i++) {
  13.526 +      a1[i] = -1;
  13.527 +      a2[i] = -1;
  13.528 +    }
  13.529 +    System.out.println("Time");
  13.530 +    long start, end;
  13.531 +    start = System.currentTimeMillis();
  13.532 +    for (int i=0; i<ITERS; i++) {
  13.533 +      test_ci(a1);
  13.534 +    }
  13.535 +    end = System.currentTimeMillis();
  13.536 +    System.out.println("test_ci: " + (end - start));
  13.537 +    start = System.currentTimeMillis();
  13.538 +    for (int i=0; i<ITERS; i++) {
  13.539 +      test_vi(a2, 123, -1);
  13.540 +    }
  13.541 +    end = System.currentTimeMillis();
  13.542 +    System.out.println("test_vi: " + (end - start));
  13.543 +    start = System.currentTimeMillis();
  13.544 +    for (int i=0; i<ITERS; i++) {
  13.545 +      test_cp(a1, a2);
  13.546 +    }
  13.547 +    end = System.currentTimeMillis();
  13.548 +    System.out.println("test_cp: " + (end - start));
  13.549 +    start = System.currentTimeMillis();
  13.550 +    for (int i=0; i<ITERS; i++) {
  13.551 +      test_2ci(a1, a2);
  13.552 +    }
  13.553 +    end = System.currentTimeMillis();
  13.554 +    System.out.println("test_2ci: " + (end - start));
  13.555 +    start = System.currentTimeMillis();
  13.556 +    for (int i=0; i<ITERS; i++) {
  13.557 +      test_2vi(a1, a2, 123, 103);
  13.558 +    }
  13.559 +    end = System.currentTimeMillis();
  13.560 +    System.out.println("test_2vi: " + (end - start));
  13.561 +
  13.562 +    start = System.currentTimeMillis();
  13.563 +    for (int i=0; i<ITERS; i++) {
  13.564 +      test_ci_neg(a1, 123);
  13.565 +    }
  13.566 +    end = System.currentTimeMillis();
  13.567 +    System.out.println("test_ci_neg: " + (end - start));
  13.568 +    start = System.currentTimeMillis();
  13.569 +    for (int i=0; i<ITERS; i++) {
  13.570 +      test_vi_neg(a2, 123, 103);
  13.571 +    }
  13.572 +    end = System.currentTimeMillis();
  13.573 +    System.out.println("test_vi_neg: " + (end - start));
  13.574 +    start = System.currentTimeMillis();
  13.575 +    for (int i=0; i<ITERS; i++) {
  13.576 +      test_cp_neg(a1, a2);
  13.577 +    }
  13.578 +    end = System.currentTimeMillis();
  13.579 +    System.out.println("test_cp_neg: " + (end - start));
  13.580 +    start = System.currentTimeMillis();
  13.581 +    for (int i=0; i<ITERS; i++) {
  13.582 +      test_2ci_neg(a1, a2);
  13.583 +    }
  13.584 +    end = System.currentTimeMillis();
  13.585 +    System.out.println("test_2ci_neg: " + (end - start));
  13.586 +    start = System.currentTimeMillis();
  13.587 +    for (int i=0; i<ITERS; i++) {
  13.588 +      test_2vi_neg(a1, a2, 123, 103);
  13.589 +    }
  13.590 +    end = System.currentTimeMillis();
  13.591 +    System.out.println("test_2vi_neg: " + (end - start));
  13.592 +
  13.593 +    start = System.currentTimeMillis();
  13.594 +    for (int i=0; i<ITERS; i++) {
  13.595 +      test_ci_oppos(a1, 123);
  13.596 +    }
  13.597 +    end = System.currentTimeMillis();
  13.598 +    System.out.println("test_ci_oppos: " + (end - start));
  13.599 +    start = System.currentTimeMillis();
  13.600 +    for (int i=0; i<ITERS; i++) {
  13.601 +      test_vi_oppos(a2, 123, 103);
  13.602 +    }
  13.603 +    end = System.currentTimeMillis();
  13.604 +    System.out.println("test_vi_oppos: " + (end - start));
  13.605 +    start = System.currentTimeMillis();
  13.606 +    for (int i=0; i<ITERS; i++) {
  13.607 +      test_cp_oppos(a1, a2);
  13.608 +    }
  13.609 +    end = System.currentTimeMillis();
  13.610 +    System.out.println("test_cp_oppos: " + (end - start));
  13.611 +    start = System.currentTimeMillis();
  13.612 +    for (int i=0; i<ITERS; i++) {
  13.613 +      test_2ci_oppos(a1, a2);
  13.614 +    }
  13.615 +    end = System.currentTimeMillis();
  13.616 +    System.out.println("test_2ci_oppos: " + (end - start));
  13.617 +    start = System.currentTimeMillis();
  13.618 +    for (int i=0; i<ITERS; i++) {
  13.619 +      test_2vi_oppos(a1, a2, 123, 103);
  13.620 +    }
  13.621 +    end = System.currentTimeMillis();
  13.622 +    System.out.println("test_2vi_oppos: " + (end - start));
  13.623 +
  13.624 +    start = System.currentTimeMillis();
  13.625 +    for (int i=0; i<ITERS; i++) {
  13.626 +      test_ci_off(a1, 123);
  13.627 +    }
  13.628 +    end = System.currentTimeMillis();
  13.629 +    System.out.println("test_ci_off: " + (end - start));
  13.630 +    start = System.currentTimeMillis();
  13.631 +    for (int i=0; i<ITERS; i++) {
  13.632 +      test_vi_off(a2, 123, 103);
  13.633 +    }
  13.634 +    end = System.currentTimeMillis();
  13.635 +    System.out.println("test_vi_off: " + (end - start));
  13.636 +    start = System.currentTimeMillis();
  13.637 +    for (int i=0; i<ITERS; i++) {
  13.638 +      test_cp_off(a1, a2);
  13.639 +    }
  13.640 +    end = System.currentTimeMillis();
  13.641 +    System.out.println("test_cp_off: " + (end - start));
  13.642 +    start = System.currentTimeMillis();
  13.643 +    for (int i=0; i<ITERS; i++) {
  13.644 +      test_2ci_off(a1, a2);
  13.645 +    }
  13.646 +    end = System.currentTimeMillis();
  13.647 +    System.out.println("test_2ci_off: " + (end - start));
  13.648 +    start = System.currentTimeMillis();
  13.649 +    for (int i=0; i<ITERS; i++) {
  13.650 +      test_2vi_off(a1, a2, 123, 103);
  13.651 +    }
  13.652 +    end = System.currentTimeMillis();
  13.653 +    System.out.println("test_2vi_off: " + (end - start));
  13.654 +
  13.655 +    start = System.currentTimeMillis();
  13.656 +    for (int i=0; i<ITERS; i++) {
  13.657 +      test_ci_inv(a1, OFFSET, 123);
  13.658 +    }
  13.659 +    end = System.currentTimeMillis();
  13.660 +    System.out.println("test_ci_inv: " + (end - start));
  13.661 +    start = System.currentTimeMillis();
  13.662 +    for (int i=0; i<ITERS; i++) {
  13.663 +      test_vi_inv(a2, 123, OFFSET, 103);
  13.664 +    }
  13.665 +    end = System.currentTimeMillis();
  13.666 +    System.out.println("test_vi_inv: " + (end - start));
  13.667 +    start = System.currentTimeMillis();
  13.668 +    for (int i=0; i<ITERS; i++) {
  13.669 +      test_cp_inv(a1, a2, OFFSET);
  13.670 +    }
  13.671 +    end = System.currentTimeMillis();
  13.672 +    System.out.println("test_cp_inv: " + (end - start));
  13.673 +    start = System.currentTimeMillis();
  13.674 +    for (int i=0; i<ITERS; i++) {
  13.675 +      test_2ci_inv(a1, a2, OFFSET);
  13.676 +    }
  13.677 +    end = System.currentTimeMillis();
  13.678 +    System.out.println("test_2ci_inv: " + (end - start));
  13.679 +    start = System.currentTimeMillis();
  13.680 +    for (int i=0; i<ITERS; i++) {
  13.681 +      test_2vi_inv(a1, a2, 123, 103, OFFSET);
  13.682 +    }
  13.683 +    end = System.currentTimeMillis();
  13.684 +    System.out.println("test_2vi_inv: " + (end - start));
  13.685 +
  13.686 +    start = System.currentTimeMillis();
  13.687 +    for (int i=0; i<ITERS; i++) {
  13.688 +      test_ci_scl(a1, 123);
  13.689 +    }
  13.690 +    end = System.currentTimeMillis();
  13.691 +    System.out.println("test_ci_scl: " + (end - start));
  13.692 +    start = System.currentTimeMillis();
  13.693 +    for (int i=0; i<ITERS; i++) {
  13.694 +      test_vi_scl(a2, 123, 103);
  13.695 +    }
  13.696 +    end = System.currentTimeMillis();
  13.697 +    System.out.println("test_vi_scl: " + (end - start));
  13.698 +    start = System.currentTimeMillis();
  13.699 +    for (int i=0; i<ITERS; i++) {
  13.700 +      test_cp_scl(a1, a2);
  13.701 +    }
  13.702 +    end = System.currentTimeMillis();
  13.703 +    System.out.println("test_cp_scl: " + (end - start));
  13.704 +    start = System.currentTimeMillis();
  13.705 +    for (int i=0; i<ITERS; i++) {
  13.706 +      test_2ci_scl(a1, a2);
  13.707 +    }
  13.708 +    end = System.currentTimeMillis();
  13.709 +    System.out.println("test_2ci_scl: " + (end - start));
  13.710 +    start = System.currentTimeMillis();
  13.711 +    for (int i=0; i<ITERS; i++) {
  13.712 +      test_2vi_scl(a1, a2, 123, 103);
  13.713 +    }
  13.714 +    end = System.currentTimeMillis();
  13.715 +    System.out.println("test_2vi_scl: " + (end - start));
  13.716 +
  13.717 +    start = System.currentTimeMillis();
  13.718 +    for (int i=0; i<ITERS; i++) {
  13.719 +      test_cp_alndst(a1, a2);
  13.720 +    }
  13.721 +    end = System.currentTimeMillis();
  13.722 +    System.out.println("test_cp_alndst: " + (end - start));
  13.723 +    start = System.currentTimeMillis();
  13.724 +    for (int i=0; i<ITERS; i++) {
  13.725 +      test_cp_alnsrc(a1, a2);
  13.726 +    }
  13.727 +    end = System.currentTimeMillis();
  13.728 +    System.out.println("test_cp_alnsrc: " + (end - start));
  13.729 +    start = System.currentTimeMillis();
  13.730 +    for (int i=0; i<ITERS; i++) {
  13.731 +      test_2ci_aln(a1, a2);
  13.732 +    }
  13.733 +    end = System.currentTimeMillis();
  13.734 +    System.out.println("test_2ci_aln: " + (end - start));
  13.735 +    start = System.currentTimeMillis();
  13.736 +    for (int i=0; i<ITERS; i++) {
  13.737 +      test_2vi_aln(a1, a2, 123, 103);
  13.738 +    }
  13.739 +    end = System.currentTimeMillis();
  13.740 +    System.out.println("test_2vi_aln: " + (end - start));
  13.741 +
  13.742 +    start = System.currentTimeMillis();
  13.743 +    for (int i=0; i<ITERS; i++) {
  13.744 +      test_cp_unalndst(a1, a2);
  13.745 +    }
  13.746 +    end = System.currentTimeMillis();
  13.747 +    System.out.println("test_cp_unalndst: " + (end - start));
  13.748 +    start = System.currentTimeMillis();
  13.749 +    for (int i=0; i<ITERS; i++) {
  13.750 +      test_cp_unalnsrc(a1, a2);
  13.751 +    }
  13.752 +    end = System.currentTimeMillis();
  13.753 +    System.out.println("test_cp_unalnsrc: " + (end - start));
  13.754 +    start = System.currentTimeMillis();
  13.755 +    for (int i=0; i<ITERS; i++) {
  13.756 +      test_2ci_unaln(a1, a2);
  13.757 +    }
  13.758 +    end = System.currentTimeMillis();
  13.759 +    System.out.println("test_2ci_unaln: " + (end - start));
  13.760 +    start = System.currentTimeMillis();
  13.761 +    for (int i=0; i<ITERS; i++) {
  13.762 +      test_2vi_unaln(a1, a2, 123, 103);
  13.763 +    }
  13.764 +    end = System.currentTimeMillis();
  13.765 +    System.out.println("test_2vi_unaln: " + (end - start));
  13.766 +
  13.767 +    return errn;
  13.768 +  }
  13.769 +
  13.770 +  private final static long byte_offset(int i) {
  13.771 +    return ((long)i << 2) + BASE;
  13.772 +  }
  13.773 +
  13.774 +  static void test_ci(int[] a) {
  13.775 +    for (int i = 0; i < ARRLEN; i+=1) {
  13.776 +      unsafe.compareAndSwapInt(a, byte_offset(i), -1, -123);
  13.777 +    }
  13.778 +  }
  13.779 +  static void test_vi(int[] a, int b, int old) {
  13.780 +    for (int i = 0; i < ARRLEN; i+=1) {
  13.781 +      unsafe.compareAndSwapInt(a, byte_offset(i), old, b);
  13.782 +    }
  13.783 +  }
  13.784 +  static void test_cp(int[] a, int[] b) {
  13.785 +    for (int i = 0; i < ARRLEN; i+=1) {
  13.786 +      unsafe.compareAndSwapInt(a, byte_offset(i), -123, b[i]);
  13.787 +    }
  13.788 +  }
  13.789 +  static void test_2ci(int[] a, int[] b) {
  13.790 +    for (int i = 0; i < ARRLEN; i+=1) {
  13.791 +      unsafe.compareAndSwapInt(a, byte_offset(i), 123, -123);
  13.792 +      unsafe.compareAndSwapInt(b, byte_offset(i), 123, -103);
  13.793 +    }
  13.794 +  }
  13.795 +  static void test_2vi(int[] a, int[] b, int c, int d) {
  13.796 +    for (int i = 0; i < ARRLEN; i+=1) {
  13.797 +      unsafe.compareAndSwapInt(a, byte_offset(i), -123, c);
  13.798 +      unsafe.compareAndSwapInt(b, byte_offset(i), -103, d);
  13.799 +    }
  13.800 +  }
  13.801 +  static void test_ci_neg(int[] a, int old) {
  13.802 +    for (int i = ARRLEN-1; i >= 0; i-=1) {
  13.803 +      unsafe.compareAndSwapInt(a, byte_offset(i), old, -123);
  13.804 +    }
  13.805 +  }
  13.806 +  static void test_vi_neg(int[] a, int b, int old) {
  13.807 +    for (int i = ARRLEN-1; i >= 0; i-=1) {
  13.808 +      unsafe.compareAndSwapInt(a, byte_offset(i), old, b);
  13.809 +    }
  13.810 +  }
  13.811 +  static void test_cp_neg(int[] a, int[] b) {
  13.812 +    for (int i = ARRLEN-1; i >= 0; i-=1) {
  13.813 +      unsafe.compareAndSwapInt(a, byte_offset(i), -123, b[i]);
  13.814 +    }
  13.815 +  }
  13.816 +  static void test_2ci_neg(int[] a, int[] b) {
  13.817 +    for (int i = ARRLEN-1; i >= 0; i-=1) {
  13.818 +      unsafe.compareAndSwapInt(a, byte_offset(i), 123, -123);
  13.819 +      unsafe.compareAndSwapInt(b, byte_offset(i), 123, -103);
  13.820 +    }
  13.821 +  }
  13.822 +  static void test_2vi_neg(int[] a, int[] b, int c, int d) {
  13.823 +    for (int i = ARRLEN-1; i >= 0; i-=1) {
  13.824 +      unsafe.compareAndSwapInt(a, byte_offset(i), -123, c);
  13.825 +      unsafe.compareAndSwapInt(b, byte_offset(i), -103, d);
  13.826 +    }
  13.827 +  }
  13.828 +  static void test_ci_oppos(int[] a, int old) {
  13.829 +    int limit = ARRLEN-1;
  13.830 +    for (int i = 0; i < ARRLEN; i+=1) {
  13.831 +      unsafe.compareAndSwapInt(a, byte_offset(limit-i), old, -123);
  13.832 +    }
  13.833 +  }
  13.834 +  static void test_vi_oppos(int[] a, int b, int old) {
  13.835 +    int limit = ARRLEN-1;
  13.836 +    for (int i = limit; i >= 0; i-=1) {
  13.837 +      unsafe.compareAndSwapInt(a, byte_offset(limit-i), old, b);
  13.838 +    }
  13.839 +  }
  13.840 +  static void test_cp_oppos(int[] a, int[] b) {
  13.841 +    int limit = ARRLEN-1;
  13.842 +    for (int i = 0; i < ARRLEN; i+=1) {
  13.843 +      unsafe.compareAndSwapInt(a, byte_offset(i), -123, b[limit-i]);
  13.844 +    }
  13.845 +  }
  13.846 +  static void test_2ci_oppos(int[] a, int[] b) {
  13.847 +    int limit = ARRLEN-1;
  13.848 +    for (int i = 0; i < ARRLEN; i+=1) {
  13.849 +      unsafe.compareAndSwapInt(a, byte_offset(limit-i), 123, -123);
  13.850 +      unsafe.compareAndSwapInt(b, byte_offset(i), 123, -103);
  13.851 +    }
  13.852 +  }
  13.853 +  static void test_2vi_oppos(int[] a, int[] b, int c, int d) {
  13.854 +    int limit = ARRLEN-1;
  13.855 +    for (int i = limit; i >= 0; i-=1) {
  13.856 +      unsafe.compareAndSwapInt(a, byte_offset(i), -123, c);
  13.857 +      unsafe.compareAndSwapInt(b, byte_offset(limit-i), -103, d);
  13.858 +    }
  13.859 +  }
  13.860 +  static void test_ci_off(int[] a, int old) {
  13.861 +    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
  13.862 +      unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), old, -123);
  13.863 +    }
  13.864 +  }
  13.865 +  static void test_vi_off(int[] a, int b, int old) {
  13.866 +    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
  13.867 +      unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), old, b);
  13.868 +    }
  13.869 +  }
  13.870 +  static void test_cp_off(int[] a, int[] b) {
  13.871 +    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
  13.872 +      unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), -123, b[i+OFFSET]);
  13.873 +    }
  13.874 +  }
  13.875 +  static void test_2ci_off(int[] a, int[] b) {
  13.876 +    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
  13.877 +      unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), 123, -123);
  13.878 +      unsafe.compareAndSwapInt(b, byte_offset(i+OFFSET), 123, -103);
  13.879 +    }
  13.880 +  }
  13.881 +  static void test_2vi_off(int[] a, int[] b, int c, int d) {
  13.882 +    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
  13.883 +      unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), -123, c);
  13.884 +      unsafe.compareAndSwapInt(b, byte_offset(i+OFFSET), -103, d);
  13.885 +    }
  13.886 +  }
  13.887 +  static void test_ci_inv(int[] a, int k, int old) {
  13.888 +    for (int i = 0; i < ARRLEN-k; i+=1) {
  13.889 +      unsafe.compareAndSwapInt(a, byte_offset(i+k), old, -123);
  13.890 +    }
  13.891 +  }
  13.892 +  static void test_vi_inv(int[] a, int b, int k, int old) {
  13.893 +    for (int i = 0; i < ARRLEN-k; i+=1) {
  13.894 +      unsafe.compareAndSwapInt(a, byte_offset(i+k), old, b);
  13.895 +    }
  13.896 +  }
  13.897 +  static void test_cp_inv(int[] a, int[] b, int k) {
  13.898 +    for (int i = 0; i < ARRLEN-k; i+=1) {
  13.899 +      unsafe.compareAndSwapInt(a, byte_offset(i+k), -123, b[i+k]);
  13.900 +    }
  13.901 +  }
  13.902 +  static void test_2ci_inv(int[] a, int[] b, int k) {
  13.903 +    for (int i = 0; i < ARRLEN-k; i+=1) {
  13.904 +      unsafe.compareAndSwapInt(a, byte_offset(i+k), 123, -123);
  13.905 +      unsafe.compareAndSwapInt(b, byte_offset(i+k), 123, -103);
  13.906 +    }
  13.907 +  }
  13.908 +  static void test_2vi_inv(int[] a, int[] b, int c, int d, int k) {
  13.909 +    for (int i = 0; i < ARRLEN-k; i+=1) {
  13.910 +      unsafe.compareAndSwapInt(a, byte_offset(i+k), -123, c);
  13.911 +      unsafe.compareAndSwapInt(b, byte_offset(i+k), -103, d);
  13.912 +    }
  13.913 +  }
  13.914 +  static void test_ci_scl(int[] a, int old) {
  13.915 +    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
  13.916 +      unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), old, -123);
  13.917 +    }
  13.918 +  }
  13.919 +  static void test_vi_scl(int[] a, int b, int old) {
  13.920 +    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
  13.921 +      unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), old, b);
  13.922 +    }
  13.923 +  }
  13.924 +  static void test_cp_scl(int[] a, int[] b) {
  13.925 +    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
  13.926 +      unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), -123, b[i*SCALE]);
  13.927 +    }
  13.928 +  }
  13.929 +  static void test_2ci_scl(int[] a, int[] b) {
  13.930 +    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
  13.931 +      unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), 123, -123);
  13.932 +      unsafe.compareAndSwapInt(b, byte_offset(i*SCALE), 123, -103);
  13.933 +    }
  13.934 +  }
  13.935 +  static void test_2vi_scl(int[] a, int[] b, int c, int d) {
  13.936 +    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
  13.937 +      unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), -123, c);
  13.938 +      unsafe.compareAndSwapInt(b, byte_offset(i*SCALE), -103, d);
  13.939 +    }
  13.940 +  }
  13.941 +  static void test_cp_alndst(int[] a, int[] b) {
  13.942 +    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
  13.943 +      unsafe.compareAndSwapInt(a, byte_offset(i+ALIGN_OFF), -1, b[i]);
  13.944 +    }
  13.945 +  }
  13.946 +  static void test_cp_alnsrc(int[] a, int[] b) {
  13.947 +    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
  13.948 +      int old = unsafe.getIntVolatile(a, byte_offset(i));
  13.949 +      unsafe.compareAndSwapInt(a, byte_offset(i), old, b[i+ALIGN_OFF]);
  13.950 +    }
  13.951 +  }
  13.952 +  static void test_2ci_aln(int[] a, int[] b) {
  13.953 +    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
  13.954 +      unsafe.compareAndSwapInt(a, byte_offset(i+ALIGN_OFF), -1, -123);
  13.955 +      int old = unsafe.getIntVolatile(b, byte_offset(i));
  13.956 +      unsafe.compareAndSwapInt(b, byte_offset(i), old, -103);
  13.957 +    }
  13.958 +  }
  13.959 +  static void test_2vi_aln(int[] a, int[] b, int c, int d) {
  13.960 +    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
  13.961 +      int old = unsafe.getIntVolatile(a, byte_offset(i));
  13.962 +      unsafe.compareAndSwapInt(a, byte_offset(i), old, c);
  13.963 +      old = unsafe.getIntVolatile(b, byte_offset(i+ALIGN_OFF));
  13.964 +      unsafe.compareAndSwapInt(b, byte_offset(i+ALIGN_OFF), old, d);
  13.965 +    }
  13.966 +  }
  13.967 +  static void test_cp_unalndst(int[] a, int[] b) {
  13.968 +    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
  13.969 +      unsafe.compareAndSwapInt(a, byte_offset(i+UNALIGN_OFF), -1, b[i]);
  13.970 +    }
  13.971 +  }
  13.972 +  static void test_cp_unalnsrc(int[] a, int[] b) {
  13.973 +    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
  13.974 +      int old = unsafe.getIntVolatile(a, byte_offset(i));
  13.975 +      unsafe.compareAndSwapInt(a, byte_offset(i), old, b[i+UNALIGN_OFF]);
  13.976 +    }
  13.977 +  }
  13.978 +  static void test_2ci_unaln(int[] a, int[] b) {
  13.979 +    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
  13.980 +      unsafe.compareAndSwapInt(a, byte_offset(i+UNALIGN_OFF), -1, -123);
  13.981 +      int old = unsafe.getIntVolatile(b, byte_offset(i));
  13.982 +      unsafe.compareAndSwapInt(b, byte_offset(i), old, -103);
  13.983 +    }
  13.984 +  }
  13.985 +  static void test_2vi_unaln(int[] a, int[] b, int c, int d) {
  13.986 +    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
  13.987 +      int old = unsafe.getIntVolatile(a, byte_offset(i));
  13.988 +      unsafe.compareAndSwapInt(a, byte_offset(i), old, c);
  13.989 +      old = unsafe.getIntVolatile(b, byte_offset(i+UNALIGN_OFF));
  13.990 +      unsafe.compareAndSwapInt(b, byte_offset(i+UNALIGN_OFF), old, d);
  13.991 +    }
  13.992 +  }
  13.993 +
  13.994 +  static int verify(String text, int i, int elem, int val) {
  13.995 +    if (elem != val) {
  13.996 +      System.err.println(text + "[" + i + "] = " + elem + " != " + val);
  13.997 +      return 1;
  13.998 +    }
  13.999 +    return 0;
 13.1000 +  }
 13.1001 +}
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/test/compiler/8004867/TestIntUnsafeOrdered.java	Thu Feb 21 06:29:43 2013 -0800
    14.3 @@ -0,0 +1,990 @@
    14.4 +/*
    14.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    14.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    14.7 + *
    14.8 + * This code is free software; you can redistribute it and/or modify it
    14.9 + * under the terms of the GNU General Public License version 2 only, as
   14.10 + * published by the Free Software Foundation.
   14.11 + *
   14.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   14.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   14.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   14.15 + * version 2 for more details (a copy is included in the LICENSE file that
   14.16 + * accompanied this code).
   14.17 + *
   14.18 + * You should have received a copy of the GNU General Public License version
   14.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   14.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   14.21 + *
   14.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   14.23 + * or visit www.oracle.com if you need additional information or have any
   14.24 + * questions.
   14.25 + *
   14.26 + */
   14.27 +
   14.28 +/**
   14.29 + * @test
   14.30 + * @bug 8004867
   14.31 + * @summary VM crashing with assert "share/vm/opto/node.hpp:357 - assert(i < _max) failed: oob"
   14.32 + *
   14.33 + * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:-OptimizeFill TestIntUnsafeOrdered
   14.34 + * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:+OptimizeFill TestIntUnsafeOrdered
   14.35 + */
   14.36 +
   14.37 +import sun.misc.Unsafe;
   14.38 +import java.lang.reflect.*;
   14.39 +
   14.40 +public class TestIntUnsafeOrdered {
   14.41 +  private static final int ARRLEN = 97;
   14.42 +  private static final int ITERS  = 11000;
   14.43 +  private static final int OFFSET = 3;
   14.44 +  private static final int SCALE = 2;
   14.45 +  private static final int ALIGN_OFF = 8;
   14.46 +  private static final int UNALIGN_OFF = 5;
   14.47 +
   14.48 +  private static final Unsafe unsafe;
   14.49 +  private static final int BASE;
   14.50 +  static {
   14.51 +    try {
   14.52 +      Class c = TestIntUnsafeOrdered.class.getClassLoader().loadClass("sun.misc.Unsafe");
   14.53 +      Field f = c.getDeclaredField("theUnsafe");
   14.54 +      f.setAccessible(true);
   14.55 +      unsafe = (Unsafe)f.get(c);
   14.56 +      BASE = unsafe.arrayBaseOffset(int[].class);
   14.57 +    } catch (Exception e) {
   14.58 +      InternalError err = new InternalError();
   14.59 +      err.initCause(e);
   14.60 +      throw err;
   14.61 +    }
   14.62 +  }
   14.63 +
   14.64 +  public static void main(String args[]) {
   14.65 +    System.out.println("Testing Integer array unsafe ordered operations");
   14.66 +    int errn = test(false);
   14.67 +    if (errn > 0) {
   14.68 +      System.err.println("FAILED: " + errn + " errors");
   14.69 +      System.exit(97);
   14.70 +    }
   14.71 +    System.out.println("PASSED");
   14.72 +  }
   14.73 +
   14.74 +  static int test(boolean test_only) {
   14.75 +    int[] a1 = new int[ARRLEN];
   14.76 +    int[] a2 = new int[ARRLEN];
   14.77 +    // Initialize
   14.78 +    for (int i=0; i<ARRLEN; i++) {
   14.79 +      a1[i] = -1;
   14.80 +      a2[i] = -1;
   14.81 +    }
   14.82 +    System.out.println("Warmup");
   14.83 +    for (int i=0; i<ITERS; i++) {
   14.84 +      test_ci(a1);
   14.85 +      test_vi(a2, 123, -1);
   14.86 +      test_cp(a1, a2);
   14.87 +      test_2ci(a1, a2);
   14.88 +      test_2vi(a1, a2, 123, 103);
   14.89 +      test_ci_neg(a1, 123);
   14.90 +      test_vi_neg(a2, 123, 103);
   14.91 +      test_cp_neg(a1, a2);
   14.92 +      test_2ci_neg(a1, a2);
   14.93 +      test_2vi_neg(a1, a2, 123, 103);
   14.94 +      test_ci_oppos(a1, 123);
   14.95 +      test_vi_oppos(a2, 123, 103);
   14.96 +      test_cp_oppos(a1, a2);
   14.97 +      test_2ci_oppos(a1, a2);
   14.98 +      test_2vi_oppos(a1, a2, 123, 103);
   14.99 +      test_ci_off(a1, 123);
  14.100 +      test_vi_off(a2, 123, 103);
  14.101 +      test_cp_off(a1, a2);
  14.102 +      test_2ci_off(a1, a2);
  14.103 +      test_2vi_off(a1, a2, 123, 103);
  14.104 +      test_ci_inv(a1, OFFSET, 123);
  14.105 +      test_vi_inv(a2, 123, OFFSET, 103);
  14.106 +      test_cp_inv(a1, a2, OFFSET);
  14.107 +      test_2ci_inv(a1, a2, OFFSET);
  14.108 +      test_2vi_inv(a1, a2, 123, 103, OFFSET);
  14.109 +      test_ci_scl(a1, 123);
  14.110 +      test_vi_scl(a2, 123, 103);
  14.111 +      test_cp_scl(a1, a2);
  14.112 +      test_2ci_scl(a1, a2);
  14.113 +      test_2vi_scl(a1, a2, 123, 103);
  14.114 +      test_cp_alndst(a1, a2);
  14.115 +      test_cp_alnsrc(a1, a2);
  14.116 +      test_2ci_aln(a1, a2);
  14.117 +      test_2vi_aln(a1, a2, 123, 103);
  14.118 +      test_cp_unalndst(a1, a2);
  14.119 +      test_cp_unalnsrc(a1, a2);
  14.120 +      test_2ci_unaln(a1, a2);
  14.121 +      test_2vi_unaln(a1, a2, 123, 103);
  14.122 +    }
  14.123 +    // Initialize
  14.124 +    for (int i=0; i<ARRLEN; i++) {
  14.125 +      a1[i] = -1;
  14.126 +      a2[i] = -1;
  14.127 +    }
  14.128 +    // Test and verify results
  14.129 +    System.out.println("Verification");
  14.130 +    int errn = 0;
  14.131 +    {
  14.132 +      test_ci(a1);
  14.133 +      for (int i=0; i<ARRLEN; i++) {
  14.134 +        errn += verify("test_ci: a1", i, a1[i], -123);
  14.135 +      }
  14.136 +      test_vi(a2, 123, -1);
  14.137 +      for (int i=0; i<ARRLEN; i++) {
  14.138 +        errn += verify("test_vi: a2", i, a2[i], 123);
  14.139 +      }
  14.140 +      test_cp(a1, a2);
  14.141 +      for (int i=0; i<ARRLEN; i++) {
  14.142 +        errn += verify("test_cp: a1", i, a1[i], 123);
  14.143 +      }
  14.144 +      test_2ci(a1, a2);
  14.145 +      for (int i=0; i<ARRLEN; i++) {
  14.146 +        errn += verify("test_2ci: a1", i, a1[i], -123);
  14.147 +        errn += verify("test_2ci: a2", i, a2[i], -103);
  14.148 +      }
  14.149 +      test_2vi(a1, a2, 123, 103);
  14.150 +      for (int i=0; i<ARRLEN; i++) {
  14.151 +        errn += verify("test_2vi: a1", i, a1[i], 123);
  14.152 +        errn += verify("test_2vi: a2", i, a2[i], 103);
  14.153 +      }
  14.154 +      // Reset for negative stride
  14.155 +      for (int i=0; i<ARRLEN; i++) {
  14.156 +        a1[i] = -1;
  14.157 +        a2[i] = -1;
  14.158 +      }
  14.159 +      test_ci_neg(a1, -1);
  14.160 +      for (int i=0; i<ARRLEN; i++) {
  14.161 +        errn += verify("test_ci_neg: a1", i, a1[i], -123);
  14.162 +      }
  14.163 +      test_vi_neg(a2, 123, -1);
  14.164 +      for (int i=0; i<ARRLEN; i++) {
  14.165 +        errn += verify("test_vi_neg: a2", i, a2[i], 123);
  14.166 +      }
  14.167 +      test_cp_neg(a1, a2);
  14.168 +      for (int i=0; i<ARRLEN; i++) {
  14.169 +        errn += verify("test_cp_neg: a1", i, a1[i], 123);
  14.170 +      }
  14.171 +      test_2ci_neg(a1, a2);
  14.172 +      for (int i=0; i<ARRLEN; i++) {
  14.173 +        errn += verify("test_2ci_neg: a1", i, a1[i], -123);
  14.174 +        errn += verify("test_2ci_neg: a2", i, a2[i], -103);
  14.175 +      }
  14.176 +      test_2vi_neg(a1, a2, 123, 103);
  14.177 +      for (int i=0; i<ARRLEN; i++) {
  14.178 +        errn += verify("test_2vi_neg: a1", i, a1[i], 123);
  14.179 +        errn += verify("test_2vi_neg: a2", i, a2[i], 103);
  14.180 +      }
  14.181 +      // Reset for opposite stride
  14.182 +      for (int i=0; i<ARRLEN; i++) {
  14.183 +        a1[i] = -1;
  14.184 +        a2[i] = -1;
  14.185 +      }
  14.186 +      test_ci_oppos(a1, -1);
  14.187 +      for (int i=0; i<ARRLEN; i++) {
  14.188 +        errn += verify("test_ci_oppos: a1", i, a1[i], -123);
  14.189 +      }
  14.190 +      test_vi_oppos(a2, 123, -1);
  14.191 +      for (int i=0; i<ARRLEN; i++) {
  14.192 +        errn += verify("test_vi_oppos: a2", i, a2[i], 123);
  14.193 +      }
  14.194 +      test_cp_oppos(a1, a2);
  14.195 +      for (int i=0; i<ARRLEN; i++) {
  14.196 +        errn += verify("test_cp_oppos: a1", i, a1[i], 123);
  14.197 +      }
  14.198 +      test_2ci_oppos(a1, a2);
  14.199 +      for (int i=0; i<ARRLEN; i++) {
  14.200 +        errn += verify("test_2ci_oppos: a1", i, a1[i], -123);
  14.201 +        errn += verify("test_2ci_oppos: a2", i, a2[i], -103);
  14.202 +      }
  14.203 +      test_2vi_oppos(a1, a2, 123, 103);
  14.204 +      for (int i=0; i<ARRLEN; i++) {
  14.205 +        errn += verify("test_2vi_oppos: a1", i, a1[i], 123);
  14.206 +        errn += verify("test_2vi_oppos: a2", i, a2[i], 103);
  14.207 +      }
  14.208 +      // Reset for indexing with offset
  14.209 +      for (int i=0; i<ARRLEN; i++) {
  14.210 +        a1[i] = -1;
  14.211 +        a2[i] = -1;
  14.212 +      }
  14.213 +      test_ci_off(a1, -1);
  14.214 +      for (int i=OFFSET; i<ARRLEN; i++) {
  14.215 +        errn += verify("test_ci_off: a1", i, a1[i], -123);
  14.216 +      }
  14.217 +      test_vi_off(a2, 123, -1);
  14.218 +      for (int i=OFFSET; i<ARRLEN; i++) {
  14.219 +        errn += verify("test_vi_off: a2", i, a2[i], 123);
  14.220 +      }
  14.221 +      test_cp_off(a1, a2);
  14.222 +      for (int i=OFFSET; i<ARRLEN; i++) {
  14.223 +        errn += verify("test_cp_off: a1", i, a1[i], 123);
  14.224 +      }
  14.225 +      test_2ci_off(a1, a2);
  14.226 +      for (int i=OFFSET; i<ARRLEN; i++) {
  14.227 +        errn += verify("test_2ci_off: a1", i, a1[i], -123);
  14.228 +        errn += verify("test_2ci_off: a2", i, a2[i], -103);
  14.229 +      }
  14.230 +      test_2vi_off(a1, a2, 123, 103);
  14.231 +      for (int i=OFFSET; i<ARRLEN; i++) {
  14.232 +        errn += verify("test_2vi_off: a1", i, a1[i], 123);
  14.233 +        errn += verify("test_2vi_off: a2", i, a2[i], 103);
  14.234 +      }
  14.235 +      for (int i=0; i<OFFSET; i++) {
  14.236 +        errn += verify("test_2vi_off: a1", i, a1[i], -1);
  14.237 +        errn += verify("test_2vi_off: a2", i, a2[i], -1);
  14.238 +      }
  14.239 +      // Reset for indexing with invariant offset
  14.240 +      for (int i=0; i<ARRLEN; i++) {
  14.241 +        a1[i] = -1;
  14.242 +        a2[i] = -1;
  14.243 +      }
  14.244 +      test_ci_inv(a1, OFFSET, -1);
  14.245 +      for (int i=OFFSET; i<ARRLEN; i++) {
  14.246 +        errn += verify("test_ci_inv: a1", i, a1[i], -123);
  14.247 +      }
  14.248 +      test_vi_inv(a2, 123, OFFSET, -1);
  14.249 +      for (int i=OFFSET; i<ARRLEN; i++) {
  14.250 +        errn += verify("test_vi_inv: a2", i, a2[i], 123);
  14.251 +      }
  14.252 +      test_cp_inv(a1, a2, OFFSET);
  14.253 +      for (int i=OFFSET; i<ARRLEN; i++) {
  14.254 +        errn += verify("test_cp_inv: a1", i, a1[i], 123);
  14.255 +      }
  14.256 +      test_2ci_inv(a1, a2, OFFSET);
  14.257 +      for (int i=OFFSET; i<ARRLEN; i++) {
  14.258 +        errn += verify("test_2ci_inv: a1", i, a1[i], -123);
  14.259 +        errn += verify("test_2ci_inv: a2", i, a2[i], -103);
  14.260 +      }
  14.261 +      test_2vi_inv(a1, a2, 123, 103, OFFSET);
  14.262 +      for (int i=OFFSET; i<ARRLEN; i++) {
  14.263 +        errn += verify("test_2vi_inv: a1", i, a1[i], 123);
  14.264 +        errn += verify("test_2vi_inv: a2", i, a2[i], 103);
  14.265 +      }
  14.266 +      for (int i=0; i<OFFSET; i++) {
  14.267 +        errn += verify("test_2vi_inv: a1", i, a1[i], -1);
  14.268 +        errn += verify("test_2vi_inv: a2", i, a2[i], -1);
  14.269 +      }
  14.270 +      // Reset for indexing with scale
  14.271 +      for (int i=0; i<ARRLEN; i++) {
  14.272 +        a1[i] = -1;
  14.273 +        a2[i] = -1;
  14.274 +      }
  14.275 +      test_ci_scl(a1, -1);
  14.276 +      for (int i=0; i<ARRLEN; i++) {
  14.277 +        int val = (i%SCALE != 0) ? -1 : -123;
  14.278 +        errn += verify("test_ci_scl: a1", i, a1[i], val);
  14.279 +      }
  14.280 +      test_vi_scl(a2, 123, -1);
  14.281 +      for (int i=0; i<ARRLEN; i++) {
  14.282 +        int val = (i%SCALE != 0) ? -1 : 123;
  14.283 +        errn += verify("test_vi_scl: a2", i, a2[i], val);
  14.284 +      }
  14.285 +      test_cp_scl(a1, a2);
  14.286 +      for (int i=0; i<ARRLEN; i++) {
  14.287 +        int val = (i%SCALE != 0) ? -1 : 123;
  14.288 +        errn += verify("test_cp_scl: a1", i, a1[i], val);
  14.289 +      }
  14.290 +      test_2ci_scl(a1, a2);
  14.291 +      for (int i=0; i<ARRLEN; i++) {
  14.292 +        if (i%SCALE != 0) {
  14.293 +          errn += verify("test_2ci_scl: a1", i, a1[i], -1);
  14.294 +        } else if (i*SCALE < ARRLEN) {
  14.295 +          errn += verify("test_2ci_scl: a1", i*SCALE, a1[i*SCALE], -123);
  14.296 +        }
  14.297 +        if (i%SCALE != 0) {
  14.298 +          errn += verify("test_2ci_scl: a2", i, a2[i], -1);
  14.299 +        } else if (i*SCALE < ARRLEN) {
  14.300 +          errn += verify("test_2ci_scl: a2", i*SCALE, a2[i*SCALE], -103);
  14.301 +        }
  14.302 +      }
  14.303 +      test_2vi_scl(a1, a2, 123, 103);
  14.304 +      for (int i=0; i<ARRLEN; i++) {
  14.305 +        if (i%SCALE != 0) {
  14.306 +          errn += verify("test_2vi_scl: a1", i, a1[i], -1);
  14.307 +        } else if (i*SCALE < ARRLEN) {
  14.308 +          errn += verify("test_2vi_scl: a1", i*SCALE, a1[i*SCALE], 123);
  14.309 +        }
  14.310 +        if (i%SCALE != 0) {
  14.311 +          errn += verify("test_2vi_scl: a2", i, a2[i], -1);
  14.312 +        } else if (i*SCALE < ARRLEN) {
  14.313 +          errn += verify("test_2vi_scl: a2", i*SCALE, a2[i*SCALE], 103);
  14.314 +        }
  14.315 +      }
  14.316 +      // Reset for 2 arrays with relative aligned offset
  14.317 +      for (int i=0; i<ARRLEN; i++) {
  14.318 +        a1[i] = -1;
  14.319 +        a2[i] = -1;
  14.320 +      }
  14.321 +      test_vi(a2, 123, -1);
  14.322 +      test_cp_alndst(a1, a2);
  14.323 +      for (int i=0; i<ALIGN_OFF; i++) {
  14.324 +        errn += verify("test_cp_alndst: a1", i, a1[i], -1);
  14.325 +      }
  14.326 +      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
  14.327 +        errn += verify("test_cp_alndst: a1", i, a1[i], 123);
  14.328 +      }
  14.329 +      for (int i=0; i<ALIGN_OFF; i++) {
  14.330 +        a1[i] = 123;
  14.331 +      }
  14.332 +      test_vi(a2, -123, 123);
  14.333 +      test_cp_alnsrc(a1, a2);
  14.334 +      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
  14.335 +        errn += verify("test_cp_alnsrc: a1", i, a1[i], -123);
  14.336 +      }
  14.337 +      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
  14.338 +        errn += verify("test_cp_alnsrc: a1", i, a1[i], 123);
  14.339 +      }
  14.340 +      for (int i=0; i<ARRLEN; i++) {
  14.341 +        a1[i] = -1;
  14.342 +        a2[i] = -1;
  14.343 +      }
  14.344 +      test_2ci_aln(a1, a2);
  14.345 +      for (int i=0; i<ALIGN_OFF; i++) {
  14.346 +        errn += verify("test_2ci_aln: a1", i, a1[i], -1);
  14.347 +      }
  14.348 +      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
  14.349 +        errn += verify("test_2ci_aln: a1", i, a1[i], -123);
  14.350 +      }
  14.351 +      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
  14.352 +        errn += verify("test_2ci_aln: a2", i, a2[i], -103);
  14.353 +      }
  14.354 +      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
  14.355 +        errn += verify("test_2ci_aln: a2", i, a2[i], -1);
  14.356 +      }
  14.357 +      for (int i=0; i<ARRLEN; i++) {
  14.358 +        a1[i] = -1;
  14.359 +        a2[i] = -1;
  14.360 +      }
  14.361 +      test_2vi_aln(a1, a2, 123, 103);
  14.362 +      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
  14.363 +        errn += verify("test_2vi_aln: a1", i, a1[i], 123);
  14.364 +      }
  14.365 +      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
  14.366 +        errn += verify("test_2vi_aln: a1", i, a1[i], -1);
  14.367 +      }
  14.368 +      for (int i=0; i<ALIGN_OFF; i++) {
  14.369 +        errn += verify("test_2vi_aln: a2", i, a2[i], -1);
  14.370 +      }
  14.371 +      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
  14.372 +        errn += verify("test_2vi_aln: a2", i, a2[i], 103);
  14.373 +      }
  14.374 +
  14.375 +      // Reset for 2 arrays with relative unaligned offset
  14.376 +      for (int i=0; i<ARRLEN; i++) {
  14.377 +        a1[i] = -1;
  14.378 +        a2[i] = -1;
  14.379 +      }
  14.380 +      test_vi(a2, 123, -1);
  14.381 +      test_cp_unalndst(a1, a2);
  14.382 +      for (int i=0; i<UNALIGN_OFF; i++) {
  14.383 +        errn += verify("test_cp_unalndst: a1", i, a1[i], -1);
  14.384 +      }
  14.385 +      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
  14.386 +        errn += verify("test_cp_unalndst: a1", i, a1[i], 123);
  14.387 +      }
  14.388 +      test_vi(a2, -123, 123);
  14.389 +      test_cp_unalnsrc(a1, a2);
  14.390 +      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
  14.391 +        errn += verify("test_cp_unalnsrc: a1", i, a1[i], -123);
  14.392 +      }
  14.393 +      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
  14.394 +        errn += verify("test_cp_unalnsrc: a1", i, a1[i], 123);
  14.395 +      }
  14.396 +      for (int i=0; i<ARRLEN; i++) {
  14.397 +        a1[i] = -1;
  14.398 +        a2[i] = -1;
  14.399 +      }
  14.400 +      test_2ci_unaln(a1, a2);
  14.401 +      for (int i=0; i<UNALIGN_OFF; i++) {
  14.402 +        errn += verify("test_2ci_unaln: a1", i, a1[i], -1);
  14.403 +      }
  14.404 +      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
  14.405 +        errn += verify("test_2ci_unaln: a1", i, a1[i], -123);
  14.406 +      }
  14.407 +      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
  14.408 +        errn += verify("test_2ci_unaln: a2", i, a2[i], -103);
  14.409 +      }
  14.410 +      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
  14.411 +        errn += verify("test_2ci_unaln: a2", i, a2[i], -1);
  14.412 +      }
  14.413 +      for (int i=0; i<ARRLEN; i++) {
  14.414 +        a1[i] = -1;
  14.415 +        a2[i] = -1;
  14.416 +      }
  14.417 +      test_2vi_unaln(a1, a2, 123, 103);
  14.418 +      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
  14.419 +        errn += verify("test_2vi_unaln: a1", i, a1[i], 123);
  14.420 +      }
  14.421 +      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
  14.422 +        errn += verify("test_2vi_unaln: a1", i, a1[i], -1);
  14.423 +      }
  14.424 +      for (int i=0; i<UNALIGN_OFF; i++) {
  14.425 +        errn += verify("test_2vi_unaln: a2", i, a2[i], -1);
  14.426 +      }
  14.427 +      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
  14.428 +        errn += verify("test_2vi_unaln: a2", i, a2[i], 103);
  14.429 +      }
  14.430 +
  14.431 +      // Reset for aligned overlap initialization
  14.432 +      for (int i=0; i<ALIGN_OFF; i++) {
  14.433 +        a1[i] = i;
  14.434 +      }
  14.435 +      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
  14.436 +        a1[i] = -1;
  14.437 +      }
  14.438 +      test_cp_alndst(a1, a1);
  14.439 +      for (int i=0; i<ARRLEN; i++) {
  14.440 +        int v = i%ALIGN_OFF;
  14.441 +        errn += verify("test_cp_alndst_overlap: a1", i, a1[i], v);
  14.442 +      }
  14.443 +      for (int i=0; i<ALIGN_OFF; i++) {
  14.444 +        a1[i+ALIGN_OFF] = -1;
  14.445 +      }
  14.446 +      test_cp_alnsrc(a1, a1);
  14.447 +      for (int i=0; i<ALIGN_OFF; i++) {
  14.448 +        errn += verify("test_cp_alnsrc_overlap: a1", i, a1[i], -1);
  14.449 +      }
  14.450 +      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
  14.451 +        int v = i%ALIGN_OFF;
  14.452 +        errn += verify("test_cp_alnsrc_overlap: a1", i, a1[i], v);
  14.453 +      }
  14.454 +      for (int i=0; i<ARRLEN; i++) {
  14.455 +        a1[i] = -1;
  14.456 +      }
  14.457 +      test_2ci_aln(a1, a1);
  14.458 +      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
  14.459 +        errn += verify("test_2ci_aln_overlap: a1", i, a1[i], -103);
  14.460 +      }
  14.461 +      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
  14.462 +        errn += verify("test_2ci_aln_overlap: a1", i, a1[i], -123);
  14.463 +      }
  14.464 +      for (int i=0; i<ARRLEN; i++) {
  14.465 +        a1[i] = -1;
  14.466 +      }
  14.467 +      test_2vi_aln(a1, a1, 123, 103);
  14.468 +      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
  14.469 +        errn += verify("test_2vi_aln_overlap: a1", i, a1[i], 123);
  14.470 +      }
  14.471 +      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
  14.472 +        errn += verify("test_2vi_aln_overlap: a1", i, a1[i], 103);
  14.473 +      }
  14.474 +
  14.475 +      // Reset for unaligned overlap initialization
  14.476 +      for (int i=0; i<UNALIGN_OFF; i++) {
  14.477 +        a1[i] = i;
  14.478 +      }
  14.479 +      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
  14.480 +        a1[i] = -1;
  14.481 +      }
  14.482 +      test_cp_unalndst(a1, a1);
  14.483 +      for (int i=0; i<ARRLEN; i++) {
  14.484 +        int v = i%UNALIGN_OFF;
  14.485 +        errn += verify("test_cp_unalndst_overlap: a1", i, a1[i], v);
  14.486 +      }
  14.487 +      for (int i=0; i<UNALIGN_OFF; i++) {
  14.488 +        a1[i+UNALIGN_OFF] = -1;
  14.489 +      }
  14.490 +      test_cp_unalnsrc(a1, a1);
  14.491 +      for (int i=0; i<UNALIGN_OFF; i++) {
  14.492 +        errn += verify("test_cp_unalnsrc_overlap: a1", i, a1[i], -1);
  14.493 +      }
  14.494 +      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
  14.495 +        int v = i%UNALIGN_OFF;
  14.496 +        errn += verify("test_cp_unalnsrc_overlap: a1", i, a1[i], v);
  14.497 +      }
  14.498 +      for (int i=0; i<ARRLEN; i++) {
  14.499 +        a1[i] = -1;
  14.500 +      }
  14.501 +      test_2ci_unaln(a1, a1);
  14.502 +      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
  14.503 +        errn += verify("test_2ci_unaln_overlap: a1", i, a1[i], -103);
  14.504 +      }
  14.505 +      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
  14.506 +        errn += verify("test_2ci_unaln_overlap: a1", i, a1[i], -123);
  14.507 +      }
  14.508 +      for (int i=0; i<ARRLEN; i++) {
  14.509 +        a1[i] = -1;
  14.510 +      }
  14.511 +      test_2vi_unaln(a1, a1, 123, 103);
  14.512 +      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
  14.513 +        errn += verify("test_2vi_unaln_overlap: a1", i, a1[i], 123);
  14.514 +      }
  14.515 +      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
  14.516 +        errn += verify("test_2vi_unaln_overlap: a1", i, a1[i], 103);
  14.517 +      }
  14.518 +
  14.519 +    }
  14.520 +
  14.521 +    if (errn > 0 || test_only)
  14.522 +      return errn;
  14.523 +
  14.524 +    // Initialize
  14.525 +    for (int i=0; i<ARRLEN; i++) {
  14.526 +      a1[i] = -1;
  14.527 +      a2[i] = -1;
  14.528 +    }
  14.529 +    System.out.println("Time");
  14.530 +    long start, end;
  14.531 +    start = System.currentTimeMillis();
  14.532 +    for (int i=0; i<ITERS; i++) {
  14.533 +      test_ci(a1);
  14.534 +    }
  14.535 +    end = System.currentTimeMillis();
  14.536 +    System.out.println("test_ci: " + (end - start));
  14.537 +    start = System.currentTimeMillis();
  14.538 +    for (int i=0; i<ITERS; i++) {
  14.539 +      test_vi(a2, 123, -1);
  14.540 +    }
  14.541 +    end = System.currentTimeMillis();
  14.542 +    System.out.println("test_vi: " + (end - start));
  14.543 +    start = System.currentTimeMillis();
  14.544 +    for (int i=0; i<ITERS; i++) {
  14.545 +      test_cp(a1, a2);
  14.546 +    }
  14.547 +    end = System.currentTimeMillis();
  14.548 +    System.out.println("test_cp: " + (end - start));
  14.549 +    start = System.currentTimeMillis();
  14.550 +    for (int i=0; i<ITERS; i++) {
  14.551 +      test_2ci(a1, a2);
  14.552 +    }
  14.553 +    end = System.currentTimeMillis();
  14.554 +    System.out.println("test_2ci: " + (end - start));
  14.555 +    start = System.currentTimeMillis();
  14.556 +    for (int i=0; i<ITERS; i++) {
  14.557 +      test_2vi(a1, a2, 123, 103);
  14.558 +    }
  14.559 +    end = System.currentTimeMillis();
  14.560 +    System.out.println("test_2vi: " + (end - start));
  14.561 +
  14.562 +    start = System.currentTimeMillis();
  14.563 +    for (int i=0; i<ITERS; i++) {
  14.564 +      test_ci_neg(a1, 123);
  14.565 +    }
  14.566 +    end = System.currentTimeMillis();
  14.567 +    System.out.println("test_ci_neg: " + (end - start));
  14.568 +    start = System.currentTimeMillis();
  14.569 +    for (int i=0; i<ITERS; i++) {
  14.570 +      test_vi_neg(a2, 123, 103);
  14.571 +    }
  14.572 +    end = System.currentTimeMillis();
  14.573 +    System.out.println("test_vi_neg: " + (end - start));
  14.574 +    start = System.currentTimeMillis();
  14.575 +    for (int i=0; i<ITERS; i++) {
  14.576 +      test_cp_neg(a1, a2);
  14.577 +    }
  14.578 +    end = System.currentTimeMillis();
  14.579 +    System.out.println("test_cp_neg: " + (end - start));
  14.580 +    start = System.currentTimeMillis();
  14.581 +    for (int i=0; i<ITERS; i++) {
  14.582 +      test_2ci_neg(a1, a2);
  14.583 +    }
  14.584 +    end = System.currentTimeMillis();
  14.585 +    System.out.println("test_2ci_neg: " + (end - start));
  14.586 +    start = System.currentTimeMillis();
  14.587 +    for (int i=0; i<ITERS; i++) {
  14.588 +      test_2vi_neg(a1, a2, 123, 103);
  14.589 +    }
  14.590 +    end = System.currentTimeMillis();
  14.591 +    System.out.println("test_2vi_neg: " + (end - start));
  14.592 +
  14.593 +    start = System.currentTimeMillis();
  14.594 +    for (int i=0; i<ITERS; i++) {
  14.595 +      test_ci_oppos(a1, 123);
  14.596 +    }
  14.597 +    end = System.currentTimeMillis();
  14.598 +    System.out.println("test_ci_oppos: " + (end - start));
  14.599 +    start = System.currentTimeMillis();
  14.600 +    for (int i=0; i<ITERS; i++) {
  14.601 +      test_vi_oppos(a2, 123, 103);
  14.602 +    }
  14.603 +    end = System.currentTimeMillis();
  14.604 +    System.out.println("test_vi_oppos: " + (end - start));
  14.605 +    start = System.currentTimeMillis();
  14.606 +    for (int i=0; i<ITERS; i++) {
  14.607 +      test_cp_oppos(a1, a2);
  14.608 +    }
  14.609 +    end = System.currentTimeMillis();
  14.610 +    System.out.println("test_cp_oppos: " + (end - start));
  14.611 +    start = System.currentTimeMillis();
  14.612 +    for (int i=0; i<ITERS; i++) {
  14.613 +      test_2ci_oppos(a1, a2);
  14.614 +    }
  14.615 +    end = System.currentTimeMillis();
  14.616 +    System.out.println("test_2ci_oppos: " + (end - start));
  14.617 +    start = System.currentTimeMillis();
  14.618 +    for (int i=0; i<ITERS; i++) {
  14.619 +      test_2vi_oppos(a1, a2, 123, 103);
  14.620 +    }
  14.621 +    end = System.currentTimeMillis();
  14.622 +    System.out.println("test_2vi_oppos: " + (end - start));
  14.623 +
  14.624 +    start = System.currentTimeMillis();
  14.625 +    for (int i=0; i<ITERS; i++) {
  14.626 +      test_ci_off(a1, 123);
  14.627 +    }
  14.628 +    end = System.currentTimeMillis();
  14.629 +    System.out.println("test_ci_off: " + (end - start));
  14.630 +    start = System.currentTimeMillis();
  14.631 +    for (int i=0; i<ITERS; i++) {
  14.632 +      test_vi_off(a2, 123, 103);
  14.633 +    }
  14.634 +    end = System.currentTimeMillis();
  14.635 +    System.out.println("test_vi_off: " + (end - start));
  14.636 +    start = System.currentTimeMillis();
  14.637 +    for (int i=0; i<ITERS; i++) {
  14.638 +      test_cp_off(a1, a2);
  14.639 +    }
  14.640 +    end = System.currentTimeMillis();
  14.641 +    System.out.println("test_cp_off: " + (end - start));
  14.642 +    start = System.currentTimeMillis();
  14.643 +    for (int i=0; i<ITERS; i++) {
  14.644 +      test_2ci_off(a1, a2);
  14.645 +    }
  14.646 +    end = System.currentTimeMillis();
  14.647 +    System.out.println("test_2ci_off: " + (end - start));
  14.648 +    start = System.currentTimeMillis();
  14.649 +    for (int i=0; i<ITERS; i++) {
  14.650 +      test_2vi_off(a1, a2, 123, 103);
  14.651 +    }
  14.652 +    end = System.currentTimeMillis();
  14.653 +    System.out.println("test_2vi_off: " + (end - start));
  14.654 +
  14.655 +    start = System.currentTimeMillis();
  14.656 +    for (int i=0; i<ITERS; i++) {
  14.657 +      test_ci_inv(a1, OFFSET, 123);
  14.658 +    }
  14.659 +    end = System.currentTimeMillis();
  14.660 +    System.out.println("test_ci_inv: " + (end - start));
  14.661 +    start = System.currentTimeMillis();
  14.662 +    for (int i=0; i<ITERS; i++) {
  14.663 +      test_vi_inv(a2, 123, OFFSET, 103);
  14.664 +    }
  14.665 +    end = System.currentTimeMillis();
  14.666 +    System.out.println("test_vi_inv: " + (end - start));
  14.667 +    start = System.currentTimeMillis();
  14.668 +    for (int i=0; i<ITERS; i++) {
  14.669 +      test_cp_inv(a1, a2, OFFSET);
  14.670 +    }
  14.671 +    end = System.currentTimeMillis();
  14.672 +    System.out.println("test_cp_inv: " + (end - start));
  14.673 +    start = System.currentTimeMillis();
  14.674 +    for (int i=0; i<ITERS; i++) {
  14.675 +      test_2ci_inv(a1, a2, OFFSET);
  14.676 +    }
  14.677 +    end = System.currentTimeMillis();
  14.678 +    System.out.println("test_2ci_inv: " + (end - start));
  14.679 +    start = System.currentTimeMillis();
  14.680 +    for (int i=0; i<ITERS; i++) {
  14.681 +      test_2vi_inv(a1, a2, 123, 103, OFFSET);
  14.682 +    }
  14.683 +    end = System.currentTimeMillis();
  14.684 +    System.out.println("test_2vi_inv: " + (end - start));
  14.685 +
  14.686 +    start = System.currentTimeMillis();
  14.687 +    for (int i=0; i<ITERS; i++) {
  14.688 +      test_ci_scl(a1, 123);
  14.689 +    }
  14.690 +    end = System.currentTimeMillis();
  14.691 +    System.out.println("test_ci_scl: " + (end - start));
  14.692 +    start = System.currentTimeMillis();
  14.693 +    for (int i=0; i<ITERS; i++) {
  14.694 +      test_vi_scl(a2, 123, 103);
  14.695 +    }
  14.696 +    end = System.currentTimeMillis();
  14.697 +    System.out.println("test_vi_scl: " + (end - start));
  14.698 +    start = System.currentTimeMillis();
  14.699 +    for (int i=0; i<ITERS; i++) {
  14.700 +      test_cp_scl(a1, a2);
  14.701 +    }
  14.702 +    end = System.currentTimeMillis();
  14.703 +    System.out.println("test_cp_scl: " + (end - start));
  14.704 +    start = System.currentTimeMillis();
  14.705 +    for (int i=0; i<ITERS; i++) {
  14.706 +      test_2ci_scl(a1, a2);
  14.707 +    }
  14.708 +    end = System.currentTimeMillis();
  14.709 +    System.out.println("test_2ci_scl: " + (end - start));
  14.710 +    start = System.currentTimeMillis();
  14.711 +    for (int i=0; i<ITERS; i++) {
  14.712 +      test_2vi_scl(a1, a2, 123, 103);
  14.713 +    }
  14.714 +    end = System.currentTimeMillis();
  14.715 +    System.out.println("test_2vi_scl: " + (end - start));
  14.716 +
  14.717 +    start = System.currentTimeMillis();
  14.718 +    for (int i=0; i<ITERS; i++) {
  14.719 +      test_cp_alndst(a1, a2);
  14.720 +    }
  14.721 +    end = System.currentTimeMillis();
  14.722 +    System.out.println("test_cp_alndst: " + (end - start));
  14.723 +    start = System.currentTimeMillis();
  14.724 +    for (int i=0; i<ITERS; i++) {
  14.725 +      test_cp_alnsrc(a1, a2);
  14.726 +    }
  14.727 +    end = System.currentTimeMillis();
  14.728 +    System.out.println("test_cp_alnsrc: " + (end - start));
  14.729 +    start = System.currentTimeMillis();
  14.730 +    for (int i=0; i<ITERS; i++) {
  14.731 +      test_2ci_aln(a1, a2);
  14.732 +    }
  14.733 +    end = System.currentTimeMillis();
  14.734 +    System.out.println("test_2ci_aln: " + (end - start));
  14.735 +    start = System.currentTimeMillis();
  14.736 +    for (int i=0; i<ITERS; i++) {
  14.737 +      test_2vi_aln(a1, a2, 123, 103);
  14.738 +    }
  14.739 +    end = System.currentTimeMillis();
  14.740 +    System.out.println("test_2vi_aln: " + (end - start));
  14.741 +
  14.742 +    start = System.currentTimeMillis();
  14.743 +    for (int i=0; i<ITERS; i++) {
  14.744 +      test_cp_unalndst(a1, a2);
  14.745 +    }
  14.746 +    end = System.currentTimeMillis();
  14.747 +    System.out.println("test_cp_unalndst: " + (end - start));
  14.748 +    start = System.currentTimeMillis();
  14.749 +    for (int i=0; i<ITERS; i++) {
  14.750 +      test_cp_unalnsrc(a1, a2);
  14.751 +    }
  14.752 +    end = System.currentTimeMillis();
  14.753 +    System.out.println("test_cp_unalnsrc: " + (end - start));
  14.754 +    start = System.currentTimeMillis();
  14.755 +    for (int i=0; i<ITERS; i++) {
  14.756 +      test_2ci_unaln(a1, a2);
  14.757 +    }
  14.758 +    end = System.currentTimeMillis();
  14.759 +    System.out.println("test_2ci_unaln: " + (end - start));
  14.760 +    start = System.currentTimeMillis();
  14.761 +    for (int i=0; i<ITERS; i++) {
  14.762 +      test_2vi_unaln(a1, a2, 123, 103);
  14.763 +    }
  14.764 +    end = System.currentTimeMillis();
  14.765 +    System.out.println("test_2vi_unaln: " + (end - start));
  14.766 +
  14.767 +    return errn;
  14.768 +  }
  14.769 +
  14.770 +  private final static long byte_offset(int i) {
  14.771 +    return ((long)i << 2) + BASE;
  14.772 +  }
  14.773 +
  14.774 +  static void test_ci(int[] a) {
  14.775 +    for (int i = 0; i < ARRLEN; i+=1) {
  14.776 +      unsafe.putOrderedInt(a, byte_offset(i), -123);
  14.777 +    }
  14.778 +  }
  14.779 +  static void test_vi(int[] a, int b, int old) {
  14.780 +    for (int i = 0; i < ARRLEN; i+=1) {
  14.781 +      unsafe.putOrderedInt(a, byte_offset(i), b);
  14.782 +    }
  14.783 +  }
  14.784 +  static void test_cp(int[] a, int[] b) {
  14.785 +    for (int i = 0; i < ARRLEN; i+=1) {
  14.786 +      unsafe.putOrderedInt(a, byte_offset(i), b[i]);
  14.787 +    }
  14.788 +  }
  14.789 +  static void test_2ci(int[] a, int[] b) {
  14.790 +    for (int i = 0; i < ARRLEN; i+=1) {
  14.791 +      unsafe.putOrderedInt(a, byte_offset(i), -123);
  14.792 +      unsafe.putOrderedInt(b, byte_offset(i), -103);
  14.793 +    }
  14.794 +  }
  14.795 +  static void test_2vi(int[] a, int[] b, int c, int d) {
  14.796 +    for (int i = 0; i < ARRLEN; i+=1) {
  14.797 +      unsafe.putOrderedInt(a, byte_offset(i), c);
  14.798 +      unsafe.putOrderedInt(b, byte_offset(i), d);
  14.799 +    }
  14.800 +  }
  14.801 +  static void test_ci_neg(int[] a, int old) {
  14.802 +    for (int i = ARRLEN-1; i >= 0; i-=1) {
  14.803 +      unsafe.putOrderedInt(a, byte_offset(i), -123);
  14.804 +    }
  14.805 +  }
  14.806 +  static void test_vi_neg(int[] a, int b, int old) {
  14.807 +    for (int i = ARRLEN-1; i >= 0; i-=1) {
  14.808 +      unsafe.putOrderedInt(a, byte_offset(i), b);
  14.809 +    }
  14.810 +  }
  14.811 +  static void test_cp_neg(int[] a, int[] b) {
  14.812 +    for (int i = ARRLEN-1; i >= 0; i-=1) {
  14.813 +      unsafe.putOrderedInt(a, byte_offset(i), b[i]);
  14.814 +    }
  14.815 +  }
  14.816 +  static void test_2ci_neg(int[] a, int[] b) {
  14.817 +    for (int i = ARRLEN-1; i >= 0; i-=1) {
  14.818 +      unsafe.putOrderedInt(a, byte_offset(i), -123);
  14.819 +      unsafe.putOrderedInt(b, byte_offset(i), -103);
  14.820 +    }
  14.821 +  }
  14.822 +  static void test_2vi_neg(int[] a, int[] b, int c, int d) {
  14.823 +    for (int i = ARRLEN-1; i >= 0; i-=1) {
  14.824 +      unsafe.putOrderedInt(a, byte_offset(i), c);
  14.825 +      unsafe.putOrderedInt(b, byte_offset(i), d);
  14.826 +    }
  14.827 +  }
  14.828 +  static void test_ci_oppos(int[] a, int old) {
  14.829 +    int limit = ARRLEN-1;
  14.830 +    for (int i = 0; i < ARRLEN; i+=1) {
  14.831 +      unsafe.putOrderedInt(a, byte_offset(limit-i), -123);
  14.832 +    }
  14.833 +  }
  14.834 +  static void test_vi_oppos(int[] a, int b, int old) {
  14.835 +    int limit = ARRLEN-1;
  14.836 +    for (int i = limit; i >= 0; i-=1) {
  14.837 +      unsafe.putOrderedInt(a, byte_offset(limit-i), b);
  14.838 +    }
  14.839 +  }
  14.840 +  static void test_cp_oppos(int[] a, int[] b) {
  14.841 +    int limit = ARRLEN-1;
  14.842 +    for (int i = 0; i < ARRLEN; i+=1) {
  14.843 +      unsafe.putOrderedInt(a, byte_offset(i), b[limit-i]);
  14.844 +    }
  14.845 +  }
  14.846 +  static void test_2ci_oppos(int[] a, int[] b) {
  14.847 +    int limit = ARRLEN-1;
  14.848 +    for (int i = 0; i < ARRLEN; i+=1) {
  14.849 +      unsafe.putOrderedInt(a, byte_offset(limit-i), -123);
  14.850 +      unsafe.putOrderedInt(b, byte_offset(i), -103);
  14.851 +    }
  14.852 +  }
  14.853 +  static void test_2vi_oppos(int[] a, int[] b, int c, int d) {
  14.854 +    int limit = ARRLEN-1;
  14.855 +    for (int i = limit; i >= 0; i-=1) {
  14.856 +      unsafe.putOrderedInt(a, byte_offset(i), c);
  14.857 +      unsafe.putOrderedInt(b, byte_offset(limit-i), d);
  14.858 +    }
  14.859 +  }
  14.860 +  static void test_ci_off(int[] a, int old) {
  14.861 +    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
  14.862 +      unsafe.putOrderedInt(a, byte_offset(i+OFFSET), -123);
  14.863 +    }
  14.864 +  }
  14.865 +  static void test_vi_off(int[] a, int b, int old) {
  14.866 +    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
  14.867 +      unsafe.putOrderedInt(a, byte_offset(i+OFFSET), b);
  14.868 +    }
  14.869 +  }
  14.870 +  static void test_cp_off(int[] a, int[] b) {
  14.871 +    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
  14.872 +      unsafe.putOrderedInt(a, byte_offset(i+OFFSET), b[i+OFFSET]);
  14.873 +    }
  14.874 +  }
  14.875 +  static void test_2ci_off(int[] a, int[] b) {
  14.876 +    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
  14.877 +      unsafe.putOrderedInt(a, byte_offset(i+OFFSET), -123);
  14.878 +      unsafe.putOrderedInt(b, byte_offset(i+OFFSET), -103);
  14.879 +    }
  14.880 +  }
  14.881 +  static void test_2vi_off(int[] a, int[] b, int c, int d) {
  14.882 +    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
  14.883 +      unsafe.putOrderedInt(a, byte_offset(i+OFFSET), c);
  14.884 +      unsafe.putOrderedInt(b, byte_offset(i+OFFSET), d);
  14.885 +    }
  14.886 +  }
  14.887 +  static void test_ci_inv(int[] a, int k, int old) {
  14.888 +    for (int i = 0; i < ARRLEN-k; i+=1) {
  14.889 +      unsafe.putOrderedInt(a, byte_offset(i+k), -123);
  14.890 +    }
  14.891 +  }
  14.892 +  static void test_vi_inv(int[] a, int b, int k, int old) {
  14.893 +    for (int i = 0; i < ARRLEN-k; i+=1) {
  14.894 +      unsafe.putOrderedInt(a, byte_offset(i+k), b);
  14.895 +    }
  14.896 +  }
  14.897 +  static void test_cp_inv(int[] a, int[] b, int k) {
  14.898 +    for (int i = 0; i < ARRLEN-k; i+=1) {
  14.899 +      unsafe.putOrderedInt(a, byte_offset(i+k), b[i+k]);
  14.900 +    }
  14.901 +  }
  14.902 +  static void test_2ci_inv(int[] a, int[] b, int k) {
  14.903 +    for (int i = 0; i < ARRLEN-k; i+=1) {
  14.904 +      unsafe.putOrderedInt(a, byte_offset(i+k), -123);
  14.905 +      unsafe.putOrderedInt(b, byte_offset(i+k), -103);
  14.906 +    }
  14.907 +  }
  14.908 +  static void test_2vi_inv(int[] a, int[] b, int c, int d, int k) {
  14.909 +    for (int i = 0; i < ARRLEN-k; i+=1) {
  14.910 +      unsafe.putOrderedInt(a, byte_offset(i+k), c);
  14.911 +      unsafe.putOrderedInt(b, byte_offset(i+k), d);
  14.912 +    }
  14.913 +  }
  14.914 +  static void test_ci_scl(int[] a, int old) {
  14.915 +    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
  14.916 +      unsafe.putOrderedInt(a, byte_offset(i*SCALE), -123);
  14.917 +    }
  14.918 +  }
  14.919 +  static void test_vi_scl(int[] a, int b, int old) {
  14.920 +    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
  14.921 +      unsafe.putOrderedInt(a, byte_offset(i*SCALE), b);
  14.922 +    }
  14.923 +  }
  14.924 +  static void test_cp_scl(int[] a, int[] b) {
  14.925 +    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
  14.926 +      unsafe.putOrderedInt(a, byte_offset(i*SCALE), b[i*SCALE]);
  14.927 +    }
  14.928 +  }
  14.929 +  static void test_2ci_scl(int[] a, int[] b) {
  14.930 +    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
  14.931 +      unsafe.putOrderedInt(a, byte_offset(i*SCALE), -123);
  14.932 +      unsafe.putOrderedInt(b, byte_offset(i*SCALE), -103);
  14.933 +    }
  14.934 +  }
  14.935 +  static void test_2vi_scl(int[] a, int[] b, int c, int d) {
  14.936 +    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
  14.937 +      unsafe.putOrderedInt(a, byte_offset(i*SCALE), c);
  14.938 +      unsafe.putOrderedInt(b, byte_offset(i*SCALE), d);
  14.939 +    }
  14.940 +  }
  14.941 +  static void test_cp_alndst(int[] a, int[] b) {
  14.942 +    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
  14.943 +      unsafe.putOrderedInt(a, byte_offset(i+ALIGN_OFF), b[i]);
  14.944 +    }
  14.945 +  }
  14.946 +  static void test_cp_alnsrc(int[] a, int[] b) {
  14.947 +    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
  14.948 +      unsafe.putOrderedInt(a, byte_offset(i), b[i+ALIGN_OFF]);
  14.949 +    }
  14.950 +  }
  14.951 +  static void test_2ci_aln(int[] a, int[] b) {
  14.952 +    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
  14.953 +      unsafe.putOrderedInt(a, byte_offset(i+ALIGN_OFF), -123);
  14.954 +      unsafe.putOrderedInt(b, byte_offset(i), -103);
  14.955 +    }
  14.956 +  }
  14.957 +  static void test_2vi_aln(int[] a, int[] b, int c, int d) {
  14.958 +    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
  14.959 +      unsafe.putOrderedInt(a, byte_offset(i), c);
  14.960 +      unsafe.putOrderedInt(b, byte_offset(i+ALIGN_OFF), d);
  14.961 +    }
  14.962 +  }
  14.963 +  static void test_cp_unalndst(int[] a, int[] b) {
  14.964 +    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
  14.965 +      unsafe.putOrderedInt(a, byte_offset(i+UNALIGN_OFF), b[i]);
  14.966 +    }
  14.967 +  }
  14.968 +  static void test_cp_unalnsrc(int[] a, int[] b) {
  14.969 +    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
  14.970 +      unsafe.putOrderedInt(a, byte_offset(i), b[i+UNALIGN_OFF]);
  14.971 +    }
  14.972 +  }
  14.973 +  static void test_2ci_unaln(int[] a, int[] b) {
  14.974 +    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
  14.975 +      unsafe.putOrderedInt(a, byte_offset(i+UNALIGN_OFF), -123);
  14.976 +      unsafe.putOrderedInt(b, byte_offset(i), -103);
  14.977 +    }
  14.978 +  }
  14.979 +  static void test_2vi_unaln(int[] a, int[] b, int c, int d) {
  14.980 +    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
  14.981 +      unsafe.putOrderedInt(a, byte_offset(i), c);
  14.982 +      unsafe.putOrderedInt(b, byte_offset(i+UNALIGN_OFF), d);
  14.983 +    }
  14.984 +  }
  14.985 +
  14.986 +  static int verify(String text, int i, int elem, int val) {
  14.987 +    if (elem != val) {
  14.988 +      System.err.println(text + "[" + i + "] = " + elem + " != " + val);
  14.989 +      return 1;
  14.990 +    }
  14.991 +    return 0;
  14.992 +  }
  14.993 +}
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/test/compiler/8004867/TestIntUnsafeVolatile.java	Thu Feb 21 06:29:43 2013 -0800
    15.3 @@ -0,0 +1,990 @@
    15.4 +/*
    15.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    15.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    15.7 + *
    15.8 + * This code is free software; you can redistribute it and/or modify it
    15.9 + * under the terms of the GNU General Public License version 2 only, as
   15.10 + * published by the Free Software Foundation.
   15.11 + *
   15.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   15.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   15.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   15.15 + * version 2 for more details (a copy is included in the LICENSE file that
   15.16 + * accompanied this code).
   15.17 + *
   15.18 + * You should have received a copy of the GNU General Public License version
   15.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   15.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   15.21 + *
   15.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   15.23 + * or visit www.oracle.com if you need additional information or have any
   15.24 + * questions.
   15.25 + *
   15.26 + */
   15.27 +
   15.28 +/**
   15.29 + * @test
   15.30 + * @bug 8004867
   15.31 + * @summary VM crashing with assert "share/vm/opto/node.hpp:357 - assert(i < _max) failed: oob"
   15.32 + *
   15.33 + * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:-OptimizeFill TestIntUnsafeVolatile
   15.34 + * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:+OptimizeFill TestIntUnsafeVolatile
   15.35 + */
   15.36 +
   15.37 +import sun.misc.Unsafe;
   15.38 +import java.lang.reflect.*;
   15.39 +
   15.40 +public class TestIntUnsafeVolatile {
   15.41 +  private static final int ARRLEN = 97;
   15.42 +  private static final int ITERS  = 11000;
   15.43 +  private static final int OFFSET = 3;
   15.44 +  private static final int SCALE = 2;
   15.45 +  private static final int ALIGN_OFF = 8;
   15.46 +  private static final int UNALIGN_OFF = 5;
   15.47 +
   15.48 +  private static final Unsafe unsafe;
   15.49 +  private static final int BASE;
   15.50 +  static {
   15.51 +    try {
   15.52 +      Class c = TestIntUnsafeVolatile.class.getClassLoader().loadClass("sun.misc.Unsafe");
   15.53 +      Field f = c.getDeclaredField("theUnsafe");
   15.54 +      f.setAccessible(true);
   15.55 +      unsafe = (Unsafe)f.get(c);
   15.56 +      BASE = unsafe.arrayBaseOffset(int[].class);
   15.57 +    } catch (Exception e) {
   15.58 +      InternalError err = new InternalError();
   15.59 +      err.initCause(e);
   15.60 +      throw err;
   15.61 +    }
   15.62 +  }
   15.63 +
   15.64 +  public static void main(String args[]) {
   15.65 +    System.out.println("Testing Integer array unsafe volatile operations");
   15.66 +    int errn = test(false);
   15.67 +    if (errn > 0) {
   15.68 +      System.err.println("FAILED: " + errn + " errors");
   15.69 +      System.exit(97);
   15.70 +    }
   15.71 +    System.out.println("PASSED");
   15.72 +  }
   15.73 +
   15.74 +  static int test(boolean test_only) {
   15.75 +    int[] a1 = new int[ARRLEN];
   15.76 +    int[] a2 = new int[ARRLEN];
   15.77 +    // Initialize
   15.78 +    for (int i=0; i<ARRLEN; i++) {
   15.79 +      a1[i] = -1;
   15.80 +      a2[i] = -1;
   15.81 +    }
   15.82 +    System.out.println("Warmup");
   15.83 +    for (int i=0; i<ITERS; i++) {
   15.84 +      test_ci(a1);
   15.85 +      test_vi(a2, 123, -1);
   15.86 +      test_cp(a1, a2);
   15.87 +      test_2ci(a1, a2);
   15.88 +      test_2vi(a1, a2, 123, 103);
   15.89 +      test_ci_neg(a1, 123);
   15.90 +      test_vi_neg(a2, 123, 103);
   15.91 +      test_cp_neg(a1, a2);
   15.92 +      test_2ci_neg(a1, a2);
   15.93 +      test_2vi_neg(a1, a2, 123, 103);
   15.94 +      test_ci_oppos(a1, 123);
   15.95 +      test_vi_oppos(a2, 123, 103);
   15.96 +      test_cp_oppos(a1, a2);
   15.97 +      test_2ci_oppos(a1, a2);
   15.98 +      test_2vi_oppos(a1, a2, 123, 103);
   15.99 +      test_ci_off(a1, 123);
  15.100 +      test_vi_off(a2, 123, 103);
  15.101 +      test_cp_off(a1, a2);
  15.102 +      test_2ci_off(a1, a2);
  15.103 +      test_2vi_off(a1, a2, 123, 103);
  15.104 +      test_ci_inv(a1, OFFSET, 123);
  15.105 +      test_vi_inv(a2, 123, OFFSET, 103);
  15.106 +      test_cp_inv(a1, a2, OFFSET);
  15.107 +      test_2ci_inv(a1, a2, OFFSET);
  15.108 +      test_2vi_inv(a1, a2, 123, 103, OFFSET);
  15.109 +      test_ci_scl(a1, 123);
  15.110 +      test_vi_scl(a2, 123, 103);
  15.111 +      test_cp_scl(a1, a2);
  15.112 +      test_2ci_scl(a1, a2);
  15.113 +      test_2vi_scl(a1, a2, 123, 103);
  15.114 +      test_cp_alndst(a1, a2);
  15.115 +      test_cp_alnsrc(a1, a2);
  15.116 +      test_2ci_aln(a1, a2);
  15.117 +      test_2vi_aln(a1, a2, 123, 103);
  15.118 +      test_cp_unalndst(a1, a2);
  15.119 +      test_cp_unalnsrc(a1, a2);
  15.120 +      test_2ci_unaln(a1, a2);
  15.121 +      test_2vi_unaln(a1, a2, 123, 103);
  15.122 +    }
  15.123 +    // Initialize
  15.124 +    for (int i=0; i<ARRLEN; i++) {
  15.125 +      a1[i] = -1;
  15.126 +      a2[i] = -1;
  15.127 +    }
  15.128 +    // Test and verify results
  15.129 +    System.out.println("Verification");
  15.130 +    int errn = 0;
  15.131 +    {
  15.132 +      test_ci(a1);
  15.133 +      for (int i=0; i<ARRLEN; i++) {
  15.134 +        errn += verify("test_ci: a1", i, a1[i], -123);
  15.135 +      }
  15.136 +      test_vi(a2, 123, -1);
  15.137 +      for (int i=0; i<ARRLEN; i++) {
  15.138 +        errn += verify("test_vi: a2", i, a2[i], 123);
  15.139 +      }
  15.140 +      test_cp(a1, a2);
  15.141 +      for (int i=0; i<ARRLEN; i++) {
  15.142 +        errn += verify("test_cp: a1", i, a1[i], 123);
  15.143 +      }
  15.144 +      test_2ci(a1, a2);
  15.145 +      for (int i=0; i<ARRLEN; i++) {
  15.146 +        errn += verify("test_2ci: a1", i, a1[i], -123);
  15.147 +        errn += verify("test_2ci: a2", i, a2[i], -103);
  15.148 +      }
  15.149 +      test_2vi(a1, a2, 123, 103);
  15.150 +      for (int i=0; i<ARRLEN; i++) {
  15.151 +        errn += verify("test_2vi: a1", i, a1[i], 123);
  15.152 +        errn += verify("test_2vi: a2", i, a2[i], 103);
  15.153 +      }
  15.154 +      // Reset for negative stride
  15.155 +      for (int i=0; i<ARRLEN; i++) {
  15.156 +        a1[i] = -1;
  15.157 +        a2[i] = -1;
  15.158 +      }
  15.159 +      test_ci_neg(a1, -1);
  15.160 +      for (int i=0; i<ARRLEN; i++) {
  15.161 +        errn += verify("test_ci_neg: a1", i, a1[i], -123);
  15.162 +      }
  15.163 +      test_vi_neg(a2, 123, -1);
  15.164 +      for (int i=0; i<ARRLEN; i++) {
  15.165 +        errn += verify("test_vi_neg: a2", i, a2[i], 123);
  15.166 +      }
  15.167 +      test_cp_neg(a1, a2);
  15.168 +      for (int i=0; i<ARRLEN; i++) {
  15.169 +        errn += verify("test_cp_neg: a1", i, a1[i], 123);
  15.170 +      }
  15.171 +      test_2ci_neg(a1, a2);
  15.172 +      for (int i=0; i<ARRLEN; i++) {
  15.173 +        errn += verify("test_2ci_neg: a1", i, a1[i], -123);
  15.174 +        errn += verify("test_2ci_neg: a2", i, a2[i], -103);
  15.175 +      }
  15.176 +      test_2vi_neg(a1, a2, 123, 103);
  15.177 +      for (int i=0; i<ARRLEN; i++) {
  15.178 +        errn += verify("test_2vi_neg: a1", i, a1[i], 123);
  15.179 +        errn += verify("test_2vi_neg: a2", i, a2[i], 103);
  15.180 +      }
  15.181 +      // Reset for opposite stride
  15.182 +      for (int i=0; i<ARRLEN; i++) {
  15.183 +        a1[i] = -1;
  15.184 +        a2[i] = -1;
  15.185 +      }
  15.186 +      test_ci_oppos(a1, -1);
  15.187 +      for (int i=0; i<ARRLEN; i++) {
  15.188 +        errn += verify("test_ci_oppos: a1", i, a1[i], -123);
  15.189 +      }
  15.190 +      test_vi_oppos(a2, 123, -1);
  15.191 +      for (int i=0; i<ARRLEN; i++) {
  15.192 +        errn += verify("test_vi_oppos: a2", i, a2[i], 123);
  15.193 +      }
  15.194 +      test_cp_oppos(a1, a2);
  15.195 +      for (int i=0; i<ARRLEN; i++) {
  15.196 +        errn += verify("test_cp_oppos: a1", i, a1[i], 123);
  15.197 +      }
  15.198 +      test_2ci_oppos(a1, a2);
  15.199 +      for (int i=0; i<ARRLEN; i++) {
  15.200 +        errn += verify("test_2ci_oppos: a1", i, a1[i], -123);
  15.201 +        errn += verify("test_2ci_oppos: a2", i, a2[i], -103);
  15.202 +      }
  15.203 +      test_2vi_oppos(a1, a2, 123, 103);
  15.204 +      for (int i=0; i<ARRLEN; i++) {
  15.205 +        errn += verify("test_2vi_oppos: a1", i, a1[i], 123);
  15.206 +        errn += verify("test_2vi_oppos: a2", i, a2[i], 103);
  15.207 +      }
  15.208 +      // Reset for indexing with offset
  15.209 +      for (int i=0; i<ARRLEN; i++) {
  15.210 +        a1[i] = -1;
  15.211 +        a2[i] = -1;
  15.212 +      }
  15.213 +      test_ci_off(a1, -1);
  15.214 +      for (int i=OFFSET; i<ARRLEN; i++) {
  15.215 +        errn += verify("test_ci_off: a1", i, a1[i], -123);
  15.216 +      }
  15.217 +      test_vi_off(a2, 123, -1);
  15.218 +      for (int i=OFFSET; i<ARRLEN; i++) {
  15.219 +        errn += verify("test_vi_off: a2", i, a2[i], 123);
  15.220 +      }
  15.221 +      test_cp_off(a1, a2);
  15.222 +      for (int i=OFFSET; i<ARRLEN; i++) {
  15.223 +        errn += verify("test_cp_off: a1", i, a1[i], 123);
  15.224 +      }
  15.225 +      test_2ci_off(a1, a2);
  15.226 +      for (int i=OFFSET; i<ARRLEN; i++) {
  15.227 +        errn += verify("test_2ci_off: a1", i, a1[i], -123);
  15.228 +        errn += verify("test_2ci_off: a2", i, a2[i], -103);
  15.229 +      }
  15.230 +      test_2vi_off(a1, a2, 123, 103);
  15.231 +      for (int i=OFFSET; i<ARRLEN; i++) {
  15.232 +        errn += verify("test_2vi_off: a1", i, a1[i], 123);
  15.233 +        errn += verify("test_2vi_off: a2", i, a2[i], 103);
  15.234 +      }
  15.235 +      for (int i=0; i<OFFSET; i++) {
  15.236 +        errn += verify("test_2vi_off: a1", i, a1[i], -1);
  15.237 +        errn += verify("test_2vi_off: a2", i, a2[i], -1);
  15.238 +      }
  15.239 +      // Reset for indexing with invariant offset
  15.240 +      for (int i=0; i<ARRLEN; i++) {
  15.241 +        a1[i] = -1;
  15.242 +        a2[i] = -1;
  15.243 +      }
  15.244 +      test_ci_inv(a1, OFFSET, -1);
  15.245 +      for (int i=OFFSET; i<ARRLEN; i++) {
  15.246 +        errn += verify("test_ci_inv: a1", i, a1[i], -123);
  15.247 +      }
  15.248 +      test_vi_inv(a2, 123, OFFSET, -1);
  15.249 +      for (int i=OFFSET; i<ARRLEN; i++) {
  15.250 +        errn += verify("test_vi_inv: a2", i, a2[i], 123);
  15.251 +      }
  15.252 +      test_cp_inv(a1, a2, OFFSET);
  15.253 +      for (int i=OFFSET; i<ARRLEN; i++) {
  15.254 +        errn += verify("test_cp_inv: a1", i, a1[i], 123);
  15.255 +      }
  15.256 +      test_2ci_inv(a1, a2, OFFSET);
  15.257 +      for (int i=OFFSET; i<ARRLEN; i++) {
  15.258 +        errn += verify("test_2ci_inv: a1", i, a1[i], -123);
  15.259 +        errn += verify("test_2ci_inv: a2", i, a2[i], -103);
  15.260 +      }
  15.261 +      test_2vi_inv(a1, a2, 123, 103, OFFSET);
  15.262 +      for (int i=OFFSET; i<ARRLEN; i++) {
  15.263 +        errn += verify("test_2vi_inv: a1", i, a1[i], 123);
  15.264 +        errn += verify("test_2vi_inv: a2", i, a2[i], 103);
  15.265 +      }
  15.266 +      for (int i=0; i<OFFSET; i++) {
  15.267 +        errn += verify("test_2vi_inv: a1", i, a1[i], -1);
  15.268 +        errn += verify("test_2vi_inv: a2", i, a2[i], -1);
  15.269 +      }
  15.270 +      // Reset for indexing with scale
  15.271 +      for (int i=0; i<ARRLEN; i++) {
  15.272 +        a1[i] = -1;
  15.273 +        a2[i] = -1;
  15.274 +      }
  15.275 +      test_ci_scl(a1, -1);
  15.276 +      for (int i=0; i<ARRLEN; i++) {
  15.277 +        int val = (i%SCALE != 0) ? -1 : -123;
  15.278 +        errn += verify("test_ci_scl: a1", i, a1[i], val);
  15.279 +      }
  15.280 +      test_vi_scl(a2, 123, -1);
  15.281 +      for (int i=0; i<ARRLEN; i++) {
  15.282 +        int val = (i%SCALE != 0) ? -1 : 123;
  15.283 +        errn += verify("test_vi_scl: a2", i, a2[i], val);
  15.284 +      }
  15.285 +      test_cp_scl(a1, a2);
  15.286 +      for (int i=0; i<ARRLEN; i++) {
  15.287 +        int val = (i%SCALE != 0) ? -1 : 123;
  15.288 +        errn += verify("test_cp_scl: a1", i, a1[i], val);
  15.289 +      }
  15.290 +      test_2ci_scl(a1, a2);
  15.291 +      for (int i=0; i<ARRLEN; i++) {
  15.292 +        if (i%SCALE != 0) {
  15.293 +          errn += verify("test_2ci_scl: a1", i, a1[i], -1);
  15.294 +        } else if (i*SCALE < ARRLEN) {
  15.295 +          errn += verify("test_2ci_scl: a1", i*SCALE, a1[i*SCALE], -123);
  15.296 +        }
  15.297 +        if (i%SCALE != 0) {
  15.298 +          errn += verify("test_2ci_scl: a2", i, a2[i], -1);
  15.299 +        } else if (i*SCALE < ARRLEN) {
  15.300 +          errn += verify("test_2ci_scl: a2", i*SCALE, a2[i*SCALE], -103);
  15.301 +        }
  15.302 +      }
  15.303 +      test_2vi_scl(a1, a2, 123, 103);
  15.304 +      for (int i=0; i<ARRLEN; i++) {
  15.305 +        if (i%SCALE != 0) {
  15.306 +          errn += verify("test_2vi_scl: a1", i, a1[i], -1);
  15.307 +        } else if (i*SCALE < ARRLEN) {
  15.308 +          errn += verify("test_2vi_scl: a1", i*SCALE, a1[i*SCALE], 123);
  15.309 +        }
  15.310 +        if (i%SCALE != 0) {
  15.311 +          errn += verify("test_2vi_scl: a2", i, a2[i], -1);
  15.312 +        } else if (i*SCALE < ARRLEN) {
  15.313 +          errn += verify("test_2vi_scl: a2", i*SCALE, a2[i*SCALE], 103);
  15.314 +        }
  15.315 +      }
  15.316 +      // Reset for 2 arrays with relative aligned offset
  15.317 +      for (int i=0; i<ARRLEN; i++) {
  15.318 +        a1[i] = -1;
  15.319 +        a2[i] = -1;
  15.320 +      }
  15.321 +      test_vi(a2, 123, -1);
  15.322 +      test_cp_alndst(a1, a2);
  15.323 +      for (int i=0; i<ALIGN_OFF; i++) {
  15.324 +        errn += verify("test_cp_alndst: a1", i, a1[i], -1);
  15.325 +      }
  15.326 +      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
  15.327 +        errn += verify("test_cp_alndst: a1", i, a1[i], 123);
  15.328 +      }
  15.329 +      for (int i=0; i<ALIGN_OFF; i++) {
  15.330 +        a1[i] = 123;
  15.331 +      }
  15.332 +      test_vi(a2, -123, 123);
  15.333 +      test_cp_alnsrc(a1, a2);
  15.334 +      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
  15.335 +        errn += verify("test_cp_alnsrc: a1", i, a1[i], -123);
  15.336 +      }
  15.337 +      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
  15.338 +        errn += verify("test_cp_alnsrc: a1", i, a1[i], 123);
  15.339 +      }
  15.340 +      for (int i=0; i<ARRLEN; i++) {
  15.341 +        a1[i] = -1;
  15.342 +        a2[i] = -1;
  15.343 +      }
  15.344 +      test_2ci_aln(a1, a2);
  15.345 +      for (int i=0; i<ALIGN_OFF; i++) {
  15.346 +        errn += verify("test_2ci_aln: a1", i, a1[i], -1);
  15.347 +      }
  15.348 +      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
  15.349 +        errn += verify("test_2ci_aln: a1", i, a1[i], -123);
  15.350 +      }
  15.351 +      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
  15.352 +        errn += verify("test_2ci_aln: a2", i, a2[i], -103);
  15.353 +      }
  15.354 +      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
  15.355 +        errn += verify("test_2ci_aln: a2", i, a2[i], -1);
  15.356 +      }
  15.357 +      for (int i=0; i<ARRLEN; i++) {
  15.358 +        a1[i] = -1;
  15.359 +        a2[i] = -1;
  15.360 +      }
  15.361 +      test_2vi_aln(a1, a2, 123, 103);
  15.362 +      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
  15.363 +        errn += verify("test_2vi_aln: a1", i, a1[i], 123);
  15.364 +      }
  15.365 +      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
  15.366 +        errn += verify("test_2vi_aln: a1", i, a1[i], -1);
  15.367 +      }
  15.368 +      for (int i=0; i<ALIGN_OFF; i++) {
  15.369 +        errn += verify("test_2vi_aln: a2", i, a2[i], -1);
  15.370 +      }
  15.371 +      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
  15.372 +        errn += verify("test_2vi_aln: a2", i, a2[i], 103);
  15.373 +      }
  15.374 +
  15.375 +      // Reset for 2 arrays with relative unaligned offset
  15.376 +      for (int i=0; i<ARRLEN; i++) {
  15.377 +        a1[i] = -1;
  15.378 +        a2[i] = -1;
  15.379 +      }
  15.380 +      test_vi(a2, 123, -1);
  15.381 +      test_cp_unalndst(a1, a2);
  15.382 +      for (int i=0; i<UNALIGN_OFF; i++) {
  15.383 +        errn += verify("test_cp_unalndst: a1", i, a1[i], -1);
  15.384 +      }
  15.385 +      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
  15.386 +        errn += verify("test_cp_unalndst: a1", i, a1[i], 123);
  15.387 +      }
  15.388 +      test_vi(a2, -123, 123);
  15.389 +      test_cp_unalnsrc(a1, a2);
  15.390 +      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
  15.391 +        errn += verify("test_cp_unalnsrc: a1", i, a1[i], -123);
  15.392 +      }
  15.393 +      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
  15.394 +        errn += verify("test_cp_unalnsrc: a1", i, a1[i], 123);
  15.395 +      }
  15.396 +      for (int i=0; i<ARRLEN; i++) {
  15.397 +        a1[i] = -1;
  15.398 +        a2[i] = -1;
  15.399 +      }
  15.400 +      test_2ci_unaln(a1, a2);
  15.401 +      for (int i=0; i<UNALIGN_OFF; i++) {
  15.402 +        errn += verify("test_2ci_unaln: a1", i, a1[i], -1);
  15.403 +      }
  15.404 +      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
  15.405 +        errn += verify("test_2ci_unaln: a1", i, a1[i], -123);
  15.406 +      }
  15.407 +      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
  15.408 +        errn += verify("test_2ci_unaln: a2", i, a2[i], -103);
  15.409 +      }
  15.410 +      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
  15.411 +        errn += verify("test_2ci_unaln: a2", i, a2[i], -1);
  15.412 +      }
  15.413 +      for (int i=0; i<ARRLEN; i++) {
  15.414 +        a1[i] = -1;
  15.415 +        a2[i] = -1;
  15.416 +      }
  15.417 +      test_2vi_unaln(a1, a2, 123, 103);
  15.418 +      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
  15.419 +        errn += verify("test_2vi_unaln: a1", i, a1[i], 123);
  15.420 +      }
  15.421 +      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
  15.422 +        errn += verify("test_2vi_unaln: a1", i, a1[i], -1);
  15.423 +      }
  15.424 +      for (int i=0; i<UNALIGN_OFF; i++) {
  15.425 +        errn += verify("test_2vi_unaln: a2", i, a2[i], -1);
  15.426 +      }
  15.427 +      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
  15.428 +        errn += verify("test_2vi_unaln: a2", i, a2[i], 103);
  15.429 +      }
  15.430 +
  15.431 +      // Reset for aligned overlap initialization
  15.432 +      for (int i=0; i<ALIGN_OFF; i++) {
  15.433 +        a1[i] = i;
  15.434 +      }
  15.435 +      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
  15.436 +        a1[i] = -1;
  15.437 +      }
  15.438 +      test_cp_alndst(a1, a1);
  15.439 +      for (int i=0; i<ARRLEN; i++) {
  15.440 +        int v = i%ALIGN_OFF;
  15.441 +        errn += verify("test_cp_alndst_overlap: a1", i, a1[i], v);
  15.442 +      }
  15.443 +      for (int i=0; i<ALIGN_OFF; i++) {
  15.444 +        a1[i+ALIGN_OFF] = -1;
  15.445 +      }
  15.446 +      test_cp_alnsrc(a1, a1);
  15.447 +      for (int i=0; i<ALIGN_OFF; i++) {
  15.448 +        errn += verify("test_cp_alnsrc_overlap: a1", i, a1[i], -1);
  15.449 +      }
  15.450 +      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
  15.451 +        int v = i%ALIGN_OFF;
  15.452 +        errn += verify("test_cp_alnsrc_overlap: a1", i, a1[i], v);
  15.453 +      }
  15.454 +      for (int i=0; i<ARRLEN; i++) {
  15.455 +        a1[i] = -1;
  15.456 +      }
  15.457 +      test_2ci_aln(a1, a1);
  15.458 +      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
  15.459 +        errn += verify("test_2ci_aln_overlap: a1", i, a1[i], -103);
  15.460 +      }
  15.461 +      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
  15.462 +        errn += verify("test_2ci_aln_overlap: a1", i, a1[i], -123);
  15.463 +      }
  15.464 +      for (int i=0; i<ARRLEN; i++) {
  15.465 +        a1[i] = -1;
  15.466 +      }
  15.467 +      test_2vi_aln(a1, a1, 123, 103);
  15.468 +      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
  15.469 +        errn += verify("test_2vi_aln_overlap: a1", i, a1[i], 123);
  15.470 +      }
  15.471 +      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
  15.472 +        errn += verify("test_2vi_aln_overlap: a1", i, a1[i], 103);
  15.473 +      }
  15.474 +
  15.475 +      // Reset for unaligned overlap initialization
  15.476 +      for (int i=0; i<UNALIGN_OFF; i++) {
  15.477 +        a1[i] = i;
  15.478 +      }
  15.479 +      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
  15.480 +        a1[i] = -1;
  15.481 +      }
  15.482 +      test_cp_unalndst(a1, a1);
  15.483 +      for (int i=0; i<ARRLEN; i++) {
  15.484 +        int v = i%UNALIGN_OFF;
  15.485 +        errn += verify("test_cp_unalndst_overlap: a1", i, a1[i], v);
  15.486 +      }
  15.487 +      for (int i=0; i<UNALIGN_OFF; i++) {
  15.488 +        a1[i+UNALIGN_OFF] = -1;
  15.489 +      }
  15.490 +      test_cp_unalnsrc(a1, a1);
  15.491 +      for (int i=0; i<UNALIGN_OFF; i++) {
  15.492 +        errn += verify("test_cp_unalnsrc_overlap: a1", i, a1[i], -1);
  15.493 +      }
  15.494 +      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
  15.495 +        int v = i%UNALIGN_OFF;
  15.496 +        errn += verify("test_cp_unalnsrc_overlap: a1", i, a1[i], v);
  15.497 +      }
  15.498 +      for (int i=0; i<ARRLEN; i++) {
  15.499 +        a1[i] = -1;
  15.500 +      }
  15.501 +      test_2ci_unaln(a1, a1);
  15.502 +      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
  15.503 +        errn += verify("test_2ci_unaln_overlap: a1", i, a1[i], -103);
  15.504 +      }
  15.505 +      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
  15.506 +        errn += verify("test_2ci_unaln_overlap: a1", i, a1[i], -123);
  15.507 +      }
  15.508 +      for (int i=0; i<ARRLEN; i++) {
  15.509 +        a1[i] = -1;
  15.510 +      }
  15.511 +      test_2vi_unaln(a1, a1, 123, 103);
  15.512 +      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
  15.513 +        errn += verify("test_2vi_unaln_overlap: a1", i, a1[i], 123);
  15.514 +      }
  15.515 +      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
  15.516 +        errn += verify("test_2vi_unaln_overlap: a1", i, a1[i], 103);
  15.517 +      }
  15.518 +
  15.519 +    }
  15.520 +
  15.521 +    if (errn > 0 || test_only)
  15.522 +      return errn;
  15.523 +
  15.524 +    // Initialize
  15.525 +    for (int i=0; i<ARRLEN; i++) {
  15.526 +      a1[i] = -1;
  15.527 +      a2[i] = -1;
  15.528 +    }
  15.529 +    System.out.println("Time");
  15.530 +    long start, end;
  15.531 +    start = System.currentTimeMillis();
  15.532 +    for (int i=0; i<ITERS; i++) {
  15.533 +      test_ci(a1);
  15.534 +    }
  15.535 +    end = System.currentTimeMillis();
  15.536 +    System.out.println("test_ci: " + (end - start));
  15.537 +    start = System.currentTimeMillis();
  15.538 +    for (int i=0; i<ITERS; i++) {
  15.539 +      test_vi(a2, 123, -1);
  15.540 +    }
  15.541 +    end = System.currentTimeMillis();
  15.542 +    System.out.println("test_vi: " + (end - start));
  15.543 +    start = System.currentTimeMillis();
  15.544 +    for (int i=0; i<ITERS; i++) {
  15.545 +      test_cp(a1, a2);
  15.546 +    }
  15.547 +    end = System.currentTimeMillis();
  15.548 +    System.out.println("test_cp: " + (end - start));
  15.549 +    start = System.currentTimeMillis();
  15.550 +    for (int i=0; i<ITERS; i++) {
  15.551 +      test_2ci(a1, a2);
  15.552 +    }
  15.553 +    end = System.currentTimeMillis();
  15.554 +    System.out.println("test_2ci: " + (end - start));
  15.555 +    start = System.currentTimeMillis();
  15.556 +    for (int i=0; i<ITERS; i++) {
  15.557 +      test_2vi(a1, a2, 123, 103);
  15.558 +    }
  15.559 +    end = System.currentTimeMillis();
  15.560 +    System.out.println("test_2vi: " + (end - start));
  15.561 +
  15.562 +    start = System.currentTimeMillis();
  15.563 +    for (int i=0; i<ITERS; i++) {
  15.564 +      test_ci_neg(a1, 123);
  15.565 +    }
  15.566 +    end = System.currentTimeMillis();
  15.567 +    System.out.println("test_ci_neg: " + (end - start));
  15.568 +    start = System.currentTimeMillis();
  15.569 +    for (int i=0; i<ITERS; i++) {
  15.570 +      test_vi_neg(a2, 123, 103);
  15.571 +    }
  15.572 +    end = System.currentTimeMillis();
  15.573 +    System.out.println("test_vi_neg: " + (end - start));
  15.574 +    start = System.currentTimeMillis();
  15.575 +    for (int i=0; i<ITERS; i++) {
  15.576 +      test_cp_neg(a1, a2);
  15.577 +    }
  15.578 +    end = System.currentTimeMillis();
  15.579 +    System.out.println("test_cp_neg: " + (end - start));
  15.580 +    start = System.currentTimeMillis();
  15.581 +    for (int i=0; i<ITERS; i++) {
  15.582 +      test_2ci_neg(a1, a2);
  15.583 +    }
  15.584 +    end = System.currentTimeMillis();
  15.585 +    System.out.println("test_2ci_neg: " + (end - start));
  15.586 +    start = System.currentTimeMillis();
  15.587 +    for (int i=0; i<ITERS; i++) {
  15.588 +      test_2vi_neg(a1, a2, 123, 103);
  15.589 +    }
  15.590 +    end = System.currentTimeMillis();
  15.591 +    System.out.println("test_2vi_neg: " + (end - start));
  15.592 +
  15.593 +    start = System.currentTimeMillis();
  15.594 +    for (int i=0; i<ITERS; i++) {
  15.595 +      test_ci_oppos(a1, 123);
  15.596 +    }
  15.597 +    end = System.currentTimeMillis();
  15.598 +    System.out.println("test_ci_oppos: " + (end - start));
  15.599 +    start = System.currentTimeMillis();
  15.600 +    for (int i=0; i<ITERS; i++) {
  15.601 +      test_vi_oppos(a2, 123, 103);
  15.602 +    }
  15.603 +    end = System.currentTimeMillis();
  15.604 +    System.out.println("test_vi_oppos: " + (end - start));
  15.605 +    start = System.currentTimeMillis();
  15.606 +    for (int i=0; i<ITERS; i++) {
  15.607 +      test_cp_oppos(a1, a2);
  15.608 +    }
  15.609 +    end = System.currentTimeMillis();
  15.610 +    System.out.println("test_cp_oppos: " + (end - start));
  15.611 +    start = System.currentTimeMillis();
  15.612 +    for (int i=0; i<ITERS; i++) {
  15.613 +      test_2ci_oppos(a1, a2);
  15.614 +    }
  15.615 +    end = System.currentTimeMillis();
  15.616 +    System.out.println("test_2ci_oppos: " + (end - start));
  15.617 +    start = System.currentTimeMillis();
  15.618 +    for (int i=0; i<ITERS; i++) {
  15.619 +      test_2vi_oppos(a1, a2, 123, 103);
  15.620 +    }
  15.621 +    end = System.currentTimeMillis();
  15.622 +    System.out.println("test_2vi_oppos: " + (end - start));
  15.623 +
  15.624 +    start = System.currentTimeMillis();
  15.625 +    for (int i=0; i<ITERS; i++) {
  15.626 +      test_ci_off(a1, 123);
  15.627 +    }
  15.628 +    end = System.currentTimeMillis();
  15.629 +    System.out.println("test_ci_off: " + (end - start));
  15.630 +    start = System.currentTimeMillis();
  15.631 +    for (int i=0; i<ITERS; i++) {
  15.632 +      test_vi_off(a2, 123, 103);
  15.633 +    }
  15.634 +    end = System.currentTimeMillis();
  15.635 +    System.out.println("test_vi_off: " + (end - start));
  15.636 +    start = System.currentTimeMillis();
  15.637 +    for (int i=0; i<ITERS; i++) {
  15.638 +      test_cp_off(a1, a2);
  15.639 +    }
  15.640 +    end = System.currentTimeMillis();
  15.641 +    System.out.println("test_cp_off: " + (end - start));
  15.642 +    start = System.currentTimeMillis();
  15.643 +    for (int i=0; i<ITERS; i++) {
  15.644 +      test_2ci_off(a1, a2);
  15.645 +    }
  15.646 +    end = System.currentTimeMillis();
  15.647 +    System.out.println("test_2ci_off: " + (end - start));
  15.648 +    start = System.currentTimeMillis();
  15.649 +    for (int i=0; i<ITERS; i++) {
  15.650 +      test_2vi_off(a1, a2, 123, 103);
  15.651 +    }
  15.652 +    end = System.currentTimeMillis();
  15.653 +    System.out.println("test_2vi_off: " + (end - start));
  15.654 +
  15.655 +    start = System.currentTimeMillis();
  15.656 +    for (int i=0; i<ITERS; i++) {
  15.657 +      test_ci_inv(a1, OFFSET, 123);
  15.658 +    }
  15.659 +    end = System.currentTimeMillis();
  15.660 +    System.out.println("test_ci_inv: " + (end - start));
  15.661 +    start = System.currentTimeMillis();
  15.662 +    for (int i=0; i<ITERS; i++) {
  15.663 +      test_vi_inv(a2, 123, OFFSET, 103);
  15.664 +    }
  15.665 +    end = System.currentTimeMillis();
  15.666 +    System.out.println("test_vi_inv: " + (end - start));
  15.667 +    start = System.currentTimeMillis();
  15.668 +    for (int i=0; i<ITERS; i++) {
  15.669 +      test_cp_inv(a1, a2, OFFSET);
  15.670 +    }
  15.671 +    end = System.currentTimeMillis();
  15.672 +    System.out.println("test_cp_inv: " + (end - start));
  15.673 +    start = System.currentTimeMillis();
  15.674 +    for (int i=0; i<ITERS; i++) {
  15.675 +      test_2ci_inv(a1, a2, OFFSET);
  15.676 +    }
  15.677 +    end = System.currentTimeMillis();
  15.678 +    System.out.println("test_2ci_inv: " + (end - start));
  15.679 +    start = System.currentTimeMillis();
  15.680 +    for (int i=0; i<ITERS; i++) {
  15.681 +      test_2vi_inv(a1, a2, 123, 103, OFFSET);
  15.682 +    }
  15.683 +    end = System.currentTimeMillis();
  15.684 +    System.out.println("test_2vi_inv: " + (end - start));
  15.685 +
  15.686 +    start = System.currentTimeMillis();
  15.687 +    for (int i=0; i<ITERS; i++) {
  15.688 +      test_ci_scl(a1, 123);
  15.689 +    }
  15.690 +    end = System.currentTimeMillis();
  15.691 +    System.out.println("test_ci_scl: " + (end - start));
  15.692 +    start = System.currentTimeMillis();
  15.693 +    for (int i=0; i<ITERS; i++) {
  15.694 +      test_vi_scl(a2, 123, 103);
  15.695 +    }
  15.696 +    end = System.currentTimeMillis();
  15.697 +    System.out.println("test_vi_scl: " + (end - start));
  15.698 +    start = System.currentTimeMillis();
  15.699 +    for (int i=0; i<ITERS; i++) {
  15.700 +      test_cp_scl(a1, a2);
  15.701 +    }
  15.702 +    end = System.currentTimeMillis();
  15.703 +    System.out.println("test_cp_scl: " + (end - start));
  15.704 +    start = System.currentTimeMillis();
  15.705 +    for (int i=0; i<ITERS; i++) {
  15.706 +      test_2ci_scl(a1, a2);
  15.707 +    }
  15.708 +    end = System.currentTimeMillis();
  15.709 +    System.out.println("test_2ci_scl: " + (end - start));
  15.710 +    start = System.currentTimeMillis();
  15.711 +    for (int i=0; i<ITERS; i++) {
  15.712 +      test_2vi_scl(a1, a2, 123, 103);
  15.713 +    }
  15.714 +    end = System.currentTimeMillis();
  15.715 +    System.out.println("test_2vi_scl: " + (end - start));
  15.716 +
  15.717 +    start = System.currentTimeMillis();
  15.718 +    for (int i=0; i<ITERS; i++) {
  15.719 +      test_cp_alndst(a1, a2);
  15.720 +    }
  15.721 +    end = System.currentTimeMillis();
  15.722 +    System.out.println("test_cp_alndst: " + (end - start));
  15.723 +    start = System.currentTimeMillis();
  15.724 +    for (int i=0; i<ITERS; i++) {
  15.725 +      test_cp_alnsrc(a1, a2);
  15.726 +    }
  15.727 +    end = System.currentTimeMillis();
  15.728 +    System.out.println("test_cp_alnsrc: " + (end - start));
  15.729 +    start = System.currentTimeMillis();
  15.730 +    for (int i=0; i<ITERS; i++) {
  15.731 +      test_2ci_aln(a1, a2);
  15.732 +    }
  15.733 +    end = System.currentTimeMillis();
  15.734 +    System.out.println("test_2ci_aln: " + (end - start));
  15.735 +    start = System.currentTimeMillis();
  15.736 +    for (int i=0; i<ITERS; i++) {
  15.737 +      test_2vi_aln(a1, a2, 123, 103);
  15.738 +    }
  15.739 +    end = System.currentTimeMillis();
  15.740 +    System.out.println("test_2vi_aln: " + (end - start));
  15.741 +
  15.742 +    start = System.currentTimeMillis();
  15.743 +    for (int i=0; i<ITERS; i++) {
  15.744 +      test_cp_unalndst(a1, a2);
  15.745 +    }
  15.746 +    end = System.currentTimeMillis();
  15.747 +    System.out.println("test_cp_unalndst: " + (end - start));
  15.748 +    start = System.currentTimeMillis();
  15.749 +    for (int i=0; i<ITERS; i++) {
  15.750 +      test_cp_unalnsrc(a1, a2);
  15.751 +    }
  15.752 +    end = System.currentTimeMillis();
  15.753 +    System.out.println("test_cp_unalnsrc: " + (end - start));
  15.754 +    start = System.currentTimeMillis();
  15.755 +    for (int i=0; i<ITERS; i++) {
  15.756 +      test_2ci_unaln(a1, a2);
  15.757 +    }
  15.758 +    end = System.currentTimeMillis();
  15.759 +    System.out.println("test_2ci_unaln: " + (end - start));
  15.760 +    start = System.currentTimeMillis();
  15.761 +    for (int i=0; i<ITERS; i++) {
  15.762 +      test_2vi_unaln(a1, a2, 123, 103);
  15.763 +    }
  15.764 +    end = System.currentTimeMillis();
  15.765 +    System.out.println("test_2vi_unaln: " + (end - start));
  15.766 +
  15.767 +    return errn;
  15.768 +  }
  15.769 +
  15.770 +  private final static long byte_offset(int i) {
  15.771 +    return ((long)i << 2) + BASE;
  15.772 +  }
  15.773 +
  15.774 +  static void test_ci(int[] a) {
  15.775 +    for (int i = 0; i < ARRLEN; i+=1) {
  15.776 +      unsafe.putIntVolatile(a, byte_offset(i), -123);
  15.777 +    }
  15.778 +  }
  15.779 +  static void test_vi(int[] a, int b, int old) {
  15.780 +    for (int i = 0; i < ARRLEN; i+=1) {
  15.781 +      unsafe.putIntVolatile(a, byte_offset(i), b);
  15.782 +    }
  15.783 +  }
  15.784 +  static void test_cp(int[] a, int[] b) {
  15.785 +    for (int i = 0; i < ARRLEN; i+=1) {
  15.786 +      unsafe.putIntVolatile(a, byte_offset(i), b[i]);
  15.787 +    }
  15.788 +  }
  15.789 +  static void test_2ci(int[] a, int[] b) {
  15.790 +    for (int i = 0; i < ARRLEN; i+=1) {
  15.791 +      unsafe.putIntVolatile(a, byte_offset(i), -123);
  15.792 +      unsafe.putIntVolatile(b, byte_offset(i), -103);
  15.793 +    }
  15.794 +  }
  15.795 +  static void test_2vi(int[] a, int[] b, int c, int d) {
  15.796 +    for (int i = 0; i < ARRLEN; i+=1) {
  15.797 +      unsafe.putIntVolatile(a, byte_offset(i), c);
  15.798 +      unsafe.putIntVolatile(b, byte_offset(i), d);
  15.799 +    }
  15.800 +  }
  15.801 +  static void test_ci_neg(int[] a, int old) {
  15.802 +    for (int i = ARRLEN-1; i >= 0; i-=1) {
  15.803 +      unsafe.putIntVolatile(a, byte_offset(i), -123);
  15.804 +    }
  15.805 +  }
  15.806 +  static void test_vi_neg(int[] a, int b, int old) {
  15.807 +    for (int i = ARRLEN-1; i >= 0; i-=1) {
  15.808 +      unsafe.putIntVolatile(a, byte_offset(i), b);
  15.809 +    }
  15.810 +  }
  15.811 +  static void test_cp_neg(int[] a, int[] b) {
  15.812 +    for (int i = ARRLEN-1; i >= 0; i-=1) {
  15.813 +      unsafe.putIntVolatile(a, byte_offset(i), b[i]);
  15.814 +    }
  15.815 +  }
  15.816 +  static void test_2ci_neg(int[] a, int[] b) {
  15.817 +    for (int i = ARRLEN-1; i >= 0; i-=1) {
  15.818 +      unsafe.putIntVolatile(a, byte_offset(i), -123);
  15.819 +      unsafe.putIntVolatile(b, byte_offset(i), -103);
  15.820 +    }
  15.821 +  }
  15.822 +  static void test_2vi_neg(int[] a, int[] b, int c, int d) {
  15.823 +    for (int i = ARRLEN-1; i >= 0; i-=1) {
  15.824 +      unsafe.putIntVolatile(a, byte_offset(i), c);
  15.825 +      unsafe.putIntVolatile(b, byte_offset(i), d);
  15.826 +    }
  15.827 +  }
  15.828 +  static void test_ci_oppos(int[] a, int old) {
  15.829 +    int limit = ARRLEN-1;
  15.830 +    for (int i = 0; i < ARRLEN; i+=1) {
  15.831 +      unsafe.putIntVolatile(a, byte_offset(limit-i), -123);
  15.832 +    }
  15.833 +  }
  15.834 +  static void test_vi_oppos(int[] a, int b, int old) {
  15.835 +    int limit = ARRLEN-1;
  15.836 +    for (int i = limit; i >= 0; i-=1) {
  15.837 +      unsafe.putIntVolatile(a, byte_offset(limit-i), b);
  15.838 +    }
  15.839 +  }
  15.840 +  static void test_cp_oppos(int[] a, int[] b) {
  15.841 +    int limit = ARRLEN-1;
  15.842 +    for (int i = 0; i < ARRLEN; i+=1) {
  15.843 +      unsafe.putIntVolatile(a, byte_offset(i), b[limit-i]);
  15.844 +    }
  15.845 +  }
  15.846 +  static void test_2ci_oppos(int[] a, int[] b) {
  15.847 +    int limit = ARRLEN-1;
  15.848 +    for (int i = 0; i < ARRLEN; i+=1) {
  15.849 +      unsafe.putIntVolatile(a, byte_offset(limit-i), -123);
  15.850 +      unsafe.putIntVolatile(b, byte_offset(i), -103);
  15.851 +    }
  15.852 +  }
  15.853 +  static void test_2vi_oppos(int[] a, int[] b, int c, int d) {
  15.854 +    int limit = ARRLEN-1;
  15.855 +    for (int i = limit; i >= 0; i-=1) {
  15.856 +      unsafe.putIntVolatile(a, byte_offset(i), c);
  15.857 +      unsafe.putIntVolatile(b, byte_offset(limit-i), d);
  15.858 +    }
  15.859 +  }
  15.860 +  static void test_ci_off(int[] a, int old) {
  15.861 +    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
  15.862 +      unsafe.putIntVolatile(a, byte_offset(i+OFFSET), -123);
  15.863 +    }
  15.864 +  }
  15.865 +  static void test_vi_off(int[] a, int b, int old) {
  15.866 +    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
  15.867 +      unsafe.putIntVolatile(a, byte_offset(i+OFFSET), b);
  15.868 +    }
  15.869 +  }
  15.870 +  static void test_cp_off(int[] a, int[] b) {
  15.871 +    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
  15.872 +      unsafe.putIntVolatile(a, byte_offset(i+OFFSET), b[i+OFFSET]);
  15.873 +    }
  15.874 +  }
  15.875 +  static void test_2ci_off(int[] a, int[] b) {
  15.876 +    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
  15.877 +      unsafe.putIntVolatile(a, byte_offset(i+OFFSET), -123);
  15.878 +      unsafe.putIntVolatile(b, byte_offset(i+OFFSET), -103);
  15.879 +    }
  15.880 +  }
  15.881 +  static void test_2vi_off(int[] a, int[] b, int c, int d) {
  15.882 +    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
  15.883 +      unsafe.putIntVolatile(a, byte_offset(i+OFFSET), c);
  15.884 +      unsafe.putIntVolatile(b, byte_offset(i+OFFSET), d);
  15.885 +    }
  15.886 +  }
  15.887 +  static void test_ci_inv(int[] a, int k, int old) {
  15.888 +    for (int i = 0; i < ARRLEN-k; i+=1) {
  15.889 +      unsafe.putIntVolatile(a, byte_offset(i+k), -123);
  15.890 +    }
  15.891 +  }
  15.892 +  static void test_vi_inv(int[] a, int b, int k, int old) {
  15.893 +    for (int i = 0; i < ARRLEN-k; i+=1) {
  15.894 +      unsafe.putIntVolatile(a, byte_offset(i+k), b);
  15.895 +    }
  15.896 +  }
  15.897 +  static void test_cp_inv(int[] a, int[] b, int k) {
  15.898 +    for (int i = 0; i < ARRLEN-k; i+=1) {
  15.899 +      unsafe.putIntVolatile(a, byte_offset(i+k), b[i+k]);
  15.900 +    }
  15.901 +  }
  15.902 +  static void test_2ci_inv(int[] a, int[] b, int k) {
  15.903 +    for (int i = 0; i < ARRLEN-k; i+=1) {
  15.904 +      unsafe.putIntVolatile(a, byte_offset(i+k), -123);
  15.905 +      unsafe.putIntVolatile(b, byte_offset(i+k), -103);
  15.906 +    }
  15.907 +  }
  15.908 +  static void test_2vi_inv(int[] a, int[] b, int c, int d, int k) {
  15.909 +    for (int i = 0; i < ARRLEN-k; i+=1) {
  15.910 +      unsafe.putIntVolatile(a, byte_offset(i+k), c);
  15.911 +      unsafe.putIntVolatile(b, byte_offset(i+k), d);
  15.912 +    }
  15.913 +  }
  15.914 +  static void test_ci_scl(int[] a, int old) {
  15.915 +    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
  15.916 +      unsafe.putIntVolatile(a, byte_offset(i*SCALE), -123);
  15.917 +    }
  15.918 +  }
  15.919 +  static void test_vi_scl(int[] a, int b, int old) {
  15.920 +    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
  15.921 +      unsafe.putIntVolatile(a, byte_offset(i*SCALE), b);
  15.922 +    }
  15.923 +  }
  15.924 +  static void test_cp_scl(int[] a, int[] b) {
  15.925 +    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
  15.926 +      unsafe.putIntVolatile(a, byte_offset(i*SCALE), b[i*SCALE]);
  15.927 +    }
  15.928 +  }
  15.929 +  static void test_2ci_scl(int[] a, int[] b) {
  15.930 +    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
  15.931 +      unsafe.putIntVolatile(a, byte_offset(i*SCALE), -123);
  15.932 +      unsafe.putIntVolatile(b, byte_offset(i*SCALE), -103);
  15.933 +    }
  15.934 +  }
  15.935 +  static void test_2vi_scl(int[] a, int[] b, int c, int d) {
  15.936 +    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
  15.937 +      unsafe.putIntVolatile(a, byte_offset(i*SCALE), c);
  15.938 +      unsafe.putIntVolatile(b, byte_offset(i*SCALE), d);
  15.939 +    }
  15.940 +  }
  15.941 +  static void test_cp_alndst(int[] a, int[] b) {
  15.942 +    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
  15.943 +      unsafe.putIntVolatile(a, byte_offset(i+ALIGN_OFF), b[i]);
  15.944 +    }
  15.945 +  }
  15.946 +  static void test_cp_alnsrc(int[] a, int[] b) {
  15.947 +    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
  15.948 +      unsafe.putIntVolatile(a, byte_offset(i), b[i+ALIGN_OFF]);
  15.949 +    }
  15.950 +  }
  15.951 +  static void test_2ci_aln(int[] a, int[] b) {
  15.952 +    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
  15.953 +      unsafe.putIntVolatile(a, byte_offset(i+ALIGN_OFF), -123);
  15.954 +      unsafe.putIntVolatile(b, byte_offset(i), -103);
  15.955 +    }
  15.956 +  }
  15.957 +  static void test_2vi_aln(int[] a, int[] b, int c, int d) {
  15.958 +    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
  15.959 +      unsafe.putIntVolatile(a, byte_offset(i), c);
  15.960 +      unsafe.putIntVolatile(b, byte_offset(i+ALIGN_OFF), d);
  15.961 +    }
  15.962 +  }
  15.963 +  static void test_cp_unalndst(int[] a, int[] b) {
  15.964 +    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
  15.965 +      unsafe.putIntVolatile(a, byte_offset(i+UNALIGN_OFF), b[i]);
  15.966 +    }
  15.967 +  }
  15.968 +  static void test_cp_unalnsrc(int[] a, int[] b) {
  15.969 +    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
  15.970 +      unsafe.putIntVolatile(a, byte_offset(i), b[i+UNALIGN_OFF]);
  15.971 +    }
  15.972 +  }
  15.973 +  static void test_2ci_unaln(int[] a, int[] b) {
  15.974 +    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
  15.975 +      unsafe.putIntVolatile(a, byte_offset(i+UNALIGN_OFF), -123);
  15.976 +      unsafe.putIntVolatile(b, byte_offset(i), -103);
  15.977 +    }
  15.978 +  }
  15.979 +  static void test_2vi_unaln(int[] a, int[] b, int c, int d) {
  15.980 +    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
  15.981 +      unsafe.putIntVolatile(a, byte_offset(i), c);
  15.982 +      unsafe.putIntVolatile(b, byte_offset(i+UNALIGN_OFF), d);
  15.983 +    }
  15.984 +  }
  15.985 +
  15.986 +  static int verify(String text, int i, int elem, int val) {
  15.987 +    if (elem != val) {
  15.988 +      System.err.println(text + "[" + i + "] = " + elem + " != " + val);
  15.989 +      return 1;
  15.990 +    }
  15.991 +    return 0;
  15.992 +  }
  15.993 +}

mercurial