changeset 234:70831b9d15b2

Cut down the generated class footprint by removing unnecessary "test" instances.
author shade
date Tue, 10 May 2016 22:20:46 +0300
parents a50a13c9f9a9
children 526f1373dcb1
files jcstress-core/src/main/java/org/openjdk/jcstress/infra/processors/JCStressTestProcessor.java
diffstat 1 files changed, 13 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/infra/processors/JCStressTestProcessor.java	Tue May 10 22:11:15 2016 +0300
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/infra/processors/JCStressTestProcessor.java	Tue May 10 22:20:46 2016 +0300
@@ -283,6 +283,8 @@
         String s = info.getState().getSimpleName().toString();
         String r = info.getResult().getSimpleName().toString();
 
+        boolean isStateItself = info.getState().equals(info.getTest());
+
         int actorsCount = info.getActors().size();
 
         pw.println("package " + getPackageName(info.getTest()) + ".generated;");
@@ -298,7 +300,9 @@
             pw.println("    Counter<" + r + "> counter_" + a.getSimpleName() + ";");
         }
 
-        pw.println("    " + t + " test;");
+        if (!isStateItself) {
+            pw.println("    " + t + " test;");
+        }
         pw.println("    volatile StateHolder<Pair> version;");
         pw.println("    volatile int epoch;");
         pw.println();
@@ -338,7 +342,9 @@
 
         pw.println("    @Override");
         pw.println("    public Counter<" + r + "> internalRun() {");
-        pw.println("        test = new " + t + "();");
+        if (!isStateItself) {
+            pw.println("        test = new " + t + "();");
+        }
         pw.println("        version = new StateHolder<>(false, new Pair[0], " + actorsCount + ");");
         pw.println("        epoch = 0;");
 
@@ -373,8 +379,6 @@
         pw.println("    }");
         pw.println();
 
-
-
         pw.println("    public final void jcstress_consume(StateHolder<Pair> holder, Counter<" + r + "> cnt, int a, int actors) {");
         pw.println("        Pair[] pairs = holder.pairs;");
         pw.println("        int len = pairs.length;");
@@ -385,7 +389,7 @@
         pw.println("            " + r + " r = p.r;");
         pw.println("            " + s + " s = p.s;");
         if (info.getArbiter() != null) {
-            if (info.getState().equals(info.getTest())) {
+            if (isStateItself) {
                 emitMethod(pw, info.getArbiter(), "            s." + info.getArbiter().getSimpleName(), "s", "r", true);
             } else {
                 emitMethod(pw, info.getArbiter(), "            test." + info.getArbiter().getSimpleName(), "s", "r", true);
@@ -431,7 +435,9 @@
             pw.println("    public final Void " + a.getSimpleName() + "() {");
             pw.println("        int curEpoch = 0;");
             pw.println();
-            pw.println("        " + t + " lt = test;");
+            if (!isStateItself) {
+                pw.println("        " + t + " lt = test;");
+            }
             pw.println("        boolean yield = control.shouldYield;");
             pw.println();
             pw.println("        while (true) {");
@@ -446,7 +452,7 @@
             pw.println();
             pw.println("            for (Pair p : pairs) {");
 
-            if (info.getState().equals(info.getTest())) {
+            if (isStateItself) {
                 emitMethod(pw, a, "                p.s." + a.getSimpleName(), "p.s", "p.r", true);
             } else {
                 emitMethod(pw, a, "                lt." + a.getSimpleName(), "p.s", "p.r", true);