changeset 20885:e7ece52e1ff3

Truffle/Instrumentation: remove two helper classes not adding enough value.
author Michael Van De Vanter <michael.van.de.vanter@oracle.com>
date Fri, 10 Apr 2015 16:55:38 -0700
parents c6ba61a3d05a
children 0e647427eee4
files graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/instrument/InstrumentationTest.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Instrument.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/SimpleASTInstrumentListener.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/SimpleInstrumentListener.java
diffstat 4 files changed, 30 insertions(+), 157 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/instrument/InstrumentationTest.java	Mon Apr 06 08:48:36 2015 -0700
+++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/instrument/InstrumentationTest.java	Fri Apr 10 16:55:38 2015 -0700
@@ -157,7 +157,6 @@
 
         // Check that the "probed" AST still executes correctly
         assertEquals(13, callTarget1.call());
-
     }
 
     @Test
@@ -182,7 +181,6 @@
 
         // Now try with the more complex flavor of listener
         checkCounters(probe, callTarget, rootNode, new TestASTInstrumentCounter(), new TestASTInstrumentCounter(), new TestASTInstrumentCounter());
-
     }
 
     private static void checkCounters(Probe probe, CallTarget callTarget, RootNode rootNode, TestCounter counterA, TestCounter counterB, TestCounter counterC) {
@@ -280,12 +278,10 @@
         assertEquals(counterB.leaveCount(), 8);
         assertEquals(counterC.enterCount(), 2);
         assertEquals(counterC.leaveCount(), 2);
-
     }
 
     @Test
     public void testTagging() {
-
         // Applies appropriate tags
         final TestASTProber astProber = new TestASTProber();
         Probe.registerASTProber(astProber);
@@ -341,7 +337,6 @@
         assertEquals(valueCounter.count, 2);
 
         Probe.unregisterASTProber(astProber);
-
     }
 
     private interface TestCounter {
@@ -353,12 +348,10 @@
         void attach(Probe probe);
 
         void dispose();
-
     }
 
     /**
-     * A counter for the number of times execution enters and leaves a probed AST node, using the
-     * simplest kind of listener.
+     * A counter for the number of times execution enters and leaves a probed AST node.
      */
     private class TestInstrumentCounter implements TestCounter {
 
@@ -367,42 +360,50 @@
         public final Instrument instrument;
 
         public TestInstrumentCounter() {
-            this.instrument = Instrument.create(new SimpleInstrumentListener() {
+            this.instrument = Instrument.create(new InstrumentListener() {
 
-                @Override
                 public void enter(Probe probe) {
                     enterCount++;
                 }
 
-                @Override
-                public void returnAny(Probe probe) {
+                public void returnVoid(Probe probe) {
+                    leaveCount++;
+                }
+
+                public void returnValue(Probe probe, Object result) {
+                    leaveCount++;
+                }
+
+                public void returnExceptional(Probe probe, Exception exception) {
                     leaveCount++;
                 }
 
             }, "Instrumentation Test Counter");
-
         }
 
+        @Override
         public int enterCount() {
             return enterCount;
         }
 
+        @Override
         public int leaveCount() {
             return leaveCount;
         }
 
+        @Override
         public void attach(Probe probe) {
             probe.attach(instrument);
         }
 
+        @Override
         public void dispose() {
             instrument.dispose();
         }
     }
 
     /**
-     * A counter for the number of times execution enters and leaves a probed AST node, using the
-     * simplest kind of listener.
+     * A counter for the number of times execution enters and leaves a probed AST node.
      */
     private class TestASTInstrumentCounter implements TestCounter {
 
@@ -411,34 +412,43 @@
         public final Instrument instrument;
 
         public TestASTInstrumentCounter() {
-            this.instrument = Instrument.create(new SimpleASTInstrumentListener() {
+            this.instrument = Instrument.create(new ASTInstrumentListener() {
 
-                @Override
                 public void enter(Probe probe, Node node, VirtualFrame vFrame) {
                     enterCount++;
                 }
 
-                @Override
-                public void returnAny(Probe probe, Node node, VirtualFrame vFrame) {
+                public void returnVoid(Probe probe, Node node, VirtualFrame vFrame) {
+                    leaveCount++;
+                }
+
+                public void returnValue(Probe probe, Node node, VirtualFrame vFrame, Object result) {
+                    leaveCount++;
+                }
+
+                public void returnExceptional(Probe probe, Node node, VirtualFrame vFrame, Exception exception) {
                     leaveCount++;
                 }
 
             }, "Instrumentation Test Counter");
-
         }
 
+        @Override
         public int enterCount() {
             return enterCount;
         }
 
+        @Override
         public int leaveCount() {
             return leaveCount;
         }
 
+        @Override
         public void attach(Probe probe) {
             probe.attach(instrument);
         }
 
+        @Override
         public void dispose() {
             instrument.dispose();
         }
@@ -483,7 +493,6 @@
         public void enter(Probe probe) {
             counter++;
         }
-
     }
 
     /**
@@ -497,7 +506,6 @@
         public void enter(Probe probe, Node node, VirtualFrame vFrame) {
             counter++;
         }
-
     }
 
     /**
@@ -539,5 +547,4 @@
             tagCount++;
         }
     }
-
 }
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Instrument.java	Mon Apr 06 08:48:36 2015 -0700
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Instrument.java	Fri Apr 10 16:55:38 2015 -0700
@@ -74,10 +74,6 @@
  * <li>Extend one of the <em>helper implementations</em>: {@link DefaultInstrumentListener} or
  * {@link DefaultASTInstrumentListener}. These provide no-op implementation of every listener
  * method, so only the methods of interest need to be overridden.</li>
- * <li>Extend one of the <em>helper implementations</em>: {@link SimpleInstrumentListener} or
- * {@link SimpleASTInstrumentListener}. These re-route all <em>execution returns</em> to a single
- * method, ignoring return values, so only two methods (for "enter" and "return") will notify all
- * events.</li>
  * </ol>
  * <p>
  * <h4>General guidelines for {@link ASTInstrumentListener} implementation:</h4>
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/SimpleASTInstrumentListener.java	Mon Apr 06 08:48:36 2015 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +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.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 ASTInstrumentListener execution events} that ignores
- * return values and supports handling all events by overriding only two methods:
- * <ul>
- * <li>{@link #enter(Probe, Node, VirtualFrame)}, and</li>
- * <li>{@link #returnAny(Probe, Node, VirtualFrame)}.</li>
- * </ul>
- */
-public abstract class SimpleASTInstrumentListener implements ASTInstrumentListener {
-
-    public void enter(Probe probe, Node node, VirtualFrame vFrame) {
-    }
-
-    /**
-     * 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 probe where the event originated
-     * @param node specific node of the event
-     * @param vFrame
-     */
-    protected void returnAny(Probe probe, Node node, VirtualFrame vFrame) {
-    }
-
-    public final void returnVoid(Probe probe, Node node, VirtualFrame vFrame) {
-        returnAny(probe, node, vFrame);
-    }
-
-    public final void returnValue(Probe probe, Node node, VirtualFrame vFrame, Object result) {
-        returnAny(probe, node, vFrame);
-    }
-
-    public final void returnExceptional(Probe probe, Node node, VirtualFrame vFrame, Exception e) {
-        returnAny(probe, node, vFrame);
-    }
-
-}
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/SimpleInstrumentListener.java	Mon Apr 06 08:48:36 2015 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-/*
- * 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.instrument.*;
-
-/**
- * An abstract listener for Truffle {@linkplain InstrumentListener execution events} that ignores
- * return values and supports handling all events by overriding only two methods:
- * <ul>
- * <li>{@link #enter(Probe)}, and</li>
- * <li>{@link #returnAny(Probe)}.</li>
- * </ul>
- */
-public abstract class SimpleInstrumentListener implements InstrumentListener {
-
-    public void enter(Probe probe) {
-    }
-
-    /**
-     * Receive notification that an execute method has just returned by any means: with or without a
-     * return value (ignored) or via exception (ignored).
-     *
-     * @param probe
-     */
-    protected void returnAny(Probe probe) {
-    }
-
-    public final void returnVoid(Probe probe) {
-        returnAny(probe);
-    }
-
-    public final void returnValue(Probe probe, Object result) {
-        returnAny(probe);
-    }
-
-    public final void returnExceptional(Probe probe, Exception e) {
-        returnAny(probe);
-    }
-
-}