changeset 10:cfd4b1ee9140

generator: remove the tests with unmatched stores
author shade
date Mon, 08 Jul 2013 19:43:03 +0400
parents 6c2aca7f74fe
children d47796d3a928
files generator/src/main/java/org/openjdk/jcstress/tracer/TraceGen.java
diffstat 1 files changed, 38 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/generator/src/main/java/org/openjdk/jcstress/tracer/TraceGen.java	Mon Jul 08 19:34:31 2013 +0400
+++ b/generator/src/main/java/org/openjdk/jcstress/tracer/TraceGen.java	Mon Jul 08 19:43:03 2013 +0400
@@ -73,6 +73,7 @@
         for (Trace trace : allTraces) {
             if (!trace.hasLoads()) continue;
             if (!trace.hasStores()) continue;
+            if (trace.hasNonMatchingStores()) continue;
 
             int constId = 0;
             int resId = 0;
@@ -372,6 +373,42 @@
             }
             return sb.toString();
         }
+
+        public boolean hasNonMatchingLoads() {
+            Set<Integer> stores = new HashSet<Integer>();
+            for (Op op : ops) {
+                if (op.getType() == Op.Type.STORE) {
+                    stores.add(op.getVarId());
+                }
+            }
+
+            for (Op op : ops) {
+                if (op.getType() == Op.Type.LOAD) {
+                    if (!stores.contains(op.getVarId()))
+                        return false;
+                }
+            }
+
+            return true;
+        }
+
+        public boolean hasNonMatchingStores() {
+            Set<Integer> loads = new HashSet<Integer>();
+            for (Op op : ops) {
+                if (op.getType() == Op.Type.LOAD) {
+                    loads.add(op.getVarId());
+                }
+            }
+
+            for (Op op : ops) {
+                if (op.getType() == Op.Type.STORE) {
+                    if (!loads.contains(op.getVarId()))
+                        return false;
+                }
+            }
+
+            return true;
+        }
     }
 
     public class MultiTrace {
@@ -379,8 +416,7 @@
         private final List<Trace> traces;
 
         public MultiTrace(Trace original, Trace... traces) {
-            this.original = original;
-            this.traces = Arrays.asList(traces);
+            this(original, Arrays.asList(traces));
         }
 
         public MultiTrace(Trace original, List<Trace> copy) {