comparison 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
comparison
equal deleted inserted replaced
14862:0e713dba33bb 15279:0c6d8a08e31b
1 /*
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25 package com.oracle.truffle.api.instrument;
26
27 import com.oracle.truffle.api.*;
28 import com.oracle.truffle.api.frame.*;
29 import com.oracle.truffle.api.nodes.*;
30
31 /**
32 * A collector of {@link ExecutionEvents} at a specific site (node) in a Truffle AST (generated by a
33 * {@link Wrapper} inserted into the AST) for the purpose of <em>instrumentation</em>. For probes
34 * associated with programmer-facing tools, there should be no more than one probe associated with a
35 * particular piece of source code syntax (i.e. a {@link SourceSection}).
36 * <p>
37 * Any {@linkplain PhylumTag tags} associated with a particular piece of source code syntax are
38 * managed by the probe.
39 * <p>
40 * When ASTs are copied, it is presumed that the probe for a site is shared by all AST nodes
41 * representing that site.
42 * <p>
43 * A probe holds zero or more {@link Instrument}s, which can be added and removed dynamically.
44 * Events reported to a probe are propagated to every attached instrument; the order is undefined.
45 * <p>
46 * Probe methods must be amenable to Truffle/Graal inlining on the assumption that the collection of
47 * attached instruments seldom changes. The assumption is invalidated when instruments are added or
48 * removed, but some instruments may change their internal state in such a way that the assumption
49 * should also be invalidated.
50 * <p>
51 * <strong>Disclaimer:</strong> experimental interface under development.
52 */
53 public interface Probe extends PhylumTagged {
54
55 /**
56 * The source location with which this probe is (presumably uniquely) associated.
57 */
58 SourceSection getSourceLocation();
59
60 /**
61 * Mark this probe as being associated with an AST node in some category useful for debugging
62 * and other tools.
63 */
64 void tagAs(PhylumTag tag);
65
66 /**
67 * Adds an instrument to this probe.
68 */
69 void addInstrument(Instrument newInstrument);
70
71 /**
72 * Removes an instrument from this probe.
73 */
74 void removeInstrument(Instrument oldInstrument);
75
76 /**
77 * Change <em>stepping mode</em>, which is used in association with nodes tagged as
78 * {@linkplain PhylumTag#STATEMENT statements}.
79 */
80 void setStepping(boolean stepping);
81
82 /**
83 * Value of <em>stepping mode</em>, which is used in association with nodes tagged as
84 * {@linkplain PhylumTag#STATEMENT statements}.
85 */
86 boolean isStepping();
87
88 /**
89 * @see ExecutionEvents#enter(Node, VirtualFrame)
90 */
91 void notifyEnter(Node astNode, VirtualFrame frame);
92
93 /**
94 * @see ExecutionEvents#leave(Node, VirtualFrame)
95 */
96 void notifyLeave(Node astNode, VirtualFrame frame);
97
98 /**
99 * @see ExecutionEvents#leave(Node, VirtualFrame, boolean)
100 */
101 void notifyLeave(Node astNode, VirtualFrame frame, boolean result);
102
103 /**
104 * @see ExecutionEvents#leave(Node, VirtualFrame, byte)
105 */
106 void notifyLeave(Node astNode, VirtualFrame frame, byte result);
107
108 /**
109 * @see ExecutionEvents#leave(Node, VirtualFrame, short)
110 */
111 void notifyLeave(Node astNode, VirtualFrame frame, short result);
112
113 /**
114 * @see ExecutionEvents#leave(Node, VirtualFrame, int)
115 */
116 void notifyLeave(Node astNode, VirtualFrame frame, int result);
117
118 /**
119 * @see ExecutionEvents#leave(Node, VirtualFrame, long)
120 */
121 void notifyLeave(Node astNode, VirtualFrame frame, long result);
122
123 /**
124 * @see ExecutionEvents#leave(Node, VirtualFrame, char)
125 */
126 void notifyLeave(Node astNode, VirtualFrame frame, char result);
127
128 /**
129 * @see ExecutionEvents#leave(Node, VirtualFrame, float)
130 */
131 void notifyLeave(Node astNode, VirtualFrame frame, float result);
132
133 /**
134 * @see ExecutionEvents#leave(Node, VirtualFrame, double)
135 */
136 void notifyLeave(Node astNode, VirtualFrame frame, double result);
137
138 /**
139 * @see ExecutionEvents#leave(Node, VirtualFrame, Object)
140 */
141 void notifyLeave(Node astNode, VirtualFrame frame, Object result);
142
143 /**
144 * @see ExecutionEvents#leaveExceptional(Node, VirtualFrame, Exception)
145 */
146 void notifyLeaveExceptional(Node astNode, VirtualFrame frame, Exception e);
147
148 }