# HG changeset patch # User Michael Van De Vanter # Date 1442979079 25200 # Node ID 14e6dfb1ef0511d0fdc56dc19bb0cf9965663060 # Parent f78c72e2e0b6f4737caf5c95d44a03a785c60994 Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation" - Caused by lack of a "vm" known to the Accessor during most testing, making the Instrumenter unavailable, which is now required to create a CallTarget - Modified the Instrumenter/Accessor with a static field that can be reflectively "poked" with a vm value for testing - Create a pair of methods to globally enable/disable testing mode to modify that static field and restore it when tests complete. diff -r f78c72e2e0b6 -r 14e6dfb1ef05 mx.truffle/suite.py --- a/mx.truffle/suite.py Tue Sep 22 20:25:58 2015 -0700 +++ b/mx.truffle/suite.py Tue Sep 22 20:31:19 2015 -0700 @@ -84,6 +84,7 @@ "sourceDirs" : ["src"], "dependencies" : [ "com.oracle.truffle.dsl.processor", + "com.oracle.truffle.api.vm", "mx:JUNIT", ], "checkstyle" : "com.oracle.truffle.dsl.processor", @@ -128,6 +129,7 @@ "sourceDirs" : ["src"], "dependencies" : [ "com.oracle.truffle.api.interop.java", + "com.oracle.truffle.api.vm", "mx:JUNIT" ], "checkstyle" : "com.oracle.truffle.api", diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ArrayTest.java --- a/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ArrayTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ArrayTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -22,7 +22,9 @@ */ package com.oracle.truffle.api.dsl.test; +import org.junit.After; import org.junit.Assert; +import org.junit.Before; import org.junit.Test; import com.oracle.truffle.api.CallTarget; @@ -35,6 +37,7 @@ import com.oracle.truffle.api.dsl.TypeSystem; import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.dsl.test.ArrayTestFactory.TestNode1NodeGen; +import com.oracle.truffle.api.dsl.test.utilities.InstrumentationTestMode; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.RootNode; @@ -42,6 +45,16 @@ public class ArrayTest { + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @Test public void testNode1() { final TestNode1 node = TestNode1NodeGen.create(null); diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/AssumptionsTest.java --- a/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/AssumptionsTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/AssumptionsTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -22,6 +22,18 @@ */ package com.oracle.truffle.api.dsl.test; +import static com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget; +import static com.oracle.truffle.api.dsl.test.TestHelper.getNode; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + import com.oracle.truffle.api.Assumption; import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.Truffle; @@ -36,17 +48,21 @@ import com.oracle.truffle.api.dsl.test.AssumptionsTestFactory.MethodTestFactory; import com.oracle.truffle.api.dsl.test.AssumptionsTestFactory.NodeFieldTest2Factory; import com.oracle.truffle.api.dsl.test.AssumptionsTestFactory.StaticFieldTestFactory; -import static com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget; -import static com.oracle.truffle.api.dsl.test.TestHelper.getNode; import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; -import java.util.HashMap; -import java.util.Map; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; -import org.junit.Test; +import com.oracle.truffle.api.dsl.test.utilities.InstrumentationTestMode; public class AssumptionsTest { + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @Test public void testField() { CallTarget root = createCallTarget(FieldTestFactory.getInstance()); diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/BadLongOverflowSpecializationTest.java --- a/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/BadLongOverflowSpecializationTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/BadLongOverflowSpecializationTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -22,18 +22,33 @@ */ package com.oracle.truffle.api.dsl.test; +import static com.oracle.truffle.api.dsl.test.TestHelper.createRoot; +import static com.oracle.truffle.api.dsl.test.TestHelper.executeWith; +import static org.junit.Assert.assertEquals; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.test.BadLongOverflowSpecializationTestFactory.ImplicitCastExclusionFactory; -import static com.oracle.truffle.api.dsl.test.TestHelper.createRoot; -import static com.oracle.truffle.api.dsl.test.TestHelper.executeWith; import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode; import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; -import static org.junit.Assert.assertEquals; -import org.junit.Test; +import com.oracle.truffle.api.dsl.test.utilities.InstrumentationTestMode; public class BadLongOverflowSpecializationTest { + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + /* Regression test for */ @NodeChild diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/BinaryNodeTest.java --- a/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/BinaryNodeTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/BinaryNodeTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -22,20 +22,35 @@ */ package com.oracle.truffle.api.dsl.test; +import static com.oracle.truffle.api.dsl.test.TestHelper.createRoot; +import static com.oracle.truffle.api.dsl.test.TestHelper.executeWith; +import static org.junit.Assert.assertEquals; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.NodeChildren; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.test.BinaryNodeTestFactory.AddNodeFactory; -import static com.oracle.truffle.api.dsl.test.TestHelper.createRoot; -import static com.oracle.truffle.api.dsl.test.TestHelper.executeWith; import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode; import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; -import static org.junit.Assert.assertEquals; -import org.junit.Test; +import com.oracle.truffle.api.dsl.test.utilities.InstrumentationTestMode; public class BinaryNodeTest { + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @Test public void testAdd() { TestRootNode node = createRoot(AddNodeFactory.getInstance()); diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CachedTest.java --- a/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CachedTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CachedTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -22,6 +22,15 @@ */ package com.oracle.truffle.api.dsl.test; +import static com.oracle.truffle.api.dsl.test.TestHelper.assertionsEnabled; +import static com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.NodeChild; @@ -39,16 +48,22 @@ import com.oracle.truffle.api.dsl.test.CachedTestFactory.TestGuardWithJustCachedParameterFactory; import com.oracle.truffle.api.dsl.test.CachedTestFactory.TestMultipleCachesFactory; import com.oracle.truffle.api.dsl.test.CachedTestFactory.UnboundCacheFactory; -import static com.oracle.truffle.api.dsl.test.TestHelper.assertionsEnabled; -import static com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget; import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; -import org.junit.Test; +import com.oracle.truffle.api.dsl.test.utilities.InstrumentationTestMode; @SuppressWarnings("unused") public class CachedTest { + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @Test public void testUnboundCache() { CallTarget root = createCallTarget(UnboundCacheFactory.getInstance()); diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CodeFormatTest.java --- a/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CodeFormatTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CodeFormatTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -22,17 +22,31 @@ */ package com.oracle.truffle.api.dsl.test; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.test.CodeFormatTestFactory.LineWrappingTestFactory; import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; -import org.junit.Assert; -import org.junit.Test; +import com.oracle.truffle.api.dsl.test.utilities.InstrumentationTestMode; /** * Tests the generated code compiles without warnings for unusual large guard names. */ public class CodeFormatTest { + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @Test public void test() { Assert.assertEquals(42, TestHelper.createCallTarget(LineWrappingTestFactory.create()).call()); diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ContainsTest.java --- a/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ContainsTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ContainsTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -22,6 +22,18 @@ */ package com.oracle.truffle.api.dsl.test; +import static com.oracle.truffle.api.dsl.test.TestHelper.array; +import static com.oracle.truffle.api.dsl.test.TestHelper.assertRuns; +import static com.oracle.truffle.api.dsl.test.TestHelper.createRoot; +import static com.oracle.truffle.api.dsl.test.TestHelper.executeWith; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.NodeChildren; import com.oracle.truffle.api.dsl.Specialization; @@ -33,21 +45,24 @@ import com.oracle.truffle.api.dsl.test.ContainsTestFactory.Contains4Factory; import com.oracle.truffle.api.dsl.test.ContainsTestFactory.PolymorphicToMonomorphic0Factory; import com.oracle.truffle.api.dsl.test.TestHelper.ExecutionListener; -import static com.oracle.truffle.api.dsl.test.TestHelper.array; -import static com.oracle.truffle.api.dsl.test.TestHelper.assertRuns; -import static com.oracle.truffle.api.dsl.test.TestHelper.createRoot; -import static com.oracle.truffle.api.dsl.test.TestHelper.executeWith; import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode; import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; +import com.oracle.truffle.api.dsl.test.utilities.InstrumentationTestMode; import com.oracle.truffle.api.nodes.NodeCost; -import static org.hamcrest.CoreMatchers.is; -import org.junit.Assert; -import static org.junit.Assert.assertThat; -import org.junit.Test; @SuppressWarnings("unused") public class ContainsTest { + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + /* * Tests a simple monomorphic inclusion. */ diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ExecuteEvaluatedTest.java --- a/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ExecuteEvaluatedTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ExecuteEvaluatedTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -22,6 +22,11 @@ */ package com.oracle.truffle.api.dsl.test; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.NodeChildren; @@ -43,14 +48,23 @@ import com.oracle.truffle.api.dsl.test.TypeSystemTest.ChildrenNode; import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode; import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; +import com.oracle.truffle.api.dsl.test.utilities.InstrumentationTestMode; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.UnexpectedResultException; -import org.junit.Assert; -import org.junit.Test; public class ExecuteEvaluatedTest { + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @Test public void testSingleEvaluated() { ArgumentNode arg0 = new ArgumentNode(0); diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/FallbackTest.java --- a/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/FallbackTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/FallbackTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -30,16 +30,21 @@ import com.oracle.truffle.api.dsl.test.FallbackTestFactory.Fallback2Factory; import com.oracle.truffle.api.dsl.test.FallbackTestFactory.Fallback3Factory; import com.oracle.truffle.api.dsl.test.FallbackTestFactory.Fallback4Factory; + import static com.oracle.truffle.api.dsl.test.TestHelper.array; import static com.oracle.truffle.api.dsl.test.TestHelper.assertRuns; import static com.oracle.truffle.api.dsl.test.TestHelper.createRoot; import static com.oracle.truffle.api.dsl.test.TestHelper.executeWith; + import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode; import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; +import com.oracle.truffle.api.dsl.test.utilities.InstrumentationTestMode; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeUtil; + import org.junit.Assert; +import org.junit.Before; import org.junit.Test; public class FallbackTest { @@ -47,6 +52,16 @@ private static final Object UNKNOWN_OBJECT = new Object() { }; + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @Before + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @Test public void testFallback1() { assertRuns(Fallback1Factory.getInstance(), // diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ImportGuardsTest.java --- a/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ImportGuardsTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ImportGuardsTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -22,17 +22,32 @@ */ package com.oracle.truffle.api.dsl.test; +import static com.oracle.truffle.api.dsl.test.TestHelper.array; +import static com.oracle.truffle.api.dsl.test.TestHelper.assertRuns; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + import com.oracle.truffle.api.dsl.ImportStatic; import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.test.ImportGuardsTestFactory.ImportGuards6Factory; -import static com.oracle.truffle.api.dsl.test.TestHelper.array; -import static com.oracle.truffle.api.dsl.test.TestHelper.assertRuns; import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; -import org.junit.Test; +import com.oracle.truffle.api.dsl.test.utilities.InstrumentationTestMode; public class ImportGuardsTest { + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @ImportStatic(Imports0.class) @NodeChild("a") static class ImportGuards0 extends ValueNode { diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/IntegerLiteralGuardsTest.java --- a/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/IntegerLiteralGuardsTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/IntegerLiteralGuardsTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -22,6 +22,13 @@ */ package com.oracle.truffle.api.dsl.test; +import static com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget; +import static org.junit.Assert.assertEquals; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.Specialization; @@ -29,14 +36,22 @@ import com.oracle.truffle.api.dsl.test.IntegerLiteralGuardsTestFactory.DecimalLiteralTestFactory; import com.oracle.truffle.api.dsl.test.IntegerLiteralGuardsTestFactory.HexLiteralTestFactory; import com.oracle.truffle.api.dsl.test.IntegerLiteralGuardsTestFactory.OctalLiteralTestFactory; -import static com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget; import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; -import static org.junit.Assert.assertEquals; -import org.junit.Test; +import com.oracle.truffle.api.dsl.test.utilities.InstrumentationTestMode; @SuppressWarnings("unused") public class IntegerLiteralGuardsTest { + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @Test public void testDecimalLiteral() { CallTarget root = createCallTarget(DecimalLiteralTestFactory.getInstance()); diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/LazyClassLoadingTest.java --- a/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/LazyClassLoadingTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/LazyClassLoadingTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -22,18 +22,34 @@ */ package com.oracle.truffle.api.dsl.test; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.test.LazyClassLoadingTestFactory.TestNodeFactory; import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode; import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import org.junit.Assert; -import org.junit.Test; +import com.oracle.truffle.api.dsl.test.utilities.InstrumentationTestMode; public class LazyClassLoadingTest { + + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @Test public void test() { String factoryName = TestNodeFactory.class.getName(); diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/LimitTest.java --- a/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/LimitTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/LimitTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -22,6 +22,14 @@ */ package com.oracle.truffle.api.dsl.test; +import static com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.NodeChild; @@ -31,15 +39,22 @@ import com.oracle.truffle.api.dsl.test.LimitTestFactory.DefaultLimit3TestFactory; import com.oracle.truffle.api.dsl.test.LimitTestFactory.LocalLimitTestFactory; import com.oracle.truffle.api.dsl.test.LimitTestFactory.MethodLimitTestFactory; -import static com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget; import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; -import org.junit.Test; +import com.oracle.truffle.api.dsl.test.utilities.InstrumentationTestMode; @SuppressWarnings("unused") public class LimitTest { + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @Test public void testDefaultLimit3() { CallTarget root = createCallTarget(DefaultLimit3TestFactory.getInstance()); diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/MergeSpecializationsTest.java --- a/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/MergeSpecializationsTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/MergeSpecializationsTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -22,6 +22,18 @@ */ package com.oracle.truffle.api.dsl.test; +import static com.oracle.truffle.api.dsl.test.TestHelper.createRoot; +import static com.oracle.truffle.api.dsl.test.TestHelper.executeWith; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import java.util.Arrays; +import java.util.concurrent.CountDownLatch; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.NodeFactory; @@ -30,21 +42,25 @@ import com.oracle.truffle.api.dsl.internal.SpecializedNode; import com.oracle.truffle.api.dsl.test.MergeSpecializationsTestFactory.TestCachedNodeFactory; import com.oracle.truffle.api.dsl.test.MergeSpecializationsTestFactory.TestNodeFactory; -import static com.oracle.truffle.api.dsl.test.TestHelper.createRoot; -import static com.oracle.truffle.api.dsl.test.TestHelper.executeWith; import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode; import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; +import com.oracle.truffle.api.dsl.test.utilities.InstrumentationTestMode; import com.oracle.truffle.api.nodes.Node; -import java.util.Arrays; -import java.util.concurrent.CountDownLatch; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; -import org.junit.Test; public class MergeSpecializationsTest { private static final int THREADS = 50; + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @NodeChild @SuppressWarnings("unused") abstract static class TestNode extends ValueNode { diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/MethodGuardsTest.java --- a/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/MethodGuardsTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/MethodGuardsTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -22,6 +22,15 @@ */ package com.oracle.truffle.api.dsl.test; +import static com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget; +import static com.oracle.truffle.api.dsl.test.TestHelper.getNode; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.Specialization; @@ -45,16 +54,22 @@ import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.GuardStaticFieldTestFactory; import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.GuardStaticFinalFieldCompareTestFactory; import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.GuardUnboundMethodTestFactory; -import static com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget; -import static com.oracle.truffle.api.dsl.test.TestHelper.getNode; import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; -import org.junit.Test; +import com.oracle.truffle.api.dsl.test.utilities.InstrumentationTestMode; @SuppressWarnings("unused") public class MethodGuardsTest { + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @Test public void testGuardEqual() { CallTarget root = createCallTarget(GuardEqualTestFactory.getInstance()); diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/MethodGuardsWithArgumentsTest.java --- a/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/MethodGuardsWithArgumentsTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/MethodGuardsWithArgumentsTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -22,6 +22,14 @@ */ package com.oracle.truffle.api.dsl.test; +import static com.oracle.truffle.api.dsl.test.TestHelper.createRoot; +import static com.oracle.truffle.api.dsl.test.TestHelper.executeWith; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.NodeChildren; import com.oracle.truffle.api.dsl.Specialization; @@ -32,15 +40,22 @@ import com.oracle.truffle.api.dsl.test.MethodGuardsWithArgumentsTestFactory.MArgumentsDouble2Factory; import com.oracle.truffle.api.dsl.test.MethodGuardsWithArgumentsTestFactory.MArgumentsDouble3Factory; import com.oracle.truffle.api.dsl.test.MethodGuardsWithArgumentsTestFactory.MArgumentsSingle2Factory; -import static com.oracle.truffle.api.dsl.test.TestHelper.createRoot; -import static com.oracle.truffle.api.dsl.test.TestHelper.executeWith; import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode; import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; -import org.junit.Assert; -import org.junit.Test; +import com.oracle.truffle.api.dsl.test.utilities.InstrumentationTestMode; public class MethodGuardsWithArgumentsTest { + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @Test public void testMArguments0() { TestRootNode root = createRoot(MArguments0Factory.getInstance()); diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NegatedGuardsTest.java --- a/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NegatedGuardsTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NegatedGuardsTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -22,17 +22,32 @@ */ package com.oracle.truffle.api.dsl.test; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.dsl.test.NegatedGuardsTestFactory.NegatedGuardNodeFactory; import static com.oracle.truffle.api.dsl.test.TestHelper.createRoot; import static com.oracle.truffle.api.dsl.test.TestHelper.executeWith; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.dsl.test.NegatedGuardsTestFactory.NegatedGuardNodeFactory; import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode; import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; -import org.junit.Assert; -import org.junit.Test; +import com.oracle.truffle.api.dsl.test.utilities.InstrumentationTestMode; public class NegatedGuardsTest { + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @Test public void testGuardGlobal() { TestRootNode root = createRoot(NegatedGuardNodeFactory.getInstance()); diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NodeChildNoNameTest.java --- a/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NodeChildNoNameTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NodeChildNoNameTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -29,12 +29,25 @@ import com.oracle.truffle.api.dsl.test.NodeChildNoNameTestFactory.ThreeArgsNoNameFactory; import com.oracle.truffle.api.dsl.test.NodeChildNoNameTestFactory.TwoArgsNoNameFactory; import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; +import com.oracle.truffle.api.dsl.test.utilities.InstrumentationTestMode; import com.oracle.truffle.api.frame.VirtualFrame; + import org.junit.Assert; +import org.junit.Before; import org.junit.Test; public class NodeChildNoNameTest { + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @Before + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @Test public void testOneArg() { ValueNode node = new ConstantNode(); diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NodeChildTest.java --- a/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NodeChildTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NodeChildTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -22,17 +22,32 @@ */ package com.oracle.truffle.api.dsl.test; +import static com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget; +import static org.junit.Assert.assertEquals; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.NodeChildren; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.test.NodeFieldTestFactory.IntFieldTestNodeFactory; -import static com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget; import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; -import static org.junit.Assert.assertEquals; -import org.junit.Test; +import com.oracle.truffle.api.dsl.test.utilities.InstrumentationTestMode; public class NodeChildTest { + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @Test public void testIntField() { assertEquals(42, createCallTarget(IntFieldTestNodeFactory.create(42)).call()); diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NodeFieldTest.java --- a/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NodeFieldTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NodeFieldTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -22,6 +22,13 @@ */ package com.oracle.truffle.api.dsl.test; +import static com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget; +import static org.junit.Assert.assertEquals; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + import com.oracle.truffle.api.dsl.NodeField; import com.oracle.truffle.api.dsl.NodeFields; import com.oracle.truffle.api.dsl.Specialization; @@ -32,13 +39,21 @@ import com.oracle.truffle.api.dsl.test.NodeFieldTestFactory.RewriteTestNodeFactory; import com.oracle.truffle.api.dsl.test.NodeFieldTestFactory.StringFieldTestNodeFactory; import com.oracle.truffle.api.dsl.test.NodeFieldTestFactory.TestContainerFactory; -import static com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget; import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; -import static org.junit.Assert.assertEquals; -import org.junit.Test; +import com.oracle.truffle.api.dsl.test.utilities.InstrumentationTestMode; public class NodeFieldTest { + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @Test public void testIntField() { assertEquals(42, createCallTarget(IntFieldTestNodeFactory.create(42)).call()); diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NullLiteralGuardsTest.java --- a/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NullLiteralGuardsTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NullLiteralGuardsTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -22,19 +22,34 @@ */ package com.oracle.truffle.api.dsl.test; +import static com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget; +import static org.junit.Assert.assertEquals; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.test.NullLiteralGuardsTestFactory.CompareNotNullNodeFactory; import com.oracle.truffle.api.dsl.test.NullLiteralGuardsTestFactory.CompareObjectsNullNodeFactory; import com.oracle.truffle.api.dsl.test.NullLiteralGuardsTestFactory.CompareStringNullNodeFactory; -import static com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget; import com.oracle.truffle.api.dsl.test.TypeSystemTest.ChildrenNode; -import static org.junit.Assert.assertEquals; -import org.junit.Test; +import com.oracle.truffle.api.dsl.test.utilities.InstrumentationTestMode; @SuppressWarnings("unused") public class NullLiteralGuardsTest { + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @Test public void testCompareObjectsNull() { CallTarget root = createCallTarget(CompareObjectsNullNodeFactory.getInstance()); diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NullTest.java --- a/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NullTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NullTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -22,19 +22,34 @@ */ package com.oracle.truffle.api.dsl.test; +import static com.oracle.truffle.api.dsl.test.TestHelper.createRoot; +import static com.oracle.truffle.api.dsl.test.TestHelper.executeWith; +import static org.junit.Assert.assertEquals; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.test.NullTestFactory.NullTest1Factory; -import static com.oracle.truffle.api.dsl.test.TestHelper.createRoot; -import static com.oracle.truffle.api.dsl.test.TestHelper.executeWith; import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode; import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; -import static org.junit.Assert.assertEquals; -import org.junit.Test; +import com.oracle.truffle.api.dsl.test.utilities.InstrumentationTestMode; public class NullTest { + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @Test public void testGuardInvocations() { TestRootNode root = createRoot(NullTest1Factory.getInstance()); diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/PolymorphicTest.java --- a/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/PolymorphicTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/PolymorphicTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -22,6 +22,19 @@ */ package com.oracle.truffle.api.dsl.test; +import static com.oracle.truffle.api.dsl.test.TestHelper.array; +import static com.oracle.truffle.api.dsl.test.TestHelper.assertRuns; +import static org.junit.Assert.assertEquals; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.Specialization; @@ -29,22 +42,25 @@ import com.oracle.truffle.api.dsl.test.PolymorphicTestFactory.Polymorphic2Factory; import com.oracle.truffle.api.dsl.test.PolymorphicTestFactory.Polymorphic3Factory; import com.oracle.truffle.api.dsl.test.TestHelper.ExecutionListener; -import static com.oracle.truffle.api.dsl.test.TestHelper.array; -import static com.oracle.truffle.api.dsl.test.TestHelper.assertRuns; import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode; import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; +import com.oracle.truffle.api.dsl.test.utilities.InstrumentationTestMode; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeCost; import com.oracle.truffle.api.nodes.NodeUtil; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; -import org.junit.Assert; -import static org.junit.Assert.assertEquals; -import org.junit.Test; public class PolymorphicTest { + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + private static void assertParent(Node expectedParent, Node child) { Node parent = child.getParent(); while (parent != null && parent != expectedParent) { diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/PolymorphicTest2.java --- a/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/PolymorphicTest2.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/PolymorphicTest2.java Tue Sep 22 20:31:19 2015 -0700 @@ -22,17 +22,32 @@ */ package com.oracle.truffle.api.dsl.test; +import static com.oracle.truffle.api.dsl.test.TestHelper.executeWith; +import static org.junit.Assert.assertEquals; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.test.BinaryNodeTest.BinaryNode; import com.oracle.truffle.api.dsl.test.PolymorphicTest2Factory.Polymorphic1Factory; -import static com.oracle.truffle.api.dsl.test.TestHelper.executeWith; import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode; +import com.oracle.truffle.api.dsl.test.utilities.InstrumentationTestMode; import com.oracle.truffle.api.nodes.NodeCost; -import static org.junit.Assert.assertEquals; -import org.junit.Test; public class PolymorphicTest2 { + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @Test public void testMultipleTypes() { /* Tests the unexpected polymorphic case. */ diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ShortCircuitTest.java --- a/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ShortCircuitTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ShortCircuitTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -24,6 +24,8 @@ import static org.junit.Assert.assertEquals; +import org.junit.After; +import org.junit.Before; import org.junit.Test; import com.oracle.truffle.api.CallTarget; @@ -40,9 +42,20 @@ import com.oracle.truffle.api.dsl.test.ShortCircuitTestFactory.VarArgsNodeFactory; import com.oracle.truffle.api.dsl.test.TypeSystemTest.ArgumentNode; import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; +import com.oracle.truffle.api.dsl.test.utilities.InstrumentationTestMode; public class ShortCircuitTest { + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @Test public void testSingleChild1() { ArgumentNode arg0 = new ArgumentNode(0); diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SourceSectionTest.java --- a/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SourceSectionTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SourceSectionTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -22,6 +22,22 @@ */ package com.oracle.truffle.api.dsl.test; +import static com.oracle.truffle.api.dsl.test.TestHelper.createRoot; +import static com.oracle.truffle.api.dsl.test.TestHelper.createRootPrefix; +import static com.oracle.truffle.api.dsl.test.TestHelper.executeWith; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.sameInstance; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThat; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.experimental.theories.DataPoints; +import org.junit.experimental.theories.Theories; +import org.junit.experimental.theories.Theory; +import org.junit.runner.RunWith; + import com.oracle.truffle.api.dsl.CreateCast; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.NodeChild; @@ -29,29 +45,28 @@ import com.oracle.truffle.api.dsl.internal.SpecializationNode; import com.oracle.truffle.api.dsl.test.SourceSectionTestFactory.SourceSection0Factory; import com.oracle.truffle.api.dsl.test.SourceSectionTestFactory.SourceSection1Factory; -import static com.oracle.truffle.api.dsl.test.TestHelper.createRoot; -import static com.oracle.truffle.api.dsl.test.TestHelper.createRootPrefix; -import static com.oracle.truffle.api.dsl.test.TestHelper.executeWith; import com.oracle.truffle.api.dsl.test.TypeSystemTest.ArgumentNode; import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode; import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; +import com.oracle.truffle.api.dsl.test.utilities.InstrumentationTestMode; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.source.SourceSection; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.sameInstance; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; -import org.junit.Test; -import org.junit.experimental.theories.DataPoints; -import org.junit.experimental.theories.Theories; -import org.junit.experimental.theories.Theory; -import org.junit.runner.RunWith; @RunWith(Theories.class) public class SourceSectionTest { @DataPoints public static final int[] data = new int[]{1, 2, 3, 4}; + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @Theory public void testSourceSections(int value0, int value1, int value2) { TestRootNode root = createRoot(SourceSection0Factory.getInstance()); diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SpecializationFallthroughTest.java --- a/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SpecializationFallthroughTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SpecializationFallthroughTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -22,6 +22,14 @@ */ package com.oracle.truffle.api.dsl.test; +import static com.oracle.truffle.api.dsl.test.TestHelper.array; +import static com.oracle.truffle.api.dsl.test.TestHelper.assertRuns; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.NodeChildren; @@ -33,15 +41,22 @@ import com.oracle.truffle.api.dsl.test.SpecializationFallthroughTestFactory.FallthroughTest4Factory; import com.oracle.truffle.api.dsl.test.SpecializationFallthroughTestFactory.FallthroughTest5Factory; import com.oracle.truffle.api.dsl.test.TestHelper.ExecutionListener; -import static com.oracle.truffle.api.dsl.test.TestHelper.array; -import static com.oracle.truffle.api.dsl.test.TestHelper.assertRuns; import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode; import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; -import org.junit.Assert; -import org.junit.Test; +import com.oracle.truffle.api.dsl.test.utilities.InstrumentationTestMode; public class SpecializationFallthroughTest { + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @Test public void testFallthrough0() { assertRuns(FallthroughTest0Factory.getInstance(), // diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SpecializationGroupingTest.java --- a/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SpecializationGroupingTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SpecializationGroupingTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -22,16 +22,20 @@ */ package com.oracle.truffle.api.dsl.test; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.test.SpecializationGroupingTestFactory.TestElseConnectionBug1Factory; import com.oracle.truffle.api.dsl.test.SpecializationGroupingTestFactory.TestElseConnectionBug2Factory; import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; +import com.oracle.truffle.api.dsl.test.utilities.InstrumentationTestMode; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.SlowPathException; -import org.junit.Assert; -import org.junit.Test; /** * Tests execution counts of guards. While we do not make guarantees for guard invocation except for @@ -40,6 +44,16 @@ */ public class SpecializationGroupingTest { + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @Test public void testElseConnectionBug1() { CallTarget target = TestHelper.createCallTarget(TestElseConnectionBug1Factory.create(new GenericInt())); diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TestSerialization.java --- a/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TestSerialization.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TestSerialization.java Tue Sep 22 20:31:19 2015 -0700 @@ -22,19 +22,34 @@ */ package com.oracle.truffle.api.dsl.test; +import static com.oracle.truffle.api.dsl.test.TestHelper.executeWith; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.Specialization; -import static com.oracle.truffle.api.dsl.test.TestHelper.executeWith; import com.oracle.truffle.api.dsl.test.TestSerializationFactory.SerializedNodeFactory; import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode; import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; +import com.oracle.truffle.api.dsl.test.utilities.InstrumentationTestMode; import com.oracle.truffle.api.nodes.NodeCost; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import org.junit.Test; public class TestSerialization { + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @Test public void testUpdateRoot() { /* Tests the unexpected polymorphic case. */ diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/UnsupportedSpecializationTest.java --- a/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/UnsupportedSpecializationTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/UnsupportedSpecializationTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -22,6 +22,13 @@ */ package com.oracle.truffle.api.dsl.test; +import java.util.List; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.NodeChildren; import com.oracle.truffle.api.dsl.ShortCircuit; @@ -31,14 +38,22 @@ import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; import com.oracle.truffle.api.dsl.test.UnsupportedSpecializationTestFactory.Unsupported1Factory; import com.oracle.truffle.api.dsl.test.UnsupportedSpecializationTestFactory.Unsupported2Factory; +import com.oracle.truffle.api.dsl.test.utilities.InstrumentationTestMode; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeUtil; -import java.util.List; -import org.junit.Assert; -import org.junit.Test; public class UnsupportedSpecializationTest { + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @Test public void testUnsupported1() { TestRootNode root = TestHelper.createRoot(Unsupported1Factory.getInstance()); diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/FunctionCall.java --- a/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/FunctionCall.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/FunctionCall.java Tue Sep 22 20:31:19 2015 -0700 @@ -22,19 +22,24 @@ */ package com.oracle.truffle.api.dsl.test.examples; +import static com.oracle.truffle.api.dsl.test.examples.ExampleNode.createArguments; +import static com.oracle.truffle.api.dsl.test.examples.ExampleNode.createDummyTarget; +import static com.oracle.truffle.api.dsl.test.examples.ExampleNode.createTarget; +import static org.junit.Assert.assertEquals; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Specialization; -import static com.oracle.truffle.api.dsl.test.examples.ExampleNode.createArguments; -import static com.oracle.truffle.api.dsl.test.examples.ExampleNode.createDummyTarget; -import static com.oracle.truffle.api.dsl.test.examples.ExampleNode.createTarget; import com.oracle.truffle.api.dsl.test.examples.FunctionCallFactory.FunctionCallNodeGen; +import com.oracle.truffle.api.dsl.test.utilities.InstrumentationTestMode; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.DirectCallNode; import com.oracle.truffle.api.nodes.IndirectCallNode; -import static org.junit.Assert.assertEquals; -import org.junit.Test; /** * This example illustrates how {@link Cached} can be used to implement function calls that use @@ -46,6 +51,16 @@ @SuppressWarnings("unused") public class FunctionCall { + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @Test public void testFunctionCall() { assertEquals(2, FunctionCallNode.CACHE_SIZE); diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/Interop.java --- a/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/Interop.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/Interop.java Tue Sep 22 20:31:19 2015 -0700 @@ -22,17 +22,22 @@ */ package com.oracle.truffle.api.dsl.test.examples; +import static com.oracle.truffle.api.dsl.test.examples.ExampleNode.createArguments; +import static com.oracle.truffle.api.dsl.test.examples.ExampleNode.createTarget; +import static org.junit.Assert.assertEquals; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Specialization; -import static com.oracle.truffle.api.dsl.test.examples.ExampleNode.createArguments; -import static com.oracle.truffle.api.dsl.test.examples.ExampleNode.createTarget; import com.oracle.truffle.api.dsl.test.examples.InteropFactory.UseInteropNodeGen; +import com.oracle.truffle.api.dsl.test.utilities.InstrumentationTestMode; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; -import static org.junit.Assert.assertEquals; -import org.junit.Test; /** * This example aims to illustrate how the {@link Cached} annotation can be used to implement a @@ -40,6 +45,16 @@ */ public class Interop { + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @Test public void testInterop() { UseInterop node = UseInteropNodeGen.create(createArguments(2)); diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/MathPow.java --- a/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/MathPow.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/MathPow.java Tue Sep 22 20:31:19 2015 -0700 @@ -25,11 +25,18 @@ import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Specialization; + import static com.oracle.truffle.api.dsl.test.examples.ExampleNode.createArguments; import static com.oracle.truffle.api.dsl.test.examples.ExampleNode.createTarget; + import com.oracle.truffle.api.dsl.test.examples.MathPowFactory.MathPowNodeGen; +import com.oracle.truffle.api.dsl.test.utilities.InstrumentationTestMode; import com.oracle.truffle.api.nodes.Node; + import static org.junit.Assert.assertEquals; + +import org.junit.After; +import org.junit.Before; import org.junit.Test; /** @@ -42,6 +49,16 @@ @SuppressWarnings("unused") public class MathPow extends Node { + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @Test public void testPow() { MathPowNode node = MathPowNodeGen.create(createArguments(2)); diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/RubyCall.java --- a/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/RubyCall.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/RubyCall.java Tue Sep 22 20:31:19 2015 -0700 @@ -22,6 +22,17 @@ */ package com.oracle.truffle.api.dsl.test.examples; +import static com.oracle.truffle.api.dsl.test.examples.ExampleNode.createArguments; +import static com.oracle.truffle.api.dsl.test.examples.ExampleNode.createTarget; +import static org.junit.Assert.assertEquals; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + import com.oracle.truffle.api.Assumption; import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; @@ -29,21 +40,15 @@ import com.oracle.truffle.api.dsl.ImportStatic; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.internal.SpecializedNode; -import static com.oracle.truffle.api.dsl.test.examples.ExampleNode.createArguments; -import static com.oracle.truffle.api.dsl.test.examples.ExampleNode.createTarget; import com.oracle.truffle.api.dsl.test.examples.RubyCallFactory.RubyDispatchNodeGen; import com.oracle.truffle.api.dsl.test.examples.RubyCallFactory.RubyHeadNodeGen; import com.oracle.truffle.api.dsl.test.examples.RubyCallFactory.RubyLookupNodeGen; +import com.oracle.truffle.api.dsl.test.utilities.InstrumentationTestMode; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.DirectCallNode; import com.oracle.truffle.api.nodes.IndirectCallNode; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.nodes.Node.Child; import com.oracle.truffle.api.utilities.CyclicAssumption; -import java.util.HashMap; -import java.util.Map; -import static org.junit.Assert.assertEquals; -import org.junit.Test; /** * This example illustrates a simplified version of a Ruby function call semantics (RubyHeadNode). @@ -52,6 +57,16 @@ @SuppressWarnings("unused") public class RubyCall { + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @Test public void testCall() { RubyHeadNode node = RubyHeadNodeGen.create(createArguments(4)); diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/utilities/InstrumentationTestMode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/utilities/InstrumentationTestMode.java Tue Sep 22 20:31:19 2015 -0700 @@ -0,0 +1,46 @@ +/* + * Copyright (c) 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. + * + * 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 com.oracle.truffle.api.dsl.test.utilities; + +import java.lang.reflect.Field; + +import com.oracle.truffle.api.instrument.Instrumenter; +import com.oracle.truffle.api.vm.TruffleVM; + +public class InstrumentationTestMode { + + public static void set(boolean enable) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + final TruffleVM vm = TruffleVM.newVM().build(); + final Field instrumenterField = vm.getClass().getDeclaredField("instrumenter"); + instrumenterField.setAccessible(true); + final Object instrumenter = instrumenterField.get(vm); + final java.lang.reflect.Field testVMField = Instrumenter.class.getDeclaredField("testVM"); + testVMField.setAccessible(true); + if (enable) { + testVMField.set(instrumenter, vm); + } else { + testVMField.set(instrumenter, null); + } + } + +} diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.interop.java.test/src/com/oracle/truffle/api/interop/java/test/ClassInteropTest.java --- a/truffle/com.oracle.truffle.api.interop.java.test/src/com/oracle/truffle/api/interop/java/test/ClassInteropTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.interop.java.test/src/com/oracle/truffle/api/interop/java/test/ClassInteropTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -27,10 +27,13 @@ import com.oracle.truffle.api.interop.Message; import com.oracle.truffle.api.interop.TruffleObject; import com.oracle.truffle.api.interop.java.JavaInterop; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; + +import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -48,9 +51,15 @@ } @Before - public void initObjects() { + public void initObjects() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { obj = JavaInterop.asTruffleObject(ClassInteropTest.class); xyp = JavaInterop.asJavaObject(XYPlus.class, obj); + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); } @Test diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.interop.java.test/src/com/oracle/truffle/api/interop/java/test/InstrumentationTestMode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/truffle/com.oracle.truffle.api.interop.java.test/src/com/oracle/truffle/api/interop/java/test/InstrumentationTestMode.java Tue Sep 22 20:31:19 2015 -0700 @@ -0,0 +1,48 @@ +/* + * Copyright (c) 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 com.oracle.truffle.api.interop.java.test; + +import java.lang.reflect.Field; + +import com.oracle.truffle.api.instrument.Instrumenter; +import com.oracle.truffle.api.vm.TruffleVM; + +public class InstrumentationTestMode { + + public static void set(boolean enable) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + final TruffleVM vm = TruffleVM.newVM().build(); + final Field instrumenterField = vm.getClass().getDeclaredField("instrumenter"); + instrumenterField.setAccessible(true); + final Object instrumenter = instrumenterField.get(vm); + final java.lang.reflect.Field testVMField = Instrumenter.class.getDeclaredField("testVM"); + testVMField.setAccessible(true); + if (enable) { + testVMField.set(instrumenter, vm); + } else { + testVMField.set(instrumenter, null); + } + } + +} diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.interop.java.test/src/com/oracle/truffle/api/interop/java/test/JavaInteropSpeedTest.java --- a/truffle/com.oracle.truffle.api.interop.java.test/src/com/oracle/truffle/api/interop/java/test/JavaInteropSpeedTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.interop.java.test/src/com/oracle/truffle/api/interop/java/test/JavaInteropSpeedTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -24,14 +24,17 @@ */ package com.oracle.truffle.api.interop.java.test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import java.util.Random; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + import com.oracle.truffle.api.interop.TruffleObject; import com.oracle.truffle.api.interop.java.JavaInterop; -import java.util.Random; -import org.junit.AfterClass; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; -import org.junit.BeforeClass; -import org.junit.Test; public class JavaInteropSpeedTest { private static final int REPEAT = 10000; @@ -40,7 +43,8 @@ private static long interopTime; @BeforeClass - public static void beforeTesting() { + public static void beforeTesting() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); arr = initArray(REPEAT); for (int i = 0; i < 1000; i++) { JavaInteropSpeedTest t = new JavaInteropSpeedTest(); @@ -50,6 +54,11 @@ } } + @AfterClass + public static void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + private int mmInOp; private int mmInJava; diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.interop.java.test/src/com/oracle/truffle/api/interop/java/test/JavaInteropTest.java --- a/truffle/com.oracle.truffle.api.interop.java.test/src/com/oracle/truffle/api/interop/java/test/JavaInteropTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.interop.java.test/src/com/oracle/truffle/api/interop/java/test/JavaInteropTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -24,6 +24,17 @@ */ package com.oracle.truffle.api.interop.java.test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; + +import java.util.List; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.Truffle; import com.oracle.truffle.api.TruffleLanguage; @@ -35,13 +46,6 @@ import com.oracle.truffle.api.interop.java.MethodMessage; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.RootNode; -import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; -import org.junit.Before; -import org.junit.Test; public class JavaInteropTest { public int x; @@ -64,9 +68,15 @@ } @Before - public void initObjects() { + public void initObjects() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { obj = JavaInterop.asTruffleObject(this); xyp = JavaInterop.asJavaObject(XYPlus.class, obj); + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); } @Test diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.interop.java.test/src/com/oracle/truffle/api/interop/java/test/MethodMessageTest.java --- a/truffle/com.oracle.truffle.api.interop.java.test/src/com/oracle/truffle/api/interop/java/test/MethodMessageTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.interop.java.test/src/com/oracle/truffle/api/interop/java/test/MethodMessageTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -27,9 +27,14 @@ import com.oracle.truffle.api.interop.TruffleObject; import com.oracle.truffle.api.interop.java.JavaInterop; import com.oracle.truffle.api.interop.java.MethodMessage; +import com.oracle.truffle.api.interop.java.test.JavaInteropTest.XYPlus; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; + +import org.junit.After; +import org.junit.Before; import org.junit.Test; public class MethodMessageTest { @@ -38,6 +43,16 @@ MaxFunction max(); } + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + interface MaxFunction { @MethodMessage(message = "IS_NULL") boolean isNull(); diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.interop.java.test/src/com/oracle/truffle/api/interop/java/test/PrimitiveArrayInteropTest.java --- a/truffle/com.oracle.truffle.api.interop.java.test/src/com/oracle/truffle/api/interop/java/test/PrimitiveArrayInteropTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.interop.java.test/src/com/oracle/truffle/api/interop/java/test/PrimitiveArrayInteropTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -26,9 +26,13 @@ import com.oracle.truffle.api.interop.TruffleObject; import com.oracle.truffle.api.interop.java.JavaInterop; + import java.util.List; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; + +import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -67,9 +71,15 @@ private ExactMatchInterop interop; @Before - public void initObjects() { + public void initObjects() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { obj = JavaInterop.asTruffleObject(this); interop = JavaInterop.asJavaObject(ExactMatchInterop.class, obj); + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); } @Test diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.interop.java.test/src/com/oracle/truffle/api/interop/java/test/PrimitiveRawArrayInteropTest.java --- a/truffle/com.oracle.truffle.api.interop.java.test/src/com/oracle/truffle/api/interop/java/test/PrimitiveRawArrayInteropTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.interop.java.test/src/com/oracle/truffle/api/interop/java/test/PrimitiveRawArrayInteropTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -26,9 +26,13 @@ import com.oracle.truffle.api.interop.TruffleObject; import com.oracle.truffle.api.interop.java.JavaInterop; + import java.util.List; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; + +import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -76,9 +80,15 @@ private RawInterop interop; @Before - public void initObjects() { + public void initObjects() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { obj = JavaInterop.asTruffleObject(this); interop = JavaInterop.asJavaObject(RawInterop.class, obj); + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); } @Test diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ArgumentsTest.java --- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ArgumentsTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ArgumentsTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -22,7 +22,9 @@ */ package com.oracle.truffle.api.test; +import org.junit.After; import org.junit.Assert; +import org.junit.Before; import org.junit.Test; import com.oracle.truffle.api.CallTarget; @@ -31,6 +33,7 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.RootNode; +import com.oracle.truffle.api.test.utilities.InstrumentationTestMode; /** *

Passing Arguments

@@ -55,6 +58,16 @@ */ public class ArgumentsTest { + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @Test public void test() { TruffleRuntime runtime = Truffle.getRuntime(); diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/CallTest.java --- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/CallTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/CallTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -27,7 +27,11 @@ import com.oracle.truffle.api.TruffleRuntime; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.RootNode; +import com.oracle.truffle.api.test.utilities.InstrumentationTestMode; + +import org.junit.After; import org.junit.Assert; +import org.junit.Before; import org.junit.Test; /** @@ -46,6 +50,16 @@ */ public class CallTest { + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @Test public void test() { TruffleRuntime runtime = Truffle.getRuntime(); diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ChildNodeTest.java --- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ChildNodeTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ChildNodeTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -29,8 +29,13 @@ import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.Node.Child; import com.oracle.truffle.api.nodes.RootNode; +import com.oracle.truffle.api.test.utilities.InstrumentationTestMode; + import java.util.Iterator; + +import org.junit.After; import org.junit.Assert; +import org.junit.Before; import org.junit.Test; /** @@ -55,6 +60,16 @@ */ public class ChildNodeTest { + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @Test public void test() { TruffleRuntime runtime = Truffle.getRuntime(); diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ChildrenNodesTest.java --- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ChildrenNodesTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ChildrenNodesTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -28,8 +28,13 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.RootNode; +import com.oracle.truffle.api.test.utilities.InstrumentationTestMode; + import java.util.Iterator; + +import org.junit.After; import org.junit.Assert; +import org.junit.Before; import org.junit.Test; /** @@ -51,6 +56,16 @@ */ public class ChildrenNodesTest { + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @Test public void test() { TruffleRuntime runtime = Truffle.getRuntime(); diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FinalFieldTest.java --- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FinalFieldTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FinalFieldTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -28,7 +28,11 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.RootNode; +import com.oracle.truffle.api.test.utilities.InstrumentationTestMode; + +import org.junit.After; import org.junit.Assert; +import org.junit.Before; import org.junit.Test; /** @@ -54,6 +58,16 @@ */ public class FinalFieldTest { + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @Test public void test() { TruffleRuntime runtime = Truffle.getRuntime(); diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FrameSlotTypeSpecializationTest.java --- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FrameSlotTypeSpecializationTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FrameSlotTypeSpecializationTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -32,7 +32,11 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.RootNode; +import com.oracle.truffle.api.test.utilities.InstrumentationTestMode; + +import org.junit.After; import org.junit.Assert; +import org.junit.Before; import org.junit.Test; /** @@ -51,6 +55,16 @@ */ public class FrameSlotTypeSpecializationTest { + @Before + public void setInstrumentationTestMode() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void unsetInstrumentationTestMode() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @Test public void test() { TruffleRuntime runtime = Truffle.getRuntime(); diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FrameTest.java --- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FrameTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FrameTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -22,6 +22,11 @@ */ package com.oracle.truffle.api.test; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.Truffle; import com.oracle.truffle.api.TruffleRuntime; @@ -33,8 +38,7 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.RootNode; -import org.junit.Assert; -import org.junit.Test; +import com.oracle.truffle.api.test.utilities.InstrumentationTestMode; /** *

Storing Values in Frame Slots

@@ -69,8 +73,18 @@ */ public class FrameTest { + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @Test - public void test() { + public void test() throws SecurityException, IllegalArgumentException { TruffleRuntime runtime = Truffle.getRuntime(); FrameDescriptor frameDescriptor = new FrameDescriptor(); String varName = "localVar"; diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/InterfaceChildFieldTest.java --- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/InterfaceChildFieldTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/InterfaceChildFieldTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -30,8 +30,13 @@ import com.oracle.truffle.api.nodes.NodeInterface; import com.oracle.truffle.api.nodes.NodeUtil; import com.oracle.truffle.api.nodes.RootNode; +import com.oracle.truffle.api.test.utilities.InstrumentationTestMode; + import java.util.Iterator; + +import org.junit.After; import org.junit.Assert; +import org.junit.Before; import org.junit.Test; /** @@ -39,6 +44,16 @@ */ public class InterfaceChildFieldTest { + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @Test public void testChild() { TruffleRuntime runtime = Truffle.getRuntime(); diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ReplaceTest.java --- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ReplaceTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ReplaceTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -28,9 +28,16 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.RootNode; +import com.oracle.truffle.api.test.utilities.InstrumentationTestMode; + import java.util.Iterator; + +import org.junit.After; import org.junit.Assert; +import org.junit.Before; + import static org.junit.Assert.assertEquals; + import org.junit.Test; /** @@ -54,6 +61,16 @@ */ public class ReplaceTest { + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @Test public void test() { TruffleRuntime runtime = Truffle.getRuntime(); diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ReturnTypeSpecializationTest.java --- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ReturnTypeSpecializationTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ReturnTypeSpecializationTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -33,7 +33,11 @@ import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.RootNode; import com.oracle.truffle.api.nodes.UnexpectedResultException; +import com.oracle.truffle.api.test.utilities.InstrumentationTestMode; + +import org.junit.After; import org.junit.Assert; +import org.junit.Before; import org.junit.Test; /** @@ -51,6 +55,16 @@ */ public class ReturnTypeSpecializationTest { + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @Test public void test() { TruffleRuntime runtime = Truffle.getRuntime(); diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/RootNodeTest.java --- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/RootNodeTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/RootNodeTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -27,7 +27,11 @@ import com.oracle.truffle.api.TruffleRuntime; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.RootNode; +import com.oracle.truffle.api.test.utilities.InstrumentationTestMode; + +import org.junit.After; import org.junit.Assert; +import org.junit.Before; import org.junit.Test; /** @@ -50,6 +54,16 @@ */ public class RootNodeTest { + @Before + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); + } + + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + @Test public void test() { TruffleRuntime runtime = Truffle.getRuntime(); diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/TruffleRuntimeTest.java --- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/TruffleRuntimeTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/TruffleRuntimeTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -30,15 +30,20 @@ import com.oracle.truffle.api.nodes.RootNode; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.source.SourceSection; +import com.oracle.truffle.api.test.utilities.InstrumentationTestMode; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; + +import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -63,10 +68,16 @@ private TruffleRuntime runtime; @Before - public void setUp() { + public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(true); this.runtime = Truffle.getRuntime(); } + @After + public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + InstrumentationTestMode.set(false); + } + private static RootNode createTestRootNode() { return new RootNode(TestingLanguage.class, null, null) { @Override diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/instrument/InstrumentationTestNodes.java --- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/instrument/InstrumentationTestNodes.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/instrument/InstrumentationTestNodes.java Tue Sep 22 20:31:19 2015 -0700 @@ -23,8 +23,6 @@ package com.oracle.truffle.api.test.instrument; import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.frame.VirtualFrame; @@ -166,11 +164,6 @@ public boolean isCloningAllowed() { return true; } - - @Override - public void applyInstrumentation() { - super.applyInstrumentation(body); - } } /** @@ -203,18 +196,6 @@ public boolean isCloningAllowed() { return true; } - - @Override - public void applyInstrumentation() { - Method method; - try { - method = Instrumenter.class.getDeclaredMethod("applyInstrumentation", Node.class); - method.setAccessible(true); - method.invoke(instrumenter, body); - } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - throw new RuntimeException("InstrumentationTestNodes"); - } - } } static class TestAdvancedInstrumentCounterRoot extends AdvancedInstrumentRoot { diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/utilities/InstrumentationTestMode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/utilities/InstrumentationTestMode.java Tue Sep 22 20:31:19 2015 -0700 @@ -0,0 +1,46 @@ +/* + * Copyright (c) 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. + * + * 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 com.oracle.truffle.api.test.utilities; + +import java.lang.reflect.Field; + +import com.oracle.truffle.api.instrument.Instrumenter; +import com.oracle.truffle.api.vm.TruffleVM; + +public class InstrumentationTestMode { + + public static void set(boolean enable) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + final TruffleVM vm = TruffleVM.newVM().build(); + final Field instrumenterField = vm.getClass().getDeclaredField("instrumenter"); + instrumenterField.setAccessible(true); + final Object instrumenter = instrumenterField.get(vm); + final java.lang.reflect.Field testVMField = Instrumenter.class.getDeclaredField("testVM"); + testVMField.setAccessible(true); + if (enable) { + testVMField.set(instrumenter, vm); + } else { + testVMField.set(instrumenter, null); + } + } + +} diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/vm/InitializationTest.java --- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/vm/InitializationTest.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/vm/InitializationTest.java Tue Sep 22 20:31:19 2015 -0700 @@ -113,11 +113,6 @@ public Object execute(VirtualFrame frame) { return node.constant(); } - - @Override - public void applyInstrumentation() { - super.applyInstrumentation(node); - } } private static class ANode extends Node { diff -r f78c72e2e0b6 -r 14e6dfb1ef05 truffle/com.oracle.truffle.tools.test/src/com/oracle/truffle/tools/test/ToolTestUtil.java --- a/truffle/com.oracle.truffle.tools.test/src/com/oracle/truffle/tools/test/ToolTestUtil.java Tue Sep 22 20:25:58 2015 -0700 +++ b/truffle/com.oracle.truffle.tools.test/src/com/oracle/truffle/tools/test/ToolTestUtil.java Tue Sep 22 20:31:19 2015 -0700 @@ -25,8 +25,6 @@ package com.oracle.truffle.tools.test; import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.Truffle; @@ -323,10 +321,6 @@ return true; } - @Override - public void applyInstrumentation() { - super.applyInstrumentation(body); - } } /** @@ -359,18 +353,5 @@ public boolean isCloningAllowed() { return true; } - - @Override - public void applyInstrumentation() { - Method method; - try { - method = Instrumenter.class.getDeclaredMethod("applyInstrumentation", Node.class); - method.setAccessible(true); - method.invoke(instrumenter, body); - } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - throw new RuntimeException("InstrumentationTestNodes"); - } - } } - }