Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Instrument.java @ 21557:31fc2fce38f3
Merge.
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 27 May 2015 13:32:18 +0200 |
parents | 36285949c1d5 |
children |
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 |
19652
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
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.*; |
19825
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:
19652
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.*; |
19825
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:
19652
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:
20900
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:
20900
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 /** |
20900
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:
20894
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> |
20900
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:
20894
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:
20894
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:
20894
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> |
20900
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:
20894
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:
20900
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:
20900
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> |
20900
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:
20894
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:
20894
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:
20894
diff
changeset
|
50 * an AST must be cloned along with the AST: AST clones are not permitted to share Nodes. |
19825
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:
19652
diff
changeset
|
51 * <p> |
20900
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:
20894
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:
20894
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:
20894
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:
20894
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> |
20900
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:
20894
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:
20894
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:
20894
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> |
20900
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:
20894
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> |
20900
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:
20894
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:
20894
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:
20900
diff
changeset
|
66 * |
20900
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:
20894
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:
20900
diff
changeset
|
68 * |
20900
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:
20894
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:
20894
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:
20894
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:
20900
diff
changeset
|
72 * |
20900
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:
20894
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:
20900
diff
changeset
|
74 * |
20900
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:
20894
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:
20894
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:
20894
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:
20894
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:
20900
diff
changeset
|
79 * |
20900
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:
20894
diff
changeset
|
80 * <li>When a new Instrument (for example an instance of {@link SimpleInstrument} is attached to a |
ca13a009e38b
Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20894
diff
changeset
|
81 * Probe, the Instrument inserts a new instance of its private Node type, |
ca13a009e38b
Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20894
diff
changeset
|
82 * {@link SimpleInstrument.SimpleInstrumentNode}, into <em>each of the instrument chains</em> |
ca13a009e38b
Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20894
diff
changeset
|
83 * managed by the Probe, i.e. one node instance per existing clone of the AST.</li> |
20908
f166d264af9f
Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20900
diff
changeset
|
84 * |
20900
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:
20894
diff
changeset
|
85 * <li>If an Instrument is attached to a Probe in an AST that subsequently gets cloned, then the |
ca13a009e38b
Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20894
diff
changeset
|
86 * Instrument's private Node type will be cloned along with the rest of the the AST.</li> |
ca13a009e38b
Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20894
diff
changeset
|
87 * <li>Each Instrument's private Node type is a dynamic inner class whose only state is in the |
ca13a009e38b
Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20894
diff
changeset
|
88 * shared (outer) Instrument instance; that state includes a reference to the Instrument's listener. |
18485
e3c95cbbb50c
Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
18131
diff
changeset
|
89 * </li> |
20908
f166d264af9f
Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20900
diff
changeset
|
90 * |
20900
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:
20894
diff
changeset
|
91 * <li>When an Instrument that has been attached to a Probe is {@linkplain #dispose() disposed}, the |
ca13a009e38b
Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20894
diff
changeset
|
92 * Instrument searches every instrument chain associated with the Probe and removes the instance of |
ca13a009e38b
Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20894
diff
changeset
|
93 * its private Node type.</li> |
20908
f166d264af9f
Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20900
diff
changeset
|
94 * |
20900
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:
20894
diff
changeset
|
95 * <li>Attaching and disposing an Instrument at a Probe <em>deoptimizes</em> any compilations of the |
ca13a009e38b
Truffle/Instrumentation: Javadoc on Instrument now includes more thorough notes describing the implementation; client-oriented notes have been rewritten into a documentation page: https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20894
diff
changeset
|
96 * AST.</li> |
20908
f166d264af9f
Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20900
diff
changeset
|
97 * |
18485
e3c95cbbb50c
Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
18131
diff
changeset
|
98 * </ul> |
15450
be0c151d912b
Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
15279
diff
changeset
|
99 * |
be0c151d912b
Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
15279
diff
changeset
|
100 * @see Probe |
19825
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:
19652
diff
changeset
|
101 * @see TruffleEvents |
15279
0c6d8a08e31b
Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
102 */ |
19652
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
103 public abstract class Instrument { |
15450
be0c151d912b
Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
15279
diff
changeset
|
104 |
18485
e3c95cbbb50c
Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
18131
diff
changeset
|
105 /** |
21181
78a4b44420cf
Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20909
diff
changeset
|
106 * Creates a <em>Simple Instrument</em>: this Instrument routes execution events to a |
78a4b44420cf
Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20909
diff
changeset
|
107 * client-provided listener. |
18485
e3c95cbbb50c
Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
18131
diff
changeset
|
108 * |
21181
78a4b44420cf
Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20909
diff
changeset
|
109 * @param listener a listener for execution events |
78a4b44420cf
Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20909
diff
changeset
|
110 * @param instrumentInfo optional description of the instrument's role, intended for debugging. |
18485
e3c95cbbb50c
Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
18131
diff
changeset
|
111 * @return a new instrument, ready for attachment at a probe |
e3c95cbbb50c
Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
18131
diff
changeset
|
112 */ |
20892
73b1844b5b14
Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20888
diff
changeset
|
113 public static Instrument create(SimpleInstrumentListener listener, String instrumentInfo) { |
73b1844b5b14
Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20888
diff
changeset
|
114 return new SimpleInstrument(listener, instrumentInfo); |
15450
be0c151d912b
Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
15279
diff
changeset
|
115 } |
be0c151d912b
Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
15279
diff
changeset
|
116 |
18485
e3c95cbbb50c
Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
18131
diff
changeset
|
117 /** |
21181
78a4b44420cf
Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20909
diff
changeset
|
118 * Creates a <em>Standard Instrument</em>: this Instrument routes execution events, together |
78a4b44420cf
Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20909
diff
changeset
|
119 * with access to Truffle execution state, to a client-provided listener. |
19825
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:
19652
diff
changeset
|
120 * |
21181
78a4b44420cf
Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20909
diff
changeset
|
121 * @param standardListener a listener for execution events and execution state |
78a4b44420cf
Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20909
diff
changeset
|
122 * @param instrumentInfo optional description of the instrument's role, intended for debugging. |
19825
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:
19652
diff
changeset
|
123 * @return a new instrument, ready for attachment at a probe |
18485
e3c95cbbb50c
Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
18131
diff
changeset
|
124 */ |
20893
263ab98b3bf0
Truffle/Instrumentation: rename ASTInstrumentListener to StandardInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20892
diff
changeset
|
125 public static Instrument create(StandardInstrumentListener standardListener, String instrumentInfo) { |
263ab98b3bf0
Truffle/Instrumentation: rename ASTInstrumentListener to StandardInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20892
diff
changeset
|
126 return new StandardInstrument(standardListener, instrumentInfo); |
15450
be0c151d912b
Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
15279
diff
changeset
|
127 } |
be0c151d912b
Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
15279
diff
changeset
|
128 |
20106
2e3cc2a27711
Truffle/Instrumentation: a new flavor of Instrument that lazily provides an AST fragment to be attached/adopted directly into a running AST, and to which execution event notifications will be routed. Important use cases so far include conditional breakpoints (with optimizeable conditions) and Ruby set_trace_func.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19825
diff
changeset
|
129 /** |
21353
876e710523c5
Truffle/Instrumentation: rename "Tool Eval" Instrument kind to "Advanced" Instrument kind
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
21302
diff
changeset
|
130 * Creates an <em>Advanced Instrument</em>: this Instrument executes efficiently, subject to |
21181
78a4b44420cf
Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20909
diff
changeset
|
131 * full Truffle optimization, a client-provided AST fragment every time the Probed node is |
78a4b44420cf
Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20909
diff
changeset
|
132 * entered. |
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
|
133 * <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
|
134 * 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
|
135 * 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:
19825
diff
changeset
|
136 * |
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
|
137 * @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
|
138 * @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
|
139 * @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
|
140 * 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
|
141 * @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
|
142 * @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:
19825
diff
changeset
|
143 */ |
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
|
144 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
|
145 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:
19825
diff
changeset
|
146 } |
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:
19825
diff
changeset
|
147 |
19652
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
148 // 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
|
149 /** |
19652
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
150 * 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
|
151 */ |
19652
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
152 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:
19521
diff
changeset
|
153 return new TruffleOptInstrument(listener, null); |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
154 } |
15450
be0c151d912b
Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
15279
diff
changeset
|
155 |
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
|
156 /** |
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 * 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
|
158 */ |
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 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
|
160 |
19825
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:
19652
diff
changeset
|
161 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
|
162 |
19652
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
163 /** |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
164 * Optional documentation, mainly for debugging. |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
165 */ |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
166 private final String instrumentInfo; |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
167 |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
168 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
|
169 this.instrumentInfo = instrumentInfo; |
15450
be0c151d912b
Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
15279
diff
changeset
|
170 } |
be0c151d912b
Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
15279
diff
changeset
|
171 |
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
|
172 /** |
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
|
173 * 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
|
174 * 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
|
175 */ |
78a4b44420cf
Truffle/Instrumentation: rename the "SplicedNode" Instrument kind to the "ToolEval" instrument kind, along with some redesign based on earlier feedback.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20909
diff
changeset
|
176 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
|
177 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
|
178 } |
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 * 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
|
182 * 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
|
183 * |
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 * @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
|
185 */ |
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 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
|
187 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
|
188 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
|
189 } |
e3c95cbbb50c
Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
18131
diff
changeset
|
190 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
|
191 // 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
|
192 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
|
193 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
|
194 } |
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 this.isDisposed = true; |
15450
be0c151d912b
Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
15279
diff
changeset
|
196 } |
be0c151d912b
Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
15279
diff
changeset
|
197 |
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
|
198 /** |
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 * 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
|
200 */ |
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
|
201 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
|
202 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
|
203 } |
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 * 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
|
207 */ |
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 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
|
209 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
|
210 } |
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 |
19825
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:
19652
diff
changeset
|
212 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
|
213 |
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
|
214 /** |
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
|
215 * 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
|
216 */ |
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 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
|
218 |
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 /** |
20892
73b1844b5b14
Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20888
diff
changeset
|
220 * 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
|
221 */ |
20892
73b1844b5b14
Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20888
diff
changeset
|
222 private static final class SimpleInstrument extends Instrument { |
19652
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
223 |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
224 /** |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
225 * Tool-supplied listener for events. |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
226 */ |
20892
73b1844b5b14
Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20888
diff
changeset
|
227 private final SimpleInstrumentListener simpleListener; |
19652
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
228 |
20892
73b1844b5b14
Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20888
diff
changeset
|
229 private SimpleInstrument(SimpleInstrumentListener simpleListener, String instrumentInfo) { |
19652
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
230 super(instrumentInfo); |
20892
73b1844b5b14
Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20888
diff
changeset
|
231 this.simpleListener = simpleListener; |
19652
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
232 } |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
233 |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
234 @Override |
19825
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:
19652
diff
changeset
|
235 AbstractInstrumentNode addToChain(AbstractInstrumentNode nextNode) { |
20892
73b1844b5b14
Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20888
diff
changeset
|
236 return new SimpleInstrumentNode(nextNode); |
19652
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
237 } |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
238 |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
239 @Override |
19825
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:
19652
diff
changeset
|
240 AbstractInstrumentNode removeFromChain(AbstractInstrumentNode instrumentNode) { |
19652
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
241 boolean found = false; |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
242 if (instrumentNode != null) { |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
243 if (instrumentNode.getInstrument() == this) { |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
244 // 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:
19825
diff
changeset
|
245 return instrumentNode.nextInstrumentNode; |
19652
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
246 } |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
247 // Match not at the head of the chain; remove it. |
20892
73b1844b5b14
Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20888
diff
changeset
|
248 found = instrumentNode.removeFromChain(SimpleInstrument.this); |
19652
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
249 } |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
250 if (!found) { |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
251 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:
19521
diff
changeset
|
252 } |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
253 return instrumentNode; |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
254 } |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
255 |
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
|
256 /** |
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 * 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
|
258 */ |
19652
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
259 @NodeInfo(cost = NodeCost.NONE) |
20892
73b1844b5b14
Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20888
diff
changeset
|
260 private final class SimpleInstrumentNode extends AbstractInstrumentNode { |
19652
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
261 |
20892
73b1844b5b14
Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20888
diff
changeset
|
262 private SimpleInstrumentNode(AbstractInstrumentNode nextNode) { |
19652
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
263 super(nextNode); |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
264 } |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
265 |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
266 public void enter(Node node, VirtualFrame vFrame) { |
20892
73b1844b5b14
Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20888
diff
changeset
|
267 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:
19825
diff
changeset
|
268 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:
19825
diff
changeset
|
269 nextInstrumentNode.enter(node, vFrame); |
19652
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
270 } |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
271 } |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
272 |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
273 public void returnVoid(Node node, VirtualFrame vFrame) { |
20892
73b1844b5b14
Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20888
diff
changeset
|
274 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:
19825
diff
changeset
|
275 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:
19825
diff
changeset
|
276 nextInstrumentNode.returnVoid(node, vFrame); |
19652
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
277 } |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
278 } |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
279 |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
280 public void returnValue(Node node, VirtualFrame vFrame, Object result) { |
20892
73b1844b5b14
Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20888
diff
changeset
|
281 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:
19825
diff
changeset
|
282 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:
19825
diff
changeset
|
283 nextInstrumentNode.returnValue(node, vFrame, result); |
19652
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
284 } |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
285 } |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
286 |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
287 public void returnExceptional(Node node, VirtualFrame vFrame, Exception exception) { |
20892
73b1844b5b14
Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20888
diff
changeset
|
288 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:
19825
diff
changeset
|
289 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:
19825
diff
changeset
|
290 nextInstrumentNode.returnExceptional(node, vFrame, exception); |
19652
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
291 } |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
292 } |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
293 |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
294 public String instrumentationInfo() { |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
295 final String info = getInstrumentInfo(); |
20892
73b1844b5b14
Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20888
diff
changeset
|
296 return info != null ? info : simpleListener.getClass().getSimpleName(); |
19825
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:
19652
diff
changeset
|
297 } |
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:
19652
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:
19652
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:
19652
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:
19652
diff
changeset
|
301 /** |
20893
263ab98b3bf0
Truffle/Instrumentation: rename ASTInstrumentListener to StandardInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20892
diff
changeset
|
302 * An instrument that propagates events to an instance of {@link StandardInstrumentListener}. |
19825
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:
19652
diff
changeset
|
303 */ |
20893
263ab98b3bf0
Truffle/Instrumentation: rename ASTInstrumentListener to StandardInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20892
diff
changeset
|
304 private static final class StandardInstrument extends Instrument { |
19825
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:
19652
diff
changeset
|
305 |
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:
19652
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:
19652
diff
changeset
|
307 * 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:
19652
diff
changeset
|
308 */ |
20893
263ab98b3bf0
Truffle/Instrumentation: rename ASTInstrumentListener to StandardInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20892
diff
changeset
|
309 private final StandardInstrumentListener standardListener; |
19825
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:
19652
diff
changeset
|
310 |
20893
263ab98b3bf0
Truffle/Instrumentation: rename ASTInstrumentListener to StandardInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20892
diff
changeset
|
311 private StandardInstrument(StandardInstrumentListener standardListener, String instrumentInfo) { |
19825
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:
19652
diff
changeset
|
312 super(instrumentInfo); |
20893
263ab98b3bf0
Truffle/Instrumentation: rename ASTInstrumentListener to StandardInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20892
diff
changeset
|
313 this.standardListener = standardListener; |
19825
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:
19652
diff
changeset
|
314 } |
907128d02b31
Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19652
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:
19652
diff
changeset
|
316 @Override |
907128d02b31
Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19652
diff
changeset
|
317 AbstractInstrumentNode addToChain(AbstractInstrumentNode nextNode) { |
20893
263ab98b3bf0
Truffle/Instrumentation: rename ASTInstrumentListener to StandardInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20892
diff
changeset
|
318 return new StandardInstrumentNode(nextNode); |
19825
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:
19652
diff
changeset
|
319 } |
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:
19652
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:
19652
diff
changeset
|
321 @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:
19652
diff
changeset
|
322 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:
19652
diff
changeset
|
323 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:
19652
diff
changeset
|
324 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:
19652
diff
changeset
|
325 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:
19652
diff
changeset
|
326 // 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:
19825
diff
changeset
|
327 return instrumentNode.nextInstrumentNode; |
19825
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:
19652
diff
changeset
|
328 } |
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:
19652
diff
changeset
|
329 // Match not at the head of the chain; remove it. |
20893
263ab98b3bf0
Truffle/Instrumentation: rename ASTInstrumentListener to StandardInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20892
diff
changeset
|
330 found = instrumentNode.removeFromChain(StandardInstrument.this); |
19825
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:
19652
diff
changeset
|
331 } |
907128d02b31
Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19652
diff
changeset
|
332 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:
19652
diff
changeset
|
333 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:
19652
diff
changeset
|
334 } |
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:
19652
diff
changeset
|
335 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:
19652
diff
changeset
|
336 } |
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:
19652
diff
changeset
|
337 |
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
|
338 /** |
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 * 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
|
340 */ |
19825
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:
19652
diff
changeset
|
341 @NodeInfo(cost = NodeCost.NONE) |
20893
263ab98b3bf0
Truffle/Instrumentation: rename ASTInstrumentListener to StandardInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20892
diff
changeset
|
342 private final class StandardInstrumentNode extends AbstractInstrumentNode { |
19825
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:
19652
diff
changeset
|
343 |
20893
263ab98b3bf0
Truffle/Instrumentation: rename ASTInstrumentListener to StandardInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20892
diff
changeset
|
344 private StandardInstrumentNode(AbstractInstrumentNode nextNode) { |
19825
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:
19652
diff
changeset
|
345 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:
19652
diff
changeset
|
346 } |
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:
19652
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:
19652
diff
changeset
|
348 public void enter(Node node, VirtualFrame vFrame) { |
20893
263ab98b3bf0
Truffle/Instrumentation: rename ASTInstrumentListener to StandardInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20892
diff
changeset
|
349 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:
19825
diff
changeset
|
350 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:
19825
diff
changeset
|
351 nextInstrumentNode.enter(node, vFrame); |
19825
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:
19652
diff
changeset
|
352 } |
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:
19652
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:
19652
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:
19652
diff
changeset
|
355 public void returnVoid(Node node, VirtualFrame vFrame) { |
20893
263ab98b3bf0
Truffle/Instrumentation: rename ASTInstrumentListener to StandardInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20892
diff
changeset
|
356 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:
19825
diff
changeset
|
357 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:
19825
diff
changeset
|
358 nextInstrumentNode.returnVoid(node, vFrame); |
19825
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:
19652
diff
changeset
|
359 } |
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:
19652
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:
19652
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:
19652
diff
changeset
|
362 public void returnValue(Node node, VirtualFrame vFrame, Object result) { |
20893
263ab98b3bf0
Truffle/Instrumentation: rename ASTInstrumentListener to StandardInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20892
diff
changeset
|
363 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:
19825
diff
changeset
|
364 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:
19825
diff
changeset
|
365 nextInstrumentNode.returnValue(node, vFrame, result); |
19825
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:
19652
diff
changeset
|
366 } |
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:
19652
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:
19652
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:
19652
diff
changeset
|
369 public void returnExceptional(Node node, VirtualFrame vFrame, Exception exception) { |
20893
263ab98b3bf0
Truffle/Instrumentation: rename ASTInstrumentListener to StandardInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20892
diff
changeset
|
370 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:
19825
diff
changeset
|
371 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:
19825
diff
changeset
|
372 nextInstrumentNode.returnExceptional(node, vFrame, exception); |
19825
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:
19652
diff
changeset
|
373 } |
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:
19652
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:
19652
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:
19652
diff
changeset
|
376 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:
19652
diff
changeset
|
377 final String info = getInstrumentInfo(); |
20893
263ab98b3bf0
Truffle/Instrumentation: rename ASTInstrumentListener to StandardInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20892
diff
changeset
|
378 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
|
379 } |
19652
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
380 } |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
381 } |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
382 |
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:
19825
diff
changeset
|
383 /** |
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
|
384 * 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
|
385 * 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
|
386 * 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:
19825
diff
changeset
|
387 */ |
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
|
388 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:
19825
diff
changeset
|
389 |
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
|
390 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
|
391 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
|
392 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:
19825
diff
changeset
|
393 |
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
|
394 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:
19825
diff
changeset
|
395 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
|
396 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
|
397 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
|
398 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:
19825
diff
changeset
|
399 } |
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:
19825
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:
19825
diff
changeset
|
401 @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:
19825
diff
changeset
|
402 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
|
403 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:
19825
diff
changeset
|
404 } |
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:
19825
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:
19825
diff
changeset
|
406 @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:
19825
diff
changeset
|
407 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:
19825
diff
changeset
|
408 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:
19825
diff
changeset
|
409 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:
19825
diff
changeset
|
410 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:
19825
diff
changeset
|
411 // 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:
19825
diff
changeset
|
412 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:
19825
diff
changeset
|
413 } |
2e3cc2a27711
Truffle/Instrumentation: a new flavor of Instrument that lazily provides an AST fragment to be attached/adopted directly into a running AST, and to which execution event notifications will be routed. Important use cases so far include conditional breakpoints (with optimizeable conditions) and Ruby set_trace_func.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19825
diff
changeset
|
414 // 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
|
415 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:
19825
diff
changeset
|
416 } |
2e3cc2a27711
Truffle/Instrumentation: a new flavor of Instrument that lazily provides an AST fragment to be attached/adopted directly into a running AST, and to which execution event notifications will be routed. Important use cases so far include conditional breakpoints (with optimizeable conditions) and Ruby set_trace_func.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19825
diff
changeset
|
417 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:
19825
diff
changeset
|
418 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:
19825
diff
changeset
|
419 } |
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:
19825
diff
changeset
|
420 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:
19825
diff
changeset
|
421 } |
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:
19825
diff
changeset
|
422 |
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
|
423 /** |
21353
876e710523c5
Truffle/Instrumentation: rename "Tool Eval" Instrument kind to "Advanced" Instrument kind
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
21302
diff
changeset
|
424 * 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
|
425 */ |
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:
19825
diff
changeset
|
426 @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
|
427 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:
19825
diff
changeset
|
428 |
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
|
429 @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:
19825
diff
changeset
|
430 |
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
|
431 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:
19825
diff
changeset
|
432 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:
19825
diff
changeset
|
433 } |
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:
19825
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:
19825
diff
changeset
|
435 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
|
436 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
|
437 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
|
438 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
|
439 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
|
440 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
|
441 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
|
442 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
|
443 } |
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 } 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
|
445 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
|
446 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
|
447 } |
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:
19825
diff
changeset
|
448 } |
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:
19825
diff
changeset
|
449 } |
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
|
450 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
|
451 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
|
452 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
|
453 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
|
454 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
|
455 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
|
456 } |
575032310b2c
Truffle/Instrumentation: runtime failures executing an AdvancedInstrument root are now reported automatically via a new mehtod onAdvancedInstrumentResultListener.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
21353
diff
changeset
|
457 } 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
|
458 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
|
459 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
|
460 } |
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 } |
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:
19825
diff
changeset
|
462 } |
2e3cc2a27711
Truffle/Instrumentation: a new flavor of Instrument that lazily provides an AST fragment to be attached/adopted directly into a running AST, and to which execution event notifications will be routed. Important use cases so far include conditional breakpoints (with optimizeable conditions) and Ruby set_trace_func.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19825
diff
changeset
|
463 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:
19825
diff
changeset
|
464 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:
19825
diff
changeset
|
465 } |
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:
19825
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:
19825
diff
changeset
|
467 |
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
|
468 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
|
469 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
|
470 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
|
471 } |
21358
19801a65cf57
Truffle/Instrumentation: NPE guard
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
21356
diff
changeset
|
472 if (result == null) { |
19801a65cf57
Truffle/Instrumentation: NPE guard
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
21356
diff
changeset
|
473 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
|
474 } |
19801a65cf57
Truffle/Instrumentation: NPE guard
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
21356
diff
changeset
|
475 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
|
476 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
|
477 } |
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 |
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:
19825
diff
changeset
|
480 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:
19825
diff
changeset
|
481 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:
19825
diff
changeset
|
482 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:
19825
diff
changeset
|
483 } |
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:
19825
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:
19825
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:
19825
diff
changeset
|
486 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:
19825
diff
changeset
|
487 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:
19825
diff
changeset
|
488 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:
19825
diff
changeset
|
489 } |
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:
19825
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:
19825
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:
19825
diff
changeset
|
492 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:
19825
diff
changeset
|
493 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:
19825
diff
changeset
|
494 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:
19825
diff
changeset
|
495 } |
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:
19825
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:
19825
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:
19825
diff
changeset
|
498 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:
19825
diff
changeset
|
499 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
|
500 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:
19825
diff
changeset
|
501 } |
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:
19825
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:
19825
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:
19825
diff
changeset
|
504 |
19652
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
505 public interface TruffleOptListener { |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
506 void notifyIsCompiled(boolean isCompiled); |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
507 } |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
508 |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
509 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:
19521
diff
changeset
|
510 |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
511 private final TruffleOptListener toolOptListener; |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
512 |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
513 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:
19521
diff
changeset
|
514 super(instrumentInfo); |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
515 this.toolOptListener = listener; |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
516 } |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
517 |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
518 @Override |
19825
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:
19652
diff
changeset
|
519 AbstractInstrumentNode addToChain(AbstractInstrumentNode nextNode) { |
19652
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
520 return new TruffleOptInstrumentNode(nextNode); |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
521 } |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
522 |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
523 @Override |
19825
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:
19652
diff
changeset
|
524 AbstractInstrumentNode removeFromChain(AbstractInstrumentNode instrumentNode) { |
19652
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
525 boolean found = false; |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
526 if (instrumentNode != null) { |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
527 if (instrumentNode.getInstrument() == this) { |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
528 // 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:
19825
diff
changeset
|
529 return instrumentNode.nextInstrumentNode; |
19652
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
530 } |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
531 // 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:
19521
diff
changeset
|
532 found = instrumentNode.removeFromChain(TruffleOptInstrument.this); |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
533 } |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
534 if (!found) { |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
535 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:
19521
diff
changeset
|
536 } |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
537 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
|
538 } |
19652
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
539 |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
540 @NodeInfo(cost = NodeCost.NONE) |
19825
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:
19652
diff
changeset
|
541 private final class TruffleOptInstrumentNode extends AbstractInstrumentNode { |
19652
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
542 |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
543 private boolean isCompiled; |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
544 |
19825
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:
19652
diff
changeset
|
545 private TruffleOptInstrumentNode(AbstractInstrumentNode nextNode) { |
19652
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
546 super(nextNode); |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
547 this.isCompiled = CompilerDirectives.inCompiledCode(); |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
548 } |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
549 |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
550 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:
19521
diff
changeset
|
551 if (this.isCompiled != CompilerDirectives.inCompiledCode()) { |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
552 this.isCompiled = CompilerDirectives.inCompiledCode(); |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
553 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:
19521
diff
changeset
|
554 } |
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:
19825
diff
changeset
|
555 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:
19825
diff
changeset
|
556 nextInstrumentNode.enter(node, vFrame); |
19652
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
557 } |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
558 } |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
559 |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
560 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:
19825
diff
changeset
|
561 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:
19825
diff
changeset
|
562 nextInstrumentNode.returnVoid(node, vFrame); |
19652
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
563 } |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
564 } |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
565 |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
566 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:
19825
diff
changeset
|
567 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:
19825
diff
changeset
|
568 nextInstrumentNode.returnValue(node, vFrame, result); |
19652
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
569 } |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
570 } |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
571 |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
572 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:
19825
diff
changeset
|
573 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:
19825
diff
changeset
|
574 nextInstrumentNode.returnExceptional(node, vFrame, exception); |
19652
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
575 } |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
576 } |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
577 |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
578 public String instrumentationInfo() { |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
579 final String info = getInstrumentInfo(); |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
580 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:
19521
diff
changeset
|
581 } |
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
|
582 } |
15450
be0c151d912b
Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
15279
diff
changeset
|
583 } |
be0c151d912b
Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
15279
diff
changeset
|
584 |
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
|
585 @NodeInfo(cost = NodeCost.NONE) |
19825
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:
19652
diff
changeset
|
586 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
|
587 |
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:
19825
diff
changeset
|
588 @Child protected AbstractInstrumentNode nextInstrumentNode; |
19825
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:
19652
diff
changeset
|
589 |
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:
19652
diff
changeset
|
590 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:
19825
diff
changeset
|
591 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
|
592 } |
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 |
18985
867058575979
Truffle: Improved support for "probing" AST nodes:
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
18485
diff
changeset
|
594 @Override |
867058575979
Truffle: Improved support for "probing" AST nodes:
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
18485
diff
changeset
|
595 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
|
596 return false; |
867058575979
Truffle: Improved support for "probing" AST nodes:
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
18485
diff
changeset
|
597 } |
867058575979
Truffle: Improved support for "probing" AST nodes:
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
18485
diff
changeset
|
598 |
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
|
599 /** |
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 * 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
|
601 */ |
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 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
|
603 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
|
604 } |
15450
be0c151d912b
Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
15279
diff
changeset
|
605 |
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
|
606 /** |
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 * 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
|
608 * 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
|
609 * 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
|
610 * 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
|
611 * 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
|
612 */ |
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 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
|
614 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:
19825
diff
changeset
|
615 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
|
616 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
|
617 } |
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:
19825
diff
changeset
|
618 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
|
619 // 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:
19825
diff
changeset
|
620 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
|
621 // 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:
19825
diff
changeset
|
622 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
|
623 } 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
|
624 // 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:
19825
diff
changeset
|
625 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
|
626 } |
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 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
|
628 } |
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:
19825
diff
changeset
|
629 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
|
630 } |
15450
be0c151d912b
Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
15279
diff
changeset
|
631 |
19652
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
632 protected String getInstrumentInfo() { |
10a1fc5e3209
Truffle/Instrumentation: new, experimental kind of Instrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19521
diff
changeset
|
633 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
|
634 } |
15450
be0c151d912b
Truffle/Instrumentation: API revisions
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
15279
diff
changeset
|
635 } |
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
|
636 } |