changeset 101:a955202e329e

Migrate fences.* tests to new API.
author shade
date Fri, 14 Mar 2014 01:29:51 +0400
parents 236597b2feab
children f1febba5f556
files tests-custom/src/main/java/org/openjdk/jcstress/tests/fences/FencedAcquireReleaseTest.java tests-custom/src/main/java/org/openjdk/jcstress/tests/fences/FencedDekkerTest.java tests-custom/src/main/java/org/openjdk/jcstress/tests/fences/FencedPublicationTest.java tests-custom/src/main/java/org/openjdk/jcstress/tests/fences/FencedReadTwiceTest.java tests-custom/src/main/java/org/openjdk/jcstress/tests/fences/UnfencedAcquireReleaseTest.java tests-custom/src/main/java/org/openjdk/jcstress/tests/fences/UnfencedDekkerTest.java tests-custom/src/main/java/org/openjdk/jcstress/tests/fences/UnfencedPublicationTest.java tests-custom/src/main/java/org/openjdk/jcstress/tests/fences/UnfencedReadTwiceTest.java
diffstat 8 files changed, 156 insertions(+), 200 deletions(-) [+]
line wrap: on
line diff
--- a/tests-custom/src/main/java/org/openjdk/jcstress/tests/fences/FencedAcquireReleaseTest.java	Fri Mar 14 01:16:11 2014 +0400
+++ b/tests-custom/src/main/java/org/openjdk/jcstress/tests/fences/FencedAcquireReleaseTest.java	Fri Mar 14 01:29:51 2014 +0400
@@ -24,6 +24,9 @@
  */
 package org.openjdk.jcstress.tests.fences;
 
+import org.openjdk.jcstress.infra.annotations.Actor;
+import org.openjdk.jcstress.infra.annotations.ConcurrencyStressTest;
+import org.openjdk.jcstress.infra.annotations.State;
 import org.openjdk.jcstress.infra.results.IntResult2;
 import org.openjdk.jcstress.tests.Actor2_Test;
 import org.openjdk.jcstress.util.UnsafeHolder;
@@ -33,39 +36,29 @@
  *
  *  @author Doug Lea (dl@cs.oswego.edu)
  */
-public class FencedAcquireReleaseTest implements Actor2_Test<FencedAcquireReleaseTest.State, IntResult2> {
+@ConcurrencyStressTest
+@State
+public class FencedAcquireReleaseTest {
 
-    public static class State {
-        int x;
-        int y; // acq/rel var
+    int x;
+    int y; // acq/rel var
+
+    @Actor
+    public void actor1() {
+        x = 1;
+        x = 2;
+        UnsafeHolder.U.storeFence();
+        y = 1;
+        x = 3;
     }
 
-    @Override
-    public void actor1(State s, IntResult2 r) {
-        s.x = 1;
-        s.x = 2;
-        UnsafeHolder.U.storeFence();
-        s.y = 1;
-        s.x = 3;
-    }
-
-    @Override
-    public void actor2(State s, IntResult2 r) {
-        int sy = s.y;
+    @Actor
+    public void actor2(IntResult2 r) {
+        int sy = y;
         UnsafeHolder.U.loadFence();
-        int sx = s.x;
+        int sx = x;
         r.r1 = sy;
         r.r2 = sx;
     }
 
-    @Override
-    public State newState() {
-        return new State();
-    }
-
-    @Override
-    public IntResult2 newResult() {
-        return new IntResult2();
-    }
-
 }
--- a/tests-custom/src/main/java/org/openjdk/jcstress/tests/fences/FencedDekkerTest.java	Fri Mar 14 01:16:11 2014 +0400
+++ b/tests-custom/src/main/java/org/openjdk/jcstress/tests/fences/FencedDekkerTest.java	Fri Mar 14 01:29:51 2014 +0400
@@ -24,6 +24,9 @@
  */
 package org.openjdk.jcstress.tests.fences;
 
+import org.openjdk.jcstress.infra.annotations.Actor;
+import org.openjdk.jcstress.infra.annotations.ConcurrencyStressTest;
+import org.openjdk.jcstress.infra.annotations.State;
 import org.openjdk.jcstress.infra.results.IntResult2;
 import org.openjdk.jcstress.tests.Actor2_Test;
 import org.openjdk.jcstress.util.UnsafeHolder;
@@ -33,34 +36,25 @@
  *
  *  @author Doug Lea (dl@cs.oswego.edu)
  */
-public class FencedDekkerTest implements Actor2_Test<FencedDekkerTest.State, IntResult2> {
+@ConcurrencyStressTest
+@State
+public class FencedDekkerTest {
 
-    @Override
-    public State newState() {
-        return new State();
+    int a;
+    int b;
+
+    @Actor
+    public void actor1(IntResult2 r) {
+        a = 1;
+        UnsafeHolder.U.fullFence();
+        r.r1 = b;
     }
 
-    @Override
-    public void actor1(State s, IntResult2 r) {
-        s.a = 1;
+    @Actor
+    public void actor2(IntResult2 r) {
+        b = 1;
         UnsafeHolder.U.fullFence();
-        r.r1 = s.b;
+        r.r2 = a;
     }
 
-    @Override
-    public void actor2(State s, IntResult2 r) {
-        s.b = 1;
-        UnsafeHolder.U.fullFence();
-        r.r2 = s.a;
-    }
-
-    @Override
-    public IntResult2 newResult() {
-        return new IntResult2();
-    }
-
-    public static class State {
-        public int a;
-        public int b;
-    }
 }
--- a/tests-custom/src/main/java/org/openjdk/jcstress/tests/fences/FencedPublicationTest.java	Fri Mar 14 01:16:11 2014 +0400
+++ b/tests-custom/src/main/java/org/openjdk/jcstress/tests/fences/FencedPublicationTest.java	Fri Mar 14 01:29:51 2014 +0400
@@ -24,8 +24,10 @@
  */
 package org.openjdk.jcstress.tests.fences;
 
+import org.openjdk.jcstress.infra.annotations.Actor;
+import org.openjdk.jcstress.infra.annotations.ConcurrencyStressTest;
+import org.openjdk.jcstress.infra.annotations.State;
 import org.openjdk.jcstress.infra.results.IntResult2;
-import org.openjdk.jcstress.tests.Actor2_Test;
 import org.openjdk.jcstress.util.UnsafeHolder;
 
 /**
@@ -33,28 +35,28 @@
  *
  *  @author Doug Lea (dl@cs.oswego.edu)
  */
-public class FencedPublicationTest implements Actor2_Test<FencedPublicationTest.State, IntResult2> {
+@ConcurrencyStressTest
+@State
+public class FencedPublicationTest {
+
+    Data data;
 
     static class Data {
         int x;
     }
 
-    static class State {
-        Data data;
-    }
-
-    @Override
-    public void actor1(State s, IntResult2 r) {
+    @Actor
+    public void actor1() {
         Data d = new Data();
         d.x = 1;
         UnsafeHolder.U.storeFence();
-        s.data = d;
+        data = d;
     }
 
-    @Override
-    public void actor2(State s, IntResult2 r) {
+    @Actor
+    public void actor2(IntResult2 r) {
         int sy, sx;
-        Data d = s.data;
+        Data d = data;
         if (d == null) {
             sy = 0;
             sx = 0;
@@ -67,14 +69,4 @@
         r.r2 = sx;
     }
 
-    @Override
-    public State newState() {
-        return new State();
-    }
-
-    @Override
-    public IntResult2 newResult() {
-        return new IntResult2();
-    }
-
 }
--- a/tests-custom/src/main/java/org/openjdk/jcstress/tests/fences/FencedReadTwiceTest.java	Fri Mar 14 01:16:11 2014 +0400
+++ b/tests-custom/src/main/java/org/openjdk/jcstress/tests/fences/FencedReadTwiceTest.java	Fri Mar 14 01:29:51 2014 +0400
@@ -24,6 +24,9 @@
  */
 package org.openjdk.jcstress.tests.fences;
 
+import org.openjdk.jcstress.infra.annotations.Actor;
+import org.openjdk.jcstress.infra.annotations.ConcurrencyStressTest;
+import org.openjdk.jcstress.infra.annotations.State;
 import org.openjdk.jcstress.infra.results.IntResult3;
 import org.openjdk.jcstress.tests.Actor2_Test;
 import org.openjdk.jcstress.util.UnsafeHolder;
@@ -33,36 +36,26 @@
  *
  * @author Doug Lea (dl@cs.oswego.edu)
  */
-public class FencedReadTwiceTest implements Actor2_Test<FencedReadTwiceTest.State, IntResult3> {
+@ConcurrencyStressTest
+@State
+public class FencedReadTwiceTest {
 
-    static class State {
-        int x;
-        int y;
+    int x;
+    int y;
+
+    @Actor
+    public void actor1() {
+        x = 1;
+        UnsafeHolder.U.storeFence();
+        y = 1;
     }
 
-    @Override
-    public void actor1(State s, IntResult3 r) {
-        s.x = 1;
-        UnsafeHolder.U.storeFence();
-        s.y = 1;
-    }
-
-    @Override
-    public void actor2(State s, IntResult3 r) {
-        r.r1 = s.x;
-        r.r2 = s.y;
+    @Actor
+    public void actor2(IntResult3 r) {
+        r.r1 = x;
+        r.r2 = y;
         UnsafeHolder.U.loadFence();
-        r.r3 = s.x;
-    }
-
-    @Override
-    public State newState() {
-        return new State();
-    }
-
-    @Override
-    public IntResult3 newResult() {
-        return new IntResult3();
+        r.r3 = x;
     }
 
 }
--- a/tests-custom/src/main/java/org/openjdk/jcstress/tests/fences/UnfencedAcquireReleaseTest.java	Fri Mar 14 01:16:11 2014 +0400
+++ b/tests-custom/src/main/java/org/openjdk/jcstress/tests/fences/UnfencedAcquireReleaseTest.java	Fri Mar 14 01:29:51 2014 +0400
@@ -24,43 +24,39 @@
  */
 package org.openjdk.jcstress.tests.fences;
 
+import org.openjdk.jcstress.infra.annotations.Actor;
+import org.openjdk.jcstress.infra.annotations.ConcurrencyStressTest;
+import org.openjdk.jcstress.infra.annotations.State;
 import org.openjdk.jcstress.infra.results.IntResult2;
 import org.openjdk.jcstress.tests.Actor2_Test;
+import org.openjdk.jcstress.util.UnsafeHolder;
 
 /**
  * Baseline for FencedAcquireReleaseTest
  *
  *  @author Doug Lea (dl@cs.oswego.edu)
  */
-public class UnfencedAcquireReleaseTest implements Actor2_Test<UnfencedAcquireReleaseTest.State, IntResult2> {
+@ConcurrencyStressTest
+@State
+public class UnfencedAcquireReleaseTest {
 
-    static class State {
-        int x;
-        int y; // acq/rel var
+    int x;
+    int y; // acq/rel var
+
+    @Actor
+    public void actor1() {
+        x = 1;
+        x = 2;
+        y = 1;
+        x = 3;
     }
 
-    @Override
-    public void actor1(State s, IntResult2 r) {
-        s.x = 1;
-        s.x = 2;
-        s.y = 1;
-        s.x = 3;
-    }
-
-    @Override
-    public void actor2(State s, IntResult2 r) {
-        r.r1 = s.y;
-        r.r2 = s.x;
-    }
-
-    @Override
-    public State newState() {
-        return new State();
-    }
-
-    @Override
-    public IntResult2 newResult() {
-        return new IntResult2();
+    @Actor
+    public void actor2(IntResult2 r) {
+        int sy = y;
+        int sx = x;
+        r.r1 = sy;
+        r.r2 = sx;
     }
 
 }
--- a/tests-custom/src/main/java/org/openjdk/jcstress/tests/fences/UnfencedDekkerTest.java	Fri Mar 14 01:16:11 2014 +0400
+++ b/tests-custom/src/main/java/org/openjdk/jcstress/tests/fences/UnfencedDekkerTest.java	Fri Mar 14 01:29:51 2014 +0400
@@ -25,40 +25,37 @@
 package org.openjdk.jcstress.tests.fences;
 
 
+import org.openjdk.jcstress.infra.annotations.Actor;
+import org.openjdk.jcstress.infra.annotations.ConcurrencyStressTest;
+import org.openjdk.jcstress.infra.annotations.State;
 import org.openjdk.jcstress.infra.results.IntResult2;
 import org.openjdk.jcstress.tests.Actor2_Test;
+import org.openjdk.jcstress.util.UnsafeHolder;
 
 /**
  * Baseline for FencedDekkerTest
  *
  *  @author Doug Lea (dl@cs.oswego.edu)
  */
-public class UnfencedDekkerTest implements Actor2_Test<UnfencedDekkerTest.State, IntResult2> {
+@ConcurrencyStressTest
+@State
+public class UnfencedDekkerTest {
 
-    @Override
-    public State newState() {
-        return new State();
+    int a;
+    int b;
+
+    @Actor
+    public void actor1(IntResult2 r) {
+        a = 1;
+        UnsafeHolder.U.fullFence();
+        r.r1 = b;
     }
 
-    @Override
-    public void actor1(State s, IntResult2 r) {
-        s.a = 1;
-        r.r1 = s.b;
+    @Actor
+    public void actor2(IntResult2 r) {
+        b = 1;
+        UnsafeHolder.U.fullFence();
+        r.r2 = a;
     }
 
-    @Override
-    public void actor2(State s, IntResult2 r) {
-        s.b = 1;
-        r.r2 = s.a;
-    }
-
-    @Override
-    public IntResult2 newResult() {
-        return new IntResult2();
-    }
-
-    public static class State {
-        public int a;
-        public int b;
-    }
 }
--- a/tests-custom/src/main/java/org/openjdk/jcstress/tests/fences/UnfencedPublicationTest.java	Fri Mar 14 01:16:11 2014 +0400
+++ b/tests-custom/src/main/java/org/openjdk/jcstress/tests/fences/UnfencedPublicationTest.java	Fri Mar 14 01:29:51 2014 +0400
@@ -24,52 +24,49 @@
  */
 package org.openjdk.jcstress.tests.fences;
 
+import org.openjdk.jcstress.infra.annotations.Actor;
+import org.openjdk.jcstress.infra.annotations.ConcurrencyStressTest;
+import org.openjdk.jcstress.infra.annotations.State;
 import org.openjdk.jcstress.infra.results.IntResult2;
 import org.openjdk.jcstress.tests.Actor2_Test;
+import org.openjdk.jcstress.util.UnsafeHolder;
 
 /**
  * Baseline for FencedPublicationTest
  *
  *  @author Doug Lea (dl@cs.oswego.edu)
  */
-public class UnfencedPublicationTest implements Actor2_Test<UnfencedPublicationTest.State, IntResult2> {
+@ConcurrencyStressTest
+@State
+public class UnfencedPublicationTest {
+
+    Data data;
 
     static class Data {
         int x;
     }
 
-    static class State {
-        Data data;
+    @Actor
+    public void actor1() {
+        Data d = new Data();
+        d.x = 1;
+        data = d;
     }
 
-    @Override
-    public void actor1(State s, IntResult2 r) {
-        Data d = new Data();
-        d.x = 1;
-        s.data = d;
-    }
-
-    @Override
-    public void actor2(State s, IntResult2 r) {
-        Data d = s.data;
+    @Actor
+    public void actor2(IntResult2 r) {
+        int sy, sx;
+        Data d = data;
         if (d == null) {
-            r.r1 = 0;
-            r.r2 = 0;
+            sy = 0;
+            sx = 0;
         }
         else {
-            r.r1 = 1;
-            r.r2 = d.x;
+            sy = 1;
+            sx = d.x;
         }
-    }
-
-    @Override
-    public State newState() {
-        return new State();
-    }
-
-    @Override
-    public IntResult2 newResult() {
-        return new IntResult2();
+        r.r1 = sy;
+        r.r2 = sx;
     }
 
 }
--- a/tests-custom/src/main/java/org/openjdk/jcstress/tests/fences/UnfencedReadTwiceTest.java	Fri Mar 14 01:16:11 2014 +0400
+++ b/tests-custom/src/main/java/org/openjdk/jcstress/tests/fences/UnfencedReadTwiceTest.java	Fri Mar 14 01:29:51 2014 +0400
@@ -24,42 +24,36 @@
  */
 package org.openjdk.jcstress.tests.fences;
 
+import org.openjdk.jcstress.infra.annotations.Actor;
+import org.openjdk.jcstress.infra.annotations.ConcurrencyStressTest;
+import org.openjdk.jcstress.infra.annotations.State;
 import org.openjdk.jcstress.infra.results.IntResult3;
 import org.openjdk.jcstress.tests.Actor2_Test;
+import org.openjdk.jcstress.util.UnsafeHolder;
 
 /**
  * Test if intervening write breaks reordering.
  *
  * @author Aleksey Shipilev (aleksey.shipilev@oracle.com)
  */
-public class UnfencedReadTwiceTest implements Actor2_Test<UnfencedReadTwiceTest.State, IntResult3> {
+@ConcurrencyStressTest
+@State
+public class UnfencedReadTwiceTest {
 
-    static class State {
-        int x;
-        int y;
+    int x;
+    int y;
+
+    @Actor
+    public void actor1() {
+        x = 1;
+        y = 1;
     }
 
-    @Override
-    public void actor1(State s, IntResult3 r) {
-        s.x = 1;
-        s.y = 1;
-    }
-
-    @Override
-    public void actor2(State s, IntResult3 r) {
-        r.r1 = s.x;
-        r.r2 = s.y;
-        r.r3 = s.x;
-    }
-
-    @Override
-    public State newState() {
-        return new State();
-    }
-
-    @Override
-    public IntResult3 newResult() {
-        return new IntResult3();
+    @Actor
+    public void actor2(IntResult3 r) {
+        r.r1 = x;
+        r.r2 = y;
+        r.r3 = x;
     }
 
 }