# HG changeset patch # User Michael Van De Vanter # Date 1442789499 25200 # Node ID c896a8e7077749f7c8e5c7f040895ef1b331932b # Parent a0fa69e3e60e39fbb94058cd435688a77bbeea70 Truffle/Instrumentation: Redesign instrumentation node classes to reduce the public API exposure. - ProbeNode is no longer public - Public interface InstrumentationNode.TruffleEvents is now abstract class EventHandlerNode with package private constructor - Interface ProbeNode.WrapperNode is no longer inside ProbeNode and has been expanded slightly so ProbeNode can be package private diff -r a0fa69e3e60e -r c896a8e70777 truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TestingLanguage.java --- a/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TestingLanguage.java Sat Sep 19 16:29:32 2015 -0700 +++ b/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TestingLanguage.java Sun Sep 20 15:51:39 2015 -0700 @@ -31,7 +31,7 @@ import com.oracle.truffle.api.instrument.ASTProber; import com.oracle.truffle.api.instrument.AdvancedInstrumentResultListener; import com.oracle.truffle.api.instrument.AdvancedInstrumentRootFactory; -import com.oracle.truffle.api.instrument.ProbeNode.WrapperNode; +import com.oracle.truffle.api.instrument.WrapperNode; import com.oracle.truffle.api.instrument.ToolSupportProvider; import com.oracle.truffle.api.instrument.Visualizer; import com.oracle.truffle.api.nodes.Node; diff -r a0fa69e3e60e -r c896a8e70777 truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/processor/LanguageRegistrationTest.java --- a/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/processor/LanguageRegistrationTest.java Sat Sep 19 16:29:32 2015 -0700 +++ b/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/processor/LanguageRegistrationTest.java Sun Sep 20 15:51:39 2015 -0700 @@ -32,7 +32,7 @@ import com.oracle.truffle.api.instrument.ASTProber; import com.oracle.truffle.api.instrument.AdvancedInstrumentResultListener; import com.oracle.truffle.api.instrument.AdvancedInstrumentRootFactory; -import com.oracle.truffle.api.instrument.ProbeNode.WrapperNode; +import com.oracle.truffle.api.instrument.WrapperNode; import com.oracle.truffle.api.instrument.ToolSupportProvider; import com.oracle.truffle.api.instrument.Visualizer; import com.oracle.truffle.api.nodes.Node; diff -r a0fa69e3e60e -r c896a8e70777 truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/TestingLanguage.java --- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/TestingLanguage.java Sat Sep 19 16:29:32 2015 -0700 +++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/TestingLanguage.java Sun Sep 20 15:51:39 2015 -0700 @@ -31,7 +31,7 @@ import com.oracle.truffle.api.instrument.ASTProber; import com.oracle.truffle.api.instrument.AdvancedInstrumentResultListener; import com.oracle.truffle.api.instrument.AdvancedInstrumentRootFactory; -import com.oracle.truffle.api.instrument.ProbeNode.WrapperNode; +import com.oracle.truffle.api.instrument.WrapperNode; import com.oracle.truffle.api.instrument.ToolSupportProvider; import com.oracle.truffle.api.instrument.Visualizer; import com.oracle.truffle.api.nodes.Node; diff -r a0fa69e3e60e -r c896a8e70777 truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/instrument/InstrumentationTest.java --- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/instrument/InstrumentationTest.java Sat Sep 19 16:29:32 2015 -0700 +++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/instrument/InstrumentationTest.java Sun Sep 20 15:51:39 2015 -0700 @@ -37,8 +37,7 @@ import com.oracle.truffle.api.instrument.Instrumenter; import com.oracle.truffle.api.instrument.Probe; import com.oracle.truffle.api.instrument.ProbeListener; -import com.oracle.truffle.api.instrument.ProbeNode; -import com.oracle.truffle.api.instrument.ProbeNode.WrapperNode; +import com.oracle.truffle.api.instrument.WrapperNode; import com.oracle.truffle.api.instrument.SimpleInstrumentListener; import com.oracle.truffle.api.instrument.StandardInstrumentListener; import com.oracle.truffle.api.instrument.SyntaxTag; @@ -60,17 +59,6 @@ * Instrumentation allows the insertion into Truffle ASTs language-specific instances of * {@link WrapperNode} that propagate execution events through a {@link Probe} to any instances of * {@link Instrument} that might be attached to the particular probe by tools. - *
    - *
  1. Creates a simple add AST
  2. - *
  3. Verifies its structure
  4. - *
  5. "Probes" the add node by adding a {@link WrapperNode} and associated {@link Probe}
  6. - *
  7. Attaches a simple {@link Instrument} to the node via the Probe's {@link ProbeNode}
  8. - *
  9. Verifies the structure of the probed AST
  10. - *
  11. Verifies the execution of the probed AST
  12. - *
  13. Verifies the results observed by the instrument.
  14. - *
- * To do these tests, several required classes have been implemented in their most basic form, only - * implementing the methods necessary for the tests to pass, with stubs elsewhere. */ public class InstrumentationTest { diff -r a0fa69e3e60e -r c896a8e70777 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 Sat Sep 19 16:29:32 2015 -0700 +++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/instrument/InstrumentationTestNodes.java Sun Sep 20 15:51:39 2015 -0700 @@ -29,11 +29,11 @@ import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.instrument.AdvancedInstrumentRoot; +import com.oracle.truffle.api.instrument.EventHandlerNode; import com.oracle.truffle.api.instrument.Instrumenter; import com.oracle.truffle.api.instrument.KillException; import com.oracle.truffle.api.instrument.Probe; -import com.oracle.truffle.api.instrument.ProbeNode; -import com.oracle.truffle.api.instrument.ProbeNode.WrapperNode; +import com.oracle.truffle.api.instrument.WrapperNode; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeCost; import com.oracle.truffle.api.nodes.NodeInfo; @@ -72,7 +72,7 @@ @NodeInfo(cost = NodeCost.NONE) static class TestLanguageWrapperNode extends TestLanguageNode implements WrapperNode { @Child private TestLanguageNode child; - @Child private ProbeNode probeNode; + @Child private EventHandlerNode eventHandlerNode; public TestLanguageWrapperNode(TestLanguageNode child) { assert !(child instanceof TestLanguageWrapperNode); @@ -90,13 +90,13 @@ } @Override - public void insertProbe(ProbeNode newProbeNode) { - this.probeNode = newProbeNode; + public void insertEventHandlerNode(EventHandlerNode eventHandler) { + this.eventHandlerNode = eventHandler; } @Override public Probe getProbe() { - return probeNode.getProbe(); + return eventHandlerNode.getProbe(); } @Override @@ -106,15 +106,15 @@ @Override public Object execute(VirtualFrame vFrame) { - probeNode.enter(child, vFrame); + eventHandlerNode.enter(child, vFrame); Object result; try { result = child.execute(vFrame); - probeNode.returnValue(child, vFrame, result); + eventHandlerNode.returnValue(child, vFrame, result); } catch (KillException e) { throw (e); } catch (Exception e) { - probeNode.returnExceptional(child, vFrame, e); + eventHandlerNode.returnExceptional(child, vFrame, e); throw (e); } return result; diff -r a0fa69e3e60e -r c896a8e70777 truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/instrument/InstrumentationTestingLanguage.java --- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/instrument/InstrumentationTestingLanguage.java Sat Sep 19 16:29:32 2015 -0700 +++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/instrument/InstrumentationTestingLanguage.java Sun Sep 20 15:51:39 2015 -0700 @@ -34,7 +34,7 @@ import com.oracle.truffle.api.instrument.AdvancedInstrumentResultListener; import com.oracle.truffle.api.instrument.AdvancedInstrumentRootFactory; import com.oracle.truffle.api.instrument.Instrumenter; -import com.oracle.truffle.api.instrument.ProbeNode.WrapperNode; +import com.oracle.truffle.api.instrument.WrapperNode; import com.oracle.truffle.api.instrument.SyntaxTag; import com.oracle.truffle.api.instrument.ToolSupportProvider; import com.oracle.truffle.api.instrument.Visualizer; diff -r a0fa69e3e60e -r c896a8e70777 truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/vm/ImplicitExplicitExportTest.java --- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/vm/ImplicitExplicitExportTest.java Sat Sep 19 16:29:32 2015 -0700 +++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/vm/ImplicitExplicitExportTest.java Sun Sep 20 15:51:39 2015 -0700 @@ -47,7 +47,7 @@ import com.oracle.truffle.api.instrument.ASTProber; import com.oracle.truffle.api.instrument.AdvancedInstrumentResultListener; import com.oracle.truffle.api.instrument.AdvancedInstrumentRootFactory; -import com.oracle.truffle.api.instrument.ProbeNode.WrapperNode; +import com.oracle.truffle.api.instrument.WrapperNode; import com.oracle.truffle.api.instrument.ToolSupportProvider; import com.oracle.truffle.api.instrument.Visualizer; import com.oracle.truffle.api.nodes.Node; diff -r a0fa69e3e60e -r c896a8e70777 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 Sat Sep 19 16:29:32 2015 -0700 +++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/vm/InitializationTest.java Sun Sep 20 15:51:39 2015 -0700 @@ -44,13 +44,13 @@ import com.oracle.truffle.api.instrument.ASTProber; import com.oracle.truffle.api.instrument.AdvancedInstrumentResultListener; import com.oracle.truffle.api.instrument.AdvancedInstrumentRootFactory; +import com.oracle.truffle.api.instrument.EventHandlerNode; import com.oracle.truffle.api.instrument.Instrumenter; import com.oracle.truffle.api.instrument.Probe; -import com.oracle.truffle.api.instrument.ProbeNode; -import com.oracle.truffle.api.instrument.ProbeNode.WrapperNode; import com.oracle.truffle.api.instrument.StandardSyntaxTag; import com.oracle.truffle.api.instrument.ToolSupportProvider; import com.oracle.truffle.api.instrument.Visualizer; +import com.oracle.truffle.api.instrument.WrapperNode; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeVisitor; import com.oracle.truffle.api.nodes.RootNode; @@ -140,7 +140,7 @@ @SuppressWarnings("deprecation") @Override - public ProbeNode.WrapperNode createWrapperNode() { + public WrapperNode createWrapperNode() { throw new UnsupportedOperationException(); } @@ -150,9 +150,9 @@ } - private static class ANodeWrapper extends ANode implements ProbeNode.WrapperNode { + private static class ANodeWrapper extends ANode implements WrapperNode { @Child ANode child; - private ProbeNode probeNode; + @Child private EventHandlerNode eventHandlerNode; ANodeWrapper(ANode node) { super(1); // dummy @@ -166,12 +166,12 @@ @Override public Probe getProbe() { - return probeNode.getProbe(); + return eventHandlerNode.getProbe(); } @Override - public void insertProbe(ProbeNode pn) { - this.probeNode = pn; + public void insertEventHandlerNode(EventHandlerNode eventHandler) { + this.eventHandlerNode = eventHandler; } @Override diff -r a0fa69e3e60e -r c896a8e70777 truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleLanguage.java --- a/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleLanguage.java Sat Sep 19 16:29:32 2015 -0700 +++ b/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleLanguage.java Sun Sep 20 15:51:39 2015 -0700 @@ -45,9 +45,9 @@ import com.oracle.truffle.api.instrument.AdvancedInstrumentRootFactory; import com.oracle.truffle.api.instrument.Instrument; import com.oracle.truffle.api.instrument.Instrumenter; -import com.oracle.truffle.api.instrument.ProbeNode.WrapperNode; import com.oracle.truffle.api.instrument.ToolSupportProvider; import com.oracle.truffle.api.instrument.Visualizer; +import com.oracle.truffle.api.instrument.WrapperNode; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.source.Source; diff -r a0fa69e3e60e -r c896a8e70777 truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/Accessor.java --- a/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/Accessor.java Sat Sep 19 16:29:32 2015 -0700 +++ b/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/Accessor.java Sun Sep 20 15:51:39 2015 -0700 @@ -44,7 +44,7 @@ import com.oracle.truffle.api.instrument.AdvancedInstrumentRootFactory; import com.oracle.truffle.api.instrument.Instrumenter; import com.oracle.truffle.api.instrument.Probe; -import com.oracle.truffle.api.instrument.ProbeNode.WrapperNode; +import com.oracle.truffle.api.instrument.WrapperNode; import com.oracle.truffle.api.instrument.ToolSupportProvider; import com.oracle.truffle.api.instrument.Visualizer; import com.oracle.truffle.api.nodes.Node; diff -r a0fa69e3e60e -r c896a8e70777 truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/EventHandlerNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/EventHandlerNode.java Sun Sep 20 15:51:39 2015 -0700 @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.truffle.api.instrument; + +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.Node; + +/** + * An Instrumentation-managed {@link Node} that synchronously propagates notification of AST + * Execution Events through the Instrumentation Framework. + */ +public abstract class EventHandlerNode extends Node implements InstrumentationNode { + + protected EventHandlerNode() { + } + + /** + * An AST node's execute method is about to be called. + */ + public abstract void enter(Node node, VirtualFrame vFrame); + + /** + * An AST Node's {@code void}-valued execute method has just returned. + */ + public abstract void returnVoid(Node node, VirtualFrame vFrame); + + /** + * An AST Node's execute method has just returned a value (boxed if primitive). + */ + public abstract void returnValue(Node node, VirtualFrame vFrame, Object result); + + /** + * An AST Node's execute method has just thrown an exception. + */ + public abstract void returnExceptional(Node node, VirtualFrame vFrame, Exception exception); + + /** + * Gets the {@link Probe} that manages this chain of event handling. + */ + public abstract Probe getProbe(); + +} diff -r a0fa69e3e60e -r c896a8e70777 truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Instrument.java --- a/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Instrument.java Sat Sep 19 16:29:32 2015 -0700 +++ b/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Instrument.java Sun Sep 20 15:51:39 2015 -0700 @@ -27,7 +27,6 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.instrument.InstrumentationNode.TruffleEvents; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeCost; import com.oracle.truffle.api.nodes.NodeInfo; @@ -46,7 +45,7 @@ * wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events * * @see Probe - * @see TruffleEvents + * @see EventHandlerNode */ public abstract class Instrument { @@ -253,6 +252,7 @@ super(nextNode); } + @Override public void enter(Node node, VirtualFrame vFrame) { SimpleInstrument.this.simpleListener.enter(SimpleInstrument.this.probe); if (nextInstrumentNode != null) { @@ -260,6 +260,7 @@ } } + @Override public void returnVoid(Node node, VirtualFrame vFrame) { SimpleInstrument.this.simpleListener.returnVoid(SimpleInstrument.this.probe); if (nextInstrumentNode != null) { @@ -267,6 +268,7 @@ } } + @Override public void returnValue(Node node, VirtualFrame vFrame, Object result) { SimpleInstrument.this.simpleListener.returnValue(SimpleInstrument.this.probe, result); if (nextInstrumentNode != null) { @@ -274,6 +276,7 @@ } } + @Override public void returnExceptional(Node node, VirtualFrame vFrame, Exception exception) { SimpleInstrument.this.simpleListener.returnExceptional(SimpleInstrument.this.probe, exception); if (nextInstrumentNode != null) { @@ -281,6 +284,7 @@ } } + @Override public String instrumentationInfo() { final String info = getInstrumentInfo(); return info != null ? info : simpleListener.getClass().getSimpleName(); @@ -335,6 +339,7 @@ super(nextNode); } + @Override public void enter(Node node, VirtualFrame vFrame) { standardListener.enter(StandardInstrument.this.probe, node, vFrame); if (nextInstrumentNode != null) { @@ -342,6 +347,7 @@ } } + @Override public void returnVoid(Node node, VirtualFrame vFrame) { standardListener.returnVoid(StandardInstrument.this.probe, node, vFrame); if (nextInstrumentNode != null) { @@ -349,6 +355,7 @@ } } + @Override public void returnValue(Node node, VirtualFrame vFrame, Object result) { standardListener.returnValue(StandardInstrument.this.probe, node, vFrame, result); if (nextInstrumentNode != null) { @@ -356,6 +363,7 @@ } } + @Override public void returnExceptional(Node node, VirtualFrame vFrame, Exception exception) { standardListener.returnExceptional(StandardInstrument.this.probe, node, vFrame, exception); if (nextInstrumentNode != null) { @@ -363,6 +371,7 @@ } } + @Override public String instrumentationInfo() { final String info = getInstrumentInfo(); return info != null ? info : standardListener.getClass().getSimpleName(); @@ -422,6 +431,7 @@ super(nextNode); } + @Override public void enter(Node node, VirtualFrame vFrame) { if (instrumentRoot == null) { try { @@ -477,24 +487,28 @@ return new RuntimeException("Instrument result " + result.toString() + " not assignable to " + requiredResultType.getSimpleName()); } + @Override public void returnVoid(Node node, VirtualFrame vFrame) { if (nextInstrumentNode != null) { nextInstrumentNode.returnVoid(node, vFrame); } } + @Override public void returnValue(Node node, VirtualFrame vFrame, Object result) { if (nextInstrumentNode != null) { nextInstrumentNode.returnValue(node, vFrame, result); } } + @Override public void returnExceptional(Node node, VirtualFrame vFrame, Exception exception) { if (nextInstrumentNode != null) { nextInstrumentNode.returnExceptional(node, vFrame, exception); } } + @Override public String instrumentationInfo() { final String info = getInstrumentInfo(); return info != null ? info : rootFactory.getClass().getSimpleName(); @@ -549,6 +563,7 @@ this.isCompiled = CompilerDirectives.inCompiledCode(); } + @Override public void enter(Node node, VirtualFrame vFrame) { if (this.isCompiled != CompilerDirectives.inCompiledCode()) { this.isCompiled = CompilerDirectives.inCompiledCode(); @@ -559,24 +574,28 @@ } } + @Override public void returnVoid(Node node, VirtualFrame vFrame) { if (nextInstrumentNode != null) { nextInstrumentNode.returnVoid(node, vFrame); } } + @Override public void returnValue(Node node, VirtualFrame vFrame, Object result) { if (nextInstrumentNode != null) { nextInstrumentNode.returnValue(node, vFrame, result); } } + @Override public void returnExceptional(Node node, VirtualFrame vFrame, Exception exception) { if (nextInstrumentNode != null) { nextInstrumentNode.returnExceptional(node, vFrame, exception); } } + @Override public String instrumentationInfo() { final String info = getInstrumentInfo(); return info != null ? info : toolOptListener.getClass().getSimpleName(); @@ -585,7 +604,7 @@ } @NodeInfo(cost = NodeCost.NONE) - abstract class AbstractInstrumentNode extends Node implements TruffleEvents, InstrumentationNode { + abstract class AbstractInstrumentNode extends EventHandlerNode { @Child protected AbstractInstrumentNode nextInstrumentNode; @@ -599,6 +618,11 @@ return false; } + @Override + public Probe getProbe() { + return probe; + } + /** * Gets the instrument that created this node. */ diff -r a0fa69e3e60e -r c896a8e70777 truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/InstrumentationNode.java --- a/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/InstrumentationNode.java Sat Sep 19 16:29:32 2015 -0700 +++ b/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/InstrumentationNode.java Sun Sep 20 15:51:39 2015 -0700 @@ -24,7 +24,6 @@ */ package com.oracle.truffle.api.instrument; -import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; /** @@ -39,30 +38,4 @@ */ String instrumentationInfo(); - /** - * Events that propagate through the {@linkplain InstrumentationNode implementation nodes} of - * the Instrumentation Framework, not visible in this form to Instrumentation clients. - */ - interface TruffleEvents { - - /** - * An AST node's execute method is about to be called. - */ - void enter(Node node, VirtualFrame vFrame); - - /** - * An AST Node's {@code void}-valued execute method has just returned. - */ - void returnVoid(Node node, VirtualFrame vFrame); - - /** - * An AST Node's execute method has just returned a value (boxed if primitive). - */ - void returnValue(Node node, VirtualFrame vFrame, Object result); - - /** - * An AST Node's execute method has just thrown an exception. - */ - void returnExceptional(Node node, VirtualFrame vFrame, Exception exception); - } } diff -r a0fa69e3e60e -r c896a8e70777 truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Instrumenter.java --- a/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Instrumenter.java Sat Sep 19 16:29:32 2015 -0700 +++ b/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Instrumenter.java Sun Sep 20 15:51:39 2015 -0700 @@ -36,8 +36,6 @@ import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.TruffleLanguage; import com.oracle.truffle.api.impl.Accessor; -import com.oracle.truffle.api.instrument.InstrumentationNode.TruffleEvents; -import com.oracle.truffle.api.instrument.ProbeNode.WrapperNode; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeVisitor; import com.oracle.truffle.api.nodes.RootNode; @@ -201,7 +199,7 @@ final Probe probe = new Probe(this, l, probeNode, sourceSection); probes.add(new WeakReference<>(probe)); probeNode.probe = probe; // package private access - wrapper.insertProbe(probeNode); + wrapper.insertEventHandlerNode(probeNode); node.replace(wrapperNode); if (TRACE) { final String location = sourceSection == null ? "" : sourceSection.getShortDescription(); @@ -314,8 +312,8 @@ * Attaches a {@link SimpleInstrumentListener listener} to a {@link Probe}, creating a * binding called an {@link Instrument}. Until the Instrument is * {@linkplain Instrument#dispose() disposed}, it routes notification of - * {@linkplain TruffleEvents execution events} taking place at the Probe's AST location to the - * listener. + * {@linkplain EventHandlerNode execution events} taking place at the Probe's AST location to + * the listener. * * @param probe source of execution events * @param listener receiver of execution events @@ -333,8 +331,8 @@ * Attaches a {@link StandardInstrumentListener listener} to a {@link Probe}, creating * a binding called an {@link Instrument}. Until the Instrument is * {@linkplain Instrument#dispose() disposed}, it routes notification of - * {@linkplain TruffleEvents execution events} taking place at the Probe's AST location to the - * listener. + * {@linkplain EventHandlerNode execution events} taking place at the Probe's AST location to + * the listener. * * @param probe source of execution events * @param listener receiver of execution events @@ -352,8 +350,8 @@ * Attaches a {@link AdvancedInstrumentResultListener listener} to a {@link Probe}, * creating a binding called an {@link Instrument}. Until the Instrument is * {@linkplain Instrument#dispose() disposed}, it routes notification of - * {@linkplain TruffleEvents execution events} taking place at the Probe's AST location to the - * listener. + * {@linkplain EventHandlerNode execution events} taking place at the Probe's AST location to + * the listener. *

* This Instrument executes efficiently, subject to full Truffle optimization, a client-provided * AST fragment every time the Probed node is entered. diff -r a0fa69e3e60e -r c896a8e70777 truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Probe.java --- a/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Probe.java Sat Sep 19 16:29:32 2015 -0700 +++ b/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Probe.java Sun Sep 20 15:51:39 2015 -0700 @@ -34,7 +34,6 @@ import com.oracle.truffle.api.Assumption; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.TruffleLanguage; -import com.oracle.truffle.api.instrument.InstrumentationNode.TruffleEvents; import com.oracle.truffle.api.nodes.InvalidAssumptionException; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.source.SourceSection; @@ -115,7 +114,7 @@ * multiple Nodes in multiple ASTs. * * - *

  • The effect of the binding is to intercept {@linkplain TruffleEvents execution events} + *
  • The effect of the binding is to intercept {@linkplain EventHandlerNode execution events} * arriving at the "probed" AST Node and notify each attached {@link Instrument} before * execution is allowed to proceed to the child and again after execution completes.
  • * diff -r a0fa69e3e60e -r c896a8e70777 truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/ProbeFailure.java --- a/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/ProbeFailure.java Sat Sep 19 16:29:32 2015 -0700 +++ b/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/ProbeFailure.java Sun Sep 20 15:51:39 2015 -0700 @@ -24,7 +24,6 @@ */ package com.oracle.truffle.api.instrument; -import com.oracle.truffle.api.instrument.ProbeNode.WrapperNode; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeFieldAccessor; import com.oracle.truffle.api.nodes.NodeUtil; diff -r a0fa69e3e60e -r c896a8e70777 truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/ProbeNode.java --- a/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/ProbeNode.java Sat Sep 19 16:29:32 2015 -0700 +++ b/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/ProbeNode.java Sun Sep 20 15:51:39 2015 -0700 @@ -28,7 +28,6 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.instrument.Instrument.AbstractInstrumentNode; -import com.oracle.truffle.api.instrument.InstrumentationNode.TruffleEvents; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeCost; import com.oracle.truffle.api.nodes.NodeInfo; @@ -48,72 +47,7 @@ * clones consistent. */ @NodeInfo(cost = NodeCost.NONE) -public final class ProbeNode extends Node implements TruffleEvents, InstrumentationNode { - - /** - * A node that can be inserted into a Truffle AST, and which enables {@linkplain Instrument - * instrumentation} at a particular Guest Language (GL) node. Implementations must extend - * {@link Node} and should ensure that {@link TruffleLanguage#isInstrumentable(Node)} returns - * {@code false}. - *

    - * The implementation must be GL-specific. A wrapper decorates a GL AST node (the - * wrapper's child) by acting as a transparent proxy with respect to the GL's - * execution semantics. - *

    - * Instrumentation at the wrapped node is implemented by an instance of {@link ProbeNode} - * attached as a second child of the {@link WrapperNode}. - *

    - * A wrapper is obliged to notify its attached {@link ProbeNode} when execution events occur at - * the wrapped AST node during program execution. - *

    - * When a GL AST is cloned, the {@link WrapperNode}, its {@link ProbeNode} and any - * {@linkplain Instrument instrumentation} are also cloned; they are in effect part of the GL - * AST. An instance of {@link Probe} represents abstractly the instrumentation at a particular - * location in a GL AST; it tracks all the copies of the Wrapper and attached instrumentation, - * and acts as a single point of access for tools. - *

    - * This interface is not intended to be visible as part of the API for tools (instrumentation - * clients). - *

    - * Implementation guidelines: - *

      - *
    1. Each GL implementation should include a WrapperNode implementation; usually only one is - * needed.
    2. - *
    3. The wrapper type should descend from the GL-specific node class.
    4. - *
    5. Must have a field: {@code @Child private Node child;}
    6. - *
    7. Must have a field: {@code @Child private ProbeNode probeNode;}
    8. - *
    9. The wrapper must act as a proxy for its child, which means implementing every - * possible execute- method that gets called on guest language AST node types by their - * parents, and passing along each call to its child.
    10. - *
    11. Method {@code Probe getProbe()} should be implemented as {@code probeNode.getProbe();} - *
    12. Method {@code insertProbe(ProbeNode)} should be implemented as - * {@code this.probeNode=insert(newProbeNode);}
    13. - *
    14. Most importantly, Wrappers must be implemented so that Truffle optimization will reduce - * their runtime overhead to zero when there are no attached {@link Instrument}s.
    15. - *
    - *

    - * - * @see Instrument - */ - public interface WrapperNode extends InstrumentationNode { - - /** - * Gets the node being "wrapped", i.e. the AST node for which - * {@linkplain InstrumentationNode.TruffleEvents execution events} will be reported through - * the Instrumentation Framework. - */ - Node getChild(); - - /** - * Gets the {@link Probe} responsible for installing this wrapper. - */ - Probe getProbe(); - - /** - * Implementation support for completing a newly created wrapper node. - */ - void insertProbe(ProbeNode probeNode); - } +final class ProbeNode extends EventHandlerNode { // Never changed once set. @CompilationFinal Probe probe = null; @@ -138,10 +72,12 @@ /** * @return the {@link Probe} permanently associated with this {@link ProbeNode}. */ + @Override public Probe getProbe() { return probe; } + @Override public void enter(Node node, VirtualFrame vFrame) { this.probe.checkProbeUnchanged(); final SyntaxTagTrap beforeTagTrap = probe.getBeforeTrap(); @@ -153,6 +89,7 @@ } } + @Override public void returnVoid(Node node, VirtualFrame vFrame) { this.probe.checkProbeUnchanged(); if (firstInstrumentNode != null) { @@ -164,6 +101,7 @@ } } + @Override public void returnValue(Node node, VirtualFrame vFrame, Object result) { this.probe.checkProbeUnchanged(); if (firstInstrumentNode != null) { @@ -175,6 +113,7 @@ } } + @Override public void returnExceptional(Node node, VirtualFrame vFrame, Exception exception) { this.probe.checkProbeUnchanged(); if (firstInstrumentNode != null) { @@ -186,6 +125,7 @@ } } + @Override public String instrumentationInfo() { return "Standard probe"; } diff -r a0fa69e3e60e -r c896a8e70777 truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/WrapperNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/WrapperNode.java Sun Sep 20 15:51:39 2015 -0700 @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2013, 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.instrument; + +import com.oracle.truffle.api.TruffleLanguage; +import com.oracle.truffle.api.nodes.Node; + +/** + * A {@link Node} instance that must be inserted into a Truffle AST in order to enable + * {@linkplain Instrument instrumentation} at a particular Guest Language (GL) node. Implementations + * must ensure that {@link TruffleLanguage#isInstrumentable(Node)} returns {@code false}. + *

    + * The implementation must be GL-specific. A wrapper decorates a GL AST node (the wrapper's + * child) by acting as a transparent proxy with respect to the GL's execution + * semantics. + *

    + * Instrumentation at the wrapped node is implemented by an instance of {@link EventHandlerNode} + * attached as a second child of the {@link WrapperNode}. + *

    + * A wrapper is obliged to notify its attached {@link EventHandlerNode} when execution events occur + * at the wrapped AST node during program execution. + *

    + * When a GL AST is cloned, the {@link WrapperNode}, its {@link EventHandlerNode} and any + * {@linkplain Instrument instrumentation} are also cloned; they are in effect part of the GL AST. + * An instance of {@link Probe} represents abstractly the instrumentation at a particular location + * in a GL AST; it tracks all the copies of the Wrapper and attached instrumentation, and acts as a + * single point of access for tools. + *

    + * Implementation guidelines: + *

      + *
    1. Each GL implementation must implement a WrapperNode implementation for each AST context in + * which Instrumentation is to be supported.
    2. + *
    3. The wrapper type should descend from the GL-specific node class.
    4. + *
    5. Must have a field: {@code @Child private Node child;}
    6. + *
    7. Must have a field: {@code @Child private EventHandlerNode eventHandlerNode;}
    8. + *
    9. The wrapper must act as a proxy for its child, which means implementing every + * possible execute- method that gets called on guest language AST node types by their + * parents, and passing along each call to its child.
    10. + *
    11. Method {@code Probe getProbe()} should be implemented as {@code eventHandlerNode.getProbe();} + *
    12. Method {@code insertProbe(EventHandlerNode)} should be implemented as + * {@code this.eventHandlerNode=insert(eventHandlerNode);}
    13. + *
    14. Most importantly, Wrappers must be implemented so that Truffle optimization will reduce their + * runtime overhead to zero when there are no attached {@link Instrument}s.
    15. + *
    + *

    + * + * @see Instrument + */ +public interface WrapperNode extends InstrumentationNode { + + /** + * Gets the node being "wrapped", i.e. the AST node for which + * {@linkplain InstrumentationNode.EventHandlerNode execution events} will be reported through + * the Instrumentation Framework. + */ + Node getChild(); + + /** + * Gets the {@link Probe} responsible for installing this wrapper. + */ + Probe getProbe(); + + /** + * Implementation support for completing a newly created wrapper node. + */ + void insertEventHandlerNode(EventHandlerNode eventHandlerNode); +} diff -r a0fa69e3e60e -r c896a8e70777 truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/DefaultASTPrinter.java --- a/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/DefaultASTPrinter.java Sat Sep 19 16:29:32 2015 -0700 +++ b/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/DefaultASTPrinter.java Sun Sep 20 15:51:39 2015 -0700 @@ -26,7 +26,7 @@ import com.oracle.truffle.api.instrument.ASTPrinter; import com.oracle.truffle.api.instrument.InstrumentationNode; -import com.oracle.truffle.api.instrument.ProbeNode.WrapperNode; +import com.oracle.truffle.api.instrument.WrapperNode; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeClass; import com.oracle.truffle.api.nodes.NodeFieldAccessor; diff -r a0fa69e3e60e -r c896a8e70777 truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java --- a/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java Sat Sep 19 16:29:32 2015 -0700 +++ b/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java Sun Sep 20 15:51:39 2015 -0700 @@ -41,7 +41,7 @@ import com.oracle.truffle.api.TruffleLanguage; import com.oracle.truffle.api.TruffleOptions; import com.oracle.truffle.api.impl.Accessor; -import com.oracle.truffle.api.instrument.ProbeNode.WrapperNode; +import com.oracle.truffle.api.instrument.WrapperNode; import com.oracle.truffle.api.source.SourceSection; import com.oracle.truffle.api.utilities.JSONHelper; diff -r a0fa69e3e60e -r c896a8e70777 truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java --- a/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java Sat Sep 19 16:29:32 2015 -0700 +++ b/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java Sun Sep 20 15:51:39 2015 -0700 @@ -27,7 +27,7 @@ import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.TruffleOptions; import com.oracle.truffle.api.instrument.Probe; -import com.oracle.truffle.api.instrument.ProbeNode.WrapperNode; +import com.oracle.truffle.api.instrument.WrapperNode; import com.oracle.truffle.api.instrument.StandardSyntaxTag; import com.oracle.truffle.api.instrument.SyntaxTag; import com.oracle.truffle.api.nodes.NodeFieldAccessor.NodeFieldKind; diff -r a0fa69e3e60e -r c896a8e70777 truffle/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java --- a/truffle/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java Sat Sep 19 16:29:32 2015 -0700 +++ b/truffle/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java Sun Sep 20 15:51:39 2015 -0700 @@ -60,7 +60,7 @@ import com.oracle.truffle.api.instrument.ASTProber; import com.oracle.truffle.api.instrument.AdvancedInstrumentResultListener; import com.oracle.truffle.api.instrument.AdvancedInstrumentRootFactory; -import com.oracle.truffle.api.instrument.ProbeNode.WrapperNode; +import com.oracle.truffle.api.instrument.WrapperNode; import com.oracle.truffle.api.instrument.ToolSupportProvider; import com.oracle.truffle.api.instrument.Visualizer; import com.oracle.truffle.api.nodes.GraphPrintVisitor; diff -r a0fa69e3e60e -r c896a8e70777 truffle/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLExpressionNode.java --- a/truffle/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLExpressionNode.java Sat Sep 19 16:29:32 2015 -0700 +++ b/truffle/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLExpressionNode.java Sun Sep 20 15:51:39 2015 -0700 @@ -42,7 +42,7 @@ import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.instrument.ProbeNode.WrapperNode; +import com.oracle.truffle.api.instrument.WrapperNode; import com.oracle.truffle.api.nodes.NodeInfo; import com.oracle.truffle.api.nodes.UnexpectedResultException; import com.oracle.truffle.api.source.SourceSection; diff -r a0fa69e3e60e -r c896a8e70777 truffle/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLStatementNode.java --- a/truffle/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLStatementNode.java Sat Sep 19 16:29:32 2015 -0700 +++ b/truffle/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLStatementNode.java Sun Sep 20 15:51:39 2015 -0700 @@ -43,7 +43,7 @@ import java.io.File; import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.instrument.ProbeNode.WrapperNode; +import com.oracle.truffle.api.instrument.WrapperNode; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeInfo; import com.oracle.truffle.api.source.SourceSection; diff -r a0fa69e3e60e -r c896a8e70777 truffle/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/instrument/SLExpressionWrapperNode.java --- a/truffle/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/instrument/SLExpressionWrapperNode.java Sat Sep 19 16:29:32 2015 -0700 +++ b/truffle/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/instrument/SLExpressionWrapperNode.java Sun Sep 20 15:51:39 2015 -0700 @@ -41,11 +41,11 @@ package com.oracle.truffle.sl.nodes.instrument; import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.instrument.EventHandlerNode; import com.oracle.truffle.api.instrument.Instrument; import com.oracle.truffle.api.instrument.KillException; import com.oracle.truffle.api.instrument.Probe; -import com.oracle.truffle.api.instrument.ProbeNode; -import com.oracle.truffle.api.instrument.ProbeNode.WrapperNode; +import com.oracle.truffle.api.instrument.WrapperNode; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeCost; import com.oracle.truffle.api.nodes.NodeInfo; @@ -63,7 +63,7 @@ @NodeInfo(cost = NodeCost.NONE) public final class SLExpressionWrapperNode extends SLExpressionNode implements WrapperNode { @Child private SLExpressionNode child; - @Child private ProbeNode probeNode; + @Child private EventHandlerNode eventHandlerNode; /** * Constructor. @@ -90,12 +90,12 @@ return child; } - public void insertProbe(ProbeNode newProbeNode) { - this.probeNode = newProbeNode; + public void insertEventHandlerNode(EventHandlerNode eventHandler) { + this.eventHandlerNode = eventHandler; } public Probe getProbe() { - return probeNode.getProbe(); + return eventHandlerNode.getProbe(); } public Node getChild() { @@ -105,16 +105,16 @@ @Override public Object executeGeneric(VirtualFrame vFrame) { - probeNode.enter(child, vFrame); + eventHandlerNode.enter(child, vFrame); Object result; try { result = child.executeGeneric(vFrame); - probeNode.returnValue(child, vFrame, result); + eventHandlerNode.returnValue(child, vFrame, result); } catch (KillException e) { throw (e); } catch (Exception e) { - probeNode.returnExceptional(child, vFrame, e); + eventHandlerNode.returnExceptional(child, vFrame, e); throw (e); } return result; @@ -132,14 +132,14 @@ @Override public SLFunction executeFunction(VirtualFrame vFrame) throws UnexpectedResultException { - probeNode.enter(child, vFrame); + eventHandlerNode.enter(child, vFrame); SLFunction result; try { result = child.executeFunction(vFrame); - probeNode.returnValue(child, vFrame, result); + eventHandlerNode.returnValue(child, vFrame, result); } catch (Exception e) { - probeNode.returnExceptional(child, vFrame, e); + eventHandlerNode.returnExceptional(child, vFrame, e); throw (e); } return result; diff -r a0fa69e3e60e -r c896a8e70777 truffle/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/instrument/SLStatementWrapperNode.java --- a/truffle/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/instrument/SLStatementWrapperNode.java Sat Sep 19 16:29:32 2015 -0700 +++ b/truffle/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/instrument/SLStatementWrapperNode.java Sun Sep 20 15:51:39 2015 -0700 @@ -41,11 +41,11 @@ package com.oracle.truffle.sl.nodes.instrument; import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.instrument.EventHandlerNode; import com.oracle.truffle.api.instrument.Instrument; import com.oracle.truffle.api.instrument.KillException; import com.oracle.truffle.api.instrument.Probe; -import com.oracle.truffle.api.instrument.ProbeNode; -import com.oracle.truffle.api.instrument.ProbeNode.WrapperNode; +import com.oracle.truffle.api.instrument.WrapperNode; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeCost; import com.oracle.truffle.api.nodes.NodeInfo; @@ -61,7 +61,7 @@ public final class SLStatementWrapperNode extends SLStatementNode implements WrapperNode { @Child private SLStatementNode child; - @Child private ProbeNode probeNode; + @Child private EventHandlerNode eventHandlerNode; public SLStatementWrapperNode(SLStatementNode child) { super(child.getSourceSection()); @@ -83,12 +83,13 @@ return child; } - public void insertProbe(ProbeNode newProbeNode) { - this.probeNode = newProbeNode; + @Override + public void insertEventHandlerNode(EventHandlerNode eventHandler) { + this.eventHandlerNode = eventHandler; } public Probe getProbe() { - return probeNode.getProbe(); + return eventHandlerNode.getProbe(); } @Override @@ -98,15 +99,15 @@ @Override public void executeVoid(VirtualFrame vFrame) { - probeNode.enter(child, vFrame); + eventHandlerNode.enter(child, vFrame); try { child.executeVoid(vFrame); - probeNode.returnVoid(child, vFrame); + eventHandlerNode.returnVoid(child, vFrame); } catch (KillException e) { throw (e); } catch (Exception e) { - probeNode.returnExceptional(child, vFrame, e); + eventHandlerNode.returnExceptional(child, vFrame, e); throw (e); } } diff -r a0fa69e3e60e -r c896a8e70777 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 Sat Sep 19 16:29:32 2015 -0700 +++ b/truffle/com.oracle.truffle.tools.test/src/com/oracle/truffle/tools/test/ToolTestUtil.java Sun Sep 20 15:51:39 2015 -0700 @@ -38,11 +38,11 @@ import com.oracle.truffle.api.instrument.ASTProber; import com.oracle.truffle.api.instrument.AdvancedInstrumentResultListener; import com.oracle.truffle.api.instrument.AdvancedInstrumentRootFactory; +import com.oracle.truffle.api.instrument.EventHandlerNode; import com.oracle.truffle.api.instrument.Instrumenter; import com.oracle.truffle.api.instrument.KillException; import com.oracle.truffle.api.instrument.Probe; -import com.oracle.truffle.api.instrument.ProbeNode; -import com.oracle.truffle.api.instrument.ProbeNode.WrapperNode; +import com.oracle.truffle.api.instrument.WrapperNode; import com.oracle.truffle.api.instrument.SyntaxTag; import com.oracle.truffle.api.instrument.ToolSupportProvider; import com.oracle.truffle.api.instrument.Visualizer; @@ -227,7 +227,7 @@ @NodeInfo(cost = NodeCost.NONE) static class ToolTestWrapperNode extends ToolTestLangNode implements WrapperNode { @Child private ToolTestLangNode child; - @Child private ProbeNode probeNode; + @Child private EventHandlerNode eventHandlerNode; public ToolTestWrapperNode(ToolTestLangNode child) { super(null); @@ -245,14 +245,13 @@ return false; } - @Override - public void insertProbe(ProbeNode newProbeNode) { - this.probeNode = newProbeNode; + public void insertEventHandlerNode(EventHandlerNode eventHandler) { + this.eventHandlerNode = eventHandler; } @Override public Probe getProbe() { - return probeNode.getProbe(); + return eventHandlerNode.getProbe(); } @Override @@ -262,15 +261,15 @@ @Override public Object execute(VirtualFrame vFrame) { - probeNode.enter(child, vFrame); + eventHandlerNode.enter(child, vFrame); Object result; try { result = child.execute(vFrame); - probeNode.returnValue(child, vFrame, result); + eventHandlerNode.returnValue(child, vFrame, result); } catch (KillException e) { throw (e); } catch (Exception e) { - probeNode.returnExceptional(child, vFrame, e); + eventHandlerNode.returnExceptional(child, vFrame, e); throw (e); } return result;