aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoramurillo <none@none>2013-02-22 10:02:06 -0800
committeramurillo <none@none>2013-02-22 10:02:06 -0800
commitf95556be259e04b71ea3bc8095e289ffbea5d22e (patch)
tree5a1a42676bce53c8297090471b89d127e1c59746
parent9b5e89efce87e194a6fde59b8cb649f03ce6f869 (diff)
parent63062a2f01015709ce9673b83fb423c6b6845733 (diff)
-rw-r--r--agent/src/os/bsd/MacosxDebuggerLocal.m94
-rw-r--r--agent/src/os/bsd/libproc_impl.c10
-rw-r--r--agent/src/os/bsd/libproc_impl.h3
-rw-r--r--agent/src/os/bsd/ps_proc.c84
-rw-r--r--agent/src/os/linux/libproc_impl.c10
-rw-r--r--agent/src/os/linux/libproc_impl.h3
-rw-r--r--agent/src/os/linux/ps_proc.c94
-rw-r--r--agent/src/share/classes/sun/jvm/hotspot/memory/CMSCollector.java6
-rw-r--r--agent/src/share/classes/sun/jvm/hotspot/memory/CompactibleFreeListSpace.java1
-rw-r--r--agent/src/share/classes/sun/jvm/hotspot/oops/MethodData.java1
-rw-r--r--agent/src/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java1
-rw-r--r--agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java22
-rw-r--r--make/bsd/makefiles/vm.make7
-rw-r--r--make/excludeSrc.make6
-rw-r--r--make/hotspot_version2
-rw-r--r--make/linux/makefiles/vm.make8
-rw-r--r--make/solaris/makefiles/vm.make8
-rw-r--r--src/os/bsd/vm/os_bsd.cpp2
-rw-r--r--src/os/linux/vm/os_linux.cpp2
-rw-r--r--src/os/solaris/vm/os_solaris.cpp4
-rw-r--r--src/os/windows/vm/os_windows.cpp11
-rw-r--r--src/share/vm/c1/c1_LIR.cpp2
-rw-r--r--src/share/vm/classfile/verifier.cpp10
-rw-r--r--src/share/vm/memory/collectorPolicy.cpp4
-rw-r--r--src/share/vm/oops/method.hpp2
-rw-r--r--src/share/vm/opto/library_call.cpp14
-rw-r--r--src/share/vm/opto/subnode.hpp30
-rw-r--r--src/share/vm/opto/superword.cpp17
-rw-r--r--src/share/vm/opto/superword.hpp2
-rw-r--r--src/share/vm/prims/jvmtiRedefineClasses.cpp12
-rw-r--r--src/share/vm/runtime/arguments.cpp64
-rw-r--r--src/share/vm/runtime/vmStructs.cpp2
-rw-r--r--src/share/vm/utilities/yieldingWorkgroup.cpp2
-rw-r--r--test/TEST.ROOT2
-rw-r--r--test/compiler/5091921/Test6850611.java4
-rw-r--r--test/compiler/5091921/Test6890943.java4
-rw-r--r--test/compiler/5091921/Test6890943.sh7
-rw-r--r--test/compiler/5091921/Test6905845.java4
-rw-r--r--test/compiler/5091921/Test6992759.java4
-rw-r--r--test/compiler/8004867/TestIntAtomicCAS.java969
-rw-r--r--test/compiler/8004867/TestIntAtomicOrdered.java969
-rw-r--r--test/compiler/8004867/TestIntAtomicVolatile.java969
-rw-r--r--test/compiler/8004867/TestIntUnsafeCAS.java998
-rw-r--r--test/compiler/8004867/TestIntUnsafeOrdered.java990
-rw-r--r--test/compiler/8004867/TestIntUnsafeVolatile.java990
-rw-r--r--test/gc/8000311/Test8000311.java42
-rw-r--r--test/gc/TestG1ZeroPGCTJcmdThreadPrint.java54
-rw-r--r--test/gc/startup_warnings/TestCMS.java46
-rw-r--r--test/gc/startup_warnings/TestCMSIncrementalMode.java46
-rw-r--r--test/gc/startup_warnings/TestCMSNoIncrementalMode.java45
-rw-r--r--test/gc/startup_warnings/TestDefNewCMS.java45
-rw-r--r--test/gc/startup_warnings/TestG1.java45
-rw-r--r--test/gc/startup_warnings/TestIncGC.java46
-rw-r--r--test/gc/startup_warnings/TestParNewCMS.java46
-rw-r--r--test/gc/startup_warnings/TestParNewSerialOld.java46
-rw-r--r--test/gc/startup_warnings/TestParallelGC.java46
-rw-r--r--test/gc/startup_warnings/TestParallelScavengeSerialOld.java46
-rw-r--r--test/gc/startup_warnings/TestSerialGC.java46
-rw-r--r--test/runtime/8007736/TestStaticIF.java44
59 files changed, 6924 insertions, 169 deletions
diff --git a/agent/src/os/bsd/MacosxDebuggerLocal.m b/agent/src/os/bsd/MacosxDebuggerLocal.m
index 2f064a986..98ace91a2 100644
--- a/agent/src/os/bsd/MacosxDebuggerLocal.m
+++ b/agent/src/os/bsd/MacosxDebuggerLocal.m
@@ -38,6 +38,8 @@
#import <dlfcn.h>
#import <limits.h>
#import <errno.h>
+#import <sys/types.h>
+#import <sys/ptrace.h>
jboolean debug = JNI_FALSE;
@@ -430,6 +432,73 @@ Java_sun_jvm_hotspot_debugger_macosx_MacOSXDebuggerLocal_translateTID0(
return (jint) usable_tid;
}
+
+static bool ptrace_continue(pid_t pid, int signal) {
+ // pass the signal to the process so we don't swallow it
+ int res;
+ if ((res = ptrace(PT_CONTINUE, pid, (caddr_t)1, signal)) < 0) {
+ fprintf(stderr, "attach: ptrace(PT_CONTINUE, %d) failed with %d\n", pid, res);
+ return false;
+ }
+ return true;
+}
+
+// waits until the ATTACH has stopped the process
+// by signal SIGSTOP
+static bool ptrace_waitpid(pid_t pid) {
+ int ret;
+ int status;
+ while (true) {
+ // Wait for debuggee to stop.
+ ret = waitpid(pid, &status, 0);
+ if (ret >= 0) {
+ if (WIFSTOPPED(status)) {
+ // Any signal will stop the thread, make sure it is SIGSTOP. Otherwise SIGSTOP
+ // will still be pending and delivered when the process is DETACHED and the process
+ // will go to sleep.
+ if (WSTOPSIG(status) == SIGSTOP) {
+ // Debuggee stopped by SIGSTOP.
+ return true;
+ }
+ if (!ptrace_continue(pid, WSTOPSIG(status))) {
+ fprintf(stderr, "attach: Failed to correctly attach to VM. VM might HANG! [PTRACE_CONT failed, stopped by %d]\n", WSTOPSIG(status));
+ return false;
+ }
+ } else {
+ fprintf(stderr, "attach: waitpid(): Child process exited/terminated (status = 0x%x)\n", status);
+ return false;
+ }
+ } else {
+ switch (errno) {
+ case EINTR:
+ continue;
+ break;
+ case ECHILD:
+ fprintf(stderr, "attach: waitpid() failed. Child process pid (%d) does not exist \n", pid);
+ break;
+ case EINVAL:
+ fprintf(stderr, "attach: waitpid() failed. Invalid options argument.\n");
+ break;
+ default:
+ fprintf(stderr, "attach: waitpid() failed. Unexpected error %d\n",errno);
+ break;
+ }
+ return false;
+ }
+ }
+}
+
+// attach to a process/thread specified by "pid"
+static bool ptrace_attach(pid_t pid) {
+ int res;
+ if ((res = ptrace(PT_ATTACH, pid, 0, 0)) < 0) {
+ fprintf(stderr, "ptrace(PT_ATTACH, %d) failed with %d\n", pid, res);
+ return false;
+ } else {
+ return ptrace_waitpid(pid);
+ }
+}
+
/*
* Class: sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal
* Method: attach0
@@ -445,7 +514,8 @@ JNF_COCOA_ENTER(env);
else
debug = JNI_FALSE;
if (debug) printf("attach0 called for jpid=%d\n", (int)jpid);
-
+
+ // get the task from the pid
kern_return_t result;
task_t gTask = 0;
result = task_for_pid(mach_task_self(), jpid, &gTask);
@@ -455,6 +525,13 @@ JNF_COCOA_ENTER(env);
}
putTask(env, this_obj, gTask);
+ // use ptrace to stop the process
+ // on os x, ptrace only needs to be called on the process, not the individual threads
+ if (ptrace_attach(jpid) != true) {
+ mach_port_deallocate(mach_task_self(), gTask);
+ THROW_NEW_DEBUGGER_EXCEPTION("Can't attach to the process");
+ }
+
id symbolicator = nil;
id jrsSymbolicator = objc_lookUpClass("JRSSymbolicator");
if (jrsSymbolicator != nil) {
@@ -486,6 +563,21 @@ JNF_COCOA_ENTER(env);
if (debug) printf("detach0 called\n");
task_t gTask = getTask(env, this_obj);
+
+ // detach from the ptraced process causing it to resume execution
+ int pid;
+ kern_return_t k_res;
+ k_res = pid_for_task(gTask, &pid);
+ if (k_res != KERN_SUCCESS) {
+ fprintf(stderr, "detach: pid_for_task(%d) failed (%d)\n", pid, k_res);
+ }
+ else {
+ int res = ptrace(PT_DETACH, pid, 0, 0);
+ if (res < 0) {
+ fprintf(stderr, "detach: ptrace(PT_DETACH, %d) failed (%d)\n", pid, res);
+ }
+ }
+
mach_port_deallocate(mach_task_self(), gTask);
id symbolicator = getSymbolicator(env, this_obj);
if (symbolicator != nil) {
diff --git a/agent/src/os/bsd/libproc_impl.c b/agent/src/os/bsd/libproc_impl.c
index 4f2d2822e..e9fa1b82a 100644
--- a/agent/src/os/bsd/libproc_impl.c
+++ b/agent/src/os/bsd/libproc_impl.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -91,6 +91,14 @@ void print_debug(const char* format,...) {
}
}
+void print_error(const char* format,...) {
+ va_list alist;
+ va_start(alist, format);
+ fputs("ERROR: ", stderr);
+ vfprintf(stderr, format, alist);
+ va_end(alist);
+}
+
bool is_debug() {
return _libsaproc_debug;
}
diff --git a/agent/src/os/bsd/libproc_impl.h b/agent/src/os/bsd/libproc_impl.h
index 8b9d23316..12326c17f 100644
--- a/agent/src/os/bsd/libproc_impl.h
+++ b/agent/src/os/bsd/libproc_impl.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -107,6 +107,7 @@ struct ps_prochandle {
int pathmap_open(const char* name);
void print_debug(const char* format,...);
+void print_error(const char* format,...);
bool is_debug();
typedef bool (*thread_info_callback)(struct ps_prochandle* ph, pthread_t pid, lwpid_t lwpid);
diff --git a/agent/src/os/bsd/ps_proc.c b/agent/src/os/bsd/ps_proc.c
index f8957c099..cf4a5d71d 100644
--- a/agent/src/os/bsd/ps_proc.c
+++ b/agent/src/os/bsd/ps_proc.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -129,42 +129,66 @@ static bool process_get_lwp_info(struct ps_prochandle *ph, lwpid_t lwp_id, void
return (errno == 0)? true: false;
}
-// attach to a process/thread specified by "pid"
-static bool ptrace_attach(pid_t pid) {
- if (ptrace(PT_ATTACH, pid, NULL, 0) < 0) {
- print_debug("ptrace(PTRACE_ATTACH, ..) failed for %d\n", pid);
+static bool ptrace_continue(pid_t pid, int signal) {
+ // pass the signal to the process so we don't swallow it
+ if (ptrace(PTRACE_CONT, pid, NULL, signal) < 0) {
+ print_debug("ptrace(PTRACE_CONT, ..) failed for %d\n", pid);
return false;
- } else {
- int ret;
- int status;
- do {
- // Wait for debuggee to stop.
- ret = waitpid(pid, &status, 0);
- if (ret >= 0) {
- if (WIFSTOPPED(status)) {
- // Debuggee stopped.
+ }
+ return true;
+}
+
+// waits until the ATTACH has stopped the process
+// by signal SIGSTOP
+static bool ptrace_waitpid(pid_t pid) {
+ int ret;
+ int status;
+ do {
+ // Wait for debuggee to stop.
+ ret = waitpid(pid, &status, 0);
+ if (ret >= 0) {
+ if (WIFSTOPPED(status)) {
+ // Any signal will stop the thread, make sure it is SIGSTOP. Otherwise SIGSTOP
+ // will still be pending and delivered when the process is DETACHED and the process
+ // will go to sleep.
+ if (WSTOPSIG(status) == SIGSTOP) {
+ // Debuggee stopped by SIGSTOP.
return true;
- } else {
- print_debug("waitpid(): Child process exited/terminated (status = 0x%x)\n", status);
+ }
+ if (!ptrace_continue(pid, WSTOPSIG(status))) {
+ print_error("Failed to correctly attach to VM. VM might HANG! [PTRACE_CONT failed, stopped by %d]\n", WSTOPSIG(status));
return false;
}
} else {
- switch (errno) {
- case EINTR:
- continue;
- break;
- case ECHILD:
- print_debug("waitpid() failed. Child process pid (%d) does not exist \n", pid);
- break;
- case EINVAL:
- print_debug("waitpid() failed. Invalid options argument.\n");
- break;
- default:
- print_debug("waitpid() failed. Unexpected error %d\n",errno);
- }
+ print_debug("waitpid(): Child process exited/terminated (status = 0x%x)\n", status);
return false;
}
- } while(true);
+ } else {
+ switch (errno) {
+ case EINTR:
+ continue;
+ break;
+ case ECHILD:
+ print_debug("waitpid() failed. Child process pid (%d) does not exist \n", pid);
+ break;
+ case EINVAL:
+ print_debug("waitpid() failed. Invalid options argument.\n");
+ break;
+ default:
+ print_debug("waitpid() failed. Unexpected error %d\n",errno);
+ }
+ return false;
+ }
+ } while(true);
+}
+
+// attach to a process/thread specified by "pid"
+static bool ptrace_attach(pid_t pid) {
+ if (ptrace(PT_ATTACH, pid, NULL, 0) < 0) {
+ print_debug("ptrace(PTRACE_ATTACH, ..) failed for %d\n", pid);
+ return false;
+ } else {
+ return ptrace_waitpid(pid);
}
}
diff --git a/agent/src/os/linux/libproc_impl.c b/agent/src/os/linux/libproc_impl.c
index 6ac43acc8..2ea0d0f88 100644
--- a/agent/src/os/linux/libproc_impl.c
+++ b/agent/src/os/linux/libproc_impl.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -92,6 +92,14 @@ void print_debug(const char* format,...) {
}
}
+void print_error(const char* format,...) {
+ va_list alist;
+ va_start(alist, format);
+ fputs("ERROR: ", stderr);
+ vfprintf(stderr, format, alist);
+ va_end(alist);
+}
+
bool is_debug() {
return _libsaproc_debug;
}
diff --git a/agent/src/os/linux/libproc_impl.h b/agent/src/os/linux/libproc_impl.h
index dbf3b30a9..bc907a970 100644
--- a/agent/src/os/linux/libproc_impl.h
+++ b/agent/src/os/linux/libproc_impl.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -105,6 +105,7 @@ struct ps_prochandle {
int pathmap_open(const char* name);
void print_debug(const char* format,...);
+void print_error(const char* format,...);
bool is_debug();
typedef bool (*thread_info_callback)(struct ps_prochandle* ph, pthread_t pid, lwpid_t lwpid);
diff --git a/agent/src/os/linux/ps_proc.c b/agent/src/os/linux/ps_proc.c
index 676e88a44..61f08692c 100644
--- a/agent/src/os/linux/ps_proc.c
+++ b/agent/src/os/linux/ps_proc.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -25,6 +25,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <signal.h>
#include <errno.h>
#include <sys/ptrace.h>
#include "libproc_impl.h"
@@ -142,46 +143,71 @@ static bool process_get_lwp_regs(struct ps_prochandle* ph, pid_t pid, struct use
}
-// attach to a process/thread specified by "pid"
-static bool ptrace_attach(pid_t pid) {
- if (ptrace(PTRACE_ATTACH, pid, NULL, NULL) < 0) {
- print_debug("ptrace(PTRACE_ATTACH, ..) failed for %d\n", pid);
+static bool ptrace_continue(pid_t pid, int signal) {
+ // pass the signal to the process so we don't swallow it
+ if (ptrace(PTRACE_CONT, pid, NULL, signal) < 0) {
+ print_debug("ptrace(PTRACE_CONT, ..) failed for %d\n", pid);
return false;
- } else {
- int ret;
- int status;
- do {
- // Wait for debuggee to stop.
- ret = waitpid(pid, &status, 0);
- if (ret == -1 && errno == ECHILD) {
- // try cloned process.
- ret = waitpid(pid, &status, __WALL);
- }
- if (ret >= 0) {
- if (WIFSTOPPED(status)) {
- // Debuggee stopped.
+ }
+ return true;
+}
+
+// waits until the ATTACH has stopped the process
+// by signal SIGSTOP
+static bool ptrace_waitpid(pid_t pid) {
+ int ret;
+ int status;
+ while (true) {
+ // Wait for debuggee to stop.
+ ret = waitpid(pid, &status, 0);
+ if (ret == -1 && errno == ECHILD) {
+ // try cloned process.
+ ret = waitpid(pid, &status, __WALL);
+ }
+ if (ret >= 0) {
+ if (WIFSTOPPED(status)) {
+ // Any signal will stop the thread, make sure it is SIGSTOP. Otherwise SIGSTOP
+ // will still be pending and delivered when the process is DETACHED and the process
+ // will go to sleep.
+ if (WSTOPSIG(status) == SIGSTOP) {
+ // Debuggee stopped by SIGSTOP.
return true;
- } else {
- print_debug("waitpid(): Child process exited/terminated (status = 0x%x)\n", status);
+ }
+ if (!ptrace_continue(pid, WSTOPSIG(status))) {
+ print_error("Failed to correctly attach to VM. VM might HANG! [PTRACE_CONT failed, stopped by %d]\n", WSTOPSIG(status));
return false;
}
} else {
- switch (errno) {
- case EINTR:
- continue;
- break;
- case ECHILD:
- print_debug("waitpid() failed. Child process pid (%d) does not exist \n", pid);
- break;
- case EINVAL:
- print_debug("waitpid() failed. Invalid options argument.\n");
- break;
- default:
- print_debug("waitpid() failed. Unexpected error %d\n",errno);
- }
+ print_debug("waitpid(): Child process exited/terminated (status = 0x%x)\n", status);
return false;
}
- } while(true);
+ } else {
+ switch (errno) {
+ case EINTR:
+ continue;
+ break;
+ case ECHILD:
+ print_debug("waitpid() failed. Child process pid (%d) does not exist \n", pid);
+ break;
+ case EINVAL:
+ print_debug("waitpid() failed. Invalid options argument.\n");
+ break;
+ default:
+ print_debug("waitpid() failed. Unexpected error %d\n",errno);
+ break;
+ }
+ return false;
+ }
+ }
+}
+
+// attach to a process/thread specified by "pid"
+static bool ptrace_attach(pid_t pid) {
+ if (ptrace(PTRACE_ATTACH, pid, NULL, NULL) < 0) {
+ print_debug("ptrace(PTRACE_ATTACH, ..) failed for %d\n", pid);
+ return false;
+ } else {
+ return ptrace_waitpid(pid);
}
}
diff --git a/agent/src/share/classes/sun/jvm/hotspot/memory/CMSCollector.java b/agent/src/share/classes/sun/jvm/hotspot/memory/CMSCollector.java
index df35e9064..f28caad66 100644
--- a/agent/src/share/classes/sun/jvm/hotspot/memory/CMSCollector.java
+++ b/agent/src/share/classes/sun/jvm/hotspot/memory/CMSCollector.java
@@ -61,15 +61,13 @@ public class CMSCollector extends VMObject {
CMSBitMap markBitMap = markBitMap();
long addressSize = VM.getVM().getAddressSize();
if ( markBitMap.isMarked(addr) && markBitMap.isMarked(addr.addOffsetTo(1*addressSize)) ) {
- System.err.println("Printezis bits are set...");
Address nextOneAddr = markBitMap.getNextMarkedWordAddress(addr.addOffsetTo(2*addressSize));
//return size in bytes
long size = (nextOneAddr.addOffsetTo(1*addressSize)).minus(addr);
return size;
} else {
- //missing Printezis marks
- System.err.println("Missing Printszis marks...");
- return -1;
+ //missing Printezis marks
+ return -1;
}
}
diff --git a/agent/src/share/classes/sun/jvm/hotspot/memory/CompactibleFreeListSpace.java b/agent/src/share/classes/sun/jvm/hotspot/memory/CompactibleFreeListSpace.java
index f47f0e811..23cb0bcb7 100644
--- a/agent/src/share/classes/sun/jvm/hotspot/memory/CompactibleFreeListSpace.java
+++ b/agent/src/share/classes/sun/jvm/hotspot/memory/CompactibleFreeListSpace.java
@@ -191,7 +191,6 @@ public class CompactibleFreeListSpace extends CompactibleSpace {
//Find the object size using Printezis bits and skip over
long size = collector().blockSizeUsingPrintezisBits(cur);
if (size == -1) {
- System.err.println("Printezis bits not set...");
break;
}
cur = cur.addOffsetTo(adjustObjectSizeInBytes(size));
diff --git a/agent/src/share/classes/sun/jvm/hotspot/oops/MethodData.java b/agent/src/share/classes/sun/jvm/hotspot/oops/MethodData.java
index 40ede7277..a397ec353 100644
--- a/agent/src/share/classes/sun/jvm/hotspot/oops/MethodData.java
+++ b/agent/src/share/classes/sun/jvm/hotspot/oops/MethodData.java
@@ -184,7 +184,6 @@ public class MethodData extends Metadata {
if (trapReasonName[index] == null) {
throw new InternalError("missing reason for " + index);
}
- System.out.println(trapReasonName[index]);
}
}
diff --git a/agent/src/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java b/agent/src/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java
index f944188f4..e663ee8e1 100644
--- a/agent/src/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java
+++ b/agent/src/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java
@@ -335,7 +335,6 @@ public class ObjectHeap {
}
if (obj == null) {
//Find the object size using Printezis bits and skip over
- System.err.println("Finding object size using Printezis bits and skipping over...");
long size = 0;
if ( (cmsSpaceOld != null) && cmsSpaceOld.contains(handle) ){
diff --git a/agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java b/agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java
index 80464a10b..0a9d94368 100644
--- a/agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java
+++ b/agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java
@@ -90,10 +90,6 @@ public class VM {
/** Flags indicating whether we are attached to a core, C1, or C2 build */
private boolean usingClientCompiler;
private boolean usingServerCompiler;
- /** Flag indicating whether UseTLAB is turned on */
- private boolean useTLAB;
- /** Flag indicating whether invokedynamic support is on */
- private boolean enableInvokeDynamic;
/** alignment constants */
private boolean isLP64;
private int bytesPerLong;
@@ -326,9 +322,6 @@ public class VM {
}
}
- useTLAB = (db.lookupIntConstant("UseTLAB").intValue() != 0);
- enableInvokeDynamic = (db.lookupIntConstant("EnableInvokeDynamic").intValue() != 0);
-
if (debugger != null) {
isLP64 = debugger.getMachineDescription().isLP64();
}
@@ -579,15 +572,6 @@ public class VM {
}
}
- /** Indicates whether Thread-Local Allocation Buffers are used */
- public boolean getUseTLAB() {
- return useTLAB;
- }
-
- public boolean getEnableInvokeDynamic() {
- return enableInvokeDynamic;
- }
-
public TypeDataBase getTypeDataBase() {
return db;
}
@@ -822,6 +806,12 @@ public class VM {
return objectAlignmentInBytes;
}
+ /** Indicates whether Thread-Local Allocation Buffers are used */
+ public boolean getUseTLAB() {
+ Flag flag = getCommandLineFlag("UseTLAB");
+ return (flag == null) ? false: flag.getBool();
+ }
+
// returns null, if not available.
public Flag[] getCommandLineFlags() {
if (commandLineFlags == null) {
diff --git a/make/bsd/makefiles/vm.make b/make/bsd/makefiles/vm.make
index fbcfb06ce..a77d04f03 100644
--- a/make/bsd/makefiles/vm.make
+++ b/make/bsd/makefiles/vm.make
@@ -94,7 +94,12 @@ CXXFLAGS = \
# This is VERY important! The version define must only be supplied to vm_version.o
# If not, ccache will not re-use the cache at all, since the version string might contain
# a time and date.
-vm_version.o: CXXFLAGS += ${JRE_VERSION}
+CXXFLAGS/vm_version.o += ${JRE_VERSION}
+
+CXXFLAGS/BYFILE = $(CXXFLAGS/$@)
+
+# File specific flags
+CXXFLAGS += $(CXXFLAGS/BYFILE)
ifdef DEFAULT_LIBPATH
CXXFLAGS += -DDEFAULT_LIBPATH="\"$(DEFAULT_LIBPATH)\""
diff --git a/make/excludeSrc.make b/make/excludeSrc.make
index 589c262ca..b3c468f04 100644
--- a/make/excludeSrc.make
+++ b/make/excludeSrc.make
@@ -78,7 +78,7 @@ ifeq ($(INCLUDE_ALL_GCS), false)
Src_Files_EXCLUDE += \
cmsAdaptiveSizePolicy.cpp cmsCollectorPolicy.cpp \
- cmsGCAdaptivePolicyCounters.cpp cmsLockVerifier.cpp cmsPermGen.cpp compactibleFreeListSpace.cpp \
+ cmsGCAdaptivePolicyCounters.cpp cmsLockVerifier.cpp compactibleFreeListSpace.cpp \
concurrentMarkSweepGeneration.cpp concurrentMarkSweepThread.cpp \
freeChunk.cpp adaptiveFreeList.cpp promotionInfo.cpp vmCMSOperations.cpp collectionSetChooser.cpp \
concurrentG1Refine.cpp concurrentG1RefineThread.cpp concurrentMark.cpp concurrentMarkThread.cpp \
@@ -91,11 +91,11 @@ ifeq ($(INCLUDE_ALL_GCS), false)
gcTaskManager.cpp gcTaskThread.cpp objectStartArray.cpp parallelScavengeHeap.cpp parMarkBitMap.cpp \
pcTasks.cpp psAdaptiveSizePolicy.cpp psCompactionManager.cpp psGCAdaptivePolicyCounters.cpp \
psGenerationCounters.cpp psMarkSweep.cpp psMarkSweepDecorator.cpp psOldGen.cpp psParallelCompact.cpp \
- psPermGen.cpp psPromotionLAB.cpp psPromotionManager.cpp psScavenge.cpp psTasks.cpp psVirtualspace.cpp \
+ psPromotionLAB.cpp psPromotionManager.cpp psScavenge.cpp psTasks.cpp psVirtualspace.cpp \
psYoungGen.cpp vmPSOperations.cpp asParNewGeneration.cpp parCardTableModRefBS.cpp \
parGCAllocBuffer.cpp parNewGeneration.cpp mutableSpace.cpp gSpaceCounters.cpp allocationStats.cpp \
spaceCounters.cpp gcAdaptivePolicyCounters.cpp mutableNUMASpace.cpp immutableSpace.cpp \
- immutableSpace.cpp g1MemoryPool.cpp psMemoryPool.cpp yieldWorkingGroup.cpp g1Log.cpp
+ immutableSpace.cpp g1MemoryPool.cpp psMemoryPool.cpp yieldingWorkGroup.cpp g1Log.cpp
endif
ifeq ($(INCLUDE_NMT), false)
diff --git a/make/hotspot_version b/make/hotspot_version
index beedf8272..5d39709c5 100644
--- a/make/hotspot_version
+++ b/make/hotspot_version
@@ -35,7 +35,7 @@ HOTSPOT_VM_COPYRIGHT=Copyright 2013
HS_MAJOR_VER=25
HS_MINOR_VER=0
-HS_BUILD_NUMBER=19
+HS_BUILD_NUMBER=20
JDK_MAJOR_VER=1
JDK_MINOR_VER=8
diff --git a/make/linux/makefiles/vm.make b/make/linux/makefiles/vm.make
index 705b34bb1..1de0d310b 100644
--- a/make/linux/makefiles/vm.make
+++ b/make/linux/makefiles/vm.make
@@ -100,7 +100,13 @@ CXXFLAGS = \
# This is VERY important! The version define must only be supplied to vm_version.o
# If not, ccache will not re-use the cache at all, since the version string might contain
# a time and date.
-vm_version.o: CXXFLAGS += ${JRE_VERSION}
+CXXFLAGS/vm_version.o += ${JRE_VERSION}
+
+CXXFLAGS/BYFILE = $(CXXFLAGS/$@)
+
+# File specific flags
+CXXFLAGS += $(CXXFLAGS/BYFILE)
+
ifndef JAVASE_EMBEDDED
ifneq (${ARCH},arm)
diff --git a/make/solaris/makefiles/vm.make b/make/solaris/makefiles/vm.make
index 4a59e5ba6..74d42a23d 100644
--- a/make/solaris/makefiles/vm.make
+++ b/make/solaris/makefiles/vm.make
@@ -88,7 +88,13 @@ CXXFLAGS = \
# This is VERY important! The version define must only be supplied to vm_version.o
# If not, ccache will not re-use the cache at all, since the version string might contain
# a time and date.
-vm_version.o: CXXFLAGS += ${JRE_VERSION}
+CXXFLAGS/vm_version.o += ${JRE_VERSION}
+
+CXXFLAGS/BYFILE = $(CXXFLAGS/$@)
+
+# File specific flags
+CXXFLAGS += $(CXXFLAGS/BYFILE)
+
# CFLAGS_WARN holds compiler options to suppress/enable warnings.
CFLAGS += $(CFLAGS_WARN)
diff --git a/src/os/bsd/vm/os_bsd.cpp b/src/os/bsd/vm/os_bsd.cpp
index a11ca3700..1bc86d13b 100644
--- a/src/os/bsd/vm/os_bsd.cpp
+++ b/src/os/bsd/vm/os_bsd.cpp
@@ -2887,7 +2887,9 @@ JVM_handle_bsd_signal(int signo, siginfo_t* siginfo,
void signalHandler(int sig, siginfo_t* info, void* uc) {
assert(info != NULL && uc != NULL, "it must be old kernel");
+ int orig_errno = errno; // Preserve errno value over signal handler.
JVM_handle_bsd_signal(sig, info, uc, true);
+ errno = orig_errno;
}
diff --git a/src/os/linux/vm/os_linux.cpp b/src/os/linux/vm/os_linux.cpp
index 537b48cdb..74c237fdf 100644
--- a/src/os/linux/vm/os_linux.cpp
+++ b/src/os/linux/vm/os_linux.cpp
@@ -3653,7 +3653,9 @@ JVM_handle_linux_signal(int signo, siginfo_t* siginfo,
void signalHandler(int sig, siginfo_t* info, void* uc) {
assert(info != NULL && uc != NULL, "it must be old kernel");
+ int orig_errno = errno; // Preserve errno value over signal handler.
JVM_handle_linux_signal(sig, info, uc, true);
+ errno = orig_errno;
}
diff --git a/src/os/solaris/vm/os_solaris.cpp b/src/os/solaris/vm/os_solaris.cpp
index 389ed9aa2..a80a0ea45 100644
--- a/src/os/solaris/vm/os_solaris.cpp
+++ b/src/os/solaris/vm/os_solaris.cpp
@@ -1865,7 +1865,7 @@ void os::abort(bool dump_core) {
// Die immediately, no exit hook, no abort hook, no cleanup.
void os::die() {
- _exit(-1);
+ ::abort(); // dump core (for debugging)
}
// unused
@@ -4317,7 +4317,9 @@ JVM_handle_solaris_signal(int signo, siginfo_t* siginfo, void* ucontext,
void signalHandler(int sig, siginfo_t* info, void* ucVoid) {
+ int orig_errno = errno; // Preserve errno value over signal handler.
JVM_handle_solaris_signal(sig, info, ucVoid, true);
+ errno = orig_errno;
}
/* Do not delete - if guarantee is ever removed, a signal handler (even empty)
diff --git a/src/os/windows/vm/os_windows.cpp b/src/os/windows/vm/os_windows.cpp
index eb16478ab..b1556bf64 100644
--- a/src/os/windows/vm/os_windows.cpp
+++ b/src/os/windows/vm/os_windows.cpp
@@ -1940,7 +1940,7 @@ int os::sigexitnum_pd(){
// a counter for each possible signal value, including signal_thread exit signal
static volatile jint pending_signals[NSIG+1] = { 0 };
-static HANDLE sig_sem;
+static HANDLE sig_sem = NULL;
void os::signal_init_pd() {
// Initialize signal structures
@@ -1970,10 +1970,11 @@ void os::signal_init_pd() {
void os::signal_notify(int signal_number) {
BOOL ret;
-
- Atomic::inc(&pending_signals[signal_number]);
- ret = ::ReleaseSemaphore(sig_sem, 1, NULL);
- assert(ret != 0, "ReleaseSemaphore() failed");
+ if (sig_sem != NULL) {
+ Atomic::inc(&pending_signals[signal_number]);
+ ret = ::ReleaseSemaphore(sig_sem, 1, NULL);
+ assert(ret != 0, "ReleaseSemaphore() failed");
+ }
}
static int check_pending_signals(bool wait_for_signal) {
diff --git a/src/share/vm/c1/c1_LIR.cpp b/src/share/vm/c1/c1_LIR.cpp
index 7a0563c6a..2082b5268 100644
--- a/src/share/vm/c1/c1_LIR.cpp
+++ b/src/share/vm/c1/c1_LIR.cpp
@@ -814,7 +814,7 @@ void LIR_OpVisitState::visit(LIR_Op* op) {
// only visit register parameters
int n = opJavaCall->_arguments->length();
- for (int i = 0; i < n; i++) {
+ for (int i = opJavaCall->_receiver->is_valid() ? 1 : 0; i < n; i++) {
if (!opJavaCall->_arguments->at(i)->is_pointer()) {
do_input(*opJavaCall->_arguments->adr_at(i));
}
diff --git a/src/share/vm/classfile/verifier.cpp b/src/share/vm/classfile/verifier.cpp
index 6181e0379..071c83527 100644
--- a/src/share/vm/classfile/verifier.cpp
+++ b/src/share/vm/classfile/verifier.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -61,7 +61,8 @@
# include "bytes_ppc.hpp"
#endif
-#define NOFAILOVER_MAJOR_VERSION 51
+#define NOFAILOVER_MAJOR_VERSION 51
+#define STATIC_METHOD_IN_INTERFACE_MAJOR_VERSION 52
// Access to external entry for VerifyClassCodes - old byte code verifier
@@ -2317,6 +2318,11 @@ void ClassVerifier::verify_invoke_instructions(
types = (1 << JVM_CONSTANT_InterfaceMethodref) |
(1 << JVM_CONSTANT_Methodref);
break;
+ case Bytecodes::_invokestatic:
+ types = (_klass->major_version() < STATIC_METHOD_IN_INTERFACE_MAJOR_VERSION) ?
+ (1 << JVM_CONSTANT_Methodref) :
+ ((1 << JVM_CONSTANT_InterfaceMethodref) | (1 << JVM_CONSTANT_Methodref));
+ break;
default:
types = 1 << JVM_CONSTANT_Methodref;
}
diff --git a/src/share/vm/memory/collectorPolicy.cpp b/src/share/vm/memory/collectorPolicy.cpp
index 2645cec46..ab8f2ca7f 100644
--- a/src/share/vm/memory/collectorPolicy.cpp
+++ b/src/share/vm/memory/collectorPolicy.cpp
@@ -168,11 +168,11 @@ size_t GenCollectorPolicy::bound_minus_alignment(size_t desired_size,
void GenCollectorPolicy::initialize_size_policy(size_t init_eden_size,
size_t init_promo_size,
size_t init_survivor_size) {
- const double max_gc_minor_pause_sec = ((double) MaxGCMinorPauseMillis)/1000.0;
+ const double max_gc_pause_sec = ((double) MaxGCPauseMillis)/1000.0;
_size_policy = new AdaptiveSizePolicy(init_eden_size,
init_promo_size,
init_survivor_size,
- max_gc_minor_pause_sec,
+ max_gc_pause_sec,
GCTimeRatio);
}
diff --git a/src/share/vm/oops/method.hpp b/src/share/vm/oops/method.hpp
index a2d24ebca..0c6203fc6 100644
--- a/src/share/vm/oops/method.hpp
+++ b/src/share/vm/oops/method.hpp
@@ -456,6 +456,8 @@ class Method : public Metadata {
void print_codes_on(int from, int to, outputStream* st) const PRODUCT_RETURN;
// method parameters
+ bool has_method_parameters() const
+ { return constMethod()->has_method_parameters(); }
int method_parameters_length() const
{ return constMethod()->method_parameters_length(); }
MethodParametersElement* method_parameters_start() const
diff --git a/src/share/vm/opto/library_call.cpp b/src/share/vm/opto/library_call.cpp
index 3969f383f..cdcb94177 100644
--- a/src/share/vm/opto/library_call.cpp
+++ b/src/share/vm/opto/library_call.cpp
@@ -1481,10 +1481,10 @@ bool LibraryCallKit::inline_math(vmIntrinsics::ID id) {
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 @@ bool LibraryCallKit::inline_trig(vmIntrinsics::ID id) {
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 --git a/src/share/vm/opto/subnode.hpp b/src/share/vm/opto/subnode.hpp
index c3a31ffd8..50c0bfac9 100644
--- a/src/share/vm/opto/subnode.hpp
+++ b/src/share/vm/opto/subnode.hpp
@@ -399,7 +399,10 @@ public:
// 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 @@ public:
// 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 @@ public:
// 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 @@ public:
// 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 @@ public:
// 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 @@ public:
// 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 --git a/src/share/vm/opto/superword.cpp b/src/share/vm/opto/superword.cpp
index f53c64837..90f24189f 100644
--- a/src/share/vm/opto/superword.cpp
+++ b/src/share/vm/opto/superword.cpp
@@ -143,7 +143,8 @@ void SuperWord::SLP_extract() {
// Ready the block
- construct_bb();
+ if (!construct_bb())
+ return; // Exit if no interesting nodes or complex graph.
dependence_graph();
@@ -615,6 +616,7 @@ void SuperWord::mem_slice_preds(Node* start, Node* stop, GrowableArray<Node*> &p
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 @@ bool SuperWord::is_vector_use(Node* use, int u_idx) {
//------------------------------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 @@ void SuperWord::construct_bb() {
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 @@ void SuperWord::construct_bb() {
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 @@ void SuperWord::construct_bb() {
}
#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 --git a/src/share/vm/opto/superword.hpp b/src/share/vm/opto/superword.hpp
index 45c0f9a83..050d7588c 100644
--- a/src/share/vm/opto/superword.hpp
+++ b/src/share/vm/opto/superword.hpp
@@ -380,7 +380,7 @@ class SuperWord : public ResourceObj {
// 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 --git a/src/share/vm/prims/jvmtiRedefineClasses.cpp b/src/share/vm/prims/jvmtiRedefineClasses.cpp
index 14cb63c60..9eaa07a09 100644
--- a/src/share/vm/prims/jvmtiRedefineClasses.cpp
+++ b/src/share/vm/prims/jvmtiRedefineClasses.cpp
@@ -1558,6 +1558,18 @@ void VM_RedefineClasses::rewrite_cp_refs_in_method(methodHandle method,
} break;
}
} // end for each bytecode
+
+ // We also need to rewrite the parameter name indexes, if there is
+ // method parameter data present
+ if(method->has_method_parameters()) {
+ const int len = method->method_parameters_length();
+ MethodParametersElement* elem = method->method_parameters_start();
+
+ for (int i = 0; i < len; i++) {
+ const u2 cp_index = elem[i].name_cp_index;
+ elem[i].name_cp_index = find_new_index(cp_index);
+ }
+ }
} // end rewrite_cp_refs_in_method()
diff --git a/src/share/vm/runtime/arguments.cpp b/src/share/vm/runtime/arguments.cpp
index 84df1ab3e..ddcabea14 100644
--- a/src/share/vm/runtime/arguments.cpp
+++ b/src/share/vm/runtime/arguments.cpp
@@ -1738,16 +1738,6 @@ bool Arguments::verify_percentage(uintx value, const char* name) {
return false;
}
-static void force_serial_gc() {
- FLAG_SET_DEFAULT(UseSerialGC, true);
- FLAG_SET_DEFAULT(UseParNewGC, false);
- FLAG_SET_DEFAULT(UseConcMarkSweepGC, false);
- FLAG_SET_DEFAULT(CMSIncrementalMode, false); // special CMS suboption
- FLAG_SET_DEFAULT(UseParallelGC, false);
- FLAG_SET_DEFAULT(UseParallelOldGC, false);
- FLAG_SET_DEFAULT(UseG1GC, false);
-}
-
static bool verify_serial_gc_flags() {
return (UseSerialGC &&
!(UseParNewGC || (UseConcMarkSweepGC || CMSIncrementalMode) || UseG1GC ||
@@ -2498,7 +2488,12 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args,
}
// Out of the box management support
if (match_option(option, "-Dcom.sun.management", &tail)) {
+#if INCLUDE_MANAGEMENT
FLAG_SET_CMDLINE(bool, ManagementServer, true);
+#else
+ vm_exit_during_initialization(
+ "-Dcom.sun.management is not supported in this VM.", NULL);
+#endif
}
// -Xint
} else if (match_option(option, "-Xint", &tail)) {
@@ -2844,6 +2839,11 @@ SOLARIS_ONLY(
// away and will cause VM initialization failures!
warning("-XX:+UseVMInterruptibleIO is obsolete and will be removed in a future release.");
FLAG_SET_CMDLINE(bool, UseVMInterruptibleIO, true);
+#if !INCLUDE_MANAGEMENT
+ } else if (match_option(option, "-XX:+ManagementServer", &tail)) {
+ vm_exit_during_initialization(
+ "ManagementServer is not supported in this VM.", NULL);
+#endif // INCLUDE_MANAGEMENT
} else if (match_option(option, "-XX:", &tail)) { // -XX:xxxx
// Skip -XX:Flags= since that case has already been handled
if (strncmp(tail, "Flags=", strlen("Flags=")) != 0) {
@@ -3072,6 +3072,27 @@ do { \
} \
} while(0)
+
+#define UNSUPPORTED_GC_OPTION(gc) \
+do { \
+ if (gc) { \
+ if (FLAG_IS_CMDLINE(gc)) { \
+ warning(#gc " is not supported in this VM. Using Serial GC."); \
+ } \
+ FLAG_SET_DEFAULT(gc, false); \
+ } \
+} while(0)
+
+static void force_serial_gc() {
+ FLAG_SET_DEFAULT(UseSerialGC, true);
+ FLAG_SET_DEFAULT(CMSIncrementalMode, false); // special CMS suboption
+ UNSUPPORTED_GC_OPTION(UseG1GC);
+ UNSUPPORTED_GC_OPTION(UseParallelGC);
+ UNSUPPORTED_GC_OPTION(UseParallelOldGC);
+ UNSUPPORTED_GC_OPTION(UseConcMarkSweepGC);
+ UNSUPPORTED_GC_OPTION(UseParNewGC);
+}
+
// Parse entry point called from JNI_CreateJavaVM
jint Arguments::parse(const JavaVMInitArgs* args) {
@@ -3187,28 +3208,15 @@ jint Arguments::parse(const JavaVMInitArgs* args) {
hotspotrc, hotspotrc);
}
-#if (defined JAVASE_EMBEDDED || defined ARM)
- UNSUPPORTED_OPTION(UseG1GC, "G1 GC");
-#endif
-
#ifdef _ALLBSD_SOURCE // UseLargePages is not yet supported on BSD.
UNSUPPORTED_OPTION(UseLargePages, "-XX:+UseLargePages");
#endif
-#if !INCLUDE_ALL_GCS
- if (UseParallelGC) {
- warning("Parallel GC is not supported in this VM. Using Serial GC.");
- }
- if (UseParallelOldGC) {
- warning("Parallel Old GC is not supported in this VM. Using Serial GC.");
- }
- if (UseConcMarkSweepGC) {
- warning("Concurrent Mark Sweep GC is not supported in this VM. Using Serial GC.");
- }
- if (UseParNewGC) {
- warning("Par New GC is not supported in this VM. Using Serial GC.");
- }
-#endif // INCLUDE_ALL_GCS
+#if INCLUDE_ALL_GCS
+ #if (defined JAVASE_EMBEDDED || defined ARM)
+ UNSUPPORTED_OPTION(UseG1GC, "G1 GC");
+ #endif
+#endif
#ifndef PRODUCT
if (TraceBytecodesAt != 0) {
diff --git a/src/share/vm/runtime/vmStructs.cpp b/src/share/vm/runtime/vmStructs.cpp
index d21c2c1bb..158060b69 100644
--- a/src/share/vm/runtime/vmStructs.cpp
+++ b/src/share/vm/runtime/vmStructs.cpp
@@ -2109,8 +2109,6 @@ typedef BinaryTreeDictionary<Metablock, FreeList> MetablockTreeDictionary;
/* Useful globals */ \
/******************/ \
\
- declare_constant(UseTLAB) \
- declare_constant(EnableInvokeDynamic) \
\
/**************/ \
/* Stack bias */ \
diff --git a/src/share/vm/utilities/yieldingWorkgroup.cpp b/src/share/vm/utilities/yieldingWorkgroup.cpp
index e344aea4b..f6e5a6bac 100644
--- a/src/share/vm/utilities/yieldingWorkgroup.cpp
+++ b/src/share/vm/utilities/yieldingWorkgroup.cpp
@@ -24,9 +24,7 @@
#include "precompiled.hpp"
#include "utilities/macros.hpp"
-#if INCLUDE_ALL_GCS
#include "utilities/yieldingWorkgroup.hpp"
-#endif // INCLUDE_ALL_GCS
// Forward declaration of classes declared here.
diff --git a/test/TEST.ROOT b/test/TEST.ROOT
index 629bb54dd..7fe2eb544 100644
--- a/test/TEST.ROOT
+++ b/test/TEST.ROOT
@@ -28,4 +28,4 @@
# DO NOT EDIT without first contacting hotspot-regtest@sun.com
# The list of keywords supported in this test suite
-keys=cte_test jcmd nmt regression
+keys=cte_test jcmd nmt regression gc
diff --git a/test/compiler/5091921/Test6850611.java b/test/compiler/5091921/Test6850611.java
index 25a493740..87b0e6b2f 100644
--- a/test/compiler/5091921/Test6850611.java
+++ b/test/compiler/5091921/Test6850611.java
@@ -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 --git a/test/compiler/5091921/Test6890943.java b/test/compiler/5091921/Test6890943.java
index d4c7b1f0e..6dee78a59 100644
--- a/test/compiler/5091921/Test6890943.java
+++ b/test/compiler/5091921/Test6890943.java
@@ -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 --git a/test/compiler/5091921/Test6890943.sh b/test/compiler/5091921/Test6890943.sh
index b722364af..7ebda8f6e 100644
--- a/test/compiler/5091921/Test6890943.sh
+++ b/test/compiler/5091921/Test6890943.sh
@@ -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 @@ cp ${TESTSRC}/Test6890943.sh .
${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 --git a/test/compiler/5091921/Test6905845.java b/test/compiler/5091921/Test6905845.java
index 012919381..1cb2f7451 100644
--- a/test/compiler/5091921/Test6905845.java
+++ b/test/compiler/5091921/Test6905845.java
@@ -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 --git a/test/compiler/5091921/Test6992759.java b/test/compiler/5091921/Test6992759.java
index 2d79b2f18..9adece6a2 100644
--- a/test/compiler/5091921/Test6992759.java
+++ b/test/compiler/5091921/Test6992759.java
@@ -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 --git a/test/compiler/8004867/TestIntAtomicCAS.java b/test/compiler/8004867/TestIntAtomicCAS.java
new file mode 100644
index 000000000..16d7d9797
--- /dev/null
+++ b/test/compiler/8004867/TestIntAtomicCAS.java
@@ -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<ARRLEN; i++) {
+ a1.set(i, -1);
+ a2.set(i, -1);
+ }
+ System.out.println("Warmup");
+ for (int i=0; i<ITERS; i++) {
+ test_ci(a1);
+ test_vi(a2, 123, -1);
+ test_cp(a1, a2);
+ test_2ci(a1, a2);
+ test_2vi(a1, a2, 123, 103);
+ test_ci_neg(a1, 123);
+ test_vi_neg(a2, 123, 103);
+ test_cp_neg(a1, a2);
+ test_2ci_neg(a1, a2);
+ test_2vi_neg(a1, a2, 123, 103);
+ test_ci_oppos(a1, 123);
+ test_vi_oppos(a2, 123, 103);
+ test_cp_oppos(a1, a2);
+ test_2ci_oppos(a1, a2);
+ test_2vi_oppos(a1, a2, 123, 103);
+ test_ci_off(a1, 123);
+ test_vi_off(a2, 123, 103);
+ test_cp_off(a1, a2);
+ test_2ci_off(a1, a2);
+ test_2vi_off(a1, a2, 123, 103);
+ test_ci_inv(a1, OFFSET, 123);
+ test_vi_inv(a2, 123, OFFSET, 103);
+ test_cp_inv(a1, a2, OFFSET);
+ test_2ci_inv(a1, a2, OFFSET);
+ test_2vi_inv(a1, a2, 123, 103, OFFSET);
+ test_ci_scl(a1, 123);
+ test_vi_scl(a2, 123, 103);
+ test_cp_scl(a1, a2);
+ test_2ci_scl(a1, a2);
+ test_2vi_scl(a1, a2, 123, 103);
+ test_cp_alndst(a1, a2);
+ test_cp_alnsrc(a1, a2);
+ test_2ci_aln(a1, a2);
+ test_2vi_aln(a1, a2, 123, 103);
+ test_cp_unalndst(a1, a2);
+ test_cp_unalnsrc(a1, a2);
+ test_2ci_unaln(a1, a2);
+ test_2vi_unaln(a1, a2, 123, 103);
+ }
+ // Initialize
+ for (int i=0; i<ARRLEN; i++) {
+ a1.set(i, -1);
+ a2.set(i, -1);
+ }
+ // Test and verify results
+ System.out.println("Verification");
+ int errn = 0;
+ {
+ test_ci(a1);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_ci: a1", i, a1.get(i), -123);
+ }
+ test_vi(a2, 123, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_vi: a2", i, a2.get(i), 123);
+ }
+ test_cp(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_cp: a1", i, a1.get(i), 123);
+ }
+ test_2ci(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_2ci: a1", i, a1.get(i), -123);
+ errn += verify("test_2ci: a2", i, a2.get(i), -103);
+ }
+ test_2vi(a1, a2, 123, 103);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_2vi: a1", i, a1.get(i), 123);
+ errn += verify("test_2vi: a2", i, a2.get(i), 103);
+ }
+ // Reset for negative stride
+ for (int i=0; i<ARRLEN; i++) {
+ a1.set(i, -1);
+ a2.set(i, -1);
+ }
+ test_ci_neg(a1, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_ci_neg: a1", i, a1.get(i), -123);
+ }
+ test_vi_neg(a2, 123, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_vi_neg: a2", i, a2.get(i), 123);
+ }
+ test_cp_neg(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_cp_neg: a1", i, a1.get(i), 123);
+ }
+ test_2ci_neg(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_2ci_neg: a1", i, a1.get(i), -123);
+ errn += verify("test_2ci_neg: a2", i, a2.get(i), -103);
+ }
+ test_2vi_neg(a1, a2, 123, 103);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_2vi_neg: a1", i, a1.get(i), 123);
+ errn += verify("test_2vi_neg: a2", i, a2.get(i), 103);
+ }
+ // Reset for opposite stride
+ for (int i=0; i<ARRLEN; i++) {
+ a1.set(i, -1);
+ a2.set(i, -1);
+ }
+ test_ci_oppos(a1, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_ci_oppos: a1", i, a1.get(i), -123);
+ }
+ test_vi_oppos(a2, 123, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_vi_oppos: a2", i, a2.get(i), 123);
+ }
+ test_cp_oppos(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_cp_oppos: a1", i, a1.get(i), 123);
+ }
+ test_2ci_oppos(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_2ci_oppos: a1", i, a1.get(i), -123);
+ errn += verify("test_2ci_oppos: a2", i, a2.get(i), -103);
+ }
+ test_2vi_oppos(a1, a2, 123, 103);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_2vi_oppos: a1", i, a1.get(i), 123);
+ errn += verify("test_2vi_oppos: a2", i, a2.get(i), 103);
+ }
+ // Reset for indexing with offset
+ for (int i=0; i<ARRLEN; i++) {
+ a1.set(i, -1);
+ a2.set(i, -1);
+ }
+ test_ci_off(a1, -1);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_ci_off: a1", i, a1.get(i), -123);
+ }
+ test_vi_off(a2, 123, -1);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_vi_off: a2", i, a2.get(i), 123);
+ }
+ test_cp_off(a1, a2);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_cp_off: a1", i, a1.get(i), 123);
+ }
+ test_2ci_off(a1, a2);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_2ci_off: a1", i, a1.get(i), -123);
+ errn += verify("test_2ci_off: a2", i, a2.get(i), -103);
+ }
+ test_2vi_off(a1, a2, 123, 103);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_2vi_off: a1", i, a1.get(i), 123);
+ errn += verify("test_2vi_off: a2", i, a2.get(i), 103);
+ }
+ for (int i=0; i<OFFSET; i++) {
+ errn += verify("test_2vi_off: a1", i, a1.get(i), -1);
+ errn += verify("test_2vi_off: a2", i, a2.get(i), -1);
+ }
+ // Reset for indexing with invariant offset
+ for (int i=0; i<ARRLEN; i++) {
+ a1.set(i, -1);
+ a2.set(i, -1);
+ }
+ test_ci_inv(a1, OFFSET, -1);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_ci_inv: a1", i, a1.get(i), -123);
+ }
+ test_vi_inv(a2, 123, OFFSET, -1);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_vi_inv: a2", i, a2.get(i), 123);
+ }
+ test_cp_inv(a1, a2, OFFSET);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_cp_inv: a1", i, a1.get(i), 123);
+ }
+ test_2ci_inv(a1, a2, OFFSET);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_2ci_inv: a1", i, a1.get(i), -123);
+ errn += verify("test_2ci_inv: a2", i, a2.get(i), -103);
+ }
+ test_2vi_inv(a1, a2, 123, 103, OFFSET);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_2vi_inv: a1", i, a1.get(i), 123);
+ errn += verify("test_2vi_inv: a2", i, a2.get(i), 103);
+ }
+ for (int i=0; i<OFFSET; i++) {
+ errn += verify("test_2vi_inv: a1", i, a1.get(i), -1);
+ errn += verify("test_2vi_inv: a2", i, a2.get(i), -1);
+ }
+ // Reset for indexing with scale
+ for (int i=0; i<ARRLEN; i++) {
+ a1.set(i, -1);
+ a2.set(i, -1);
+ }
+ test_ci_scl(a1, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ int val = (i%SCALE != 0) ? -1 : -123;
+ errn += verify("test_ci_scl: a1", i, a1.get(i), val);
+ }
+ test_vi_scl(a2, 123, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ int val = (i%SCALE != 0) ? -1 : 123;
+ errn += verify("test_vi_scl: a2", i, a2.get(i), val);
+ }
+ test_cp_scl(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ int val = (i%SCALE != 0) ? -1 : 123;
+ errn += verify("test_cp_scl: a1", i, a1.get(i), val);
+ }
+ test_2ci_scl(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ if (i%SCALE != 0) {
+ errn += verify("test_2ci_scl: a1", i, a1.get(i), -1);
+ } else if (i*SCALE < ARRLEN) {
+ errn += verify("test_2ci_scl: a1", i*SCALE, a1.get(i*SCALE), -123);
+ }
+ if (i%SCALE != 0) {
+ errn += verify("test_2ci_scl: a2", i, a2.get(i), -1);
+ } else if (i*SCALE < ARRLEN) {
+ errn += verify("test_2ci_scl: a2", i*SCALE, a2.get(i*SCALE), -103);
+ }
+ }
+ test_2vi_scl(a1, a2, 123, 103);
+ for (int i=0; i<ARRLEN; i++) {
+ if (i%SCALE != 0) {
+ errn += verify("test_2vi_scl: a1", i, a1.get(i), -1);
+ } else if (i*SCALE < ARRLEN) {
+ errn += verify("test_2vi_scl: a1", i*SCALE, a1.get(i*SCALE), 123);
+ }
+ if (i%SCALE != 0) {
+ errn += verify("test_2vi_scl: a2", i, a2.get(i), -1);
+ } else if (i*SCALE < ARRLEN) {
+ errn += verify("test_2vi_scl: a2", i*SCALE, a2.get(i*SCALE), 103);
+ }
+ }
+ // Reset for 2 arrays with relative aligned offset
+ for (int i=0; i<ARRLEN; i++) {
+ a1.set(i, -1);
+ a2.set(i, -1);
+ }
+ test_vi(a2, 123, -1);
+ test_cp_alndst(a1, a2);
+ for (int i=0; i<ALIGN_OFF; i++) {
+ errn += verify("test_cp_alndst: a1", i, a1.get(i), -1);
+ }
+ for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_cp_alndst: a1", i, a1.get(i), 123);
+ }
+ for (int i=0; i<ALIGN_OFF; i++) {
+ a1.set(i, 123);
+ }
+ test_vi(a2, -123, 123);
+ test_cp_alnsrc(a1, a2);
+ for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+ errn += verify("test_cp_alnsrc: a1", i, a1.get(i), -123);
+ }
+ for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_cp_alnsrc: a1", i, a1.get(i), 123);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1.set(i, -1);
+ a2.set(i, -1);
+ }
+ test_2ci_aln(a1, a2);
+ for (int i=0; i<ALIGN_OFF; i++) {
+ errn += verify("test_2ci_aln: a1", i, a1.get(i), -1);
+ }
+ for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2ci_aln: a1", i, a1.get(i), -123);
+ }
+ for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+ errn += verify("test_2ci_aln: a2", i, a2.get(i), -103);
+ }
+ for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2ci_aln: a2", i, a2.get(i), -1);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1.set(i, -1);
+ a2.set(i, -1);
+ }
+ test_2vi_aln(a1, a2, 123, 103);
+ for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+ errn += verify("test_2vi_aln: a1", i, a1.get(i), 123);
+ }
+ for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2vi_aln: a1", i, a1.get(i), -1);
+ }
+ for (int i=0; i<ALIGN_OFF; i++) {
+ errn += verify("test_2vi_aln: a2", i, a2.get(i), -1);
+ }
+ for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2vi_aln: a2", i, a2.get(i), 103);
+ }
+
+ // Reset for 2 arrays with relative unaligned offset
+ for (int i=0; i<ARRLEN; i++) {
+ a1.set(i, -1);
+ a2.set(i, -1);
+ }
+ test_vi(a2, 123, -1);
+ test_cp_unalndst(a1, a2);
+ for (int i=0; i<UNALIGN_OFF; i++) {
+ errn += verify("test_cp_unalndst: a1", i, a1.get(i), -1);
+ }
+ for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_cp_unalndst: a1", i, a1.get(i), 123);
+ }
+ test_vi(a2, -123, 123);
+ test_cp_unalnsrc(a1, a2);
+ for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+ errn += verify("test_cp_unalnsrc: a1", i, a1.get(i), -123);
+ }
+ for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_cp_unalnsrc: a1", i, a1.get(i), 123);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1.set(i, -1);
+ a2.set(i, -1);
+ }
+ test_2ci_unaln(a1, a2);
+ for (int i=0; i<UNALIGN_OFF; i++) {
+ errn += verify("test_2ci_unaln: a1", i, a1.get(i), -1);
+ }
+ for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2ci_unaln: a1", i, a1.get(i), -123);
+ }
+ for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+ errn += verify("test_2ci_unaln: a2", i, a2.get(i), -103);
+ }
+ for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2ci_unaln: a2", i, a2.get(i), -1);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1.set(i, -1);
+ a2.set(i, -1);
+ }
+ test_2vi_unaln(a1, a2, 123, 103);
+ for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+ errn += verify("test_2vi_unaln: a1", i, a1.get(i), 123);
+ }
+ for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2vi_unaln: a1", i, a1.get(i), -1);
+ }
+ for (int i=0; i<UNALIGN_OFF; i++) {
+ errn += verify("test_2vi_unaln: a2", i, a2.get(i), -1);
+ }
+ for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2vi_unaln: a2", i, a2.get(i), 103);
+ }
+
+ // Reset for aligned overlap initialization
+ for (int i=0; i<ALIGN_OFF; i++) {
+ a1.set(i, i);
+ }
+ for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+ a1.set(i, -1);
+ }
+ test_cp_alndst(a1, a1);
+ for (int i=0; i<ARRLEN; i++) {
+ int v = i%ALIGN_OFF;
+ errn += verify("test_cp_alndst_overlap: a1", i, a1.get(i), v);
+ }
+ for (int i=0; i<ALIGN_OFF; i++) {
+ a1.set((i+ALIGN_OFF), -1);
+ }
+ test_cp_alnsrc(a1, a1);
+ for (int i=0; i<ALIGN_OFF; i++) {
+ errn += verify("test_cp_alnsrc_overlap: a1", i, a1.get(i), -1);
+ }
+ for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+ int v = i%ALIGN_OFF;
+ errn += verify("test_cp_alnsrc_overlap: a1", i, a1.get(i), v);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1.set(i, -1);
+ }
+ test_2ci_aln(a1, a1);
+ for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+ errn += verify("test_2ci_aln_overlap: a1", i, a1.get(i), -103);
+ }
+ for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2ci_aln_overlap: a1", i, a1.get(i), -123);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1.set(i, -1);
+ }
+ test_2vi_aln(a1, a1, 123, 103);
+ for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+ errn += verify("test_2vi_aln_overlap: a1", i, a1.get(i), 123);
+ }
+ for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2vi_aln_overlap: a1", i, a1.get(i), 103);
+ }
+
+ // Reset for unaligned overlap initialization
+ for (int i=0; i<UNALIGN_OFF; i++) {
+ a1.set(i, i);
+ }
+ for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+ a1.set(i, -1);
+ }
+ test_cp_unalndst(a1, a1);
+ for (int i=0; i<ARRLEN; i++) {
+ int v = i%UNALIGN_OFF;
+ errn += verify("test_cp_unalndst_overlap: a1", i, a1.get(i), v);
+ }
+ for (int i=0; i<UNALIGN_OFF; i++) {
+ a1.set((i+UNALIGN_OFF), -1);
+ }
+ test_cp_unalnsrc(a1, a1);
+ for (int i=0; i<UNALIGN_OFF; i++) {
+ errn += verify("test_cp_unalnsrc_overlap: a1", i, a1.get(i), -1);
+ }
+ for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+ int v = i%UNALIGN_OFF;
+ errn += verify("test_cp_unalnsrc_overlap: a1", i, a1.get(i), v);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1.set(i, -1);
+ }
+ test_2ci_unaln(a1, a1);
+ for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+ errn += verify("test_2ci_unaln_overlap: a1", i, a1.get(i), -103);
+ }
+ for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2ci_unaln_overlap: a1", i, a1.get(i), -123);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1.set(i, -1);
+ }
+ test_2vi_unaln(a1, a1, 123, 103);
+ for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+ errn += verify("test_2vi_unaln_overlap: a1", i, a1.get(i), 123);
+ }
+ for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2vi_unaln_overlap: a1", i, a1.get(i), 103);
+ }
+
+ }
+
+ if (errn > 0 || test_only)
+ return errn;
+
+ // Initialize
+ for (int i=0; i<ARRLEN; i++) {
+ a1.set(i, -1);
+ a2.set(i, -1);
+ }
+ System.out.println("Time");
+ long start, end;
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_ci(a1);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_ci: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_vi(a2, 123, -1);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_vi: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_ci_neg(a1, 123);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_ci_neg: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_vi_neg(a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_vi_neg: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_neg(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_neg: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_neg(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_neg: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_neg(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_neg: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_ci_oppos(a1, 123);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_ci_oppos: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_vi_oppos(a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_vi_oppos: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_oppos(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_oppos: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_oppos(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_oppos: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_oppos(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_oppos: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_ci_off(a1, 123);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_ci_off: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_vi_off(a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_vi_off: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_off(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_off: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_off(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_off: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_off(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_off: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_ci_inv(a1, OFFSET, 123);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_ci_inv: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_vi_inv(a2, 123, OFFSET, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_vi_inv: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_inv(a1, a2, OFFSET);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_inv: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_inv(a1, a2, OFFSET);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_inv: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_inv(a1, a2, 123, 103, OFFSET);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_inv: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_ci_scl(a1, 123);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_ci_scl: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_vi_scl(a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_vi_scl: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_scl(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_scl: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_scl(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_scl: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_scl(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_scl: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_alndst(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_alndst: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_alnsrc(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_alnsrc: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_aln(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_aln: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_aln(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_aln: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_unalndst(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_unalndst: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_unalnsrc(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_unalnsrc: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_unaln(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_unaln: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_unaln(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_unaln: " + (end - start));
+
+ return errn;
+ }
+
+ static void test_ci(AtomicIntegerArray a) {
+ for (int i = 0; i < ARRLEN; i+=1) {
+ a.compareAndSet(i, -1, -123);
+ }
+ }
+ static void test_vi(AtomicIntegerArray a, int b, int old) {
+ for (int i = 0; i < ARRLEN; i+=1) {
+ a.compareAndSet(i, old, b);
+ }
+ }
+ static void test_cp(AtomicIntegerArray a, AtomicIntegerArray b) {
+ for (int i = 0; i < ARRLEN; i+=1) {
+ a.compareAndSet(i, -123, b.get(i));
+ }
+ }
+ static void test_2ci(AtomicIntegerArray a, AtomicIntegerArray b) {
+ for (int i = 0; i < ARRLEN; i+=1) {
+ a.compareAndSet(i, 123, -123);
+ b.compareAndSet(i, 123, -103);
+ }
+ }
+ static void test_2vi(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
+ for (int i = 0; i < ARRLEN; i+=1) {
+ a.compareAndSet(i, -123, c);
+ b.compareAndSet(i, -103, d);
+ }
+ }
+ static void test_ci_neg(AtomicIntegerArray a, int old) {
+ for (int i = ARRLEN-1; 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 --git a/test/compiler/8004867/TestIntAtomicOrdered.java b/test/compiler/8004867/TestIntAtomicOrdered.java
new file mode 100644
index 000000000..8e81f6cde
--- /dev/null
+++ b/test/compiler/8004867/TestIntAtomicOrdered.java
@@ -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<ARRLEN; i++) {
+ a1.lazySet(i, -1);
+ a2.lazySet(i, -1);
+ }
+ System.out.println("Warmup");
+ for (int i=0; i<ITERS; i++) {
+ test_ci(a1);
+ test_vi(a2, 123, -1);
+ test_cp(a1, a2);
+ test_2ci(a1, a2);
+ test_2vi(a1, a2, 123, 103);
+ test_ci_neg(a1, 123);
+ test_vi_neg(a2, 123, 103);
+ test_cp_neg(a1, a2);
+ test_2ci_neg(a1, a2);
+ test_2vi_neg(a1, a2, 123, 103);
+ test_ci_oppos(a1, 123);
+ test_vi_oppos(a2, 123, 103);
+ test_cp_oppos(a1, a2);
+ test_2ci_oppos(a1, a2);
+ test_2vi_oppos(a1, a2, 123, 103);
+ test_ci_off(a1, 123);
+ test_vi_off(a2, 123, 103);
+ test_cp_off(a1, a2);
+ test_2ci_off(a1, a2);
+ test_2vi_off(a1, a2, 123, 103);
+ test_ci_inv(a1, OFFSET, 123);
+ test_vi_inv(a2, 123, OFFSET, 103);
+ test_cp_inv(a1, a2, OFFSET);
+ test_2ci_inv(a1, a2, OFFSET);
+ test_2vi_inv(a1, a2, 123, 103, OFFSET);
+ test_ci_scl(a1, 123);
+ test_vi_scl(a2, 123, 103);
+ test_cp_scl(a1, a2);
+ test_2ci_scl(a1, a2);
+ test_2vi_scl(a1, a2, 123, 103);
+ test_cp_alndst(a1, a2);
+ test_cp_alnsrc(a1, a2);
+ test_2ci_aln(a1, a2);
+ test_2vi_aln(a1, a2, 123, 103);
+ test_cp_unalndst(a1, a2);
+ test_cp_unalnsrc(a1, a2);
+ test_2ci_unaln(a1, a2);
+ test_2vi_unaln(a1, a2, 123, 103);
+ }
+ // Initialize
+ for (int i=0; i<ARRLEN; i++) {
+ a1.lazySet(i, -1);
+ a2.lazySet(i, -1);
+ }
+ // Test and verify results
+ System.out.println("Verification");
+ int errn = 0;
+ {
+ test_ci(a1);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_ci: a1", i, a1.get(i), -123);
+ }
+ test_vi(a2, 123, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_vi: a2", i, a2.get(i), 123);
+ }
+ test_cp(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_cp: a1", i, a1.get(i), 123);
+ }
+ test_2ci(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_2ci: a1", i, a1.get(i), -123);
+ errn += verify("test_2ci: a2", i, a2.get(i), -103);
+ }
+ test_2vi(a1, a2, 123, 103);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_2vi: a1", i, a1.get(i), 123);
+ errn += verify("test_2vi: a2", i, a2.get(i), 103);
+ }
+ // Reset for negative stride
+ for (int i=0; i<ARRLEN; i++) {
+ a1.lazySet(i, -1);
+ a2.lazySet(i, -1);
+ }
+ test_ci_neg(a1, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_ci_neg: a1", i, a1.get(i), -123);
+ }
+ test_vi_neg(a2, 123, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_vi_neg: a2", i, a2.get(i), 123);
+ }
+ test_cp_neg(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_cp_neg: a1", i, a1.get(i), 123);
+ }
+ test_2ci_neg(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_2ci_neg: a1", i, a1.get(i), -123);
+ errn += verify("test_2ci_neg: a2", i, a2.get(i), -103);
+ }
+ test_2vi_neg(a1, a2, 123, 103);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_2vi_neg: a1", i, a1.get(i), 123);
+ errn += verify("test_2vi_neg: a2", i, a2.get(i), 103);
+ }
+ // Reset for opposite stride
+ for (int i=0; i<ARRLEN; i++) {
+ a1.lazySet(i, -1);
+ a2.lazySet(i, -1);
+ }
+ test_ci_oppos(a1, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_ci_oppos: a1", i, a1.get(i), -123);
+ }
+ test_vi_oppos(a2, 123, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_vi_oppos: a2", i, a2.get(i), 123);
+ }
+ test_cp_oppos(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_cp_oppos: a1", i, a1.get(i), 123);
+ }
+ test_2ci_oppos(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_2ci_oppos: a1", i, a1.get(i), -123);
+ errn += verify("test_2ci_oppos: a2", i, a2.get(i), -103);
+ }
+ test_2vi_oppos(a1, a2, 123, 103);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_2vi_oppos: a1", i, a1.get(i), 123);
+ errn += verify("test_2vi_oppos: a2", i, a2.get(i), 103);
+ }
+ // Reset for indexing with offset
+ for (int i=0; i<ARRLEN; i++) {
+ a1.lazySet(i, -1);
+ a2.lazySet(i, -1);
+ }
+ test_ci_off(a1, -1);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_ci_off: a1", i, a1.get(i), -123);
+ }
+ test_vi_off(a2, 123, -1);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_vi_off: a2", i, a2.get(i), 123);
+ }
+ test_cp_off(a1, a2);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_cp_off: a1", i, a1.get(i), 123);
+ }
+ test_2ci_off(a1, a2);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_2ci_off: a1", i, a1.get(i), -123);
+ errn += verify("test_2ci_off: a2", i, a2.get(i), -103);
+ }
+ test_2vi_off(a1, a2, 123, 103);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_2vi_off: a1", i, a1.get(i), 123);
+ errn += verify("test_2vi_off: a2", i, a2.get(i), 103);
+ }
+ for (int i=0; i<OFFSET; i++) {
+ errn += verify("test_2vi_off: a1", i, a1.get(i), -1);
+ errn += verify("test_2vi_off: a2", i, a2.get(i), -1);
+ }
+ // Reset for indexing with invariant offset
+ for (int i=0; i<ARRLEN; i++) {
+ a1.lazySet(i, -1);
+ a2.lazySet(i, -1);
+ }
+ test_ci_inv(a1, OFFSET, -1);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_ci_inv: a1", i, a1.get(i), -123);
+ }
+ test_vi_inv(a2, 123, OFFSET, -1);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_vi_inv: a2", i, a2.get(i), 123);
+ }
+ test_cp_inv(a1, a2, OFFSET);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_cp_inv: a1", i, a1.get(i), 123);
+ }
+ test_2ci_inv(a1, a2, OFFSET);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_2ci_inv: a1", i, a1.get(i), -123);
+ errn += verify("test_2ci_inv: a2", i, a2.get(i), -103);
+ }
+ test_2vi_inv(a1, a2, 123, 103, OFFSET);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_2vi_inv: a1", i, a1.get(i), 123);
+ errn += verify("test_2vi_inv: a2", i, a2.get(i), 103);
+ }
+ for (int i=0; i<OFFSET; i++) {
+ errn += verify("test_2vi_inv: a1", i, a1.get(i), -1);
+ errn += verify("test_2vi_inv: a2", i, a2.get(i), -1);
+ }
+ // Reset for indexing with scale
+ for (int i=0; i<ARRLEN; i++) {
+ a1.lazySet(i, -1);
+ a2.lazySet(i, -1);
+ }
+ test_ci_scl(a1, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ int val = (i%SCALE != 0) ? -1 : -123;
+ errn += verify("test_ci_scl: a1", i, a1.get(i), val);
+ }
+ test_vi_scl(a2, 123, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ int val = (i%SCALE != 0) ? -1 : 123;
+ errn += verify("test_vi_scl: a2", i, a2.get(i), val);
+ }
+ test_cp_scl(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ int val = (i%SCALE != 0) ? -1 : 123;
+ errn += verify("test_cp_scl: a1", i, a1.get(i), val);
+ }
+ test_2ci_scl(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ if (i%SCALE != 0) {
+ errn += verify("test_2ci_scl: a1", i, a1.get(i), -1);
+ } else if (i*SCALE < ARRLEN) {
+ errn += verify("test_2ci_scl: a1", i*SCALE, a1.get(i*SCALE), -123);
+ }
+ if (i%SCALE != 0) {
+ errn += verify("test_2ci_scl: a2", i, a2.get(i), -1);
+ } else if (i*SCALE < ARRLEN) {
+ errn += verify("test_2ci_scl: a2", i*SCALE, a2.get(i*SCALE), -103);
+ }
+ }
+ test_2vi_scl(a1, a2, 123, 103);
+ for (int i=0; i<ARRLEN; i++) {
+ if (i%SCALE != 0) {
+ errn += verify("test_2vi_scl: a1", i, a1.get(i), -1);
+ } else if (i*SCALE < ARRLEN) {
+ errn += verify("test_2vi_scl: a1", i*SCALE, a1.get(i*SCALE), 123);
+ }
+ if (i%SCALE != 0) {
+ errn += verify("test_2vi_scl: a2", i, a2.get(i), -1);
+ } else if (i*SCALE < ARRLEN) {
+ errn += verify("test_2vi_scl: a2", i*SCALE, a2.get(i*SCALE), 103);
+ }
+ }
+ // Reset for 2 arrays with relative aligned offset
+ for (int i=0; i<ARRLEN; i++) {
+ a1.lazySet(i, -1);
+ a2.lazySet(i, -1);
+ }
+ test_vi(a2, 123, -1);
+ test_cp_alndst(a1, a2);
+ for (int i=0; i<ALIGN_OFF; i++) {
+ errn += verify("test_cp_alndst: a1", i, a1.get(i), -1);
+ }
+ for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_cp_alndst: a1", i, a1.get(i), 123);
+ }
+ for (int i=0; i<ALIGN_OFF; i++) {
+ a1.lazySet(i, 123);
+ }
+ test_vi(a2, -123, 123);
+ test_cp_alnsrc(a1, a2);
+ for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+ errn += verify("test_cp_alnsrc: a1", i, a1.get(i), -123);
+ }
+ for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_cp_alnsrc: a1", i, a1.get(i), 123);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1.lazySet(i, -1);
+ a2.lazySet(i, -1);
+ }
+ test_2ci_aln(a1, a2);
+ for (int i=0; i<ALIGN_OFF; i++) {
+ errn += verify("test_2ci_aln: a1", i, a1.get(i), -1);
+ }
+ for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2ci_aln: a1", i, a1.get(i), -123);
+ }
+ for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+ errn += verify("test_2ci_aln: a2", i, a2.get(i), -103);
+ }
+ for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2ci_aln: a2", i, a2.get(i), -1);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1.lazySet(i, -1);
+ a2.lazySet(i, -1);
+ }
+ test_2vi_aln(a1, a2, 123, 103);
+ for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+ errn += verify("test_2vi_aln: a1", i, a1.get(i), 123);
+ }
+ for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2vi_aln: a1", i, a1.get(i), -1);
+ }
+ for (int i=0; i<ALIGN_OFF; i++) {
+ errn += verify("test_2vi_aln: a2", i, a2.get(i), -1);
+ }
+ for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2vi_aln: a2", i, a2.get(i), 103);
+ }
+
+ // Reset for 2 arrays with relative unaligned offset
+ for (int i=0; i<ARRLEN; i++) {
+ a1.lazySet(i, -1);
+ a2.lazySet(i, -1);
+ }
+ test_vi(a2, 123, -1);
+ test_cp_unalndst(a1, a2);
+ for (int i=0; i<UNALIGN_OFF; i++) {
+ errn += verify("test_cp_unalndst: a1", i, a1.get(i), -1);
+ }
+ for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_cp_unalndst: a1", i, a1.get(i), 123);
+ }
+ test_vi(a2, -123, 123);
+ test_cp_unalnsrc(a1, a2);
+ for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+ errn += verify("test_cp_unalnsrc: a1", i, a1.get(i), -123);
+ }
+ for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_cp_unalnsrc: a1", i, a1.get(i), 123);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1.lazySet(i, -1);
+ a2.lazySet(i, -1);
+ }
+ test_2ci_unaln(a1, a2);
+ for (int i=0; i<UNALIGN_OFF; i++) {
+ errn += verify("test_2ci_unaln: a1", i, a1.get(i), -1);
+ }
+ for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2ci_unaln: a1", i, a1.get(i), -123);
+ }
+ for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+ errn += verify("test_2ci_unaln: a2", i, a2.get(i), -103);
+ }
+ for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2ci_unaln: a2", i, a2.get(i), -1);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1.lazySet(i, -1);
+ a2.lazySet(i, -1);
+ }
+ test_2vi_unaln(a1, a2, 123, 103);
+ for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+ errn += verify("test_2vi_unaln: a1", i, a1.get(i), 123);
+ }
+ for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2vi_unaln: a1", i, a1.get(i), -1);
+ }
+ for (int i=0; i<UNALIGN_OFF; i++) {
+ errn += verify("test_2vi_unaln: a2", i, a2.get(i), -1);
+ }
+ for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2vi_unaln: a2", i, a2.get(i), 103);
+ }
+
+ // Reset for aligned overlap initialization
+ for (int i=0; i<ALIGN_OFF; i++) {
+ a1.lazySet(i, i);
+ }
+ for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+ a1.lazySet(i, -1);
+ }
+ test_cp_alndst(a1, a1);
+ for (int i=0; i<ARRLEN; i++) {
+ int v = i%ALIGN_OFF;
+ errn += verify("test_cp_alndst_overlap: a1", i, a1.get(i), v);
+ }
+ for (int i=0; i<ALIGN_OFF; i++) {
+ a1.lazySet((i+ALIGN_OFF), -1);
+ }
+ test_cp_alnsrc(a1, a1);
+ for (int i=0; i<ALIGN_OFF; i++) {
+ errn += verify("test_cp_alnsrc_overlap: a1", i, a1.get(i), -1);
+ }
+ for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+ int v = i%ALIGN_OFF;
+ errn += verify("test_cp_alnsrc_overlap: a1", i, a1.get(i), v);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1.lazySet(i, -1);
+ }
+ test_2ci_aln(a1, a1);
+ for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+ errn += verify("test_2ci_aln_overlap: a1", i, a1.get(i), -103);
+ }
+ for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2ci_aln_overlap: a1", i, a1.get(i), -123);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1.lazySet(i, -1);
+ }
+ test_2vi_aln(a1, a1, 123, 103);
+ for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+ errn += verify("test_2vi_aln_overlap: a1", i, a1.get(i), 123);
+ }
+ for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2vi_aln_overlap: a1", i, a1.get(i), 103);
+ }
+
+ // Reset for unaligned overlap initialization
+ for (int i=0; i<UNALIGN_OFF; i++) {
+ a1.lazySet(i, i);
+ }
+ for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+ a1.lazySet(i, -1);
+ }
+ test_cp_unalndst(a1, a1);
+ for (int i=0; i<ARRLEN; i++) {
+ int v = i%UNALIGN_OFF;
+ errn += verify("test_cp_unalndst_overlap: a1", i, a1.get(i), v);
+ }
+ for (int i=0; i<UNALIGN_OFF; i++) {
+ a1.lazySet((i+UNALIGN_OFF), -1);
+ }
+ test_cp_unalnsrc(a1, a1);
+ for (int i=0; i<UNALIGN_OFF; i++) {
+ errn += verify("test_cp_unalnsrc_overlap: a1", i, a1.get(i), -1);
+ }
+ for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+ int v = i%UNALIGN_OFF;
+ errn += verify("test_cp_unalnsrc_overlap: a1", i, a1.get(i), v);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1.lazySet(i, -1);
+ }
+ test_2ci_unaln(a1, a1);
+ for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+ errn += verify("test_2ci_unaln_overlap: a1", i, a1.get(i), -103);
+ }
+ for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2ci_unaln_overlap: a1", i, a1.get(i), -123);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1.lazySet(i, -1);
+ }
+ test_2vi_unaln(a1, a1, 123, 103);
+ for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+ errn += verify("test_2vi_unaln_overlap: a1", i, a1.get(i), 123);
+ }
+ for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2vi_unaln_overlap: a1", i, a1.get(i), 103);
+ }
+
+ }
+
+ if (errn > 0 || test_only)
+ return errn;
+
+ // Initialize
+ for (int i=0; i<ARRLEN; i++) {
+ a1.lazySet(i, -1);
+ a2.lazySet(i, -1);
+ }
+ System.out.println("Time");
+ long start, end;
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_ci(a1);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_ci: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_vi(a2, 123, -1);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_vi: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_ci_neg(a1, 123);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_ci_neg: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_vi_neg(a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_vi_neg: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_neg(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_neg: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_neg(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_neg: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_neg(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_neg: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_ci_oppos(a1, 123);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_ci_oppos: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_vi_oppos(a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_vi_oppos: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_oppos(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_oppos: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_oppos(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_oppos: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_oppos(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_oppos: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_ci_off(a1, 123);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_ci_off: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_vi_off(a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_vi_off: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_off(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_off: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_off(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_off: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_off(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_off: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_ci_inv(a1, OFFSET, 123);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_ci_inv: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_vi_inv(a2, 123, OFFSET, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_vi_inv: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_inv(a1, a2, OFFSET);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_inv: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_inv(a1, a2, OFFSET);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_inv: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_inv(a1, a2, 123, 103, OFFSET);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_inv: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_ci_scl(a1, 123);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_ci_scl: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_vi_scl(a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_vi_scl: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_scl(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_scl: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_scl(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_scl: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_scl(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_scl: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_alndst(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_alndst: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_alnsrc(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_alnsrc: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_aln(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_aln: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_aln(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_aln: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_unalndst(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_unalndst: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_unalnsrc(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_unalnsrc: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_unaln(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_unaln: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_unaln(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_unaln: " + (end - start));
+
+ return errn;
+ }
+
+ static void test_ci(AtomicIntegerArray a) {
+ for (int i = 0; i < ARRLEN; i+=1) {
+ a.lazySet(i, -123);
+ }
+ }
+ static void test_vi(AtomicIntegerArray a, int b, int old) {
+ for (int i = 0; i < ARRLEN; i+=1) {
+ a.lazySet(i, b);
+ }
+ }
+ static void test_cp(AtomicIntegerArray a, AtomicIntegerArray b) {
+ for (int i = 0; i < ARRLEN; i+=1) {
+ a.lazySet(i, b.get(i));
+ }
+ }
+ static void test_2ci(AtomicIntegerArray a, AtomicIntegerArray b) {
+ for (int i = 0; i < ARRLEN; i+=1) {
+ a.lazySet(i, -123);
+ b.lazySet(i, -103);
+ }
+ }
+ static void test_2vi(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
+ for (int i = 0; i < ARRLEN; i+=1) {
+ a.lazySet(i, c);
+ b.lazySet(i, d);
+ }
+ }
+ static void test_ci_neg(AtomicIntegerArray a, int old) {
+ for (int i = ARRLEN-1; 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 --git a/test/compiler/8004867/TestIntAtomicVolatile.java b/test/compiler/8004867/TestIntAtomicVolatile.java
new file mode 100644
index 000000000..ed0563de4
--- /dev/null
+++ b/test/compiler/8004867/TestIntAtomicVolatile.java
@@ -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<ARRLEN; i++) {
+ a1.set(i, -1);
+ a2.set(i, -1);
+ }
+ System.out.println("Warmup");
+ for (int i=0; i<ITERS; i++) {
+ test_ci(a1);
+ test_vi(a2, 123, -1);
+ test_cp(a1, a2);
+ test_2ci(a1, a2);
+ test_2vi(a1, a2, 123, 103);
+ test_ci_neg(a1, 123);
+ test_vi_neg(a2, 123, 103);
+ test_cp_neg(a1, a2);
+ test_2ci_neg(a1, a2);
+ test_2vi_neg(a1, a2, 123, 103);
+ test_ci_oppos(a1, 123);
+ test_vi_oppos(a2, 123, 103);
+ test_cp_oppos(a1, a2);
+ test_2ci_oppos(a1, a2);
+ test_2vi_oppos(a1, a2, 123, 103);
+ test_ci_off(a1, 123);
+ test_vi_off(a2, 123, 103);
+ test_cp_off(a1, a2);
+ test_2ci_off(a1, a2);
+ test_2vi_off(a1, a2, 123, 103);
+ test_ci_inv(a1, OFFSET, 123);
+ test_vi_inv(a2, 123, OFFSET, 103);
+ test_cp_inv(a1, a2, OFFSET);
+ test_2ci_inv(a1, a2, OFFSET);
+ test_2vi_inv(a1, a2, 123, 103, OFFSET);
+ test_ci_scl(a1, 123);
+ test_vi_scl(a2, 123, 103);
+ test_cp_scl(a1, a2);
+ test_2ci_scl(a1, a2);
+ test_2vi_scl(a1, a2, 123, 103);
+ test_cp_alndst(a1, a2);
+ test_cp_alnsrc(a1, a2);
+ test_2ci_aln(a1, a2);
+ test_2vi_aln(a1, a2, 123, 103);
+ test_cp_unalndst(a1, a2);
+ test_cp_unalnsrc(a1, a2);
+ test_2ci_unaln(a1, a2);
+ test_2vi_unaln(a1, a2, 123, 103);
+ }
+ // Initialize
+ for (int i=0; i<ARRLEN; i++) {
+ a1.set(i, -1);
+ a2.set(i, -1);
+ }
+ // Test and verify results
+ System.out.println("Verification");
+ int errn = 0;
+ {
+ test_ci(a1);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_ci: a1", i, a1.get(i), -123);
+ }
+ test_vi(a2, 123, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_vi: a2", i, a2.get(i), 123);
+ }
+ test_cp(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_cp: a1", i, a1.get(i), 123);
+ }
+ test_2ci(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_2ci: a1", i, a1.get(i), -123);
+ errn += verify("test_2ci: a2", i, a2.get(i), -103);
+ }
+ test_2vi(a1, a2, 123, 103);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_2vi: a1", i, a1.get(i), 123);
+ errn += verify("test_2vi: a2", i, a2.get(i), 103);
+ }
+ // Reset for negative stride
+ for (int i=0; i<ARRLEN; i++) {
+ a1.set(i, -1);
+ a2.set(i, -1);
+ }
+ test_ci_neg(a1, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_ci_neg: a1", i, a1.get(i), -123);
+ }
+ test_vi_neg(a2, 123, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_vi_neg: a2", i, a2.get(i), 123);
+ }
+ test_cp_neg(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_cp_neg: a1", i, a1.get(i), 123);
+ }
+ test_2ci_neg(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_2ci_neg: a1", i, a1.get(i), -123);
+ errn += verify("test_2ci_neg: a2", i, a2.get(i), -103);
+ }
+ test_2vi_neg(a1, a2, 123, 103);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_2vi_neg: a1", i, a1.get(i), 123);
+ errn += verify("test_2vi_neg: a2", i, a2.get(i), 103);
+ }
+ // Reset for opposite stride
+ for (int i=0; i<ARRLEN; i++) {
+ a1.set(i, -1);
+ a2.set(i, -1);
+ }
+ test_ci_oppos(a1, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_ci_oppos: a1", i, a1.get(i), -123);
+ }
+ test_vi_oppos(a2, 123, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_vi_oppos: a2", i, a2.get(i), 123);
+ }
+ test_cp_oppos(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_cp_oppos: a1", i, a1.get(i), 123);
+ }
+ test_2ci_oppos(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_2ci_oppos: a1", i, a1.get(i), -123);
+ errn += verify("test_2ci_oppos: a2", i, a2.get(i), -103);
+ }
+ test_2vi_oppos(a1, a2, 123, 103);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_2vi_oppos: a1", i, a1.get(i), 123);
+ errn += verify("test_2vi_oppos: a2", i, a2.get(i), 103);
+ }
+ // Reset for indexing with offset
+ for (int i=0; i<ARRLEN; i++) {
+ a1.set(i, -1);
+ a2.set(i, -1);
+ }
+ test_ci_off(a1, -1);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_ci_off: a1", i, a1.get(i), -123);
+ }
+ test_vi_off(a2, 123, -1);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_vi_off: a2", i, a2.get(i), 123);
+ }
+ test_cp_off(a1, a2);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_cp_off: a1", i, a1.get(i), 123);
+ }
+ test_2ci_off(a1, a2);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_2ci_off: a1", i, a1.get(i), -123);
+ errn += verify("test_2ci_off: a2", i, a2.get(i), -103);
+ }
+ test_2vi_off(a1, a2, 123, 103);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_2vi_off: a1", i, a1.get(i), 123);
+ errn += verify("test_2vi_off: a2", i, a2.get(i), 103);
+ }
+ for (int i=0; i<OFFSET; i++) {
+ errn += verify("test_2vi_off: a1", i, a1.get(i), -1);
+ errn += verify("test_2vi_off: a2", i, a2.get(i), -1);
+ }
+ // Reset for indexing with invariant offset
+ for (int i=0; i<ARRLEN; i++) {
+ a1.set(i, -1);
+ a2.set(i, -1);
+ }
+ test_ci_inv(a1, OFFSET, -1);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_ci_inv: a1", i, a1.get(i), -123);
+ }
+ test_vi_inv(a2, 123, OFFSET, -1);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_vi_inv: a2", i, a2.get(i), 123);
+ }
+ test_cp_inv(a1, a2, OFFSET);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_cp_inv: a1", i, a1.get(i), 123);
+ }
+ test_2ci_inv(a1, a2, OFFSET);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_2ci_inv: a1", i, a1.get(i), -123);
+ errn += verify("test_2ci_inv: a2", i, a2.get(i), -103);
+ }
+ test_2vi_inv(a1, a2, 123, 103, OFFSET);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_2vi_inv: a1", i, a1.get(i), 123);
+ errn += verify("test_2vi_inv: a2", i, a2.get(i), 103);
+ }
+ for (int i=0; i<OFFSET; i++) {
+ errn += verify("test_2vi_inv: a1", i, a1.get(i), -1);
+ errn += verify("test_2vi_inv: a2", i, a2.get(i), -1);
+ }
+ // Reset for indexing with scale
+ for (int i=0; i<ARRLEN; i++) {
+ a1.set(i, -1);
+ a2.set(i, -1);
+ }
+ test_ci_scl(a1, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ int val = (i%SCALE != 0) ? -1 : -123;
+ errn += verify("test_ci_scl: a1", i, a1.get(i), val);
+ }
+ test_vi_scl(a2, 123, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ int val = (i%SCALE != 0) ? -1 : 123;
+ errn += verify("test_vi_scl: a2", i, a2.get(i), val);
+ }
+ test_cp_scl(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ int val = (i%SCALE != 0) ? -1 : 123;
+ errn += verify("test_cp_scl: a1", i, a1.get(i), val);
+ }
+ test_2ci_scl(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ if (i%SCALE != 0) {
+ errn += verify("test_2ci_scl: a1", i, a1.get(i), -1);
+ } else if (i*SCALE < ARRLEN) {
+ errn += verify("test_2ci_scl: a1", i*SCALE, a1.get(i*SCALE), -123);
+ }
+ if (i%SCALE != 0) {
+ errn += verify("test_2ci_scl: a2", i, a2.get(i), -1);
+ } else if (i*SCALE < ARRLEN) {
+ errn += verify("test_2ci_scl: a2", i*SCALE, a2.get(i*SCALE), -103);
+ }
+ }
+ test_2vi_scl(a1, a2, 123, 103);
+ for (int i=0; i<ARRLEN; i++) {
+ if (i%SCALE != 0) {
+ errn += verify("test_2vi_scl: a1", i, a1.get(i), -1);
+ } else if (i*SCALE < ARRLEN) {
+ errn += verify("test_2vi_scl: a1", i*SCALE, a1.get(i*SCALE), 123);
+ }
+ if (i%SCALE != 0) {
+ errn += verify("test_2vi_scl: a2", i, a2.get(i), -1);
+ } else if (i*SCALE < ARRLEN) {
+ errn += verify("test_2vi_scl: a2", i*SCALE, a2.get(i*SCALE), 103);
+ }
+ }
+ // Reset for 2 arrays with relative aligned offset
+ for (int i=0; i<ARRLEN; i++) {
+ a1.set(i, -1);
+ a2.set(i, -1);
+ }
+ test_vi(a2, 123, -1);
+ test_cp_alndst(a1, a2);
+ for (int i=0; i<ALIGN_OFF; i++) {
+ errn += verify("test_cp_alndst: a1", i, a1.get(i), -1);
+ }
+ for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_cp_alndst: a1", i, a1.get(i), 123);
+ }
+ for (int i=0; i<ALIGN_OFF; i++) {
+ a1.set(i, 123);
+ }
+ test_vi(a2, -123, 123);
+ test_cp_alnsrc(a1, a2);
+ for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+ errn += verify("test_cp_alnsrc: a1", i, a1.get(i), -123);
+ }
+ for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_cp_alnsrc: a1", i, a1.get(i), 123);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1.set(i, -1);
+ a2.set(i, -1);
+ }
+ test_2ci_aln(a1, a2);
+ for (int i=0; i<ALIGN_OFF; i++) {
+ errn += verify("test_2ci_aln: a1", i, a1.get(i), -1);
+ }
+ for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2ci_aln: a1", i, a1.get(i), -123);
+ }
+ for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+ errn += verify("test_2ci_aln: a2", i, a2.get(i), -103);
+ }
+ for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2ci_aln: a2", i, a2.get(i), -1);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1.set(i, -1);
+ a2.set(i, -1);
+ }
+ test_2vi_aln(a1, a2, 123, 103);
+ for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+ errn += verify("test_2vi_aln: a1", i, a1.get(i), 123);
+ }
+ for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2vi_aln: a1", i, a1.get(i), -1);
+ }
+ for (int i=0; i<ALIGN_OFF; i++) {
+ errn += verify("test_2vi_aln: a2", i, a2.get(i), -1);
+ }
+ for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2vi_aln: a2", i, a2.get(i), 103);
+ }
+
+ // Reset for 2 arrays with relative unaligned offset
+ for (int i=0; i<ARRLEN; i++) {
+ a1.set(i, -1);
+ a2.set(i, -1);
+ }
+ test_vi(a2, 123, -1);
+ test_cp_unalndst(a1, a2);
+ for (int i=0; i<UNALIGN_OFF; i++) {
+ errn += verify("test_cp_unalndst: a1", i, a1.get(i), -1);
+ }
+ for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_cp_unalndst: a1", i, a1.get(i), 123);
+ }
+ test_vi(a2, -123, 123);
+ test_cp_unalnsrc(a1, a2);
+ for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+ errn += verify("test_cp_unalnsrc: a1", i, a1.get(i), -123);
+ }
+ for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_cp_unalnsrc: a1", i, a1.get(i), 123);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1.set(i, -1);
+ a2.set(i, -1);
+ }
+ test_2ci_unaln(a1, a2);
+ for (int i=0; i<UNALIGN_OFF; i++) {
+ errn += verify("test_2ci_unaln: a1", i, a1.get(i), -1);
+ }
+ for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2ci_unaln: a1", i, a1.get(i), -123);
+ }
+ for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+ errn += verify("test_2ci_unaln: a2", i, a2.get(i), -103);
+ }
+ for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2ci_unaln: a2", i, a2.get(i), -1);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1.set(i, -1);
+ a2.set(i, -1);
+ }
+ test_2vi_unaln(a1, a2, 123, 103);
+ for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+ errn += verify("test_2vi_unaln: a1", i, a1.get(i), 123);
+ }
+ for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2vi_unaln: a1", i, a1.get(i), -1);
+ }
+ for (int i=0; i<UNALIGN_OFF; i++) {
+ errn += verify("test_2vi_unaln: a2", i, a2.get(i), -1);
+ }
+ for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2vi_unaln: a2", i, a2.get(i), 103);
+ }
+
+ // Reset for aligned overlap initialization
+ for (int i=0; i<ALIGN_OFF; i++) {
+ a1.set(i, i);
+ }
+ for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+ a1.set(i, -1);
+ }
+ test_cp_alndst(a1, a1);
+ for (int i=0; i<ARRLEN; i++) {
+ int v = i%ALIGN_OFF;
+ errn += verify("test_cp_alndst_overlap: a1", i, a1.get(i), v);
+ }
+ for (int i=0; i<ALIGN_OFF; i++) {
+ a1.set((i+ALIGN_OFF), -1);
+ }
+ test_cp_alnsrc(a1, a1);
+ for (int i=0; i<ALIGN_OFF; i++) {
+ errn += verify("test_cp_alnsrc_overlap: a1", i, a1.get(i), -1);
+ }
+ for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+ int v = i%ALIGN_OFF;
+ errn += verify("test_cp_alnsrc_overlap: a1", i, a1.get(i), v);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1.set(i, -1);
+ }
+ test_2ci_aln(a1, a1);
+ for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+ errn += verify("test_2ci_aln_overlap: a1", i, a1.get(i), -103);
+ }
+ for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2ci_aln_overlap: a1", i, a1.get(i), -123);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1.set(i, -1);
+ }
+ test_2vi_aln(a1, a1, 123, 103);
+ for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+ errn += verify("test_2vi_aln_overlap: a1", i, a1.get(i), 123);
+ }
+ for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2vi_aln_overlap: a1", i, a1.get(i), 103);
+ }
+
+ // Reset for unaligned overlap initialization
+ for (int i=0; i<UNALIGN_OFF; i++) {
+ a1.set(i, i);
+ }
+ for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+ a1.set(i, -1);
+ }
+ test_cp_unalndst(a1, a1);
+ for (int i=0; i<ARRLEN; i++) {
+ int v = i%UNALIGN_OFF;
+ errn += verify("test_cp_unalndst_overlap: a1", i, a1.get(i), v);
+ }
+ for (int i=0; i<UNALIGN_OFF; i++) {
+ a1.set((i+UNALIGN_OFF), -1);
+ }
+ test_cp_unalnsrc(a1, a1);
+ for (int i=0; i<UNALIGN_OFF; i++) {
+ errn += verify("test_cp_unalnsrc_overlap: a1", i, a1.get(i), -1);
+ }
+ for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+ int v = i%UNALIGN_OFF;
+ errn += verify("test_cp_unalnsrc_overlap: a1", i, a1.get(i), v);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1.set(i, -1);
+ }
+ test_2ci_unaln(a1, a1);
+ for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+ errn += verify("test_2ci_unaln_overlap: a1", i, a1.get(i), -103);
+ }
+ for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2ci_unaln_overlap: a1", i, a1.get(i), -123);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1.set(i, -1);
+ }
+ test_2vi_unaln(a1, a1, 123, 103);
+ for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+ errn += verify("test_2vi_unaln_overlap: a1", i, a1.get(i), 123);
+ }
+ for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2vi_unaln_overlap: a1", i, a1.get(i), 103);
+ }
+
+ }
+
+ if (errn > 0 || test_only)
+ return errn;
+
+ // Initialize
+ for (int i=0; i<ARRLEN; i++) {
+ a1.set(i, -1);
+ a2.set(i, -1);
+ }
+ System.out.println("Time");
+ long start, end;
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_ci(a1);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_ci: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_vi(a2, 123, -1);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_vi: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_ci_neg(a1, 123);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_ci_neg: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_vi_neg(a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_vi_neg: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_neg(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_neg: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_neg(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_neg: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_neg(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_neg: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_ci_oppos(a1, 123);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_ci_oppos: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_vi_oppos(a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_vi_oppos: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_oppos(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_oppos: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_oppos(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_oppos: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_oppos(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_oppos: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_ci_off(a1, 123);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_ci_off: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_vi_off(a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_vi_off: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_off(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_off: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_off(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_off: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_off(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_off: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_ci_inv(a1, OFFSET, 123);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_ci_inv: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_vi_inv(a2, 123, OFFSET, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_vi_inv: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_inv(a1, a2, OFFSET);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_inv: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_inv(a1, a2, OFFSET);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_inv: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_inv(a1, a2, 123, 103, OFFSET);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_inv: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_ci_scl(a1, 123);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_ci_scl: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_vi_scl(a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_vi_scl: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_scl(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_scl: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_scl(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_scl: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_scl(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_scl: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_alndst(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_alndst: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_alnsrc(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_alnsrc: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_aln(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_aln: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_aln(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_aln: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_unalndst(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_unalndst: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_unalnsrc(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_unalnsrc: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_unaln(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_unaln: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_unaln(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_unaln: " + (end - start));
+
+ return errn;
+ }
+
+ static void test_ci(AtomicIntegerArray a) {
+ for (int i = 0; i < ARRLEN; i+=1) {
+ a.set(i, -123);
+ }
+ }
+ static void test_vi(AtomicIntegerArray a, int b, int old) {
+ for (int i = 0; i < ARRLEN; i+=1) {
+ a.set(i, b);
+ }
+ }
+ static void test_cp(AtomicIntegerArray a, AtomicIntegerArray b) {
+ for (int i = 0; i < ARRLEN; i+=1) {
+ a.set(i, b.get(i));
+ }
+ }
+ static void test_2ci(AtomicIntegerArray a, AtomicIntegerArray b) {
+ for (int i = 0; i < ARRLEN; i+=1) {
+ a.set(i, -123);
+ b.set(i, -103);
+ }
+ }
+ static void test_2vi(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
+ for (int i = 0; i < ARRLEN; i+=1) {
+ a.set(i, c);
+ b.set(i, d);
+ }
+ }
+ static void test_ci_neg(AtomicIntegerArray a, int old) {
+ for (int i = ARRLEN-1; 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 --git a/test/compiler/8004867/TestIntUnsafeCAS.java b/test/compiler/8004867/TestIntUnsafeCAS.java
new file mode 100644
index 000000000..9489376c6
--- /dev/null
+++ b/test/compiler/8004867/TestIntUnsafeCAS.java
@@ -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<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ System.out.println("Warmup");
+ for (int i=0; i<ITERS; i++) {
+ test_ci(a1);
+ test_vi(a2, 123, -1);
+ test_cp(a1, a2);
+ test_2ci(a1, a2);
+ test_2vi(a1, a2, 123, 103);
+ test_ci_neg(a1, 123);
+ test_vi_neg(a2, 123, 103);
+ test_cp_neg(a1, a2);
+ test_2ci_neg(a1, a2);
+ test_2vi_neg(a1, a2, 123, 103);
+ test_ci_oppos(a1, 123);
+ test_vi_oppos(a2, 123, 103);
+ test_cp_oppos(a1, a2);
+ test_2ci_oppos(a1, a2);
+ test_2vi_oppos(a1, a2, 123, 103);
+ test_ci_off(a1, 123);
+ test_vi_off(a2, 123, 103);
+ test_cp_off(a1, a2);
+ test_2ci_off(a1, a2);
+ test_2vi_off(a1, a2, 123, 103);
+ test_ci_inv(a1, OFFSET, 123);
+ test_vi_inv(a2, 123, OFFSET, 103);
+ test_cp_inv(a1, a2, OFFSET);
+ test_2ci_inv(a1, a2, OFFSET);
+ test_2vi_inv(a1, a2, 123, 103, OFFSET);
+ test_ci_scl(a1, 123);
+ test_vi_scl(a2, 123, 103);
+ test_cp_scl(a1, a2);
+ test_2ci_scl(a1, a2);
+ test_2vi_scl(a1, a2, 123, 103);
+ test_cp_alndst(a1, a2);
+ test_cp_alnsrc(a1, a2);
+ test_2ci_aln(a1, a2);
+ test_2vi_aln(a1, a2, 123, 103);
+ test_cp_unalndst(a1, a2);
+ test_cp_unalnsrc(a1, a2);
+ test_2ci_unaln(a1, a2);
+ test_2vi_unaln(a1, a2, 123, 103);
+ }
+ // Initialize
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ // Test and verify results
+ System.out.println("Verification");
+ int errn = 0;
+ {
+ test_ci(a1);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_ci: a1", i, a1[i], -123);
+ }
+ test_vi(a2, 123, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_vi: a2", i, a2[i], 123);
+ }
+ test_cp(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_cp: a1", i, a1[i], 123);
+ }
+ test_2ci(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_2ci: a1", i, a1[i], -123);
+ errn += verify("test_2ci: a2", i, a2[i], -103);
+ }
+ test_2vi(a1, a2, 123, 103);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_2vi: a1", i, a1[i], 123);
+ errn += verify("test_2vi: a2", i, a2[i], 103);
+ }
+ // Reset for negative stride
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ test_ci_neg(a1, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_ci_neg: a1", i, a1[i], -123);
+ }
+ test_vi_neg(a2, 123, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_vi_neg: a2", i, a2[i], 123);
+ }
+ test_cp_neg(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_cp_neg: a1", i, a1[i], 123);
+ }
+ test_2ci_neg(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_2ci_neg: a1", i, a1[i], -123);
+ errn += verify("test_2ci_neg: a2", i, a2[i], -103);
+ }
+ test_2vi_neg(a1, a2, 123, 103);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_2vi_neg: a1", i, a1[i], 123);
+ errn += verify("test_2vi_neg: a2", i, a2[i], 103);
+ }
+ // Reset for opposite stride
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ test_ci_oppos(a1, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_ci_oppos: a1", i, a1[i], -123);
+ }
+ test_vi_oppos(a2, 123, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_vi_oppos: a2", i, a2[i], 123);
+ }
+ test_cp_oppos(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_cp_oppos: a1", i, a1[i], 123);
+ }
+ test_2ci_oppos(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_2ci_oppos: a1", i, a1[i], -123);
+ errn += verify("test_2ci_oppos: a2", i, a2[i], -103);
+ }
+ test_2vi_oppos(a1, a2, 123, 103);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_2vi_oppos: a1", i, a1[i], 123);
+ errn += verify("test_2vi_oppos: a2", i, a2[i], 103);
+ }
+ // Reset for indexing with offset
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ test_ci_off(a1, -1);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_ci_off: a1", i, a1[i], -123);
+ }
+ test_vi_off(a2, 123, -1);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_vi_off: a2", i, a2[i], 123);
+ }
+ test_cp_off(a1, a2);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_cp_off: a1", i, a1[i], 123);
+ }
+ test_2ci_off(a1, a2);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_2ci_off: a1", i, a1[i], -123);
+ errn += verify("test_2ci_off: a2", i, a2[i], -103);
+ }
+ test_2vi_off(a1, a2, 123, 103);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_2vi_off: a1", i, a1[i], 123);
+ errn += verify("test_2vi_off: a2", i, a2[i], 103);
+ }
+ for (int i=0; i<OFFSET; i++) {
+ errn += verify("test_2vi_off: a1", i, a1[i], -1);
+ errn += verify("test_2vi_off: a2", i, a2[i], -1);
+ }
+ // Reset for indexing with invariant offset
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ test_ci_inv(a1, OFFSET, -1);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_ci_inv: a1", i, a1[i], -123);
+ }
+ test_vi_inv(a2, 123, OFFSET, -1);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_vi_inv: a2", i, a2[i], 123);
+ }
+ test_cp_inv(a1, a2, OFFSET);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_cp_inv: a1", i, a1[i], 123);
+ }
+ test_2ci_inv(a1, a2, OFFSET);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_2ci_inv: a1", i, a1[i], -123);
+ errn += verify("test_2ci_inv: a2", i, a2[i], -103);
+ }
+ test_2vi_inv(a1, a2, 123, 103, OFFSET);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_2vi_inv: a1", i, a1[i], 123);
+ errn += verify("test_2vi_inv: a2", i, a2[i], 103);
+ }
+ for (int i=0; i<OFFSET; i++) {
+ errn += verify("test_2vi_inv: a1", i, a1[i], -1);
+ errn += verify("test_2vi_inv: a2", i, a2[i], -1);
+ }
+ // Reset for indexing with scale
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ test_ci_scl(a1, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ int val = (i%SCALE != 0) ? -1 : -123;
+ errn += verify("test_ci_scl: a1", i, a1[i], val);
+ }
+ test_vi_scl(a2, 123, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ int val = (i%SCALE != 0) ? -1 : 123;
+ errn += verify("test_vi_scl: a2", i, a2[i], val);
+ }
+ test_cp_scl(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ int val = (i%SCALE != 0) ? -1 : 123;
+ errn += verify("test_cp_scl: a1", i, a1[i], val);
+ }
+ test_2ci_scl(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ if (i%SCALE != 0) {
+ errn += verify("test_2ci_scl: a1", i, a1[i], -1);
+ } else if (i*SCALE < ARRLEN) {
+ errn += verify("test_2ci_scl: a1", i*SCALE, a1[i*SCALE], -123);
+ }
+ if (i%SCALE != 0) {
+ errn += verify("test_2ci_scl: a2", i, a2[i], -1);
+ } else if (i*SCALE < ARRLEN) {
+ errn += verify("test_2ci_scl: a2", i*SCALE, a2[i*SCALE], -103);
+ }
+ }
+ test_2vi_scl(a1, a2, 123, 103);
+ for (int i=0; i<ARRLEN; i++) {
+ if (i%SCALE != 0) {
+ errn += verify("test_2vi_scl: a1", i, a1[i], -1);
+ } else if (i*SCALE < ARRLEN) {
+ errn += verify("test_2vi_scl: a1", i*SCALE, a1[i*SCALE], 123);
+ }
+ if (i%SCALE != 0) {
+ errn += verify("test_2vi_scl: a2", i, a2[i], -1);
+ } else if (i*SCALE < ARRLEN) {
+ errn += verify("test_2vi_scl: a2", i*SCALE, a2[i*SCALE], 103);
+ }
+ }
+ // Reset for 2 arrays with relative aligned offset
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ test_vi(a2, 123, -1);
+ test_cp_alndst(a1, a2);
+ for (int i=0; i<ALIGN_OFF; i++) {
+ errn += verify("test_cp_alndst: a1", i, a1[i], -1);
+ }
+ for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_cp_alndst: a1", i, a1[i], 123);
+ }
+ for (int i=0; i<ALIGN_OFF; i++) {
+ a1[i] = 123;
+ }
+ test_vi(a2, -123, 123);
+ test_cp_alnsrc(a1, a2);
+ for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+ errn += verify("test_cp_alnsrc: a1", i, a1[i], -123);
+ }
+ for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_cp_alnsrc: a1", i, a1[i], 123);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ test_2ci_aln(a1, a2);
+ for (int i=0; i<ALIGN_OFF; i++) {
+ errn += verify("test_2ci_aln: a1", i, a1[i], -1);
+ }
+ for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2ci_aln: a1", i, a1[i], -123);
+ }
+ for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+ errn += verify("test_2ci_aln: a2", i, a2[i], -103);
+ }
+ for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2ci_aln: a2", i, a2[i], -1);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ test_2vi_aln(a1, a2, 123, 103);
+ for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+ errn += verify("test_2vi_aln: a1", i, a1[i], 123);
+ }
+ for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2vi_aln: a1", i, a1[i], -1);
+ }
+ for (int i=0; i<ALIGN_OFF; i++) {
+ errn += verify("test_2vi_aln: a2", i, a2[i], -1);
+ }
+ for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2vi_aln: a2", i, a2[i], 103);
+ }
+
+ // Reset for 2 arrays with relative unaligned offset
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ test_vi(a2, 123, -1);
+ test_cp_unalndst(a1, a2);
+ for (int i=0; i<UNALIGN_OFF; i++) {
+ errn += verify("test_cp_unalndst: a1", i, a1[i], -1);
+ }
+ for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_cp_unalndst: a1", i, a1[i], 123);
+ }
+ test_vi(a2, -123, 123);
+ test_cp_unalnsrc(a1, a2);
+ for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+ errn += verify("test_cp_unalnsrc: a1", i, a1[i], -123);
+ }
+ for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_cp_unalnsrc: a1", i, a1[i], 123);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ test_2ci_unaln(a1, a2);
+ for (int i=0; i<UNALIGN_OFF; i++) {
+ errn += verify("test_2ci_unaln: a1", i, a1[i], -1);
+ }
+ for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2ci_unaln: a1", i, a1[i], -123);
+ }
+ for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+ errn += verify("test_2ci_unaln: a2", i, a2[i], -103);
+ }
+ for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2ci_unaln: a2", i, a2[i], -1);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ test_2vi_unaln(a1, a2, 123, 103);
+ for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+ errn += verify("test_2vi_unaln: a1", i, a1[i], 123);
+ }
+ for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2vi_unaln: a1", i, a1[i], -1);
+ }
+ for (int i=0; i<UNALIGN_OFF; i++) {
+ errn += verify("test_2vi_unaln: a2", i, a2[i], -1);
+ }
+ for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2vi_unaln: a2", i, a2[i], 103);
+ }
+
+ // Reset for aligned overlap initialization
+ for (int i=0; i<ALIGN_OFF; i++) {
+ a1[i] = i;
+ }
+ for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+ a1[i] = -1;
+ }
+ test_cp_alndst(a1, a1);
+ for (int i=0; i<ARRLEN; i++) {
+ int v = i%ALIGN_OFF;
+ errn += verify("test_cp_alndst_overlap: a1", i, a1[i], v);
+ }
+ for (int i=0; i<ALIGN_OFF; i++) {
+ a1[i+ALIGN_OFF] = -1;
+ }
+ test_cp_alnsrc(a1, a1);
+ for (int i=0; i<ALIGN_OFF; i++) {
+ errn += verify("test_cp_alnsrc_overlap: a1", i, a1[i], -1);
+ }
+ for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+ int v = i%ALIGN_OFF;
+ errn += verify("test_cp_alnsrc_overlap: a1", i, a1[i], v);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ }
+ test_2ci_aln(a1, a1);
+ for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+ errn += verify("test_2ci_aln_overlap: a1", i, a1[i], -103);
+ }
+ for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2ci_aln_overlap: a1", i, a1[i], -123);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ }
+ test_2vi_aln(a1, a1, 123, 103);
+ for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+ errn += verify("test_2vi_aln_overlap: a1", i, a1[i], 123);
+ }
+ for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2vi_aln_overlap: a1", i, a1[i], 103);
+ }
+
+ // Reset for unaligned overlap initialization
+ for (int i=0; i<UNALIGN_OFF; i++) {
+ a1[i] = i;
+ }
+ for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+ a1[i] = -1;
+ }
+ test_cp_unalndst(a1, a1);
+ for (int i=0; i<ARRLEN; i++) {
+ int v = i%UNALIGN_OFF;
+ errn += verify("test_cp_unalndst_overlap: a1", i, a1[i], v);
+ }
+ for (int i=0; i<UNALIGN_OFF; i++) {
+ a1[i+UNALIGN_OFF] = -1;
+ }
+ test_cp_unalnsrc(a1, a1);
+ for (int i=0; i<UNALIGN_OFF; i++) {
+ errn += verify("test_cp_unalnsrc_overlap: a1", i, a1[i], -1);
+ }
+ for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+ int v = i%UNALIGN_OFF;
+ errn += verify("test_cp_unalnsrc_overlap: a1", i, a1[i], v);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ }
+ test_2ci_unaln(a1, a1);
+ for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+ errn += verify("test_2ci_unaln_overlap: a1", i, a1[i], -103);
+ }
+ for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2ci_unaln_overlap: a1", i, a1[i], -123);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ }
+ test_2vi_unaln(a1, a1, 123, 103);
+ for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+ errn += verify("test_2vi_unaln_overlap: a1", i, a1[i], 123);
+ }
+ for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2vi_unaln_overlap: a1", i, a1[i], 103);
+ }
+
+ }
+
+ if (errn > 0 || test_only)
+ return errn;
+
+ // Initialize
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ System.out.println("Time");
+ long start, end;
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_ci(a1);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_ci: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_vi(a2, 123, -1);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_vi: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_ci_neg(a1, 123);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_ci_neg: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_vi_neg(a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_vi_neg: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_neg(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_neg: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_neg(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_neg: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_neg(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_neg: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_ci_oppos(a1, 123);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_ci_oppos: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_vi_oppos(a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_vi_oppos: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_oppos(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_oppos: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_oppos(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_oppos: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_oppos(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_oppos: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_ci_off(a1, 123);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_ci_off: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_vi_off(a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_vi_off: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_off(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_off: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_off(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_off: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_off(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_off: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_ci_inv(a1, OFFSET, 123);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_ci_inv: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_vi_inv(a2, 123, OFFSET, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_vi_inv: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_inv(a1, a2, OFFSET);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_inv: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_inv(a1, a2, OFFSET);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_inv: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_inv(a1, a2, 123, 103, OFFSET);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_inv: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_ci_scl(a1, 123);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_ci_scl: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_vi_scl(a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_vi_scl: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_scl(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_scl: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_scl(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_scl: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_scl(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_scl: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_alndst(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_alndst: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_alnsrc(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_alnsrc: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_aln(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_aln: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_aln(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_aln: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_unalndst(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_unalndst: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_unalnsrc(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_unalnsrc: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_unaln(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_unaln: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_unaln(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_unaln: " + (end - start));
+
+ return errn;
+ }
+
+ private final static long byte_offset(int i) {
+ return ((long)i << 2) + BASE;
+ }
+
+ static void test_ci(int[] a) {
+ for (int i = 0; i < ARRLEN; i+=1) {
+ unsafe.compareAndSwapInt(a, byte_offset(i), -1, -123);
+ }
+ }
+ static void test_vi(int[] a, int b, int old) {
+ for (int i = 0; i < ARRLEN; i+=1) {
+ unsafe.compareAndSwapInt(a, byte_offset(i), old, b);
+ }
+ }
+ static void test_cp(int[] a, int[] b) {
+ for (int i = 0; i < ARRLEN; i+=1) {
+ unsafe.compareAndSwapInt(a, byte_offset(i), -123, b[i]);
+ }
+ }
+ static void test_2ci(int[] a, int[] b) {
+ for (int i = 0; i < ARRLEN; i+=1) {
+ unsafe.compareAndSwapInt(a, byte_offset(i), 123, -123);
+ unsafe.compareAndSwapInt(b, byte_offset(i), 123, -103);
+ }
+ }
+ static void test_2vi(int[] a, int[] b, int c, int d) {
+ for (int i = 0; i < ARRLEN; i+=1) {
+ unsafe.compareAndSwapInt(a, byte_offset(i), -123, c);
+ unsafe.compareAndSwapInt(b, byte_offset(i), -103, d);
+ }
+ }
+ static void test_ci_neg(int[] a, int old) {
+ for (int i = ARRLEN-1; 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 --git a/test/compiler/8004867/TestIntUnsafeOrdered.java b/test/compiler/8004867/TestIntUnsafeOrdered.java
new file mode 100644
index 000000000..6588d63e8
--- /dev/null
+++ b/test/compiler/8004867/TestIntUnsafeOrdered.java
@@ -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<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ System.out.println("Warmup");
+ for (int i=0; i<ITERS; i++) {
+ test_ci(a1);
+ test_vi(a2, 123, -1);
+ test_cp(a1, a2);
+ test_2ci(a1, a2);
+ test_2vi(a1, a2, 123, 103);
+ test_ci_neg(a1, 123);
+ test_vi_neg(a2, 123, 103);
+ test_cp_neg(a1, a2);
+ test_2ci_neg(a1, a2);
+ test_2vi_neg(a1, a2, 123, 103);
+ test_ci_oppos(a1, 123);
+ test_vi_oppos(a2, 123, 103);
+ test_cp_oppos(a1, a2);
+ test_2ci_oppos(a1, a2);
+ test_2vi_oppos(a1, a2, 123, 103);
+ test_ci_off(a1, 123);
+ test_vi_off(a2, 123, 103);
+ test_cp_off(a1, a2);
+ test_2ci_off(a1, a2);
+ test_2vi_off(a1, a2, 123, 103);
+ test_ci_inv(a1, OFFSET, 123);
+ test_vi_inv(a2, 123, OFFSET, 103);
+ test_cp_inv(a1, a2, OFFSET);
+ test_2ci_inv(a1, a2, OFFSET);
+ test_2vi_inv(a1, a2, 123, 103, OFFSET);
+ test_ci_scl(a1, 123);
+ test_vi_scl(a2, 123, 103);
+ test_cp_scl(a1, a2);
+ test_2ci_scl(a1, a2);
+ test_2vi_scl(a1, a2, 123, 103);
+ test_cp_alndst(a1, a2);
+ test_cp_alnsrc(a1, a2);
+ test_2ci_aln(a1, a2);
+ test_2vi_aln(a1, a2, 123, 103);
+ test_cp_unalndst(a1, a2);
+ test_cp_unalnsrc(a1, a2);
+ test_2ci_unaln(a1, a2);
+ test_2vi_unaln(a1, a2, 123, 103);
+ }
+ // Initialize
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ // Test and verify results
+ System.out.println("Verification");
+ int errn = 0;
+ {
+ test_ci(a1);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_ci: a1", i, a1[i], -123);
+ }
+ test_vi(a2, 123, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_vi: a2", i, a2[i], 123);
+ }
+ test_cp(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_cp: a1", i, a1[i], 123);
+ }
+ test_2ci(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_2ci: a1", i, a1[i], -123);
+ errn += verify("test_2ci: a2", i, a2[i], -103);
+ }
+ test_2vi(a1, a2, 123, 103);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_2vi: a1", i, a1[i], 123);
+ errn += verify("test_2vi: a2", i, a2[i], 103);
+ }
+ // Reset for negative stride
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ test_ci_neg(a1, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_ci_neg: a1", i, a1[i], -123);
+ }
+ test_vi_neg(a2, 123, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_vi_neg: a2", i, a2[i], 123);
+ }
+ test_cp_neg(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_cp_neg: a1", i, a1[i], 123);
+ }
+ test_2ci_neg(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_2ci_neg: a1", i, a1[i], -123);
+ errn += verify("test_2ci_neg: a2", i, a2[i], -103);
+ }
+ test_2vi_neg(a1, a2, 123, 103);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_2vi_neg: a1", i, a1[i], 123);
+ errn += verify("test_2vi_neg: a2", i, a2[i], 103);
+ }
+ // Reset for opposite stride
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ test_ci_oppos(a1, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_ci_oppos: a1", i, a1[i], -123);
+ }
+ test_vi_oppos(a2, 123, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_vi_oppos: a2", i, a2[i], 123);
+ }
+ test_cp_oppos(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_cp_oppos: a1", i, a1[i], 123);
+ }
+ test_2ci_oppos(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_2ci_oppos: a1", i, a1[i], -123);
+ errn += verify("test_2ci_oppos: a2", i, a2[i], -103);
+ }
+ test_2vi_oppos(a1, a2, 123, 103);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_2vi_oppos: a1", i, a1[i], 123);
+ errn += verify("test_2vi_oppos: a2", i, a2[i], 103);
+ }
+ // Reset for indexing with offset
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ test_ci_off(a1, -1);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_ci_off: a1", i, a1[i], -123);
+ }
+ test_vi_off(a2, 123, -1);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_vi_off: a2", i, a2[i], 123);
+ }
+ test_cp_off(a1, a2);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_cp_off: a1", i, a1[i], 123);
+ }
+ test_2ci_off(a1, a2);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_2ci_off: a1", i, a1[i], -123);
+ errn += verify("test_2ci_off: a2", i, a2[i], -103);
+ }
+ test_2vi_off(a1, a2, 123, 103);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_2vi_off: a1", i, a1[i], 123);
+ errn += verify("test_2vi_off: a2", i, a2[i], 103);
+ }
+ for (int i=0; i<OFFSET; i++) {
+ errn += verify("test_2vi_off: a1", i, a1[i], -1);
+ errn += verify("test_2vi_off: a2", i, a2[i], -1);
+ }
+ // Reset for indexing with invariant offset
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ test_ci_inv(a1, OFFSET, -1);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_ci_inv: a1", i, a1[i], -123);
+ }
+ test_vi_inv(a2, 123, OFFSET, -1);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_vi_inv: a2", i, a2[i], 123);
+ }
+ test_cp_inv(a1, a2, OFFSET);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_cp_inv: a1", i, a1[i], 123);
+ }
+ test_2ci_inv(a1, a2, OFFSET);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_2ci_inv: a1", i, a1[i], -123);
+ errn += verify("test_2ci_inv: a2", i, a2[i], -103);
+ }
+ test_2vi_inv(a1, a2, 123, 103, OFFSET);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_2vi_inv: a1", i, a1[i], 123);
+ errn += verify("test_2vi_inv: a2", i, a2[i], 103);
+ }
+ for (int i=0; i<OFFSET; i++) {
+ errn += verify("test_2vi_inv: a1", i, a1[i], -1);
+ errn += verify("test_2vi_inv: a2", i, a2[i], -1);
+ }
+ // Reset for indexing with scale
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ test_ci_scl(a1, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ int val = (i%SCALE != 0) ? -1 : -123;
+ errn += verify("test_ci_scl: a1", i, a1[i], val);
+ }
+ test_vi_scl(a2, 123, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ int val = (i%SCALE != 0) ? -1 : 123;
+ errn += verify("test_vi_scl: a2", i, a2[i], val);
+ }
+ test_cp_scl(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ int val = (i%SCALE != 0) ? -1 : 123;
+ errn += verify("test_cp_scl: a1", i, a1[i], val);
+ }
+ test_2ci_scl(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ if (i%SCALE != 0) {
+ errn += verify("test_2ci_scl: a1", i, a1[i], -1);
+ } else if (i*SCALE < ARRLEN) {
+ errn += verify("test_2ci_scl: a1", i*SCALE, a1[i*SCALE], -123);
+ }
+ if (i%SCALE != 0) {
+ errn += verify("test_2ci_scl: a2", i, a2[i], -1);
+ } else if (i*SCALE < ARRLEN) {
+ errn += verify("test_2ci_scl: a2", i*SCALE, a2[i*SCALE], -103);
+ }
+ }
+ test_2vi_scl(a1, a2, 123, 103);
+ for (int i=0; i<ARRLEN; i++) {
+ if (i%SCALE != 0) {
+ errn += verify("test_2vi_scl: a1", i, a1[i], -1);
+ } else if (i*SCALE < ARRLEN) {
+ errn += verify("test_2vi_scl: a1", i*SCALE, a1[i*SCALE], 123);
+ }
+ if (i%SCALE != 0) {
+ errn += verify("test_2vi_scl: a2", i, a2[i], -1);
+ } else if (i*SCALE < ARRLEN) {
+ errn += verify("test_2vi_scl: a2", i*SCALE, a2[i*SCALE], 103);
+ }
+ }
+ // Reset for 2 arrays with relative aligned offset
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ test_vi(a2, 123, -1);
+ test_cp_alndst(a1, a2);
+ for (int i=0; i<ALIGN_OFF; i++) {
+ errn += verify("test_cp_alndst: a1", i, a1[i], -1);
+ }
+ for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_cp_alndst: a1", i, a1[i], 123);
+ }
+ for (int i=0; i<ALIGN_OFF; i++) {
+ a1[i] = 123;
+ }
+ test_vi(a2, -123, 123);
+ test_cp_alnsrc(a1, a2);
+ for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+ errn += verify("test_cp_alnsrc: a1", i, a1[i], -123);
+ }
+ for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_cp_alnsrc: a1", i, a1[i], 123);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ test_2ci_aln(a1, a2);
+ for (int i=0; i<ALIGN_OFF; i++) {
+ errn += verify("test_2ci_aln: a1", i, a1[i], -1);
+ }
+ for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2ci_aln: a1", i, a1[i], -123);
+ }
+ for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+ errn += verify("test_2ci_aln: a2", i, a2[i], -103);
+ }
+ for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2ci_aln: a2", i, a2[i], -1);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ test_2vi_aln(a1, a2, 123, 103);
+ for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+ errn += verify("test_2vi_aln: a1", i, a1[i], 123);
+ }
+ for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2vi_aln: a1", i, a1[i], -1);
+ }
+ for (int i=0; i<ALIGN_OFF; i++) {
+ errn += verify("test_2vi_aln: a2", i, a2[i], -1);
+ }
+ for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2vi_aln: a2", i, a2[i], 103);
+ }
+
+ // Reset for 2 arrays with relative unaligned offset
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ test_vi(a2, 123, -1);
+ test_cp_unalndst(a1, a2);
+ for (int i=0; i<UNALIGN_OFF; i++) {
+ errn += verify("test_cp_unalndst: a1", i, a1[i], -1);
+ }
+ for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_cp_unalndst: a1", i, a1[i], 123);
+ }
+ test_vi(a2, -123, 123);
+ test_cp_unalnsrc(a1, a2);
+ for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+ errn += verify("test_cp_unalnsrc: a1", i, a1[i], -123);
+ }
+ for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_cp_unalnsrc: a1", i, a1[i], 123);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ test_2ci_unaln(a1, a2);
+ for (int i=0; i<UNALIGN_OFF; i++) {
+ errn += verify("test_2ci_unaln: a1", i, a1[i], -1);
+ }
+ for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2ci_unaln: a1", i, a1[i], -123);
+ }
+ for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+ errn += verify("test_2ci_unaln: a2", i, a2[i], -103);
+ }
+ for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2ci_unaln: a2", i, a2[i], -1);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ test_2vi_unaln(a1, a2, 123, 103);
+ for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+ errn += verify("test_2vi_unaln: a1", i, a1[i], 123);
+ }
+ for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2vi_unaln: a1", i, a1[i], -1);
+ }
+ for (int i=0; i<UNALIGN_OFF; i++) {
+ errn += verify("test_2vi_unaln: a2", i, a2[i], -1);
+ }
+ for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2vi_unaln: a2", i, a2[i], 103);
+ }
+
+ // Reset for aligned overlap initialization
+ for (int i=0; i<ALIGN_OFF; i++) {
+ a1[i] = i;
+ }
+ for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+ a1[i] = -1;
+ }
+ test_cp_alndst(a1, a1);
+ for (int i=0; i<ARRLEN; i++) {
+ int v = i%ALIGN_OFF;
+ errn += verify("test_cp_alndst_overlap: a1", i, a1[i], v);
+ }
+ for (int i=0; i<ALIGN_OFF; i++) {
+ a1[i+ALIGN_OFF] = -1;
+ }
+ test_cp_alnsrc(a1, a1);
+ for (int i=0; i<ALIGN_OFF; i++) {
+ errn += verify("test_cp_alnsrc_overlap: a1", i, a1[i], -1);
+ }
+ for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+ int v = i%ALIGN_OFF;
+ errn += verify("test_cp_alnsrc_overlap: a1", i, a1[i], v);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ }
+ test_2ci_aln(a1, a1);
+ for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+ errn += verify("test_2ci_aln_overlap: a1", i, a1[i], -103);
+ }
+ for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2ci_aln_overlap: a1", i, a1[i], -123);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ }
+ test_2vi_aln(a1, a1, 123, 103);
+ for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+ errn += verify("test_2vi_aln_overlap: a1", i, a1[i], 123);
+ }
+ for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2vi_aln_overlap: a1", i, a1[i], 103);
+ }
+
+ // Reset for unaligned overlap initialization
+ for (int i=0; i<UNALIGN_OFF; i++) {
+ a1[i] = i;
+ }
+ for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+ a1[i] = -1;
+ }
+ test_cp_unalndst(a1, a1);
+ for (int i=0; i<ARRLEN; i++) {
+ int v = i%UNALIGN_OFF;
+ errn += verify("test_cp_unalndst_overlap: a1", i, a1[i], v);
+ }
+ for (int i=0; i<UNALIGN_OFF; i++) {
+ a1[i+UNALIGN_OFF] = -1;
+ }
+ test_cp_unalnsrc(a1, a1);
+ for (int i=0; i<UNALIGN_OFF; i++) {
+ errn += verify("test_cp_unalnsrc_overlap: a1", i, a1[i], -1);
+ }
+ for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+ int v = i%UNALIGN_OFF;
+ errn += verify("test_cp_unalnsrc_overlap: a1", i, a1[i], v);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ }
+ test_2ci_unaln(a1, a1);
+ for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+ errn += verify("test_2ci_unaln_overlap: a1", i, a1[i], -103);
+ }
+ for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2ci_unaln_overlap: a1", i, a1[i], -123);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ }
+ test_2vi_unaln(a1, a1, 123, 103);
+ for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+ errn += verify("test_2vi_unaln_overlap: a1", i, a1[i], 123);
+ }
+ for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2vi_unaln_overlap: a1", i, a1[i], 103);
+ }
+
+ }
+
+ if (errn > 0 || test_only)
+ return errn;
+
+ // Initialize
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ System.out.println("Time");
+ long start, end;
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_ci(a1);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_ci: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_vi(a2, 123, -1);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_vi: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_ci_neg(a1, 123);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_ci_neg: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_vi_neg(a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_vi_neg: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_neg(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_neg: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_neg(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_neg: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_neg(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_neg: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_ci_oppos(a1, 123);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_ci_oppos: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_vi_oppos(a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_vi_oppos: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_oppos(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_oppos: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_oppos(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_oppos: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_oppos(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_oppos: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_ci_off(a1, 123);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_ci_off: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_vi_off(a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_vi_off: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_off(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_off: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_off(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_off: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_off(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_off: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_ci_inv(a1, OFFSET, 123);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_ci_inv: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_vi_inv(a2, 123, OFFSET, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_vi_inv: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_inv(a1, a2, OFFSET);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_inv: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_inv(a1, a2, OFFSET);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_inv: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_inv(a1, a2, 123, 103, OFFSET);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_inv: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_ci_scl(a1, 123);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_ci_scl: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_vi_scl(a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_vi_scl: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_scl(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_scl: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_scl(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_scl: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_scl(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_scl: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_alndst(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_alndst: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_alnsrc(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_alnsrc: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_aln(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_aln: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_aln(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_aln: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_unalndst(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_unalndst: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_unalnsrc(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_unalnsrc: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_unaln(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_unaln: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_unaln(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_unaln: " + (end - start));
+
+ return errn;
+ }
+
+ private final static long byte_offset(int i) {
+ return ((long)i << 2) + BASE;
+ }
+
+ static void test_ci(int[] a) {
+ for (int i = 0; i < ARRLEN; i+=1) {
+ unsafe.putOrderedInt(a, byte_offset(i), -123);
+ }
+ }
+ static void test_vi(int[] a, int b, int old) {
+ for (int i = 0; i < ARRLEN; i+=1) {
+ unsafe.putOrderedInt(a, byte_offset(i), b);
+ }
+ }
+ static void test_cp(int[] a, int[] b) {
+ for (int i = 0; i < ARRLEN; i+=1) {
+ unsafe.putOrderedInt(a, byte_offset(i), b[i]);
+ }
+ }
+ static void test_2ci(int[] a, int[] b) {
+ for (int i = 0; i < ARRLEN; i+=1) {
+ unsafe.putOrderedInt(a, byte_offset(i), -123);
+ unsafe.putOrderedInt(b, byte_offset(i), -103);
+ }
+ }
+ static void test_2vi(int[] a, int[] b, int c, int d) {
+ for (int i = 0; i < ARRLEN; i+=1) {
+ unsafe.putOrderedInt(a, byte_offset(i), c);
+ unsafe.putOrderedInt(b, byte_offset(i), d);
+ }
+ }
+ static void test_ci_neg(int[] a, int old) {
+ for (int i = ARRLEN-1; 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 --git a/test/compiler/8004867/TestIntUnsafeVolatile.java b/test/compiler/8004867/TestIntUnsafeVolatile.java
new file mode 100644
index 000000000..84ecd10c2
--- /dev/null
+++ b/test/compiler/8004867/TestIntUnsafeVolatile.java
@@ -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<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ System.out.println("Warmup");
+ for (int i=0; i<ITERS; i++) {
+ test_ci(a1);
+ test_vi(a2, 123, -1);
+ test_cp(a1, a2);
+ test_2ci(a1, a2);
+ test_2vi(a1, a2, 123, 103);
+ test_ci_neg(a1, 123);
+ test_vi_neg(a2, 123, 103);
+ test_cp_neg(a1, a2);
+ test_2ci_neg(a1, a2);
+ test_2vi_neg(a1, a2, 123, 103);
+ test_ci_oppos(a1, 123);
+ test_vi_oppos(a2, 123, 103);
+ test_cp_oppos(a1, a2);
+ test_2ci_oppos(a1, a2);
+ test_2vi_oppos(a1, a2, 123, 103);
+ test_ci_off(a1, 123);
+ test_vi_off(a2, 123, 103);
+ test_cp_off(a1, a2);
+ test_2ci_off(a1, a2);
+ test_2vi_off(a1, a2, 123, 103);
+ test_ci_inv(a1, OFFSET, 123);
+ test_vi_inv(a2, 123, OFFSET, 103);
+ test_cp_inv(a1, a2, OFFSET);
+ test_2ci_inv(a1, a2, OFFSET);
+ test_2vi_inv(a1, a2, 123, 103, OFFSET);
+ test_ci_scl(a1, 123);
+ test_vi_scl(a2, 123, 103);
+ test_cp_scl(a1, a2);
+ test_2ci_scl(a1, a2);
+ test_2vi_scl(a1, a2, 123, 103);
+ test_cp_alndst(a1, a2);
+ test_cp_alnsrc(a1, a2);
+ test_2ci_aln(a1, a2);
+ test_2vi_aln(a1, a2, 123, 103);
+ test_cp_unalndst(a1, a2);
+ test_cp_unalnsrc(a1, a2);
+ test_2ci_unaln(a1, a2);
+ test_2vi_unaln(a1, a2, 123, 103);
+ }
+ // Initialize
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ // Test and verify results
+ System.out.println("Verification");
+ int errn = 0;
+ {
+ test_ci(a1);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_ci: a1", i, a1[i], -123);
+ }
+ test_vi(a2, 123, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_vi: a2", i, a2[i], 123);
+ }
+ test_cp(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_cp: a1", i, a1[i], 123);
+ }
+ test_2ci(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_2ci: a1", i, a1[i], -123);
+ errn += verify("test_2ci: a2", i, a2[i], -103);
+ }
+ test_2vi(a1, a2, 123, 103);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_2vi: a1", i, a1[i], 123);
+ errn += verify("test_2vi: a2", i, a2[i], 103);
+ }
+ // Reset for negative stride
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ test_ci_neg(a1, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_ci_neg: a1", i, a1[i], -123);
+ }
+ test_vi_neg(a2, 123, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_vi_neg: a2", i, a2[i], 123);
+ }
+ test_cp_neg(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_cp_neg: a1", i, a1[i], 123);
+ }
+ test_2ci_neg(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_2ci_neg: a1", i, a1[i], -123);
+ errn += verify("test_2ci_neg: a2", i, a2[i], -103);
+ }
+ test_2vi_neg(a1, a2, 123, 103);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_2vi_neg: a1", i, a1[i], 123);
+ errn += verify("test_2vi_neg: a2", i, a2[i], 103);
+ }
+ // Reset for opposite stride
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ test_ci_oppos(a1, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_ci_oppos: a1", i, a1[i], -123);
+ }
+ test_vi_oppos(a2, 123, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_vi_oppos: a2", i, a2[i], 123);
+ }
+ test_cp_oppos(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_cp_oppos: a1", i, a1[i], 123);
+ }
+ test_2ci_oppos(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_2ci_oppos: a1", i, a1[i], -123);
+ errn += verify("test_2ci_oppos: a2", i, a2[i], -103);
+ }
+ test_2vi_oppos(a1, a2, 123, 103);
+ for (int i=0; i<ARRLEN; i++) {
+ errn += verify("test_2vi_oppos: a1", i, a1[i], 123);
+ errn += verify("test_2vi_oppos: a2", i, a2[i], 103);
+ }
+ // Reset for indexing with offset
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ test_ci_off(a1, -1);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_ci_off: a1", i, a1[i], -123);
+ }
+ test_vi_off(a2, 123, -1);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_vi_off: a2", i, a2[i], 123);
+ }
+ test_cp_off(a1, a2);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_cp_off: a1", i, a1[i], 123);
+ }
+ test_2ci_off(a1, a2);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_2ci_off: a1", i, a1[i], -123);
+ errn += verify("test_2ci_off: a2", i, a2[i], -103);
+ }
+ test_2vi_off(a1, a2, 123, 103);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_2vi_off: a1", i, a1[i], 123);
+ errn += verify("test_2vi_off: a2", i, a2[i], 103);
+ }
+ for (int i=0; i<OFFSET; i++) {
+ errn += verify("test_2vi_off: a1", i, a1[i], -1);
+ errn += verify("test_2vi_off: a2", i, a2[i], -1);
+ }
+ // Reset for indexing with invariant offset
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ test_ci_inv(a1, OFFSET, -1);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_ci_inv: a1", i, a1[i], -123);
+ }
+ test_vi_inv(a2, 123, OFFSET, -1);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_vi_inv: a2", i, a2[i], 123);
+ }
+ test_cp_inv(a1, a2, OFFSET);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_cp_inv: a1", i, a1[i], 123);
+ }
+ test_2ci_inv(a1, a2, OFFSET);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_2ci_inv: a1", i, a1[i], -123);
+ errn += verify("test_2ci_inv: a2", i, a2[i], -103);
+ }
+ test_2vi_inv(a1, a2, 123, 103, OFFSET);
+ for (int i=OFFSET; i<ARRLEN; i++) {
+ errn += verify("test_2vi_inv: a1", i, a1[i], 123);
+ errn += verify("test_2vi_inv: a2", i, a2[i], 103);
+ }
+ for (int i=0; i<OFFSET; i++) {
+ errn += verify("test_2vi_inv: a1", i, a1[i], -1);
+ errn += verify("test_2vi_inv: a2", i, a2[i], -1);
+ }
+ // Reset for indexing with scale
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ test_ci_scl(a1, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ int val = (i%SCALE != 0) ? -1 : -123;
+ errn += verify("test_ci_scl: a1", i, a1[i], val);
+ }
+ test_vi_scl(a2, 123, -1);
+ for (int i=0; i<ARRLEN; i++) {
+ int val = (i%SCALE != 0) ? -1 : 123;
+ errn += verify("test_vi_scl: a2", i, a2[i], val);
+ }
+ test_cp_scl(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ int val = (i%SCALE != 0) ? -1 : 123;
+ errn += verify("test_cp_scl: a1", i, a1[i], val);
+ }
+ test_2ci_scl(a1, a2);
+ for (int i=0; i<ARRLEN; i++) {
+ if (i%SCALE != 0) {
+ errn += verify("test_2ci_scl: a1", i, a1[i], -1);
+ } else if (i*SCALE < ARRLEN) {
+ errn += verify("test_2ci_scl: a1", i*SCALE, a1[i*SCALE], -123);
+ }
+ if (i%SCALE != 0) {
+ errn += verify("test_2ci_scl: a2", i, a2[i], -1);
+ } else if (i*SCALE < ARRLEN) {
+ errn += verify("test_2ci_scl: a2", i*SCALE, a2[i*SCALE], -103);
+ }
+ }
+ test_2vi_scl(a1, a2, 123, 103);
+ for (int i=0; i<ARRLEN; i++) {
+ if (i%SCALE != 0) {
+ errn += verify("test_2vi_scl: a1", i, a1[i], -1);
+ } else if (i*SCALE < ARRLEN) {
+ errn += verify("test_2vi_scl: a1", i*SCALE, a1[i*SCALE], 123);
+ }
+ if (i%SCALE != 0) {
+ errn += verify("test_2vi_scl: a2", i, a2[i], -1);
+ } else if (i*SCALE < ARRLEN) {
+ errn += verify("test_2vi_scl: a2", i*SCALE, a2[i*SCALE], 103);
+ }
+ }
+ // Reset for 2 arrays with relative aligned offset
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ test_vi(a2, 123, -1);
+ test_cp_alndst(a1, a2);
+ for (int i=0; i<ALIGN_OFF; i++) {
+ errn += verify("test_cp_alndst: a1", i, a1[i], -1);
+ }
+ for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_cp_alndst: a1", i, a1[i], 123);
+ }
+ for (int i=0; i<ALIGN_OFF; i++) {
+ a1[i] = 123;
+ }
+ test_vi(a2, -123, 123);
+ test_cp_alnsrc(a1, a2);
+ for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+ errn += verify("test_cp_alnsrc: a1", i, a1[i], -123);
+ }
+ for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_cp_alnsrc: a1", i, a1[i], 123);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ test_2ci_aln(a1, a2);
+ for (int i=0; i<ALIGN_OFF; i++) {
+ errn += verify("test_2ci_aln: a1", i, a1[i], -1);
+ }
+ for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2ci_aln: a1", i, a1[i], -123);
+ }
+ for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+ errn += verify("test_2ci_aln: a2", i, a2[i], -103);
+ }
+ for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2ci_aln: a2", i, a2[i], -1);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ test_2vi_aln(a1, a2, 123, 103);
+ for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+ errn += verify("test_2vi_aln: a1", i, a1[i], 123);
+ }
+ for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2vi_aln: a1", i, a1[i], -1);
+ }
+ for (int i=0; i<ALIGN_OFF; i++) {
+ errn += verify("test_2vi_aln: a2", i, a2[i], -1);
+ }
+ for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2vi_aln: a2", i, a2[i], 103);
+ }
+
+ // Reset for 2 arrays with relative unaligned offset
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ test_vi(a2, 123, -1);
+ test_cp_unalndst(a1, a2);
+ for (int i=0; i<UNALIGN_OFF; i++) {
+ errn += verify("test_cp_unalndst: a1", i, a1[i], -1);
+ }
+ for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_cp_unalndst: a1", i, a1[i], 123);
+ }
+ test_vi(a2, -123, 123);
+ test_cp_unalnsrc(a1, a2);
+ for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+ errn += verify("test_cp_unalnsrc: a1", i, a1[i], -123);
+ }
+ for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_cp_unalnsrc: a1", i, a1[i], 123);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ test_2ci_unaln(a1, a2);
+ for (int i=0; i<UNALIGN_OFF; i++) {
+ errn += verify("test_2ci_unaln: a1", i, a1[i], -1);
+ }
+ for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2ci_unaln: a1", i, a1[i], -123);
+ }
+ for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+ errn += verify("test_2ci_unaln: a2", i, a2[i], -103);
+ }
+ for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2ci_unaln: a2", i, a2[i], -1);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ test_2vi_unaln(a1, a2, 123, 103);
+ for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+ errn += verify("test_2vi_unaln: a1", i, a1[i], 123);
+ }
+ for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2vi_unaln: a1", i, a1[i], -1);
+ }
+ for (int i=0; i<UNALIGN_OFF; i++) {
+ errn += verify("test_2vi_unaln: a2", i, a2[i], -1);
+ }
+ for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2vi_unaln: a2", i, a2[i], 103);
+ }
+
+ // Reset for aligned overlap initialization
+ for (int i=0; i<ALIGN_OFF; i++) {
+ a1[i] = i;
+ }
+ for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+ a1[i] = -1;
+ }
+ test_cp_alndst(a1, a1);
+ for (int i=0; i<ARRLEN; i++) {
+ int v = i%ALIGN_OFF;
+ errn += verify("test_cp_alndst_overlap: a1", i, a1[i], v);
+ }
+ for (int i=0; i<ALIGN_OFF; i++) {
+ a1[i+ALIGN_OFF] = -1;
+ }
+ test_cp_alnsrc(a1, a1);
+ for (int i=0; i<ALIGN_OFF; i++) {
+ errn += verify("test_cp_alnsrc_overlap: a1", i, a1[i], -1);
+ }
+ for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+ int v = i%ALIGN_OFF;
+ errn += verify("test_cp_alnsrc_overlap: a1", i, a1[i], v);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ }
+ test_2ci_aln(a1, a1);
+ for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+ errn += verify("test_2ci_aln_overlap: a1", i, a1[i], -103);
+ }
+ for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2ci_aln_overlap: a1", i, a1[i], -123);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ }
+ test_2vi_aln(a1, a1, 123, 103);
+ for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+ errn += verify("test_2vi_aln_overlap: a1", i, a1[i], 123);
+ }
+ for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2vi_aln_overlap: a1", i, a1[i], 103);
+ }
+
+ // Reset for unaligned overlap initialization
+ for (int i=0; i<UNALIGN_OFF; i++) {
+ a1[i] = i;
+ }
+ for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+ a1[i] = -1;
+ }
+ test_cp_unalndst(a1, a1);
+ for (int i=0; i<ARRLEN; i++) {
+ int v = i%UNALIGN_OFF;
+ errn += verify("test_cp_unalndst_overlap: a1", i, a1[i], v);
+ }
+ for (int i=0; i<UNALIGN_OFF; i++) {
+ a1[i+UNALIGN_OFF] = -1;
+ }
+ test_cp_unalnsrc(a1, a1);
+ for (int i=0; i<UNALIGN_OFF; i++) {
+ errn += verify("test_cp_unalnsrc_overlap: a1", i, a1[i], -1);
+ }
+ for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+ int v = i%UNALIGN_OFF;
+ errn += verify("test_cp_unalnsrc_overlap: a1", i, a1[i], v);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ }
+ test_2ci_unaln(a1, a1);
+ for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+ errn += verify("test_2ci_unaln_overlap: a1", i, a1[i], -103);
+ }
+ for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2ci_unaln_overlap: a1", i, a1[i], -123);
+ }
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ }
+ test_2vi_unaln(a1, a1, 123, 103);
+ for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+ errn += verify("test_2vi_unaln_overlap: a1", i, a1[i], 123);
+ }
+ for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+ errn += verify("test_2vi_unaln_overlap: a1", i, a1[i], 103);
+ }
+
+ }
+
+ if (errn > 0 || test_only)
+ return errn;
+
+ // Initialize
+ for (int i=0; i<ARRLEN; i++) {
+ a1[i] = -1;
+ a2[i] = -1;
+ }
+ System.out.println("Time");
+ long start, end;
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_ci(a1);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_ci: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_vi(a2, 123, -1);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_vi: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_ci_neg(a1, 123);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_ci_neg: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_vi_neg(a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_vi_neg: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_neg(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_neg: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_neg(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_neg: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_neg(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_neg: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_ci_oppos(a1, 123);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_ci_oppos: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_vi_oppos(a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_vi_oppos: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_oppos(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_oppos: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_oppos(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_oppos: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_oppos(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_oppos: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_ci_off(a1, 123);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_ci_off: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_vi_off(a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_vi_off: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_off(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_off: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_off(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_off: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_off(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_off: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_ci_inv(a1, OFFSET, 123);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_ci_inv: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_vi_inv(a2, 123, OFFSET, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_vi_inv: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_inv(a1, a2, OFFSET);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_inv: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_inv(a1, a2, OFFSET);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_inv: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_inv(a1, a2, 123, 103, OFFSET);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_inv: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_ci_scl(a1, 123);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_ci_scl: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_vi_scl(a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_vi_scl: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_scl(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_scl: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_scl(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_scl: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_scl(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_scl: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_alndst(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_alndst: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_alnsrc(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_alnsrc: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_aln(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_aln: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_aln(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_aln: " + (end - start));
+
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_unalndst(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_unalndst: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_cp_unalnsrc(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_cp_unalnsrc: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2ci_unaln(a1, a2);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2ci_unaln: " + (end - start));
+ start = System.currentTimeMillis();
+ for (int i=0; i<ITERS; i++) {
+ test_2vi_unaln(a1, a2, 123, 103);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("test_2vi_unaln: " + (end - start));
+
+ return errn;
+ }
+
+ private final static long byte_offset(int i) {
+ return ((long)i << 2) + BASE;
+ }
+
+ static void test_ci(int[] a) {
+ for (int i = 0; i < ARRLEN; i+=1) {
+ unsafe.putIntVolatile(a, byte_offset(i), -123);
+ }
+ }
+ static void test_vi(int[] a, int b, int old) {
+ for (int i = 0; i < ARRLEN; i+=1) {
+ unsafe.putIntVolatile(a, byte_offset(i), b);
+ }
+ }
+ static void test_cp(int[] a, int[] b) {
+ for (int i = 0; i < ARRLEN; i+=1) {
+ unsafe.putIntVolatile(a, byte_offset(i), b[i]);
+ }
+ }
+ static void test_2ci(int[] a, int[] b) {
+ for (int i = 0; i < ARRLEN; i+=1) {
+ unsafe.putIntVolatile(a, byte_offset(i), -123);
+ unsafe.putIntVolatile(b, byte_offset(i), -103);
+ }
+ }
+ static void test_2vi(int[] a, int[] b, int c, int d) {
+ for (int i = 0; i < ARRLEN; i+=1) {
+ unsafe.putIntVolatile(a, byte_offset(i), c);
+ unsafe.putIntVolatile(b, byte_offset(i), d);
+ }
+ }
+ static void test_ci_neg(int[] a, int old) {
+ for (int i = ARRLEN-1; 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;
+ }
+}
diff --git a/test/gc/8000311/Test8000311.java b/test/gc/8000311/Test8000311.java
new file mode 100644
index 000000000..2c33191c9
--- /dev/null
+++ b/test/gc/8000311/Test8000311.java
@@ -0,0 +1,42 @@
+/*
+ * 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 Test8000311
+ * @key gc
+ * @bug 8000311
+ * @summary G1: ParallelGCThreads==0 broken
+ * @run main/othervm -XX:+UseG1GC -XX:ParallelGCThreads=0 -XX:+ResizePLAB -XX:+ExplicitGCInvokesConcurrent Test8000311
+ * @author filipp.zhinkin@oracle.com
+ */
+
+import java.util.*;
+
+public class Test8000311 {
+ public static void main(String args[]) {
+ for(int i = 0; i<100; i++) {
+ byte[] garbage = new byte[1000];
+ System.gc();
+ }
+ }
+}
diff --git a/test/gc/TestG1ZeroPGCTJcmdThreadPrint.java b/test/gc/TestG1ZeroPGCTJcmdThreadPrint.java
new file mode 100644
index 000000000..efe130147
--- /dev/null
+++ b/test/gc/TestG1ZeroPGCTJcmdThreadPrint.java
@@ -0,0 +1,54 @@
+/*
+ * 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 TestG1ZeroPGCTJcmdThreadPrint
+ * @key gc
+ * @bug 8005875
+ * @summary Use jcmd to generate a thread dump of a Java program being run with PGCT=0 to verify 8005875
+ * @library /testlibrary
+ * @run main/othervm -XX:+UseG1GC -XX:ParallelGCThreads=0 -XX:+IgnoreUnrecognizedVMOptions TestG1ZeroPGCTJcmdThreadPrint
+ */
+
+import com.oracle.java.testlibrary.*;
+
+public class TestG1ZeroPGCTJcmdThreadPrint {
+ public static void main(String args[]) throws Exception {
+
+ // Grab the pid from the current java process
+ String pid = Integer.toString(ProcessTools.getProcessId());
+
+ // Create a ProcessBuilder
+ ProcessBuilder pb = new ProcessBuilder();
+
+ // Run jcmd <pid> Thread.print
+ pb.command(JDKToolFinder.getJDKTool("jcmd"), pid, "Thread.print");
+
+ OutputAnalyzer output = new OutputAnalyzer(pb.start());
+
+ // There shouldn't be a work gang for concurrent marking.
+ output.shouldNotContain("G1 Parallel Marking Threads");
+
+ // Make sure we didn't crash
+ output.shouldHaveExitValue(0);
+ }
+}
diff --git a/test/gc/startup_warnings/TestCMS.java b/test/gc/startup_warnings/TestCMS.java
new file mode 100644
index 000000000..22a071957
--- /dev/null
+++ b/test/gc/startup_warnings/TestCMS.java
@@ -0,0 +1,46 @@
+/*
+* 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 TestCMS
+* @key gc
+* @bug 8006398
+* @summary Test that CMS does not print a warning message
+* @library /testlibrary
+*/
+
+import com.oracle.java.testlibrary.OutputAnalyzer;
+import com.oracle.java.testlibrary.ProcessTools;
+
+
+public class TestCMS {
+
+ public static void main(String args[]) throws Exception {
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseConcMarkSweepGC", "-version");
+ OutputAnalyzer output = new OutputAnalyzer(pb.start());
+ output.shouldNotContain("warning");
+ output.shouldNotContain("error");
+ output.shouldHaveExitValue(0);
+ }
+
+}
diff --git a/test/gc/startup_warnings/TestCMSIncrementalMode.java b/test/gc/startup_warnings/TestCMSIncrementalMode.java
new file mode 100644
index 000000000..2103093ce
--- /dev/null
+++ b/test/gc/startup_warnings/TestCMSIncrementalMode.java
@@ -0,0 +1,46 @@
+
+/*
+* 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 TestCMSIncrementalMode
+* @key gc
+* @bug 8006398
+* @summary Test that the deprecated CMSIncrementalMode print a warning message
+* @library /testlibrary
+*/
+
+import com.oracle.java.testlibrary.OutputAnalyzer;
+import com.oracle.java.testlibrary.ProcessTools;
+
+public class TestCMSIncrementalMode {
+
+ public static void main(String args[]) throws Exception {
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseConcMarkSweepGC", "-XX:+CMSIncrementalMode", "-version");
+ OutputAnalyzer output = new OutputAnalyzer(pb.start());
+ output.shouldContain("warning: Using incremental CMS is deprecated and will likely be removed in a future release");
+ output.shouldNotContain("error");
+ output.shouldHaveExitValue(0);
+ }
+
+}
diff --git a/test/gc/startup_warnings/TestCMSNoIncrementalMode.java b/test/gc/startup_warnings/TestCMSNoIncrementalMode.java
new file mode 100644
index 000000000..f2180904e
--- /dev/null
+++ b/test/gc/startup_warnings/TestCMSNoIncrementalMode.java
@@ -0,0 +1,45 @@
+/*
+* 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 TestCMSNoIncrementalMode
+* @key gc
+* @bug 8006398
+* @summary Test that CMS with incremental mode turned off does not print a warning message
+* @library /testlibrary
+*/
+
+import com.oracle.java.testlibrary.OutputAnalyzer;
+import com.oracle.java.testlibrary.ProcessTools;
+
+public class TestCMSNoIncrementalMode {
+
+ public static void main(String args[]) throws Exception {
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseConcMarkSweepGC", "-XX:-CMSIncrementalMode", "-version");
+ OutputAnalyzer output = new OutputAnalyzer(pb.start());
+ output.shouldNotContain("warning");
+ output.shouldNotContain("error");
+ output.shouldHaveExitValue(0);
+ }
+
+}
diff --git a/test/gc/startup_warnings/TestDefNewCMS.java b/test/gc/startup_warnings/TestDefNewCMS.java
new file mode 100644
index 000000000..35360b60c
--- /dev/null
+++ b/test/gc/startup_warnings/TestDefNewCMS.java
@@ -0,0 +1,45 @@
+/*
+* 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 TestDefNewCMS
+* @key gc
+* @bug 8006398
+* @summary Test that the deprecated DefNew+CMS combination print a warning message
+* @library /testlibrary
+*/
+
+import com.oracle.java.testlibrary.OutputAnalyzer;
+import com.oracle.java.testlibrary.ProcessTools;
+
+public class TestDefNewCMS {
+
+ public static void main(String args[]) throws Exception {
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:-UseParNewGC", "-XX:+UseConcMarkSweepGC", "-version");
+ OutputAnalyzer output = new OutputAnalyzer(pb.start());
+ output.shouldContain("warning: Using the DefNew young collector with the CMS collector is deprecated and will likely be removed in a future release");
+ output.shouldNotContain("error");
+ output.shouldHaveExitValue(0);
+ }
+
+}
diff --git a/test/gc/startup_warnings/TestG1.java b/test/gc/startup_warnings/TestG1.java
new file mode 100644
index 000000000..536612bbc
--- /dev/null
+++ b/test/gc/startup_warnings/TestG1.java
@@ -0,0 +1,45 @@
+/*
+* 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 TestG1
+* @key gc
+* @bug 8006398
+* @summary Test that the G1 collector does not print a warning message
+* @library /testlibrary
+*/
+
+import com.oracle.java.testlibrary.OutputAnalyzer;
+import com.oracle.java.testlibrary.ProcessTools;
+
+public class TestG1 {
+
+ public static void main(String args[]) throws Exception {
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC", "-version");
+ OutputAnalyzer output = new OutputAnalyzer(pb.start());
+ output.shouldNotContain("warning");
+ output.shouldNotContain("error");
+ output.shouldHaveExitValue(0);
+ }
+
+}
diff --git a/test/gc/startup_warnings/TestIncGC.java b/test/gc/startup_warnings/TestIncGC.java
new file mode 100644
index 000000000..03c7f9b9f
--- /dev/null
+++ b/test/gc/startup_warnings/TestIncGC.java
@@ -0,0 +1,46 @@
+/*
+* 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 TestIncGC
+* @key gc
+* @bug 8006398
+* @summary Test that the deprecated -Xincgc print a warning message
+* @library /testlibrary
+*/
+
+import com.oracle.java.testlibrary.OutputAnalyzer;
+import com.oracle.java.testlibrary.ProcessTools;
+
+
+public class TestIncGC {
+
+ public static void main(String args[]) throws Exception {
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xincgc", "-version");
+ OutputAnalyzer output = new OutputAnalyzer(pb.start());
+ output.shouldContain("warning: Using incremental CMS is deprecated and will likely be removed in a future release");
+ output.shouldNotContain("error");
+ output.shouldHaveExitValue(0);
+ }
+
+}
diff --git a/test/gc/startup_warnings/TestParNewCMS.java b/test/gc/startup_warnings/TestParNewCMS.java
new file mode 100644
index 000000000..f74d65c66
--- /dev/null
+++ b/test/gc/startup_warnings/TestParNewCMS.java
@@ -0,0 +1,46 @@
+/*
+* 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 TestParNewCMS
+* @key gc
+* @bug 8006398
+* @summary Test that the combination ParNew+CMS does not print a warning message
+* @library /testlibrary
+*/
+
+import com.oracle.java.testlibrary.OutputAnalyzer;
+import com.oracle.java.testlibrary.ProcessTools;
+
+
+public class TestParNewCMS {
+
+ public static void main(String args[]) throws Exception {
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseParNewGC", "-XX:+UseConcMarkSweepGC", "-version");
+ OutputAnalyzer output = new OutputAnalyzer(pb.start());
+ output.shouldNotContain("warning");
+ output.shouldNotContain("error");
+ output.shouldHaveExitValue(0);
+ }
+
+}
diff --git a/test/gc/startup_warnings/TestParNewSerialOld.java b/test/gc/startup_warnings/TestParNewSerialOld.java
new file mode 100644
index 000000000..cbcea77e6
--- /dev/null
+++ b/test/gc/startup_warnings/TestParNewSerialOld.java
@@ -0,0 +1,46 @@
+/*
+* 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 TestParNewSerialOld
+* @key gc
+* @bug 8006398
+* @summary Test that the deprecated ParNew+SerialOld combination print a warning message
+* @library /testlibrary
+*/
+
+import com.oracle.java.testlibrary.OutputAnalyzer;
+import com.oracle.java.testlibrary.ProcessTools;
+
+
+public class TestParNewSerialOld {
+
+ public static void main(String args[]) throws Exception {
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseParNewGC", "-version");
+ OutputAnalyzer output = new OutputAnalyzer(pb.start());
+ output.shouldContain("warning: Using the ParNew young collector with the Serial old collector is deprecated and will likely be removed in a future release");
+ output.shouldNotContain("error");
+ output.shouldHaveExitValue(0);
+ }
+
+}
diff --git a/test/gc/startup_warnings/TestParallelGC.java b/test/gc/startup_warnings/TestParallelGC.java
new file mode 100644
index 000000000..7a0766ebc
--- /dev/null
+++ b/test/gc/startup_warnings/TestParallelGC.java
@@ -0,0 +1,46 @@
+/*
+* 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 TestParallelGC
+* @key gc
+* @bug 8006398
+* @summary Test that ParallelGC does not print a warning message
+* @library /testlibrary
+*/
+
+import com.oracle.java.testlibrary.OutputAnalyzer;
+import com.oracle.java.testlibrary.ProcessTools;
+
+
+public class TestParallelGC {
+
+ public static void main(String args[]) throws Exception {
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseParallelGC", "-version");
+ OutputAnalyzer output = new OutputAnalyzer(pb.start());
+ output.shouldNotContain("warning");
+ output.shouldNotContain("error");
+ output.shouldHaveExitValue(0);
+ }
+
+}
diff --git a/test/gc/startup_warnings/TestParallelScavengeSerialOld.java b/test/gc/startup_warnings/TestParallelScavengeSerialOld.java
new file mode 100644
index 000000000..27a25b23d
--- /dev/null
+++ b/test/gc/startup_warnings/TestParallelScavengeSerialOld.java
@@ -0,0 +1,46 @@
+/*
+* 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 TestParallelScavengeSerialOld
+* @key gc
+* @bug 8006398
+* @summary Test that the ParallelScavenge+SerialOld combination does not print a warning message
+* @library /testlibrary
+*/
+
+import com.oracle.java.testlibrary.OutputAnalyzer;
+import com.oracle.java.testlibrary.ProcessTools;
+
+
+public class TestParallelScavengeSerialOld {
+
+ public static void main(String args[]) throws Exception {
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseParallelGC", "-XX:-UseParallelOldGC", "-version");
+ OutputAnalyzer output = new OutputAnalyzer(pb.start());
+ output.shouldNotContain("warning");
+ output.shouldNotContain("error");
+ output.shouldHaveExitValue(0);
+ }
+
+}
diff --git a/test/gc/startup_warnings/TestSerialGC.java b/test/gc/startup_warnings/TestSerialGC.java
new file mode 100644
index 000000000..d84fd5d96
--- /dev/null
+++ b/test/gc/startup_warnings/TestSerialGC.java
@@ -0,0 +1,46 @@
+/*
+* 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 TestSerialGC
+* @key gc
+* @bug 8006398
+* @summary Test that SerialGC does not print a warning message
+* @library /testlibrary
+*/
+
+import com.oracle.java.testlibrary.OutputAnalyzer;
+import com.oracle.java.testlibrary.ProcessTools;
+
+
+public class TestSerialGC {
+
+ public static void main(String args[]) throws Exception {
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseSerialGC", "-version");
+ OutputAnalyzer output = new OutputAnalyzer(pb.start());
+ output.shouldNotContain("warning");
+ output.shouldNotContain("error");
+ output.shouldHaveExitValue(0);
+ }
+
+}
diff --git a/test/runtime/8007736/TestStaticIF.java b/test/runtime/8007736/TestStaticIF.java
new file mode 100644
index 000000000..d3c3239e8
--- /dev/null
+++ b/test/runtime/8007736/TestStaticIF.java
@@ -0,0 +1,44 @@
+/*
+ * 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 8007736
+ * @summary Test static interface method.
+ * @run main/othervm -Xverify:all TestStaticIF
+ */
+
+public class TestStaticIF implements StaticMethodInInterface {
+
+ public static void main(String[] args) {
+ System.out.printf("main: %s%n", StaticMethodInInterface.get());
+ }
+}
+
+interface StaticMethodInInterface {
+
+ public static String get() {
+ return "Hello from StaticMethodInInterface.get()";
+ }
+}