Mercurial > hg > truffle
diff truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Instrument.java @ 22226:c896a8e70777
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
author | Michael Van De Vanter <michael.van.de.vanter@oracle.com> |
---|---|
date | Sun, 20 Sep 2015 15:51:39 -0700 |
parents | a0fa69e3e60e |
children | 68a0c3dcea10 |
line wrap: on
line diff
--- 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</a> * * @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. */