diff graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Probe.java @ 15279:0c6d8a08e31b

Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
author Michael Van De Vanter <michael.van.de.vanter@oracle.com>
date Sun, 20 Apr 2014 20:37:27 -0700
parents
children bb9473723904
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Probe.java	Sun Apr 20 20:37:27 2014 -0700
@@ -0,0 +1,148 @@
+/*
+ * 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;
+
+import com.oracle.truffle.api.*;
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.api.nodes.*;
+
+/**
+ * A collector of {@link ExecutionEvents} at a specific site (node) in a Truffle AST (generated by a
+ * {@link Wrapper} inserted into the AST) for the purpose of <em>instrumentation</em>. For probes
+ * associated with programmer-facing tools, there should be no more than one probe associated with a
+ * particular piece of source code syntax (i.e. a {@link SourceSection}).
+ * <p>
+ * Any {@linkplain PhylumTag tags} associated with a particular piece of source code syntax are
+ * managed by the probe.
+ * <p>
+ * When ASTs are copied, it is presumed that the probe for a site is shared by all AST nodes
+ * representing that site.
+ * <p>
+ * A probe holds zero or more {@link Instrument}s, which can be added and removed dynamically.
+ * Events reported to a probe are propagated to every attached instrument; the order is undefined.
+ * <p>
+ * Probe methods must be amenable to Truffle/Graal inlining on the assumption that the collection of
+ * attached instruments seldom changes. The assumption is invalidated when instruments are added or
+ * removed, but some instruments may change their internal state in such a way that the assumption
+ * should also be invalidated.
+ * <p>
+ * <strong>Disclaimer:</strong> experimental interface under development.
+ */
+public interface Probe extends PhylumTagged {
+
+    /**
+     * The source location with which this probe is (presumably uniquely) associated.
+     */
+    SourceSection getSourceLocation();
+
+    /**
+     * Mark this probe as being associated with an AST node in some category useful for debugging
+     * and other tools.
+     */
+    void tagAs(PhylumTag tag);
+
+    /**
+     * Adds an instrument to this probe.
+     */
+    void addInstrument(Instrument newInstrument);
+
+    /**
+     * Removes an instrument from this probe.
+     */
+    void removeInstrument(Instrument oldInstrument);
+
+    /**
+     * Change <em>stepping mode</em>, which is used in association with nodes tagged as
+     * {@linkplain PhylumTag#STATEMENT statements}.
+     */
+    void setStepping(boolean stepping);
+
+    /**
+     * Value of <em>stepping mode</em>, which is used in association with nodes tagged as
+     * {@linkplain PhylumTag#STATEMENT statements}.
+     */
+    boolean isStepping();
+
+    /**
+     * @see ExecutionEvents#enter(Node, VirtualFrame)
+     */
+    void notifyEnter(Node astNode, VirtualFrame frame);
+
+    /**
+     * @see ExecutionEvents#leave(Node, VirtualFrame)
+     */
+    void notifyLeave(Node astNode, VirtualFrame frame);
+
+    /**
+     * @see ExecutionEvents#leave(Node, VirtualFrame, boolean)
+     */
+    void notifyLeave(Node astNode, VirtualFrame frame, boolean result);
+
+    /**
+     * @see ExecutionEvents#leave(Node, VirtualFrame, byte)
+     */
+    void notifyLeave(Node astNode, VirtualFrame frame, byte result);
+
+    /**
+     * @see ExecutionEvents#leave(Node, VirtualFrame, short)
+     */
+    void notifyLeave(Node astNode, VirtualFrame frame, short result);
+
+    /**
+     * @see ExecutionEvents#leave(Node, VirtualFrame, int)
+     */
+    void notifyLeave(Node astNode, VirtualFrame frame, int result);
+
+    /**
+     * @see ExecutionEvents#leave(Node, VirtualFrame, long)
+     */
+    void notifyLeave(Node astNode, VirtualFrame frame, long result);
+
+    /**
+     * @see ExecutionEvents#leave(Node, VirtualFrame, char)
+     */
+    void notifyLeave(Node astNode, VirtualFrame frame, char result);
+
+    /**
+     * @see ExecutionEvents#leave(Node, VirtualFrame, float)
+     */
+    void notifyLeave(Node astNode, VirtualFrame frame, float result);
+
+    /**
+     * @see ExecutionEvents#leave(Node, VirtualFrame, double)
+     */
+    void notifyLeave(Node astNode, VirtualFrame frame, double result);
+
+    /**
+     * @see ExecutionEvents#leave(Node, VirtualFrame, Object)
+     */
+    void notifyLeave(Node astNode, VirtualFrame frame, Object result);
+
+    /**
+     * @see ExecutionEvents#leaveExceptional(Node, VirtualFrame, Exception)
+     */
+    void notifyLeaveExceptional(Node astNode, VirtualFrame frame, Exception e);
+
+}