annotate graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Instrument.java @ 21355:442b57a7f208

Truffle/Instrumentation: change the signature for creation of Advanced instruments, refactor how the callback listener is managed.
author Michael Van De Vanter <michael.van.de.vanter@oracle.com>
date Tue, 12 May 2015 16:06:00 -0700
parents 575032310b2c
children e34bc00733d1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15279
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
1 /*
18985
867058575979 Truffle: Improved support for "probing" AST nodes:
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18485
diff changeset
2 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
15279
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
4 *
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation. Oracle designates this
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
8 * particular file as subject to the "Classpath" exception as provided
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
9 * by Oracle in the LICENSE file that accompanied this code.
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
10 *
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
11 * This code is distributed in the hope that it will be useful, but WITHOUT
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
14 * version 2 for more details (a copy is included in the LICENSE file that
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
15 * accompanied this code).
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
16 *
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License version
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
18 * 2 along with this work; if not, write to the Free Software Foundation,
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
20 *
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
22 * or visit www.oracle.com if you need additional information or have any
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
23 * questions.
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
24 */
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
25 package com.oracle.truffle.api.instrument;
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
26
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
27 import com.oracle.truffle.api.*;
15450
be0c151d912b Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15279
diff changeset
28 import com.oracle.truffle.api.frame.*;
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
29 import com.oracle.truffle.api.instrument.InstrumentationNode.TruffleEvents;
15450
be0c151d912b Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15279
diff changeset
30 import com.oracle.truffle.api.nodes.*;
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
31 import com.oracle.truffle.api.source.*;
15450
be0c151d912b Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15279
diff changeset
32
20908
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20897
diff changeset
33 // TODO (mlvdv) these statics should not be global. Move them to some kind of context.
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20897
diff changeset
34 // TODO (mlvdv) migrate factory into .impl (together with Probe)? break out nested classes?
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20897
diff changeset
35
15279
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
36 /**
20897
ca13a009e38b Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20891
diff changeset
37 * A <em>binding</em> between:
15450
be0c151d912b Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15279
diff changeset
38 * <ol>
20897
ca13a009e38b Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20891
diff changeset
39 * <li>A {@link Probe}: a source of <em>execution events</em> taking place at a program location in
ca13a009e38b Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20891
diff changeset
40 * an executing Truffle AST, and</li>
ca13a009e38b Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20891
diff changeset
41 * <li>A <em>listener</em>: a consumer of execution events on behalf of an external client.
15450
be0c151d912b Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15279
diff changeset
42 * </ol>
be0c151d912b Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15279
diff changeset
43 * <p>
20897
ca13a009e38b Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20891
diff changeset
44 * Client-oriented documentation for the use of Instruments is available online at <a
20908
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20897
diff changeset
45 * HREF="https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events"
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20897
diff changeset
46 * >https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events</a>
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
47 * <p>
20897
ca13a009e38b Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20891
diff changeset
48 * The implementation of Instruments is complicated by the requirement that Truffle be able to clone
ca13a009e38b Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20891
diff changeset
49 * ASTs at any time. In particular, any instrumentation-supporting Nodes that have been attached to
ca13a009e38b Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20891
diff changeset
50 * an AST must be cloned along with the AST: AST clones are not permitted to share Nodes.
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
51 * <p>
20897
ca13a009e38b Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20891
diff changeset
52 * AST cloning is intended to be as <em>transparent</em> as possible to clients. This is encouraged
ca13a009e38b Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20891
diff changeset
53 * by providing the {@link SimpleInstrumentListener} for clients that need know nothing more than
ca13a009e38b Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20891
diff changeset
54 * the properties associated with a Probe: it's {@link SourceSection} and any associated instances
ca13a009e38b Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20891
diff changeset
55 * of {@link SyntaxTag}.
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
56 * <p>
20897
ca13a009e38b Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20891
diff changeset
57 * AST cloning is <em>not transparent</em> to clients that use the
ca13a009e38b Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20891
diff changeset
58 * {@link StandardInstrumentListener}, since those event methods identify the concrete Node instance
ca13a009e38b Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20891
diff changeset
59 * (and thus the AST instance) where the event takes place.
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
60 * <p>
20897
ca13a009e38b Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20891
diff changeset
61 * <h4>Implementation Notes: the Life Cycle of an {@link Instrument} at a {@link Probe}</h4>
15779
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15605
diff changeset
62 * <p>
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
63 * <ul>
20897
ca13a009e38b Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20891
diff changeset
64 * <li>A new Instrument is created in permanent association with a client-provided
ca13a009e38b Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20891
diff changeset
65 * <em>listener.</em></li>
20908
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20897
diff changeset
66 *
20897
ca13a009e38b Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20891
diff changeset
67 * <li>Multiple Instruments may share a single listener.</li>
20908
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20897
diff changeset
68 *
20897
ca13a009e38b Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20891
diff changeset
69 * <li>An Instrument does nothing until it is {@linkplain Probe#attach(Instrument) attached} to a
ca13a009e38b Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20891
diff changeset
70 * Probe, at which time the Instrument begins routing execution events from the Probe's AST location
ca13a009e38b Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20891
diff changeset
71 * to the Instrument's listener.</li>
20908
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20897
diff changeset
72 *
20897
ca13a009e38b Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20891
diff changeset
73 * <li>Neither Instruments nor Probes are {@link Node}s.</li>
20908
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20897
diff changeset
74 *
20897
ca13a009e38b Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20891
diff changeset
75 * <li>A Probe has a single source-based location in an AST, but manages a separate
ca13a009e38b Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20891
diff changeset
76 * <em>instrumentation chain</em> of Nodes at the equivalent location in each clone of the AST.</li>
ca13a009e38b Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20891
diff changeset
77 * <li>When a probed AST is cloned, the instrumentation chain associated with each Probe is cloned
ca13a009e38b Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20891
diff changeset
78 * along with the rest of the AST.</li>
20908
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20897
diff changeset
79 *
20897
ca13a009e38b Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20891
diff changeset
80 * <li>When a new Instrument (for example an instance of {@link SimpleInstrument} is attached to a
ca13a009e38b Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20891
diff changeset
81 * Probe, the Instrument inserts a new instance of its private Node type,
ca13a009e38b Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20891
diff changeset
82 * {@link SimpleInstrument.SimpleInstrumentNode}, into <em>each of the instrument chains</em>
ca13a009e38b Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20891
diff changeset
83 * managed by the Probe, i.e. one node instance per existing clone of the AST.</li>
20908
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20897
diff changeset
84 *
20897
ca13a009e38b Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20891
diff changeset
85 * <li>If an Instrument is attached to a Probe in an AST that subsequently gets cloned, then the
ca13a009e38b Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20891
diff changeset
86 * Instrument's private Node type will be cloned along with the rest of the the AST.</li>
ca13a009e38b Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20891
diff changeset
87 * <li>Each Instrument's private Node type is a dynamic inner class whose only state is in the
ca13a009e38b Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20891
diff changeset
88 * shared (outer) Instrument instance; that state includes a reference to the Instrument's listener.
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
89 * </li>
20908
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20897
diff changeset
90 *
20897
ca13a009e38b Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20891
diff changeset
91 * <li>When an Instrument that has been attached to a Probe is {@linkplain #dispose() disposed}, the
ca13a009e38b Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20891
diff changeset
92 * Instrument searches every instrument chain associated with the Probe and removes the instance of
ca13a009e38b Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20891
diff changeset
93 * its private Node type.</li>
20908
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20897
diff changeset
94 *
20897
ca13a009e38b Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20891
diff changeset
95 * <li>Attaching and disposing an Instrument at a Probe <em>deoptimizes</em> any compilations of the
ca13a009e38b Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20891
diff changeset
96 * AST.</li>
20908
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20897
diff changeset
97 *
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
98 * </ul>
15450
be0c151d912b Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15279
diff changeset
99 *
be0c151d912b Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15279
diff changeset
100 * @see Probe
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
101 * @see TruffleEvents
15279
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
102 */
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
103 public abstract class Instrument {
15450
be0c151d912b Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15279
diff changeset
104
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
105 /**
21181
78a4b44420cf Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20909
diff changeset
106 * Creates a <em>Simple Instrument</em>: this Instrument routes execution events to a
78a4b44420cf Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20909
diff changeset
107 * client-provided listener.
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
108 *
21181
78a4b44420cf Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20909
diff changeset
109 * @param listener a listener for execution events
78a4b44420cf Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20909
diff changeset
110 * @param instrumentInfo optional description of the instrument's role, intended for debugging.
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
111 * @return a new instrument, ready for attachment at a probe
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
112 */
20889
73b1844b5b14 Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20885
diff changeset
113 public static Instrument create(SimpleInstrumentListener listener, String instrumentInfo) {
73b1844b5b14 Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20885
diff changeset
114 return new SimpleInstrument(listener, instrumentInfo);
15450
be0c151d912b Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15279
diff changeset
115 }
be0c151d912b Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15279
diff changeset
116
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
117 /**
21181
78a4b44420cf Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20909
diff changeset
118 * Creates a <em>Standard Instrument</em>: this Instrument routes execution events, together
78a4b44420cf Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20909
diff changeset
119 * with access to Truffle execution state, to a client-provided listener.
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
120 *
21181
78a4b44420cf Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20909
diff changeset
121 * @param standardListener a listener for execution events and execution state
78a4b44420cf Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20909
diff changeset
122 * @param instrumentInfo optional description of the instrument's role, intended for debugging.
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
123 * @return a new instrument, ready for attachment at a probe
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
124 */
20890
263ab98b3bf0 Truffle/Instrumentation: rename ASTInstrumentListener to StandardInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
125 public static Instrument create(StandardInstrumentListener standardListener, String instrumentInfo) {
263ab98b3bf0 Truffle/Instrumentation: rename ASTInstrumentListener to StandardInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
126 return new StandardInstrument(standardListener, instrumentInfo);
15450
be0c151d912b Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15279
diff changeset
127 }
be0c151d912b Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15279
diff changeset
128
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
129 /**
21353
876e710523c5 Truffle/Instrumentation: rename "Tool Eval" Instrument kind to "Advanced" Instrument kind
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21302
diff changeset
130 * Creates an <em>Advanced Instrument</em>: this Instrument executes efficiently, subject to
21181
78a4b44420cf Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20909
diff changeset
131 * full Truffle optimization, a client-provided AST fragment every time the Probed node is
78a4b44420cf Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20909
diff changeset
132 * entered.
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
133 *
21355
442b57a7f208 Truffle/Instrumentation: change the signature for creation of Advanced instruments, refactor how the callback listener is managed.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21354
diff changeset
134 * @param resultListener optional client callback for results/failure notification
21353
876e710523c5 Truffle/Instrumentation: rename "Tool Eval" Instrument kind to "Advanced" Instrument kind
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21302
diff changeset
135 * @param rootFactory provider of AST fragments on behalf of the client
21181
78a4b44420cf Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20909
diff changeset
136 * @param instrumentInfo optional description of the instrument's role, intended for debugging.
78a4b44420cf Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20909
diff changeset
137 * @return a new instrument, ready for attachment at a probe
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
138 */
21355
442b57a7f208 Truffle/Instrumentation: change the signature for creation of Advanced instruments, refactor how the callback listener is managed.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21354
diff changeset
139 public static Instrument create(AdvancedInstrumentResultListener resultListener, AdvancedInstrumentRootFactory rootFactory, String instrumentInfo) {
442b57a7f208 Truffle/Instrumentation: change the signature for creation of Advanced instruments, refactor how the callback listener is managed.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21354
diff changeset
140 return new AdvancedInstrument(resultListener, rootFactory, instrumentInfo);
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
141 }
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
142
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
143 // TODO (mlvdv) experimental
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
144 /**
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
145 * For implementation testing.
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
146 */
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
147 public static Instrument create(TruffleOptListener listener) {
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
148 return new TruffleOptInstrument(listener, null);
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
149 }
15450
be0c151d912b Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15279
diff changeset
150
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
151 /**
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
152 * Has this instrument been disposed? stays true once set.
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
153 */
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
154 private boolean isDisposed = false;
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
155
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
156 protected Probe probe = null;
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
157
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
158 /**
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
159 * Optional documentation, mainly for debugging.
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
160 */
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
161 private final String instrumentInfo;
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
162
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
163 private Instrument(String instrumentInfo) {
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
164 this.instrumentInfo = instrumentInfo;
15450
be0c151d912b Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15279
diff changeset
165 }
be0c151d912b Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15279
diff changeset
166
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
167 /**
21181
78a4b44420cf Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20909
diff changeset
168 * Gets the {@link Probe} to which this Instrument is currently attached: {@code null} if not
78a4b44420cf Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20909
diff changeset
169 * yet attached to a Probe or if this Instrument has been {@linkplain #dispose() disposed}.
78a4b44420cf Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20909
diff changeset
170 */
78a4b44420cf Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20909
diff changeset
171 public Probe getProbe() {
78a4b44420cf Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20909
diff changeset
172 return probe;
78a4b44420cf Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20909
diff changeset
173 }
78a4b44420cf Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20909
diff changeset
174
78a4b44420cf Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20909
diff changeset
175 /**
78a4b44420cf Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20909
diff changeset
176 * Removes this Instrument from the Probe to which it attached and renders this Instrument
78a4b44420cf Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20909
diff changeset
177 * inert.
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
178 *
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
179 * @throws IllegalStateException if this instrument has already been disposed
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
180 */
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
181 public void dispose() throws IllegalStateException {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
182 if (isDisposed) {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
183 throw new IllegalStateException("Attempt to dispose an already disposed Instrumennt");
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
184 }
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
185 if (probe != null) {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
186 // It's attached
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
187 probe.disposeInstrument(this);
21181
78a4b44420cf Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20909
diff changeset
188 probe = null;
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
189 }
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
190 this.isDisposed = true;
15450
be0c151d912b Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15279
diff changeset
191 }
be0c151d912b Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15279
diff changeset
192
21181
78a4b44420cf Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20909
diff changeset
193 /**
78a4b44420cf Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20909
diff changeset
194 * For internal implementation only.
78a4b44420cf Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20909
diff changeset
195 */
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
196 void setAttachedTo(Probe probe) {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
197 this.probe = probe;
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
198 }
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
199
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
200 /**
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
201 * Has this instrument been disposed and rendered unusable?
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
202 */
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
203 boolean isDisposed() {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
204 return isDisposed;
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
205 }
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
206
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
207 abstract AbstractInstrumentNode addToChain(AbstractInstrumentNode nextNode);
15279
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
208
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
209 /**
20909
f96165ecb6f1 Truffle/Instrumentation: rename the most recently created kind of Instrument, formerly "ToolNodeblahblah...". It is now defined by SpliceInstrumentListener. This listener allows the client to create an instrument that will *splied* a client-supplied AST fragment directly into a Probe's "instrumentation chain", and this directly into the flow of Truffle execution (with full optimization).
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20908
diff changeset
210 * Removes this instrument from an instrument chain.
f96165ecb6f1 Truffle/Instrumentation: rename the most recently created kind of Instrument, formerly "ToolNodeblahblah...". It is now defined by SpliceInstrumentListener. This listener allows the client to create an instrument that will *splied* a client-supplied AST fragment directly into a Probe's "instrumentation chain", and this directly into the flow of Truffle execution (with full optimization).
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20908
diff changeset
211 */
f96165ecb6f1 Truffle/Instrumentation: rename the most recently created kind of Instrument, formerly "ToolNodeblahblah...". It is now defined by SpliceInstrumentListener. This listener allows the client to create an instrument that will *splied* a client-supplied AST fragment directly into a Probe's "instrumentation chain", and this directly into the flow of Truffle execution (with full optimization).
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20908
diff changeset
212 abstract AbstractInstrumentNode removeFromChain(AbstractInstrumentNode instrumentNode);
f96165ecb6f1 Truffle/Instrumentation: rename the most recently created kind of Instrument, formerly "ToolNodeblahblah...". It is now defined by SpliceInstrumentListener. This listener allows the client to create an instrument that will *splied* a client-supplied AST fragment directly into a Probe's "instrumentation chain", and this directly into the flow of Truffle execution (with full optimization).
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20908
diff changeset
213
f96165ecb6f1 Truffle/Instrumentation: rename the most recently created kind of Instrument, formerly "ToolNodeblahblah...". It is now defined by SpliceInstrumentListener. This listener allows the client to create an instrument that will *splied* a client-supplied AST fragment directly into a Probe's "instrumentation chain", and this directly into the flow of Truffle execution (with full optimization).
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20908
diff changeset
214 /**
20889
73b1844b5b14 Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20885
diff changeset
215 * An instrument that propagates events to an instance of {@link SimpleInstrumentListener}.
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
216 */
20889
73b1844b5b14 Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20885
diff changeset
217 private static final class SimpleInstrument extends Instrument {
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
218
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
219 /**
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
220 * Tool-supplied listener for events.
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
221 */
20889
73b1844b5b14 Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20885
diff changeset
222 private final SimpleInstrumentListener simpleListener;
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
223
20889
73b1844b5b14 Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20885
diff changeset
224 private SimpleInstrument(SimpleInstrumentListener simpleListener, String instrumentInfo) {
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
225 super(instrumentInfo);
20889
73b1844b5b14 Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20885
diff changeset
226 this.simpleListener = simpleListener;
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
227 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
228
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
229 @Override
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
230 AbstractInstrumentNode addToChain(AbstractInstrumentNode nextNode) {
20889
73b1844b5b14 Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20885
diff changeset
231 return new SimpleInstrumentNode(nextNode);
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
232 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
233
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
234 @Override
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
235 AbstractInstrumentNode removeFromChain(AbstractInstrumentNode instrumentNode) {
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
236 boolean found = false;
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
237 if (instrumentNode != null) {
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
238 if (instrumentNode.getInstrument() == this) {
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
239 // Found the match at the head of the chain
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
240 return instrumentNode.nextInstrumentNode;
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
241 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
242 // Match not at the head of the chain; remove it.
20889
73b1844b5b14 Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20885
diff changeset
243 found = instrumentNode.removeFromChain(SimpleInstrument.this);
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
244 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
245 if (!found) {
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
246 throw new IllegalStateException("Couldn't find instrument node to remove: " + this);
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
247 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
248 return instrumentNode;
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
249 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
250
21181
78a4b44420cf Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20909
diff changeset
251 /**
78a4b44420cf Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20909
diff changeset
252 * Node that implements a {@link SimpleInstrument} in a particular AST.
78a4b44420cf Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20909
diff changeset
253 */
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
254 @NodeInfo(cost = NodeCost.NONE)
20889
73b1844b5b14 Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20885
diff changeset
255 private final class SimpleInstrumentNode extends AbstractInstrumentNode {
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
256
20889
73b1844b5b14 Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20885
diff changeset
257 private SimpleInstrumentNode(AbstractInstrumentNode nextNode) {
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
258 super(nextNode);
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
259 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
260
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
261 public void enter(Node node, VirtualFrame vFrame) {
20889
73b1844b5b14 Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20885
diff changeset
262 SimpleInstrument.this.simpleListener.enter(SimpleInstrument.this.probe);
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
263 if (nextInstrumentNode != null) {
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
264 nextInstrumentNode.enter(node, vFrame);
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
265 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
266 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
267
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
268 public void returnVoid(Node node, VirtualFrame vFrame) {
20889
73b1844b5b14 Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20885
diff changeset
269 SimpleInstrument.this.simpleListener.returnVoid(SimpleInstrument.this.probe);
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
270 if (nextInstrumentNode != null) {
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
271 nextInstrumentNode.returnVoid(node, vFrame);
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
272 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
273 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
274
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
275 public void returnValue(Node node, VirtualFrame vFrame, Object result) {
20889
73b1844b5b14 Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20885
diff changeset
276 SimpleInstrument.this.simpleListener.returnValue(SimpleInstrument.this.probe, result);
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
277 if (nextInstrumentNode != null) {
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
278 nextInstrumentNode.returnValue(node, vFrame, result);
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
279 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
280 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
281
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
282 public void returnExceptional(Node node, VirtualFrame vFrame, Exception exception) {
20889
73b1844b5b14 Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20885
diff changeset
283 SimpleInstrument.this.simpleListener.returnExceptional(SimpleInstrument.this.probe, exception);
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
284 if (nextInstrumentNode != null) {
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
285 nextInstrumentNode.returnExceptional(node, vFrame, exception);
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
286 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
287 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
288
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
289 public String instrumentationInfo() {
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
290 final String info = getInstrumentInfo();
20889
73b1844b5b14 Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20885
diff changeset
291 return info != null ? info : simpleListener.getClass().getSimpleName();
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
292 }
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
293 }
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
294 }
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
295
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
296 /**
20890
263ab98b3bf0 Truffle/Instrumentation: rename ASTInstrumentListener to StandardInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
297 * An instrument that propagates events to an instance of {@link StandardInstrumentListener}.
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
298 */
20890
263ab98b3bf0 Truffle/Instrumentation: rename ASTInstrumentListener to StandardInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
299 private static final class StandardInstrument extends Instrument {
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
300
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
301 /**
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
302 * Tool-supplied listener for AST events.
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
303 */
20890
263ab98b3bf0 Truffle/Instrumentation: rename ASTInstrumentListener to StandardInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
304 private final StandardInstrumentListener standardListener;
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
305
20890
263ab98b3bf0 Truffle/Instrumentation: rename ASTInstrumentListener to StandardInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
306 private StandardInstrument(StandardInstrumentListener standardListener, String instrumentInfo) {
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
307 super(instrumentInfo);
20890
263ab98b3bf0 Truffle/Instrumentation: rename ASTInstrumentListener to StandardInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
308 this.standardListener = standardListener;
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
309 }
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
310
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
311 @Override
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
312 AbstractInstrumentNode addToChain(AbstractInstrumentNode nextNode) {
20890
263ab98b3bf0 Truffle/Instrumentation: rename ASTInstrumentListener to StandardInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
313 return new StandardInstrumentNode(nextNode);
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
314 }
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
315
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
316 @Override
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
317 AbstractInstrumentNode removeFromChain(AbstractInstrumentNode instrumentNode) {
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
318 boolean found = false;
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
319 if (instrumentNode != null) {
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
320 if (instrumentNode.getInstrument() == this) {
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
321 // Found the match at the head of the chain
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
322 return instrumentNode.nextInstrumentNode;
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
323 }
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
324 // Match not at the head of the chain; remove it.
20890
263ab98b3bf0 Truffle/Instrumentation: rename ASTInstrumentListener to StandardInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
325 found = instrumentNode.removeFromChain(StandardInstrument.this);
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
326 }
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
327 if (!found) {
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
328 throw new IllegalStateException("Couldn't find instrument node to remove: " + this);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
329 }
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
330 return instrumentNode;
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
331 }
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
332
21181
78a4b44420cf Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20909
diff changeset
333 /**
78a4b44420cf Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20909
diff changeset
334 * Node that implements a {@link StandardInstrument} in a particular AST.
78a4b44420cf Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20909
diff changeset
335 */
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
336 @NodeInfo(cost = NodeCost.NONE)
20890
263ab98b3bf0 Truffle/Instrumentation: rename ASTInstrumentListener to StandardInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
337 private final class StandardInstrumentNode extends AbstractInstrumentNode {
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
338
20890
263ab98b3bf0 Truffle/Instrumentation: rename ASTInstrumentListener to StandardInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
339 private StandardInstrumentNode(AbstractInstrumentNode nextNode) {
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
340 super(nextNode);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
341 }
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
342
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
343 public void enter(Node node, VirtualFrame vFrame) {
20890
263ab98b3bf0 Truffle/Instrumentation: rename ASTInstrumentListener to StandardInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
344 standardListener.enter(StandardInstrument.this.probe, node, vFrame);
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
345 if (nextInstrumentNode != null) {
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
346 nextInstrumentNode.enter(node, vFrame);
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
347 }
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
348 }
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
349
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
350 public void returnVoid(Node node, VirtualFrame vFrame) {
20890
263ab98b3bf0 Truffle/Instrumentation: rename ASTInstrumentListener to StandardInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
351 standardListener.returnVoid(StandardInstrument.this.probe, node, vFrame);
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
352 if (nextInstrumentNode != null) {
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
353 nextInstrumentNode.returnVoid(node, vFrame);
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
354 }
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
355 }
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
356
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
357 public void returnValue(Node node, VirtualFrame vFrame, Object result) {
20890
263ab98b3bf0 Truffle/Instrumentation: rename ASTInstrumentListener to StandardInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
358 standardListener.returnValue(StandardInstrument.this.probe, node, vFrame, result);
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
359 if (nextInstrumentNode != null) {
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
360 nextInstrumentNode.returnValue(node, vFrame, result);
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
361 }
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
362 }
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
363
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
364 public void returnExceptional(Node node, VirtualFrame vFrame, Exception exception) {
20890
263ab98b3bf0 Truffle/Instrumentation: rename ASTInstrumentListener to StandardInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
365 standardListener.returnExceptional(StandardInstrument.this.probe, node, vFrame, exception);
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
366 if (nextInstrumentNode != null) {
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
367 nextInstrumentNode.returnExceptional(node, vFrame, exception);
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
368 }
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
369 }
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
370
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
371 public String instrumentationInfo() {
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
372 final String info = getInstrumentInfo();
20890
263ab98b3bf0 Truffle/Instrumentation: rename ASTInstrumentListener to StandardInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
373 return info != null ? info : standardListener.getClass().getSimpleName();
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
374 }
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
375 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
376 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
377
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
378 /**
21181
78a4b44420cf Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20909
diff changeset
379 * An instrument that allows clients to provide an AST fragment to be executed directly from
78a4b44420cf Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20909
diff changeset
380 * within a Probe's <em>instrumentation chain</em>, and thus directly in the executing Truffle
78a4b44420cf Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20909
diff changeset
381 * AST with potential for full optimization.
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
382 */
21353
876e710523c5 Truffle/Instrumentation: rename "Tool Eval" Instrument kind to "Advanced" Instrument kind
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21302
diff changeset
383 private static final class AdvancedInstrument extends Instrument {
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
384
21355
442b57a7f208 Truffle/Instrumentation: change the signature for creation of Advanced instruments, refactor how the callback listener is managed.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21354
diff changeset
385 private final AdvancedInstrumentResultListener resultListener;
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
386 /**
21181
78a4b44420cf Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20909
diff changeset
387 * Client-provided supplier of new node instances to attach.
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
388 */
21353
876e710523c5 Truffle/Instrumentation: rename "Tool Eval" Instrument kind to "Advanced" Instrument kind
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21302
diff changeset
389 private final AdvancedInstrumentRootFactory rootFactory;
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
390
21355
442b57a7f208 Truffle/Instrumentation: change the signature for creation of Advanced instruments, refactor how the callback listener is managed.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21354
diff changeset
391 private AdvancedInstrument(AdvancedInstrumentResultListener resultListener, AdvancedInstrumentRootFactory rootFactory, String instrumentInfo) {
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
392 super(instrumentInfo);
21355
442b57a7f208 Truffle/Instrumentation: change the signature for creation of Advanced instruments, refactor how the callback listener is managed.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21354
diff changeset
393 this.resultListener = resultListener;
21353
876e710523c5 Truffle/Instrumentation: rename "Tool Eval" Instrument kind to "Advanced" Instrument kind
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21302
diff changeset
394 this.rootFactory = rootFactory;
21181
78a4b44420cf Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20909
diff changeset
395
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
396 }
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
397
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
398 @Override
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
399 AbstractInstrumentNode addToChain(AbstractInstrumentNode nextNode) {
21353
876e710523c5 Truffle/Instrumentation: rename "Tool Eval" Instrument kind to "Advanced" Instrument kind
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21302
diff changeset
400 return new AdvancedInstrumentNode(nextNode);
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
401 }
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
402
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
403 @Override
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
404 AbstractInstrumentNode removeFromChain(AbstractInstrumentNode instrumentNode) {
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
405 boolean found = false;
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
406 if (instrumentNode != null) {
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
407 if (instrumentNode.getInstrument() == this) {
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
408 // Found the match at the head of the chain
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
409 return instrumentNode.nextInstrumentNode;
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
410 }
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
411 // Match not at the head of the chain; remove it.
21353
876e710523c5 Truffle/Instrumentation: rename "Tool Eval" Instrument kind to "Advanced" Instrument kind
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21302
diff changeset
412 found = instrumentNode.removeFromChain(AdvancedInstrument.this);
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
413 }
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
414 if (!found) {
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
415 throw new IllegalStateException("Couldn't find instrument node to remove: " + this);
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
416 }
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
417 return instrumentNode;
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
418 }
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
419
21181
78a4b44420cf Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20909
diff changeset
420 /**
21353
876e710523c5 Truffle/Instrumentation: rename "Tool Eval" Instrument kind to "Advanced" Instrument kind
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21302
diff changeset
421 * Node that implements a {@link AdvancedInstrument} in a particular AST.
21181
78a4b44420cf Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20909
diff changeset
422 */
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
423 @NodeInfo(cost = NodeCost.NONE)
21353
876e710523c5 Truffle/Instrumentation: rename "Tool Eval" Instrument kind to "Advanced" Instrument kind
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21302
diff changeset
424 private final class AdvancedInstrumentNode extends AbstractInstrumentNode {
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
425
21353
876e710523c5 Truffle/Instrumentation: rename "Tool Eval" Instrument kind to "Advanced" Instrument kind
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21302
diff changeset
426 @Child private AdvancedInstrumentRoot instrumentRoot;
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
427
21353
876e710523c5 Truffle/Instrumentation: rename "Tool Eval" Instrument kind to "Advanced" Instrument kind
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21302
diff changeset
428 private AdvancedInstrumentNode(AbstractInstrumentNode nextNode) {
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
429 super(nextNode);
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
430 }
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
431
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
432 public void enter(Node node, VirtualFrame vFrame) {
21353
876e710523c5 Truffle/Instrumentation: rename "Tool Eval" Instrument kind to "Advanced" Instrument kind
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21302
diff changeset
433 if (instrumentRoot == null) {
21355
442b57a7f208 Truffle/Instrumentation: change the signature for creation of Advanced instruments, refactor how the callback listener is managed.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21354
diff changeset
434 try {
442b57a7f208 Truffle/Instrumentation: change the signature for creation of Advanced instruments, refactor how the callback listener is managed.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21354
diff changeset
435 final AdvancedInstrumentRoot newInstrumentRoot = AdvancedInstrument.this.rootFactory.createInstrumentRoot(AdvancedInstrument.this.probe, node);
442b57a7f208 Truffle/Instrumentation: change the signature for creation of Advanced instruments, refactor how the callback listener is managed.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21354
diff changeset
436 if (newInstrumentRoot != null) {
442b57a7f208 Truffle/Instrumentation: change the signature for creation of Advanced instruments, refactor how the callback listener is managed.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21354
diff changeset
437 instrumentRoot = newInstrumentRoot;
442b57a7f208 Truffle/Instrumentation: change the signature for creation of Advanced instruments, refactor how the callback listener is managed.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21354
diff changeset
438 adoptChildren();
442b57a7f208 Truffle/Instrumentation: change the signature for creation of Advanced instruments, refactor how the callback listener is managed.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21354
diff changeset
439 AdvancedInstrument.this.probe.invalidateProbeUnchanged();
442b57a7f208 Truffle/Instrumentation: change the signature for creation of Advanced instruments, refactor how the callback listener is managed.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21354
diff changeset
440 }
442b57a7f208 Truffle/Instrumentation: change the signature for creation of Advanced instruments, refactor how the callback listener is managed.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21354
diff changeset
441 } catch (RuntimeException ex) {
442b57a7f208 Truffle/Instrumentation: change the signature for creation of Advanced instruments, refactor how the callback listener is managed.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21354
diff changeset
442 if (resultListener != null) {
442b57a7f208 Truffle/Instrumentation: change the signature for creation of Advanced instruments, refactor how the callback listener is managed.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21354
diff changeset
443 resultListener.notifyFailure(node, vFrame, ex);
442b57a7f208 Truffle/Instrumentation: change the signature for creation of Advanced instruments, refactor how the callback listener is managed.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21354
diff changeset
444 }
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
445 }
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
446 }
21353
876e710523c5 Truffle/Instrumentation: rename "Tool Eval" Instrument kind to "Advanced" Instrument kind
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21302
diff changeset
447 if (instrumentRoot != null) {
21354
575032310b2c Truffle/Instrumentation: runtime failures executing an AdvancedInstrument root are now reported automatically via a new mehtod onAdvancedInstrumentResultListener.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21353
diff changeset
448 try {
575032310b2c Truffle/Instrumentation: runtime failures executing an AdvancedInstrument root are now reported automatically via a new mehtod onAdvancedInstrumentResultListener.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21353
diff changeset
449 final Object result = instrumentRoot.executeRoot(node, vFrame);
575032310b2c Truffle/Instrumentation: runtime failures executing an AdvancedInstrument root are now reported automatically via a new mehtod onAdvancedInstrumentResultListener.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21353
diff changeset
450 if (resultListener != null) {
575032310b2c Truffle/Instrumentation: runtime failures executing an AdvancedInstrument root are now reported automatically via a new mehtod onAdvancedInstrumentResultListener.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21353
diff changeset
451 resultListener.notifyResult(node, vFrame, result);
575032310b2c Truffle/Instrumentation: runtime failures executing an AdvancedInstrument root are now reported automatically via a new mehtod onAdvancedInstrumentResultListener.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21353
diff changeset
452 }
575032310b2c Truffle/Instrumentation: runtime failures executing an AdvancedInstrument root are now reported automatically via a new mehtod onAdvancedInstrumentResultListener.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21353
diff changeset
453 } catch (RuntimeException ex) {
575032310b2c Truffle/Instrumentation: runtime failures executing an AdvancedInstrument root are now reported automatically via a new mehtod onAdvancedInstrumentResultListener.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21353
diff changeset
454 if (resultListener != null) {
575032310b2c Truffle/Instrumentation: runtime failures executing an AdvancedInstrument root are now reported automatically via a new mehtod onAdvancedInstrumentResultListener.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21353
diff changeset
455 resultListener.notifyFailure(node, vFrame, ex);
575032310b2c Truffle/Instrumentation: runtime failures executing an AdvancedInstrument root are now reported automatically via a new mehtod onAdvancedInstrumentResultListener.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21353
diff changeset
456 }
575032310b2c Truffle/Instrumentation: runtime failures executing an AdvancedInstrument root are now reported automatically via a new mehtod onAdvancedInstrumentResultListener.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21353
diff changeset
457 }
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
458 }
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
459 if (nextInstrumentNode != null) {
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
460 nextInstrumentNode.enter(node, vFrame);
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
461 }
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
462 }
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
463
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
464 public void returnVoid(Node node, VirtualFrame vFrame) {
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
465 if (nextInstrumentNode != null) {
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
466 nextInstrumentNode.returnVoid(node, vFrame);
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
467 }
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
468 }
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
469
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
470 public void returnValue(Node node, VirtualFrame vFrame, Object result) {
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
471 if (nextInstrumentNode != null) {
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
472 nextInstrumentNode.returnValue(node, vFrame, result);
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
473 }
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
474 }
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
475
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
476 public void returnExceptional(Node node, VirtualFrame vFrame, Exception exception) {
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
477 if (nextInstrumentNode != null) {
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
478 nextInstrumentNode.returnExceptional(node, vFrame, exception);
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
479 }
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
480 }
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
481
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
482 public String instrumentationInfo() {
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
483 final String info = getInstrumentInfo();
21353
876e710523c5 Truffle/Instrumentation: rename "Tool Eval" Instrument kind to "Advanced" Instrument kind
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21302
diff changeset
484 return info != null ? info : rootFactory.getClass().getSimpleName();
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
485 }
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
486 }
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
487 }
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
488
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
489 public interface TruffleOptListener {
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
490 void notifyIsCompiled(boolean isCompiled);
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
491 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
492
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
493 private static final class TruffleOptInstrument extends Instrument {
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
494
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
495 private final TruffleOptListener toolOptListener;
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
496
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
497 private TruffleOptInstrument(TruffleOptListener listener, String instrumentInfo) {
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
498 super(instrumentInfo);
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
499 this.toolOptListener = listener;
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
500 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
501
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
502 @Override
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
503 AbstractInstrumentNode addToChain(AbstractInstrumentNode nextNode) {
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
504 return new TruffleOptInstrumentNode(nextNode);
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
505 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
506
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
507 @Override
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
508 AbstractInstrumentNode removeFromChain(AbstractInstrumentNode instrumentNode) {
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
509 boolean found = false;
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
510 if (instrumentNode != null) {
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
511 if (instrumentNode.getInstrument() == this) {
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
512 // Found the match at the head of the chain
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
513 return instrumentNode.nextInstrumentNode;
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
514 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
515 // Match not at the head of the chain; remove it.
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
516 found = instrumentNode.removeFromChain(TruffleOptInstrument.this);
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
517 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
518 if (!found) {
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
519 throw new IllegalStateException("Couldn't find instrument node to remove: " + this);
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
520 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
521 return instrumentNode;
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
522 }
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
523
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
524 @NodeInfo(cost = NodeCost.NONE)
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
525 private final class TruffleOptInstrumentNode extends AbstractInstrumentNode {
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
526
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
527 private boolean isCompiled;
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
528
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
529 private TruffleOptInstrumentNode(AbstractInstrumentNode nextNode) {
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
530 super(nextNode);
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
531 this.isCompiled = CompilerDirectives.inCompiledCode();
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
532 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
533
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
534 public void enter(Node node, VirtualFrame vFrame) {
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
535 if (this.isCompiled != CompilerDirectives.inCompiledCode()) {
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
536 this.isCompiled = CompilerDirectives.inCompiledCode();
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
537 TruffleOptInstrument.this.toolOptListener.notifyIsCompiled(this.isCompiled);
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
538 }
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
539 if (nextInstrumentNode != null) {
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
540 nextInstrumentNode.enter(node, vFrame);
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
541 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
542 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
543
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
544 public void returnVoid(Node node, VirtualFrame vFrame) {
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
545 if (nextInstrumentNode != null) {
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
546 nextInstrumentNode.returnVoid(node, vFrame);
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
547 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
548 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
549
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
550 public void returnValue(Node node, VirtualFrame vFrame, Object result) {
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
551 if (nextInstrumentNode != null) {
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
552 nextInstrumentNode.returnValue(node, vFrame, result);
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
553 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
554 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
555
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
556 public void returnExceptional(Node node, VirtualFrame vFrame, Exception exception) {
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
557 if (nextInstrumentNode != null) {
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
558 nextInstrumentNode.returnExceptional(node, vFrame, exception);
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
559 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
560 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
561
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
562 public String instrumentationInfo() {
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
563 final String info = getInstrumentInfo();
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
564 return info != null ? info : toolOptListener.getClass().getSimpleName();
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
565 }
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
566 }
15450
be0c151d912b Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15279
diff changeset
567 }
be0c151d912b Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15279
diff changeset
568
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
569 @NodeInfo(cost = NodeCost.NONE)
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
570 abstract class AbstractInstrumentNode extends Node implements TruffleEvents, InstrumentationNode {
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
571
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
572 @Child protected AbstractInstrumentNode nextInstrumentNode;
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
573
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19645
diff changeset
574 protected AbstractInstrumentNode(AbstractInstrumentNode nextNode) {
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
575 this.nextInstrumentNode = nextNode;
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
576 }
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
577
18985
867058575979 Truffle: Improved support for "probing" AST nodes:
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18485
diff changeset
578 @Override
867058575979 Truffle: Improved support for "probing" AST nodes:
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18485
diff changeset
579 public boolean isInstrumentable() {
867058575979 Truffle: Improved support for "probing" AST nodes:
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18485
diff changeset
580 return false;
867058575979 Truffle: Improved support for "probing" AST nodes:
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18485
diff changeset
581 }
867058575979 Truffle: Improved support for "probing" AST nodes:
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18485
diff changeset
582
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
583 /**
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
584 * Gets the instrument that created this node.
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
585 */
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
586 private Instrument getInstrument() {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
587 return Instrument.this;
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
588 }
15450
be0c151d912b Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15279
diff changeset
589
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
590 /**
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
591 * Removes the node from this chain that was added by a particular instrument, assuming that
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
592 * the head of the chain is not the one to be replaced. This is awkward, but is required
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
593 * because {@link Node#replace(Node)} won't take a {@code null} argument. This doesn't work
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
594 * for the tail of the list, which would be replacing itself with null. So the replacement
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
595 * must be directed the parent of the node being removed.
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
596 */
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
597 private boolean removeFromChain(Instrument instrument) {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
598 assert getInstrument() != instrument;
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
599 if (nextInstrumentNode == null) {
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
600 return false;
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
601 }
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
602 if (nextInstrumentNode.getInstrument() == instrument) {
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
603 // Next is the one to remove
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
604 if (nextInstrumentNode.nextInstrumentNode == null) {
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
605 // Next is at the tail; just forget
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
606 nextInstrumentNode = null;
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
607 } else {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
608 // Replace next with its successor
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
609 nextInstrumentNode.replace(nextInstrumentNode.nextInstrumentNode);
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
610 }
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
611 return true;
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
612 }
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.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
613 return nextInstrumentNode.removeFromChain(instrument);
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
614 }
15450
be0c151d912b Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15279
diff changeset
615
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
616 protected String getInstrumentInfo() {
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
617 return Instrument.this.instrumentInfo;
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18131
diff changeset
618 }
15450
be0c151d912b Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15279
diff changeset
619 }
15279
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
620 }