annotate truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Instrument.java @ 21972:ff6f34159b8a

Providing package-info for most of API packages. Feel free to provide your package-info.java for anything that has API in its name.
author Jaroslav Tulach <jaroslav.tulach@oracle.com>
date Tue, 23 Jun 2015 12:44:41 +0200
parents 9c8c0937da41
children 5bc7f7b867ab
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.
21406
b4aca5ec3f10 Truffle/Instrumentation: Javadoc commentary
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21358
diff changeset
34 // TODO (mlvdv) migrate factory (together with Probe)? break out nested classes?
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
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 *
21972
ff6f34159b8a Providing package-info for most of API packages. Feel free to provide your package-info.java for anything that has API in its name.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
80 * <li>When a new Instrument (for example an instance created by
ff6f34159b8a Providing package-info for most of API packages. Feel free to provide your package-info.java for anything that has API in its name.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
81 * {@link Instrument#create(com.oracle.truffle.api.instrument.SimpleInstrumentListener, java.lang.String)}
ff6f34159b8a Providing package-info for most of API packages. Feel free to provide your package-info.java for anything that has API in its name.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
82 * is attached to a Probe, the Instrument inserts a new instance of its private Node type into
ff6f34159b8a Providing package-info for most of API packages. Feel free to provide your package-info.java for anything that has API in its name.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
83 * <em>each of the instrument chains</em> managed by the Probe, i.e. one node instance per existing
ff6f34159b8a Providing package-info for most of API packages. Feel free to provide your package-info.java for anything that has API in its name.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
84 * 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
85 *
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
86 * <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
87 * 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
88 * <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
89 * 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
90 * </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
91 *
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
92 * <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
93 * 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
94 * 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
95 *
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
96 * <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
97 * 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
98 *
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
99 * </ul>
15450
be0c151d912b Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15279
diff changeset
100 *
be0c151d912b Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15279
diff changeset
101 * @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
102 * @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
103 */
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
104 public abstract class Instrument {
15450
be0c151d912b Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15279
diff changeset
105
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
106 /**
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
107 * 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
108 * 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
109 *
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
110 * @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
111 * @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
112 * @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
113 */
20889
73b1844b5b14 Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20885
diff changeset
114 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
115 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
116 }
be0c151d912b Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15279
diff changeset
117
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
118 /**
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
119 * 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
120 * 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
121 *
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
122 * @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
123 * @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
124 * @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
125 */
20890
263ab98b3bf0 Truffle/Instrumentation: rename ASTInstrumentListener to StandardInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
126 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
127 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
128 }
be0c151d912b Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15279
diff changeset
129
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
130 /**
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
131 * 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
132 * 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
133 * entered.
21407
36285949c1d5 Truffle/Instrumentation: some commentary and a new AST printing method needed for tools.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21406
diff changeset
134 * <p>
36285949c1d5 Truffle/Instrumentation: some commentary and a new AST printing method needed for tools.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21406
diff changeset
135 * Any {@link RuntimeException} thrown by execution of the fragment is caught by the framework
36285949c1d5 Truffle/Instrumentation: some commentary and a new AST printing method needed for tools.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21406
diff changeset
136 * and reported to the listener; there is no other notification.
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
137 *
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
138 * @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
139 * @param rootFactory provider of AST fragments on behalf of the client
21356
e34bc00733d1 Truffle/Instrumentation: an Advanced Instrument can now be created that requires the evaluation result be of a specified type, reporting a failure if not
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21355
diff changeset
140 * @param requiredResultType optional requirement, any non-assignable result is reported to the
e34bc00733d1 Truffle/Instrumentation: an Advanced Instrument can now be created that requires the evaluation result be of a specified type, reporting a failure if not
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21355
diff changeset
141 * the listener, if any, as a failure
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
142 * @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
143 * @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
144 */
21356
e34bc00733d1 Truffle/Instrumentation: an Advanced Instrument can now be created that requires the evaluation result be of a specified type, reporting a failure if not
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21355
diff changeset
145 public static Instrument create(AdvancedInstrumentResultListener resultListener, AdvancedInstrumentRootFactory rootFactory, Class<?> requiredResultType, String instrumentInfo) {
e34bc00733d1 Truffle/Instrumentation: an Advanced Instrument can now be created that requires the evaluation result be of a specified type, reporting a failure if not
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21355
diff changeset
146 return new AdvancedInstrument(resultListener, rootFactory, requiredResultType, 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
147 }
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
148
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
149 // 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
150 /**
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
151 * 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
152 */
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
153 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
154 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
155 }
15450
be0c151d912b Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15279
diff changeset
156
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 /**
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
158 * 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
159 */
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
160 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
161
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
162 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
163
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
164 /**
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
165 * 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
166 */
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
167 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
168
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
169 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
170 this.instrumentInfo = instrumentInfo;
15450
be0c151d912b Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15279
diff changeset
171 }
be0c151d912b Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15279
diff changeset
172
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
173 /**
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
174 * 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
175 * 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
176 */
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 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
178 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
179 }
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
180
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
181 /**
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
182 * 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
183 * 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
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 * @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
186 */
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 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
188 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
189 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
190 }
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
191 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
192 // 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
193 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
194 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
195 }
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 this.isDisposed = true;
15450
be0c151d912b Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15279
diff changeset
197 }
be0c151d912b Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15279
diff changeset
198
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
199 /**
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
200 * 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
201 */
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
202 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
203 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
204 }
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 /**
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
207 * 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
208 */
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 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
210 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
211 }
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
212
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
213 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
214
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
215 /**
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
216 * 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
217 */
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
218 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
219
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
220 /**
20889
73b1844b5b14 Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20885
diff changeset
221 * 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
222 */
20889
73b1844b5b14 Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20885
diff changeset
223 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
224
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
225 /**
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
226 * 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
227 */
20889
73b1844b5b14 Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20885
diff changeset
228 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
229
20889
73b1844b5b14 Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20885
diff changeset
230 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
231 super(instrumentInfo);
20889
73b1844b5b14 Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20885
diff changeset
232 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
233 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
234
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
235 @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
236 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
237 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
238 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
239
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
240 @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
241 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
242 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
243 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
244 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
245 // 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
246 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
247 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
248 // 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
249 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
250 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
251 if (!found) {
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
252 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
253 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
254 return instrumentNode;
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
255 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
256
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
257 /**
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
258 * 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
259 */
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
260 @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
261 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
262
20889
73b1844b5b14 Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20885
diff changeset
263 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
264 super(nextNode);
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 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
268 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
269 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
270 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
271 }
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 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
275 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
276 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
277 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
278 }
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 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
282 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
283 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
284 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
285 }
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 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
289 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
290 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
291 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
292 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
293 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
294
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
295 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
296 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
297 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
298 }
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
299 }
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 /**
20890
263ab98b3bf0 Truffle/Instrumentation: rename ASTInstrumentListener to StandardInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
303 * 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
304 */
20890
263ab98b3bf0 Truffle/Instrumentation: rename ASTInstrumentListener to StandardInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
305 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
306
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 /**
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
308 * 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
309 */
20890
263ab98b3bf0 Truffle/Instrumentation: rename ASTInstrumentListener to StandardInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
310 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
311
20890
263ab98b3bf0 Truffle/Instrumentation: rename ASTInstrumentListener to StandardInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
312 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
313 super(instrumentInfo);
20890
263ab98b3bf0 Truffle/Instrumentation: rename ASTInstrumentListener to StandardInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
314 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
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
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 @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
318 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
319 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
320 }
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
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
322 @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
323 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
324 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
325 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
326 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
327 // 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
328 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
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 // 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
331 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
332 }
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
333 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
334 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
335 }
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 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
337 }
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
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
339 /**
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
340 * 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
341 */
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
342 @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
343 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
344
20890
263ab98b3bf0 Truffle/Instrumentation: rename ASTInstrumentListener to StandardInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
345 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
346 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
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 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
350 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
351 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
352 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
353 }
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 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
357 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
358 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
359 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
360 }
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 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
364 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
365 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
366 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
367 }
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 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
371 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
372 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
373 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
374 }
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
375 }
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
376
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
377 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
378 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
379 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
380 }
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
381 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
382 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
383
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 /**
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
385 * 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
386 * 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
387 * 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
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 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
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 final AdvancedInstrumentResultListener 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
392 private final AdvancedInstrumentRootFactory rootFactory;
21356
e34bc00733d1 Truffle/Instrumentation: an Advanced Instrument can now be created that requires the evaluation result be of a specified type, reporting a failure if not
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21355
diff changeset
393 private final Class<?> requiredResultType;
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
394
21356
e34bc00733d1 Truffle/Instrumentation: an Advanced Instrument can now be created that requires the evaluation result be of a specified type, reporting a failure if not
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21355
diff changeset
395 private AdvancedInstrument(AdvancedInstrumentResultListener resultListener, AdvancedInstrumentRootFactory rootFactory, Class<?> requiredResultType, 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
396 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
397 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
398 this.rootFactory = rootFactory;
21356
e34bc00733d1 Truffle/Instrumentation: an Advanced Instrument can now be created that requires the evaluation result be of a specified type, reporting a failure if not
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21355
diff changeset
399 this.requiredResultType = requiredResultType;
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
400 }
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 @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
403 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
404 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
405 }
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
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 @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
408 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
409 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
410 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
411 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
412 // 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
413 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
414 }
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 // 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
416 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
417 }
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 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
419 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
420 }
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
421 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
422 }
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
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
424 /**
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
425 * 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
426 */
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 @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
428 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
429
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
430 @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
431
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
432 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
433 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
434 }
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
435
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
436 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
437 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
438 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
439 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
440 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
441 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
442 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
443 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
444 }
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
445 } 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
446 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
447 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
448 }
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
449 }
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
450 }
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
451 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
452 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
453 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
454 if (resultListener != null) {
21356
e34bc00733d1 Truffle/Instrumentation: an Advanced Instrument can now be created that requires the evaluation result be of a specified type, reporting a failure if not
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21355
diff changeset
455 checkResultType(result);
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
456 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
457 }
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
458 } 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
459 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
460 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
461 }
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
462 }
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
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 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
465 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
466 }
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
21356
e34bc00733d1 Truffle/Instrumentation: an Advanced Instrument can now be created that requires the evaluation result be of a specified type, reporting a failure if not
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21355
diff changeset
469 private void checkResultType(Object result) {
e34bc00733d1 Truffle/Instrumentation: an Advanced Instrument can now be created that requires the evaluation result be of a specified type, reporting a failure if not
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21355
diff changeset
470 if (requiredResultType == null) {
e34bc00733d1 Truffle/Instrumentation: an Advanced Instrument can now be created that requires the evaluation result be of a specified type, reporting a failure if not
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21355
diff changeset
471 return;
e34bc00733d1 Truffle/Instrumentation: an Advanced Instrument can now be created that requires the evaluation result be of a specified type, reporting a failure if not
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21355
diff changeset
472 }
21358
19801a65cf57 Truffle/Instrumentation: NPE guard
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21356
diff changeset
473 if (result == null) {
19801a65cf57 Truffle/Instrumentation: NPE guard
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21356
diff changeset
474 throw new RuntimeException("Instrument result null: " + requiredResultType.getSimpleName() + " is required");
19801a65cf57 Truffle/Instrumentation: NPE guard
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21356
diff changeset
475 }
19801a65cf57 Truffle/Instrumentation: NPE guard
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21356
diff changeset
476 if (!(requiredResultType.isAssignableFrom(result.getClass()))) {
21356
e34bc00733d1 Truffle/Instrumentation: an Advanced Instrument can now be created that requires the evaluation result be of a specified type, reporting a failure if not
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21355
diff changeset
477 throw new RuntimeException("Instrument result " + result.toString() + " not assignable to " + requiredResultType.getSimpleName());
e34bc00733d1 Truffle/Instrumentation: an Advanced Instrument can now be created that requires the evaluation result be of a specified type, reporting a failure if not
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21355
diff changeset
478 }
e34bc00733d1 Truffle/Instrumentation: an Advanced Instrument can now be created that requires the evaluation result be of a specified type, reporting a failure if not
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21355
diff changeset
479 }
e34bc00733d1 Truffle/Instrumentation: an Advanced Instrument can now be created that requires the evaluation result be of a specified type, reporting a failure if not
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21355
diff changeset
480
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
481 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
482 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
483 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
484 }
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 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
488 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
489 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
490 }
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
491 }
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
492
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
493 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
494 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
495 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
496 }
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
497 }
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
498
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
499 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
500 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
501 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
502 }
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
503 }
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
504 }
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
505
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
506 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
507 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
508 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
509
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
510 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
511
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
512 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
513
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
514 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
515 super(instrumentInfo);
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
516 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
517 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
518
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
519 @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
520 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
521 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
522 }
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 @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
525 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
526 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
527 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
528 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
529 // 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
530 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
531 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
532 // 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
533 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
534 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
535 if (!found) {
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
536 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
537 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
538 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
539 }
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
540
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
541 @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
542 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
543
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
544 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
545
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
546 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
547 super(nextNode);
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
548 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
549 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
550
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
551 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
552 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
553 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
554 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
555 }
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
556 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
557 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
558 }
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 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
562 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
563 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
564 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
565 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
566
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
567 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
568 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
569 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
570 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
571 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
572
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
573 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
574 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
575 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
576 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
577 }
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
578
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
579 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
580 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
581 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
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 }
15450
be0c151d912b Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15279
diff changeset
584 }
be0c151d912b Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15279
diff changeset
585
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
586 @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
587 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
588
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
589 @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
590
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
591 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
592 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
593 }
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
18985
867058575979 Truffle: Improved support for "probing" AST nodes:
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18485
diff changeset
595 @Override
867058575979 Truffle: Improved support for "probing" AST nodes:
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18485
diff changeset
596 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
597 return false;
867058575979 Truffle: Improved support for "probing" AST nodes:
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18485
diff changeset
598 }
867058575979 Truffle: Improved support for "probing" AST nodes:
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18485
diff changeset
599
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 /**
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 * 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
602 */
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 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
604 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
605 }
15450
be0c151d912b Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15279
diff changeset
606
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 /**
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 * 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
609 * 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
610 * 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
611 * 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
612 * 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
613 */
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 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
615 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
616 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
617 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
618 }
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
619 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
620 // 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
621 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
622 // 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
623 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
624 } 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
625 // 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
626 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
627 }
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
628 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
629 }
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
630 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
631 }
15450
be0c151d912b Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15279
diff changeset
632
19645
10a1fc5e3209 Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
633 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
634 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
635 }
15450
be0c151d912b Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15279
diff changeset
636 }
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
637 }