Mercurial > hg > graal-compiler
diff graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Instrument.java @ 19247:128586040207
Truffle/Instrumentation: TruffleEventReceiver renamed to TruffleEventListener
author | Michael Van De Vanter <michael.van.de.vanter@oracle.com> |
---|---|
date | Tue, 10 Feb 2015 16:44:11 -0800 |
parents | 867058575979 |
children | b5467bb34b24 |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Instrument.java Wed Feb 11 00:33:28 2015 +0100 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Instrument.java Tue Feb 10 16:44:11 2015 -0800 @@ -33,37 +33,37 @@ // TODO (mlvdv) migrate some of this to external documentation. /** * A dynamically added/removed binding between a {@link Probe}, which provides notification of - * {@linkplain TruffleEventReceiver execution events} taking place at a {@link Node} in a Guest - * Language (GL) Truffle AST, and a {@linkplain TruffleEventReceiver receiver}, which consumes + * {@linkplain TruffleEventListener execution events} taking place at a {@link Node} in a Guest + * Language (GL) Truffle AST, and a {@linkplain TruffleEventListener listener}, which consumes * notifications on behalf of an external tool. * <p> * <h4>Summary: How to "instrument" an AST location:</h4> * <ol> - * <li>Create an implementation of {@link TruffleEventReceiver} that responds to events on behalf of + * <li>Create an implementation of {@link TruffleEventListener} that responds to events on behalf of * a tool.</li> - * <li>Create an Instrument via factory method {@link Instrument#create(TruffleEventReceiver)}.</li> + * <li>Create an Instrument via factory method {@link Instrument#create(TruffleEventListener)}.</li> * <li>"Attach" the Instrument to a Probe via {@link Probe#attach(Instrument)}, at which point event - * notifications begin to arrive at the receiver.</li> + * notifications begin to arrive at the listener.</li> * <li>When no longer needed, "detach" the Instrument via {@link Instrument#dispose()}, at which - * point event notifications to the receiver cease, and the Instrument becomes unusable.</li> + * point event notifications to the listener cease, and the Instrument becomes unusable.</li> * </ol> * <p> - * <h4>Options for creating receivers:</h4> + * <h4>Options for creating listeners:</h4> * <p> * <ol> - * <li>Implement the interface {@link TruffleEventReceiver}. The event handling methods account for + * <li>Implement the interface {@link TruffleEventListener}. The event handling methods account for * both the entry into an AST node (about to call) and several possible kinds of exit from an AST * node (just returned).</li> - * <li>Extend {@link DefaultEventReceiver}, which provides a no-op implementation of every - * {@link TruffleEventReceiver} method; override the methods of interest.</li> - * <li>Extend {@link SimpleEventReceiver}, where return values are ignored so only two methods (for + * <li>Extend {@link DefaultEventListener}, which provides a no-op implementation of every + * {@link TruffleEventListener} method; override the methods of interest.</li> + * <li>Extend {@link SimpleEventListener}, where return values are ignored so only two methods (for * "enter" and "return") will notify all events.</li> * </ol> * <p> - * <h4>General guidelines for receiver implementation:</h4> + * <h4>General guidelines for listener implementation:</h4> * <p> - * When an Instrument is attached to a Probe, the receiver effectively becomes part of the executing - * GL program; performance can be affected by the receiver's implementation. + * When an Instrument is attached to a Probe, the listener effectively becomes part of the executing + * GL program; performance can be affected by the listener's implementation. * <ul> * <li>Do not store {@link Frame} or {@link Node} references in fields.</li> * <li>Prefer {@code final} fields and (where performance is important) short methods.</li> @@ -71,7 +71,7 @@ * possible through code that is expected to be inlined, since this incurs no runtime overhead. When * access to frame data is needed, substitute a more expensive {@linkplain Frame#materialize() * materialized} representation of the frame.</li> - * <li>If a receiver calls back to its tool during event handling, and if performance is an issue, + * <li>If a listener calls back to its tool during event handling, and if performance is an issue, * then this should be through a final "callback" field in the instrument, and the called methods * should be minimal.</li> * <li>On the other hand, implementations should prevent Truffle from inlining beyond a reasonable @@ -85,14 +85,14 @@ * <p> * <h4>Allowing for AST cloning:</h4> * <p> - * Truffle routinely <em>clones</em> ASTs, which has consequences for receiver implementation. + * Truffle routinely <em>clones</em> ASTs, which has consequences for listener implementation. * <ul> * <li>Even though a {@link Probe} is uniquely associated with a particular location in the * executing Guest Language program, execution events at that location will in general be * implemented by different {@link Node} instances, i.e. <em>clones</em> of the originally probed * node.</li> * <li>Because of <em>cloning</em> the {@link Node} supplied with notifications to a particular - * receiver will vary, but because they all represent the same GL program location the events should + * listener will vary, but because they all represent the same GL program location the events should * be treated as equivalent for most purposes.</li> * </ul> * <p> @@ -107,8 +107,8 @@ * </ul> * <li>Some global information is available, for example the execution * {@linkplain TruffleRuntime#iterateFrames(FrameInstanceVisitor) stack}.</li> - * <li>Additional information needed by a receiver could be stored when created, preferably - * {@code final} of course. For example, a reference to the {@link Probe} to which the receiver's + * <li>Additional information needed by a listener could be stored when created, preferably + * {@code final} of course. For example, a reference to the {@link Probe} to which the listener's * Instrument has been attached would give access to its corresponding * {@linkplain Probe#getProbedSourceSection() source location} or to the collection of * {@linkplain SyntaxTag tags} currently applied to the Probe.</li> @@ -129,43 +129,43 @@ * which can trigger deoptimization.</li> * </ul> * <p> - * <h4>Sharing receivers:</h4> + * <h4>Sharing listeners:</h4> * <p> - * Although an Instrument may only be attached to a single Probe, a receiver can be shared among + * Although an Instrument may only be attached to a single Probe, a listener can be shared among * multiple Instruments. This can be useful for observing events that might happen at different * locations in a single AST, for example all assignments to a particular variable. In this case a * new Instrument would be created and attached at each assignment node, but all the Instruments - * would be created with the same receiver. + * would be created with the same listener. * <p> * <strong>Disclaimer:</strong> experimental; under development. * * @see Probe - * @see TruffleEventReceiver + * @see TruffleEventListener */ public final class Instrument { /** - * Creates an instrument that will route execution events to a receiver. + * Creates an instrument that will route execution events to a listener. * - * @param receiver a receiver for event generated by the instrument + * @param listener a listener for event generated by the instrument * @param instrumentInfo optional description of the instrument's role * @return a new instrument, ready for attachment at a probe */ - public static Instrument create(TruffleEventReceiver receiver, String instrumentInfo) { - return new Instrument(receiver, instrumentInfo); + public static Instrument create(TruffleEventListener listener, String instrumentInfo) { + return new Instrument(listener, instrumentInfo); } /** - * Creates an instrument that will route execution events to a receiver. + * Creates an instrument that will route execution events to a listener. */ - public static Instrument create(TruffleEventReceiver receiver) { - return new Instrument(receiver, null); + public static Instrument create(TruffleEventListener listener) { + return new Instrument(listener, null); } /** - * Tool-supplied receiver of events. + * Tool-supplied listener for events. */ - private final TruffleEventReceiver toolEventreceiver; + private final TruffleEventListener toolEventListener; /** * Optional documentation, mainly for debugging. @@ -179,8 +179,8 @@ private Probe probe = null; - private Instrument(TruffleEventReceiver receiver, String instrumentInfo) { - this.toolEventreceiver = receiver; + private Instrument(TruffleEventListener listener, String instrumentInfo) { + this.toolEventListener = listener; this.instrumentInfo = instrumentInfo; } @@ -240,7 +240,7 @@ } @NodeInfo(cost = NodeCost.NONE) - final class InstrumentNode extends Node implements TruffleEventReceiver, InstrumentationNode { + final class InstrumentNode extends Node implements TruffleEventListener, InstrumentationNode { @Child private InstrumentNode nextInstrument; @@ -287,28 +287,28 @@ } public void enter(Node node, VirtualFrame frame) { - Instrument.this.toolEventreceiver.enter(node, frame); + Instrument.this.toolEventListener.enter(node, frame); if (nextInstrument != null) { nextInstrument.enter(node, frame); } } public void returnVoid(Node node, VirtualFrame frame) { - Instrument.this.toolEventreceiver.returnVoid(node, frame); + Instrument.this.toolEventListener.returnVoid(node, frame); if (nextInstrument != null) { nextInstrument.returnVoid(node, frame); } } public void returnValue(Node node, VirtualFrame frame, Object result) { - Instrument.this.toolEventreceiver.returnValue(node, frame, result); + Instrument.this.toolEventListener.returnValue(node, frame, result); if (nextInstrument != null) { nextInstrument.returnValue(node, frame, result); } } public void returnExceptional(Node node, VirtualFrame frame, Exception exception) { - Instrument.this.toolEventreceiver.returnExceptional(node, frame, exception); + Instrument.this.toolEventListener.returnExceptional(node, frame, exception); if (nextInstrument != null) { nextInstrument.returnExceptional(node, frame, exception); } @@ -318,7 +318,7 @@ if (Instrument.this.instrumentInfo != null) { return Instrument.this.instrumentInfo; } - return toolEventreceiver.getClass().getSimpleName(); + return toolEventListener.getClass().getSimpleName(); } }