changeset 1333:c698f6c0e0fc

7901743: @State DAG machinery miscompiles/rejects valid DAGs
author shade
date Fri, 22 Jul 2016 15:20:54 +0300
parents fa510264b3f6
children f3769cbfafee
files jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/CycleBenchmarkTest.java jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/CycleThreadTest.java jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/cycles/ExplicitCycleBenchmarkTest.java jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/cycles/ExplicitCycleThreadTest.java jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/cycles/ImplicitCycleBenchmarkTest.java jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/cycles/ImplicitCycleThreadTest.java jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/BenchmarkBenchmarkTest.java jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/BenchmarkThreadTest.java jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/ThreadBenchmarkTest.java jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/ThreadThreadTest.java jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/implicit/BenchmarkBenchmarkTest.java jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/implicit/BenchmarkThreadTest.java jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/implicit/ThreadBenchmarkTest.java jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/implicit/ThreadThreadTest.java jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObject.java jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java
diffstat 17 files changed, 785 insertions(+), 172 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/CycleBenchmarkTest.java	Thu Jul 21 17:42:20 2016 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2005, 2014, 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.jmh.ct.states.dag;
-
-import org.junit.Test;
-import org.openjdk.jmh.annotations.Benchmark;
-import org.openjdk.jmh.annotations.Scope;
-import org.openjdk.jmh.annotations.Setup;
-import org.openjdk.jmh.annotations.State;
-import org.openjdk.jmh.ct.CompileTest;
-
-public class CycleBenchmarkTest {
-
-    @State(Scope.Benchmark)
-    public static class B1 {
-        @Setup
-        public void setup(B2 b1) {
-
-        }
-    }
-
-    @State(Scope.Benchmark)
-    public static class B2 {
-        @Setup
-        public void setup(B1 b1) {
-
-        }
-    }
-
-    @Benchmark
-    public void test(B1 b1) {
-
-    }
-
-    @Test
-    public void compileTest() {
-        CompileTest.assertFail(this.getClass());
-    }
-
-}
--- a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/CycleThreadTest.java	Thu Jul 21 17:42:20 2016 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2005, 2014, 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.jmh.ct.states.dag;
-
-import org.junit.Test;
-import org.openjdk.jmh.annotations.Benchmark;
-import org.openjdk.jmh.annotations.Scope;
-import org.openjdk.jmh.annotations.Setup;
-import org.openjdk.jmh.annotations.State;
-import org.openjdk.jmh.ct.CompileTest;
-
-public class CycleThreadTest {
-
-    @State(Scope.Thread)
-    public static class B1 {
-        @Setup
-        public void setup(B2 b1) {
-
-        }
-    }
-
-    @State(Scope.Thread)
-    public static class B2 {
-        @Setup
-        public void setup(B1 b1) {
-
-        }
-    }
-
-    @Benchmark
-    public void test(B1 b1) {
-
-    }
-
-    @Test
-    public void compileTest() {
-        CompileTest.assertFail(this.getClass());
-    }
-
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/cycles/ExplicitCycleBenchmarkTest.java	Fri Jul 22 15:20:54 2016 +0300
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2005, 2014, 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.jmh.ct.states.dag.cycles;
+
+import org.junit.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.ct.CompileTest;
+
+public class ExplicitCycleBenchmarkTest {
+
+    @State(Scope.Benchmark)
+    public static class B1 {
+        @Setup
+        public void setup(B2 b1) {
+
+        }
+    }
+
+    @State(Scope.Benchmark)
+    public static class B2 {
+        @Setup
+        public void setup(B1 b1) {
+
+        }
+    }
+
+    @Benchmark
+    public void test(B1 b1) {
+
+    }
+
+    @Test
+    public void compileTest() {
+        CompileTest.assertFail(this.getClass(), "@State dependency cycle is detected");
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/cycles/ExplicitCycleThreadTest.java	Fri Jul 22 15:20:54 2016 +0300
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2005, 2014, 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.jmh.ct.states.dag.cycles;
+
+import org.junit.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.ct.CompileTest;
+
+public class ExplicitCycleThreadTest {
+
+    @State(Scope.Thread)
+    public static class B1 {
+        @Setup
+        public void setup(B2 b1) {
+
+        }
+    }
+
+    @State(Scope.Thread)
+    public static class B2 {
+        @Setup
+        public void setup(B1 b1) {
+
+        }
+    }
+
+    @Benchmark
+    public void test(B1 b1) {
+
+    }
+
+    @Test
+    public void compileTest() {
+        CompileTest.assertFail(this.getClass(), "@State dependency cycle is detected");
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/cycles/ImplicitCycleBenchmarkTest.java	Fri Jul 22 15:20:54 2016 +0300
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2005, 2014, 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.jmh.ct.states.dag.cycles;
+
+import org.junit.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.ct.CompileTest;
+
+@State(Scope.Benchmark)
+public class ImplicitCycleBenchmarkTest {
+
+    @State(Scope.Benchmark)
+    public static class B1 {
+        @Setup
+        public void setup(ImplicitCycleBenchmarkTest b1) {
+
+        }
+    }
+
+    @Setup
+    public void setup(B1 b1) {
+
+    }
+
+    @Benchmark
+    public void test() {
+
+    }
+
+    @Test
+    public void compileTest() {
+        CompileTest.assertFail(this.getClass(), "@State dependency cycle is detected");
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/cycles/ImplicitCycleThreadTest.java	Fri Jul 22 15:20:54 2016 +0300
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2005, 2014, 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.jmh.ct.states.dag.cycles;
+
+import org.junit.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.ct.CompileTest;
+
+@State(Scope.Thread)
+public class ImplicitCycleThreadTest {
+
+    @State(Scope.Thread)
+    public static class B1 {
+        @Setup
+        public void setup(ImplicitCycleThreadTest b1) {
+
+        }
+    }
+
+    @Setup
+    public void setup(B1 b1) {
+
+    }
+
+    @Benchmark
+    public void test() {
+
+    }
+
+    @Test
+    public void compileTest() {
+        CompileTest.assertFail(this.getClass(), "@State dependency cycle is detected");
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/BenchmarkBenchmarkTest.java	Fri Jul 22 15:20:54 2016 +0300
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2014, 2015, 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.jmh.ct.states.dag.doublets;
+
+import org.junit.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.ct.CompileTest;
+
+public class BenchmarkBenchmarkTest {
+
+    @State(Scope.Benchmark)
+    public static class L {
+
+    }
+
+    @State(Scope.Benchmark)
+    public static class G {
+        @Setup
+        public void setup(L l1) {
+
+        }
+    }
+
+    @Benchmark
+    public void test(G g1, G g2) {
+
+    }
+
+    @Test
+    public void compileTest() {
+        CompileTest.assertOK(this.getClass());
+    }
+
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/BenchmarkThreadTest.java	Fri Jul 22 15:20:54 2016 +0300
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2014, 2015, 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.jmh.ct.states.dag.doublets;
+
+import org.junit.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.ct.CompileTest;
+
+public class BenchmarkThreadTest {
+
+    @State(Scope.Benchmark)
+    public static class L {
+
+    }
+
+    @State(Scope.Thread)
+    public static class G {
+        @Setup
+        public void setup(L l1) {
+
+        }
+    }
+
+    @Benchmark
+    public void test(G g1, G g2) {
+
+    }
+
+    @Test
+    public void compileTest() {
+        CompileTest.assertOK(this.getClass());
+    }
+
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/ThreadBenchmarkTest.java	Fri Jul 22 15:20:54 2016 +0300
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2014, 2015, 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.jmh.ct.states.dag.doublets;
+
+import org.junit.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.ct.CompileTest;
+
+public class ThreadBenchmarkTest {
+
+    @State(Scope.Thread)
+    public static class L {
+
+    }
+
+    @State(Scope.Benchmark)
+    public static class G {
+        @Setup
+        public void setup(L l1) {
+
+        }
+    }
+
+    @Benchmark
+    public void test(G g1, G g2) {
+
+    }
+
+    @Test
+    public void compileTest() {
+        CompileTest.assertOK(this.getClass());
+    }
+
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/ThreadThreadTest.java	Fri Jul 22 15:20:54 2016 +0300
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2014, 2015, 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.jmh.ct.states.dag.doublets;
+
+import org.junit.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.ct.CompileTest;
+
+public class ThreadThreadTest {
+
+    @State(Scope.Thread)
+    public static class L {
+
+    }
+
+    @State(Scope.Thread)
+    public static class G {
+        @Setup
+        public void setup(L l1) {
+
+        }
+    }
+
+    @Benchmark
+    public void test(G g1, G g2) {
+
+    }
+
+    @Test
+    public void compileTest() {
+        CompileTest.assertOK(this.getClass());
+    }
+
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/implicit/BenchmarkBenchmarkTest.java	Fri Jul 22 15:20:54 2016 +0300
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2014, 2015, 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.jmh.ct.states.dag.implicit;
+
+import org.junit.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.ct.CompileTest;
+
+@State(Scope.Benchmark)
+public class BenchmarkBenchmarkTest {
+
+    @State(Scope.Benchmark)
+    public static class L {
+
+    }
+
+    @Setup
+    public void setup(L l1) {
+
+    }
+
+    @Benchmark
+    public void test(BenchmarkBenchmarkTest state) {}
+
+    @Test
+    public void compileTest() {
+        CompileTest.assertOK(this.getClass());
+    }
+
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/implicit/BenchmarkThreadTest.java	Fri Jul 22 15:20:54 2016 +0300
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2014, 2015, 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.jmh.ct.states.dag.implicit;
+
+import org.junit.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.ct.CompileTest;
+
+@State(Scope.Benchmark)
+public class BenchmarkThreadTest {
+
+    @State(Scope.Thread)
+    public static class L {
+
+    }
+
+    @Setup
+    public void setup(L l1) {
+
+    }
+
+    @Benchmark
+    public void test(BenchmarkThreadTest state) {}
+
+    @Test
+    public void compileTest() {
+        CompileTest.assertOK(this.getClass());
+    }
+
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/implicit/ThreadBenchmarkTest.java	Fri Jul 22 15:20:54 2016 +0300
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2014, 2015, 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.jmh.ct.states.dag.implicit;
+
+import org.junit.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.ct.CompileTest;
+
+@State(Scope.Thread)
+public class ThreadBenchmarkTest {
+
+    @State(Scope.Benchmark)
+    public static class L {
+
+    }
+
+    @Setup
+    public void setup(L l1) {
+
+    }
+
+    @Benchmark
+    public void test(ThreadBenchmarkTest state) {}
+
+    @Test
+    public void compileTest() {
+        CompileTest.assertOK(this.getClass());
+    }
+
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/implicit/ThreadThreadTest.java	Fri Jul 22 15:20:54 2016 +0300
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2014, 2015, 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.jmh.ct.states.dag.implicit;
+
+import org.junit.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.ct.CompileTest;
+
+@State(Scope.Thread)
+public class ThreadThreadTest {
+
+    @State(Scope.Thread)
+    public static class L {
+
+    }
+
+    @Setup
+    public void setup(L l1) {
+
+    }
+
+    @Benchmark
+    public void test(ThreadThreadTest state) {}
+
+    @Test
+    public void compileTest() {
+        CompileTest.assertOK(this.getClass());
+    }
+
+
+}
--- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java	Thu Jul 21 17:42:20 2016 +0300
+++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java	Fri Jul 22 15:20:54 2016 +0300
@@ -271,6 +271,11 @@
             StateObjectHandler.validateState(clazz);
         }
 
+        // validate no @State cycles
+        for (MethodInfo e : methods) {
+            StateObjectHandler.validateNoCycles(e);
+        }
+
         // validate against rogue fields
         if (!explicitState || clazz.isAbstract()) {
             for (FieldInfo fi : BenchmarkGeneratorUtils.getAllFields(clazz)) {
@@ -461,11 +466,8 @@
     private void generateClass(GeneratorSource source, GeneratorDestination destination, ClassInfo classInfo, BenchmarkInfo info) throws IOException {
         StateObjectHandler states = new StateObjectHandler(compilerControl);
 
-        // benchmark instance is implicit
-        states.bindImplicit(classInfo, "bench", Scope.Thread);
-
         // bind all methods
-        states.bindMethodGroup(info.methodGroup);
+        states.bindMethods(classInfo, info.methodGroup);
 
         // Create file and open an outputstream
         PrintWriter writer = new PrintWriter(destination.newClass(info.generatedClassQName), false);
--- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObject.java	Thu Jul 21 17:42:20 2016 +0300
+++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObject.java	Fri Jul 22 15:20:54 2016 +0300
@@ -25,13 +25,11 @@
 package org.openjdk.jmh.generators.core;
 
 import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.util.HashMultimap;
 import org.openjdk.jmh.util.Multimap;
 import org.openjdk.jmh.util.TreeMultimap;
 
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.SortedSet;
-import java.util.TreeSet;
+import java.util.*;
 
 class StateObject {
 
@@ -50,6 +48,8 @@
     public final String fieldIdentifier;
     public final Multimap<String, FieldInfo> params;
     public final SortedSet<HelperMethodInvocation> helpers;
+    public final Multimap<String, String> helperArgs;
+    public final List<StateObject> depends;
 
     public StateObject(Identifiers identifiers, ClassInfo info, Scope scope) {
         this.packageName = info.getPackageName() + ".generated";
@@ -63,6 +63,8 @@
 
         this.params = new TreeMultimap<String, FieldInfo>();
         this.helpers = new TreeSet<HelperMethodInvocation>();
+        this.helperArgs = new HashMultimap<String, String>();
+        this.depends = new ArrayList<StateObject>();
     }
 
     @Override
--- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java	Thu Jul 21 17:42:20 2016 +0300
+++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java	Fri Jul 22 15:20:54 2016 +0300
@@ -48,10 +48,9 @@
 
     private final Set<StateObject> stateObjects;
     private final Map<String, StateObject> implicits;
-    private final Multimap<StateObject, StateObject> stateObjectDeps;
+
 
     private final Multimap<String, String> benchmarkArgs;
-    private final Multimap<String, String> stateHelperArgs;
 
     private final Multimap<String, String> auxNames = new HashMultimap<String, String>();
     private final Map<String, String> auxAccessors = new HashMap<String, String>();
@@ -63,8 +62,6 @@
         this.implicits = new HashMap<String, StateObject>();
         this.specials = new HashMultimap<String, ClassInfo>();
         this.stateObjects = new HashSet<StateObject>();
-        this.stateHelperArgs = new HashMultimap<String, String>();
-        this.stateObjectDeps = new HashMultimap<StateObject, StateObject>();
         this.identifiers = new Identifiers();
     }
 
@@ -178,13 +175,24 @@
         return ann;
     }
 
-    public void bindMethodGroup(MethodGroup mg) {
+    public void bindMethods(ClassInfo holder, MethodGroup mg) {
         for (MethodInfo method : mg.methods()) {
-            Set<StateObject> seen = new HashSet<StateObject>();
+            // Bind the holder implicitly:
+            {
+                State ann = BenchmarkGeneratorUtils.getAnnSuper(holder, State.class);
+                Scope scope = (ann != null) ? ann.value() : Scope.Thread;
+                StateObject holderSo = new StateObject(identifiers, holder, scope);
+                stateObjects.add(holderSo);
+                implicits.put("bench", holderSo);
+                bindState(method, holderSo, holder);
+
+                resolveDependencies(method, holder, holderSo);
+            }
 
             // Check that all arguments are states.
             validateStateArgs(method);
 
+            // Bind all @Benchmark parameters
             for (ParameterInfo ppi : method.getParameters()) {
                 ClassInfo pci = ppi.getType();
 
@@ -198,9 +206,41 @@
                     benchmarkArgs.put(method.getName(), pso.toLocal());
                     bindState(method, pso, pci);
 
-                    seen.add(pso);
+                    resolveDependencies(method, pci, pso);
+                }
+            }
+        }
+    }
 
-                    recursiveStateResolve(method, pci, pso, seen);
+    public static void validateNoCycles(MethodInfo method) {
+        try {
+            validateNoCyclesStep(Collections.<String>emptyList(), method, true);
+        } catch (StackOverflowError e) {
+            // "YOLO Engineering"
+            throw new GenerationException("@" + State.class.getSimpleName() +
+                    " dependency cycle is detected.", method);
+        }
+    }
+
+    private static void validateNoCyclesStep(List<String> states, MethodInfo method, boolean includeHolder) {
+        List<ClassInfo> stratum = new ArrayList<ClassInfo>();
+        if (includeHolder) {
+            stratum.add(method.getDeclaringClass());
+        }
+        for (ParameterInfo ppi : method.getParameters()) {
+            stratum.add(ppi.getType());
+        }
+
+        List<String> newStates = new ArrayList<String>();
+        newStates.addAll(states);
+        for (ClassInfo ci : stratum) {
+            newStates.add(ci.getQualifiedName());
+        }
+
+        for (ClassInfo ci : stratum) {
+            for (MethodInfo mi : BenchmarkGeneratorUtils.getMethods(ci)) {
+                if (mi.getAnnotation(Setup.class) != null || mi.getAnnotation(TearDown.class) != null) {
+                    validateNoCyclesStep(newStates, mi, false);
                 }
             }
         }
@@ -209,7 +249,7 @@
     /**
      * Recursively resolve if there are any other states referenced through helper methods.
      */
-    private void recursiveStateResolve(MethodInfo method, ClassInfo pci, StateObject pso, Set<StateObject> seen) {
+    private void resolveDependencies(MethodInfo method, ClassInfo pci, StateObject pso) {
 
         for (MethodInfo mi : BenchmarkGeneratorUtils.getMethods(pci)) {
             if (mi.getAnnotation(Setup.class) != null || mi.getAnnotation(TearDown.class) != null) {
@@ -217,21 +257,18 @@
                     ClassInfo ci = pi.getType();
 
                     if (isSpecialClass(ci)) {
-                        stateHelperArgs.put(mi.getQualifiedName(), getSpecialClassAccessor(ci));
+                        pso.helperArgs.put(mi.getQualifiedName(), getSpecialClassAccessor(ci));
                         specials.put(mi.getQualifiedName(), ci);
                     } else {
                         StateObject so = new StateObject(identifiers, ci, getState(ci, pi).value());
 
-                        if (!seen.add(so)) {
-                            throw new GenerationException("@" + State.class.getSimpleName() + " dependency cycle is detected.", pi);
-                        }
+                        if (!pso.helperArgs.get(mi.getQualifiedName()).contains(so.toLocal())) {
+                            stateObjects.add(so);
+                            pso.depends.add(so);
+                            pso.helperArgs.put(mi.getQualifiedName(), so.toLocal());
 
-                        if (!stateHelperArgs.get(mi.getQualifiedName()).contains(so.toLocal())) {
-                            stateObjects.add(so);
-                            stateObjectDeps.put(pso, so);
-                            stateHelperArgs.put(mi.getQualifiedName(), so.toLocal());
                             bindState(method, so, ci);
-                            recursiveStateResolve(method, ci, so, seen);
+                            resolveDependencies(method, ci, so);
                         }
                     }
                 }
@@ -239,18 +276,6 @@
         }
     }
 
-
-    public void bindImplicit(ClassInfo ci, String label, Scope scope) {
-        State ann = BenchmarkGeneratorUtils.getAnnSuper(ci, State.class);
-        StateObject so = new StateObject(identifiers, ci, (ann != null) ? ann.value() : scope);
-        stateObjects.add(so);
-        implicits.put(label, so);
-        bindState(null, so, ci);
-
-        Set<StateObject> seen = new HashSet<StateObject>();
-        recursiveStateResolve(null, ci, so, seen);
-    }
-
     private void bindState(MethodInfo execMethod, StateObject so, ClassInfo ci) {
         // Check it is a valid state
         validateState(ci);
@@ -549,7 +574,7 @@
             if (type == HelperType.SETUP) {
                 for (HelperMethodInvocation mi : so.getHelpers()) {
                     if (mi.helperLevel == helperLevel && mi.type == HelperType.SETUP) {
-                        Collection<String> args = stateHelperArgs.get(mi.method.getQualifiedName());
+                        Collection<String> args = so.helperArgs.get(mi.method.getQualifiedName());
                         result.add(so.localIdentifier + "." + mi.method.getName() + "(" + Utils.join(args, ",") + ");");
                     }
                 }
@@ -562,7 +587,7 @@
             if (type == HelperType.TEARDOWN) {
                 for (HelperMethodInvocation mi : so.getHelpers()) {
                     if (mi.helperLevel == helperLevel && mi.type == HelperType.TEARDOWN) {
-                        Collection<String> args = stateHelperArgs.get(mi.method.getQualifiedName());
+                        Collection<String> args = so.helperArgs.get(mi.method.getQualifiedName());
                         result.add(so.localIdentifier + "." + mi.method.getName() + "(" + Utils.join(args, ",") + ");");
                     }
                 }
@@ -579,7 +604,7 @@
                 result.add("        if (!" + so.localIdentifier + ".ready" + helperLevel + ") {");
                 for (HelperMethodInvocation mi : so.getHelpers()) {
                     if (mi.helperLevel == helperLevel && mi.type == HelperType.SETUP) {
-                        Collection<String> args = stateHelperArgs.get(mi.method.getQualifiedName());
+                        Collection<String> args = so.helperArgs.get(mi.method.getQualifiedName());
                         result.add("            " + so.localIdentifier + "." + mi.method.getName() + "(" + Utils.join(args, ",") + ");");
                     }
                 }
@@ -605,7 +630,7 @@
                 result.add("        if (" + so.localIdentifier + ".ready" + helperLevel + ") {");
                 for (HelperMethodInvocation mi : so.getHelpers()) {
                     if (mi.helperLevel == helperLevel && mi.type == HelperType.TEARDOWN) {
-                        Collection<String> args = stateHelperArgs.get(mi.method.getQualifiedName());
+                        Collection<String> args = so.helperArgs.get(mi.method.getQualifiedName());
                         result.add("            " + so.localIdentifier + "." + mi.method.getName() + "(" + Utils.join(args, ",") + ");");
                     }
                 }
@@ -702,7 +727,7 @@
             for (HelperMethodInvocation hmi : so.getHelpers()) {
                 if (hmi.helperLevel != Level.Trial) continue;
                 if (hmi.type != HelperType.SETUP) continue;
-                Collection<String> args = stateHelperArgs.get(hmi.method.getQualifiedName());
+                Collection<String> args = so.helperArgs.get(hmi.method.getQualifiedName());
                 result.add("        val." + hmi.method.getName() + "(" + Utils.join(args, ",") + ");");
             }
             result.add("        val.ready" + Level.Trial + " = true;");
@@ -737,7 +762,7 @@
             for (HelperMethodInvocation hmi : so.getHelpers()) {
                 if (hmi.helperLevel != Level.Trial) continue;
                 if (hmi.type != HelperType.SETUP) continue;
-                Collection<String> args = stateHelperArgs.get(hmi.method.getQualifiedName());
+                Collection<String> args = so.helperArgs.get(hmi.method.getQualifiedName());
                 result.add("        val." + hmi.method.getName() + "(" + Utils.join(args, ",") + ");");
             }
             result.add("        " + so.fieldIdentifier + " = val;");
@@ -777,7 +802,7 @@
             for (HelperMethodInvocation hmi : so.getHelpers()) {
                 if (hmi.helperLevel != Level.Trial) continue;
                 if (hmi.type != HelperType.SETUP) continue;
-                Collection<String> args = stateHelperArgs.get(hmi.method.getQualifiedName());
+                Collection<String> args = so.helperArgs.get(hmi.method.getQualifiedName());
                 result.add("        val." + hmi.method.getName() + "(" + Utils.join(args, ",") + ");");
             }
             result.add("        " + "val.ready" + Level.Trial + " = true;");
@@ -790,11 +815,11 @@
     }
 
     private String soDependency_TypeArgs(StateObject so) {
-        return (stateObjectDeps.get(so).isEmpty() ? "" : ", " + getTypeArgList(stateObjectDeps.get(so)));
+        return (so.depends.isEmpty() ? "" : ", " + getTypeArgList(so.depends));
     }
 
     private String soDependency_Args(StateObject so) {
-        return (stateObjectDeps.get(so).isEmpty() ? "" : ", " + getArgList(stateObjectDeps.get(so)));
+        return (so.depends.isEmpty() ? "" : ", " + getArgList(so.depends));
     }
 
     public Collection<String> getStateDestructors(MethodInfo method) {
@@ -845,7 +870,7 @@
             linearOrder.addAll(stratum);
             List<StateObject> newStratum = new ArrayList<StateObject>();
             for (StateObject so : stratum) {
-                newStratum.addAll(stateObjectDeps.get(so));
+                newStratum.addAll(so.depends);
             }
             stratum = newStratum;
         }