changeset 26:6c339a5aa00d

scratch: experimental VW_Sync tests
author shade
date Thu, 11 Jul 2013 14:48:15 +0400
parents 2dec45c6dfc0
children f5c6d0f7fcd3
files tests-custom/src/main/java/org/openjdk/jcstress/tests/scratch/VW_Sync_1_Test.java tests-custom/src/main/java/org/openjdk/jcstress/tests/scratch/VW_Sync_2_Test.java tests-custom/src/main/resources/org/openjdk/jcstress/desc/scratch.xml
diffstat 3 files changed, 134 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests-custom/src/main/java/org/openjdk/jcstress/tests/scratch/VW_Sync_1_Test.java	Thu Jul 11 14:48:15 2013 +0400
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2005, 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.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.
+ */
+package org.openjdk.jcstress.tests.scratch;
+
+import org.openjdk.jcstress.infra.results.IntResult2;
+import org.openjdk.jcstress.tests.Actor2_Test;
+
+/**
+ * Dummy test to check if volatile write's StoreLoad is erased by following biased lock
+ * Run with -XX:BiasedLockingStartupDelay=0
+ */
+public class VW_Sync_1_Test implements Actor2_Test<VW_Sync_1_Test.State, IntResult2> {
+
+    @Override
+    public void actor1(State s, IntResult2 r) {
+        synchronized (s.o) {} // bias first
+        s.x = 1;
+        s.v = 1;
+        synchronized (s.o) {}
+    }
+
+    @Override
+    public void actor2(State s, IntResult2 r) {
+        r.r1 = s.v;
+        r.r2 = s.x;
+    }
+
+    @Override
+    public State newState() {
+        return new State();
+    }
+
+    @Override
+    public IntResult2 newResult() {
+        return new IntResult2();
+    }
+
+    public static class State  {
+        public int x;
+        public volatile int v;
+        public final Object o = new Object();
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests-custom/src/main/java/org/openjdk/jcstress/tests/scratch/VW_Sync_2_Test.java	Thu Jul 11 14:48:15 2013 +0400
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2005, 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.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.
+ */
+package org.openjdk.jcstress.tests.scratch;
+
+import org.openjdk.jcstress.infra.results.IntResult2;
+import org.openjdk.jcstress.tests.Actor2_Test;
+
+/**
+ * Dummy test to check if volatile write's StoreLoad is erased by following biased lock
+ * Run with -XX:BiasedLockingStartupDelay=0
+ */
+public class VW_Sync_2_Test implements Actor2_Test<VW_Sync_2_Test.State, IntResult2> {
+
+    @Override
+    public void actor1(State s, IntResult2 r) {
+        synchronized (s.o) {
+            s.x = 1;
+            s.v = 1;
+        }
+    }
+
+    @Override
+    public void actor2(State s, IntResult2 r) {
+        r.r1 = s.v;
+        r.r2 = s.x;
+    }
+
+    @Override
+    public State newState() {
+        return new State();
+    }
+
+    @Override
+    public IntResult2 newResult() {
+        return new IntResult2();
+    }
+
+    public static class State  {
+        public int x;
+        public volatile int v;
+        public final Object o = new Object();
+    }
+
+}
--- a/tests-custom/src/main/resources/org/openjdk/jcstress/desc/scratch.xml	Tue Jul 09 16:32:19 2013 +0400
+++ b/tests-custom/src/main/resources/org/openjdk/jcstress/desc/scratch.xml	Thu Jul 11 14:48:15 2013 +0400
@@ -55,6 +55,8 @@
     <test name="org.openjdk.jcstress.tests.scratch.basic.ThreadStartTest" template="scratch-main" />
     <test name="org.openjdk.jcstress.tests.scratch.basic.VolatileTest" template="scratch-main" />
     <test name="org.openjdk.jcstress.tests.scratch.FailingCASTest" template="scratch-main" />
+    <test name="org.openjdk.jcstress.tests.scratch.VW_Sync_1_Test" template="scratch-main" />
+    <test name="org.openjdk.jcstress.tests.scratch.VW_Sync_2_Test" template="scratch-main" />
 
     <test name="org.openjdk.jcstress.tests.scratch.AQSTest">
         <contributed-by>Aleksey Shipilev (aleksey.shipilev@oracle.com)</contributed-by>