# HG changeset patch # User Michael Van De Vanter # Date 1428725654 25200 # Node ID 263ab98b3bf0c3900d16d9b40fc97c6ef3043f52 # Parent 73b1844b5b141f5eecd3ac4a27b5a2649350ad42 Truffle/Instrumentation: rename ASTInstrumentListener to StandardInstrumentListener diff -r 73b1844b5b14 -r 263ab98b3bf0 graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/InstrumentationPartialEvaluationTest.java --- a/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/InstrumentationPartialEvaluationTest.java Fri Apr 10 21:00:26 2015 -0700 +++ b/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/InstrumentationPartialEvaluationTest.java Fri Apr 10 21:14:14 2015 -0700 @@ -79,7 +79,7 @@ RootTestNode root = new RootTestNode(fd, "constantValue", result); root.adoptChildren(); Probe probe = result.probe(); - Instrument instrument = Instrument.create(new DefaultASTInstrumentListener(), "Null test Instrument"); + Instrument instrument = Instrument.create(new DefaultStandardInstrumentListener(), "Null test Instrument"); probe.attach(instrument); assertPartialEvalEquals("constant42", root); } @@ -104,7 +104,7 @@ RootTestNode root = new RootTestNode(fd, "constantValue", result); root.adoptChildren(); Probe probe = result.probe(); - Instrument instrument = Instrument.create(new DefaultASTInstrumentListener(), "Null test Instrument"); + Instrument instrument = Instrument.create(new DefaultStandardInstrumentListener(), "Null test Instrument"); probe.attach(instrument); instrument.dispose(); assertPartialEvalEquals("constant42", root); @@ -131,9 +131,9 @@ RootTestNode root = new RootTestNode(fd, "constantValue", result); root.adoptChildren(); Probe probe = result.probe(); - Instrument instrument1 = Instrument.create(new DefaultASTInstrumentListener(), "Null test Instrument 1"); + Instrument instrument1 = Instrument.create(new DefaultStandardInstrumentListener(), "Null test Instrument 1"); probe.attach(instrument1); - Instrument instrument2 = Instrument.create(new DefaultASTInstrumentListener(), "Null test Instrument 2"); + Instrument instrument2 = Instrument.create(new DefaultStandardInstrumentListener(), "Null test Instrument 2"); probe.attach(instrument2); assertPartialEvalEquals("constant42", root); } @@ -161,11 +161,11 @@ RootTestNode root = new RootTestNode(fd, "constantValue", result); root.adoptChildren(); Probe probe = result.probe(); - Instrument instrument1 = Instrument.create(new DefaultASTInstrumentListener(), "Null test Instrument 1"); + Instrument instrument1 = Instrument.create(new DefaultStandardInstrumentListener(), "Null test Instrument 1"); probe.attach(instrument1); - Instrument instrument2 = Instrument.create(new DefaultASTInstrumentListener(), "Null test Instrument 2"); + Instrument instrument2 = Instrument.create(new DefaultStandardInstrumentListener(), "Null test Instrument 2"); probe.attach(instrument2); - Instrument instrument3 = Instrument.create(new DefaultASTInstrumentListener(), "Null test Instrument 3"); + Instrument instrument3 = Instrument.create(new DefaultStandardInstrumentListener(), "Null test Instrument 3"); probe.attach(instrument3); assertPartialEvalEquals("constant42", root); } @@ -194,11 +194,11 @@ RootTestNode root = new RootTestNode(fd, "constantValue", result); root.adoptChildren(); Probe probe = result.probe(); - Instrument instrument1 = Instrument.create(new DefaultASTInstrumentListener(), "Null test Instrument 1"); + Instrument instrument1 = Instrument.create(new DefaultStandardInstrumentListener(), "Null test Instrument 1"); probe.attach(instrument1); - Instrument instrument2 = Instrument.create(new DefaultASTInstrumentListener(), "Null test Instrument 2"); + Instrument instrument2 = Instrument.create(new DefaultStandardInstrumentListener(), "Null test Instrument 2"); probe.attach(instrument2); - Instrument instrument3 = Instrument.create(new DefaultASTInstrumentListener(), "Null test Instrument 3"); + Instrument instrument3 = Instrument.create(new DefaultStandardInstrumentListener(), "Null test Instrument 3"); probe.attach(instrument3); instrument2.dispose(); assertPartialEvalEquals("constant42", root); diff -r 73b1844b5b14 -r 263ab98b3bf0 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 Fri Apr 10 21:00:26 2015 -0700 +++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/instrument/InstrumentationTest.java Fri Apr 10 21:14:14 2015 -0700 @@ -180,7 +180,7 @@ checkCounters(probe, callTarget, rootNode, new TestSimpleInstrumentCounter(), new TestSimpleInstrumentCounter(), new TestSimpleInstrumentCounter()); // Now try with the more complex flavor of listener - checkCounters(probe, callTarget, rootNode, new TestASTInstrumentCounter(), new TestASTInstrumentCounter(), new TestASTInstrumentCounter()); + checkCounters(probe, callTarget, rootNode, new TestStandardInstrumentCounter(), new TestStandardInstrumentCounter(), new TestStandardInstrumentCounter()); } private static void checkCounters(Probe probe, CallTarget callTarget, RootNode rootNode, TestCounter counterA, TestCounter counterB, TestCounter counterC) { @@ -405,14 +405,14 @@ /** * A counter for the number of times execution enters and leaves a probed AST node. */ - private class TestASTInstrumentCounter implements TestCounter { + private class TestStandardInstrumentCounter implements TestCounter { public int enterCount = 0; public int leaveCount = 0; public final Instrument instrument; - public TestASTInstrumentCounter() { - this.instrument = Instrument.create(new ASTInstrumentListener() { + public TestStandardInstrumentCounter() { + this.instrument = Instrument.create(new StandardInstrumentListener() { public void enter(Probe probe, Node node, VirtualFrame vFrame) { enterCount++; @@ -498,7 +498,7 @@ /** * Counts the number of "enter" events at probed nodes using the AST listener. */ - static final class TestASTInstrumentListener extends DefaultASTInstrumentListener { + static final class TestASTInstrumentListener extends DefaultStandardInstrumentListener { public int counter = 0; diff -r 73b1844b5b14 -r 263ab98b3bf0 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/ASTInstrumentListener.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/ASTInstrumentListener.java Fri Apr 10 21:00:26 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ -/* - * Copyright (c) 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.*; -import com.oracle.truffle.api.source.*; - -/** - * A receiver of Truffle execution events that can act on behalf of an external client. - *

- * The {@link Probe} argument provides access to the {@link SourceSection} associated with the - * event, as well as any {@link SyntaxTag}s that have been applied at that AST node. - *

- * This listener is designed for clients that also require access to the AST execution state at the - * time of the event. Clients that do not require access to the AST execution state should use the - * {@link SimpleInstrumentListener}. - *

- * Clients are free, of course, to record additional information in the listener implementation that - * carries additional information about the context and reason for the particular {@link Instrument} - * that is to be created from the listener. - */ -public interface ASTInstrumentListener { - - /** - * Receive notification that an AST node's execute method is about to be called. - *

- * Synchronous: Truffle execution waits until the call returns. - */ - void enter(Probe probe, Node node, VirtualFrame vFrame); - - /** - * Receive notification that an AST Node's {@code void}-valued execute method has just returned. - *

- * Synchronous: Truffle execution waits until the call returns. - */ - void returnVoid(Probe probe, Node node, VirtualFrame vFrame); - - /** - * Receive notification that an AST Node's execute method has just returned a value (boxed if - * primitive). - *

- * Synchronous: Truffle execution waits until the call returns. - */ - void returnValue(Probe probe, Node node, VirtualFrame vFrame, Object result); - - /** - * Receive notification that an AST Node's execute method has just thrown an exception. - *

- * Synchronous: Truffle execution waits until the call returns. - */ - void returnExceptional(Probe probe, Node node, VirtualFrame vFrame, Exception exception); -} diff -r 73b1844b5b14 -r 263ab98b3bf0 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 Fri Apr 10 21:00:26 2015 -0700 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Instrument.java Fri Apr 10 21:14:14 2015 -0700 @@ -41,13 +41,13 @@ * and a listener, which consumes notifications on behalf of an external tool. There are at * present two kinds of listeners that be used: *

    - *
  1. {@link SimpleInstrumentListener} is the simplest and is intended for tools that require no access - * to the internal execution state of the Truffle execution, only that execution has passed - * through a particular location in the program. Information about that location is made available - * via the {@link Probe} argument in notification methods, including the {@linkplain SourceSection - * source location} of the node and any {@linkplain SyntaxTag tags} that have been applied to the - * node.
  2. - *
  3. {@link ASTInstrumentListener} reports the same events and {@link Probe} argument, but + *
  4. {@link SimpleInstrumentListener} is the simplest and is intended for tools that require no + * access to the internal execution state of the Truffle execution, only that execution has + * passed through a particular location in the program. Information about that location is made + * available via the {@link Probe} argument in notification methods, including the + * {@linkplain SourceSection source location} of the node and any {@linkplain SyntaxTag tags} that + * have been applied to the node.
  5. + *
  6. {@link StandardInstrumentListener} reports the same events and {@link Probe} argument, but * additionally provides access to the execution state via the explicit {@link Node} and * {@link Frame} at the current execution site.
  7. *
@@ -58,36 +58,36 @@ *
  • Create an implementation of a listener interface.
  • *
  • Create an Instrument via factory methods * {@link Instrument#create(SimpleInstrumentListener, String)} or - * {@link Instrument#create(ASTInstrumentListener, String)}.
  • + * {@link Instrument#create(StandardInstrumentListener, String)}. *
  • "Attach" the Instrument to a Probe via {@link Probe#attach(Instrument)}, at which point event * notifications begin to arrive at the listener.
  • - *
  • When no longer needed, "detach" the Instrument via {@link ASTInstrument#dispose()}, at which - * point event notifications to the listener cease, and the Instrument becomes unusable.
  • + *
  • When no longer needed, "detach" the Instrument via {@link StandardInstrument#dispose()}, at + * which point event notifications to the listener cease, and the Instrument becomes unusable.
  • * *

    *

    Options for creating listeners:

    *

    *

      *
    1. Implement one of the listener interfaces: {@link SimpleInstrumentListener} or - * {@link ASTInstrumentListener} . Their event handling methods account for both the entry into an + * {@link StandardInstrumentListener} . Their event handling methods account for both the entry into an * AST node (about to call) and three possible kinds of execution return from an AST node.
    2. *
    3. Extend one of the helper implementations: {@link DefaultSimpleInstrumentListener} or - * {@link DefaultASTInstrumentListener}. These provide no-op implementation of every listener + * {@link DefaultStandardInstrumentListener}. These provide no-op implementation of every listener * method, so only the methods of interest need to be overridden.
    4. *
    *

    - *

    General guidelines for {@link ASTInstrumentListener} implementation:

    + *

    General guidelines for {@link StandardInstrumentListener} implementation:

    *

    * Unlike the listener interface {@link SimpleInstrumentListener}, which isolates implementations - * completely from Truffle internals (and is thus Truffle-safe), implementations of - * {@link ASTInstrumentListener} can interact directly with (and potentially affect) Truffle + * from Truffle internals (and is thus Truffle-safe), implementations of + * {@link StandardInstrumentListener} can interact directly with (and potentially affect) Truffle * execution in general and Truffle optimization in particular. For example, it is possible to * implement a debugger with this interface. *

    *

    - * As a consequence, implementations of {@link ASTInstrumentListener} effectively become part of the - * Truffle execution and must be coded according to general guidelines for Truffle implementations. - * For example: + * As a consequence, implementations of {@link StandardInstrumentListener} effectively become part of + * the Truffle execution and must be coded according to general guidelines for Truffle + * implementations. For example: *