changeset 40:38e70041b24b

Reuse state/result arrays; reuse result objects.
author shade
date Wed, 07 Aug 2013 17:22:50 +0400
parents 1802ea51fea7
children 7a3c80c151b5
files generator/src/main/java/org/openjdk/jcstress/generator/ResultGenerator.java harness/src/main/java/org/openjdk/jcstress/JCStress.java harness/src/main/java/org/openjdk/jcstress/infra/Result.java harness/src/main/java/org/openjdk/jcstress/infra/results/BooleanResult1.java harness/src/main/java/org/openjdk/jcstress/infra/results/BooleanResult2.java harness/src/main/java/org/openjdk/jcstress/infra/results/BooleanResult4.java harness/src/main/java/org/openjdk/jcstress/infra/results/ByteResult1.java harness/src/main/java/org/openjdk/jcstress/infra/results/ByteResult2.java harness/src/main/java/org/openjdk/jcstress/infra/results/ByteResult3.java harness/src/main/java/org/openjdk/jcstress/infra/results/ByteResult4.java harness/src/main/java/org/openjdk/jcstress/infra/results/ByteResult8.java harness/src/main/java/org/openjdk/jcstress/infra/results/CharResult1.java harness/src/main/java/org/openjdk/jcstress/infra/results/CharResult2.java harness/src/main/java/org/openjdk/jcstress/infra/results/CharResult4.java harness/src/main/java/org/openjdk/jcstress/infra/results/DoubleResult1.java harness/src/main/java/org/openjdk/jcstress/infra/results/DoubleResult2.java harness/src/main/java/org/openjdk/jcstress/infra/results/DoubleResult4.java harness/src/main/java/org/openjdk/jcstress/infra/results/FloatResult1.java harness/src/main/java/org/openjdk/jcstress/infra/results/FloatResult2.java harness/src/main/java/org/openjdk/jcstress/infra/results/FloatResult4.java harness/src/main/java/org/openjdk/jcstress/infra/results/IntResult1.java harness/src/main/java/org/openjdk/jcstress/infra/results/IntResult2.java harness/src/main/java/org/openjdk/jcstress/infra/results/IntResult3.java harness/src/main/java/org/openjdk/jcstress/infra/results/IntResult4.java harness/src/main/java/org/openjdk/jcstress/infra/results/LongResult1.java harness/src/main/java/org/openjdk/jcstress/infra/results/LongResult2.java harness/src/main/java/org/openjdk/jcstress/infra/results/LongResult3.java harness/src/main/java/org/openjdk/jcstress/infra/results/LongResult4.java harness/src/main/java/org/openjdk/jcstress/infra/results/ShortResult1.java harness/src/main/java/org/openjdk/jcstress/infra/results/ShortResult2.java harness/src/main/java/org/openjdk/jcstress/infra/results/ShortResult4.java harness/src/main/java/org/openjdk/jcstress/infra/runners/Actor1_Runner.java harness/src/main/java/org/openjdk/jcstress/infra/runners/Actor2_Arbiter1_Runner.java harness/src/main/java/org/openjdk/jcstress/infra/runners/Actor2_Runner.java harness/src/main/java/org/openjdk/jcstress/infra/runners/Actor3_Runner.java harness/src/main/java/org/openjdk/jcstress/infra/runners/Actor4_Runner.java harness/src/main/java/org/openjdk/jcstress/infra/runners/ActorBase.java harness/src/main/java/org/openjdk/jcstress/infra/runners/StateHolder.java harness/src/main/java/org/openjdk/jcstress/tests/Actor1_Test.java harness/src/main/java/org/openjdk/jcstress/tests/Actor2_Arbiter1_Test.java harness/src/main/java/org/openjdk/jcstress/tests/Actor2_Test.java harness/src/main/java/org/openjdk/jcstress/tests/Actor3_Test.java harness/src/main/java/org/openjdk/jcstress/tests/Actor4_Test.java harness/src/main/java/org/openjdk/jcstress/tests/ActorConcurrencyTest.java harness/src/main/java/org/openjdk/jcstress/util/HashCounter.java
diffstat 45 files changed, 332 insertions(+), 68 deletions(-) [+]
line wrap: on
line diff
--- a/generator/src/main/java/org/openjdk/jcstress/generator/ResultGenerator.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/generator/src/main/java/org/openjdk/jcstress/generator/ResultGenerator.java	Wed Aug 07 17:22:50 2013 +0400
@@ -67,8 +67,9 @@
         pw.println("package org.openjdk.jcstress.infra.results;");
         pw.println("");
         pw.println("import java.io.Serializable;");
+        pw.println("import org.openjdk.jcstress.infra.Result;");
         pw.println("");
-        pw.println("public class " + name + " implements Serializable {");
+        pw.println("public class " + name + " implements Serializable, Result {");
 
         {
             int n = 1;
@@ -152,6 +153,22 @@
 
         pw.println("    }");
 
+        pw.println("    public void reset() {");
+
+        {
+            int n = 1;
+            for (Class k : types.all()) {
+                if (k == boolean.class) {
+                    pw.println("r" + n + " = false;");
+                } else {
+                    pw.println("r" + n + " = 0;");
+                }
+                n++;
+            }
+        }
+
+        pw.println("    }");
+
         pw.println("}");
         pw.close();
 
--- a/harness/src/main/java/org/openjdk/jcstress/JCStress.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/JCStress.java	Wed Aug 07 17:22:50 2013 +0400
@@ -24,6 +24,7 @@
  */
 package org.openjdk.jcstress;
 
+import org.openjdk.jcstress.infra.Result;
 import org.openjdk.jcstress.infra.Scheduler;
 import org.openjdk.jcstress.infra.Status;
 import org.openjdk.jcstress.infra.collectors.DiskReadCollector;
@@ -234,37 +235,38 @@
         });
     }
 
+    @SuppressWarnings("unchecked")
     public void run(Options opts, Set<Class<? extends ConcurrencyTest>> tests, boolean alreadyForked, TestResultCollector collector) throws Exception {
 
         for (Class<? extends ConcurrencyTest> test : tests) {
             if (Actor2_Arbiter1_Test.class.isAssignableFrom(test)) {
                 @SuppressWarnings("unchecked")
-                Actor2_Arbiter1_Test<Object, Object> obj = (Actor2_Arbiter1_Test<Object, Object>) test.newInstance();
-                async(new Actor2_Arbiter1_Runner<Object, Object>(opts, obj, collector, pool));
+                Actor2_Arbiter1_Test<Object, ? extends Result> obj = (Actor2_Arbiter1_Test<Object, ? extends Result>) test.newInstance();
+                async(new Actor2_Arbiter1_Runner(opts, obj, collector, pool));
             }
 
             if (Actor1_Test.class.isAssignableFrom(test)) {
                 @SuppressWarnings("unchecked")
-                Actor1_Test<Object, Object> obj = (Actor1_Test<Object, Object>) test.newInstance();
-                async(new Actor1_Runner<Object, Object>(opts, obj, collector, pool));
+                Actor1_Test<Object, ? extends Result> obj = (Actor1_Test<Object, ? extends Result>) test.newInstance();
+                async(new Actor1_Runner(opts, obj, collector, pool));
             }
 
             if (Actor2_Test.class.isAssignableFrom(test)) {
                 @SuppressWarnings("unchecked")
-                Actor2_Test<Object, Object> obj = (Actor2_Test<Object, Object>) test.newInstance();
-                async(new Actor2_Runner<Object, Object>(opts, obj, collector, pool));
+                Actor2_Test<Object, ? extends Result> obj = (Actor2_Test<Object, ? extends Result>) test.newInstance();
+                async(new Actor2_Runner(opts, obj, collector, pool));
             }
 
             if (Actor3_Test.class.isAssignableFrom(test)) {
                 @SuppressWarnings("unchecked")
-                Actor3_Test<Object, Object> obj = (Actor3_Test<Object, Object>) test.newInstance();
-                async(new Actor3_Runner<Object, Object>(opts, obj, collector, pool));
+                Actor3_Test<Object, ? extends Result> obj = (Actor3_Test<Object, ? extends Result>) test.newInstance();
+                async(new Actor3_Runner(opts, obj, collector, pool));
             }
 
             if (Actor4_Test.class.isAssignableFrom(test)) {
                 @SuppressWarnings("unchecked")
-                Actor4_Test<Object, Object> obj = (Actor4_Test<Object, Object>) test.newInstance();
-                async(new Actor4_Runner<Object, Object>(opts, obj, collector, pool));
+                Actor4_Test<Object, ? extends Result> obj = (Actor4_Test<Object, ? extends Result>) test.newInstance();
+                async(new Actor4_Runner(opts, obj, collector, pool));
             }
 
             if (TerminationTest.class.isAssignableFrom(test)) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/Result.java	Wed Aug 07 17:22:50 2013 +0400
@@ -0,0 +1,29 @@
+/*
+ * 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.infra;
+
+public interface Result {
+    void reset();
+}
--- a/harness/src/main/java/org/openjdk/jcstress/infra/results/BooleanResult1.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/results/BooleanResult1.java	Wed Aug 07 17:22:50 2013 +0400
@@ -24,11 +24,12 @@
  */
 package org.openjdk.jcstress.infra.results;
 
+import org.openjdk.jcstress.infra.Result;
 import sun.misc.Contended;
 
 import java.io.Serializable;
 
-public class BooleanResult1 implements Serializable {
+public class BooleanResult1 implements Serializable, Result {
 
     @Contended
     public boolean r1;
@@ -54,4 +55,9 @@
     public String toString() {
         return "[" + r1 + ']';
     }
+
+    @Override
+    public void reset() {
+        r1 = false;
+    }
 }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/results/BooleanResult2.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/results/BooleanResult2.java	Wed Aug 07 17:22:50 2013 +0400
@@ -24,11 +24,12 @@
  */
 package org.openjdk.jcstress.infra.results;
 
+import org.openjdk.jcstress.infra.Result;
 import sun.misc.Contended;
 
 import java.io.Serializable;
 
-public class BooleanResult2 implements Serializable {
+public class BooleanResult2 implements Serializable, Result {
 
     @Contended
     public boolean r1;
@@ -60,4 +61,9 @@
     public String toString() {
         return "[" + r1 + ", " + r2 + ']';
     }
+
+    @Override
+    public void reset() {
+        r1 = r2 = false;
+    }
 }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/results/BooleanResult4.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/results/BooleanResult4.java	Wed Aug 07 17:22:50 2013 +0400
@@ -24,11 +24,12 @@
  */
 package org.openjdk.jcstress.infra.results;
 
+import org.openjdk.jcstress.infra.Result;
 import sun.misc.Contended;
 
 import java.io.Serializable;
 
-public class BooleanResult4 implements Serializable {
+public class BooleanResult4 implements Serializable, Result {
 
     @Contended
     public boolean r1;
@@ -70,4 +71,9 @@
     public String toString() {
         return "[" + r1 + ", " + r2 + ", " + r3 + ", " + r4 + ']';
     }
+
+    @Override
+    public void reset() {
+        r1 = r2 = r3 = r4 = false;
+    }
 }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/results/ByteResult1.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/results/ByteResult1.java	Wed Aug 07 17:22:50 2013 +0400
@@ -24,11 +24,12 @@
  */
 package org.openjdk.jcstress.infra.results;
 
+import org.openjdk.jcstress.infra.Result;
 import sun.misc.Contended;
 
 import java.io.Serializable;
 
-public class ByteResult1 implements Serializable {
+public class ByteResult1 implements Serializable, Result {
 
     @Contended
     public byte r1;
@@ -54,4 +55,9 @@
     public String toString() {
         return "[" + r1 + ']';
     }
+
+    @Override
+    public void reset() {
+        r1 = 0;
+    }
 }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/results/ByteResult2.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/results/ByteResult2.java	Wed Aug 07 17:22:50 2013 +0400
@@ -24,11 +24,12 @@
  */
 package org.openjdk.jcstress.infra.results;
 
+import org.openjdk.jcstress.infra.Result;
 import sun.misc.Contended;
 
 import java.io.Serializable;
 
-public class ByteResult2 implements Serializable {
+public class ByteResult2 implements Serializable, Result {
 
     @Contended
     public byte r1;
@@ -61,4 +62,8 @@
         return "[" + r1 + ", " + r2 + ']';
     }
 
+    @Override
+    public void reset() {
+        r1 = r2 = 0;
+    }
 }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/results/ByteResult3.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/results/ByteResult3.java	Wed Aug 07 17:22:50 2013 +0400
@@ -24,11 +24,12 @@
  */
 package org.openjdk.jcstress.infra.results;
 
+import org.openjdk.jcstress.infra.Result;
 import sun.misc.Contended;
 
 import java.io.Serializable;
 
-public class ByteResult3 implements Serializable {
+public class ByteResult3 implements Serializable, Result {
 
     @Contended
     public byte r1;
@@ -66,4 +67,8 @@
         return "[" + r1 + ", " + r2 + ", " + r3 + ']';
     }
 
+    @Override
+    public void reset() {
+        r1 = r2 = r3 = 0;
+    }
 }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/results/ByteResult4.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/results/ByteResult4.java	Wed Aug 07 17:22:50 2013 +0400
@@ -24,11 +24,12 @@
  */
 package org.openjdk.jcstress.infra.results;
 
+import org.openjdk.jcstress.infra.Result;
 import sun.misc.Contended;
 
 import java.io.Serializable;
 
-public class ByteResult4 implements Serializable {
+public class ByteResult4 implements Serializable, Result {
 
     @Contended
     public byte r1;
@@ -70,4 +71,9 @@
         result = 31 * result + r4;
         return result;
     }
+
+    @Override
+    public void reset() {
+        r1 = r2 = r3 = r4 = 0;
+    }
 }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/results/ByteResult8.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/results/ByteResult8.java	Wed Aug 07 17:22:50 2013 +0400
@@ -24,11 +24,12 @@
  */
 package org.openjdk.jcstress.infra.results;
 
+import org.openjdk.jcstress.infra.Result;
 import sun.misc.Contended;
 
 import java.io.Serializable;
 
-public class ByteResult8 implements Serializable {
+public class ByteResult8 implements Serializable, Result {
 
     @Contended
     public byte r1;
@@ -90,4 +91,9 @@
         result = 31 * result + (int) r8;
         return result;
     }
+
+    @Override
+    public void reset() {
+        r1 = r2 = r3 = r4 = r5 = r6 = r7 = r8 = 0;
+    }
 }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/results/CharResult1.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/results/CharResult1.java	Wed Aug 07 17:22:50 2013 +0400
@@ -24,11 +24,12 @@
  */
 package org.openjdk.jcstress.infra.results;
 
+import org.openjdk.jcstress.infra.Result;
 import sun.misc.Contended;
 
 import java.io.Serializable;
 
-public class CharResult1 implements Serializable {
+public class CharResult1 implements Serializable, Result {
 
     @Contended
     public char r1;
@@ -54,4 +55,9 @@
     public String toString() {
         return "[" + r1 + ']';
     }
+
+    @Override
+    public void reset() {
+        r1 = 0;
+    }
 }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/results/CharResult2.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/results/CharResult2.java	Wed Aug 07 17:22:50 2013 +0400
@@ -24,11 +24,12 @@
  */
 package org.openjdk.jcstress.infra.results;
 
+import org.openjdk.jcstress.infra.Result;
 import sun.misc.Contended;
 
 import java.io.Serializable;
 
-public class CharResult2 implements Serializable {
+public class CharResult2 implements Serializable, Result {
 
     @Contended
     public char r1;
@@ -60,4 +61,9 @@
     public String toString() {
         return "[" + r1 + ", " + r2 + ']';
     }
+
+    @Override
+    public void reset() {
+        r1 = r2 = 0;
+    }
 }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/results/CharResult4.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/results/CharResult4.java	Wed Aug 07 17:22:50 2013 +0400
@@ -24,11 +24,12 @@
  */
 package org.openjdk.jcstress.infra.results;
 
+import org.openjdk.jcstress.infra.Result;
 import sun.misc.Contended;
 
 import java.io.Serializable;
 
-public class CharResult4 implements Serializable {
+public class CharResult4 implements Serializable, Result {
 
     @Contended
     public char r1;
@@ -70,4 +71,9 @@
     public String toString() {
         return "[" + r1 + ", " + r2 + ", " + r3 + ", " + r4 + ']';
     }
+
+    @Override
+    public void reset() {
+        r1 = r2 = r3 = r4 = 0;
+    }
 }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/results/DoubleResult1.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/results/DoubleResult1.java	Wed Aug 07 17:22:50 2013 +0400
@@ -24,11 +24,12 @@
  */
 package org.openjdk.jcstress.infra.results;
 
+import org.openjdk.jcstress.infra.Result;
 import sun.misc.Contended;
 
 import java.io.Serializable;
 
-public class DoubleResult1 implements Serializable {
+public class DoubleResult1 implements Serializable, Result {
 
     @Contended
     public double r1;
@@ -55,4 +56,9 @@
     public String toString() {
         return "[" + r1 + ']';
     }
+
+    @Override
+    public void reset() {
+        r1 = 0;
+    }
 }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/results/DoubleResult2.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/results/DoubleResult2.java	Wed Aug 07 17:22:50 2013 +0400
@@ -24,11 +24,12 @@
  */
 package org.openjdk.jcstress.infra.results;
 
+import org.openjdk.jcstress.infra.Result;
 import sun.misc.Contended;
 
 import java.io.Serializable;
 
-public class DoubleResult2 implements Serializable {
+public class DoubleResult2 implements Serializable, Result {
 
     @Contended
     public double r1;
@@ -64,4 +65,9 @@
     public String toString() {
         return "[" + r1 + ", " + r2 + ']';
     }
+
+    @Override
+    public void reset() {
+        r1 = r2 = 0;
+    }
 }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/results/DoubleResult4.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/results/DoubleResult4.java	Wed Aug 07 17:22:50 2013 +0400
@@ -24,11 +24,12 @@
  */
 package org.openjdk.jcstress.infra.results;
 
+import org.openjdk.jcstress.infra.Result;
 import sun.misc.Contended;
 
 import java.io.Serializable;
 
-public class DoubleResult4 implements Serializable {
+public class DoubleResult4 implements Serializable, Result {
 
     @Contended
     public double r1;
@@ -76,4 +77,9 @@
     public String toString() {
         return "[" + r1 + ", " + r2 + ", " + r3 + ", " + r4 + ']';
     }
+
+    @Override
+    public void reset() {
+        r1 = r2 = r3 = r4 = 0;
+    }
 }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/results/FloatResult1.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/results/FloatResult1.java	Wed Aug 07 17:22:50 2013 +0400
@@ -24,11 +24,12 @@
  */
 package org.openjdk.jcstress.infra.results;
 
+import org.openjdk.jcstress.infra.Result;
 import sun.misc.Contended;
 
 import java.io.Serializable;
 
-public class FloatResult1 implements Serializable {
+public class FloatResult1 implements Serializable, Result {
 
     @Contended
     public float r1;
@@ -54,4 +55,9 @@
     public String toString() {
         return "[" + r1 + ']';
     }
+
+    @Override
+    public void reset() {
+        r1 = 0;
+    }
 }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/results/FloatResult2.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/results/FloatResult2.java	Wed Aug 07 17:22:50 2013 +0400
@@ -24,11 +24,12 @@
  */
 package org.openjdk.jcstress.infra.results;
 
+import org.openjdk.jcstress.infra.Result;
 import sun.misc.Contended;
 
 import java.io.Serializable;
 
-public class FloatResult2 implements Serializable {
+public class FloatResult2 implements Serializable, Result {
 
     @Contended
     public float r1;
@@ -60,4 +61,9 @@
     public String toString() {
         return "[" + r1 + ", " + r2 + ']';
     }
+
+    @Override
+    public void reset() {
+        r1 = r2 = 0;
+    }
 }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/results/FloatResult4.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/results/FloatResult4.java	Wed Aug 07 17:22:50 2013 +0400
@@ -24,11 +24,12 @@
  */
 package org.openjdk.jcstress.infra.results;
 
+import org.openjdk.jcstress.infra.Result;
 import sun.misc.Contended;
 
 import java.io.Serializable;
 
-public class FloatResult4 implements Serializable {
+public class FloatResult4 implements Serializable, Result {
 
     @Contended
     public float r1;
@@ -70,4 +71,9 @@
     public String toString() {
         return "[" + r1 + ", " + r2 + ", " + r3 + ", " + r4 + ']';
     }
+
+    @Override
+    public void reset() {
+        r1 = r2 = r3 = r4 = 0;
+    }
 }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/results/IntResult1.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/results/IntResult1.java	Wed Aug 07 17:22:50 2013 +0400
@@ -24,11 +24,12 @@
  */
 package org.openjdk.jcstress.infra.results;
 
+import org.openjdk.jcstress.infra.Result;
 import sun.misc.Contended;
 
 import java.io.Serializable;
 
-public class IntResult1 implements Serializable {
+public class IntResult1 implements Serializable, Result {
 
     @Contended
     public int r1;
@@ -54,4 +55,9 @@
     public String toString() {
         return "[" + r1 + ']';
     }
+
+    @Override
+    public void reset() {
+        r1 = 0;
+    }
 }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/results/IntResult2.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/results/IntResult2.java	Wed Aug 07 17:22:50 2013 +0400
@@ -24,11 +24,12 @@
  */
 package org.openjdk.jcstress.infra.results;
 
+import org.openjdk.jcstress.infra.Result;
 import sun.misc.Contended;
 
 import java.io.Serializable;
 
-public class IntResult2 implements Serializable {
+public class IntResult2 implements Serializable, Result {
 
     @Contended
     public int r1;
@@ -61,4 +62,8 @@
         return "[" + r1 + ", " + r2 + ']';
     }
 
+    @Override
+    public void reset() {
+        r1 = r2 = 0;
+    }
 }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/results/IntResult3.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/results/IntResult3.java	Wed Aug 07 17:22:50 2013 +0400
@@ -24,11 +24,12 @@
  */
 package org.openjdk.jcstress.infra.results;
 
+import org.openjdk.jcstress.infra.Result;
 import sun.misc.Contended;
 
 import java.io.Serializable;
 
-public class IntResult3 implements Serializable {
+public class IntResult3 implements Serializable, Result {
 
     @Contended
     public int r1;
@@ -66,4 +67,8 @@
         return "[" + r1 + ", " + r2 + ", " + r3 + ']';
     }
 
+    @Override
+    public void reset() {
+        r1 = r2 = r3 = 0;
+    }
 }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/results/IntResult4.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/results/IntResult4.java	Wed Aug 07 17:22:50 2013 +0400
@@ -24,11 +24,12 @@
  */
 package org.openjdk.jcstress.infra.results;
 
+import org.openjdk.jcstress.infra.Result;
 import sun.misc.Contended;
 
 import java.io.Serializable;
 
-public class IntResult4 implements Serializable {
+public class IntResult4 implements Serializable, Result {
 
     @Contended
     public int r1;
@@ -70,4 +71,9 @@
         result = 31 * result + r4;
         return result;
     }
+
+    @Override
+    public void reset() {
+        r1 = r2 = r3 = r4 = 0;
+    }
 }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/results/LongResult1.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/results/LongResult1.java	Wed Aug 07 17:22:50 2013 +0400
@@ -24,11 +24,12 @@
  */
 package org.openjdk.jcstress.infra.results;
 
+import org.openjdk.jcstress.infra.Result;
 import sun.misc.Contended;
 
 import java.io.Serializable;
 
-public class LongResult1 implements Serializable {
+public class LongResult1 implements Serializable, Result {
 
     @Contended
     public long r1;
@@ -54,4 +55,9 @@
     public String toString() {
         return "[" + r1 + ']';
     }
+
+    @Override
+    public void reset() {
+        r1 = 0;
+    }
 }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/results/LongResult2.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/results/LongResult2.java	Wed Aug 07 17:22:50 2013 +0400
@@ -24,11 +24,12 @@
  */
 package org.openjdk.jcstress.infra.results;
 
+import org.openjdk.jcstress.infra.Result;
 import sun.misc.Contended;
 
 import java.io.Serializable;
 
-public class LongResult2 implements Serializable {
+public class LongResult2 implements Serializable, Result {
 
     @Contended
     public long r1;
@@ -60,4 +61,9 @@
     public String toString() {
         return "[" + r1 + ", " + r2 + ']';
     }
+
+    @Override
+    public void reset() {
+        r1 = r2 = 0;
+    }
 }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/results/LongResult3.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/results/LongResult3.java	Wed Aug 07 17:22:50 2013 +0400
@@ -24,11 +24,12 @@
  */
 package org.openjdk.jcstress.infra.results;
 
+import org.openjdk.jcstress.infra.Result;
 import sun.misc.Contended;
 
 import java.io.Serializable;
 
-public class LongResult3 implements Serializable {
+public class LongResult3 implements Serializable, Result {
 
     @Contended
     public long r1;
@@ -66,4 +67,8 @@
         return "[" + r1 + ", " + r2 + ", " + r3 + ']';
     }
 
+    @Override
+    public void reset() {
+        r1 = r2 = r3 = 0;
+    }
 }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/results/LongResult4.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/results/LongResult4.java	Wed Aug 07 17:22:50 2013 +0400
@@ -24,11 +24,12 @@
  */
 package org.openjdk.jcstress.infra.results;
 
+import org.openjdk.jcstress.infra.Result;
 import sun.misc.Contended;
 
 import java.io.Serializable;
 
-public class LongResult4 implements Serializable {
+public class LongResult4 implements Serializable, Result {
 
     @Contended
     public long r1;
@@ -70,4 +71,9 @@
         result = 31 * result + (int) (r4 ^ (r4 >>> 32));
         return result;
     }
+
+    @Override
+    public void reset() {
+        r1 = r2 = r3 = r4 = 0;
+    }
 }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/results/ShortResult1.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/results/ShortResult1.java	Wed Aug 07 17:22:50 2013 +0400
@@ -24,11 +24,12 @@
  */
 package org.openjdk.jcstress.infra.results;
 
+import org.openjdk.jcstress.infra.Result;
 import sun.misc.Contended;
 
 import java.io.Serializable;
 
-public class ShortResult1 implements Serializable {
+public class ShortResult1 implements Serializable, Result {
 
     @Contended
     public short r1;
@@ -54,4 +55,9 @@
     public String toString() {
         return "[" + r1 + ']';
     }
+
+    @Override
+    public void reset() {
+        r1 = 0;
+    }
 }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/results/ShortResult2.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/results/ShortResult2.java	Wed Aug 07 17:22:50 2013 +0400
@@ -24,11 +24,12 @@
  */
 package org.openjdk.jcstress.infra.results;
 
+import org.openjdk.jcstress.infra.Result;
 import sun.misc.Contended;
 
 import java.io.Serializable;
 
-public class ShortResult2 implements Serializable {
+public class ShortResult2 implements Serializable, Result {
 
     @Contended
     public short r1;
@@ -60,4 +61,9 @@
     public String toString() {
         return "[" + r1 + ", " + r2  + ']';
     }
+
+    @Override
+    public void reset() {
+        r1 = r2 = 0;
+    }
 }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/results/ShortResult4.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/results/ShortResult4.java	Wed Aug 07 17:22:50 2013 +0400
@@ -24,11 +24,12 @@
  */
 package org.openjdk.jcstress.infra.results;
 
+import org.openjdk.jcstress.infra.Result;
 import sun.misc.Contended;
 
 import java.io.Serializable;
 
-public class ShortResult4 implements Serializable {
+public class ShortResult4 implements Serializable, Result {
 
     @Contended
     public short r1;
@@ -70,4 +71,9 @@
     public String toString() {
         return "[" + r1 + ", " + r2 + ", " + r3 + ", " + r4 + ']';
     }
+
+    @Override
+    public void reset() {
+        r1 = r2 = r3 = r4 = 0;
+    }
 }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/runners/Actor1_Runner.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/runners/Actor1_Runner.java	Wed Aug 07 17:22:50 2013 +0400
@@ -25,6 +25,7 @@
 package org.openjdk.jcstress.infra.runners;
 
 import org.openjdk.jcstress.Options;
+import org.openjdk.jcstress.infra.Result;
 import org.openjdk.jcstress.infra.Status;
 import org.openjdk.jcstress.infra.collectors.TestResultCollector;
 import org.openjdk.jcstress.tests.Actor1_Test;
@@ -46,7 +47,7 @@
 /**
  * @author Aleksey Shipilev (aleksey.shipilev@oracle.com)
  */
-public class Actor1_Runner<S, R> extends Runner {
+public class Actor1_Runner<S, R extends Result> extends Runner {
     private final Actor1_Test<S, R> test;
 
     public Actor1_Runner(Options opts, Actor1_Test<S, R> test, TestResultCollector collector, ExecutorService pool) throws FileNotFoundException, JAXBException {
@@ -130,7 +131,7 @@
         }
 
         @SuppressWarnings("unchecked")
-        R[] newResult = (R[]) new Object[minStride];
+        R[] newResult = (R[]) new Result[minStride];
         for (int c = 0; c < minStride; c++) {
             newResult[c] = test.newResult();
         }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/runners/Actor2_Arbiter1_Runner.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/runners/Actor2_Arbiter1_Runner.java	Wed Aug 07 17:22:50 2013 +0400
@@ -25,6 +25,7 @@
 package org.openjdk.jcstress.infra.runners;
 
 import org.openjdk.jcstress.Options;
+import org.openjdk.jcstress.infra.Result;
 import org.openjdk.jcstress.infra.Status;
 import org.openjdk.jcstress.infra.collectors.TestResultCollector;
 import org.openjdk.jcstress.tests.Actor2_Arbiter1_Test;
@@ -46,7 +47,7 @@
 /**
  * @author Aleksey Shipilev (aleksey.shipilev@oracle.com)
  */
-public class Actor2_Arbiter1_Runner<S, R> extends Runner {
+public class Actor2_Arbiter1_Runner<S, R extends Result> extends Runner {
     private Actor2_Arbiter1_Test<S, R> test;
 
     public Actor2_Arbiter1_Runner(Options opts, Actor2_Arbiter1_Test<S, R> test, TestResultCollector collector, ExecutorService pool) throws FileNotFoundException, JAXBException {
@@ -123,7 +124,7 @@
         }
 
         @SuppressWarnings("unchecked")
-        R[] newResult = (R[]) new Object[minStride];
+        R[] newResult = (R[]) new Result[minStride];
         for (int c = 0; c < minStride; c++) {
             newResult[c] = test.newResult();
         }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/runners/Actor2_Runner.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/runners/Actor2_Runner.java	Wed Aug 07 17:22:50 2013 +0400
@@ -25,6 +25,7 @@
 package org.openjdk.jcstress.infra.runners;
 
 import org.openjdk.jcstress.Options;
+import org.openjdk.jcstress.infra.Result;
 import org.openjdk.jcstress.infra.Status;
 import org.openjdk.jcstress.infra.collectors.TestResultCollector;
 import org.openjdk.jcstress.tests.Actor2_Test;
@@ -46,7 +47,7 @@
 /**
  * @author Aleksey Shipilev (aleksey.shipilev@oracle.com)
  */
-public class Actor2_Runner<S, R> extends Runner {
+public class Actor2_Runner<S, R extends Result> extends Runner {
     final Actor2_Test<S, R> test;
 
     public Actor2_Runner(Options opts, Actor2_Test<S, R> test, TestResultCollector collector, ExecutorService pool) throws FileNotFoundException, JAXBException {
@@ -131,7 +132,7 @@
         }
 
         @SuppressWarnings("unchecked")
-        R[] newResult = (R[]) new Object[minStride];
+        R[] newResult = (R[]) new Result[minStride];
         for (int c = 0; c < minStride; c++) {
             newResult[c] = test.newResult();
         }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/runners/Actor3_Runner.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/runners/Actor3_Runner.java	Wed Aug 07 17:22:50 2013 +0400
@@ -25,6 +25,7 @@
 package org.openjdk.jcstress.infra.runners;
 
 import org.openjdk.jcstress.Options;
+import org.openjdk.jcstress.infra.Result;
 import org.openjdk.jcstress.infra.Status;
 import org.openjdk.jcstress.infra.collectors.TestResultCollector;
 import org.openjdk.jcstress.tests.Actor3_Test;
@@ -46,7 +47,7 @@
 /**
  * @author Aleksey Shipilev (aleksey.shipilev@oracle.com)
  */
-public class Actor3_Runner<S, R> extends Runner {
+public class Actor3_Runner<S, R extends Result> extends Runner {
     final Actor3_Test<S, R> test;
 
     public Actor3_Runner(Options opts, Actor3_Test<S, R> test, TestResultCollector collector, ExecutorService pool) throws FileNotFoundException, JAXBException {
@@ -133,7 +134,7 @@
         }
 
         @SuppressWarnings("unchecked")
-        R[] newResult = (R[]) new Object[minStride];
+        R[] newResult = (R[]) new Result[minStride];
         for (int c = 0; c < minStride; c++) {
             newResult[c] = test.newResult();
         }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/runners/Actor4_Runner.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/runners/Actor4_Runner.java	Wed Aug 07 17:22:50 2013 +0400
@@ -25,6 +25,7 @@
 package org.openjdk.jcstress.infra.runners;
 
 import org.openjdk.jcstress.Options;
+import org.openjdk.jcstress.infra.Result;
 import org.openjdk.jcstress.infra.Status;
 import org.openjdk.jcstress.infra.collectors.TestResultCollector;
 import org.openjdk.jcstress.tests.Actor4_Test;
@@ -46,7 +47,7 @@
 /**
  * @author Aleksey Shipilev (aleksey.shipilev@oracle.com)
  */
-public class Actor4_Runner<S, R> extends Runner {
+public class Actor4_Runner<S, R extends Result> extends Runner {
     final Actor4_Test<S, R> test;
 
     public Actor4_Runner(Options opts, Actor4_Test<S, R> test, TestResultCollector collector, ExecutorService pool) throws FileNotFoundException, JAXBException {
@@ -135,7 +136,7 @@
         }
 
         @SuppressWarnings("unchecked")
-        R[] newResult = (R[]) new Object[minStride];
+        R[] newResult = (R[]) new Result[minStride];
         for (int c = 0; c < minStride; c++) {
             newResult[c] = test.newResult();
         }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/runners/ActorBase.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/runners/ActorBase.java	Wed Aug 07 17:22:50 2013 +0400
@@ -24,8 +24,10 @@
  */
 package org.openjdk.jcstress.infra.runners;
 
+import org.openjdk.jcstress.infra.Result;
 import org.openjdk.jcstress.tests.ActorConcurrencyTest;
 import org.openjdk.jcstress.util.Counter;
+import org.openjdk.jcstress.util.UnsafeHolder;
 
 import java.util.Arrays;
 import java.util.concurrent.Callable;
@@ -41,7 +43,7 @@
  *
  * @author Aleksey Shipilev (aleksey.shipilev@oracle.com)
  */
-public abstract class ActorBase<T extends ActorConcurrencyTest<S, R>, S, R> implements Callable<Void> {
+public abstract class ActorBase<T extends ActorConcurrencyTest<S, R>, S, R extends Result> implements Callable<Void> {
     private final int index;
     private final T test;
     private final AtomicReference<StateHolder<S, R>> version;
@@ -191,9 +193,6 @@
                     lCounter.record(r1);
                 }
 
-            }
-
-            if (epoch.compareAndSet(curEpoch + 1, curEpoch + 2)) {
                 // prepare the new chunk of work
                 StateHolder<S, R> newHolder;
                 if (control.isStopped) {
@@ -202,15 +201,24 @@
                     // feedback: should bump the stride size?
                     int newLoops = holder.hasLaggedWorkers ? Math.min(loops * 2, maxStride) : loops;
 
-                    S[] newStride = Arrays.copyOf(cur, newLoops);
+                    for (int c = 0; c < loops; c++) {
+                        res[c].reset();
+                    }
+
+                    S[] newStride = cur;
+                    R[] newRes = res;
+                    if (newLoops > loops) {
+                        newStride = Arrays.copyOf(cur, newLoops);
+                        newRes = Arrays.copyOf(res, newLoops);
+                        for (int c = loops; c < newLoops; c++) {
+                            newRes[c] = lt.newResult();
+                        }
+                    }
+
                     for (int c = 0; c < newLoops; c++) {
                         newStride[c] = lt.newState();
                     }
 
-                    R[] newRes = Arrays.copyOf(res, newLoops);
-                    for (int c = 0; c < newLoops; c++) {
-                        newRes[c] = lt.newResult();
-                    }
                     newHolder = new StateHolder<S, R>(newStride, newRes, holder.countWorkers);
                 }
 
@@ -218,7 +226,7 @@
             }
 
             // defensive cross-check against global
-            curEpoch += 2;
+            curEpoch += 1;
             while (curEpoch != epoch.get()) {
                 if (shouldYield) Thread.yield();
             }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/runners/StateHolder.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/runners/StateHolder.java	Wed Aug 07 17:22:50 2013 +0400
@@ -30,8 +30,8 @@
  * @author Aleksey Shipilev (aleksey.shipilev@oracle.com)
  */
 public class StateHolder<S, R> {
-    final S[] s;
-    final R[] r;
+    volatile S[] s;
+    volatile R[] r;
     final int loops;
     final int countWorkers;
     final AtomicInteger started, ready, finished, consumed;
--- a/harness/src/main/java/org/openjdk/jcstress/tests/Actor1_Test.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/tests/Actor1_Test.java	Wed Aug 07 17:22:50 2013 +0400
@@ -24,7 +24,9 @@
  */
 package org.openjdk.jcstress.tests;
 
-public interface Actor1_Test<S, R> extends ActorConcurrencyTest<S, R> {
+import org.openjdk.jcstress.infra.Result;
+
+public interface Actor1_Test<S, R extends Result> extends ActorConcurrencyTest<S, R> {
 
     /**
      * Body for the actor 1.
--- a/harness/src/main/java/org/openjdk/jcstress/tests/Actor2_Arbiter1_Test.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/tests/Actor2_Arbiter1_Test.java	Wed Aug 07 17:22:50 2013 +0400
@@ -24,7 +24,9 @@
  */
 package org.openjdk.jcstress.tests;
 
-public interface Actor2_Arbiter1_Test<S, R> extends ActorConcurrencyTest<S, R> {
+import org.openjdk.jcstress.infra.Result;
+
+public interface Actor2_Arbiter1_Test<S, R extends Result> extends ActorConcurrencyTest<S, R> {
 
     /**
      * Body for actor 1.
--- a/harness/src/main/java/org/openjdk/jcstress/tests/Actor2_Test.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/tests/Actor2_Test.java	Wed Aug 07 17:22:50 2013 +0400
@@ -24,7 +24,9 @@
  */
 package org.openjdk.jcstress.tests;
 
-public interface Actor2_Test<S, R> extends ActorConcurrencyTest<S, R> {
+import org.openjdk.jcstress.infra.Result;
+
+public interface Actor2_Test<S, R extends Result> extends ActorConcurrencyTest<S, R> {
 
     /**
      * Body for the actor 1.
--- a/harness/src/main/java/org/openjdk/jcstress/tests/Actor3_Test.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/tests/Actor3_Test.java	Wed Aug 07 17:22:50 2013 +0400
@@ -24,7 +24,9 @@
  */
 package org.openjdk.jcstress.tests;
 
-public interface Actor3_Test<S, R> extends ActorConcurrencyTest<S, R> {
+import org.openjdk.jcstress.infra.Result;
+
+public interface Actor3_Test<S, R extends Result> extends ActorConcurrencyTest<S, R> {
 
     /**
      * Body for the actor 1.
--- a/harness/src/main/java/org/openjdk/jcstress/tests/Actor4_Test.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/tests/Actor4_Test.java	Wed Aug 07 17:22:50 2013 +0400
@@ -24,7 +24,9 @@
  */
 package org.openjdk.jcstress.tests;
 
-public interface Actor4_Test<S, R> extends ActorConcurrencyTest<S, R> {
+import org.openjdk.jcstress.infra.Result;
+
+public interface Actor4_Test<S, R extends Result> extends ActorConcurrencyTest<S, R> {
 
     /**
      * Body for the actor 1.
--- a/harness/src/main/java/org/openjdk/jcstress/tests/ActorConcurrencyTest.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/tests/ActorConcurrencyTest.java	Wed Aug 07 17:22:50 2013 +0400
@@ -24,6 +24,8 @@
  */
 package org.openjdk.jcstress.tests;
 
+import org.openjdk.jcstress.infra.Result;
+
 /**
  * Actor concurrency tests accept one or more:
  *   - actors:     threads actively mutating the state, and recording the current state
@@ -48,7 +50,7 @@
  * @param <R> result object type
  * @author Aleksey Shipilev (aleksey.shipilev@oracle.com)
  */
-public interface ActorConcurrencyTest<S, R> extends ConcurrencyTest {
+public interface ActorConcurrencyTest<S, R extends Result> extends ConcurrencyTest {
 
     /**
      * Produce new state holder.
--- a/harness/src/main/java/org/openjdk/jcstress/util/HashCounter.java	Wed Aug 07 15:13:56 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/util/HashCounter.java	Wed Aug 07 17:22:50 2013 +0400
@@ -24,6 +24,13 @@
  */
 package org.openjdk.jcstress.util;
 
+import org.openjdk.jcstress.infra.Result;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
@@ -42,11 +49,32 @@
         Holder holder = ms.get(result);
         if (holder == null) {
             holder = new Holder();
-            ms.put(result, holder);
+            ms.put(decouple(result), holder);
         }
         holder.value += count;
     }
 
+    private T decouple(T result) {
+        try {
+            ByteArrayOutputStream bos = new ByteArrayOutputStream();
+            ObjectOutputStream oos = new ObjectOutputStream(bos);
+            oos.writeObject(result);
+            oos.close();
+
+            ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
+            ObjectInputStream ois = new ObjectInputStream(bis);
+
+            @SuppressWarnings("unchecked")
+            T t = (T)ois.readObject();
+
+            return t;
+        } catch (IOException e) {
+            throw new IllegalStateException(e);
+        } catch (ClassNotFoundException e) {
+            throw new IllegalStateException(e);
+        }
+    }
+
     @Override
     public long count(T result) {
         Holder holder = ms.get(result);