# HG changeset patch # User Michael Van De Vanter # Date 1443677086 25200 # Node ID 4d8fc9f88d30a4d1b3c30a2763db31a86a2690e3 # Parent 339272c9d5196609104a2d76184d40e58e8b24ee Eclipseformat diff -r 339272c9d519 -r 4d8fc9f88d30 graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/InstrumentationPartialEvaluationTest.java --- a/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/InstrumentationPartialEvaluationTest.java Wed Sep 30 22:10:52 2015 -0700 +++ b/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/InstrumentationPartialEvaluationTest.java Wed Sep 30 22:24:46 2015 -0700 @@ -32,352 +32,353 @@ return 42; } -// @Test -// public void constantValueUninstrumented() { -// FrameDescriptor fd = new FrameDescriptor(); -// AbstractTestNode result = new ConstantTestNode(42); -// RootTestNode root = new RootTestNode(fd, "constantValue", result); -// root.adoptChildren(); -// assertPartialEvalEquals("constant42", root); -// } -// -// @Test -// public void constantValueProbedNoInstruments() { -// FrameDescriptor fd = new FrameDescriptor(); -// AbstractTestNode result = new ConstantTestNode(42); -// RootTestNode root = new RootTestNode(fd, "constantValue", result); -// root.adoptChildren(); -// result.probe(); -// assertPartialEvalEquals("constant42", root); -// } -// -// @Test -// public void constantValueProbedNullInstrument1() { -// FrameDescriptor fd = new FrameDescriptor(); -// AbstractTestNode result = new ConstantTestNode(42); -// RootTestNode root = new RootTestNode(fd, "constantValue", result); -// root.adoptChildren(); -// Probe probe = result.probe(); -// Instrument instrument = Instrument.create(new DefaultSimpleInstrumentListener(), -// "Null test Instrument"); -// probe.attach(instrument); -// assertPartialEvalEquals("constant42", root); -// } -// -// @Test -// public void constantValueProbedNullInstrument2() { -// FrameDescriptor fd = new FrameDescriptor(); -// AbstractTestNode result = new ConstantTestNode(42); -// RootTestNode root = new RootTestNode(fd, "constantValue", result); -// root.adoptChildren(); -// Probe probe = result.probe(); -// Instrument instrument = Instrument.create(new DefaultStandardInstrumentListener(), -// "Null test Instrument"); -// probe.attach(instrument); -// assertPartialEvalEquals("constant42", root); -// } -// -// @Test -// public void constantValueProbedNullInstrumentDisposed1() { -// FrameDescriptor fd = new FrameDescriptor(); -// AbstractTestNode result = new ConstantTestNode(42); -// RootTestNode root = new RootTestNode(fd, "constantValue", result); -// root.adoptChildren(); -// Probe probe = result.probe(); -// Instrument instrument = Instrument.create(new DefaultSimpleInstrumentListener(), -// "Null test Instrument"); -// probe.attach(instrument); -// instrument.dispose(); -// assertPartialEvalEquals("constant42", root); -// } -// -// @Test -// public void constantValueProbedNullInstrumentDisposed2() { -// FrameDescriptor fd = new FrameDescriptor(); -// AbstractTestNode result = new ConstantTestNode(42); -// RootTestNode root = new RootTestNode(fd, "constantValue", result); -// root.adoptChildren(); -// Probe probe = result.probe(); -// Instrument instrument = Instrument.create(new DefaultStandardInstrumentListener(), -// "Null test Instrument"); -// probe.attach(instrument); -// instrument.dispose(); -// assertPartialEvalEquals("constant42", root); -// } -// -// @Test -// public void constantValueProbedTwoNullInstruments1() { -// FrameDescriptor fd = new FrameDescriptor(); -// AbstractTestNode result = new ConstantTestNode(42); -// RootTestNode root = new RootTestNode(fd, "constantValue", result); -// root.adoptChildren(); -// Probe probe = result.probe(); -// Instrument instrument1 = Instrument.create(new DefaultSimpleInstrumentListener(), -// "Null test Instrument 1"); -// probe.attach(instrument1); -// Instrument instrument2 = Instrument.create(new DefaultSimpleInstrumentListener(), -// "Null test Instrument 2"); -// probe.attach(instrument2); -// assertPartialEvalEquals("constant42", root); -// } -// -// @Test -// public void constantValueProbedTwoNullInstruments2() { -// FrameDescriptor fd = new FrameDescriptor(); -// AbstractTestNode result = new ConstantTestNode(42); -// RootTestNode root = new RootTestNode(fd, "constantValue", result); -// root.adoptChildren(); -// Probe probe = result.probe(); -// Instrument instrument1 = Instrument.create(new DefaultStandardInstrumentListener(), -// "Null test Instrument 1"); -// probe.attach(instrument1); -// Instrument instrument2 = Instrument.create(new DefaultStandardInstrumentListener(), -// "Null test Instrument 2"); -// probe.attach(instrument2); -// assertPartialEvalEquals("constant42", root); -// } -// -// @Test -// public void constantValueProbedThreeNullInstruments1() { -// FrameDescriptor fd = new FrameDescriptor(); -// AbstractTestNode result = new ConstantTestNode(42); -// RootTestNode root = new RootTestNode(fd, "constantValue", result); -// root.adoptChildren(); -// Probe probe = result.probe(); -// Instrument instrument1 = Instrument.create(new DefaultSimpleInstrumentListener(), -// "Null test Instrument 1"); -// probe.attach(instrument1); -// Instrument instrument2 = Instrument.create(new DefaultSimpleInstrumentListener(), -// "Null test Instrument 2"); -// probe.attach(instrument2); -// Instrument instrument3 = Instrument.create(new DefaultSimpleInstrumentListener(), -// "Null test Instrument 3"); -// probe.attach(instrument3); -// assertPartialEvalEquals("constant42", root); -// } -// -// @Test -// public void constantValueProbedThreeNullInstruments2() { -// FrameDescriptor fd = new FrameDescriptor(); -// AbstractTestNode result = new ConstantTestNode(42); -// RootTestNode root = new RootTestNode(fd, "constantValue", result); -// root.adoptChildren(); -// Probe probe = result.probe(); -// Instrument instrument1 = Instrument.create(new DefaultStandardInstrumentListener(), -// "Null test Instrument 1"); -// probe.attach(instrument1); -// Instrument instrument2 = Instrument.create(new DefaultStandardInstrumentListener(), -// "Null test Instrument 2"); -// probe.attach(instrument2); -// Instrument instrument3 = Instrument.create(new DefaultStandardInstrumentListener(), -// "Null test Instrument 3"); -// probe.attach(instrument3); -// assertPartialEvalEquals("constant42", root); -// } -// -// @Test -// public void constantValueProbedThreeNullInstrumentsOneDisposed1() { -// FrameDescriptor fd = new FrameDescriptor(); -// AbstractTestNode result = new ConstantTestNode(42); -// RootTestNode root = new RootTestNode(fd, "constantValue", result); -// root.adoptChildren(); -// Probe probe = result.probe(); -// Instrument instrument1 = Instrument.create(new DefaultSimpleInstrumentListener(), -// "Null test Instrument 1"); -// probe.attach(instrument1); -// Instrument instrument2 = Instrument.create(new DefaultSimpleInstrumentListener(), -// "Null test Instrument 2"); -// probe.attach(instrument2); -// Instrument instrument3 = Instrument.create(new DefaultSimpleInstrumentListener(), -// "Null test Instrument 3"); -// probe.attach(instrument3); -// instrument2.dispose(); -// assertPartialEvalEquals("constant42", root); -// } -// -// @Test -// public void constantValueProbedThreeNullInstrumentsOneDisposed2() { -// FrameDescriptor fd = new FrameDescriptor(); -// AbstractTestNode result = new ConstantTestNode(42); -// RootTestNode root = new RootTestNode(fd, "constantValue", result); -// root.adoptChildren(); -// Probe probe = result.probe(); -// Instrument instrument1 = Instrument.create(new DefaultStandardInstrumentListener(), -// "Null test Instrument 1"); -// probe.attach(instrument1); -// Instrument instrument2 = Instrument.create(new DefaultStandardInstrumentListener(), -// "Null test Instrument 2"); -// probe.attach(instrument2); -// Instrument instrument3 = Instrument.create(new DefaultStandardInstrumentListener(), -// "Null test Instrument 3"); -// probe.attach(instrument3); -// instrument2.dispose(); -// assertPartialEvalEquals("constant42", root); -// } -// -// @Test -// public void constantValueInertAdvancedInstrumentRootFactory() { -// FrameDescriptor fd = new FrameDescriptor(); -// AbstractTestNode result = new ConstantTestNode(42); -// RootTestNode root = new RootTestNode(fd, "constantValue", result); -// root.adoptChildren(); -// Probe testProbe = result.probe(); -// // A factory that could insert a AdvancedInstrumentRoot into the AST, but which never does. -// Instrument instrument = Instrument.create(null, new AdvancedInstrumentRootFactory() { -// -// public AdvancedInstrumentRoot createInstrumentRoot(Probe probe, Node node) { -// return null; -// } -// }, null, "test AdvancedInstrument"); -// testProbe.attach(instrument); -// -// // It all gets compiled away -// assertPartialEvalEquals("constant42", root); -// } -// -// @Test -// public void constantValueInertAdvancedInstrumentRoot() { -// FrameDescriptor fd = new FrameDescriptor(); -// AbstractTestNode resultTestNode = new ConstantTestNode(42); -// RootTestNode rootTestNode = new RootTestNode(fd, "constantValue", resultTestNode); -// rootTestNode.adoptChildren(); -// Probe testProbe = resultTestNode.probe(); -// // Factory inserts a AdvancedInstrumentRoot with empty methods into instrumentation . -// Instrument instrument = Instrument.create(null, new AdvancedInstrumentRootFactory() { -// -// @Override -// public AdvancedInstrumentRoot createInstrumentRoot(Probe probe, Node node) { -// return new AdvancedInstrumentRoot() { -// -// public String instrumentationInfo() { -// return null; -// } -// -// @Override -// public Object executeRoot(Node n, VirtualFrame frame) { -// return null; -// } -// }; -// } -// }, null, "test AdvancedInstrument"); -// testProbe.attach(instrument); -// -// // It all gets compiled away. -// assertPartialEvalEquals("constant42", rootTestNode); -// } -// -// @Test -// public void instrumentDeopt() { -// final FrameDescriptor fd = new FrameDescriptor(); -// final AbstractTestNode result = new ConstantTestNode(42); -// final RootTestNode root = new RootTestNode(fd, "constantValue", result); -// final Probe[] probe = new Probe[1]; -// final int[] count = {1}; -// count[0] = 0; -// // Register a "prober" that will get applied when CallTarget gets created. -// final ASTProber prober = new ASTProber() { -// -// @Override -// public void probeAST(Node node) { -// node.accept(new NodeVisitor() { -// -// @Override -// public boolean visit(Node visitedNode) { -// if (visitedNode instanceof ConstantTestNode) { -// probe[0] = visitedNode.probe(); -// } -// return true; -// } -// -// }); -// } -// }; -// Probe.registerASTProber(prober); -// try { -// final RootCallTarget callTarget = Truffle.getRuntime().createCallTarget(root); -// -// // The CallTarget has one Probe, attached to the ConstantTestNode, ready to run -// Assert.assertEquals(42, callTarget.call()); // Correct result -// Assert.assertEquals(0, count[0]); // Didn't count anything -// -// // Add a counting instrument; this changes the "Probe state" and should cause a deopt -// final Instrument countingInstrument = Instrument.create(new DefaultSimpleInstrumentListener() { -// -// @Override -// public void enter(Probe p) { -// count[0] = count[0] + 1; -// } -// }, null); -// probe[0].attach(countingInstrument); -// -// Assert.assertEquals(42, callTarget.call()); // Correct result -// Assert.assertEquals(1, count[0]); // Counted the first call -// -// // Remove the counting instrument; this changes the "Probe state" and should cause a -// // deopt -// countingInstrument.dispose(); -// -// Assert.assertEquals(42, callTarget.call()); // Correct result -// Assert.assertEquals(1, count[0]); // Didn't count this time -// } finally { -// Probe.unregisterASTProber(prober); -// } -// -// } -// -// /** -// * Experimental feature; not yet validated. -// */ -// @Test -// public void specialOptInstrument() { -// final FrameDescriptor fd = new FrameDescriptor(); -// final AbstractTestNode result = new ConstantTestNode(42); -// final RootTestNode root = new RootTestNode(fd, "constantValue", result); -// final Probe[] probe = new Probe[1]; -// final int[] count = {1}; -// count[0] = 0; -// // Register a "prober" that will get applied when CallTarget gets created. -// final ASTProber prober = new ASTProber() { -// -// @Override -// public void probeAST(Node node) { -// node.accept(new NodeVisitor() { -// -// @Override -// public boolean visit(Node visitedNode) { -// if (visitedNode instanceof ConstantTestNode) { -// probe[0] = visitedNode.probe(); -// } -// return true; -// } -// }); -// } -// }; -// Probe.registerASTProber(prober); -// try { -// final RootCallTarget callTarget = Truffle.getRuntime().createCallTarget(root); -// -// // The CallTarget has one Probe, attached to the ConstantTestNode, ready to run -// Assert.assertEquals(42, callTarget.call()); // Correct result -// -// final boolean[] isCurrentlyCompiled = {false}; -// final Instrument optInstrument = Instrument.create(new Instrument.TruffleOptListener() { -// -// @Override -// public void notifyIsCompiled(boolean isCompiled) { -// isCurrentlyCompiled[0] = isCompiled; -// } -// }); -// probe[0].attach(optInstrument); -// -// Assert.assertEquals(42, callTarget.call()); // Correct result -// Assert.assertFalse(isCurrentlyCompiled[0]); -// -// // TODO (mlvdv) compile, call again, and assert that isCurrentlyCompiled == true -// -// } finally { -// Probe.unregisterASTProber(prober); -// } -// -// } + // @Test + // public void constantValueUninstrumented() { + // FrameDescriptor fd = new FrameDescriptor(); + // AbstractTestNode result = new ConstantTestNode(42); + // RootTestNode root = new RootTestNode(fd, "constantValue", result); + // root.adoptChildren(); + // assertPartialEvalEquals("constant42", root); + // } + // + // @Test + // public void constantValueProbedNoInstruments() { + // FrameDescriptor fd = new FrameDescriptor(); + // AbstractTestNode result = new ConstantTestNode(42); + // RootTestNode root = new RootTestNode(fd, "constantValue", result); + // root.adoptChildren(); + // result.probe(); + // assertPartialEvalEquals("constant42", root); + // } + // + // @Test + // public void constantValueProbedNullInstrument1() { + // FrameDescriptor fd = new FrameDescriptor(); + // AbstractTestNode result = new ConstantTestNode(42); + // RootTestNode root = new RootTestNode(fd, "constantValue", result); + // root.adoptChildren(); + // Probe probe = result.probe(); + // Instrument instrument = Instrument.create(new DefaultSimpleInstrumentListener(), + // "Null test Instrument"); + // probe.attach(instrument); + // assertPartialEvalEquals("constant42", root); + // } + // + // @Test + // public void constantValueProbedNullInstrument2() { + // FrameDescriptor fd = new FrameDescriptor(); + // AbstractTestNode result = new ConstantTestNode(42); + // RootTestNode root = new RootTestNode(fd, "constantValue", result); + // root.adoptChildren(); + // Probe probe = result.probe(); + // Instrument instrument = Instrument.create(new DefaultStandardInstrumentListener(), + // "Null test Instrument"); + // probe.attach(instrument); + // assertPartialEvalEquals("constant42", root); + // } + // + // @Test + // public void constantValueProbedNullInstrumentDisposed1() { + // FrameDescriptor fd = new FrameDescriptor(); + // AbstractTestNode result = new ConstantTestNode(42); + // RootTestNode root = new RootTestNode(fd, "constantValue", result); + // root.adoptChildren(); + // Probe probe = result.probe(); + // Instrument instrument = Instrument.create(new DefaultSimpleInstrumentListener(), + // "Null test Instrument"); + // probe.attach(instrument); + // instrument.dispose(); + // assertPartialEvalEquals("constant42", root); + // } + // + // @Test + // public void constantValueProbedNullInstrumentDisposed2() { + // FrameDescriptor fd = new FrameDescriptor(); + // AbstractTestNode result = new ConstantTestNode(42); + // RootTestNode root = new RootTestNode(fd, "constantValue", result); + // root.adoptChildren(); + // Probe probe = result.probe(); + // Instrument instrument = Instrument.create(new DefaultStandardInstrumentListener(), + // "Null test Instrument"); + // probe.attach(instrument); + // instrument.dispose(); + // assertPartialEvalEquals("constant42", root); + // } + // + // @Test + // public void constantValueProbedTwoNullInstruments1() { + // FrameDescriptor fd = new FrameDescriptor(); + // AbstractTestNode result = new ConstantTestNode(42); + // RootTestNode root = new RootTestNode(fd, "constantValue", result); + // root.adoptChildren(); + // Probe probe = result.probe(); + // Instrument instrument1 = Instrument.create(new DefaultSimpleInstrumentListener(), + // "Null test Instrument 1"); + // probe.attach(instrument1); + // Instrument instrument2 = Instrument.create(new DefaultSimpleInstrumentListener(), + // "Null test Instrument 2"); + // probe.attach(instrument2); + // assertPartialEvalEquals("constant42", root); + // } + // + // @Test + // public void constantValueProbedTwoNullInstruments2() { + // FrameDescriptor fd = new FrameDescriptor(); + // AbstractTestNode result = new ConstantTestNode(42); + // RootTestNode root = new RootTestNode(fd, "constantValue", result); + // root.adoptChildren(); + // Probe probe = result.probe(); + // Instrument instrument1 = Instrument.create(new DefaultStandardInstrumentListener(), + // "Null test Instrument 1"); + // probe.attach(instrument1); + // Instrument instrument2 = Instrument.create(new DefaultStandardInstrumentListener(), + // "Null test Instrument 2"); + // probe.attach(instrument2); + // assertPartialEvalEquals("constant42", root); + // } + // + // @Test + // public void constantValueProbedThreeNullInstruments1() { + // FrameDescriptor fd = new FrameDescriptor(); + // AbstractTestNode result = new ConstantTestNode(42); + // RootTestNode root = new RootTestNode(fd, "constantValue", result); + // root.adoptChildren(); + // Probe probe = result.probe(); + // Instrument instrument1 = Instrument.create(new DefaultSimpleInstrumentListener(), + // "Null test Instrument 1"); + // probe.attach(instrument1); + // Instrument instrument2 = Instrument.create(new DefaultSimpleInstrumentListener(), + // "Null test Instrument 2"); + // probe.attach(instrument2); + // Instrument instrument3 = Instrument.create(new DefaultSimpleInstrumentListener(), + // "Null test Instrument 3"); + // probe.attach(instrument3); + // assertPartialEvalEquals("constant42", root); + // } + // + // @Test + // public void constantValueProbedThreeNullInstruments2() { + // FrameDescriptor fd = new FrameDescriptor(); + // AbstractTestNode result = new ConstantTestNode(42); + // RootTestNode root = new RootTestNode(fd, "constantValue", result); + // root.adoptChildren(); + // Probe probe = result.probe(); + // Instrument instrument1 = Instrument.create(new DefaultStandardInstrumentListener(), + // "Null test Instrument 1"); + // probe.attach(instrument1); + // Instrument instrument2 = Instrument.create(new DefaultStandardInstrumentListener(), + // "Null test Instrument 2"); + // probe.attach(instrument2); + // Instrument instrument3 = Instrument.create(new DefaultStandardInstrumentListener(), + // "Null test Instrument 3"); + // probe.attach(instrument3); + // assertPartialEvalEquals("constant42", root); + // } + // + // @Test + // public void constantValueProbedThreeNullInstrumentsOneDisposed1() { + // FrameDescriptor fd = new FrameDescriptor(); + // AbstractTestNode result = new ConstantTestNode(42); + // RootTestNode root = new RootTestNode(fd, "constantValue", result); + // root.adoptChildren(); + // Probe probe = result.probe(); + // Instrument instrument1 = Instrument.create(new DefaultSimpleInstrumentListener(), + // "Null test Instrument 1"); + // probe.attach(instrument1); + // Instrument instrument2 = Instrument.create(new DefaultSimpleInstrumentListener(), + // "Null test Instrument 2"); + // probe.attach(instrument2); + // Instrument instrument3 = Instrument.create(new DefaultSimpleInstrumentListener(), + // "Null test Instrument 3"); + // probe.attach(instrument3); + // instrument2.dispose(); + // assertPartialEvalEquals("constant42", root); + // } + // + // @Test + // public void constantValueProbedThreeNullInstrumentsOneDisposed2() { + // FrameDescriptor fd = new FrameDescriptor(); + // AbstractTestNode result = new ConstantTestNode(42); + // RootTestNode root = new RootTestNode(fd, "constantValue", result); + // root.adoptChildren(); + // Probe probe = result.probe(); + // Instrument instrument1 = Instrument.create(new DefaultStandardInstrumentListener(), + // "Null test Instrument 1"); + // probe.attach(instrument1); + // Instrument instrument2 = Instrument.create(new DefaultStandardInstrumentListener(), + // "Null test Instrument 2"); + // probe.attach(instrument2); + // Instrument instrument3 = Instrument.create(new DefaultStandardInstrumentListener(), + // "Null test Instrument 3"); + // probe.attach(instrument3); + // instrument2.dispose(); + // assertPartialEvalEquals("constant42", root); + // } + // + // @Test + // public void constantValueInertAdvancedInstrumentRootFactory() { + // FrameDescriptor fd = new FrameDescriptor(); + // AbstractTestNode result = new ConstantTestNode(42); + // RootTestNode root = new RootTestNode(fd, "constantValue", result); + // root.adoptChildren(); + // Probe testProbe = result.probe(); + // // A factory that could insert a AdvancedInstrumentRoot into the AST, but which never does. + // Instrument instrument = Instrument.create(null, new AdvancedInstrumentRootFactory() { + // + // public AdvancedInstrumentRoot createInstrumentRoot(Probe probe, Node node) { + // return null; + // } + // }, null, "test AdvancedInstrument"); + // testProbe.attach(instrument); + // + // // It all gets compiled away + // assertPartialEvalEquals("constant42", root); + // } + // + // @Test + // public void constantValueInertAdvancedInstrumentRoot() { + // FrameDescriptor fd = new FrameDescriptor(); + // AbstractTestNode resultTestNode = new ConstantTestNode(42); + // RootTestNode rootTestNode = new RootTestNode(fd, "constantValue", resultTestNode); + // rootTestNode.adoptChildren(); + // Probe testProbe = resultTestNode.probe(); + // // Factory inserts a AdvancedInstrumentRoot with empty methods into instrumentation . + // Instrument instrument = Instrument.create(null, new AdvancedInstrumentRootFactory() { + // + // @Override + // public AdvancedInstrumentRoot createInstrumentRoot(Probe probe, Node node) { + // return new AdvancedInstrumentRoot() { + // + // public String instrumentationInfo() { + // return null; + // } + // + // @Override + // public Object executeRoot(Node n, VirtualFrame frame) { + // return null; + // } + // }; + // } + // }, null, "test AdvancedInstrument"); + // testProbe.attach(instrument); + // + // // It all gets compiled away. + // assertPartialEvalEquals("constant42", rootTestNode); + // } + // + // @Test + // public void instrumentDeopt() { + // final FrameDescriptor fd = new FrameDescriptor(); + // final AbstractTestNode result = new ConstantTestNode(42); + // final RootTestNode root = new RootTestNode(fd, "constantValue", result); + // final Probe[] probe = new Probe[1]; + // final int[] count = {1}; + // count[0] = 0; + // // Register a "prober" that will get applied when CallTarget gets created. + // final ASTProber prober = new ASTProber() { + // + // @Override + // public void probeAST(Node node) { + // node.accept(new NodeVisitor() { + // + // @Override + // public boolean visit(Node visitedNode) { + // if (visitedNode instanceof ConstantTestNode) { + // probe[0] = visitedNode.probe(); + // } + // return true; + // } + // + // }); + // } + // }; + // Probe.registerASTProber(prober); + // try { + // final RootCallTarget callTarget = Truffle.getRuntime().createCallTarget(root); + // + // // The CallTarget has one Probe, attached to the ConstantTestNode, ready to run + // Assert.assertEquals(42, callTarget.call()); // Correct result + // Assert.assertEquals(0, count[0]); // Didn't count anything + // + // // Add a counting instrument; this changes the "Probe state" and should cause a deopt + // final Instrument countingInstrument = Instrument.create(new DefaultSimpleInstrumentListener() + // { + // + // @Override + // public void enter(Probe p) { + // count[0] = count[0] + 1; + // } + // }, null); + // probe[0].attach(countingInstrument); + // + // Assert.assertEquals(42, callTarget.call()); // Correct result + // Assert.assertEquals(1, count[0]); // Counted the first call + // + // // Remove the counting instrument; this changes the "Probe state" and should cause a + // // deopt + // countingInstrument.dispose(); + // + // Assert.assertEquals(42, callTarget.call()); // Correct result + // Assert.assertEquals(1, count[0]); // Didn't count this time + // } finally { + // Probe.unregisterASTProber(prober); + // } + // + // } + // + // /** + // * Experimental feature; not yet validated. + // */ + // @Test + // public void specialOptInstrument() { + // final FrameDescriptor fd = new FrameDescriptor(); + // final AbstractTestNode result = new ConstantTestNode(42); + // final RootTestNode root = new RootTestNode(fd, "constantValue", result); + // final Probe[] probe = new Probe[1]; + // final int[] count = {1}; + // count[0] = 0; + // // Register a "prober" that will get applied when CallTarget gets created. + // final ASTProber prober = new ASTProber() { + // + // @Override + // public void probeAST(Node node) { + // node.accept(new NodeVisitor() { + // + // @Override + // public boolean visit(Node visitedNode) { + // if (visitedNode instanceof ConstantTestNode) { + // probe[0] = visitedNode.probe(); + // } + // return true; + // } + // }); + // } + // }; + // Probe.registerASTProber(prober); + // try { + // final RootCallTarget callTarget = Truffle.getRuntime().createCallTarget(root); + // + // // The CallTarget has one Probe, attached to the ConstantTestNode, ready to run + // Assert.assertEquals(42, callTarget.call()); // Correct result + // + // final boolean[] isCurrentlyCompiled = {false}; + // final Instrument optInstrument = Instrument.create(new Instrument.TruffleOptListener() { + // + // @Override + // public void notifyIsCompiled(boolean isCompiled) { + // isCurrentlyCompiled[0] = isCompiled; + // } + // }); + // probe[0].attach(optInstrument); + // + // Assert.assertEquals(42, callTarget.call()); // Correct result + // Assert.assertFalse(isCurrentlyCompiled[0]); + // + // // TODO (mlvdv) compile, call again, and assert that isCurrentlyCompiled == true + // + // } finally { + // Probe.unregisterASTProber(prober); + // } + // + // } }