comparison graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/ToolNodeInstrumentListener.java @ 20106:2e3cc2a27711

Truffle/Instrumentation: a new flavor of Instrument that lazily provides an AST fragment to be attached/adopted directly into a running AST, and to which execution event notifications will be routed. Important use cases so far include conditional breakpoints (with optimizeable conditions) and Ruby set_trace_func.
author Michael Van De Vanter <michael.van.de.vanter@oracle.com>
date Tue, 31 Mar 2015 19:01:07 -0700
parents
children
comparison
equal deleted inserted replaced
20105:e73096245a4c 20106:2e3cc2a27711
1 /*
2 * Copyright (c) 2015, 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 /**
28 * Instrument listener for a tool that works by providing an AST to be attached/adopted directly
29 * into the AST.
30 */
31 public interface ToolNodeInstrumentListener {
32
33 /**
34 * Receive notification that a probed AST node to which the {@link Instrument} is attached is
35 * about to be executed for the first time. This is a lazy opportunity for the tool to
36 * optionally add the root of a newly created AST fragment that will be attached/adopted
37 * directly into the executing AST. The new AST fragment will immediately begin receiving
38 * {@link InstrumentationNode.TruffleEvents}, beginning with the current execution event.
39 * <p>
40 * AST fragments must be written to Truffle conventions. Some of these conventions are
41 * especially important if the fragment is to be fully optimized along with it's new parent AST.
42 * <p>
43 * If this method returns {@code null} then it will be called again the next time the probed
44 * node is about to be executed.
45 * <p>
46 * In some situations, this method will be called more than once for a particular Probe, and a
47 * new instance must be supplied each time. Each instance will be attached at the equivalent
48 * location in clones of the AST, and so should be behave as if equivalent for most purposes.
49 * <p>
50 * In some situations the AST fragment supplied by this method maybe cloned for attachment to
51 * equivalent locations in cloned AST, so care should be taken about any state local to each
52 * instance of the AST fragment.
53 *
54 * @see Instrument
55 */
56 ToolNode getToolNode(Probe probe);
57
58 }