# HG changeset patch # User vlivanov # Date 1361456983 28800 # Node ID 2e4b16122164890226dcb531f5e7c0c87f18736e # Parent 5741d3fc502d1874a89b4e9b5a0e80a157e8e79d# Parent ad736b4683b41fe8f860166cc23476dfa7820242 Merge diff -r 5741d3fc502d -r 2e4b16122164 src/share/vm/opto/library_call.cpp --- a/src/share/vm/opto/library_call.cpp Thu Feb 21 13:13:22 2013 +0100 +++ b/src/share/vm/opto/library_call.cpp Thu Feb 21 06:29:43 2013 -0800 @@ -1481,10 +1481,10 @@ Node* arg = round_double_node(argument(0)); Node* n; switch (id) { - case vmIntrinsics::_dabs: n = new (C) AbsDNode( arg); break; - case vmIntrinsics::_dsqrt: n = new (C) SqrtDNode(0, arg); break; - case vmIntrinsics::_dlog: n = new (C) LogDNode( arg); break; - case vmIntrinsics::_dlog10: n = new (C) Log10DNode( arg); break; + case vmIntrinsics::_dabs: n = new (C) AbsDNode( arg); break; + case vmIntrinsics::_dsqrt: n = new (C) SqrtDNode(C, control(), arg); break; + case vmIntrinsics::_dlog: n = new (C) LogDNode(C, control(), arg); break; + case vmIntrinsics::_dlog10: n = new (C) Log10DNode(C, control(), arg); break; default: fatal_unexpected_iid(id); break; } set_result(_gvn.transform(n)); @@ -1499,9 +1499,9 @@ Node* n = NULL; switch (id) { - case vmIntrinsics::_dsin: n = new (C) SinDNode(arg); break; - case vmIntrinsics::_dcos: n = new (C) CosDNode(arg); break; - case vmIntrinsics::_dtan: n = new (C) TanDNode(arg); break; + case vmIntrinsics::_dsin: n = new (C) SinDNode(C, control(), arg); break; + case vmIntrinsics::_dcos: n = new (C) CosDNode(C, control(), arg); break; + case vmIntrinsics::_dtan: n = new (C) TanDNode(C, control(), arg); break; default: fatal_unexpected_iid(id); break; } n = _gvn.transform(n); diff -r 5741d3fc502d -r 2e4b16122164 src/share/vm/opto/subnode.hpp --- a/src/share/vm/opto/subnode.hpp Thu Feb 21 13:13:22 2013 +0100 +++ b/src/share/vm/opto/subnode.hpp Thu Feb 21 06:29:43 2013 -0800 @@ -399,7 +399,10 @@ // Cosinus of a double class CosDNode : public Node { public: - CosDNode( Node *in1 ) : Node(0, in1) {} + CosDNode(Compile* C, Node *c, Node *in1) : Node(c, in1) { + init_flags(Flag_is_expensive); + C->add_expensive_node(this); + } virtual int Opcode() const; const Type *bottom_type() const { return Type::DOUBLE; } virtual uint ideal_reg() const { return Op_RegD; } @@ -410,7 +413,10 @@ // Sinus of a double class SinDNode : public Node { public: - SinDNode( Node *in1 ) : Node(0, in1) {} + SinDNode(Compile* C, Node *c, Node *in1) : Node(c, in1) { + init_flags(Flag_is_expensive); + C->add_expensive_node(this); + } virtual int Opcode() const; const Type *bottom_type() const { return Type::DOUBLE; } virtual uint ideal_reg() const { return Op_RegD; } @@ -422,7 +428,10 @@ // tangens of a double class TanDNode : public Node { public: - TanDNode(Node *in1 ) : Node(0, in1) {} + TanDNode(Compile* C, Node *c,Node *in1) : Node(c, in1) { + init_flags(Flag_is_expensive); + C->add_expensive_node(this); + } virtual int Opcode() const; const Type *bottom_type() const { return Type::DOUBLE; } virtual uint ideal_reg() const { return Op_RegD; } @@ -445,7 +454,10 @@ // square root a double class SqrtDNode : public Node { public: - SqrtDNode(Node *c, Node *in1 ) : Node(c, in1) {} + SqrtDNode(Compile* C, Node *c, Node *in1) : Node(c, in1) { + init_flags(Flag_is_expensive); + C->add_expensive_node(this); + } virtual int Opcode() const; const Type *bottom_type() const { return Type::DOUBLE; } virtual uint ideal_reg() const { return Op_RegD; } @@ -470,7 +482,10 @@ // Log_e of a double class LogDNode : public Node { public: - LogDNode( Node *in1 ) : Node(0, in1) {} + LogDNode(Compile* C, Node *c, Node *in1) : Node(c, in1) { + init_flags(Flag_is_expensive); + C->add_expensive_node(this); + } virtual int Opcode() const; const Type *bottom_type() const { return Type::DOUBLE; } virtual uint ideal_reg() const { return Op_RegD; } @@ -481,7 +496,10 @@ // Log_10 of a double class Log10DNode : public Node { public: - Log10DNode( Node *in1 ) : Node(0, in1) {} + Log10DNode(Compile* C, Node *c, Node *in1) : Node(c, in1) { + init_flags(Flag_is_expensive); + C->add_expensive_node(this); + } virtual int Opcode() const; const Type *bottom_type() const { return Type::DOUBLE; } virtual uint ideal_reg() const { return Op_RegD; } diff -r 5741d3fc502d -r 2e4b16122164 src/share/vm/opto/superword.cpp --- a/src/share/vm/opto/superword.cpp Thu Feb 21 13:13:22 2013 +0100 +++ b/src/share/vm/opto/superword.cpp Thu Feb 21 06:29:43 2013 -0800 @@ -143,7 +143,8 @@ // Ready the block - construct_bb(); + if (!construct_bb()) + return; // Exit if no interesting nodes or complex graph. dependence_graph(); @@ -615,6 +616,7 @@ if (n == stop) break; preds.push(n); prev = n; + assert(n->is_Mem(), err_msg_res("unexpected node %s", n->Name())); n = n->in(MemNode::Memory); } } @@ -1578,7 +1580,7 @@ //------------------------------construct_bb--------------------------- // Construct reverse postorder list of block members -void SuperWord::construct_bb() { +bool SuperWord::construct_bb() { Node* entry = bb(); assert(_stk.length() == 0, "stk is empty"); @@ -1596,6 +1598,12 @@ Node *n = lpt()->_body.at(i); set_bb_idx(n, i); // Create a temporary map if (in_bb(n)) { + if (n->is_LoadStore() || n->is_MergeMem() || + (n->is_Proj() && !n->as_Proj()->is_CFG())) { + // Bailout if the loop has LoadStore, MergeMem or data Proj + // nodes. Superword optimization does not work with them. + return false; + } bb_ct++; if (!n->is_CFG()) { bool found = false; @@ -1620,6 +1628,10 @@ if (in_bb(n) && (n->is_Phi() && n->bottom_type() == Type::MEMORY)) { Node* n_tail = n->in(LoopNode::LoopBackControl); if (n_tail != n->in(LoopNode::EntryControl)) { + if (!n_tail->is_Mem()) { + assert(n_tail->is_Mem(), err_msg_res("unexpected node for memory slice: %s", n_tail->Name())); + return false; // Bailout + } _mem_slice_head.push(n); _mem_slice_tail.push(n_tail); } @@ -1695,6 +1707,7 @@ } #endif assert(rpo_idx == -1 && bb_ct == _block.length(), "all block members found"); + return (_mem_slice_head.length() > 0) || (_data_entry.length() > 0); } //------------------------------initialize_bb--------------------------- diff -r 5741d3fc502d -r 2e4b16122164 src/share/vm/opto/superword.hpp --- a/src/share/vm/opto/superword.hpp Thu Feb 21 13:13:22 2013 +0100 +++ b/src/share/vm/opto/superword.hpp Thu Feb 21 06:29:43 2013 -0800 @@ -380,7 +380,7 @@ // Is use->in(u_idx) a vector use? bool is_vector_use(Node* use, int u_idx); // Construct reverse postorder list of block members - void construct_bb(); + bool construct_bb(); // Initialize per node info void initialize_bb(); // Insert n into block after pos diff -r 5741d3fc502d -r 2e4b16122164 test/compiler/5091921/Test6850611.java --- a/test/compiler/5091921/Test6850611.java Thu Feb 21 13:13:22 2013 +0100 +++ b/test/compiler/5091921/Test6850611.java Thu Feb 21 06:29:43 2013 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,7 +27,7 @@ * @bug 6850611 * @summary int / long arithmetic seems to be broken in 1.6.0_14 HotSpot Server VM (Win XP) * - * @run main Test6850611 + * @run main/timeout=480 Test6850611 */ public class Test6850611 { diff -r 5741d3fc502d -r 2e4b16122164 test/compiler/5091921/Test6890943.java --- a/test/compiler/5091921/Test6890943.java Thu Feb 21 13:13:22 2013 +0100 +++ b/test/compiler/5091921/Test6890943.java Thu Feb 21 06:29:43 2013 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,7 +27,7 @@ * @bug 6890943 * @summary JVM mysteriously gives wrong result on 64-bit 1.6 VMs in hotspot mode. * - * @run shell Test6890943.sh + * @run shell/timeout=240 Test6890943.sh */ import java.util.*; import java.io.*; diff -r 5741d3fc502d -r 2e4b16122164 test/compiler/5091921/Test6890943.sh --- a/test/compiler/5091921/Test6890943.sh Thu Feb 21 13:13:22 2013 +0100 +++ b/test/compiler/5091921/Test6890943.sh Thu Feb 21 06:29:43 2013 -0800 @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -52,7 +52,10 @@ ${TESTJAVA}/bin/javac -d . Test6890943.java -${TESTJAVA}/bin/java -XX:-PrintVMOptions ${TESTVMOPTS} Test6890943 < input6890943.txt > test.out 2>&1 +${TESTJAVA}/bin/java -XX:-PrintVMOptions -XX:+IgnoreUnrecognizedVMOptions ${TESTVMOPTS} Test6890943 < input6890943.txt > pretest.out 2>&1 + +# This test sometimes tickles an unrelated performance warning that interferes with diff. +grep -v 'warning: Performance bug: SystemDictionary' pretest.out > test.out diff output6890943.txt test.out diff -r 5741d3fc502d -r 2e4b16122164 test/compiler/5091921/Test6905845.java --- a/test/compiler/5091921/Test6905845.java Thu Feb 21 13:13:22 2013 +0100 +++ b/test/compiler/5091921/Test6905845.java Thu Feb 21 06:29:43 2013 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,7 +27,7 @@ * @bug 6905845 * @summary Server VM improperly optimizing away loop. * - * @run main Test6905845 + * @run main/timeout=480 Test6905845 */ public class Test6905845 { diff -r 5741d3fc502d -r 2e4b16122164 test/compiler/5091921/Test6992759.java --- a/test/compiler/5091921/Test6992759.java Thu Feb 21 13:13:22 2013 +0100 +++ b/test/compiler/5091921/Test6992759.java Thu Feb 21 06:29:43 2013 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,7 +27,7 @@ * @bug 6992759 * @summary Bad code generated for integer <= comparison, fails for Integer.MAX_VALUE * - * @run main Test6992759 + * @run main/timeout=240 Test6992759 */ public class Test6992759 { diff -r 5741d3fc502d -r 2e4b16122164 test/compiler/8004867/TestIntAtomicCAS.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/compiler/8004867/TestIntAtomicCAS.java Thu Feb 21 06:29:43 2013 -0800 @@ -0,0 +1,969 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +/** + * @test + * @bug 8004867 + * @summary VM crashing with assert "share/vm/opto/node.hpp:357 - assert(i < _max) failed: oob" + * + * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:-OptimizeFill TestIntAtomicCAS + * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:+OptimizeFill TestIntAtomicCAS + */ + +import java.util.concurrent.atomic.AtomicIntegerArray; + +public class TestIntAtomicCAS { + private static final int ARRLEN = 97; + private static final int ITERS = 11000; + private static final int OFFSET = 3; + private static final int SCALE = 2; + private static final int ALIGN_OFF = 8; + private static final int UNALIGN_OFF = 5; + + public static void main(String args[]) { + System.out.println("Testing Integer array atomic CAS operations"); + int errn = test(false); + if (errn > 0) { + System.err.println("FAILED: " + errn + " errors"); + System.exit(97); + } + System.out.println("PASSED"); + } + + static int test(boolean test_only) { + AtomicIntegerArray a1 = new AtomicIntegerArray(ARRLEN); + AtomicIntegerArray a2 = new AtomicIntegerArray(ARRLEN); + // Initialize + for (int i=0; i 0 || test_only) + return errn; + + // Initialize + for (int i=0; i= 0; i-=1) { + a.compareAndSet(i, old, -123); + } + } + static void test_vi_neg(AtomicIntegerArray a, int b, int old) { + for (int i = ARRLEN-1; i >= 0; i-=1) { + a.compareAndSet(i, old, b); + } + } + static void test_cp_neg(AtomicIntegerArray a, AtomicIntegerArray b) { + for (int i = ARRLEN-1; i >= 0; i-=1) { + a.compareAndSet(i, -123, b.get(i)); + } + } + static void test_2ci_neg(AtomicIntegerArray a, AtomicIntegerArray b) { + for (int i = ARRLEN-1; i >= 0; i-=1) { + a.compareAndSet(i, 123, -123); + b.compareAndSet(i, 123, -103); + } + } + static void test_2vi_neg(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) { + for (int i = ARRLEN-1; i >= 0; i-=1) { + a.compareAndSet(i, -123, c); + b.compareAndSet(i, -103, d); + } + } + static void test_ci_oppos(AtomicIntegerArray a, int old) { + int limit = ARRLEN-1; + for (int i = 0; i < ARRLEN; i+=1) { + a.compareAndSet((limit-i), old, -123); + } + } + static void test_vi_oppos(AtomicIntegerArray a, int b, int old) { + int limit = ARRLEN-1; + for (int i = limit; i >= 0; i-=1) { + a.compareAndSet((limit-i), old, b); + } + } + static void test_cp_oppos(AtomicIntegerArray a, AtomicIntegerArray b) { + int limit = ARRLEN-1; + for (int i = 0; i < ARRLEN; i+=1) { + a.compareAndSet(i, -123, b.get(limit-i)); + } + } + static void test_2ci_oppos(AtomicIntegerArray a, AtomicIntegerArray b) { + int limit = ARRLEN-1; + for (int i = 0; i < ARRLEN; i+=1) { + a.compareAndSet((limit-i), 123, -123); + b.compareAndSet(i, 123, -103); + } + } + static void test_2vi_oppos(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) { + int limit = ARRLEN-1; + for (int i = limit; i >= 0; i-=1) { + a.compareAndSet(i, -123, c); + b.compareAndSet((limit-i), -103, d); + } + } + static void test_ci_off(AtomicIntegerArray a, int old) { + for (int i = 0; i < ARRLEN-OFFSET; i+=1) { + a.compareAndSet((i+OFFSET), old, -123); + } + } + static void test_vi_off(AtomicIntegerArray a, int b, int old) { + for (int i = 0; i < ARRLEN-OFFSET; i+=1) { + a.compareAndSet((i+OFFSET), old, b); + } + } + static void test_cp_off(AtomicIntegerArray a, AtomicIntegerArray b) { + for (int i = 0; i < ARRLEN-OFFSET; i+=1) { + a.compareAndSet((i+OFFSET), -123, b.get(i+OFFSET)); + } + } + static void test_2ci_off(AtomicIntegerArray a, AtomicIntegerArray b) { + for (int i = 0; i < ARRLEN-OFFSET; i+=1) { + a.compareAndSet((i+OFFSET), 123, -123); + b.compareAndSet((i+OFFSET), 123, -103); + } + } + static void test_2vi_off(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) { + for (int i = 0; i < ARRLEN-OFFSET; i+=1) { + a.compareAndSet((i+OFFSET), -123, c); + b.compareAndSet((i+OFFSET), -103, d); + } + } + static void test_ci_inv(AtomicIntegerArray a, int k, int old) { + for (int i = 0; i < ARRLEN-k; i+=1) { + a.compareAndSet((i+k), old, -123); + } + } + static void test_vi_inv(AtomicIntegerArray a, int b, int k, int old) { + for (int i = 0; i < ARRLEN-k; i+=1) { + a.compareAndSet((i+k), old, b); + } + } + static void test_cp_inv(AtomicIntegerArray a, AtomicIntegerArray b, int k) { + for (int i = 0; i < ARRLEN-k; i+=1) { + a.compareAndSet((i+k), -123, b.get(i+k)); + } + } + static void test_2ci_inv(AtomicIntegerArray a, AtomicIntegerArray b, int k) { + for (int i = 0; i < ARRLEN-k; i+=1) { + a.compareAndSet((i+k), 123, -123); + b.compareAndSet((i+k), 123, -103); + } + } + static void test_2vi_inv(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d, int k) { + for (int i = 0; i < ARRLEN-k; i+=1) { + a.compareAndSet((i+k), -123, c); + b.compareAndSet((i+k), -103, d); + } + } + static void test_ci_scl(AtomicIntegerArray a, int old) { + for (int i = 0; i*SCALE < ARRLEN; i+=1) { + a.compareAndSet((i*SCALE), old, -123); + } + } + static void test_vi_scl(AtomicIntegerArray a, int b, int old) { + for (int i = 0; i*SCALE < ARRLEN; i+=1) { + a.compareAndSet((i*SCALE), old, b); + } + } + static void test_cp_scl(AtomicIntegerArray a, AtomicIntegerArray b) { + for (int i = 0; i*SCALE < ARRLEN; i+=1) { + a.compareAndSet((i*SCALE), -123, b.get(i*SCALE)); + } + } + static void test_2ci_scl(AtomicIntegerArray a, AtomicIntegerArray b) { + for (int i = 0; i*SCALE < ARRLEN; i+=1) { + a.compareAndSet((i*SCALE), 123, -123); + b.compareAndSet((i*SCALE), 123, -103); + } + } + static void test_2vi_scl(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) { + for (int i = 0; i*SCALE < ARRLEN; i+=1) { + a.compareAndSet((i*SCALE), -123, c); + b.compareAndSet((i*SCALE), -103, d); + } + } + static void test_cp_alndst(AtomicIntegerArray a, AtomicIntegerArray b) { + for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) { + a.compareAndSet((i+ALIGN_OFF), -1, b.get(i)); + } + } + static void test_cp_alnsrc(AtomicIntegerArray a, AtomicIntegerArray b) { + for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) { + a.getAndSet(i, b.get(i+ALIGN_OFF)); + } + } + static void test_2ci_aln(AtomicIntegerArray a, AtomicIntegerArray b) { + for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) { + a.compareAndSet((i+ALIGN_OFF), -1, -123); + b.getAndSet(i, -103); + } + } + static void test_2vi_aln(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) { + for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) { + a.getAndSet(i, c); + b.getAndSet((i+ALIGN_OFF), d); + } + } + static void test_cp_unalndst(AtomicIntegerArray a, AtomicIntegerArray b) { + for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) { + a.compareAndSet((i+UNALIGN_OFF), -1, b.get(i)); + } + } + static void test_cp_unalnsrc(AtomicIntegerArray a, AtomicIntegerArray b) { + for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) { + a.getAndSet(i, b.get(i+UNALIGN_OFF)); + } + } + static void test_2ci_unaln(AtomicIntegerArray a, AtomicIntegerArray b) { + for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) { + a.compareAndSet((i+UNALIGN_OFF), -1, -123); + b.getAndSet(i, -103); + } + } + static void test_2vi_unaln(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) { + for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) { + a.getAndSet(i, c); + b.getAndSet((i+UNALIGN_OFF), d); + } + } + + static int verify(String text, int i, int elem, int val) { + if (elem != val) { + System.err.println(text + "[" + i + "] = " + elem + " != " + val); + return 1; + } + return 0; + } +} diff -r 5741d3fc502d -r 2e4b16122164 test/compiler/8004867/TestIntAtomicOrdered.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/compiler/8004867/TestIntAtomicOrdered.java Thu Feb 21 06:29:43 2013 -0800 @@ -0,0 +1,969 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +/** + * @test + * @bug 8004867 + * @summary VM crashing with assert "share/vm/opto/node.hpp:357 - assert(i < _max) failed: oob" + * + * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:-OptimizeFill TestIntAtomicOrdered + * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:+OptimizeFill TestIntAtomicOrdered + */ + +import java.util.concurrent.atomic.AtomicIntegerArray; + +public class TestIntAtomicOrdered { + private static final int ARRLEN = 97; + private static final int ITERS = 11000; + private static final int OFFSET = 3; + private static final int SCALE = 2; + private static final int ALIGN_OFF = 8; + private static final int UNALIGN_OFF = 5; + + public static void main(String args[]) { + System.out.println("Testing Integer array atomic ordered operations"); + int errn = test(false); + if (errn > 0) { + System.err.println("FAILED: " + errn + " errors"); + System.exit(97); + } + System.out.println("PASSED"); + } + + static int test(boolean test_only) { + AtomicIntegerArray a1 = new AtomicIntegerArray(ARRLEN); + AtomicIntegerArray a2 = new AtomicIntegerArray(ARRLEN); + // Initialize + for (int i=0; i 0 || test_only) + return errn; + + // Initialize + for (int i=0; i= 0; i-=1) { + a.lazySet(i,-123); + } + } + static void test_vi_neg(AtomicIntegerArray a, int b, int old) { + for (int i = ARRLEN-1; i >= 0; i-=1) { + a.lazySet(i, b); + } + } + static void test_cp_neg(AtomicIntegerArray a, AtomicIntegerArray b) { + for (int i = ARRLEN-1; i >= 0; i-=1) { + a.lazySet(i, b.get(i)); + } + } + static void test_2ci_neg(AtomicIntegerArray a, AtomicIntegerArray b) { + for (int i = ARRLEN-1; i >= 0; i-=1) { + a.lazySet(i, -123); + b.lazySet(i, -103); + } + } + static void test_2vi_neg(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) { + for (int i = ARRLEN-1; i >= 0; i-=1) { + a.lazySet(i, c); + b.lazySet(i, d); + } + } + static void test_ci_oppos(AtomicIntegerArray a, int old) { + int limit = ARRLEN-1; + for (int i = 0; i < ARRLEN; i+=1) { + a.lazySet((limit-i), -123); + } + } + static void test_vi_oppos(AtomicIntegerArray a, int b, int old) { + int limit = ARRLEN-1; + for (int i = limit; i >= 0; i-=1) { + a.lazySet((limit-i), b); + } + } + static void test_cp_oppos(AtomicIntegerArray a, AtomicIntegerArray b) { + int limit = ARRLEN-1; + for (int i = 0; i < ARRLEN; i+=1) { + a.lazySet(i, b.get(limit-i)); + } + } + static void test_2ci_oppos(AtomicIntegerArray a, AtomicIntegerArray b) { + int limit = ARRLEN-1; + for (int i = 0; i < ARRLEN; i+=1) { + a.lazySet((limit-i), -123); + b.lazySet(i, -103); + } + } + static void test_2vi_oppos(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) { + int limit = ARRLEN-1; + for (int i = limit; i >= 0; i-=1) { + a.lazySet(i, c); + b.lazySet((limit-i), d); + } + } + static void test_ci_off(AtomicIntegerArray a, int old) { + for (int i = 0; i < ARRLEN-OFFSET; i+=1) { + a.lazySet((i+OFFSET), -123); + } + } + static void test_vi_off(AtomicIntegerArray a, int b, int old) { + for (int i = 0; i < ARRLEN-OFFSET; i+=1) { + a.lazySet((i+OFFSET), b); + } + } + static void test_cp_off(AtomicIntegerArray a, AtomicIntegerArray b) { + for (int i = 0; i < ARRLEN-OFFSET; i+=1) { + a.lazySet((i+OFFSET), b.get(i+OFFSET)); + } + } + static void test_2ci_off(AtomicIntegerArray a, AtomicIntegerArray b) { + for (int i = 0; i < ARRLEN-OFFSET; i+=1) { + a.lazySet((i+OFFSET), -123); + b.lazySet((i+OFFSET), -103); + } + } + static void test_2vi_off(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) { + for (int i = 0; i < ARRLEN-OFFSET; i+=1) { + a.lazySet((i+OFFSET), c); + b.lazySet((i+OFFSET), d); + } + } + static void test_ci_inv(AtomicIntegerArray a, int k, int old) { + for (int i = 0; i < ARRLEN-k; i+=1) { + a.lazySet((i+k),-123); + } + } + static void test_vi_inv(AtomicIntegerArray a, int b, int k, int old) { + for (int i = 0; i < ARRLEN-k; i+=1) { + a.lazySet((i+k), b); + } + } + static void test_cp_inv(AtomicIntegerArray a, AtomicIntegerArray b, int k) { + for (int i = 0; i < ARRLEN-k; i+=1) { + a.lazySet((i+k), b.get(i+k)); + } + } + static void test_2ci_inv(AtomicIntegerArray a, AtomicIntegerArray b, int k) { + for (int i = 0; i < ARRLEN-k; i+=1) { + a.lazySet((i+k), -123); + b.lazySet((i+k), -103); + } + } + static void test_2vi_inv(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d, int k) { + for (int i = 0; i < ARRLEN-k; i+=1) { + a.lazySet((i+k), c); + b.lazySet((i+k), d); + } + } + static void test_ci_scl(AtomicIntegerArray a, int old) { + for (int i = 0; i*SCALE < ARRLEN; i+=1) { + a.lazySet((i*SCALE), -123); + } + } + static void test_vi_scl(AtomicIntegerArray a, int b, int old) { + for (int i = 0; i*SCALE < ARRLEN; i+=1) { + a.lazySet((i*SCALE), b); + } + } + static void test_cp_scl(AtomicIntegerArray a, AtomicIntegerArray b) { + for (int i = 0; i*SCALE < ARRLEN; i+=1) { + a.lazySet((i*SCALE), b.get(i*SCALE)); + } + } + static void test_2ci_scl(AtomicIntegerArray a, AtomicIntegerArray b) { + for (int i = 0; i*SCALE < ARRLEN; i+=1) { + a.lazySet((i*SCALE), -123); + b.lazySet((i*SCALE), -103); + } + } + static void test_2vi_scl(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) { + for (int i = 0; i*SCALE < ARRLEN; i+=1) { + a.lazySet((i*SCALE), c); + b.lazySet((i*SCALE), d); + } + } + static void test_cp_alndst(AtomicIntegerArray a, AtomicIntegerArray b) { + for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) { + a.lazySet((i+ALIGN_OFF), b.get(i)); + } + } + static void test_cp_alnsrc(AtomicIntegerArray a, AtomicIntegerArray b) { + for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) { + a.lazySet(i, b.get(i+ALIGN_OFF)); + } + } + static void test_2ci_aln(AtomicIntegerArray a, AtomicIntegerArray b) { + for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) { + a.lazySet((i+ALIGN_OFF), -123); + b.lazySet(i, -103); + } + } + static void test_2vi_aln(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) { + for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) { + a.lazySet(i, c); + b.lazySet((i+ALIGN_OFF), d); + } + } + static void test_cp_unalndst(AtomicIntegerArray a, AtomicIntegerArray b) { + for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) { + a.lazySet((i+UNALIGN_OFF), b.get(i)); + } + } + static void test_cp_unalnsrc(AtomicIntegerArray a, AtomicIntegerArray b) { + for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) { + a.lazySet(i, b.get(i+UNALIGN_OFF)); + } + } + static void test_2ci_unaln(AtomicIntegerArray a, AtomicIntegerArray b) { + for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) { + a.lazySet((i+UNALIGN_OFF), -123); + b.lazySet(i, -103); + } + } + static void test_2vi_unaln(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) { + for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) { + a.lazySet(i, c); + b.lazySet((i+UNALIGN_OFF), d); + } + } + + static int verify(String text, int i, int elem, int val) { + if (elem != val) { + System.err.println(text + "[" + i + "] = " + elem + " != " + val); + return 1; + } + return 0; + } +} diff -r 5741d3fc502d -r 2e4b16122164 test/compiler/8004867/TestIntAtomicVolatile.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/compiler/8004867/TestIntAtomicVolatile.java Thu Feb 21 06:29:43 2013 -0800 @@ -0,0 +1,969 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +/** + * @test + * @bug 8004867 + * @summary VM crashing with assert "share/vm/opto/node.hpp:357 - assert(i < _max) failed: oob" + * + * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:-OptimizeFill TestIntAtomicVolatile + * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:+OptimizeFill TestIntAtomicVolatile + */ + +import java.util.concurrent.atomic.AtomicIntegerArray; + +public class TestIntAtomicVolatile { + private static final int ARRLEN = 97; + private static final int ITERS = 11000; + private static final int OFFSET = 3; + private static final int SCALE = 2; + private static final int ALIGN_OFF = 8; + private static final int UNALIGN_OFF = 5; + + public static void main(String args[]) { + System.out.println("Testing Integer array atomic volatile operations"); + int errn = test(false); + if (errn > 0) { + System.err.println("FAILED: " + errn + " errors"); + System.exit(97); + } + System.out.println("PASSED"); + } + + static int test(boolean test_only) { + AtomicIntegerArray a1 = new AtomicIntegerArray(ARRLEN); + AtomicIntegerArray a2 = new AtomicIntegerArray(ARRLEN); + // Initialize + for (int i=0; i 0 || test_only) + return errn; + + // Initialize + for (int i=0; i= 0; i-=1) { + a.set(i,-123); + } + } + static void test_vi_neg(AtomicIntegerArray a, int b, int old) { + for (int i = ARRLEN-1; i >= 0; i-=1) { + a.set(i, b); + } + } + static void test_cp_neg(AtomicIntegerArray a, AtomicIntegerArray b) { + for (int i = ARRLEN-1; i >= 0; i-=1) { + a.set(i, b.get(i)); + } + } + static void test_2ci_neg(AtomicIntegerArray a, AtomicIntegerArray b) { + for (int i = ARRLEN-1; i >= 0; i-=1) { + a.set(i, -123); + b.set(i, -103); + } + } + static void test_2vi_neg(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) { + for (int i = ARRLEN-1; i >= 0; i-=1) { + a.set(i, c); + b.set(i, d); + } + } + static void test_ci_oppos(AtomicIntegerArray a, int old) { + int limit = ARRLEN-1; + for (int i = 0; i < ARRLEN; i+=1) { + a.set((limit-i), -123); + } + } + static void test_vi_oppos(AtomicIntegerArray a, int b, int old) { + int limit = ARRLEN-1; + for (int i = limit; i >= 0; i-=1) { + a.set((limit-i), b); + } + } + static void test_cp_oppos(AtomicIntegerArray a, AtomicIntegerArray b) { + int limit = ARRLEN-1; + for (int i = 0; i < ARRLEN; i+=1) { + a.set(i, b.get(limit-i)); + } + } + static void test_2ci_oppos(AtomicIntegerArray a, AtomicIntegerArray b) { + int limit = ARRLEN-1; + for (int i = 0; i < ARRLEN; i+=1) { + a.set((limit-i), -123); + b.set(i, -103); + } + } + static void test_2vi_oppos(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) { + int limit = ARRLEN-1; + for (int i = limit; i >= 0; i-=1) { + a.set(i, c); + b.set((limit-i), d); + } + } + static void test_ci_off(AtomicIntegerArray a, int old) { + for (int i = 0; i < ARRLEN-OFFSET; i+=1) { + a.set((i+OFFSET), -123); + } + } + static void test_vi_off(AtomicIntegerArray a, int b, int old) { + for (int i = 0; i < ARRLEN-OFFSET; i+=1) { + a.set((i+OFFSET), b); + } + } + static void test_cp_off(AtomicIntegerArray a, AtomicIntegerArray b) { + for (int i = 0; i < ARRLEN-OFFSET; i+=1) { + a.set((i+OFFSET), b.get(i+OFFSET)); + } + } + static void test_2ci_off(AtomicIntegerArray a, AtomicIntegerArray b) { + for (int i = 0; i < ARRLEN-OFFSET; i+=1) { + a.set((i+OFFSET), -123); + b.set((i+OFFSET), -103); + } + } + static void test_2vi_off(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) { + for (int i = 0; i < ARRLEN-OFFSET; i+=1) { + a.set((i+OFFSET), c); + b.set((i+OFFSET), d); + } + } + static void test_ci_inv(AtomicIntegerArray a, int k, int old) { + for (int i = 0; i < ARRLEN-k; i+=1) { + a.set((i+k),-123); + } + } + static void test_vi_inv(AtomicIntegerArray a, int b, int k, int old) { + for (int i = 0; i < ARRLEN-k; i+=1) { + a.set((i+k), b); + } + } + static void test_cp_inv(AtomicIntegerArray a, AtomicIntegerArray b, int k) { + for (int i = 0; i < ARRLEN-k; i+=1) { + a.set((i+k), b.get(i+k)); + } + } + static void test_2ci_inv(AtomicIntegerArray a, AtomicIntegerArray b, int k) { + for (int i = 0; i < ARRLEN-k; i+=1) { + a.set((i+k), -123); + b.set((i+k), -103); + } + } + static void test_2vi_inv(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d, int k) { + for (int i = 0; i < ARRLEN-k; i+=1) { + a.set((i+k), c); + b.set((i+k), d); + } + } + static void test_ci_scl(AtomicIntegerArray a, int old) { + for (int i = 0; i*SCALE < ARRLEN; i+=1) { + a.set((i*SCALE), -123); + } + } + static void test_vi_scl(AtomicIntegerArray a, int b, int old) { + for (int i = 0; i*SCALE < ARRLEN; i+=1) { + a.set((i*SCALE), b); + } + } + static void test_cp_scl(AtomicIntegerArray a, AtomicIntegerArray b) { + for (int i = 0; i*SCALE < ARRLEN; i+=1) { + a.set((i*SCALE), b.get(i*SCALE)); + } + } + static void test_2ci_scl(AtomicIntegerArray a, AtomicIntegerArray b) { + for (int i = 0; i*SCALE < ARRLEN; i+=1) { + a.set((i*SCALE), -123); + b.set((i*SCALE), -103); + } + } + static void test_2vi_scl(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) { + for (int i = 0; i*SCALE < ARRLEN; i+=1) { + a.set((i*SCALE), c); + b.set((i*SCALE), d); + } + } + static void test_cp_alndst(AtomicIntegerArray a, AtomicIntegerArray b) { + for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) { + a.set((i+ALIGN_OFF), b.get(i)); + } + } + static void test_cp_alnsrc(AtomicIntegerArray a, AtomicIntegerArray b) { + for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) { + a.set(i, b.get(i+ALIGN_OFF)); + } + } + static void test_2ci_aln(AtomicIntegerArray a, AtomicIntegerArray b) { + for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) { + a.set((i+ALIGN_OFF), -123); + b.set(i, -103); + } + } + static void test_2vi_aln(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) { + for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) { + a.set(i, c); + b.set((i+ALIGN_OFF), d); + } + } + static void test_cp_unalndst(AtomicIntegerArray a, AtomicIntegerArray b) { + for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) { + a.set((i+UNALIGN_OFF), b.get(i)); + } + } + static void test_cp_unalnsrc(AtomicIntegerArray a, AtomicIntegerArray b) { + for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) { + a.set(i, b.get(i+UNALIGN_OFF)); + } + } + static void test_2ci_unaln(AtomicIntegerArray a, AtomicIntegerArray b) { + for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) { + a.set((i+UNALIGN_OFF), -123); + b.set(i, -103); + } + } + static void test_2vi_unaln(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) { + for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) { + a.set(i, c); + b.set((i+UNALIGN_OFF), d); + } + } + + static int verify(String text, int i, int elem, int val) { + if (elem != val) { + System.err.println(text + "[" + i + "] = " + elem + " != " + val); + return 1; + } + return 0; + } +} diff -r 5741d3fc502d -r 2e4b16122164 test/compiler/8004867/TestIntUnsafeCAS.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/compiler/8004867/TestIntUnsafeCAS.java Thu Feb 21 06:29:43 2013 -0800 @@ -0,0 +1,998 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +/** + * @test + * @bug 8004867 + * @summary VM crashing with assert "share/vm/opto/node.hpp:357 - assert(i < _max) failed: oob" + * + * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:-OptimizeFill TestIntUnsafeCAS + * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:+OptimizeFill TestIntUnsafeCAS + */ + +import sun.misc.Unsafe; +import java.lang.reflect.*; + +public class TestIntUnsafeCAS { + private static final int ARRLEN = 97; + private static final int ITERS = 11000; + private static final int OFFSET = 3; + private static final int SCALE = 2; + private static final int ALIGN_OFF = 8; + private static final int UNALIGN_OFF = 5; + + private static final Unsafe unsafe; + private static final int BASE; + static { + try { + Class c = TestIntUnsafeCAS.class.getClassLoader().loadClass("sun.misc.Unsafe"); + Field f = c.getDeclaredField("theUnsafe"); + f.setAccessible(true); + unsafe = (Unsafe)f.get(c); + BASE = unsafe.arrayBaseOffset(int[].class); + } catch (Exception e) { + InternalError err = new InternalError(); + err.initCause(e); + throw err; + } + } + + public static void main(String args[]) { + System.out.println("Testing Integer array unsafe CAS operations"); + int errn = test(false); + if (errn > 0) { + System.err.println("FAILED: " + errn + " errors"); + System.exit(97); + } + System.out.println("PASSED"); + } + + static int test(boolean test_only) { + int[] a1 = new int[ARRLEN]; + int[] a2 = new int[ARRLEN]; + // Initialize + for (int i=0; i 0 || test_only) + return errn; + + // Initialize + for (int i=0; i= 0; i-=1) { + unsafe.compareAndSwapInt(a, byte_offset(i), old, -123); + } + } + static void test_vi_neg(int[] a, int b, int old) { + for (int i = ARRLEN-1; i >= 0; i-=1) { + unsafe.compareAndSwapInt(a, byte_offset(i), old, b); + } + } + static void test_cp_neg(int[] a, int[] b) { + for (int i = ARRLEN-1; i >= 0; i-=1) { + unsafe.compareAndSwapInt(a, byte_offset(i), -123, b[i]); + } + } + static void test_2ci_neg(int[] a, int[] b) { + for (int i = ARRLEN-1; i >= 0; i-=1) { + unsafe.compareAndSwapInt(a, byte_offset(i), 123, -123); + unsafe.compareAndSwapInt(b, byte_offset(i), 123, -103); + } + } + static void test_2vi_neg(int[] a, int[] b, int c, int d) { + for (int i = ARRLEN-1; i >= 0; i-=1) { + unsafe.compareAndSwapInt(a, byte_offset(i), -123, c); + unsafe.compareAndSwapInt(b, byte_offset(i), -103, d); + } + } + static void test_ci_oppos(int[] a, int old) { + int limit = ARRLEN-1; + for (int i = 0; i < ARRLEN; i+=1) { + unsafe.compareAndSwapInt(a, byte_offset(limit-i), old, -123); + } + } + static void test_vi_oppos(int[] a, int b, int old) { + int limit = ARRLEN-1; + for (int i = limit; i >= 0; i-=1) { + unsafe.compareAndSwapInt(a, byte_offset(limit-i), old, b); + } + } + static void test_cp_oppos(int[] a, int[] b) { + int limit = ARRLEN-1; + for (int i = 0; i < ARRLEN; i+=1) { + unsafe.compareAndSwapInt(a, byte_offset(i), -123, b[limit-i]); + } + } + static void test_2ci_oppos(int[] a, int[] b) { + int limit = ARRLEN-1; + for (int i = 0; i < ARRLEN; i+=1) { + unsafe.compareAndSwapInt(a, byte_offset(limit-i), 123, -123); + unsafe.compareAndSwapInt(b, byte_offset(i), 123, -103); + } + } + static void test_2vi_oppos(int[] a, int[] b, int c, int d) { + int limit = ARRLEN-1; + for (int i = limit; i >= 0; i-=1) { + unsafe.compareAndSwapInt(a, byte_offset(i), -123, c); + unsafe.compareAndSwapInt(b, byte_offset(limit-i), -103, d); + } + } + static void test_ci_off(int[] a, int old) { + for (int i = 0; i < ARRLEN-OFFSET; i+=1) { + unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), old, -123); + } + } + static void test_vi_off(int[] a, int b, int old) { + for (int i = 0; i < ARRLEN-OFFSET; i+=1) { + unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), old, b); + } + } + static void test_cp_off(int[] a, int[] b) { + for (int i = 0; i < ARRLEN-OFFSET; i+=1) { + unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), -123, b[i+OFFSET]); + } + } + static void test_2ci_off(int[] a, int[] b) { + for (int i = 0; i < ARRLEN-OFFSET; i+=1) { + unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), 123, -123); + unsafe.compareAndSwapInt(b, byte_offset(i+OFFSET), 123, -103); + } + } + static void test_2vi_off(int[] a, int[] b, int c, int d) { + for (int i = 0; i < ARRLEN-OFFSET; i+=1) { + unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), -123, c); + unsafe.compareAndSwapInt(b, byte_offset(i+OFFSET), -103, d); + } + } + static void test_ci_inv(int[] a, int k, int old) { + for (int i = 0; i < ARRLEN-k; i+=1) { + unsafe.compareAndSwapInt(a, byte_offset(i+k), old, -123); + } + } + static void test_vi_inv(int[] a, int b, int k, int old) { + for (int i = 0; i < ARRLEN-k; i+=1) { + unsafe.compareAndSwapInt(a, byte_offset(i+k), old, b); + } + } + static void test_cp_inv(int[] a, int[] b, int k) { + for (int i = 0; i < ARRLEN-k; i+=1) { + unsafe.compareAndSwapInt(a, byte_offset(i+k), -123, b[i+k]); + } + } + static void test_2ci_inv(int[] a, int[] b, int k) { + for (int i = 0; i < ARRLEN-k; i+=1) { + unsafe.compareAndSwapInt(a, byte_offset(i+k), 123, -123); + unsafe.compareAndSwapInt(b, byte_offset(i+k), 123, -103); + } + } + static void test_2vi_inv(int[] a, int[] b, int c, int d, int k) { + for (int i = 0; i < ARRLEN-k; i+=1) { + unsafe.compareAndSwapInt(a, byte_offset(i+k), -123, c); + unsafe.compareAndSwapInt(b, byte_offset(i+k), -103, d); + } + } + static void test_ci_scl(int[] a, int old) { + for (int i = 0; i*SCALE < ARRLEN; i+=1) { + unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), old, -123); + } + } + static void test_vi_scl(int[] a, int b, int old) { + for (int i = 0; i*SCALE < ARRLEN; i+=1) { + unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), old, b); + } + } + static void test_cp_scl(int[] a, int[] b) { + for (int i = 0; i*SCALE < ARRLEN; i+=1) { + unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), -123, b[i*SCALE]); + } + } + static void test_2ci_scl(int[] a, int[] b) { + for (int i = 0; i*SCALE < ARRLEN; i+=1) { + unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), 123, -123); + unsafe.compareAndSwapInt(b, byte_offset(i*SCALE), 123, -103); + } + } + static void test_2vi_scl(int[] a, int[] b, int c, int d) { + for (int i = 0; i*SCALE < ARRLEN; i+=1) { + unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), -123, c); + unsafe.compareAndSwapInt(b, byte_offset(i*SCALE), -103, d); + } + } + static void test_cp_alndst(int[] a, int[] b) { + for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) { + unsafe.compareAndSwapInt(a, byte_offset(i+ALIGN_OFF), -1, b[i]); + } + } + static void test_cp_alnsrc(int[] a, int[] b) { + for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) { + int old = unsafe.getIntVolatile(a, byte_offset(i)); + unsafe.compareAndSwapInt(a, byte_offset(i), old, b[i+ALIGN_OFF]); + } + } + static void test_2ci_aln(int[] a, int[] b) { + for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) { + unsafe.compareAndSwapInt(a, byte_offset(i+ALIGN_OFF), -1, -123); + int old = unsafe.getIntVolatile(b, byte_offset(i)); + unsafe.compareAndSwapInt(b, byte_offset(i), old, -103); + } + } + static void test_2vi_aln(int[] a, int[] b, int c, int d) { + for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) { + int old = unsafe.getIntVolatile(a, byte_offset(i)); + unsafe.compareAndSwapInt(a, byte_offset(i), old, c); + old = unsafe.getIntVolatile(b, byte_offset(i+ALIGN_OFF)); + unsafe.compareAndSwapInt(b, byte_offset(i+ALIGN_OFF), old, d); + } + } + static void test_cp_unalndst(int[] a, int[] b) { + for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) { + unsafe.compareAndSwapInt(a, byte_offset(i+UNALIGN_OFF), -1, b[i]); + } + } + static void test_cp_unalnsrc(int[] a, int[] b) { + for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) { + int old = unsafe.getIntVolatile(a, byte_offset(i)); + unsafe.compareAndSwapInt(a, byte_offset(i), old, b[i+UNALIGN_OFF]); + } + } + static void test_2ci_unaln(int[] a, int[] b) { + for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) { + unsafe.compareAndSwapInt(a, byte_offset(i+UNALIGN_OFF), -1, -123); + int old = unsafe.getIntVolatile(b, byte_offset(i)); + unsafe.compareAndSwapInt(b, byte_offset(i), old, -103); + } + } + static void test_2vi_unaln(int[] a, int[] b, int c, int d) { + for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) { + int old = unsafe.getIntVolatile(a, byte_offset(i)); + unsafe.compareAndSwapInt(a, byte_offset(i), old, c); + old = unsafe.getIntVolatile(b, byte_offset(i+UNALIGN_OFF)); + unsafe.compareAndSwapInt(b, byte_offset(i+UNALIGN_OFF), old, d); + } + } + + static int verify(String text, int i, int elem, int val) { + if (elem != val) { + System.err.println(text + "[" + i + "] = " + elem + " != " + val); + return 1; + } + return 0; + } +} diff -r 5741d3fc502d -r 2e4b16122164 test/compiler/8004867/TestIntUnsafeOrdered.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/compiler/8004867/TestIntUnsafeOrdered.java Thu Feb 21 06:29:43 2013 -0800 @@ -0,0 +1,990 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +/** + * @test + * @bug 8004867 + * @summary VM crashing with assert "share/vm/opto/node.hpp:357 - assert(i < _max) failed: oob" + * + * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:-OptimizeFill TestIntUnsafeOrdered + * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:+OptimizeFill TestIntUnsafeOrdered + */ + +import sun.misc.Unsafe; +import java.lang.reflect.*; + +public class TestIntUnsafeOrdered { + private static final int ARRLEN = 97; + private static final int ITERS = 11000; + private static final int OFFSET = 3; + private static final int SCALE = 2; + private static final int ALIGN_OFF = 8; + private static final int UNALIGN_OFF = 5; + + private static final Unsafe unsafe; + private static final int BASE; + static { + try { + Class c = TestIntUnsafeOrdered.class.getClassLoader().loadClass("sun.misc.Unsafe"); + Field f = c.getDeclaredField("theUnsafe"); + f.setAccessible(true); + unsafe = (Unsafe)f.get(c); + BASE = unsafe.arrayBaseOffset(int[].class); + } catch (Exception e) { + InternalError err = new InternalError(); + err.initCause(e); + throw err; + } + } + + public static void main(String args[]) { + System.out.println("Testing Integer array unsafe ordered operations"); + int errn = test(false); + if (errn > 0) { + System.err.println("FAILED: " + errn + " errors"); + System.exit(97); + } + System.out.println("PASSED"); + } + + static int test(boolean test_only) { + int[] a1 = new int[ARRLEN]; + int[] a2 = new int[ARRLEN]; + // Initialize + for (int i=0; i 0 || test_only) + return errn; + + // Initialize + for (int i=0; i= 0; i-=1) { + unsafe.putOrderedInt(a, byte_offset(i), -123); + } + } + static void test_vi_neg(int[] a, int b, int old) { + for (int i = ARRLEN-1; i >= 0; i-=1) { + unsafe.putOrderedInt(a, byte_offset(i), b); + } + } + static void test_cp_neg(int[] a, int[] b) { + for (int i = ARRLEN-1; i >= 0; i-=1) { + unsafe.putOrderedInt(a, byte_offset(i), b[i]); + } + } + static void test_2ci_neg(int[] a, int[] b) { + for (int i = ARRLEN-1; i >= 0; i-=1) { + unsafe.putOrderedInt(a, byte_offset(i), -123); + unsafe.putOrderedInt(b, byte_offset(i), -103); + } + } + static void test_2vi_neg(int[] a, int[] b, int c, int d) { + for (int i = ARRLEN-1; i >= 0; i-=1) { + unsafe.putOrderedInt(a, byte_offset(i), c); + unsafe.putOrderedInt(b, byte_offset(i), d); + } + } + static void test_ci_oppos(int[] a, int old) { + int limit = ARRLEN-1; + for (int i = 0; i < ARRLEN; i+=1) { + unsafe.putOrderedInt(a, byte_offset(limit-i), -123); + } + } + static void test_vi_oppos(int[] a, int b, int old) { + int limit = ARRLEN-1; + for (int i = limit; i >= 0; i-=1) { + unsafe.putOrderedInt(a, byte_offset(limit-i), b); + } + } + static void test_cp_oppos(int[] a, int[] b) { + int limit = ARRLEN-1; + for (int i = 0; i < ARRLEN; i+=1) { + unsafe.putOrderedInt(a, byte_offset(i), b[limit-i]); + } + } + static void test_2ci_oppos(int[] a, int[] b) { + int limit = ARRLEN-1; + for (int i = 0; i < ARRLEN; i+=1) { + unsafe.putOrderedInt(a, byte_offset(limit-i), -123); + unsafe.putOrderedInt(b, byte_offset(i), -103); + } + } + static void test_2vi_oppos(int[] a, int[] b, int c, int d) { + int limit = ARRLEN-1; + for (int i = limit; i >= 0; i-=1) { + unsafe.putOrderedInt(a, byte_offset(i), c); + unsafe.putOrderedInt(b, byte_offset(limit-i), d); + } + } + static void test_ci_off(int[] a, int old) { + for (int i = 0; i < ARRLEN-OFFSET; i+=1) { + unsafe.putOrderedInt(a, byte_offset(i+OFFSET), -123); + } + } + static void test_vi_off(int[] a, int b, int old) { + for (int i = 0; i < ARRLEN-OFFSET; i+=1) { + unsafe.putOrderedInt(a, byte_offset(i+OFFSET), b); + } + } + static void test_cp_off(int[] a, int[] b) { + for (int i = 0; i < ARRLEN-OFFSET; i+=1) { + unsafe.putOrderedInt(a, byte_offset(i+OFFSET), b[i+OFFSET]); + } + } + static void test_2ci_off(int[] a, int[] b) { + for (int i = 0; i < ARRLEN-OFFSET; i+=1) { + unsafe.putOrderedInt(a, byte_offset(i+OFFSET), -123); + unsafe.putOrderedInt(b, byte_offset(i+OFFSET), -103); + } + } + static void test_2vi_off(int[] a, int[] b, int c, int d) { + for (int i = 0; i < ARRLEN-OFFSET; i+=1) { + unsafe.putOrderedInt(a, byte_offset(i+OFFSET), c); + unsafe.putOrderedInt(b, byte_offset(i+OFFSET), d); + } + } + static void test_ci_inv(int[] a, int k, int old) { + for (int i = 0; i < ARRLEN-k; i+=1) { + unsafe.putOrderedInt(a, byte_offset(i+k), -123); + } + } + static void test_vi_inv(int[] a, int b, int k, int old) { + for (int i = 0; i < ARRLEN-k; i+=1) { + unsafe.putOrderedInt(a, byte_offset(i+k), b); + } + } + static void test_cp_inv(int[] a, int[] b, int k) { + for (int i = 0; i < ARRLEN-k; i+=1) { + unsafe.putOrderedInt(a, byte_offset(i+k), b[i+k]); + } + } + static void test_2ci_inv(int[] a, int[] b, int k) { + for (int i = 0; i < ARRLEN-k; i+=1) { + unsafe.putOrderedInt(a, byte_offset(i+k), -123); + unsafe.putOrderedInt(b, byte_offset(i+k), -103); + } + } + static void test_2vi_inv(int[] a, int[] b, int c, int d, int k) { + for (int i = 0; i < ARRLEN-k; i+=1) { + unsafe.putOrderedInt(a, byte_offset(i+k), c); + unsafe.putOrderedInt(b, byte_offset(i+k), d); + } + } + static void test_ci_scl(int[] a, int old) { + for (int i = 0; i*SCALE < ARRLEN; i+=1) { + unsafe.putOrderedInt(a, byte_offset(i*SCALE), -123); + } + } + static void test_vi_scl(int[] a, int b, int old) { + for (int i = 0; i*SCALE < ARRLEN; i+=1) { + unsafe.putOrderedInt(a, byte_offset(i*SCALE), b); + } + } + static void test_cp_scl(int[] a, int[] b) { + for (int i = 0; i*SCALE < ARRLEN; i+=1) { + unsafe.putOrderedInt(a, byte_offset(i*SCALE), b[i*SCALE]); + } + } + static void test_2ci_scl(int[] a, int[] b) { + for (int i = 0; i*SCALE < ARRLEN; i+=1) { + unsafe.putOrderedInt(a, byte_offset(i*SCALE), -123); + unsafe.putOrderedInt(b, byte_offset(i*SCALE), -103); + } + } + static void test_2vi_scl(int[] a, int[] b, int c, int d) { + for (int i = 0; i*SCALE < ARRLEN; i+=1) { + unsafe.putOrderedInt(a, byte_offset(i*SCALE), c); + unsafe.putOrderedInt(b, byte_offset(i*SCALE), d); + } + } + static void test_cp_alndst(int[] a, int[] b) { + for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) { + unsafe.putOrderedInt(a, byte_offset(i+ALIGN_OFF), b[i]); + } + } + static void test_cp_alnsrc(int[] a, int[] b) { + for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) { + unsafe.putOrderedInt(a, byte_offset(i), b[i+ALIGN_OFF]); + } + } + static void test_2ci_aln(int[] a, int[] b) { + for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) { + unsafe.putOrderedInt(a, byte_offset(i+ALIGN_OFF), -123); + unsafe.putOrderedInt(b, byte_offset(i), -103); + } + } + static void test_2vi_aln(int[] a, int[] b, int c, int d) { + for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) { + unsafe.putOrderedInt(a, byte_offset(i), c); + unsafe.putOrderedInt(b, byte_offset(i+ALIGN_OFF), d); + } + } + static void test_cp_unalndst(int[] a, int[] b) { + for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) { + unsafe.putOrderedInt(a, byte_offset(i+UNALIGN_OFF), b[i]); + } + } + static void test_cp_unalnsrc(int[] a, int[] b) { + for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) { + unsafe.putOrderedInt(a, byte_offset(i), b[i+UNALIGN_OFF]); + } + } + static void test_2ci_unaln(int[] a, int[] b) { + for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) { + unsafe.putOrderedInt(a, byte_offset(i+UNALIGN_OFF), -123); + unsafe.putOrderedInt(b, byte_offset(i), -103); + } + } + static void test_2vi_unaln(int[] a, int[] b, int c, int d) { + for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) { + unsafe.putOrderedInt(a, byte_offset(i), c); + unsafe.putOrderedInt(b, byte_offset(i+UNALIGN_OFF), d); + } + } + + static int verify(String text, int i, int elem, int val) { + if (elem != val) { + System.err.println(text + "[" + i + "] = " + elem + " != " + val); + return 1; + } + return 0; + } +} diff -r 5741d3fc502d -r 2e4b16122164 test/compiler/8004867/TestIntUnsafeVolatile.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/compiler/8004867/TestIntUnsafeVolatile.java Thu Feb 21 06:29:43 2013 -0800 @@ -0,0 +1,990 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +/** + * @test + * @bug 8004867 + * @summary VM crashing with assert "share/vm/opto/node.hpp:357 - assert(i < _max) failed: oob" + * + * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:-OptimizeFill TestIntUnsafeVolatile + * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:+OptimizeFill TestIntUnsafeVolatile + */ + +import sun.misc.Unsafe; +import java.lang.reflect.*; + +public class TestIntUnsafeVolatile { + private static final int ARRLEN = 97; + private static final int ITERS = 11000; + private static final int OFFSET = 3; + private static final int SCALE = 2; + private static final int ALIGN_OFF = 8; + private static final int UNALIGN_OFF = 5; + + private static final Unsafe unsafe; + private static final int BASE; + static { + try { + Class c = TestIntUnsafeVolatile.class.getClassLoader().loadClass("sun.misc.Unsafe"); + Field f = c.getDeclaredField("theUnsafe"); + f.setAccessible(true); + unsafe = (Unsafe)f.get(c); + BASE = unsafe.arrayBaseOffset(int[].class); + } catch (Exception e) { + InternalError err = new InternalError(); + err.initCause(e); + throw err; + } + } + + public static void main(String args[]) { + System.out.println("Testing Integer array unsafe volatile operations"); + int errn = test(false); + if (errn > 0) { + System.err.println("FAILED: " + errn + " errors"); + System.exit(97); + } + System.out.println("PASSED"); + } + + static int test(boolean test_only) { + int[] a1 = new int[ARRLEN]; + int[] a2 = new int[ARRLEN]; + // Initialize + for (int i=0; i 0 || test_only) + return errn; + + // Initialize + for (int i=0; i= 0; i-=1) { + unsafe.putIntVolatile(a, byte_offset(i), -123); + } + } + static void test_vi_neg(int[] a, int b, int old) { + for (int i = ARRLEN-1; i >= 0; i-=1) { + unsafe.putIntVolatile(a, byte_offset(i), b); + } + } + static void test_cp_neg(int[] a, int[] b) { + for (int i = ARRLEN-1; i >= 0; i-=1) { + unsafe.putIntVolatile(a, byte_offset(i), b[i]); + } + } + static void test_2ci_neg(int[] a, int[] b) { + for (int i = ARRLEN-1; i >= 0; i-=1) { + unsafe.putIntVolatile(a, byte_offset(i), -123); + unsafe.putIntVolatile(b, byte_offset(i), -103); + } + } + static void test_2vi_neg(int[] a, int[] b, int c, int d) { + for (int i = ARRLEN-1; i >= 0; i-=1) { + unsafe.putIntVolatile(a, byte_offset(i), c); + unsafe.putIntVolatile(b, byte_offset(i), d); + } + } + static void test_ci_oppos(int[] a, int old) { + int limit = ARRLEN-1; + for (int i = 0; i < ARRLEN; i+=1) { + unsafe.putIntVolatile(a, byte_offset(limit-i), -123); + } + } + static void test_vi_oppos(int[] a, int b, int old) { + int limit = ARRLEN-1; + for (int i = limit; i >= 0; i-=1) { + unsafe.putIntVolatile(a, byte_offset(limit-i), b); + } + } + static void test_cp_oppos(int[] a, int[] b) { + int limit = ARRLEN-1; + for (int i = 0; i < ARRLEN; i+=1) { + unsafe.putIntVolatile(a, byte_offset(i), b[limit-i]); + } + } + static void test_2ci_oppos(int[] a, int[] b) { + int limit = ARRLEN-1; + for (int i = 0; i < ARRLEN; i+=1) { + unsafe.putIntVolatile(a, byte_offset(limit-i), -123); + unsafe.putIntVolatile(b, byte_offset(i), -103); + } + } + static void test_2vi_oppos(int[] a, int[] b, int c, int d) { + int limit = ARRLEN-1; + for (int i = limit; i >= 0; i-=1) { + unsafe.putIntVolatile(a, byte_offset(i), c); + unsafe.putIntVolatile(b, byte_offset(limit-i), d); + } + } + static void test_ci_off(int[] a, int old) { + for (int i = 0; i < ARRLEN-OFFSET; i+=1) { + unsafe.putIntVolatile(a, byte_offset(i+OFFSET), -123); + } + } + static void test_vi_off(int[] a, int b, int old) { + for (int i = 0; i < ARRLEN-OFFSET; i+=1) { + unsafe.putIntVolatile(a, byte_offset(i+OFFSET), b); + } + } + static void test_cp_off(int[] a, int[] b) { + for (int i = 0; i < ARRLEN-OFFSET; i+=1) { + unsafe.putIntVolatile(a, byte_offset(i+OFFSET), b[i+OFFSET]); + } + } + static void test_2ci_off(int[] a, int[] b) { + for (int i = 0; i < ARRLEN-OFFSET; i+=1) { + unsafe.putIntVolatile(a, byte_offset(i+OFFSET), -123); + unsafe.putIntVolatile(b, byte_offset(i+OFFSET), -103); + } + } + static void test_2vi_off(int[] a, int[] b, int c, int d) { + for (int i = 0; i < ARRLEN-OFFSET; i+=1) { + unsafe.putIntVolatile(a, byte_offset(i+OFFSET), c); + unsafe.putIntVolatile(b, byte_offset(i+OFFSET), d); + } + } + static void test_ci_inv(int[] a, int k, int old) { + for (int i = 0; i < ARRLEN-k; i+=1) { + unsafe.putIntVolatile(a, byte_offset(i+k), -123); + } + } + static void test_vi_inv(int[] a, int b, int k, int old) { + for (int i = 0; i < ARRLEN-k; i+=1) { + unsafe.putIntVolatile(a, byte_offset(i+k), b); + } + } + static void test_cp_inv(int[] a, int[] b, int k) { + for (int i = 0; i < ARRLEN-k; i+=1) { + unsafe.putIntVolatile(a, byte_offset(i+k), b[i+k]); + } + } + static void test_2ci_inv(int[] a, int[] b, int k) { + for (int i = 0; i < ARRLEN-k; i+=1) { + unsafe.putIntVolatile(a, byte_offset(i+k), -123); + unsafe.putIntVolatile(b, byte_offset(i+k), -103); + } + } + static void test_2vi_inv(int[] a, int[] b, int c, int d, int k) { + for (int i = 0; i < ARRLEN-k; i+=1) { + unsafe.putIntVolatile(a, byte_offset(i+k), c); + unsafe.putIntVolatile(b, byte_offset(i+k), d); + } + } + static void test_ci_scl(int[] a, int old) { + for (int i = 0; i*SCALE < ARRLEN; i+=1) { + unsafe.putIntVolatile(a, byte_offset(i*SCALE), -123); + } + } + static void test_vi_scl(int[] a, int b, int old) { + for (int i = 0; i*SCALE < ARRLEN; i+=1) { + unsafe.putIntVolatile(a, byte_offset(i*SCALE), b); + } + } + static void test_cp_scl(int[] a, int[] b) { + for (int i = 0; i*SCALE < ARRLEN; i+=1) { + unsafe.putIntVolatile(a, byte_offset(i*SCALE), b[i*SCALE]); + } + } + static void test_2ci_scl(int[] a, int[] b) { + for (int i = 0; i*SCALE < ARRLEN; i+=1) { + unsafe.putIntVolatile(a, byte_offset(i*SCALE), -123); + unsafe.putIntVolatile(b, byte_offset(i*SCALE), -103); + } + } + static void test_2vi_scl(int[] a, int[] b, int c, int d) { + for (int i = 0; i*SCALE < ARRLEN; i+=1) { + unsafe.putIntVolatile(a, byte_offset(i*SCALE), c); + unsafe.putIntVolatile(b, byte_offset(i*SCALE), d); + } + } + static void test_cp_alndst(int[] a, int[] b) { + for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) { + unsafe.putIntVolatile(a, byte_offset(i+ALIGN_OFF), b[i]); + } + } + static void test_cp_alnsrc(int[] a, int[] b) { + for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) { + unsafe.putIntVolatile(a, byte_offset(i), b[i+ALIGN_OFF]); + } + } + static void test_2ci_aln(int[] a, int[] b) { + for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) { + unsafe.putIntVolatile(a, byte_offset(i+ALIGN_OFF), -123); + unsafe.putIntVolatile(b, byte_offset(i), -103); + } + } + static void test_2vi_aln(int[] a, int[] b, int c, int d) { + for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) { + unsafe.putIntVolatile(a, byte_offset(i), c); + unsafe.putIntVolatile(b, byte_offset(i+ALIGN_OFF), d); + } + } + static void test_cp_unalndst(int[] a, int[] b) { + for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) { + unsafe.putIntVolatile(a, byte_offset(i+UNALIGN_OFF), b[i]); + } + } + static void test_cp_unalnsrc(int[] a, int[] b) { + for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) { + unsafe.putIntVolatile(a, byte_offset(i), b[i+UNALIGN_OFF]); + } + } + static void test_2ci_unaln(int[] a, int[] b) { + for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) { + unsafe.putIntVolatile(a, byte_offset(i+UNALIGN_OFF), -123); + unsafe.putIntVolatile(b, byte_offset(i), -103); + } + } + static void test_2vi_unaln(int[] a, int[] b, int c, int d) { + for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) { + unsafe.putIntVolatile(a, byte_offset(i), c); + unsafe.putIntVolatile(b, byte_offset(i+UNALIGN_OFF), d); + } + } + + static int verify(String text, int i, int elem, int val) { + if (elem != val) { + System.err.println(text + "[" + i + "] = " + elem + " != " + val); + return 1; + } + return 0; + } +}