# HG changeset patch # User Michael Van De Vanter # Date 1423615451 28800 # Node ID 128586040207db904645dcfbef72501c750a3a7b # Parent d3e835fa6bbf454cebec3fcb5a1e54d22fdce74d Truffle/Instrumentation: TruffleEventReceiver renamed to TruffleEventListener diff -r d3e835fa6bbf -r 128586040207 graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/instrument/InstrumentationTest.java --- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/instrument/InstrumentationTest.java Wed Feb 11 00:33:28 2015 +0100 +++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/instrument/InstrumentationTest.java Tue Feb 10 16:44:11 2015 -0800 @@ -318,11 +318,11 @@ // Use the "lite-probing" option, limited to a single pass of // probing and a single Instrument at each probed node. This - // particular test uses a shared event receiver at every + // particular test uses a shared event listener at every // lite-probed node. - final TestEventReceiver receiver = new TestEventReceiver(); + final TestEventListener listener = new TestEventListener(); - TestASTLiteProber astLiteProber = new TestASTLiteProber(receiver); + TestASTLiteProber astLiteProber = new TestASTLiteProber(listener); Probe.registerASTProber(astLiteProber); // Create a simple addition AST @@ -337,9 +337,9 @@ final CallTarget callTarget = runtime.createCallTarget(rootNode); // Check that the instrument is working as expected. - assertEquals(0, receiver.counter); + assertEquals(0, listener.counter); callTarget.call(); - assertEquals(2, receiver.counter); + assertEquals(2, listener.counter); // Check that you can't probe a node that's already received a probeLite() call try { @@ -409,7 +409,7 @@ } // Use reflection to check that each WrapperNode has a ProbeLiteNode with a - // SimpleEventReceiver + // SimpleEventListener try { java.lang.reflect.Field probeNodeField = leftWrapper.getClass().getDeclaredField("probeNode"); @@ -420,15 +420,15 @@ // hack: Since ProbeLiteNode is not visible, we do a string compare here assertTrue(probeNode.getClass().toString().endsWith("ProbeLiteNode")); - // Now we do the same to check the type of the eventReceiver in ProbeLiteNode - java.lang.reflect.Field eventReceiverField = probeNode.getClass().getDeclaredField("eventReceiver"); - eventReceiverField.setAccessible(true); - TruffleEventReceiver eventReceiver = (TruffleEventReceiver) eventReceiverField.get(probeNode); - assertTrue(eventReceiver instanceof SimpleEventReceiver); + // Now we do the same to check the type of the eventListener in ProbeLiteNode + java.lang.reflect.Field eventListenerField = probeNode.getClass().getDeclaredField("eventListener"); + eventListenerField.setAccessible(true); + TruffleEventListener eventListener = (TruffleEventListener) eventListenerField.get(probeNode); + assertTrue(eventListener instanceof SimpleEventListener); // Reset accessibility probeNodeField.setAccessible(false); - eventReceiverField.setAccessible(false); + eventListenerField.setAccessible(false); } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) { fail(); @@ -588,7 +588,7 @@ public final Instrument instrument; public TestCounter() { - instrument = Instrument.create(new SimpleEventReceiver() { + instrument = Instrument.create(new SimpleEventListener() { @Override public void enter(Node node, VirtualFrame frame) { @@ -641,19 +641,19 @@ } /** - * "lite-probes" every value node with a shared event receiver. + * "lite-probes" every value node with a shared event listener. */ private static final class TestASTLiteProber implements NodeVisitor, ASTProber { - private final TruffleEventReceiver eventReceiver; + private final TruffleEventListener eventListener; - public TestASTLiteProber(SimpleEventReceiver simpleEventReceiver) { - this.eventReceiver = simpleEventReceiver; + public TestASTLiteProber(SimpleEventListener simpleEventListener) { + this.eventListener = simpleEventListener; } public boolean visit(Node node) { if (node instanceof TestValueNode) { final TestLanguageNode testNode = (TestValueNode) node; - testNode.probeLite(eventReceiver); + testNode.probeLite(eventListener); } return true; } @@ -667,7 +667,7 @@ * Counts the number of "enter" events at probed nodes. * */ - static final class TestEventReceiver extends SimpleEventReceiver { + static final class TestEventListener extends SimpleEventListener { public int counter = 0; @@ -692,7 +692,7 @@ // where we want to count executions. // it will get copied when ASTs cloned, so // keep the count in this outer class. - probe.attach(Instrument.create(new SimpleEventReceiver() { + probe.attach(Instrument.create(new SimpleEventListener() { @Override public void enter(Node node, VirtualFrame frame) { diff -r d3e835fa6bbf -r 128586040207 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Instrument.java --- 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. *

*

Summary: How to "instrument" an AST location:

*
    - *
  1. Create an implementation of {@link TruffleEventReceiver} that responds to events on behalf of + *
  2. Create an implementation of {@link TruffleEventListener} that responds to events on behalf of * a tool.
  3. - *
  4. Create an Instrument via factory method {@link Instrument#create(TruffleEventReceiver)}.
  5. + *
  6. Create an Instrument via factory method {@link Instrument#create(TruffleEventListener)}.
  7. *
  8. "Attach" the Instrument to a Probe via {@link Probe#attach(Instrument)}, at which point event - * notifications begin to arrive at the receiver.
  9. + * notifications begin to arrive at the listener. *
  10. 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.
  11. + * point event notifications to the listener cease, and the Instrument becomes unusable. *
*

- *

Options for creating receivers:

+ *

Options for creating listeners:

*

*

    - *
  1. Implement the interface {@link TruffleEventReceiver}. The event handling methods account for + *
  2. 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).
  3. - *
  4. Extend {@link DefaultEventReceiver}, which provides a no-op implementation of every - * {@link TruffleEventReceiver} method; override the methods of interest.
  5. - *
  6. Extend {@link SimpleEventReceiver}, where return values are ignored so only two methods (for + *
  7. Extend {@link DefaultEventListener}, which provides a no-op implementation of every + * {@link TruffleEventListener} method; override the methods of interest.
  8. + *
  9. Extend {@link SimpleEventListener}, where return values are ignored so only two methods (for * "enter" and "return") will notify all events.
  10. *
*

- *

General guidelines for receiver implementation:

+ *

General guidelines for listener implementation:

*

- * 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. *

*
  • Some global information is available, for example the execution * {@linkplain TruffleRuntime#iterateFrames(FrameInstanceVisitor) stack}.
  • - *
  • 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 + *
  • 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.
  • @@ -129,43 +129,43 @@ * which can trigger deoptimization. * *

    - *

    Sharing receivers:

    + *

    Sharing listeners:

    *

    - * 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. *

    * Disclaimer: 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(); } } diff -r d3e835fa6bbf -r 128586040207 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Probe.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Probe.java Wed Feb 11 00:33:28 2015 +0100 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Probe.java Tue Feb 10 16:44:11 2015 -0800 @@ -40,7 +40,7 @@ * is intended to persist at the location, even if the specific node instance is * {@linkplain Node#replace(Node) replaced}. *

    - * The effect of a binding is to intercept {@linkplain TruffleEventReceiver execution events} + * The effect of a binding is to intercept {@linkplain TruffleEventListener execution events} * arriving at the node and notify each attached {@link Instrument} before execution is allowed to * proceed to the child. *

    diff -r d3e835fa6bbf -r 128586040207 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/ProbeNode.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/ProbeNode.java Wed Feb 11 00:33:28 2015 +0100 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/ProbeNode.java Tue Feb 10 16:44:11 2015 -0800 @@ -35,7 +35,7 @@ /** * Implementation interfaces and classes for attaching {@link Probe}s to {@link WrapperNode}s. */ -public abstract class ProbeNode extends Node implements TruffleEventReceiver, InstrumentationNode { +public abstract class ProbeNode extends Node implements TruffleEventListener, InstrumentationNode { /** * A node that can be inserted into a Truffle AST, and which enables {@linkplain Instrument @@ -85,14 +85,14 @@ /** * Gets the node being "wrapped", i.e. the AST node for which - * {@linkplain TruffleEventReceiver execution events} will be reported through the + * {@linkplain TruffleEventListener execution events} will be reported through the * Instrumentation Framework. */ Node getChild(); /** * Gets the {@link Probe} responsible for installing this wrapper; none if the wrapper - * installed via {@linkplain Node#probeLite(TruffleEventReceiver) "lite-Probing"}. + * installed via {@linkplain Node#probeLite(TruffleEventListener) "lite-Probing"}. */ Probe getProbe(); @@ -120,8 +120,8 @@ * Creates a new {@link ProbeLiteNode} associated with, and attached to, a Guest Language * specific instance of {@link WrapperNode}. */ - public static void insertProbeLite(WrapperNode wrapper, TruffleEventReceiver eventReceiver) { - final ProbeLiteNode probeLiteNode = new ProbeLiteNode(eventReceiver); + public static void insertProbeLite(WrapperNode wrapper, TruffleEventListener eventListener) { + final ProbeLiteNode probeLiteNode = new ProbeLiteNode(eventListener); wrapper.insertProbe(probeLiteNode); } @@ -277,15 +277,15 @@ /** * Implementation of a probe that only ever has a single "instrument" associated with it. No * {@link Instrument} is ever created; instead this method simply delegates the various enter - * and return events to a {@link TruffleEventReceiver} passed in during construction. + * and return events to a {@link TruffleEventListener} passed in during construction. */ @NodeInfo(cost = NodeCost.NONE) private static final class ProbeLiteNode extends ProbeNode { - private final TruffleEventReceiver eventReceiver; + private final TruffleEventListener eventListener; - private ProbeLiteNode(TruffleEventReceiver eventReceiver) { - this.eventReceiver = eventReceiver; + private ProbeLiteNode(TruffleEventListener eventListener) { + this.eventListener = eventListener; } @Override @@ -306,19 +306,19 @@ } public void enter(Node node, VirtualFrame frame) { - eventReceiver.enter(node, frame); + eventListener.enter(node, frame); } public void returnVoid(Node node, VirtualFrame frame) { - eventReceiver.returnVoid(node, frame); + eventListener.returnVoid(node, frame); } public void returnValue(Node node, VirtualFrame frame, Object result) { - eventReceiver.returnValue(node, frame, result); + eventListener.returnValue(node, frame, result); } public void returnExceptional(Node node, VirtualFrame frame, Exception exception) { - eventReceiver.returnExceptional(node, frame, exception); + eventListener.returnExceptional(node, frame, exception); } public String instrumentationInfo() { diff -r d3e835fa6bbf -r 128586040207 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/TruffleEventListener.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/TruffleEventListener.java Tue Feb 10 16:44:11 2015 -0800 @@ -0,0 +1,57 @@ +/* + * 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.frame.*; +import com.oracle.truffle.api.nodes.*; + +/** + * A listener of Truffle AST runtime execution events that can collect information and possibly + * intervene on behalf of an external tool. + */ +public interface TruffleEventListener { + + /** + * Receive notification that an AST node's execute method is about to be called. + */ + void enter(Node node, VirtualFrame frame); + + /** + * Receive notification that an AST Node's {@code void}-valued execute method has just returned. + */ + void returnVoid(Node node, VirtualFrame frame); + + /** + * Receive notification that an AST Node'sexecute method has just returned a value (boxed if + * primitive). + */ + void returnValue(Node node, VirtualFrame frame, Object result); + + /** + * Receive notification that an AST Node's execute method has just thrown an exception. + */ + void returnExceptional(Node node, VirtualFrame frame, Exception exception); + +} diff -r d3e835fa6bbf -r 128586040207 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/TruffleEventReceiver.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/TruffleEventReceiver.java Wed Feb 11 00:33:28 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2013, 2014, 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.*; -import com.oracle.truffle.api.nodes.*; - -/** - * A receiver of Truffle AST runtime execution events that can collect information and possibly - * intervene on behalf of an external tool. - */ -public interface TruffleEventReceiver { - - /** - * Receive notification that an AST node's execute method is about to be called. - */ - void enter(Node node, VirtualFrame frame); - - /** - * Receive notification that an AST Node's {@code void}-valued execute method has just returned. - */ - void returnVoid(Node node, VirtualFrame frame); - - /** - * Receive notification that an AST Node'sexecute method has just returned a value (boxed if - * primitive). - */ - void returnValue(Node node, VirtualFrame frame, Object result); - - /** - * Receive notification that an AST Node's execute method has just thrown an exception. - */ - void returnExceptional(Node node, VirtualFrame frame, Exception exception); - -} diff -r d3e835fa6bbf -r 128586040207 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/DefaultEventListener.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/DefaultEventListener.java Tue Feb 10 16:44:11 2015 -0800 @@ -0,0 +1,49 @@ +/* + * 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.impl; + +import com.oracle.truffle.api.frame.*; +import com.oracle.truffle.api.instrument.*; +import com.oracle.truffle.api.nodes.*; + +/** + * A listener for AST {@linkplain TruffleEventListener execution events} that provides a no-op + * implementation of every event. + */ +public class DefaultEventListener implements TruffleEventListener { + + public void enter(Node node, VirtualFrame frame) { + } + + public void returnVoid(Node node, VirtualFrame frame) { + } + + public void returnValue(Node node, VirtualFrame frame, Object result) { + } + + public void returnExceptional(Node node, VirtualFrame frame, Exception exception) { + } + +} diff -r d3e835fa6bbf -r 128586040207 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/DefaultEventReceiver.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/DefaultEventReceiver.java Wed Feb 11 00:33:28 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2014, 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.impl; - -import com.oracle.truffle.api.frame.*; -import com.oracle.truffle.api.instrument.*; -import com.oracle.truffle.api.nodes.*; - -/** - * A receiver for AST {@linkplain TruffleEventReceiver execution events} that provides a no-op - * implementation of every event. - */ -public class DefaultEventReceiver implements TruffleEventReceiver { - - public void enter(Node node, VirtualFrame frame) { - } - - public void returnVoid(Node node, VirtualFrame frame) { - } - - public void returnValue(Node node, VirtualFrame frame, Object result) { - } - - public void returnExceptional(Node node, VirtualFrame frame, Exception exception) { - } - -} diff -r d3e835fa6bbf -r 128586040207 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/SimpleEventListener.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/SimpleEventListener.java Tue Feb 10 16:44:11 2015 -0800 @@ -0,0 +1,66 @@ +/* + * 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.impl; + +import com.oracle.truffle.api.frame.*; +import com.oracle.truffle.api.instrument.*; +import com.oracle.truffle.api.nodes.*; + +/** + * An abstract listener for AST {@linkplain TruffleEventListener execution events} that ignores + * return values and supports handling all events by overriding only two methods: + *

    + */ +public abstract class SimpleEventListener implements TruffleEventListener { + + public void enter(Node node, VirtualFrame frame) { + } + + /** + * Receive notification that one of an AST Node's execute methods has just returned by any + * means: with or without a return value (ignored) or via exception (ignored). + * + * @param node + * @param frame + */ + public void returnAny(Node node, VirtualFrame frame) { + } + + public final void returnVoid(Node node, VirtualFrame frame) { + returnAny(node, frame); + } + + public final void returnValue(Node node, VirtualFrame frame, Object result) { + returnAny(node, frame); + } + + public final void returnExceptional(Node node, VirtualFrame frame, Exception e) { + returnAny(node, frame); + } + +} diff -r d3e835fa6bbf -r 128586040207 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/SimpleEventReceiver.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/SimpleEventReceiver.java Wed Feb 11 00:33:28 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2014, 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.impl; - -import com.oracle.truffle.api.frame.*; -import com.oracle.truffle.api.instrument.*; -import com.oracle.truffle.api.nodes.*; - -/** - * An abstract receiver for AST {@linkplain TruffleEventReceiver execution events} that ignores - * return values and supports handling all events by overriding only two methods: - * - */ -public abstract class SimpleEventReceiver implements TruffleEventReceiver { - - public void enter(Node node, VirtualFrame frame) { - } - - /** - * Receive notification that one of an AST Node's execute methods has just returned by any - * means: with or without a return value (ignored) or via exception (ignored). - * - * @param node - * @param frame - */ - public void returnAny(Node node, VirtualFrame frame) { - } - - public final void returnVoid(Node node, VirtualFrame frame) { - returnAny(node, frame); - } - - public final void returnValue(Node node, VirtualFrame frame, Object result) { - returnAny(node, frame); - } - - public final void returnExceptional(Node node, VirtualFrame frame, Exception e) { - returnAny(node, frame); - } - -} diff -r d3e835fa6bbf -r 128586040207 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java Wed Feb 11 00:33:28 2015 +0100 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java Tue Feb 10 16:44:11 2015 -0800 @@ -504,16 +504,16 @@ * its parent; the wrapper node must be provided by implementations of * {@link #createWrapperNode()}. *

    - * Unlike {@link #probe()}, once {@link #probeLite(TruffleEventReceiver)} is called at a node, + * Unlike {@link #probe()}, once {@link #probeLite(TruffleEventListener)} is called at a node, * no additional probing can be added and no additional instrumentation can be attached. *

    * This restricted form of instrumentation is intended for special cases where only one kind of * instrumentation is desired, and for which performance is a concern * - * @param eventReceiver + * @param eventListener * @throws ProbeException (unchecked) when a probe cannot be created, leaving the AST unchanged */ - public final void probeLite(TruffleEventReceiver eventReceiver) { + public final void probeLite(TruffleEventListener eventListener) { if (this instanceof WrapperNode) { throw new ProbeException(ProbeFailure.Reason.WRAPPER_NODE, null, this, null); @@ -545,7 +545,7 @@ } // Connect it to a Probe - ProbeNode.insertProbeLite(wrapper, eventReceiver); + ProbeNode.insertProbeLite(wrapper, eventListener); // Replace this node in the AST with the wrapper this.replace(wrapperNode); diff -r d3e835fa6bbf -r 128586040207 graal/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/instrument/SLInstrumentTestRunner.java --- a/graal/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/instrument/SLInstrumentTestRunner.java Wed Feb 11 00:33:28 2015 +0100 +++ b/graal/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/instrument/SLInstrumentTestRunner.java Tue Feb 10 16:44:11 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -218,8 +218,8 @@ // Attach an instrument to every probe tagged as an assignment for (Probe probe : Probe.findProbesTaggedAs(StandardSyntaxTag.ASSIGNMENT)) { - SLPrintAssigmentValueReciever slPrintAssigmentValueReceiver = new SLPrintAssigmentValueReciever(printer); - probe.attach(Instrument.create(slPrintAssigmentValueReceiver, "SL print assignment value")); + SLPrintAssigmentValueListener slPrintAssigmentValueListener = new SLPrintAssigmentValueListener(printer); + probe.attach(Instrument.create(slPrintAssigmentValueListener, "SL print assignment value")); } SLFunction main = slContext.getFunctionRegistry().lookup("main"); @@ -271,16 +271,16 @@ } /** - * This sample instrument receiver provides prints the value of an assignment (after the + * This sample instrument listener provides prints the value of an assignment (after the * assignment is complete) to the {@link PrintStream} specified in the constructor. This * instrument can only be attached to a wrapped {@link SLWriteLocalVariableNode}, but provides * no guards to protect it from being attached elsewhere. */ - public final class SLPrintAssigmentValueReciever extends DefaultEventReceiver { + public final class SLPrintAssigmentValueListener extends DefaultEventListener { private PrintStream output; - public SLPrintAssigmentValueReciever(PrintStream output) { + public SLPrintAssigmentValueListener(PrintStream output) { this.output = output; }